Exemple #1
0
def read_ovf_settings(ovf_file):
    """
    Reads given ovf template configuration file, returns a dictionary
    of settings.
    """
    settings = {}

    settings["template_name"] = os.path.splitext(os.path.basename(ovf_file.path))[0]

    vm_type = ovfutil.get_vm_type(ovf_file)
    if vm_type != "openvz":
        raise RuntimeError("Given template is not compatible with OpenVZ on OpenNode server")
    settings["vm_type"] = vm_type

    memory_settings = [
        ("memory_min", ovfutil.get_ovf_min_memory_gb(ovf_file)),
        ("memory", ovfutil.get_ovf_normal_memory_gb(ovf_file)),
        ("memory_max", ovfutil.get_ovf_max_memory_gb(ovf_file))]

    # set only those settings that are explicitly specified in the ovf file (non-null)
    settings.update(dict(filter(operator.itemgetter(1), memory_settings)))

    vcpu_settings = [
        ("vcpu_min", ovfutil.get_ovf_min_vcpu(ovf_file)),
        ("vcpu", ovfutil.get_ovf_normal_vcpu(ovf_file)),
        ("vcpu_max", ovfutil.get_ovf_max_vcpu(ovf_file))]
    # set only those settings that are explicitly specified in the ovf file (non-null)
    settings.update(dict(filter(operator.itemgetter(1), vcpu_settings)))

    settings["ostemplate"] = ovfutil.get_ovf_os_type(ovf_file)

    # TODO: apparently need to check disks also?
    return settings
Exemple #2
0
def read_ovf_settings(ovf_file):
    """
    Reads given ovf template configuration file, returns a dictionary
    of settings.
    """
    settings = {}

    settings["template_name"] = os.path.splitext(
        os.path.basename(ovf_file.path))[0]

    vm_type = ovfutil.get_vm_type(ovf_file)
    if vm_type != "openvz":
        raise RuntimeError(
            "Given template is not compatible with OpenVZ on OpenNode server")
    settings["vm_type"] = vm_type

    memory_settings = [("memory_min", ovfutil.get_ovf_min_memory_gb(ovf_file)),
                       ("memory", ovfutil.get_ovf_normal_memory_gb(ovf_file)),
                       ("memory_max", ovfutil.get_ovf_max_memory_gb(ovf_file))]

    # set only those settings that are explicitly specified in the ovf file (non-null)
    settings.update(dict(filter(operator.itemgetter(1), memory_settings)))

    vcpu_settings = [("vcpu_min", ovfutil.get_ovf_min_vcpu(ovf_file)),
                     ("vcpu", ovfutil.get_ovf_normal_vcpu(ovf_file)),
                     ("vcpu_max", ovfutil.get_ovf_max_vcpu(ovf_file))]
    # set only those settings that are explicitly specified in the ovf file (non-null)
    settings.update(dict(filter(operator.itemgetter(1), vcpu_settings)))

    settings["ostemplate"] = ovfutil.get_ovf_os_type(ovf_file)

    # TODO: apparently need to check disks also?
    return settings
Exemple #3
0
def read_ovf_settings(settings, ovf_file):
    """
    Parses OVF template/appliance XML configuration and save parsed settings.

    @return: Parsed OVF template/appliance XML configuration settings
    @rtype: Dictionary
    """

    settings["template_name"] = path.splitext(path.basename(ovf_file.path))[0]

    sys_type, sys_arch = ovfutil.get_vm_type(ovf_file).split("-")
    if sys_type != "kvm":
        raise TemplateException(
            "The chosen template '%s' cannot run on KVM hypervisor." %
            sys_type)
    if sys_arch not in ["x86_64", "i686"]:
        raise TemplateException(
            "Template architecture '%s' is not supported." % sys_arch)
    settings["arch"] = sys_arch

    memory_settings = [("memory_min", ovfutil.get_ovf_min_memory_gb(ovf_file)),
                       ("memory", ovfutil.get_ovf_normal_memory_gb(ovf_file)),
                       ("memory_max", ovfutil.get_ovf_max_memory_gb(ovf_file))]
    # set only those settings that are explicitly specified in the ovf file (non-null)
    settings.update(dict(filter(operator.itemgetter(1), memory_settings)))

    vcpu_settings = [("vcpu_min", ovfutil.get_ovf_min_vcpu(ovf_file)),
                     ("vcpu_normal", ovfutil.get_ovf_normal_vcpu(ovf_file)),
                     ("vcpu_max", ovfutil.get_ovf_max_vcpu(ovf_file))]
    # set only those settings that are explicitly specified in the ovf file (non-null)
    settings.update(dict(filter(operator.itemgetter(1), vcpu_settings)))

    network_list = ovfutil.get_networks(ovf_file)
    for network in network_list:
        settings["interfaces"].append({
            "type": "bridge",
            "source_bridge": network["sourceName"]
        })

    settings["disks"] = ovfutil.get_disks(ovf_file)
    settings["features"] = ovfutil.get_openode_features(ovf_file)
    settings['passwd'] = ovfutil.get_root_password(ovf_file)
    settings['username'] = ovfutil.get_admin_username(ovf_file)

    return settings
Exemple #4
0
def read_ovf_settings(settings, ovf_file):
    """
    Parses OVF template/appliance XML configuration and save parsed settings.

    @return: Parsed OVF template/appliance XML configuration settings
    @rtype: Dictionary
    """

    settings["template_name"] = path.splitext(path.basename(ovf_file.path))[0]

    sys_type, sys_arch = ovfutil.get_vm_type(ovf_file).split("-")
    if sys_type != "kvm":
        raise TemplateException("The chosen template '%s' cannot run on KVM hypervisor." % sys_type)
    if sys_arch not in ["x86_64", "i686"]:
        raise TemplateException("Template architecture '%s' is not supported." % sys_arch)
    settings["arch"] = sys_arch

    memory_settings = [
        ("memory_min", ovfutil.get_ovf_min_memory_gb(ovf_file)),
        ("memory", ovfutil.get_ovf_normal_memory_gb(ovf_file)),
        ("memory_max", ovfutil.get_ovf_max_memory_gb(ovf_file))]
    # set only those settings that are explicitly specified in the ovf file (non-null)
    settings.update(dict(filter(operator.itemgetter(1), memory_settings)))

    vcpu_settings = [
        ("vcpu_min", ovfutil.get_ovf_min_vcpu(ovf_file)),
        ("vcpu_normal", ovfutil.get_ovf_normal_vcpu(ovf_file)),
        ("vcpu_max", ovfutil.get_ovf_max_vcpu(ovf_file))]
    # set only those settings that are explicitly specified in the ovf file (non-null)
    settings.update(dict(filter(operator.itemgetter(1), vcpu_settings)))

    network_list = ovfutil.get_networks(ovf_file)
    for network in network_list:
        settings["interfaces"].append({"type": "bridge", "source_bridge": network["sourceName"]})

    settings["disks"] = ovfutil.get_disks(ovf_file)
    settings["features"] = ovfutil.get_openode_features(ovf_file)
    settings['passwd'] = ovfutil.get_root_password(ovf_file)
    settings['username'] = ovfutil.get_admin_username(ovf_file) or 'root'

    return settings