Beispiel #1
0
def update_from_s3(vc_swc, enc_svc_cls, template_vm_name=None,
                   target_path=None, ovf_name=None, ova_name=None,
                   ovftool_path=None, mv_ovf_name=None,
                   download_file_list=None, user_data_str=None,
                   status_port=ENCRYPTOR_STATUS_PORT):
    guest_vm = None
    mv_vm = None
    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:
        if (mv_ovf_name is None or download_file_list is None):
            log.error("Cannot get metavisor OVF from S3")
            raise Exception("Invalid MV OVF")
        mv_vm = launch_mv_vm_from_s3(vc_swc, mv_ovf_name, download_file_list)
    except Exception as e:
        log.exception("Failed to launch metavisor OVF from S3 (%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)
Beispiel #2
0
def encrypt_from_s3(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,
                    ovf_name=None, download_file_list=None,
                    user_data_str=None, serial_port_file_name=None,
                    status_port=ENCRYPTOR_STATUS_PORT):
    vm = None
    try:
        if (ovf_name is None or download_file_list is None):
            log.error("Cannot get metavisor OVF from S3")
            raise Exception("Invalid MV OVF")
        mv_vm_name = None
        if vc_swc.is_esx_host() is True:
            mv_vm_name = vm_name
        vm = launch_mv_vm_from_s3(vc_swc, ovf_name,
                                  download_file_list, mv_vm_name)
    except Exception as e:
        log.exception("Failed to launch metavisor OVF from S3 (%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)