def copy_seed_ks_to_websvr(self):
     print "Copying ubuntu seed and kickstart files on to jumphost webserver"
     cmd = 'cp {0}/contrail-ubuntu-sk.seed {1}/'.format(
         from_project_root('contrail'), sk_img_path)
     execute(cmd, ignore_errors=True)
     cmd = 'cp {0}/contrail-ubuntu-sk.ks {1}/'.format(
         from_project_root('contrail'), sk_img_path)
     execute(cmd, ignore_errors=True)
 def __init__(self):
     install_dir = helpers.from_project_root('conf/')
     cfg_file = os.path.join(install_dir, SK_ENV_FILE)
     if not os.path.exists(os.path.join(install_dir, SK_ENV_FILE)):
         print "Missing required configuration file {}".format(cfg_file)
         sys.exit(1)
     print "Configuration file {} exists".format(cfg_file)
 def __init__(self):
     global jinja_env
     jinja_env = Environment(
         loader=FileSystemLoader(from_project_root('contrail')))
     self.sm_vm = None
     self.sm_api = None
     self.sm_home = None
    def __init__(self):
        global jinja_env
        jinja_env = Environment(
            loader=FileSystemLoader(from_project_root('vmx')))

        svr1name = CONF['DEFAULTS']['bms'][0]
        self.svr2_bms_name = CONF['DEFAULTS']['bms'][1]

        self.server1_ip = get_ip(CONF[svr1name]['management_address'])
        server2_ip = get_ip(CONF[self.svr2_bms_name]['management_address'])
        server2_user = CONF['DEFAULTS']['root_username']
        server2_passwd = CONF['DEFAULTS']['root_password']

        self.svr2_bms = RemoteConnection()
        self.svr2_bms.connect(server2_ip,
                              username=server2_user,
                              password=server2_passwd)
        cmd = 'eval echo ~$USER'
        self.svr2_bms_home = self.svr2_bms.execute_cmd(cmd, timeout=10)
Ejemplo n.º 5
0
    def __init__(self):
        global jinja_env
        jinja_env = Environment(loader=FileSystemLoader(from_project_root('sanity')))

        #Check the reachability to api_server and auth_server
        password = CONF['DEFAULTS']['contrail_os_webui_passwd']
        api_server = CONF['CONTRAILCTRL']['ctrldata_address']
        auth_server = CONF['OPENSTACK']['ctrldata_address']
        self._imageid = None

        if self.checkPing(api_server) and self.checkPing(auth_server):
            print "Contrail API server (%s) and Keystone server (%s) is reachable"%(api_server,auth_server)
            #Get handle to OS and VNC API
            self._osapi = openstackApi(get_keystone_creds(), get_nova_creds())
            self._vncapi = contrailVncApi(username='******', password=password, tenant_name='admin'
                        api_server_host=api_server, auth_host=auth_server)
        else:
            print "Contrail API server (%s) and Keystone server (%s) is not reachable"%(api_server,auth_server)
            sys.exit(1)
    def __init__(self):
        global jinja_env
        jinja_env = Environment(
            loader=FileSystemLoader(from_project_root('smgr')))

        # configure server1 bridge ips
        svr1 = CONF['DEFAULTS']['bms'][0]
        print "Checking ntp server reachability from jumphost(%s)" % (svr1)
        sm_ntp_server = CONF['DEFAULTS']['ntp_servers']
        res = os.system('ping -c 3 ' + sm_ntp_server)
        if res == 0:
            print "NTP server %s is reachable" % (sm_ntp_server)
        else:
            print "Response: %s" % (res)
            print "NTP server %s is not reachable" % (sm_ntp_server)
            sys.exit(1)
        print "Checking mgmtbr, ctrldatabr bridge configuration on jumphost server."
        m_intf = CONF[svr1]['management_interface']
        c_intf = CONF[svr1]['ctrldata_interface']
        m_ip = get_ip(CONF[svr1]['management_address'])
        m_netmask = get_netmask(CONF[svr1]['management_address'])
        c_ip = get_ip(CONF[svr1]['ctrldata_address'])
        c_netmask = get_netmask(CONF[svr1]['ctrldata_address'])
        command = 'brctl show mgmtbr'
        res1 = execute(command, ignore_errors=False)
        command = 'brctl show ctrldatabr'
        res2 = execute(command, ignore_errors=False)
        if None not in (re.search(r'%s' % m_intf, res1, re.M | re.I),
                        re.search(r'%s' % c_intf, res2, re.M | re.I)):
            print "Jumphost server bridge interface configuration exists."
        else:
            print "Configuring jumphost server bridge interfaces. Begins.."
            command = '/sbin/ifconfig %s 0.0.0.0 up' % (m_intf)
            execute(command, ignore_errors=False)
            command = '/sbin/ifconfig mgmtbr %s netmask %s up' % (m_ip,
                                                                  m_netmask)
            execute(command, ignore_errors=False)
            command = 'brctl addif mgmtbr %s' % (m_intf)
            execute(command, ignore_errors=False)

            command = '/sbin/ifconfig %s 0.0.0.0 up' % (c_intf)
            execute(command, ignore_errors=False)
            command = '/sbin/ifconfig ctrldatabr %s netmask %s up' % (
                c_ip, c_netmask)
            execute(command, ignore_errors=False)
            command = 'brctl addif ctrldatabr %s' % (c_intf)
            execute(command, ignore_errors=False)
            print "Configuring jumphost server bridge interfaces. Ends.."

        #update /etc/network/interfaces file with this ip
        cmd = 'cat /etc/network/interfaces'
        res = execute(cmd, ignore_errors=False)
        if re.search(r'mgmtbr|ctrldatabr', res, re.M | re.I):
            print "mgmtbr/ctrldatabr interface configuration exists"
        else:
            print "mgmtbr/ctrldatabr interface configuration does not exists, hence configuring"
            command = 'sudo echo -ne \"auto {}\n iface {} inet manual\n auto mgmtbr\n iface mgmtbr inet static\n address {}\n netmask {}\n bridge_ports {}\n bridge_stp off\n bridge_fd 0\n bridge_maxwait 0\n\" >> /etc/network/interfaces'.format(
                m_intf, m_intf, m_ip, m_netmask, m_intf)
            execute(command, ignore_errors=False)
            command = 'sudo echo -ne \"auto {}\n iface {} inet manual\n auto ctrldatabr\n iface ctrldatabr inet static\n address {}\n netmask {}\n bridge_ports {}\n bridge_stp off\n bridge_fd 0\n bridge_maxwait 0\n\" >> /etc/network/interfaces'.format(
                c_intf, c_intf, c_ip, c_netmask, c_intf)
            execute(command, ignore_errors=False)