'prepare a registry for instantiation'

def prepare_registry(self):

    options = self.config.to_option_list(ascommalist='labels')
    cmd = ['registry']
    cmd.extend(options)
    cmd.extend(['--dry-run=True', '-o', 'json'])
    results = self.openshift_cmd(cmd, oadm=True, output=True, output_type='json')
    if ((results['returncode'] != 0) and ('items' not in results['results'])):
        raise RegistryException('Could    not    perform    registry    preparation.    {}'.format(results))
    service = None
    deploymentconfig = None
    for res in results['results']['items']:
        if (res['kind'] == 'DeploymentConfig'):
            deploymentconfig = DeploymentConfig(res)
        elif (res['kind'] == 'Service'):
            service = Service(res)
    if ((not service) or (not deploymentconfig)):
        return results
    deploymentconfig = DeploymentConfig(self.add_modifications(deploymentconfig))
    if self.svc_ip:
        service.put('spec.clusterIP', self.svc_ip)
    if self.portal_ip:
        service.put('spec.portalIP', self.portal_ip)
    if self.service:
        service.put('spec.selector', self.service.get_selector())
    service_file = Utils.create_tmp_file_from_contents('service', service.yaml_dict)
    deployment_file = Utils.create_tmp_file_from_contents('deploymentconfig', deploymentconfig.yaml_dict)
    return {'service': service, 'service_file': service_file, 'service_update': False, 'deployment': deploymentconfig, 'deployment_file': deployment_file, 'deployment_update': False}
