コード例 #1
0
def get_compute_pkgs(manage_nova_compute='yes'):
    """Returns a list of packages to be installed in the
       compute node.
    """
    ostype = detect_ostype()

    if get_orchestrator() is 'vcenter':
        pkgs = ['contrail-vmware-vrouter']
    else:
        pkgs = ['contrail-openstack-vrouter']

    if ostype in ['ubuntu']:
        # For Ubuntu, Install contrail-vrouter-generic package if one available for
        # node's kernel version or install contrail-vrouter-dkms
        # If dkms is already installed, continue to upgrade contrail-vrouter-dkms
        contrail_vrouter_pkg = get_vrouter_kmod_pkg()

        if env.host_string in getattr(env, 'dpdk', []):
            contrail_vrouter_pkg = 'contrail-vrouter-dpdk-init'
        # This order of installation matters, because in a node with
        # non recommended kernel installed, contrail-vrouter-dkms pkg
        # needs to get installed first before contrail-openstack-vrouter.
        if get_orchestrator() is 'vcenter':
            pkgs = [contrail_vrouter_pkg, 'contrail-vmware-vrouter']
        else:
            pkgs = [contrail_vrouter_pkg, 'contrail-openstack-vrouter']

    # Append only vrouter and contrail vrouter dependent packages
    # no need to append the contrail-openstack-vrouter, which when
    # installed will bring in nova-compute and its dependents.
    if (manage_nova_compute == 'no'
            and ostype in ['centos', 'redhat', 'fedora', 'centoslinux']):
        pkgs = [
            'contrail-vrouter-common',
            'openstack-utils',
        ]
        if get_openstack_sku() in ['juno']:
            pkgs.append('contrail-nova-vif')
    elif (manage_nova_compute == 'no' and ostype in ['ubuntu']):
        pkgs = [contrail_vrouter_pkg, 'contrail-vrouter-common']
        if get_orchestrator() is 'openstack':
            pkgs.append('contrail-nova-vif')
        else:
            pkgs.append('contrail-vmware-vrouter')
    # Append lbaas dependent packages if haproxy is enabled..
    if getattr(testbed, 'haproxy', False):
        pkgs.append('haproxy')

    # Append lbaas dependent packages if Lbaas is enabled..
    if is_lbaas_enabled():
        pkgs.append('haproxy')
        pkgs.append('iproute')

    if ostype == 'ubuntu':
        # Append nova-docker if hypervisor for this compute host is docker.
        if get_hypervisor(env.host_string) == 'docker':
            pkgs.append('nova-docker')

    return pkgs
コード例 #2
0
def get_compute_pkgs(manage_nova_compute='yes'):
    """Returns a list of packages to be installed in the
       compute node.
    """
    ostype = detect_ostype()

    if get_orchestrator() is 'vcenter':
        pkgs = ['contrail-vmware-vrouter']
    else:
        pkgs = ['contrail-openstack-vrouter']

    if ostype in ['ubuntu']:
        # For Ubuntu, Install contrail-vrouter-generic package if one available for
        # node's kernel version or install contrail-vrouter-dkms
        # If dkms is already installed, continue to upgrade contrail-vrouter-dkms
        contrail_vrouter_pkg = get_vrouter_kmod_pkg()

        if env.host_string in getattr(env, 'dpdk', []):
            contrail_vrouter_pkg = 'contrail-vrouter-dpdk-init'
        # This order of installation matters, because in a node with
        # non recommended kernel installed, contrail-vrouter-dkms pkg
        # needs to get installed first before contrail-openstack-vrouter.
        if get_orchestrator() is 'vcenter':
            pkgs = [contrail_vrouter_pkg, 'contrail-vmware-vrouter']
        else:
            pkgs = [contrail_vrouter_pkg, 'contrail-openstack-vrouter']

    # Append only vrouter and contrail vrouter dependent packages
    # no need to append the contrail-openstack-vrouter, which when
    # installed will bring in nova-compute and its dependents.
    if (manage_nova_compute == 'no' and ostype in ['centos', 'redhat', 'fedora', 'centoslinux']):
        pkgs = ['contrail-vrouter-common',
               'openstack-utils',
              ]
        if get_openstack_sku() in ['juno']:
            pkgs.append('contrail-nova-vif')
    elif (manage_nova_compute== 'no' and ostype in ['ubuntu']):
        pkgs = [contrail_vrouter_pkg,
               'contrail-vrouter-common']
	if get_orchestrator() is 'openstack':
            pkgs.append('contrail-nova-vif')
        else:
            pkgs.append('contrail-vmware-vrouter')
    # Append lbaas dependent packages if haproxy is enabled..
    if getattr(testbed, 'haproxy', False):
        pkgs.append('haproxy')

    # Append lbaas dependent packages if Lbaas is enabled..
    if is_lbaas_enabled():
        pkgs.append('haproxy')
        pkgs.append('iproute')

    if ostype == 'ubuntu':
        # Append nova-docker if hypervisor for this compute host is docker.
        if get_hypervisor(env.host_string) == 'docker':
            pkgs.append('nova-docker')

    return pkgs
