Exemple #1
0
def update_from_local_ovf(vc_swc, enc_svc_cls, template_vm_name=None,
                          target_path=None, ovf_name=None, ova_name=None,
                          ovftool_path=None, source_image_path=None,
                          ovf_image_name=None, user_data_str=None,
                          status_port=ENCRYPTOR_STATUS_PORT):
    guest_vm = None
    mv_vm = None
    if ((source_image_path is None) or
        (ovf_image_name is None)):
        log.error("Metavisor OVF path needs to be specified")
        return
    try:
        guest_vm = launch_guest_vm(vc_swc, template_vm_name, target_path,
                                   ovf_name, ova_name, ovftool_path)
    except Exception as e:
        log.exception("Failed to lauch guest VM (%s)", e)
        if (guest_vm is not None):
            vc_swc.destroy_vm(guest_vm)
        raise
    try:
        log.info("Launching MV VM from local OVF")
        ovf_image_name = ovf_image_name + ".ovf"
        validate_local_mv_ovf(source_image_path, ovf_image_name)
        mv_vm = vc_swc.upload_ovf_to_vcenter(source_image_path,
                                             ovf_image_name)
    except Exception as e:
        log.exception("Failed to launch from metavisor OVF (%s)", e)
        if (mv_vm is not None):
            vc_swc.destroy_vm(mv_vm)
        if (guest_vm is not None):
            vc_swc.destroy_vm(guest_vm)
        raise
    update_ovf_image_mv_vm(vc_swc, enc_svc_cls, guest_vm, mv_vm,
                           template_vm_name, target_path, ovf_name,
                           ova_name, ovftool_path, user_data_str, status_port)
Exemple #2
0
def encrypt_from_local_ovf(vc_swc, enc_svc_cls, guest_vmdk, vm_name=None,
                           create_ovf=False, create_ova=False, target_path=None,
                           image_name=None, ovftool_path=None,
                           source_image_path=None, ovf_image_name=None,
                           user_data_str=None, serial_port_file_name=None,
                           status_port=ENCRYPTOR_STATUS_PORT):
    vm = None
    try:
        if ((source_image_path is None) or
            (ovf_image_name is None)):
            log.error("Metavisor OVF path needs to be specified")
            return
        # Launch OVF
        log.info("Launching VM from local OVF")
        ovf_image_name = ovf_image_name + ".ovf"
        validate_local_mv_ovf(source_image_path, ovf_image_name)
        vm = vc_swc.upload_ovf_to_vcenter(source_image_path, ovf_image_name)
    except Exception as e:
        log.exception("Failed to launch from metavisor OVF (%s)", e)
        if (vm is not None):
            vc_swc.destroy_vm(vm)
        raise
    create_ovf_image_from_mv_vm(vc_swc, enc_svc_cls, vm,
                                guest_vmdk, vm_name,
                                create_ovf, create_ova, target_path,
                                image_name, ovftool_path,
                                user_data_str, serial_port_file_name,
                                status_port)