def vmware_push_image_upload(self, target_image_id, provider, credentials): # BuildDispatcher is now the only location for the logic to map a provider to its data and target provider_data = BuildDispatcher().get_dynamic_provider_data(provider) if provider_data is None: raise ImageFactoryException("VMWare instance not found in local configuration file /etc/imagefactory/vsphere.json or as XML or JSON") if provider_data['target'] != 'vsphere': raise ImageFactoryException("Got a non-vsphere target in the vsphere builder. This should never happen.") self.generic_decode_credentials(credentials, provider_data) # Image is always here and it is the target_image datafile input_image = self.builder.target_image.data # Example of some JSON for westford_esx # {"westford_esx": {"api-url": "https://vsphere.virt.bos.redhat.com/sdk", "username": "******", "password": "******", # "datastore": "datastore1", "network_name": "VM Network" } } vm_name = "factory-image-" + self.new_image_id vm_import = VMImport(provider_data['api-url'], self.username, self.password) vm_import.import_vm(datastore=provider_data['datastore'], network_name = provider_data['network_name'], name=vm_name, disksize_kb = (10*1024*1024 + 2 ), memory=512, num_cpus=1, guest_id='otherLinux64Guest', imagefilename=input_image) self.percent_complete = 100
def vmware_push_image_upload(self, target_image_id, provider, credentials): # BuildDispatcher is now the only location for the logic to map a provider to its data and target provider_data = BuildDispatcher().get_dynamic_provider_data(provider) if provider_data is None: raise ImageFactoryException("VMWare instance not found in local configuration file /etc/imagefactory/vsphere.json or as XML or JSON") if provider_data['target'] != 'vsphere': raise ImageFactoryException("Got a non-vsphere target in the vsphere builder. This should never happen.") self.generic_decode_credentials(credentials, provider_data) # This is where the image should be after a local build input_image = self.app_config['imgdir'] + "/vmware-image-" + target_image_id + ".vmdk" # Grab from Warehouse if it isn't here self.retrieve_image(target_image_id, input_image) # Example of some JSON for westford_esx # {"westford_esx": {"api-url": "https://vsphere.virt.bos.redhat.com/sdk", "username": "******", "password": "******", # "datastore": "datastore1", "network_name": "VM Network" } } vm_name = "factory-image-" + self.new_image_id vm_import = VMImport(provider_data['api-url'], self.username, self.password) vm_import.import_vm(datastore=provider_data['datastore'], network_name = provider_data['network_name'], name=vm_name, disksize_kb = (10*1024*1024 + 2 ), memory=512, num_cpus=1, guest_id='otherLinux64Guest', imagefilename=input_image) # Create the provdier image metadata = dict(target_image=target_image_id, provider=provider_data['name'], icicle="none", target_identifier=vm_name) self.warehouse.create_provider_image(self.new_image_id, metadata=metadata) self.percent_complete = 100