コード例 #3
0
def get_compute_pkgs(manage_nova_compute="yes"):
    """Returns a list of packages to be installed in the
       compute node.
    """
    ostype = detect_ostype()

    if get_orchestrator() is "vcenter":
        pkgs = ["contrail-vmware-vrouter"]
    else:
        pkgs = ["contrail-openstack-vrouter"]

    if ostype in ["ubuntu"]:
        # For Ubuntu, Install contrail-vrouter-generic package if one available for
        # node's kernel version or install contrail-vrouter-dkms
        # If dkms is already installed, continue to upgrade contrail-vrouter-dkms
        contrail_vrouter_pkg = get_vrouter_kmod_pkg()

        if env.host_string in getattr(env, "dpdk", []):
            contrail_vrouter_pkg = "contrail-vrouter-dpdk-init"
        # This order of installation matters, because in a node with
        # non recommended kernel installed, contrail-vrouter-dkms pkg
        # needs to get installed first before contrail-openstack-vrouter.
        if get_orchestrator() is "vcenter":
            pkgs = [contrail_vrouter_pkg, "contrail-vmware-vrouter"]
        else:
            pkgs = [contrail_vrouter_pkg, "contrail-openstack-vrouter"]

    # Append only vrouter and contrail vrouter dependent packages
    # no need to append the contrail-openstack-vrouter, which when
    # installed will bring in nova-compute and its dependents.
    if manage_nova_compute == "no" and ostype in ["centos", "redhat", "fedora", "centoslinux"]:
        pkgs = ["contrail-vrouter-common", "openstack-utils", "contrail-nova-vif"]
    elif manage_nova_compute == "no" and ostype in ["ubuntu"]:
        pkgs = [contrail_vrouter_pkg, "contrail-vrouter-common"]
        if get_orchestrator() is "openstack":
            pkgs.append("contrail-nova-vif")
        else:
            pkgs.append("contrail-vmware-vrouter")
    # Append lbaas dependent packages if haproxy is enabled..
    if getattr(testbed, "haproxy", False):
        pkgs.append("haproxy")

    # Append lbaas dependent packages if Lbaas is enabled..
    if ostype == "ubuntu" and is_lbaas_enabled():
        pkgs.append("haproxy")
        pkgs.append("iproute")

    if ostype == "ubuntu":
        # Append nova-docker if hypervisor for this compute host is docker.
        if get_hypervisor(env.host_string) == "docker":
            pkgs.append("nova-docker")

    return pkgs
コード例 #4
0
def install_new_contrail(**kwargs):
    """Installs required contrail packages in all nodes as per the role definition.
    """
    new_host = kwargs.get("new_ctrl")
    execute("pre_check")
    execute(create_install_repo_node, new_host)

    if new_host in env.roledefs["database"]:
        execute(install_database_node, True, new_host)
    if get_orchestrator() is "openstack":
        if new_host in env.roledefs["openstack"]:
            execute("install_openstack_node", new_host)
    else:
        print "ERROR: Only adding a new Openstack controller is supported"
        return

    if new_host in env.roledefs["cfgm"]:
        execute(install_cfgm_node, new_host)

    if new_host in env.roledefs["control"]:
        execute(install_control_node, new_host)

    if new_host in env.roledefs["collector"]:
        execute(install_collector_node, new_host)

    if new_host in env.roledefs["webui"]:
        execute(install_webui_node, new_host)

    execute(upgrade_pkgs_node, new_host)
