Пример #1
0
def preload_image_to_esx(url, glance_id, sizes, version):
    esxi_hosts = getattr(testbed, 'esxi_hosts', None)
    if not esxi_hosts:
        return
    for esxi in esxi_hosts.values():
        if esxi['contrail_vm']['host'] in env.roledefs['compute']:
            apply_esxi_defaults(esxi)
            # for havana(2013.2), images are stored under datastore/vmware_base/
            base = esxi['datastore'] + 'vmware_base/'
            # for icehouse, images are stored under datstore/<ip>_base/<glanceid>/
            if '2014.1' in version:
                ip = esxi['contrail_vm']['host'].split('@')[-1]
                base = esxi['datastore'] + ip + '_base/' + glance_id + '/'

            with settings(host_string=esxi['username'] + '@' + esxi['ip'],
                          password=esxi['password'],
                          warn_only=True,
                          shell='/bin/sh -l -c'):
                run('mkdir -p %s' % base)
                with cd(base):
                    run('wget -O ' + glance_id + '-sparse.vmdk.gz ' + url)
                    run('gunzip ' + glance_id + '-sparse.vmdk.gz')
                    run('vmkfstools -i ' + glance_id + '-sparse.vmdk -a ide ' +
                        glance_id + '.vmdk')

                    run('rm ' + glance_id + '-sparse.vmdk')
                    for size in sizes:
                        run('vmkfstools -i ' + glance_id + '.vmdk -a ide ' +
                            glance_id + '.' + str(size) + '.vmdk')
                        run('vmkfstools -X ' + str(size) + 'G ' + glance_id +
                            '.' + str(size) + '.vmdk')
Пример #2
0
def preload_image_to_esx(url, glance_id, sizes, version):
    esxi_hosts = getattr(testbed, 'esxi_hosts', None)
    if not esxi_hosts:
        return
    for esxi in esxi_hosts.values():
        if esxi['contrail_vm']['host'] in env.roledefs['compute']:
            apply_esxi_defaults(esxi)
            # for havana(2013.2), images are stored under datastore/vmware_base/
            base = esxi['datastore'] + 'vmware_base/'
            # for icehouse, images are stored under datstore/<ip>_base/<glanceid>/
            if '2014.1' in version:
                ip = esxi['contrail_vm']['host'].split('@')[-1]
                base = esxi['datastore'] + ip + '_base/' + glance_id + '/'

            with settings(host_string = esxi['username'] + '@' + esxi['ip'],
                          password = esxi['password'], warn_only=True,
                          shell = '/bin/sh -l -c'):
                 run('mkdir -p %s' % base)
                 with cd(base):
                      run('wget -O ' + glance_id + '-sparse.vmdk.gz ' + url)
                      run('gunzip ' + glance_id + '-sparse.vmdk.gz')
                      run('vmkfstools -i ' + glance_id + '-sparse.vmdk -a ide ' + glance_id + '.vmdk')

                      run('rm ' + glance_id + '-sparse.vmdk')
                      for size in sizes:
                          run('vmkfstools -i ' + glance_id + '.vmdk -a ide ' + glance_id + '.' + str(size) + '.vmdk')
                          run('vmkfstools -X ' + str(size) + 'G ' + glance_id + '.' + str(size) + '.vmdk')
