def import_appliance(self, auth, href, type, arch, pae, hvm, size, provider_id, platform, description, link, image_name, group_id, is_manual, date, time): try: is_hvm = 'False' if hvm == 'true': is_hvm = 'True' is_pae = 'False' if pae == 'true': is_pae = 'True' image_name = re.sub(ImageStore.INVALID_CHARS_EXP, '_', image_name) appliance_entry = {} appliance_entry["href"] = href appliance_entry["type"] = type appliance_entry["arch"] = arch appliance_entry["PAE"] = is_pae appliance_entry["is_hvm"] = is_hvm appliance_entry["size"] = size appliance_entry["provider_id"] = provider_id appliance_entry["platform"] = platform appliance_entry["title"] = image_name if appliance_entry["provider_id"].lower() == "jumpbox": appliance_entry["is_hvm"] = "True" p_url = self.appliance_store.get_provider_url(provider_id) appliance_entry["provider_url"] = p_url p_logo_url = self.appliance_store.get_logo_url(provider_id) appliance_entry["provider_logo_url"] = p_logo_url if is_manual == 'true': description = "Manually imported appliance. Plese use 'Edit Description' menu to put appropriate description here." link = "" appliance_entry["description"] = description appliance_entry["link"] = link if self.appliance_store.get_provider(provider_id): appliance_entry[ "provider"] = self.appliance_store.get_provider( provider_id) else: appliance_entry["provider"] = provider_id if image_name: image_name = image_name.strip() platform = appliance_entry["platform"] type = appliance_entry["type"] if type.lower() not in ("xva", "file_system", "jb_archive"): raise Exception( "Invalid Package type %s: supported package types are XVA, FILE_SYSTEM. JB_ARCHIVE" % type) image_store = Basic.getImageStore() #force = False #for image_group in image_store.get_image_groups(auth).values(): if image_store.image_exists_by_name(image_name): img = image_store.get_image_by_name(image_name) image_store.delete_image(auth, group_id, img.get_id()) #image_group = image_store.get_image_groups(auth)[group_id] # Create a new image and add it to the group. #img = image_store.create_image(auth,group_id, image_name, platform.lower()) title = appliance_entry.get("title") if not title: title = "" tc = TaskCreator() tc.import_appliance(auth, appliance_entry, image_store, \ group_id, image_name, platform.lower(),True,date,time) except Exception, e: print_traceback() LOGGER.error(to_str(e).replace("'", "")) raise e