コード例 #5
0
def install_contrail_vcenter_plugin(pkg, *args):
    """Installs any rpm/deb package in all nodes."""
    if not pkg:
        print "Error:No vcenter plugin pkg, aborting"
        exit(1)

    depend_pkgs = get_vcenter_plugin_depend_pkgs()

    if args:
        host_list = args
    else:
       if get_orchestrator() is 'vcenter':
            host_list = env.roledefs['cfgm'][:]
       else:
            if 'vcenter_compute' in env.roledefs:
                host_list = env.roledefs['vcenter_compute'][:]

    for host_string in host_list:
         with settings (host_string=host_string, warn_only=True):
            apt_install(depend_pkgs)
            if type(pkg) is list:
                 #Invoked from install_cfgm or install_vcenter_compute
                 #pkg is passed as a list
                 apt_install(pkg)
            else:
                 #Invoked when 'fab install_contrail_vcenter_plugin'
                 #is used with the vcenter-plugin deb as argument
                 execute('install_pkg_node', pkg, env.host_string)
            execute('install_contrail_vcenter_plugin_node', env.host_string)
コード例 #6
0
def create_vmx (esxi_host, vm_name):
    '''Creates vmx file for contrail compute VM (non vcenter env)'''
    fab_pg = esxi_host['fabric_port_group']
    vm_pg = esxi_host['vm_port_group']
    data_pg = esxi_host.get('data_port_group', None)
    orch = get_orchestrator()
    vm_name = vm_name
    vm_mac = esxi_host['contrail_vm']['mac']
    assert vm_mac, "MAC address for contrail-compute-vm must be specified"

    if orch is 'vcenter':
        eth0_type = "vmxnet3"
        ext_params = compute_vmx_template.vcenter_ext_template
    else:
        eth0_type = "e1000"
        ext_params = compute_vmx_template.esxi_eth1_template.safe_substitute({'__vm_pg__' : vm_pg})

    if data_pg:
        data_intf = compute_vmx_template.esxi_eth2_template.safe_substitute({'__data_pg__' : data_pg})
        ext_params += data_intf

    template_vals = { '__vm_name__' : vm_name,
                      '__vm_mac__' : vm_mac,
                      '__fab_pg__' : fab_pg,
                      '__eth0_type__' : eth0_type,
                      '__extension_params__' : ext_params,
                    }
    _, vmx_file = tempfile.mkstemp(prefix=vm_name)
    _template_substitute_write(compute_vmx_template.template,
                               template_vals, vmx_file)
    print "VMX File %s created for VM %s" %(vmx_file, vm_name)
    return vmx_file
コード例 #7
0
def install_new_contrail(**kwargs):
    """Installs required contrail packages in all nodes as per the role definition.
    """
    new_host = kwargs.get('new_ctrl')
    execute('pre_check')
    execute(create_install_repo_node, new_host)

    if new_host in env.roledefs['database']:
        execute(install_database_node, True, new_host)
    if (get_orchestrator() is 'openstack'):
        if new_host in env.roledefs['openstack']:
            execute("install_openstack_node", new_host)
    else:
        print "ERROR: Only adding a new Openstack controller is supported"
        return

    if new_host in env.roledefs['cfgm']:
        execute(install_cfgm_node, new_host)

    if new_host in env.roledefs['control']:
        execute(install_control_node, new_host)

    if new_host in env.roledefs['collector']:
        execute(install_collector_node, new_host)

    if new_host in env.roledefs['webui']:
        execute(install_webui_node, new_host)
コード例 #8
0
def get_config_pkgs():
     if get_orchestrator() is 'vcenter':
         pkgs = ['contrail-vmware-config']
     else:
         pkgs = ['contrail-openstack-config']

     return pkgs
コード例 #9
0
def get_config_pkgs():
    if get_orchestrator() is "vcenter":
        pkgs = ["contrail-vmware-config"]
    else:
        pkgs = ["contrail-openstack-config"]

    return pkgs