def frame_vnc_compute_cmd(host_string, cmd='setup-vnc-compute',
                          manage_nova_compute='yes', configure_nova='yes'):
    orch = get_orchestrator()
    ncontrols = len(env.roledefs['control'])
    cfgm_host = get_control_host_string(env.roledefs['cfgm'][0])
    cfgm_ip = get_contrail_internal_vip() or hstr_to_ip(cfgm_host)
    cfgm_user = env.roledefs['cfgm'][0].split('@')[0]
    cfgm_passwd = get_env_passwords(env.roledefs['cfgm'][0])
    compute_host = get_control_host_string(host_string)
    (tgt_ip, tgt_gw) = get_data_ip(host_string)
    metadata_secret = get_metadata_secret()

    compute_mgmt_ip= host_string.split('@')[1]
    compute_control_ip= hstr_to_ip(compute_host)

    amqp_server_ip = get_contrail_amqp_server()
    # Using amqp running in openstack node
    if (get_from_testbed_dict('openstack', 'manage_amqp', 'no') == 'yes' or
        get_from_testbed_dict('openstack', 'amqp_host', None)):
        amqp_server_ip = get_openstack_amqp_server()
    cpu_mode = get_nova_cpu_mode()
    cpu_model = get_nova_cpu_model()

    # Frame the command line to provision compute node.
    cmd += " --self_ip %s" % compute_control_ip
    cmd += " --cfgm_ip %s" % cfgm_ip
    cmd += " --cfgm_user %s" % cfgm_user
    cmd += " --cfgm_passwd %s" % cfgm_passwd
    cmd += " --ncontrols %s" % ncontrols
    cmd += " --amqp_server_ip %s" % amqp_server_ip
    cmd += " --service_token %s" % get_service_token()
    cmd += " --orchestrator %s" % get_orchestrator()
    cmd += " --hypervisor %s" % get_hypervisor(host_string)
    haproxy = get_haproxy()
    if haproxy:
        cmd += " --haproxy %s" % haproxy

    if tgt_ip != compute_mgmt_ip:
        cmd += " --non_mgmt_ip %s" % tgt_ip
        cmd += " --non_mgmt_gw %s" % tgt_gw

    if orch == 'openstack':
        openstack_mgmt_ip = hstr_to_ip(env.roledefs['openstack'][0])
        authserver_ip = get_authserver_ip()
        ks_auth_protocol = get_authserver_protocol()
        ks_auth_port = get_authserver_port()
        ks_admin_user, ks_admin_password = get_authserver_credentials()
        cmd += " --keystone_ip %s" % authserver_ip
        cmd += " --openstack_mgmt_ip %s" % openstack_mgmt_ip
        cmd += " --keystone_auth_protocol %s" % ks_auth_protocol
        cmd += " --keystone_auth_port %s" % ks_auth_port
        cmd += " --quantum_service_protocol %s" % get_quantum_service_protocol()
        cmd += " --keystone_admin_user %s" % ks_admin_user
        cmd += " --keystone_admin_password %s" % ks_admin_password
        cmd += " --nova_password %s" % get_nova_password()
        cmd += " --neutron_password %s" % get_neutron_password()
        cmd += " --service_tenant_name %s" % get_keystone_service_tenant_name()
        if cpu_mode is not None:
            cmd += " --cpu_mode %s" % cpu_mode
            if cpu_mode == 'custom':
                if cpu_model is None:
                    raise Exception('cpu model is required for custom cpu mode')
                cmd += " --cpu_model %s" % cpu_model

    # Add metadata_secret if available
    if metadata_secret:
        cmd += " --metadata_secret %s" % metadata_secret

    # HA arguments
    internal_vip = get_openstack_internal_vip()
    if internal_vip:
        # Highly availbale setup
        cmd += " --internal_vip %s" % internal_vip
    external_vip = get_from_testbed_dict('ha', 'external_vip', None)
    if external_vip:
        cmd += ' --external_vip %s' % external_vip
    if manage_nova_compute == 'no':
        cmd = cmd + "  --no_contrail_openstack"
    contrail_internal_vip = get_contrail_internal_vip()
    if contrail_internal_vip:
        # Highly availbale setup with mulitple interfaces
        cmd += " --contrail_internal_vip %s" % contrail_internal_vip
    if internal_vip or contrail_internal_vip:
        cmd += " --mgmt_self_ip %s" % compute_mgmt_ip

    if configure_nova == 'no':
        cmd = cmd + "  --no_nova_config"

    # Simple Gateway(vgw) arguments
    (set_vgw, gateway_routes, public_subnet, public_vn_name, vgw_intf_list) = get_vgw_details(host_string)
    if set_vgw:
        cmd += " --vgw_public_subnet %s" % str([(';'.join(str(e) for e in public_subnet)).replace(" ","")])
        cmd += " --vgw_public_vn_name %s" % str([(';'.join(str(e) for e in public_vn_name)).replace(" ","")])
        cmd += " --vgw_intf_list %s" % str([(';'.join(str(e) for e in vgw_intf_list)).replace(" ","")])
        if gateway_routes:
            cmd += " --vgw_gateway_routes %s" % str([(';'.join(str(e) for e in gateway_routes)).replace(" ","")])

    if 'vcenter_compute' in env.roledefs:
        compute_host = 'root' + '@' + compute_mgmt_ip
        if compute_host in env.roledefs['vcenter_compute'][:]:
            vcenter_info = getattr(env, 'vcenter', None)
            if compute_mgmt_ip == vcenter_info['vcenter_compute']:
                cmd += " --vcenter_server %s" % vcenter_info['server']
                cmd += " --vcenter_username %s" % vcenter_info['username']
                cmd += " --vcenter_password %s" % vcenter_info['password']
                cluster_list = vcenter_info['cluster']
                cluster_list_now = "" 
                for cluster in cluster_list:
                     cluster_list_now += cluster
                     cluster_list_now += ","
                cluster_list_now = cluster_list_now.rstrip(',')
                cmd += " --vcenter_cluster %s" % cluster_list_now 
                cmd += " --vcenter_dvswitch %s" % vcenter_info['dv_switch']['dv_switch_name']    

    # Contrail with vmware as orchestrator
    esxi_data = get_vmware_details(host_string)
    if esxi_data:
        apply_esxi_defaults(esxi_data)
        cmd += " --vmware %s" % esxi_data['ip']
        cmd += " --vmware_username %s" % esxi_data['username']
        cmd += " --vmware_passwd %s" % esxi_data['password']
        cmd += " --vmware_vmpg_vswitch %s" % esxi_data['vm_vswitch']
        if orch is 'vcenter':
            # Setting mtu when vmware is orchestrator
            mtu = "1500"
            cmd += " --vmware_vmpg_vswitch_mtu %s" % mtu
        else:
            cmd += " --vmware_vmpg_vswitch_mtu %s" % esxi_data['vm_vswitch_mtu']
        cmd += " --mode %s" % get_mode(env.host_string) 

    dpdk = getattr(env, 'dpdk', None)
    if dpdk:
        if env.host_string in dpdk:
            cmd += " --dpdk"

    return cmd
