def rhevm_push_image_upload(self, target_image_id, provider, credentials): provider_data = self.get_dynamic_provider_data(provider) if provider_data is None: raise ImageFactoryException( "RHEV-M instance not found in XML or JSON provided") self.generic_decode_credentials(credentials, provider_data, "rhevm") self.log.debug("Username: %s" % (self.username)) helper = RHEVMHelper(url=provider_data['api-url'], username=self.username, password=self.password) # Image is always here and it is the target_image datafile input_image = self.builder.target_image.data rhevm_uuid = helper.import_template( input_image, provider_data['nfs-host'], provider_data['nfs-path'], provider_data['nfs-dir'], provider_data['cluster'], ovf_name=str(self.new_image_id), ovf_desc="Template name (%s) from base image (%s)" % (self.tdlobj.name, str(self.builder.base_image.identifier))) if rhevm_uuid is None: raise ImageFactoryException( "Failed to obtain RHEV-M UUID from helper") self.log.debug("New RHEVM Template UUID: %s " % (rhevm_uuid)) self.builder.provider_image.identifier_on_provider = rhevm_uuid self.builder.provider_image.provider_account_identifier = self.username self.percent_complete = 100
def delete_from_provider(self, builder, provider, credentials, target, parameters): self.log.debug("Deleting RHEVM template (%s)" % (self.builder.provider_image.identifier_on_provider)) provider_data = self.get_dynamic_provider_data(provider) if provider_data is None: raise ImageFactoryException("RHEV-M instance not found in local configuration file /etc/imagefactory/rhevm.json or as XML or JSON") self.generic_decode_credentials(credentials, provider_data, "rhevm") self.log.debug("Username: %s" % (self.username)) helper = RHEVMHelper(url=provider_data['api-url'], username=self.username, password=self.password) if not helper.delete_template(self.builder.provider_image.identifier_on_provider): raise ImageFactoryException("Delete of template failed")
def rhevm_push_image_upload(self, target_image_id, provider, credentials): provider_data = self.get_dynamic_provider_data(provider) if provider_data is None: raise ImageFactoryException("RHEV-M instance not found in local configuration file /etc/imagefactory/rhevm.json or as XML or JSON") self.generic_decode_credentials(credentials, provider_data, "rhevm") self.log.debug("Username: %s" % (self.username)) helper = RHEVMHelper(url=provider_data['api-url'], username=self.username, password=self.password) # Image is always here and it is the target_image datafile input_image = self.builder.target_image.data rhevm_uuid = helper.import_template(input_image, provider_data['nfs-host'], provider_data['nfs-path'], provider_data['nfs-dir'], provider_data['cluster'], ovf_name=str(self.new_image_id), ovf_desc = "Template name (%s) from base image (%s)" % (self.tdlobj.name, str(self.builder.base_image.identifier)) ) if rhevm_uuid is None: raise ImageFactoryException("Failed to obtain RHEV-M UUID from helper") self.log.debug("New RHEVM Template UUID: %s " % (rhevm_uuid)) self.builder.provider_image.identifier_on_provider = rhevm_uuid self.builder.provider_image.provider_account_identifier = self.username self.percent_complete = 100