コード例 #10
0
def install_new_contrail(**kwargs):
    """Installs required contrail packages in all nodes as per the role definition.
    """
    new_host = kwargs.get('new_ctrl')
    execute('pre_check')
    execute(create_install_repo_node, new_host)

    if new_host in env.roledefs['database']:
        execute(install_database_node, True, new_host)
    if (get_orchestrator() is 'openstack'):
        if new_host in env.roledefs['openstack']:
            execute("install_openstack_node", new_host)
    else:
        print "ERROR: Only adding a new Openstack controller is supported"
        return

    if new_host in env.roledefs['cfgm']:
        execute(install_cfgm_node, new_host)

    if new_host in env.roledefs['control']:
        execute(install_control_node, new_host)

    if new_host in env.roledefs['collector']:
        execute(install_collector_node, new_host)

    if new_host in env.roledefs['webui']:
        execute(install_webui_node, new_host)
コード例 #11
0
def install_contrail_vcenter_plugin(pkg, *args):
    """Installs any rpm/deb package in all nodes."""
    if not pkg:
        print "Error:No vcenter plugin pkg, aborting"
        exit(1)

    depend_pkgs = get_vcenter_plugin_depend_pkgs()

    if args:
        host_list = args
    else:
       if get_orchestrator() is 'vcenter':
            host_list = env.roledefs['cfgm'][:]
       else:
            if 'vcenter_compute' in env.roledefs:
                host_list = env.roledefs['vcenter_compute'][:]

    for host_string in host_list:
         with settings (host_string=host_string, warn_only=True):
            apt_install(depend_pkgs)
            if type(pkg) is list:
                 #Invoked from install_cfgm or install_vcenter_compute
                 #pkg is passed as a list
                 apt_install(pkg)
            else:
                 #Invoked when 'fab install_contrail_vcenter_plugin'
                 #is used with the vcenter-plugin deb as argument
                 execute('install_pkg_node', pkg, env.host_string)
            execute('install_contrail_vcenter_plugin_node', env.host_string)
コード例 #12
0
def restart_cfgm_node(*args):
    """Restarts the contrail config services in once cfgm node. USAGE:fab restart_cfgm_node:[email protected],[email protected]"""
    for host_string in args:
        with  settings(host_string=host_string):
            sudo('service supervisor-support-service restart')
            sudo('service supervisor-config restart')
            if get_orchestrator() == 'openstack':
                sudo('service neutron-server restart')
コード例 #13
0
def install_vrouter(manage_nova_compute='yes'):
    """Installs vrouter pkgs in all nodes defined in vrouter role."""
    if env.roledefs['compute']:
        # Nova compute need not required for TSN node
        if 'tsn' in env.roledefs.keys():
            if  env.host_string in env.roledefs['tsn']: manage_nova_compute='no'
        if get_orchestrator() is 'vcenter': manage_nova_compute='no'
        execute("install_only_vrouter_node", manage_nova_compute, env.host_string)
コード例 #14
0
def get_config_pkgs():
     if get_orchestrator() is 'vcenter':
         pkgs = ['contrail-vmware-config']
     else:
         pkgs = ['contrail-openstack-config']
     if manage_config_db:
         pkgs.append('contrail-database-common')

     return pkgs
コード例 #15
0
def get_config_pkgs():
    if get_orchestrator() is 'vcenter':
        pkgs = ['contrail-vmware-config']
    else:
        pkgs = ['contrail-openstack-config']
    if manage_config_db:
        pkgs.append('contrail-database-common')

    return pkgs
コード例 #16
0
def install_gdb(container=None):
	# In openstack clusters, agent is not a container
    if env.host_string in env.roledefs['compute'] and \
            'openstack' in get_orchestrator():
        execute('install_test_repo_node', None, env.host_string)
        install_pkg(['gdb'])
    else:
        execute('install_test_repo_node', container, env.host_string)
        install_pkg(['gdb'], container)
コード例 #17
0
def save_systemd_logs():
    dist, version, extra = get_linux_distro()
    # No systemd on ubuntu 14.04
    if '14.04' in version:
        return
    sudo('journalctl > /var/log/journalctl.log')
    save_contrail_systemd_logs()
    if get_orchestrator() == 'openstack':
        save_openstack_container_logs()
コード例 #18
0
def restart_cfgm_node(*args):
    """Restarts the contrail config services in once cfgm node. USAGE:fab restart_cfgm_node:[email protected],[email protected]"""
    openstack_services = get_openstack_services()
    for host_string in args:
        with settings(host_string=host_string):
            sudo('service %s restart' % openstack_services['rabbitmq-server'])
            sudo('service supervisor-config restart')
            if get_orchestrator() == 'openstack':
                sudo('service neutron-server restart')
