Пример #1
0
def deploy(ovf_settings, storage_pool):
    """ Deploys OpenVZ container """
    # make sure we have required template present and symlinked
    link_template(storage_pool, ovf_settings["template_name"])

    print "Generating configuration..."
    generate_config(ovf_settings)

    print "Creating OpenVZ container..."
    create_container(ovf_settings)

    print "Deploying..."
    nameservers = ovf_settings.get("nameservers", None)
    if not nameservers:
        nameservers = [ovf_settings["nameserver"]]

    execute("vzctl set %s %s --save" % (ovf_settings["vm_id"], ' '.join('--nameserver %s' % i for i in nameservers)))
    execute("vzctl set %s --ipadd %s --save" % (ovf_settings["vm_id"], ovf_settings["ip_address"]))
    execute("vzctl set %s --hostname %s --save" % (ovf_settings["vm_id"], ovf_settings["hostname"]))
    execute("vzctl set %s --userpasswd root:%s --save" % (ovf_settings["vm_id"], ovf_settings["passwd"]))

    print "Setting up action scripts..."
    setup_scripts(ovf_settings, storage_pool)

    if ovf_settings.get('appliance_type') == 'oms':
        oms.configure_oms_vm(ovf_settings["vm_id"], ovf_settings["hostname"])

    if ovf_settings.get("startvm", 0) == 1:
        execute("vzctl start %s" % (ovf_settings["vm_id"]))

    if ovf_settings.get("onboot", 0) == 1:
        execute("vzctl set %s --onboot yes --save" % (ovf_settings["vm_id"]))

    print "Template %s deployed successfully!" % ovf_settings["vm_id"]
Пример #2
0
def deploy(ovf_settings, storage_pool):
    """ Deploys OpenVZ container """
    log = get_logger()
    # make sure we have required template present and symlinked
    link_template(storage_pool, ovf_settings["template_name"])

    msg = "Generating configuration..."
    log.info(msg)
    generate_config(ovf_settings)

    msg = "Creating OpenVZ container..."
    log.info(msg)
    create_container(ovf_settings)

    msg = "Deploying..."
    log.info(msg)
    nameservers = ovf_settings.get("nameservers", None)
    if not nameservers:
        nameservers = [ovf_settings.get("nameserver", '8.8.8.8')]

    # XXX a hack to set a working dns if NS is malformed for some reason (OMS-444)
    if (type(nameservers) == str and len(nameservers) < 7):
        nameservers = ['8.8.8.8']

    execute("vzctl set %s %s --save" %
            (ovf_settings["vm_id"], ' '.join('--nameserver %s' % i
                                             for i in nameservers)))
    execute("vzctl set %s --ipadd %s --save" %
            (ovf_settings["vm_id"], ovf_settings["ip_address"]))
    execute("vzctl set %s --hostname %s --save" %
            (ovf_settings["vm_id"], ovf_settings["hostname"]))
    if len(ovf_settings['passwd']) > 0:
        execute("vzctl set %s --userpasswd 'root:%s' --save" %
                (ovf_settings["vm_id"], ovf_settings["passwd"]))

    msg = "Setting up action scripts..."
    log.info(msg)
    setup_scripts(ovf_settings, storage_pool)

    if ovf_settings.get('appliance_type') == 'oms':
        oms.configure_oms_vm(ovf_settings["vm_id"], ovf_settings["hostname"])

    if ovf_settings.get("startvm", 0) == 1:
        execute("vzctl start %s" % (ovf_settings["vm_id"]))

    if ovf_settings.get("onboot", 0) == 1:
        execute("vzctl set %s --onboot yes --save" % (ovf_settings["vm_id"]))
    else:
        execute("vzctl set %s --onboot no --save" % (ovf_settings["vm_id"]))

    if ovf_settings.get("ioprio", 4):
        execute("vzctl set %s --ioprio %d --save" %
                (ovf_settings["vm_id"], ovf_settings["ioprio"]))

    msg = "Template %s deployed successfully!" % ovf_settings["vm_id"]
    log.info(msg)
Пример #3
0
def deploy(ovf_settings, storage_pool):
    """ Deploys OpenVZ container """
    log = get_logger()
    # make sure we have required template present and symlinked
    link_template(storage_pool, ovf_settings["template_name"])

    msg = "Generating configuration..."
    log.info(msg)
    generate_config(ovf_settings)

    msg = "Creating OpenVZ container..."
    log.info(msg)
    create_container(ovf_settings)

    msg = "Deploying..."
    log.info(msg)
    nameservers = ovf_settings.get("nameservers", None)
    if not nameservers:
        nameservers = [ovf_settings.get("nameserver", '8.8.8.8')]

    # XXX a hack to set a working dns if NS is malformed for some reason (OMS-444)
    if (type(nameservers) == str and len(nameservers) < 7):
        nameservers = ['8.8.8.8']

    execute("vzctl set %s %s --save" % (ovf_settings["vm_id"],
                                        ' '.join('--nameserver %s' % i for i in nameservers)))
    execute("vzctl set %s --ipadd %s --save" % (ovf_settings["vm_id"], ovf_settings["ip_address"]))
    execute("vzctl set %s --hostname %s --save" % (ovf_settings["vm_id"], ovf_settings["hostname"]))
    if len(ovf_settings['passwd']) > 0:
        execute("vzctl set %s --userpasswd 'root:%s' --save" % (ovf_settings["vm_id"],
                                                                ovf_settings["passwd"]))

    msg = "Setting up action scripts..."
    log.info(msg)
    setup_scripts(ovf_settings, storage_pool)

    if ovf_settings.get('appliance_type') == 'oms':
        oms.configure_oms_vm(ovf_settings["vm_id"], ovf_settings["hostname"])

    if ovf_settings.get("startvm", 0) == 1:
        execute("vzctl start %s" % (ovf_settings["vm_id"]))

    if ovf_settings.get("onboot", 0) == 1:
        execute("vzctl set %s --onboot yes --save" % (ovf_settings["vm_id"]))
    else:
        execute("vzctl set %s --onboot no --save" % (ovf_settings["vm_id"]))

    if ovf_settings.get("ioprio", 4):
        execute("vzctl set %s --ioprio %d --save" % (ovf_settings["vm_id"], ovf_settings["ioprio"]))

    msg = "Template %s deployed successfully!" % ovf_settings["vm_id"]
    log.info(msg)