Exemplo n.º 1
0
 def exec_task(self, auth, ctx, appliance_entry, image_store, group_id, \
                             image_name, platform, force):
     local_node = Basic.local_node
     if appliance_entry["type"].lower() == "xva":
         return xva.import_appliance(auth,local_node, appliance_entry, \
                                     image_store, group_id, image_name, \
                                     platform, force, None)
     else:
         return ImageUtils.import_fs(auth,local_node, appliance_entry, \
                                     image_store, group_id, image_name, \
                                     platform, force, None)
Exemplo n.º 2
0
 def exec_task(self, auth, ctx, appliance_entry, image_store, group_id, \
                             image_name, platform, force):
     local_node = Basic.local_node
     if appliance_entry["type"].lower() == "xva":
         return xva.import_appliance(auth,local_node, appliance_entry, \
                                     image_store, group_id, image_name, \
                                     platform, force, None)
     else:
         return ImageUtils.import_fs(auth,local_node, appliance_entry, \
                                     image_store, group_id, image_name, \
                                     platform, force, None)
Exemplo n.º 3
0
def import_appliance(auth,local, appliance_entry, image_store, image_group_id,\
                                image_name, platform, force, progress=None):

    # TODO :
    # image_store.validate_image_name(image_name)
    appliance_url = appliance_entry["href"]

    image_dir = image_store._get_location(image_name)

    if not local.node_proxy.file_exists(image_dir):
        mkdir2(local, image_dir)

    # fetch the image
    filename = appliance_entry.get("filename")
    ###DIRTY FIX... need to check which transaction is going on
    import transaction
    transaction.commit()
    downloaded_filename = ImageUtils.download_appliance(
        local, appliance_url, image_dir, filename, progress)

    #Make the image entry into the database after the appliance is downloaded.
    #so that database and image store filesystem will be in sync
    #for image_group in image_store.get_image_groups(auth).values():
    #  if image_store.image_exists_by_name(image_name):
    #    raise Exception("Image "+image_name+" already exists.")
    image = image_store.create_image(auth, image_group_id, image_name,
                                     platform)

    # gunzip/unzip if required
    ImageUtils.open_package(local, downloaded_filename, image_dir, progress)

    # get ova / xva information from the package
    (ova_location, full_appliance_dir, appliance_dir) = search_ova(image_dir)
    (cfg, hacks, vbds, vdis) = get_ova_info(ova_location)

    # create disk from the chunks
    disk_info = create_disks(local, full_appliance_dir, vbds, vdis, progress)

    # get rid of the hacks
    appliance_entry["is_hvm"] = hacks["is_hvm"]
    cfg["extra"] = hacks["kernel_boot_cmdline"]

    vm_template = ImageUtils.get_vm_conf_template(local, appliance_entry, cfg,
                                                  disk_info)
    image_conf = ImageUtils.get_image_config(local, appliance_entry, disk_info,
                                             image_dir)

    ImageUtils.create_files(local, appliance_entry, image_store,
                            image_group_id, image, vm_template, image_conf,
                            force)
    return True
Exemplo n.º 4
0
def import_appliance(auth,local, appliance_entry, image_store, image_group_id,\
                                image_name, platform, force, progress=None): 

  # TODO :
  # image_store.validate_image_name(image_name)
  appliance_url = appliance_entry["href"]

  image_dir = image_store._get_location(image_name)

  if not local.node_proxy.file_exists(image_dir):
    mkdir2(local, image_dir)

  # fetch the image
  filename = appliance_entry.get("filename")
  ###DIRTY FIX... need to check which transaction is going on
  import transaction
  transaction.commit()  
  downloaded_filename = ImageUtils.download_appliance(local,appliance_url,
                                                      image_dir, filename,
                                                      progress)

  #Make the image entry into the database after the appliance is downloaded.
  #so that database and image store filesystem will be in sync
  #for image_group in image_store.get_image_groups(auth).values():
#  if image_store.image_exists_by_name(image_name):
#    raise Exception("Image "+image_name+" already exists.")
  image = image_store.create_image(auth,image_group_id, image_name, platform) 

  # gunzip/unzip if required
  ImageUtils.open_package(local, downloaded_filename, image_dir, progress)

  # get ova / xva information from the package
  (ova_location, full_appliance_dir, appliance_dir) = search_ova(image_dir)
  (cfg, hacks, vbds, vdis) = get_ova_info(ova_location)

  # create disk from the chunks
  disk_info = create_disks(local, full_appliance_dir, vbds, vdis, progress)

  # get rid of the hacks
  appliance_entry["is_hvm"] = hacks["is_hvm"]
  cfg["extra"] = hacks["kernel_boot_cmdline"]

  vm_template = ImageUtils.get_vm_conf_template(local, appliance_entry,
                                                cfg, disk_info)
  image_conf  = ImageUtils.get_image_config(local, appliance_entry, disk_info,
                                            image_dir)

  ImageUtils.create_files(local, appliance_entry,
                          image_store,image_group_id, image,
                          vm_template, image_conf, force)
  return True