コード例 #19
0
def restart_openstack_compute():
    """Restarts the contrail openstack compute service."""
    if 'tsn' in env.roledefs.keys() and env.host_string in env.roledefs['tsn']:
        return
    if get_orchestrator() == 'vcenter':
        return
    if detect_ostype() in ['ubuntu']:
        sudo('service nova-compute restart')
        return
    sudo('service openstack-nova-compute restart')
コード例 #20
0
def restart_openstack_compute():
    """Restarts the contrail openstack compute service."""
    if 'tsn' in env.roledefs.keys() and env.host_string in env.roledefs['tsn']:
        return
    if get_orchestrator() == 'vcenter':
        return
    if detect_ostype() in ['ubuntu']:
        sudo('service nova-compute restart')
        return
    sudo('service openstack-nova-compute restart')
コード例 #21
0
def install_test_repo():
    '''
    Installs test repo which contains packages specific to
    execute contrail test scripts
    '''
    containers = get_contrail_containers()
    for container in containers:
        execute('install_test_repo_node', container, env.host_string)
    if env.host_string in env.roledefs['compute'] and \
            'openstack' in get_orchestrator():
        execute('install_test_repo_node', None, env.host_string)
コード例 #22
0
def install_test_repo():
    '''
    Installs test repo which contains packages specific to
    execute contrail test scripts
    '''
    containers = get_contrail_containers()
    for container in containers:
        execute('install_test_repo_node', container, env.host_string)
    if env.host_string in env.roledefs['compute'] and \
            'openstack' in get_orchestrator():
        execute('install_test_repo_node', None, env.host_string)
コード例 #23
0
def is_ceilometer_compute_provision_supported():
    supported = is_ceilometer_supported()
    if not supported:
        return False
    # Orchestrator should be openstack
    orchestrator = get_orchestrator()
    if orchestrator != 'openstack':
        return False
    # Not supported on redhat
    os_type = detect_ostype()
    if os_type == 'redhat':
        return False
    return supported
コード例 #24
0
def is_ceilometer_compute_provision_supported():
    supported = is_ceilometer_supported()
    if not supported:
        return False
    # Orchestrator should be openstack
    orchestrator = get_orchestrator()
    if orchestrator != 'openstack':
        return False
    # Not supported on redhat
    os_type = detect_ostype()
    if os_type == 'redhat':
        return False
    return supported
コード例 #25
0
ファイル: ha.py プロジェクト: hkumarmk/contrail-fabric-utils
def join_orchestrator(new_ctrl_host):
    orch = get_orchestrator()
    if orch == 'openstack':
        execute('increase_ulimits_node', new_ctrl_host)
        execute('setup_openstack_node', new_ctrl_host)
        if is_package_installed('contrail-openstack-dashboard'):
            execute('setup_contrail_horizon_node', new_ctrl_host)
        if get_openstack_internal_vip():
            execute('sync_keystone_ssl_certs_node', new_ctrl_host)
            execute('setup_cluster_monitors_node', new_ctrl_host)
        with settings(host_string = new_ctrl_host):
            sudo('service supervisor-openstack restart')
        execute('verify_openstack')
コード例 #26
0
def is_ceilometer_supported(use_install_repo=False):
    # Ceilometer should be enabled
    enable_ceilometer = get_enable_ceilometer()
    if not enable_ceilometer:
        return False
    # Orchestrator should be openstack
    orchestrator = get_orchestrator()
    if orchestrator != 'openstack':
        return False
    os_type = detect_ostype()
    if os_type in ['redhat', 'ubuntu']:
        return True
    else:
        return False
コード例 #27
0
def is_ceilometer_supported(use_install_repo=False):
    # Ceilometer should be enabled
    enable_ceilometer = get_enable_ceilometer()
    if not enable_ceilometer:
        return False
    # Orchestrator should be openstack
    orchestrator = get_orchestrator()
    if orchestrator != 'openstack':
        return False
    os_type = detect_ostype()
    if os_type in ['redhat', 'ubuntu']:
        return True
    else:
        return False