Пример #4
0
def frame_vnc_compute_cmd(host_string,
                          cmd='setup-vnc-compute',
                          manage_nova_compute='yes',
                          configure_nova='yes'):
    orch = get_orchestrator()
    cfgm_host = get_control_host_string(env.roledefs['cfgm'][0])
    cfgm_ip = get_contrail_internal_vip() or hstr_to_ip(cfgm_host)
    cfgm_user = env.roledefs['cfgm'][0].split('@')[0]
    cfgm_passwd = get_env_passwords(env.roledefs['cfgm'][0])
    compute_host = get_control_host_string(host_string)
    (tgt_ip, tgt_gw) = get_data_ip(host_string)
    metadata_secret = get_metadata_secret()

    compute_mgmt_ip = host_string.split('@')[1]
    compute_control_ip = hstr_to_ip(compute_host)

    amqp_server_ip = get_contrail_amqp_server()
    # Using amqp running in openstack node
    if (get_from_testbed_dict('openstack', 'manage_amqp', 'no') == 'yes'
            or get_from_testbed_dict('openstack', 'amqp_host', None)):
        amqp_server_ip = get_openstack_amqp_server()
    cpu_mode = get_nova_cpu_mode()
    cpu_model = get_nova_cpu_model()

    # Frame the command line to provision compute node.
    cmd += " --self_ip %s" % compute_control_ip
    cmd += " --cfgm_ip %s" % cfgm_ip
    cmd += " --cfgm_user %s" % cfgm_user
    cmd += " --cfgm_passwd %s" % cfgm_passwd
    cmd += " --amqp_server_ip %s" % amqp_server_ip
    cmd += " --service_token %s" % get_service_token()
    cmd += " --orchestrator %s" % get_orchestrator()
    cmd += " --hypervisor %s" % get_hypervisor(host_string)
    collector_host_list = []
    for entry in env.roledefs['collector']:
        collector_host_list.append(hstr_to_ip(get_control_host_string(entry)))
    cmd += ' --collectors %s' % ' '.join(collector_host_list)
    control_host_list = []
    for entry in env.roledefs['control']:
        control_host_list.append(hstr_to_ip(get_control_host_string(entry)))
    cmd += ' --control-nodes %s' % ' '.join(control_host_list)

    haproxy = get_haproxy()
    if haproxy:
        cmd += " --haproxy %s" % haproxy

    if tgt_ip != compute_mgmt_ip:
        cmd += " --non_mgmt_ip %s" % tgt_ip
        cmd += " --non_mgmt_gw %s" % tgt_gw

    if orch == 'openstack':
        openstack_mgmt_ip = hstr_to_ip(env.roledefs['openstack'][0])
        openstack_ctrl_ip = hstr_to_ip(
            get_control_host_string(env.roledefs['openstack'][0]))
        authserver_ip = get_authserver_ip()
        ks_auth_protocol = get_authserver_protocol()
        ks_auth_port = get_authserver_port()
        ks_admin_user, ks_admin_password = get_authserver_credentials()
        cmd += " --keystone_ip %s" % authserver_ip
        cmd += " --keystone_version %s" % get_keystone_version()
        cmd += " --openstack_mgmt_ip %s" % openstack_mgmt_ip
        cmd += " --openstack_ctrl_ip %s" % openstack_ctrl_ip
        cmd += " --keystone_auth_protocol %s" % ks_auth_protocol
        cmd += " --keystone_auth_port %s" % ks_auth_port
        cmd += " --quantum_service_protocol %s" % get_quantum_service_protocol(
        )
        cmd += " --keystone_admin_user %s" % ks_admin_user
        cmd += " --keystone_admin_password %s" % ks_admin_password
        cmd += " --nova_password %s" % get_nova_password()
        cmd += " --neutron_password %s" % get_neutron_password()
        cmd += " --service_tenant_name %s" % get_keystone_service_tenant_name()
        cmd += " --region_name %s" % get_region_name()
        if cpu_mode is not None:
            cmd += " --cpu_mode %s" % cpu_mode
            if cpu_mode == 'custom':
                if cpu_model is None:
                    raise Exception(
                        'cpu model is required for custom cpu mode')
                cmd += " --cpu_model %s" % cpu_model

    # Add metadata_secret if available
    if metadata_secret:
        cmd += " --metadata_secret %s" % metadata_secret

    # HA arguments
    internal_vip = get_openstack_internal_vip()
    if internal_vip:
        # Highly availbale setup
        cmd += " --internal_vip %s" % internal_vip
    external_vip = get_from_testbed_dict('ha', 'external_vip', None)
    if external_vip:
        cmd += ' --external_vip %s' % external_vip
    if manage_nova_compute == 'no':
        cmd = cmd + "  --no_contrail_openstack"
    contrail_internal_vip = get_contrail_internal_vip()
    if contrail_internal_vip:
        # Highly availbale setup with mulitple interfaces
        cmd += " --contrail_internal_vip %s" % contrail_internal_vip
    if internal_vip or contrail_internal_vip:
        cmd += " --mgmt_self_ip %s" % compute_mgmt_ip

    if configure_nova == 'no':
        cmd = cmd + "  --no_nova_config"

    # Simple Gateway(vgw) arguments
    (set_vgw, gateway_routes, public_subnet, public_vn_name,
     vgw_intf_list) = get_vgw_details(host_string)
    if set_vgw:
        cmd += " --vgw_public_subnet %s" % str([(';'.join(
            str(e) for e in public_subnet)).replace(" ", "")])
        cmd += " --vgw_public_vn_name %s" % str([(';'.join(
            str(e) for e in public_vn_name)).replace(" ", "")])
        cmd += " --vgw_intf_list %s" % str([(';'.join(
            str(e) for e in vgw_intf_list)).replace(" ", "")])
        if gateway_routes:
            cmd += " --vgw_gateway_routes %s" % str([(';'.join(
                str(e) for e in gateway_routes)).replace(" ", "")])

    # Qos Arguments
    (set_qos, qos_logical_queue, qos_queue_id,
     default_hw_queue) = get_qos_details(host_string)
    if set_qos:
        cmd += " --qos_logical_queue %s" % ' '.join(qos_logical_queue)
        cmd += " --qos_queue_id %s" % ' '.join(qos_queue_id)
        if default_hw_queue:
            cmd += " --default_hw_queue"

    # Qos priority group arguments
    (set_priority, priority_id, priority_bandwidth,
     priority_scheduling) = get_priority_group_details(host_string)
    set_priority = False
    if set_priority:
        cmd += " --priority_id %s" % ' '.join(priority_id)
        cmd += " --priority_scheduling %s" % ' '.join(priority_scheduling)
        cmd += " --priority_bandwidth %s" % ' '.join(priority_bandwidth)

    compute_as_gateway_list = get_compute_as_gateway_list()
    if compute_as_gateway_list:
        cmd += " --gateway_server_list %s" % ' '.join(compute_as_gateway_list)

    sriov_string = get_sriov_details(host_string)
    if sriov_string:
        cmd += " --sriov %s" % sriov_string

    if 'vcenter_compute' in env.roledefs:
        compute_host = 'root' + '@' + compute_mgmt_ip
        if compute_host in env.roledefs['vcenter_compute'][:]:
            vcenter_info = getattr(env, 'vcenter_servers', None)
            for v in vcenter_info.keys():
                vcenter_server = vcenter_info[v]
                datacenters = get_vcenter_datacenters(vcenter_server)
                for dc in datacenters:
                    dc_info = vcenter_server['datacenters'][dc]
                    vcenter_compute_nodes = get_vcenter_compute_nodes(dc_info)
                    if compute_mgmt_ip in vcenter_compute_nodes:
                        vcenter_compute_node = compute_mgmt_ip
                        cmd += " --vcenter_server %s" % vcenter_server['server']
                        cmd += " --vcenter_username %s" % vcenter_server[
                            'username']
                        cmd += " --vcenter_password %s" % vcenter_server[
                            'password']

                        for dvs in dc_info['dv_switches'].keys():
                            dvs_info = dc_info['dv_switches'][dvs]
                            if vcenter_compute_node == dvs_info[
                                    'vcenter_compute']:
                                dv_switch = dvs
                                cluster_list = dvs_info['clusters']
                                break

                        cluster_list_now = ""
                        for cluster in cluster_list:
                            cluster_list_now += cluster
                            cluster_list_now += ","
                        cluster_list_now = cluster_list_now.rstrip(',')
                        cmd += " --vcenter_cluster %s" % cluster_list_now
                        cmd += " --vcenter_dvswitch %s" % dv_switch

    # Contrail with vmware as orchestrator
    esxi_data = get_vmware_details(host_string)
    if esxi_data:
        apply_esxi_defaults(esxi_data)
        datacenter_mtu = get_vcenter_datacenter_mtu(
            esxi_data['vcenter_server'])
        cmd += " --vmware %s" % esxi_data['ip']
        cmd += " --vmware_username %s" % esxi_data['username']
        cmd += " --vmware_passwd %s" % esxi_data['password']
        cmd += " --vmware_vmpg_vswitch %s" % esxi_data['vm_vswitch']
        mode = get_mode(env.host_string)
        cmd += " --mode %s" % mode
        cmd += " --vmware_vmpg_vswitch_mtu %s" % datacenter_mtu
        cmd += " --vmware_datanic_mtu %s" % datacenter_mtu

    dpdk = getattr(env, 'dpdk', None)
    if dpdk:
        if host_string in dpdk:
            cmd += " --dpdk"

    return cmd