コード例 #28
0
def install_net_driver_node(*args):
    """Installs network drives that are packaged with contrail
       on a single node. Called during a add_vrouter_node
    """
    for host_string in args:
        with  settings(host_string=host_string):
            ostype = detect_ostype()
            pkgs = get_net_driver_pkgs()

            if get_orchestrator() is not 'vcenter':
                if ostype == 'ubuntu':
                    apt_install(pkgs)
                    # Update initrd to add the new drivers
                    # if necessary.
                    sudo('update-initramfs -k all -u')
コード例 #29
0
def install_net_driver_node(*args):
    """Installs network drives that are packaged with contrail
       on a single node. Called during a add_vrouter_node
    """
    for host_string in args:
        with settings(host_string=host_string):
            ostype = detect_ostype()
            pkgs = get_net_driver_pkgs()

            if get_orchestrator() is not 'vcenter':
                if ostype == 'ubuntu':
                    apt_install(pkgs)
                    # Update initrd to add the new drivers
                    # if necessary.
                    sudo('update-initramfs -k all -u')
コード例 #30
0
def install_cfgm_node(*args):
    """Installs config pkgs in one or list of nodes. USAGE:fab install_cfgm_node:[email protected],[email protected]"""
    for host_string in args:
        with settings(host_string=host_string):
            pkg = get_config_pkgs()

            if detect_ostype() == 'ubuntu':
                sudo('echo "manual" >> /etc/init/supervisor-config.override')
                sudo('echo "manual" >> /etc/init/neutron-server.override')
                apt_install(pkg)
            else:
                yum_install(pkg)

            if get_orchestrator() is 'vcenter':
                pkg = get_vcenter_plugin_pkg()
                install_contrail_vcenter_plugin(pkg)
コード例 #31
0
def get_service_token():
    if get_orchestrator() is not 'openstack':
        with settings(host_string=env.roledefs['cfgm'][0], warn_only=True):
            if sudo("sudo ls /etc/contrail/service.token").failed:
                sudo("sudo setup-service-token.sh")
            service_token = sudo("sudo cat /etc/contrail/service.token")
        return service_token

    service_token = get_from_testbed_dict('openstack','service_token',
                             getattr(testbed, 'service_token', ''))
    if not service_token:
        with settings(host_string=env.roledefs['openstack'][0], warn_only=True):
            if sudo("sudo ls /etc/contrail/service.token").failed:
                sudo("sudo setup-service-token.sh")
            service_token = sudo("sudo cat /etc/contrail/service.token")
    return service_token
コード例 #32
0
def install_cfgm_node(*args):
    """Installs config pkgs in one or list of nodes. USAGE:fab install_cfgm_node:[email protected],[email protected]"""
    for host_string in args:
        with settings(host_string=host_string):
            pkg = get_config_pkgs()

            if detect_ostype() == 'ubuntu':
                sudo('echo "manual" >> /etc/init/supervisor-config.override')
                sudo('echo "manual" >> /etc/init/neutron-server.override')
                apt_install(pkg)
            else:
                yum_install(pkg)

            if get_orchestrator() is 'vcenter':
                pkg = get_vcenter_plugin_pkg()
                install_contrail_vcenter_plugin(pkg)
コード例 #33
0
ファイル: host.py プロジェクト: skiranh/contrail-fabric-utils
def get_service_token():
    if get_orchestrator() is not 'openstack':
        with settings(host_string=env.roledefs['cfgm'][0], warn_only=True):
            if sudo("sudo ls /etc/contrail/service.token").failed:
                sudo("sudo setup-service-token.sh")
            service_token = sudo("sudo cat /etc/contrail/service.token")
        return service_token

    service_token = get_from_testbed_dict('openstack','service_token',
                             getattr(testbed, 'service_token', ''))
    if not service_token:
        with settings(host_string=env.roledefs['openstack'][0], warn_only=True):
            if sudo("sudo ls /etc/contrail/service.token").failed:
                sudo("sudo setup-service-token.sh")
            service_token = sudo("sudo cat /etc/contrail/service.token")
    return service_token
コード例 #34
0
def tar_logs_cores():
    sudo("rm -f /var/log/logs_*.tgz")
    sudo("rm -f /var/crashes/*gz; mkdir -p /var/crashes")
    sudo("rm -f /var/log/gdb*.log")
    sudo("rm -f /var/log/contrail*.log")
    sudo("rm -rf /var/log/temp_log")
    sudo("rm -rf /var/temp_log")
    a = dt.now().strftime("%Y_%m_%d_%H_%M_%S")
    d = env.host_string
    e=sudo('hostname')
    with settings(warn_only=True):
        save_systemd_logs()
    sudo ("mkdir -p /var/temp_log; cp -R /var/log/* /var/temp_log")
    sudo ("mv /var/temp_log /var/log/temp_log")
    sudo ("cd /var/log/temp_log/ ; tar czf /var/log/logs_%s_%s.tgz *"%(e, a))
    with settings(warn_only=True):
        check_cores_on_containers(hostname=e)
        if env.host_string in env.roledefs['compute'] and \
                get_orchestrator() == 'openstack':
            check_cores_on_host(hostname=e)
コード例 #35
0
def is_ceilometer_supported(use_install_repo=False):
    # Ceilometer should be enabled
    enable_ceilometer = get_enable_ceilometer()
    if not enable_ceilometer:
        return False
    # Orchestrator should be openstack
    orchestrator = get_orchestrator()
    if orchestrator != 'openstack':
        return False
    # Currently supported only on ubuntu icehouse
    os_type = detect_ostype()
    openstack_sku = get_openstack_sku(use_install_repo)
    if os_type in ['redhat'] and \
            openstack_sku in ['juno']:
        return True
    elif os_type in ['ubuntu'] and \
            openstack_sku in ['juno']:
        return True
    else:
        return False
コード例 #36
0
def configure_esxi_network(esxi_info):
    '''Provision ESXi server'''
    user = esxi_info['username']
    ip = esxi_info['ip']
    password = esxi_info['password']
    assert (user and ip and password), "User, password and IP of the ESXi server must be specified"

    orch = get_orchestrator()
    if orch == 'openstack':
        vm_pg = esxi_info['vm_port_group']
        vm_switch = esxi_info['vm_vswitch']
        vm_switch_mtu = esxi_info['vm_vswitch_mtu']
        data_pg = esxi_info.get('data_port_group', None)
        data_switch = esxi_info.get('data_vswitch', None)
        data_nic = esxi_info.get('data_nic', None)
    fabric_pg = esxi_info['fabric_port_group']
    fab_switch = esxi_info['fabric_vswitch']
    uplink_nic = esxi_info['uplink_nic']

    host_string = '%s@%s' %(user, ip)
    with settings(host_string = host_string, password = password, 
                    warn_only = True, shell = '/bin/sh -l -c'):
        run('esxcli network vswitch standard add --vswitch-name=%s' %(fab_switch))
        run('esxcli network vswitch standard portgroup add --portgroup-name=%s --vswitch-name=%s' %(fabric_pg, fab_switch))
        if uplink_nic:
            run('esxcli network vswitch standard uplink add --uplink-name=%s --vswitch-name=%s' %(uplink_nic, fab_switch))
        if orch == 'openstack':
            run('esxcli network vswitch standard add --vswitch-name=%s' %(vm_switch))
            run('esxcli network vswitch standard portgroup add --portgroup-name=%s --vswitch-name=%s' %(vm_pg, vm_switch))
            run('esxcli network vswitch standard set -v %s -m %s' % (vm_switch, vm_switch_mtu))
            run('esxcli network vswitch standard policy security set --vswitch-name=%s --allow-promiscuous=1' % (vm_switch))
            run('esxcli network vswitch standard portgroup set --portgroup-name=%s --vlan-id=4095' %(vm_pg))
            if data_switch:
                run('esxcli network vswitch standard add --vswitch-name=%s' %(data_switch))
            if data_nic:
                assert data_switch, "Data vSwitch must be specified to add data nic"
                run('esxcli network vswitch standard uplink add --uplink-name=%s --vswitch-name=%s' %(data_nic, data_switch))
            if data_pg:
                assert data_switch, "Data vSwitch must be specified to create data port group"
                run('esxcli network vswitch standard portgroup add --portgroup-name=%s --vswitch-name=%s' %(data_pg, data_switch))