Пример #5
0
def frame_vnc_compute_cmd(host_string, cmd='setup-vnc-compute',
                          manage_nova_compute='yes', configure_nova='yes'):
    orch = get_orchestrator()
    cfgm_host = get_control_host_string(env.roledefs['cfgm'][0])
    cfgm_ip = get_contrail_internal_vip() or hstr_to_ip(cfgm_host)
    cfgm_user = env.roledefs['cfgm'][0].split('@')[0]
    cfgm_passwd = get_env_passwords(env.roledefs['cfgm'][0])
    compute_host = get_control_host_string(host_string)
    (tgt_ip, tgt_gw) = get_data_ip(host_string)
    metadata_secret = get_metadata_secret()

    compute_mgmt_ip= host_string.split('@')[1]
    compute_control_ip= hstr_to_ip(compute_host)

    amqp_server_ip = get_contrail_amqp_server()
    # Using amqp running in openstack node
    if (get_from_testbed_dict('openstack', 'manage_amqp', 'no') == 'yes' or
        get_from_testbed_dict('openstack', 'amqp_host', None)):
        amqp_server_ip = get_openstack_amqp_server()
    cpu_mode = get_nova_cpu_mode()
    cpu_model = get_nova_cpu_model()

    # Frame the command line to provision compute node.
    cmd += " --self_ip %s" % compute_control_ip
    cmd += " --cfgm_ip %s" % cfgm_ip
    cmd += " --cfgm_user %s" % cfgm_user
    cmd += " --cfgm_passwd %s" % cfgm_passwd
    cmd += " --amqp_server_ip %s" % amqp_server_ip
    cmd += " --service_token %s" % get_service_token()
    cmd += " --orchestrator %s" % get_orchestrator()
    cmd += " --hypervisor %s" % get_hypervisor(host_string)
    collector_host_list=[]
    for entry in env.roledefs['collector']:
        collector_host_list.append(hstr_to_ip(get_control_host_string(entry)))
    cmd += ' --collectors %s' % ' '.join(collector_host_list)
    control_host_list=[]
    for entry in env.roledefs['control']:
        control_host_list.append(hstr_to_ip(get_control_host_string(entry)))
    cmd += ' --control-nodes %s' % ' '.join(control_host_list)

    haproxy = get_haproxy()
    if haproxy:
        cmd += " --haproxy %s" % haproxy

    if tgt_ip != compute_mgmt_ip:
        cmd += " --non_mgmt_ip %s" % tgt_ip
        cmd += " --non_mgmt_gw %s" % tgt_gw

    if orch == 'openstack':
        openstack_mgmt_ip = hstr_to_ip(env.roledefs['openstack'][0])
        openstack_ctrl_ip = hstr_to_ip(get_control_host_string(env.roledefs['openstack'][0]))
        authserver_ip = get_authserver_ip()
        ks_auth_protocol = get_authserver_protocol()
        ks_auth_port = get_authserver_port()
        ks_admin_user, ks_admin_password = get_authserver_credentials()
        cmd += " --keystone_ip %s" % authserver_ip
        cmd += " --keystone_version %s" % get_keystone_version()
        cmd += " --openstack_mgmt_ip %s" % openstack_mgmt_ip
        cmd += " --openstack_ctrl_ip %s" % openstack_ctrl_ip
        cmd += " --keystone_auth_protocol %s" % ks_auth_protocol
        cmd += " --keystone_auth_port %s" % ks_auth_port
        cmd += " --quantum_service_protocol %s" % get_quantum_service_protocol()
        cmd += " --keystone_admin_user %s" % ks_admin_user
        cmd += " --keystone_admin_password %s" % ks_admin_password
        cmd += " --nova_password %s" % get_nova_password()
        cmd += " --neutron_password %s" % get_neutron_password()
        cmd += " --service_tenant_name %s" % get_keystone_service_tenant_name()
        cmd += " --region_name %s" % get_region_name()
        if cpu_mode is not None:
            cmd += " --cpu_mode %s" % cpu_mode
            if cpu_mode == 'custom':
                if cpu_model is None:
                    raise Exception('cpu model is required for custom cpu mode')
                cmd += " --cpu_model %s" % cpu_model

    # Add metadata_secret if available
    if metadata_secret:
        cmd += " --metadata_secret %s" % metadata_secret

    # HA arguments
    internal_vip = get_openstack_internal_vip()
    if internal_vip:
        # Highly availbale setup
        cmd += " --internal_vip %s" % internal_vip
    external_vip = get_from_testbed_dict('ha', 'external_vip', None)
    if external_vip:
        cmd += ' --external_vip %s' % external_vip
    if manage_nova_compute == 'no':
        cmd = cmd + "  --no_contrail_openstack"
    contrail_internal_vip = get_contrail_internal_vip()
    if contrail_internal_vip:
        # Highly availbale setup with mulitple interfaces
        cmd += " --contrail_internal_vip %s" % contrail_internal_vip
    if internal_vip or contrail_internal_vip:
        cmd += " --mgmt_self_ip %s" % compute_mgmt_ip

    if configure_nova == 'no':
        cmd = cmd + "  --no_nova_config"

    # Simple Gateway(vgw) arguments
    (set_vgw, gateway_routes, public_subnet, public_vn_name, vgw_intf_list) = get_vgw_details(host_string)
    if set_vgw:
        cmd += " --vgw_public_subnet %s" % str([(';'.join(str(e) for e in public_subnet)).replace(" ","")])
        cmd += " --vgw_public_vn_name %s" % str([(';'.join(str(e) for e in public_vn_name)).replace(" ","")])
        cmd += " --vgw_intf_list %s" % str([(';'.join(str(e) for e in vgw_intf_list)).replace(" ","")])
        if gateway_routes:
            cmd += " --vgw_gateway_routes %s" % str([(';'.join(str(e) for e in gateway_routes)).replace(" ","")])

    # Qos Arguments
    (set_qos, qos_logical_queue, qos_queue_id, default_hw_queue) = get_qos_details(host_string)
    if set_qos:
        cmd += " --qos_logical_queue %s" % ' '.join(qos_logical_queue)
        cmd += " --qos_queue_id %s" %  ' '.join(qos_queue_id)
        if default_hw_queue:
            cmd += " --default_hw_queue"

    # Qos priority group arguments
    (set_priority, priority_id, priority_bandwidth, priority_scheduling) = get_priority_group_details(host_string)
    set_priority = False
    if set_priority:
        cmd += " --priority_id %s" % ' '.join(priority_id)
        cmd += " --priority_scheduling %s" % ' '.join(priority_scheduling)
        cmd += " --priority_bandwidth %s" % ' '.join(priority_bandwidth)

    compute_as_gateway_list = get_compute_as_gateway_list()
    if compute_as_gateway_list:
        cmd += " --gateway_server_list %s" % ' '.join(compute_as_gateway_list)

    sriov_string = get_sriov_details(host_string)
    if sriov_string:
        cmd += " --sriov %s" % sriov_string
        
    if 'vcenter_compute' in env.roledefs:
        compute_host = 'root' + '@' + compute_mgmt_ip
        if compute_host in env.roledefs['vcenter_compute'][:]:
            vcenter_info = getattr(env, 'vcenter_servers', None)
            for v in vcenter_info.keys():
                 vcenter_server = vcenter_info[v]
                 datacenters = get_vcenter_datacenters(vcenter_server)
                 for dc in datacenters: 
                     dc_info = vcenter_server['datacenters'][dc]
                     vcenter_compute_nodes = get_vcenter_compute_nodes(dc_info)
                     if compute_mgmt_ip in vcenter_compute_nodes:
                         vcenter_compute_node = compute_mgmt_ip
                         cmd += " --vcenter_server %s" % vcenter_server['server']
                         cmd += " --vcenter_username %s" % vcenter_server['username']
                         cmd += " --vcenter_password %s" % vcenter_server['password']

                         for dvs in dc_info['dv_switches'].keys():
                              dvs_info = dc_info['dv_switches'][dvs]
                              if vcenter_compute_node == dvs_info['vcenter_compute']:
                                  dv_switch = dvs
                                  cluster_list = dvs_info['clusters']
                                  break

                         cluster_list_now = ""
                         for cluster in cluster_list:
                              cluster_list_now += cluster
                              cluster_list_now += ","
                         cluster_list_now = cluster_list_now.rstrip(',')
                         cmd += " --vcenter_cluster %s" % cluster_list_now
                         cmd += " --vcenter_dvswitch %s" % dv_switch

    # Contrail with vmware as orchestrator
    esxi_data = get_vmware_details(host_string)
    if esxi_data:
        apply_esxi_defaults(esxi_data)
        datacenter_mtu = get_vcenter_datacenter_mtu(esxi_data['vcenter_server'])
        cmd += " --vmware %s" % esxi_data['ip']
        cmd += " --vmware_username %s" % esxi_data['username']
        cmd += " --vmware_passwd %s" % esxi_data['password']
        cmd += " --vmware_vmpg_vswitch %s" % esxi_data['vm_vswitch']
        mode = get_mode(env.host_string)
        cmd += " --mode %s" % mode
        cmd += " --vmware_vmpg_vswitch_mtu %s" % datacenter_mtu
        cmd += " --vmware_datanic_mtu %s" % datacenter_mtu

    dpdk = getattr(env, 'dpdk', None)
    if dpdk:
        if host_string in dpdk:
            cmd += " --dpdk"

    return cmd