コード例 #37
0
def install_contrail_vcenter_plugin(pkg, *args):
    """Installs any rpm/deb package in all nodes."""
    if not pkg:
        print "Error:No vcenter plugin pkg, aborting"
        exit(1)

    depend_pkgs = get_vcenter_plugin_depend_pkgs()

    if args:
        host_list = args
    else:
       if get_orchestrator() is 'vcenter':
            host_list = env.roledefs['cfgm'][:]
       else:
            if 'vcenter_compute' in env.roledefs:
                host_list = env.roledefs['vcenter_compute'][:]

    for host_string in host_list:
         with settings (host_string=host_string, warn_only=True):
             apt_install(depend_pkgs)
             execute('install_pkg_node', pkg, env.host_string)
             execute('install_contrail_vcenter_plugin_node', env.host_string)
コード例 #38
0
def install_orchestrator():
    if get_orchestrator() is 'openstack':
        execute(install_openstack)
        execute(update_keystone_log)
コード例 #39
0
def create_esxi_compute_vm (esxi_host, vcenter_info, power_on):
    '''Spawns contrail vm on openstack managed esxi server (non vcenter env)'''
    orch = get_orchestrator()
    datastore = esxi_host['datastore']
    if 'vmdk_download_path' in esxi_host['contrail_vm'].keys():
         vmdk_download_path = esxi_host['contrail_vm']['vmdk_download_path']
         run("wget -O /tmp/ContrailVM-disk1.vmdk %s" % vmdk_download_path)
         vmdk = "/tmp/ContrailVM-disk1.vmdk"
    else:
         vmdk = esxi_host['contrail_vm']['vmdk']
         if vmdk is None:
            assert vmdk, "Contrail VM vmdk image or download path should be specified in testbed file"
    if orch is 'openstack':
        vm_name = esxi_host['contrail_vm']['name']
    if orch is 'vcenter':
        name = "ContrailVM"
        vm_name = name+"-"+vcenter_info['datacenter']+"-"+esxi_host['ip']
    vm_store = datastore + '/' + vm_name + '/'

    vmx_file = create_vmx(esxi_host, vm_name)
    with settings(host_string = esxi_host['username'] + '@' + esxi_host['ip'],
                  password = esxi_host['password'], warn_only = True,
                  shell = '/bin/sh -l -c'):
         vmid = run("vim-cmd vmsvc/getallvms | grep %s | awk \'{print $1}\'" % vm_name)
         if vmid:
             run("vim-cmd vmsvc/power.off %s" % vmid)
             run("vim-cmd vmsvc/unregister %s" % vmid)

         run("rm -rf %s" % vm_store)
         out = run("mkdir -p %s" % vm_store)
         if out.failed:
             raise Exception("Unable create %s on esxi host %s:%s" % (vm_store,
                                     esxi_host['ip'], out))
         dst_vmx = vm_store + vm_name + '.vmx'
         out = put(vmx_file, dst_vmx)
         os.remove(vmx_file)
         if out.failed:
             raise Exception("Unable to copy %s to %s on %s:%s" % (vmx_file,
                                     vm_store, esxi_host['ip'], out))
         if orch == 'openstack':
             src_vmdk = '/var/tmp/%s' % os.path.split(vmdk)[-1]
         if orch == 'vcenter':
             src_vmdk = '/var/tmp/ContrailVM-disk1.vmdk'
         dst_vmdk = vm_store + vm_name + '.vmdk'
         put(vmdk, src_vmdk)
         out = run('vmkfstools -i "%s" -d zeroedthick "%s"' % (src_vmdk, dst_vmdk))
         if out.failed:
             raise Exception("Unable to create vmdk on %s:%s" %
                                      (esxi_host['ip'], out))
         run('rm ' + src_vmdk)
         out = run("vim-cmd solo/registervm " + dst_vmx)
         if out.failed:
             raise Exception("Unable to register VM %s on %s:%s" % (vm_name,
                                      esxi_host['ip'], out))

         if (power_on == False):
             return

         out = run("vim-cmd vmsvc/power.on %s" % out)
         if out.failed:
             raise Exception("Unable to power on %s on %s:%s" % (vm_name,
                                      esxi_host['ip'], out))
コード例 #40
0
def install_orchestrator():
    if get_orchestrator() is 'openstack':
        execute(install_openstack)
        execute(update_keystone_log)
コード例 #41
0
def install_orchestrator():
    if get_orchestrator() is 'openstack':
        execute(install_openstack)