Пример #6
0
def frame_vnc_compute_cmd(host_string, cmd="setup-vnc-compute", manage_nova_compute="yes", configure_nova="yes"):
    orch = get_orchestrator()
    ncontrols = len(env.roledefs["control"])
    cfgm_host = get_control_host_string(env.roledefs["cfgm"][0])
    cfgm_ip = get_contrail_internal_vip() or hstr_to_ip(cfgm_host)
    cfgm_user = env.roledefs["cfgm"][0].split("@")[0]
    cfgm_passwd = get_env_passwords(env.roledefs["cfgm"][0])
    compute_host = get_control_host_string(host_string)
    (tgt_ip, tgt_gw) = get_data_ip(host_string)
    metadata_secret = get_metadata_secret()

    compute_mgmt_ip = host_string.split("@")[1]
    compute_control_ip = hstr_to_ip(compute_host)

    amqp_server_ip = get_contrail_amqp_server()
    # Using amqp running in openstack node
    if get_from_testbed_dict("openstack", "manage_amqp", "no") == "yes" or get_from_testbed_dict(
        "openstack", "amqp_host", None
    ):
        amqp_server_ip = get_openstack_amqp_server()
    cpu_mode = get_nova_cpu_mode()
    cpu_model = get_nova_cpu_model()

    # Frame the command line to provision compute node.
    cmd += " --self_ip %s" % compute_control_ip
    cmd += " --cfgm_ip %s" % cfgm_ip
    cmd += " --cfgm_user %s" % cfgm_user
    cmd += " --cfgm_passwd %s" % cfgm_passwd
    cmd += " --ncontrols %s" % ncontrols
    cmd += " --amqp_server_ip %s" % amqp_server_ip
    cmd += " --service_token %s" % get_service_token()
    cmd += " --orchestrator %s" % get_orchestrator()
    cmd += " --hypervisor %s" % get_hypervisor(host_string)
    haproxy = get_haproxy()
    if haproxy:
        cmd += " --haproxy %s" % haproxy

    if tgt_ip != compute_mgmt_ip:
        cmd += " --non_mgmt_ip %s" % tgt_ip
        cmd += " --non_mgmt_gw %s" % tgt_gw

    if orch == "openstack":
        openstack_mgmt_ip = hstr_to_ip(env.roledefs["openstack"][0])
        authserver_ip = get_authserver_ip()
        ks_auth_protocol = get_authserver_protocol()
        ks_auth_port = get_authserver_port()
        ks_admin_user, ks_admin_password = get_authserver_credentials()
        cmd += " --keystone_ip %s" % authserver_ip
        cmd += " --keystone_version %s" % get_keystone_version()
        cmd += " --openstack_mgmt_ip %s" % openstack_mgmt_ip
        cmd += " --keystone_auth_protocol %s" % ks_auth_protocol
        cmd += " --keystone_auth_port %s" % ks_auth_port
        cmd += " --quantum_service_protocol %s" % get_quantum_service_protocol()
        cmd += " --keystone_admin_user %s" % ks_admin_user
        cmd += " --keystone_admin_password %s" % ks_admin_password
        cmd += " --nova_password %s" % get_nova_password()
        cmd += " --neutron_password %s" % get_neutron_password()
        cmd += " --service_tenant_name %s" % get_keystone_service_tenant_name()
        cmd += " --region_name %s" % get_region_name()
        if cpu_mode is not None:
            cmd += " --cpu_mode %s" % cpu_mode
            if cpu_mode == "custom":
                if cpu_model is None:
                    raise Exception("cpu model is required for custom cpu mode")
                cmd += " --cpu_model %s" % cpu_model

    # Add metadata_secret if available
    if metadata_secret:
        cmd += " --metadata_secret %s" % metadata_secret

    # HA arguments
    internal_vip = get_openstack_internal_vip()
    if internal_vip:
        # Highly availbale setup
        cmd += " --internal_vip %s" % internal_vip
    external_vip = get_from_testbed_dict("ha", "external_vip", None)
    if external_vip:
        cmd += " --external_vip %s" % external_vip
    if manage_nova_compute == "no":
        cmd = cmd + "  --no_contrail_openstack"
    contrail_internal_vip = get_contrail_internal_vip()
    if contrail_internal_vip:
        # Highly availbale setup with mulitple interfaces
        cmd += " --contrail_internal_vip %s" % contrail_internal_vip
    if internal_vip or contrail_internal_vip:
        cmd += " --mgmt_self_ip %s" % compute_mgmt_ip

    if configure_nova == "no":
        cmd = cmd + "  --no_nova_config"

    # Simple Gateway(vgw) arguments
    (set_vgw, gateway_routes, public_subnet, public_vn_name, vgw_intf_list) = get_vgw_details(host_string)
    if set_vgw:
        cmd += " --vgw_public_subnet %s" % str([(";".join(str(e) for e in public_subnet)).replace(" ", "")])
        cmd += " --vgw_public_vn_name %s" % str([(";".join(str(e) for e in public_vn_name)).replace(" ", "")])
        cmd += " --vgw_intf_list %s" % str([(";".join(str(e) for e in vgw_intf_list)).replace(" ", "")])
        if gateway_routes:
            cmd += " --vgw_gateway_routes %s" % str([(";".join(str(e) for e in gateway_routes)).replace(" ", "")])

    # Qos Arguments
    (set_qos, qos_logical_queue, qos_queue_id, default_hw_queue) = get_qos_details(host_string)
    if set_qos:
        cmd += " --qos_logical_queue %s" % " ".join(qos_logical_queue)
        cmd += " --qos_queue_id %s" % " ".join(qos_queue_id)
        if default_hw_queue:
            cmd += " --default_hw_queue"

    # Qos priority group arguments
    (set_priority, priority_id, priority_bandwidth, priority_scheduling) = get_priority_group_details(host_string)
    set_priority = False
    if set_priority:
        cmd += " --priority_id %s" % " ".join(priority_id)
        cmd += " --priority_scheduling %s" % " ".join(priority_scheduling)
        cmd += " --priority_bandwidth %s" % " ".join(priority_bandwidth)

    compute_as_gateway_list = get_compute_as_gateway_list()
    if compute_as_gateway_list:
        cmd += " --gateway_server_list %s" % " ".join(compute_as_gateway_list)

    sriov_string = get_sriov_details(host_string)
    if sriov_string:
        cmd += " --sriov %s" % sriov_string

    if "vcenter_compute" in env.roledefs:
        compute_host = "root" + "@" + compute_mgmt_ip
        if compute_host in env.roledefs["vcenter_compute"][:]:
            vcenter_info = getattr(env, "vcenter_servers", None)
            for v in vcenter_info.keys():
                vcenter_server = vcenter_info[v]
                if compute_mgmt_ip == vcenter_server["vcenter_compute"]:
                    cmd += " --vcenter_server %s" % vcenter_server["server"]
                    cmd += " --vcenter_username %s" % vcenter_server["username"]
                    cmd += " --vcenter_password %s" % vcenter_server["password"]
                    cluster_list = vcenter_server["cluster"]
                    cluster_list_now = ""
                    for cluster in cluster_list:
                        cluster_list_now += cluster
                        cluster_list_now += ","
                    cluster_list_now = cluster_list_now.rstrip(",")
                    cmd += " --vcenter_cluster %s" % cluster_list_now
                    cmd += " --vcenter_dvswitch %s" % vcenter_server["dv_switch"]["dv_switch_name"]

    # Contrail with vmware as orchestrator
    esxi_data = get_vmware_details(host_string)
    if esxi_data:
        apply_esxi_defaults(esxi_data)
        datacenter_mtu = get_vmware_datacenter_mtu(esxi_data["vcenter_server"])
        cmd += " --vmware %s" % esxi_data["ip"]
        cmd += " --vmware_username %s" % esxi_data["username"]
        cmd += " --vmware_passwd %s" % esxi_data["password"]
        cmd += " --vmware_vmpg_vswitch %s" % esxi_data["vm_vswitch"]
        mode = get_mode(env.host_string)
        cmd += " --mode %s" % mode
        cmd += " --vmware_vmpg_vswitch_mtu %s" % datacenter_mtu
        cmd += " --vmware_datanic_mtu %s" % datacenter_mtu

    dpdk = getattr(env, "dpdk", None)
    if dpdk:
        if host_string in dpdk:
            cmd += " --dpdk"

    return cmd