diff --git a/contrail_setup_utils/cinder-server-setup.sh b/contrail_setup_utils/cinder-server-setup.sh index 89227e10..6ab04def 100755 --- a/contrail_setup_utils/cinder-server-setup.sh +++ b/contrail_setup_utils/cinder-server-setup.sh @@ -83,7 +83,7 @@ cat > $CONF_DIR/openstackrc < /tmp/libvirtd.conf cp -f /tmp/libvirtd.conf /etc/libvirt/libvirtd.conf -if [ -f /etc/sysconfig/libvirtd ] -then - cat /etc/sysconfig/libvirtd | sed s/"#LIBVIRTD_ARGS=\"--listen\""/"LIBVIRTD_ARGS=\"--listen\""/ > /tmp/libvirtd - cp -f /tmp/libvirtd /etc/sysconfig/libvirtd +cat /etc/sysconfig/libvirtd | sed s/"#LIBVIRTD_ARGS=\"--listen\""/"LIBVIRTD_ARGS=\"--listen\""/ > /tmp/libvirtd +cp -f /tmp/libvirtd /etc/sysconfig/libvirtd - for svc in openstack-nova-compute; do - service $svc restart - done +for svc in openstack-nova-compute; do + service $svc restart +done - for svc in libvirtd; do - service $svc restart - done -fi -if [ -f /etc/default/libvirt-bin ] -then - cat /etc/default/libvirt-bin | sed s/"-d"/"-d -l"/ > /tmp/libvirt-bin - cp -f /tmp/libvirt-bin /etc/default/libvirt-bin - if [ -f /etc/init.d/nova-compute ] - then - service nova-compute restart - fi - service libvirt-bin restart -fi +for svc in libvirtd; do + service $svc restart +done diff --git a/contrail_setup_utils/compute-server-setup.sh b/contrail_setup_utils/compute-server-setup.sh index 75eb4106..7eb545f7 100755 --- a/contrail_setup_utils/compute-server-setup.sh +++ b/contrail_setup_utils/compute-server-setup.sh @@ -3,24 +3,13 @@ if [ -f /etc/redhat-release ]; then is_redhat=1 is_ubuntu=0 - nova_compute_ver=`rpm -q --qf "%{VERSION}\n" openstack-nova-compute` - if [ "$nova_compute_ver" == "2013.1" ]; then - OS_NET=quantum - TENANT_NAME=quantum_admin_tenant_name - ADMIN_USER=quantum_admin_username - ADMIN_PASSWD=quantum_admin_password - ADMIN_AUTH_URL=quantum_admin_auth_url - OS_URL=quantum_url - OS_URL_TIMEOUT=quantum_url_timeout - else - OS_NET=neutron - TENANT_NAME=neutron_admin_tenant_name - ADMIN_USER=neutron_admin_username - ADMIN_PASSWD=neutron_admin_password - ADMIN_AUTH_URL=neutron_admin_auth_url - OS_URL=neutron_url - OS_URL_TIMEOUT=neutron_url_timeout - fi + OS_NET=quantum + TENANT_NAME=quantum_admin_tenant_name + ADMIN_USER=quantum_admin_username + ADMIN_PASSWD=quantum_admin_password + ADMIN_AUTH_URL=quantum_admin_auth_url + OS_URL=quantum_url + OS_URL_TIMEOUT=quantum_url_timeout fi if [ -f /etc/lsb-release ]; then @@ -62,7 +51,7 @@ if [ $CONTROLLER != $COMPUTE ] ; then openstack-config --set /etc/nova/nova.conf DEFAULT $OS_URL http://$QUANTUM:9696/ openstack-config --set /etc/nova/nova.conf DEFAULT $OS_URL_TIMEOUT 300 if [ $is_ubuntu -eq 1 ] ; then - openstack-config --set /etc/nova/nova.conf DEFAULT network_api_class nova.network.${OS_NET}v2.api.API + openstack-config --set /etc/nova/nova.conf DEFAULT network_api_class nova.network.neutronv2.api.API fi openstack-config --set /etc/nova/nova.conf keystone_authtoken admin_tenant_name service openstack-config --set /etc/nova/nova.conf keystone_authtoken admin_user nova diff --git a/contrail_setup_utils/glance-server-setup.sh b/contrail_setup_utils/glance-server-setup.sh index 52f693fb..0700094e 100755 --- a/contrail_setup_utils/glance-server-setup.sh +++ b/contrail_setup_utils/glance-server-setup.sh @@ -83,7 +83,7 @@ cat > $CONF_DIR/openstackrc < $CONF_DIR/openstackrc <> ${memcache_conf} - fi -elif [ $is_redhat -eq 1 ]; then - memcache_conf='/etc/sysconfig/memcached' - opts=$(grep OPTIONS ${memcache_conf} | grep -Po '".*?"') - if [ $? -ne 0 ]; then - #Write option to memcached config file - echo "OPTIONS=\"-I ${item_size_max}\"" >> ${memcache_conf} - else - #strip the leading and trailing qoutes - opts=$(echo "$opts" | sed -e 's/^"//' -e 's/"$//') - grep OPTIONS ${memcache_conf} | grep -Po '".*?"' | grep "\-I" - if [ $? -ne 0 ]; then - #concatenate with the existing options. - opts="$opts -I ${item_size_max}" - sed -i "s/OPTIONS.*/OPTIONS=\"${opts}\"/g" ${memcache_conf} - fi - fi -fi - # Create link /usr/bin/nodejs to /usr/bin/node if [ ! -f /usr/bin/nodejs ]; then ln -s /usr/bin/node /usr/bin/nodejs diff --git a/contrail_setup_utils/nova-server-setup.sh b/contrail_setup_utils/nova-server-setup.sh index 19d39f33..f1fc118b 100755 --- a/contrail_setup_utils/nova-server-setup.sh +++ b/contrail_setup_utils/nova-server-setup.sh @@ -24,27 +24,14 @@ if [ -f /etc/redhat-release ]; then web_svc=httpd mysql_svc=mysqld nova_pfx=openstack-nova - nova_api_ver=`rpm -q --qf "%{VERSION}\n" openstack-nova-api` - echo $nova_api_ver - if [ "$nova_api_ver" == "2013.1" ]; then - OS_NET=quantum - TENANT_NAME=quantum_admin_tenant_name - ADMIN_USER=quantum_admin_username - ADMIN_PASSWD=quantum_admin_password - ADMIN_AUTH_URL=quantum_admin_auth_url - OS_URL=quantum_url - OS_URL_TIMEOUT=quantum_url_timeout - META_DATA_PROXY=service_quantum_metadata_proxy - else - OS_NET=neutron - TENANT_NAME=neutron_admin_tenant_name - ADMIN_USER=neutron_admin_username - ADMIN_PASSWD=neutron_admin_password - ADMIN_AUTH_URL=neutron_admin_auth_url - OS_URL=neutron_url - OS_URL_TIMEOUT=neutron_url_timeout - META_DATA_PROXY=service_neutron_metadata_proxy - fi + OS_NET=quantum + TENANT_NAME=quantum_admin_tenant_name + ADMIN_USER=quantum_admin_username + ADMIN_PASSWD=quantum_admin_password + ADMIN_AUTH_URL=quantum_admin_auth_url + OS_URL=quantum_url + OS_URL_TIMEOUT=quantum_url_timeout + META_DATA_PROXY=service_quantum_metadata_proxy fi if [ -f /etc/lsb-release ]; then @@ -125,12 +112,12 @@ cat > $CONF_DIR/openstackrc < to auto excluding these pattern - # then delete specifically auto - local("sed -i '/auto %s/,/auto/{/auto/!d}' %s" %(dev, temp_intf_file)) - local("sed -i '/auto %s/d' %s" %(dev, temp_intf_file)) - # add manual entry for dev - local("echo 'auto %s' >> %s" %(dev, temp_intf_file)) - local("echo 'iface %s inet manual' >> %s" %(dev, temp_intf_file)) - local("echo ' pre-up ifconfig %s up' >> %s" %(dev, temp_intf_file)) - local("echo ' post-down ifconfig %s down' >> %s" %(dev, temp_intf_file)) - if vlan: - local("echo ' vlan-raw-device %s' >> %s" %(phydev, temp_intf_file)) - if 'bond' in dev.lower(): - iters = re.finditer('^\s*auto\s', cfg_file, re.M) - indices = [match.start() for match in iters] - matches = map(cfg_file.__getslice__, indices, indices[1:] + [len(cfg_file)]) - for each in matches: - each = each.strip() - if re.match('^auto\s+%s'%dev, each): - string = '' - for lines in each.splitlines(): - if 'bond-' in lines: - string += lines+os.linesep - local("echo '%s' >> %s" %(string, temp_intf_file)) - else: - continue - local("echo '' >> %s" %(temp_intf_file)) - else: - #remove ip address and gateway - local("sed -i '/iface %s inet static/, +2d' %s" % (dev, temp_intf_file)) - local("sed -i '/auto %s/ a\iface %s inet manual' %s" % (dev, dev, temp_intf_file)) + local("mv /etc/network/interfaces %s" %(temp_intf_file)) # populte vhost0 as static local("echo '' >> %s" %(temp_intf_file)) local("echo 'auto vhost0' >> %s" %(temp_intf_file)) local("echo 'iface vhost0 inet static' >> %s" %(temp_intf_file)) + local("echo ' pre-up /opt/contrail/bin/if-vhost0' >> %s" %(temp_intf_file)) local("echo ' netmask %s' >> %s" %(netmask, temp_intf_file)) local("echo ' network_name application' >> %s" %(temp_intf_file)) if vhost_ip: local("echo ' address %s' >> %s" %(vhost_ip, temp_intf_file)) - if (vhost_ip == self._args.compute_ip) and gateway_ip: + if gateway_ip: local("echo ' gateway %s' >> %s" %(gateway_ip, temp_intf_file)) domain = self.get_domain_search_list() @@ -636,11 +557,42 @@ def _rewrite_net_interfaces_file(self, dev, mac, vhost_ip, netmask, gateway_ip): local("echo -n ' %s' >> %s" %(dns, temp_intf_file)) local("echo '\n' >> %s" %(temp_intf_file)) + if not self._args.non_mgmt_ip: + # remove entry from auto to auto excluding these pattern + # then delete specifically auto + local("sed -i '/auto %s/,/auto/{/auto/!d}' %s" %(dev, temp_intf_file)) + local("sed -i '/auto %s/d' %s" %(dev, temp_intf_file)) + # add manual entry for dev + local("echo 'auto %s' >> %s" %(dev, temp_intf_file)) + local("echo 'iface %s inet manual' >> %s" %(dev, temp_intf_file)) + local("echo ' pre-up ifconfig %s up' >> %s" %(dev, temp_intf_file)) + local("echo ' post-down ifconfig %s down' >> %s" %(dev, temp_intf_file)) + local("echo '' >> %s" %(temp_intf_file)) + else: + #remove ip address and gateway + local("sed -i '/iface %s inet static/, +2d' %s" % (dev, temp_intf_file)) + local("sed -i '/auto %s/ a\iface %s inet manual' %s" % (dev, dev, temp_intf_file)) + # move it to right place - local("sudo mv -f %s /etc/network/interfaces" %(temp_intf_file)) + local("mv %s /etc/network/interfaces" %(temp_intf_file)) #end _rewrite_net_interfaces_file + def _replace_discovery_server(self, agent_elem, discovery_ip, ncontrols): + for srv in agent_elem.findall('discovery-server'): + agent_elem.remove(srv) + + pri_dss_elem = ET.Element('discovery-server') + pri_dss_ip = ET.SubElement(pri_dss_elem, 'ip-address') + pri_dss_ip.text = '%s' %(discovery_ip) + + xs_instances = ET.SubElement(pri_dss_elem, 'control-instances') + xs_instances.text = '%s' %(ncontrols) + agent_elem.append(pri_dss_elem) + + #end _replace_discovery_server + + def fixup_config_files(self): pdist = platform.dist()[0] temp_dir_name = self._temp_dir_name @@ -649,32 +601,26 @@ def fixup_config_files(self): collector_ip = self._args.collector_ip use_certs = True if self._args.use_certs else False nova_conf_file = "/etc/nova/nova.conf" - cinder_conf_file = "/etc/cinder/cinder.conf" - if (os.path.isdir("/etc/openstack_dashboard")): - dashboard_setting_file = "/etc/openstack_dashboard/local_settings" - else: - dashboard_setting_file = "/etc/openstack-dashboard/local_settings" if pdist == 'Ubuntu': local("ln -sf /bin/true /sbin/chkconfig") # TODO till post of openstack-horizon.spec is fixed... if 'openstack' in self._args.role: + pylibpath = local ('/usr/bin/python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"', capture = True) if pdist == 'fedora' or pdist == 'centos': - local("sudo sed -i 's/ALLOWED_HOSTS =/#ALLOWED_HOSTS =/g' %s" %(dashboard_setting_file)) + local('runuser -p apache -c "echo yes | django-admin collectstatic --settings=settings --pythonpath=%s/openstack_dashboard"' % pylibpath) if os.path.exists(nova_conf_file): local("sudo sed -i 's/rpc_backend = nova.openstack.common.rpc.impl_qpid/#rpc_backend = nova.openstack.common.rpc.impl_qpid/g' %s" \ % (nova_conf_file)) - if os.path.exists(cinder_conf_file): - local("sudo sed -i 's/rpc_backend = cinder.openstack.common.rpc.impl_qpid/#rpc_backend = cinder.openstack.common.rpc.impl_qpid/g' %s" \ - % (cinder_conf_file)) # Put hostname/ip mapping into /etc/hosts to avoid DNS resolution failing at bootup (Cassandra can fail) if 'database' in self._args.role: - hosts_entry = '%s %s' %(cfgm_ip, hostname) + database_listen_ip = self._args.database_listen_ip + hosts_entry = '%s %s' %(database_listen_ip, hostname) with settings( warn_only= True) : - local('grep -q \'%s\' /etc/hosts || echo \'%s %s\' >> /etc/hosts' %(cfgm_ip, cfgm_ip, hosts_entry)) + local('grep -q \'%s\' /etc/hosts || echo \'%s\' >> /etc/hosts' %(database_listen_ip, hosts_entry)) # Disable selinux with lcd(temp_dir_name): @@ -699,8 +645,6 @@ def fixup_config_files(self): if pdist == 'centos' or pdist == 'fedora': core_unlim = "echo DAEMON_COREFILE_LIMIT=\"'unlimited'\"" local("%s >> %s" %(core_unlim, initf)) - if pdist == 'Ubuntu': - local('mkdir -p /var/crash') #Core pattern pattern= 'kernel.core_pattern = /var/crashes/core.%e.%p.%h.%t' @@ -724,32 +668,27 @@ def fixup_config_files(self): # analytics venv instalation if os.path.exists('/opt/contrail/analytics-venv/archive') and os.path.exists('/opt/contrail/analytics-venv/bin/activate'): with lcd("/opt/contrail/analytics-venv/archive"): - if os.listdir('/opt/contrail/analytics-venv/archive'): - local("bash -c 'source ../bin/activate && pip install *'") + local("bash -c 'source ../bin/activate && pip install *'") # api venv instalation if os.path.exists('/opt/contrail/api-venv/archive') and os.path.exists('/opt/contrail/api-venv/bin/activate'): with lcd("/opt/contrail/api-venv/archive"): - if os.listdir('/opt/contrail/api-venv/archive'): - local("bash -c 'source ../bin/activate && pip install *'") + local("bash -c 'source ../bin/activate && pip install *'") # vrouter venv instalation if os.path.exists('/opt/contrail/vrouter-venv/archive') and os.path.exists('/opt/contrail/vrouter-venv/bin/activate'): with lcd("/opt/contrail/vrouter-venv/archive"): - if os.listdir('/opt/contrail/vrouter-venv/archive'): - local("bash -c 'source ../bin/activate && pip install *'") + local("bash -c 'source ../bin/activate && pip install *'") # control venv instalation if os.path.exists('/opt/contrail/control-venv/archive') and os.path.exists('/opt/contrail/control-venv/bin/activate'): with lcd("/opt/contrail/control-venv/archive"): - if os.listdir('/opt/contrail/control-venv/archive'): - local("bash -c 'source ../bin/activate && pip install *'") + local("bash -c 'source ../bin/activate && pip install *'") # database venv instalation if os.path.exists('/opt/contrail/database-venv/archive') and os.path.exists('/opt/contrail/database-venv/bin/activate'): with lcd("/opt/contrail/database-venv/archive"): - if os.listdir('/opt/contrail/database-venv/archive'): - local("bash -c 'source ../bin/activate && pip install *'") + local("bash -c 'source ../bin/activate && pip install *'") if 'openstack' in self._args.role: self.service_token = self._args.service_token @@ -783,7 +722,7 @@ def fixup_config_files(self): if 'compute' in self._args.role or 'openstack' in self._args.role: with settings(warn_only = True): - local("echo 'rabbit_host = %s' >> /etc/nova/nova.conf" %(self._args.keystone_ip)) + local("echo 'rabbit_host = %s' >> /etc/nova/nova.conf" %(self._args.openstack_ip)) if 'compute' in self._args.role: with settings(warn_only = True): @@ -791,7 +730,7 @@ def fixup_config_files(self): cmd = "dpkg -l | grep 'ii' | grep nova-compute | grep -v vif | grep -v nova-compute-kvm | awk '{print $3}'" nova_compute_version = subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT) if (nova_compute_version != "2:2013.1.3-0ubuntu1"): - local("echo 'neutron_admin_auth_url = http://%s:5000/v2.0' >> /etc/nova/nova.conf" %(self._args.keystone_ip)) + local("echo 'neutron_admin_auth_url = http://%s:5000/v2.0' >> /etc/nova/nova.conf" %(self._args.openstack_ip)) if os.path.exists(nova_conf_file): local("sudo sed -i 's/rpc_backend = nova.openstack.common.rpc.impl_qpid/#rpc_backend = nova.openstack.common.rpc.impl_qpid/g' %s" \ @@ -802,12 +741,12 @@ def fixup_config_files(self): # get service token from openstack(role) node and fix local config self.service_token = self._args.service_token self.haproxy = self._args.haproxy - keystone_ip = self._args.keystone_ip + openstack_ip = self._args.openstack_ip compute_ip = self._args.compute_ip cfgm_ip = self._args.cfgm_ip quantum_port = self._args.quantum_port if not self.service_token: - with settings(host_string = 'root@%s' %(keystone_ip), password = env.password): + with settings(host_string = 'root@%s' %(openstack_ip), password = env.password): get("/etc/contrail/service.token", temp_dir_name) tok_fd = open('%s/service.token' %(temp_dir_name)) self.service_token = tok_fd.read() @@ -817,7 +756,7 @@ def fixup_config_files(self): local("echo 'SERVICE_TOKEN=%s' >> %s/ctrl-details" %(self.service_token, temp_dir_name)) local("echo 'ADMIN_TOKEN=%s' >> %s/ctrl-details" %(ks_admin_password, temp_dir_name)) - local("echo 'CONTROLLER=%s' >> %s/ctrl-details" %(keystone_ip, temp_dir_name)) + local("echo 'CONTROLLER=%s' >> %s/ctrl-details" %(openstack_ip, temp_dir_name)) if self.haproxy: local("echo 'QUANTUM=127.0.0.1' >> %s/ctrl-details" %(temp_dir_name)) else: @@ -854,8 +793,6 @@ def fixup_config_files(self): initial_token = self._args.database_initial_token seed_list = self._args.database_seed_list data_dir = self._args.data_dir - analytics_data_dir = self._args.analytics_data_dir - ssd_data_dir = self._args.ssd_data_dir if not cassandra_dir: raise ArgumentError('Undefined cassandra directory') conf_dir = CASSANDRA_CONF @@ -877,17 +814,6 @@ def fixup_config_files(self): self.replace_in_file(conf_file, 'commitlog_directory:', 'commitlog_directory: ' + commit_log_dir) cass_data_dir = os.path.join(data_dir, 'data') self.replace_in_file(conf_file, ' - /var/lib/cassandra/data', ' - ' + cass_data_dir) - if ssd_data_dir: - commit_log_dir = os.path.join(ssd_data_dir, 'commitlog') - self.replace_in_file(conf_file, 'commitlog_directory:', 'commitlog_directory: ' + commit_log_dir) - if analytics_data_dir: - if not data_dir: - data_dir = '/var/lib/cassandra/data' - analytics_dir_link = os.path.join(data_dir, 'ContrailAnalytics') - analytics_dir = os.path.join(analytics_data_dir, 'ContrailAnalytics') - if not os.path.exists(analytics_dir_link): - local("sudo mkdir -p %s" % (analytics_dir)) - local("sudo ln -s %s %s" % (analytics_dir, analytics_dir_link)) if seed_list: self.replace_in_file(conf_file, ' - seeds: ', ' - seeds: "' + ", ".join(seed_list) + '"') @@ -914,17 +840,12 @@ def fixup_config_files(self): % (env_file)) local("sudo sed -i 's/# JVM_OPTS=\"\$JVM_OPTS -Xloggc:\/var\/log\/cassandra\/gc-`date +%%s`.log\"/JVM_OPTS=\"\$JVM_OPTS -Xloggc:\/var\/log\/cassandra\/gc-`date +%%s`.log\"/g' %s" \ % (env_file)) - template_vals = { - '__contrail_discovery_ip__': cfgm_ip - } - self._template_substitute_write(database_nodemgr_param_template.template, - template_vals, temp_dir_name + '/database_nodemgr_param') - local("sudo mv %s/database_nodemgr_param /etc/contrail/database_nodemgr_param" %(temp_dir_name)) if 'collector' in self._args.role: self_collector_ip = self._args.self_collector_ip cassandra_server_list = [(cassandra_server_ip, '9160') for cassandra_server_ip in self._args.cassandra_ip_list] template_vals = {'__contrail_log_file__' : '/var/log/contrail/collector.log', + '__contrail_log_local__': '--log-local', '__contrail_discovery_ip__' : cfgm_ip, '__contrail_host_ip__' : self_collector_ip, '__contrail_listen_port__' : '8086', @@ -933,10 +854,11 @@ def fixup_config_files(self): '__contrail_analytics_data_ttl__' : self._args.analytics_data_ttl, '__contrail_analytics_syslog_port__' : str(self._args.analytics_syslog_port)} self._template_substitute_write(vizd_param_template.template, - template_vals, temp_dir_name + '/collector.conf') - local("sudo mv %s/collector.conf /etc/contrail/collector.conf" %(temp_dir_name)) + template_vals, temp_dir_name + '/vizd_param') + local("sudo mv %s/vizd_param /etc/contrail/vizd_param" %(temp_dir_name)) - template_vals = {'__contrail_log_file__' : '/var/log/contrail/query-engine.log', + template_vals = {'__contrail_log_file__' : '/var/log/contrail/qe.log', + '__contrail_log_local__': '--log-local', '__contrail_redis_server__': '127.0.0.1', '__contrail_redis_server_port__' : '6380', '__contrail_http_server_port__' : '8091', @@ -944,32 +866,34 @@ def fixup_config_files(self): '__contrail_collector_port__' : '8086', '__contrail_cassandra_server_list__' : ' '.join('%s:%s' % cassandra_server for cassandra_server in cassandra_server_list)} self._template_substitute_write(qe_param_template.template, - template_vals, temp_dir_name + '/query-engine.conf') - local("sudo mv %s/query-engine.conf /etc/contrail/query-engine.conf" %(temp_dir_name)) + template_vals, temp_dir_name + '/qe_param') + local("sudo mv %s/qe_param /etc/contrail/qe_param" %(temp_dir_name)) template_vals = {'__contrail_log_file__' : '/var/log/contrail/opserver.log', - '__contrail_log_local__': '0', - '__contrail_log_category__': '', - '__contrail_log_level__': 'SYS_DEBUG', + '__contrail_log_local__': '--log_local', '__contrail_redis_server_port__' : '6381', '__contrail_redis_query_port__' : '6380', '__contrail_http_server_port__' : '8090', '__contrail_rest_api_port__' : '8081', '__contrail_host_ip__' : self_collector_ip, '__contrail_discovery_ip__' : cfgm_ip, - '__contrail_discovery_port__' : 5998, - '__contrail_collector__': self_collector_ip, + '__contrail_collector__': '127.0.0.1', '__contrail_collector_port__': '8086'} self._template_substitute_write(opserver_param_template.template, template_vals, temp_dir_name + '/opserver_param') - local("sudo mv %s/opserver_param /etc/contrail/contrail-analytics-api.conf" %(temp_dir_name)) + local("sudo mv %s/opserver_param /etc/contrail/opserver_param" %(temp_dir_name)) if 'config' in self._args.role: - keystone_ip = self._args.keystone_ip - region_name = self._args.region_name + openstack_ip = self._args.openstack_ip cassandra_server_list = [(cassandra_server_ip, '9160') for cassandra_server_ip in self._args.cassandra_ip_list] - zk_servers = ','.join(self._args.zookeeper_ip_list) - zk_servers_ports = ','.join(['%s:2181' %(s) for s in self._args.zookeeper_ip_list]) + if cfgm_ip in self._args.zookeeper_ip_list: + # prefer local zk if available + zk_servers = '%s' %(cfgm_ip) + zk_servers_ports = '%s:2181' %(cfgm_ip) + else: + zk_servers = ','.join(self._args.zookeeper_ip_list) + zk_servers_ports = \ + ','.join(['%s:2181' %(s) for s in self._args.zookeeper_ip_list]) # api_server.conf template_vals = {'__contrail_ifmap_server_ip__': cfgm_ip, @@ -983,12 +907,11 @@ def fixup_config_files(self): '__contrail_certfile_location__': '/etc/contrail/ssl/certs/apiserver.pem', '__contrail_cacertfile_location__': '/etc/contrail/ssl/certs/ca.pem', '__contrail_multi_tenancy__': self._args.multi_tenancy, - '__contrail_keystone_ip__': keystone_ip, + '__contrail_openstack_ip__': openstack_ip, '__contrail_redis_ip__': self._args.redis_master_ip, '__contrail_admin_user__': ks_admin_user, '__contrail_admin_password__': ks_admin_password, '__contrail_admin_tenant_name__': ks_admin_tenant_name, - '__contrail_admin_token__': self.service_token, '__contrail_memcached_opt__': 'memcache_servers=127.0.0.1:11211' if self._args.multi_tenancy else '', '__contrail_log_file__': '/var/log/contrail/api.log', '__contrail_cassandra_server_list__' : ' '.join('%s:%s' % cassandra_server for cassandra_server in cassandra_server_list), @@ -1055,7 +978,6 @@ def fixup_config_files(self): '__contrail_admin_user__': ks_admin_user, '__contrail_admin_password__': ks_admin_password, '__contrail_admin_tenant_name__': ks_admin_tenant_name, - '__contrail_admin_token__': self.service_token, '__contrail_log_file__' : '/var/log/contrail/schema.log', '__contrail_cassandra_server_list__' : ' '.join('%s:%s' % cassandra_server for cassandra_server in cassandra_server_list), '__contrail_disc_server_ip__': cfgm_ip, @@ -1072,7 +994,7 @@ def fixup_config_files(self): '__contrail_ifmap_password__': 'svc-monitor', '__contrail_api_server_ip__': cfgm_ip, '__contrail_api_server_port__': '8082', - '__contrail_keystone_ip__': keystone_ip, + '__contrail_openstack_ip__': openstack_ip, '__contrail_zookeeper_server_ip__': zk_servers_ports, '__contrail_use_certs__': use_certs, '__contrail_keyfile_location__': '/etc/contrail/ssl/private_keys/svc_monitor_key.pem', @@ -1081,12 +1003,10 @@ def fixup_config_files(self): '__contrail_admin_user__': ks_admin_user, '__contrail_admin_password__': ks_admin_password, '__contrail_admin_tenant_name__': ks_admin_tenant_name, - '__contrail_admin_token__': self.service_token, '__contrail_log_file__' : '/var/log/contrail/svc-monitor.log', '__contrail_cassandra_server_list__' : ' '.join('%s:%s' % cassandra_server for cassandra_server in cassandra_server_list), '__contrail_disc_server_ip__': cfgm_ip, '__contrail_disc_server_port__': '5998', - '__contrail_region_name__': region_name, } self._template_substitute_write(svc_monitor_conf_template.template, template_vals, temp_dir_name + '/svc_monitor.conf') @@ -1100,7 +1020,7 @@ def fixup_config_files(self): '__contrail_listen_port__': '5998', '__contrail_log_local__': 'True', '__contrail_log_file__': '/var/log/contrail/discovery.log', - '__contrail_healthcheck_interval__': 5, + '__contrail_healthcheck_interval__': -1, } self._template_substitute_write(discovery_conf_template.template, template_vals, temp_dir_name + '/discovery.conf') @@ -1130,29 +1050,32 @@ def fixup_config_files(self): # vnc_api_lib.ini template_vals = { - '__contrail_keystone_ip__': keystone_ip, + '__contrail_openstack_ip__': openstack_ip, } self._template_substitute_write(vnc_api_lib_ini_template.template, template_vals, temp_dir_name + '/vnc_api_lib.ini') local("sudo mv %s/vnc_api_lib.ini /etc/contrail/" %(temp_dir_name)) # set high session timeout to survive glance led disk activity - local('sudo echo "maxSessionTimeout=120000" >> /etc/zookeeper/conf/zoo.cfg') - local('sudo echo "autopurge.purgeInterval=3" >> /etc/zookeeper/conf/zoo.cfg') - local("sudo sed 's/^#log4j.appender.ROLLINGFILE.MaxBackupIndex=/log4j.appender.ROLLINGFILE.MaxBackupIndex=/g' /etc/zookeeper/conf/log4j.properties > log4j.properties.new") - local("sudo mv log4j.properties.new /etc/zookeeper/conf/log4j.properties") + local('sudo echo "maxSessionTimeout=120000" >> /etc/zookeeper/zoo.cfg') + local('echo export ZOO_LOG4J_PROP="INFO,CONSOLE,ROLLINGFILE" >> /etc/zookeeper/zookeeper-env.sh') if pdist == 'fedora' or pdist == 'centos': - local('echo export ZOO_LOG4J_PROP="INFO,CONSOLE,ROLLINGFILE" >> /usr/lib/zookeeper/bin/zkEnv.sh') + local("sudo sed 's/^#log4j.appender.ROLLINGFILE.MaxBackupIndex=11/log4j.appender.ROLLINGFILE.MaxBackupIndex=11/g' /etc/zookeeper/log4j.properties > log4j.properties.new") + local("sudo mv log4j.properties.new /etc/zookeeper/log4j.properties") if pdist == 'Ubuntu': - local('echo ZOO_LOG4J_PROP="INFO,CONSOLE,ROLLINGFILE" >> /etc/zookeeper/conf/environment') + local("sudo sed 's/^#log4j.appender.ROLLINGFILE.MaxBackupIndex=11/log4j.appender.ROLLINGFILE.MaxBackupIndex=11/g' /etc/zookeeper/conf_example/log4j.properties > log4j.properties.new") + local("sudo mv log4j.properties.new /etc/zookeeper/conf_example/log4j.properties") zk_index = 1 for zk_ip in self._args.zookeeper_ip_list: - local('sudo echo "server.%d=%s:2888:3888" >> /etc/zookeeper/conf/zoo.cfg' %(zk_index, zk_ip)) + local('sudo echo "server.%d=%s:2888:3888" >> /etc/zookeeper/zoo.cfg' %(zk_index, zk_ip)) zk_index = zk_index + 1 #put cluster-unique zookeeper's instance id in myid - local('sudo echo "%s" > /var/lib/zookeeper/myid' %(self._args.cfgm_index)) + if pdist == 'fedora' or pdist == 'centos': + local('sudo echo "%s" > /var/lib/zookeeper/data/myid' %(self._args.cfgm_index)) + if pdist == 'Ubuntu': + local('sudo echo "%s" > /var/lib/zookeeper/myid' %(self._args.cfgm_index)) # Configure rabbitmq config file with settings(warn_only = True): @@ -1228,7 +1151,7 @@ def fixup_config_files(self): template_vals, temp_dir_name + '/vrouter_nodemgr_param') local("sudo mv %s/vrouter_nodemgr_param /etc/contrail/vrouter_nodemgr_param" %(temp_dir_name)) - keystone_ip = self._args.keystone_ip + openstack_ip = self._args.openstack_ip compute_ip = self._args.compute_ip if self.haproxy: discovery_ip = '127.0.0.1' @@ -1300,57 +1223,80 @@ def fixup_config_files(self): with lcd(temp_dir_name): local("sudo sed 's/COLLECTOR=.*/COLLECTOR=%s/g;s/dev=.*/dev=%s/g' /etc/contrail/agent_param.tmpl > agent_param.new" %(collector_ip, dev)) local("sudo mv agent_param.new /etc/contrail/agent_param") - vnswad_conf_template_vals = {'__contrail_vhost_ip__': cidr, - '__contrail_vhost_gateway__': gateway, - '__contrail_discovery_ip__': discovery_ip, - '__contrail_discovery_ncontrol__': ncontrols, - '__contrail_physical_intf__': dev, - '__contrail_control_ip__': compute_ip, - } - self._template_substitute_write(vnswad_conf_template.template, - vnswad_conf_template_vals, temp_dir_name + '/vnswad.conf') + # set agent conf with control node IPs, first remove old ones + agent_tree = ET.parse('/etc/contrail/rpm_agent.conf') + agent_root = agent_tree.getroot() + agent_elem = agent_root.find('agent') + vhost_elem = agent_elem.find('vhost') + for vip in vhost_elem.findall('ip-address'): + vhost_elem.remove (vip) + vip = ET.Element('ip-address') + vip.text = cidr + vhost_elem.append(vip) + for gw in vhost_elem.findall('gateway'): + vhost_elem.remove (gw) + if gateway: + gw = ET.Element('gateway') + gw.text = gateway + vhost_elem.append(gw) + + ethpt_elem = agent_elem.find('eth-port') + for pn in ethpt_elem.findall('name'): + ethpt_elem.remove (pn) + pn = ET.Element('name') + pn.text = dev + ethpt_elem.append(pn) if vgw_public_vn_name and vgw_public_subnet: vgw_public_vn_name = vgw_public_vn_name[1:-1].split(';') vgw_public_subnet = vgw_public_subnet[1:-1].split(';') vgw_intf_list = vgw_intf_list[1:-1].split(';') - gateway_str = "" if vgw_gateway_routes != None: vgw_gateway_routes = vgw_gateway_routes[1:-1].split(';') for i in range(len(vgw_public_vn_name)): - gateway_str += '\n[%s%d]\n' %("Gateway-", i) - gateway_str += "# Name of the routing_instance for which the gateway is being configured\n" - gateway_str += "routing_instance=" + vgw_public_vn_name[i] + "\n\n" - gateway_str += "# Gateway interface name\n" - gateway_str += "interface=" + vgw_intf_list[i] + "\n\n" - gateway_str += "# Virtual network ip blocks for which gateway service is required. Each IP\n" - gateway_str += "# block is represented as ip/prefix. Multiple IP blocks are represented by\n" - gateway_str += "# separating each with a space\n" - gateway_str += "ip_blocks=" - + gateway_elem = ET.Element("gateway") + gateway_elem.set("virtual-network", vgw_public_vn_name[i]) + virtual_network_interface_elem = ET.Element('interface') + virtual_network_interface_elem.text = vgw_intf_list[i] + gateway_elem.append(virtual_network_interface_elem) if vgw_public_subnet[i].find("[") !=-1: for ele in vgw_public_subnet[i][1:-1].split(","): - gateway_str += ele[1:-1] + " " + virtual_network_subnet_elem = ET.Element('subnet') + virtual_network_subnet_elem.text =ele[1:-1] + gateway_elem.append(virtual_network_subnet_elem) else: - gateway_str += vgw_public_subnet[i] - gateway_str += "\n\n" + virtual_network_subnet_elem = ET.Element('subnet') + virtual_network_subnet_elem.text =vgw_public_subnet[i] + gateway_elem.append(virtual_network_subnet_elem) if vgw_gateway_routes != None and i < len(vgw_gateway_routes): if vgw_gateway_routes[i] != '[]': - gateway_str += "# Routes to be exported in routing_instance. Each route is represented as\n" - gateway_str += "# ip/prefix. Multiple routes are represented by separating each with a space\n" - gateway_str += "routes=" if vgw_gateway_routes[i].find("[") !=-1: for ele in vgw_gateway_routes[i][1:-1].split(","): - gateway_str += ele[1:-1] + " " + vgw_gateway_routes_elem = ET.Element('route') + vgw_gateway_routes_elem.text =ele[1:-1] + gateway_elem.append(vgw_gateway_routes_elem) else: - gateway_str += vgw_gateway_routes[i] - gateway_str += "\n" - filename = temp_dir_name + "/vnswad.conf" - with open(filename, "a") as f: - f.write(gateway_str) + vgw_gateway_routes_elem = ET.Element('route') + vgw_gateway_routes_elem.text =vgw_gateway_routes[i] + gateway_elem.append(vgw_gateway_routes_elem) + agent_elem.append(gateway_elem) - local("sudo cp %s/vnswad.conf /etc/contrail/contrail-vrouter-agent.conf" %(temp_dir_name)) - local("sudo rm %s/vnswad.conf*" %(temp_dir_name)) + + self._replace_discovery_server(agent_elem, discovery_ip, ncontrols) + + control_elem = ET.Element('control') + control_ip_elem = ET.Element('ip-address') + control_ip_elem.text = compute_ip + control_elem.append(control_ip_elem) + agent_elem.append(control_elem) + + agent_tree = agent_tree.write('%s/agent.conf' %(temp_dir_name)) + with settings(warn_only = True): + local("cp %s/agent.conf %s/agent.conf.1" %(temp_dir_name,temp_dir_name)) + if local("xmllint --format %s/agent.conf.1").succeeded: + local("xmllint --format %s/agent.conf.1 > %s/agent.conf" %(temp_dir_name,temp_dir_name)) + local("sudo cp %s/agent.conf /etc/contrail/agent.conf" %(temp_dir_name)) + local("sudo rm %s/agent.conf*" %(temp_dir_name)) if pdist == 'centos' or pdist == 'fedora': ## make ifcfg-vhost0 @@ -1399,7 +1345,6 @@ def fixup_config_files(self): self.migrate_routes(dev) with settings(warn_only = True): - local("sudo cp -f %s/ifcfg-%s /etc/sysconfig/network-scripts/ifcfg-%s" % (temp_dir_name, dev, dev)) local("sudo mv %s/ifcfg-%s /etc/contrail/" % (temp_dir_name, dev)) local("sudo chkconfig network on") @@ -1411,16 +1356,21 @@ def fixup_config_files(self): # end pdist == ubuntu else: # of if dev and dev != 'vhost0' - if not os.path.isfile("/etc/contrail/contrail-vrouter-agent.conf"): - if os.path.isfile("/opt/contrail/contrail_installer/contrail_config_templates/agent_xml2ini.py"): - local("sudo python /opt/contrail/contrail_installer/contrail_config_templates/agent_xml2ini.py") + local("sudo cp /etc/contrail/agent.conf %s/agent.conf" %(temp_dir_name)) + agent_tree = ET.parse('%s/agent.conf' %(temp_dir_name)) + agent_root = agent_tree.getroot() + agent_elem = agent_root.find('agent') + self._replace_discovery_server(agent_elem, discovery_ip, ncontrols) + + agent_tree = agent_tree.write('%s/agent.conf' %(temp_dir_name)) + local("sudo cp %s/agent.conf /etc/contrail/agent.conf" %(temp_dir_name)) + local("sudo rm %s/agent.conf" %(temp_dir_name)) #end if dev and dev != 'vhost0' : # role == compute && !cfgm if 'webui' in self._args.role: openstack_ip = self._args.openstack_ip - keystone_ip = self._args.keystone_ip local("sudo sed \"s/config.cnfg.server_ip.*/config.cnfg.server_ip = '%s';/g\" /etc/contrail/config.global.js > config.global.js.new" %(cfgm_ip)) local("sudo mv config.global.js.new /etc/contrail/config.global.js") local("sudo sed \"s/config.networkManager.ip.*/config.networkManager.ip = '%s';/g\" /etc/contrail/config.global.js > config.global.js.new" %(cfgm_ip)) @@ -1429,7 +1379,7 @@ def fixup_config_files(self): local("sudo mv config.global.js.new /etc/contrail/config.global.js") local("sudo sed \"s/config.computeManager.ip.*/config.computeManager.ip = '%s';/g\" /etc/contrail/config.global.js > config.global.js.new" %(openstack_ip)) local("sudo mv config.global.js.new /etc/contrail/config.global.js") - local("sudo sed \"s/config.identityManager.ip.*/config.identityManager.ip = '%s';/g\" /etc/contrail/config.global.js > config.global.js.new" %(keystone_ip)) + local("sudo sed \"s/config.identityManager.ip.*/config.identityManager.ip = '%s';/g\" /etc/contrail/config.global.js > config.global.js.new" %(openstack_ip)) local("sudo mv config.global.js.new /etc/contrail/config.global.js") local("sudo sed \"s/config.storageManager.ip.*/config.storageManager.ip = '%s';/g\" /etc/contrail/config.global.js > config.global.js.new" %(openstack_ip)) local("sudo mv config.global.js.new /etc/contrail/config.global.js") @@ -1490,16 +1440,13 @@ def run_services(self): local("sudo ./contrail_setup_utils/nova-server-setup.sh") if 'config' in self._args.role: - keystone_ip = self._args.keystone_ip - region_name = self._args.region_name + openstack_ip = self._args.openstack_ip quantum_ip = self._args.cfgm_ip local("sudo ./contrail_setup_utils/config-server-setup.sh") local("sudo ./contrail_setup_utils/quantum-server-setup.sh") quant_args = "--ks_server_ip %s --quant_server_ip %s --tenant %s --user %s --password %s --svc_password %s --root_password %s" \ - %(keystone_ip, quantum_ip, ks_admin_tenant_name, ks_admin_user, ks_admin_password, self.service_token, + %(openstack_ip, quantum_ip, ks_admin_tenant_name, ks_admin_user, ks_admin_password, self.service_token, env.password) - if region_name: - quant_args += " --region_name %s" %(region_name) local("python /opt/contrail/contrail_installer/contrail_setup_utils/setup-quantum-in-keystone.py %s" %(quant_args)) if 'collector' in self._args.role: diff --git a/contrail_setup_utils/storage-ceph-setup.py b/contrail_setup_utils/storage-ceph-setup.py index b06f87a4..948bc76c 100755 --- a/contrail_setup_utils/storage-ceph-setup.py +++ b/contrail_setup_utils/storage-ceph-setup.py @@ -20,6 +20,14 @@ import xml.etree.ElementTree as ET import platform +#dist = platform.dist()[0] +#if dist == 'centos': +# _tgt_path = os.path.abspath(os.path.dirname(sys.argv[0])) +# subprocess.call("sudo pip-python install %s/contrail_setup_utils/pycrypto-2.6.tar.gz" %(_tgt_path), shell=True) +# subprocess.call("sudo pip-python install %s/contrail_setup_utils/paramiko-1.11.0.tar.gz" %(_tgt_path), shell=True) +# subprocess.call("sudo pip-python install %s/contrail_setup_utils/Fabric-1.7.0.tar.gz" %(_tgt_path), shell=True) +# subprocess.call("sudo pip-python install %s/contrail_setup_utils/zope.interface-3.7.0.tar.gz" %(_tgt_path), shell=True) + import tempfile from fabric.api import local, env, run from fabric.operations import get, put @@ -30,63 +38,6 @@ sys.path.insert(0, os.getcwd()) class SetupCeph(object): - - def reset_mon_local_list(self): - local('echo "get_local_daemon_ulist() {" > /tmp/mon_local_list.sh') - local('echo "if [ -d \\"/var/lib/ceph/mon\\" ]; then" >> /tmp/mon_local_list.sh') - local('echo "for i in \`find -L /var/lib/ceph/mon -mindepth 1 -maxdepth 1 -type d -printf \'%f\\\\\\n\'\`; do" >> /tmp/mon_local_list.sh') - local('echo "if [ -e \\"/var/lib/ceph/mon/\$i/upstart\\" ]; then" >> /tmp/mon_local_list.sh') - local('echo "id=\`echo \$i | sed \'s/[^-]*-//\'\`" >> /tmp/mon_local_list.sh') - local('echo "sudo stop ceph-mon id=\$id" >> /tmp/mon_local_list.sh') - local('echo "fi done fi" >> /tmp/mon_local_list.sh') - local('echo "}" >> /tmp/mon_local_list.sh') - local('echo "get_local_daemon_ulist" >> /tmp/mon_local_list.sh') - local('echo "exit 0" >> /tmp/mon_local_list.sh') - local('chmod a+x /tmp/mon_local_list.sh') - local('/tmp/mon_local_list.sh') - - def reset_osd_local_list(self): - local('echo "get_local_daemon_ulist() {" > /tmp/osd_local_list.sh') - local('echo "if [ -d \\"/var/lib/ceph/osd\\" ]; then" >> /tmp/osd_local_list.sh') - local('echo "for i in \`find -L /var/lib/ceph/osd -mindepth 1 -maxdepth 1 -type d -printf \'%f\\\\\\n\'\`; do" >> /tmp/osd_local_list.sh') - local('echo "if [ -e \\"/var/lib/ceph/osd/\$i/upstart\\" ]; then" >> /tmp/osd_local_list.sh') - local('echo "id=\`echo \$i | sed \'s/[^-]*-//\'\`" >> /tmp/osd_local_list.sh') - local('echo "sudo stop ceph-osd id=\$id" >> /tmp/osd_local_list.sh') - local('echo "fi done fi" >> /tmp/osd_local_list.sh') - local('echo "}" >> /tmp/osd_local_list.sh') - local('echo "get_local_daemon_ulist" >> /tmp/osd_local_list.sh') - local('echo "exit 0" >> /tmp/osd_local_list.sh') - local('chmod a+x /tmp/osd_local_list.sh') - local('/tmp/osd_local_list.sh') - - def reset_mon_remote_list(self): - run('echo "get_local_daemon_ulist() {" > /tmp/mon_local_list.sh') - run('echo "if [ -d \\\\"/var/lib/ceph/mon\\\\" ]; then" >> /tmp/mon_local_list.sh') - run('echo "for i in \\\\`find -L /var/lib/ceph/mon -mindepth 1 -maxdepth 1 -type d -printf \'%f\\\\\\n\'\\\\`; do" >> /tmp/mon_local_list.sh') - run('echo "if [ -e \\\\"/var/lib/ceph/mon/\\\\$i/upstart\\\\" ]; then" >> /tmp/mon_local_list.sh') - run('echo "id=\\\\`echo \\\\$i | sed \'s/[^-]*-//\'\\\\`" >> /tmp/mon_local_list.sh') - run('echo "sudo stop ceph-mon id=\\\\$id" >> /tmp/mon_local_list.sh') - run('echo "fi done fi" >> /tmp/mon_local_list.sh') - run('echo "}" >> /tmp/mon_local_list.sh') - run('echo "get_local_daemon_ulist" >> /tmp/mon_local_list.sh') - run('echo "exit 0" >> /tmp/mon_local_list.sh') - run('chmod a+x /tmp/mon_local_list.sh') - run('/tmp/mon_local_list.sh') - - def reset_osd_remote_list(self): - run('echo "get_local_daemon_ulist() {" > /tmp/osd_local_list.sh') - run('echo "if [ -d \\\\"/var/lib/ceph/osd\\\\" ]; then" >> /tmp/osd_local_list.sh') - run('echo "for i in \\\\`find -L /var/lib/ceph/osd -mindepth 1 -maxdepth 1 -type d -printf \'%f\\\\\\n\'\\\\`; do" >> /tmp/osd_local_list.sh') - run('echo "if [ -e \\\\"/var/lib/ceph/osd/\\\\$i/upstart\\\\" ]; then" >> /tmp/osd_local_list.sh') - run('echo "id=\\\\`echo \\\\$i | sed \'s/[^-]*-//\'\\\\`" >> /tmp/osd_local_list.sh') - run('echo "sudo stop ceph-osd id=\\\\$id" >> /tmp/osd_local_list.sh') - run('echo "fi done fi" >> /tmp/osd_local_list.sh') - run('echo "}" >> /tmp/osd_local_list.sh') - run('echo "get_local_daemon_ulist" >> /tmp/osd_local_list.sh') - run('echo "exit 0" >> /tmp/osd_local_list.sh') - run('chmod a+x /tmp/osd_local_list.sh') - run('/tmp/osd_local_list.sh') - def __init__(self, args_str = None): #print sys.argv[1:] self._args = None @@ -98,17 +49,13 @@ def __init__(self, args_str = None): for hostname, host_ip in zip(self._args.storage_hostnames, self._args.storage_hosts): run('cat /etc/hosts |grep -v %s > /tmp/hosts; echo %s %s >> /tmp/hosts; cp -f /tmp/hosts /etc/hosts' % (hostname, host_ip, hostname)) ceph_mon_hosts='' - pdist = platform.dist()[0] for entries in self._args.storage_hostnames: ceph_mon_hosts=ceph_mon_hosts+entries+' ' #print ceph_mon_hosts # setup SSH for autologin for Ceph - local('sudo rm -rf ~/.ssh/id_rsa') - local('sudo ssh-keygen -t rsa -N "" -f ~/.ssh/id_rsa') + local('sudo ssh-keygen -t rsa -N "" -f ~/.ssh/id_rsa <<< \"y\"') sshkey=local('cat ~/.ssh/id_rsa.pub', capture=True) local('sudo mkdir -p ~/.ssh') - local('sudo echo "%s" >> ~/.ssh/known_hosts' % (sshkey)) - local('sudo echo "%s" >> ~/.ssh/authorized_keys' % (sshkey)) for entries, entry_token, hostname in zip(self._args.storage_hosts, self._args.storage_host_tokens, self._args.storage_hostnames): if entries != self._args.storage_master: with settings(host_string = 'root@%s' %(entries), password = entry_token): @@ -120,87 +67,55 @@ def __init__(self, args_str = None): out = run('sudo ssh-keyscan -t rsa %s,%s' %(hostname,entries)) local('sudo echo "%s" >> ~/.ssh/known_hosts' % (out)) #local('sudo echo "%s" >> ~/.ssh/authorized_keys' % (out)) - ocs_blk_disk = local('(. /etc/contrail/openstackrc ; cinder type-list | grep ocs-block-disk | cut -d"|" -f 2)', capture=True) - if ocs_blk_disk != "": - cinderlst = local('(. /etc/contrail/openstackrc ; cinder list | grep ocs-block-disk | cut -d"|" -f 2)', capture=True) - if cinderlst != "": - cinderalst = cinderlst.split('\n') - for x in cinderalst: - inuse = local('(. /etc/contrail/openstackrc ; cinder list | grep %s | cut -d"|" -f 3)' % (x), capture=True) - if inuse == "in-use": - detach = local('(. /etc/contrail/openstackrc ; cinder list | grep %s | cut -d"|" -f 8)' % (x), capture=True) - local('(. /etc/contrail/openstackrc ; nova volume-detach %s %s)' % (detach, x)) - local('(. /etc/contrail/openstackrc ; cinder force-delete %s)' % (x)) - local('. /etc/contrail/openstackrc ; cinder type-delete %s' % (ocs_blk_disk)) # stop existing ceph monitor/osd local('pwd') - if pdist == 'centos': - local('/etc/init.d/ceph stop osd') - local('/etc/init.d/ceph stop mon') - if pdist == 'Ubuntu': - self.reset_mon_local_list() - self.reset_osd_local_list() - #local('chmod a+x /tmp/ceph.stop.sh') - #local('/tmp/ceph.stop.sh') + local('/etc/init.d/ceph stop osd') + local('/etc/init.d/ceph stop mon') for entries, entry_token in zip(self._args.storage_hosts, self._args.storage_host_tokens): if entries != self._args.storage_master: with settings(host_string = 'root@%s' %(entries), password = entry_token): - if pdist == 'centos': - run('echo "/etc/init.d/ceph stop osd" > /tmp/ceph.stop.sh') - run('echo "/etc/init.d/ceph stop mon" >> /tmp/ceph.stop.sh') - run('chmod a+x /tmp/ceph.stop.sh') - run('/tmp/ceph.stop.sh') - if pdist == 'Ubuntu': - self.reset_mon_remote_list() - self.reset_osd_remote_list() - time.sleep(2) - local('sudo ceph-deploy purgedata %s <<< \"y\"' % (ceph_mon_hosts), capture=False, shell='/bin/bash') + run('echo "/etc/init.d/ceph stop osd" > /tmp/ceph.stop.sh') + run('echo "/etc/init.d/ceph stop mon" >> /tmp/ceph.stop.sh') + run('chmod a+x /tmp/ceph.stop.sh') + run('/tmp/ceph.stop.sh') + local('sudo ceph-deploy purgedata %s <<< \"y\"' % (ceph_mon_hosts)) local('sudo mkdir -p /var/lib/ceph/bootstrap-osd') local('sudo mkdir -p /var/lib/ceph/osd') local('sudo mkdir -p /etc/ceph') - if self._args.storage_directory_config[0] != 'none': - for directory in self._args.storage_directory_config: - for hostname, entries, entry_token in zip(self._args.storage_hostnames, self._args.storage_hosts, self._args.storage_host_tokens): - dirsplit = directory.split(':') - if dirsplit[0] == hostname: - if entries != self._args.storage_master: - with settings(host_string = 'root@%s' %(entries), password = entry_token): - run('sudo mkdir -p %s' % (dirsplit[1])) - run('sudo rm -rf %s' % (dirsplit[1])) - run('sudo mkdir -p %s' % (dirsplit[1])) - else: - local('sudo mkdir -p %s' % (dirsplit[1])) - local('sudo rm -rf %s' % (dirsplit[1])) - local('sudo mkdir -p %s' % (dirsplit[1])) + if self._args.storage_directory_config[0] != 'none': + for entries, entry_token, directory in zip(self._args.storage_hosts, self._args.storage_host_tokens, self._args.storage_directory_config): + dir = directory.split(':') + if entries != self._args.storage_master: + with settings(host_string = 'root@%s' %(entries), password = entry_token): + run('sudo mkdir -p %s' % (dir[1])) + run('sudo rm -rf %s' % (dir[1])) + run('sudo mkdir -p %s' % (dir[1])) + else: + local('sudo mkdir -p %s' % (dir[1])) + local('sudo rm -rf %s' % (dir[1])) + local('sudo mkdir -p %s' % (dir[1])) for entries, entry_token in zip(self._args.storage_hosts, self._args.storage_host_tokens): if entries != self._args.storage_master: with settings(host_string = 'root@%s' %(entries), password = entry_token): - run('sudo mkdir -p /var/lib/ceph/bootstrap-osd') + run('sudo mkdir -p /var/lib/ceph/bootstrap-osd') run('sudo mkdir -p /var/lib/ceph/osd') - run('sudo mkdir -p /etc/ceph') + run('sudo mkdir -p /etc/ceph') # Ceph deploy create monitor - local('sudo ceph-deploy new %s' % (ceph_mon_hosts)) + local('sudo ceph-deploy new %s' % (ceph_mon_hosts)) local('sudo ceph-deploy mon create %s' % (ceph_mon_hosts)) - if self._args.storage_disk_config[0] != 'none': - for disks in self._args.storage_disk_config: - local('sudo ceph-deploy disk zap %s' % (disks)) - time.sleep(10) + for disks in self._args.storage_disk_config: + local('sudo ceph-deploy disk zap %s' % (disks)) for entries in self._args.storage_hostnames: local('sudo ceph-deploy gatherkeys %s' % (entries)) # Ceph deploy OSD create - if self._args.storage_directory_config[0] != 'none': + if self._args.storage_directory_config[0] != 'none': for directory in self._args.storage_directory_config: local('sudo ceph-deploy osd prepare %s' % (directory)) for directory in self._args.storage_directory_config: local('sudo ceph-deploy osd activate %s' % (directory)) - if self._args.storage_disk_config[0] != 'none': - for disks in self._args.storage_disk_config: - if pdist == 'centos': - local('sudo ceph-deploy osd create %s' % (disks)) - if pdist == 'Ubuntu': - local('sudo ceph-deploy osd prepare %s' % (disks)) - local('sudo ceph-deploy osd activate %s' % (disks)) + for disks in self._args.storage_disk_config: + local('sudo ceph-deploy osd create %s' % (disks)) # Create pools local('unset CEPH_ARGS') local('sudo rados mkpool volumes') @@ -222,13 +137,10 @@ def __init__(self, args_str = None): run('sudo openstack-config --set /etc/ceph/ceph.conf client.images keyring /etc/ceph/client.images.keyring') local('cat ~/.bashrc |grep -v CEPH_ARGS > /tmp/.bashrc') local('mv -f /tmp/.bashrc ~/.bashrc') - local('echo export CEPH_ARGS=\\"--id volumes\\" >> ~/.bashrc') - local('. ~/.bashrc') + local('echo -e export CEPH_ARGS=\\"--id volumes\\" >> ~/.bashrc') + local('source ~/.bashrc') local('ceph-authtool -p -n client.volumes /etc/ceph/client.volumes.keyring > /etc/ceph/client.volumes') - if pdist == 'centos': - local('sudo service libvirtd restart') - if pdist == 'Ubuntu': - local('sudo service libvirt-bin restart') + local('sudo service libvirtd restart') virsh_unsecret=local('virsh secret-list 2>&1 |cut -d " " -f 1 | awk \'NR > 2 { print }\' | head -n 1', capture=True) if virsh_unsecret != "": local('virsh secret-undefine %s' %(virsh_unsecret)) @@ -244,16 +156,12 @@ def __init__(self, args_str = None): for entries, entry_token in zip(self._args.storage_hosts, self._args.storage_host_tokens): if entries != self._args.storage_master: with settings(host_string = 'root@%s' %(entries), password = entry_token): - if pdist == 'centos': - run('cat ~/.bashrc |grep -v CEPH_ARGS > /tmp/.bashrc') - run('mv -f /tmp/.bashrc ~/.bashrc') - run('echo export CEPH_ARGS=\\\\"--id volumes\\\\" >> ~/.bashrc') - run('. ~/.bashrc') - run('sudo ceph-authtool -p -n client.volumes /etc/ceph/client.volumes.keyring > /etc/ceph/client.volumes') - local('sudo service libvirtd restart') - if pdist == 'Ubuntu': - run('sudo ceph-authtool -p -n client.volumes /etc/ceph/client.volumes.keyring > /etc/ceph/client.volumes') - local('sudo service libvirt-bin restart') + run('cat ~/.bashrc |grep -v CEPH_ARGS > /tmp/.bashrc') + run('mv -f /tmp/.bashrc ~/.bashrc') + run('echo -e export CEPH_ARGS=\\\\"--id volumes\\\\" >> ~/.bashrc') + run('source ~/.bashrc') + run('sudo ceph-authtool -p -n client.volumes /etc/ceph/client.volumes.keyring > /etc/ceph/client.volumes') + run('sudo service libvirtd restart') virsh_unsecret=run('virsh secret-list 2>&1 |cut -d " " -f 1 | awk \'NR > 2 { print }\' | head -n 1') if virsh_unsecret != "": run('virsh secret-undefine %s' %(virsh_unsecret)) @@ -276,85 +184,66 @@ def __init__(self, args_str = None): for entries, entry_token in zip(self._args.storage_hosts, self._args.storage_host_tokens): if entries != self._args.storage_master: with settings(host_string = 'root@%s' %(entries), password = entry_token): - # Change nova conf for cinder client configuration - run('sudo openstack-config --set /etc/nova/nova.conf DEFAULT rbd_user volumes') - run('sudo openstack-config --set /etc/nova/nova.conf DEFAULT rbd_secret_uuid %s' % (virsh_secret)) - run('sudo openstack-config --set /etc/nova/nova.conf DEFAULT cinder_endpoint_template "http://%s:8776/v1/%%(project_id)s"' % (self._args.storage_master), shell='/bin/bash') - + run('sudo openstack-config --set /etc/cinder/cinder.conf DEFAULT sql_connection mysql://cinder:cinder@%s/cinder' % (self._args.storage_master)) + run('sudo openstack-config --set /etc/cinder/cinder.conf DEFAULT qpid_hostname %s' % (self._args.storage_master)) + run('sudo openstack-config --set /etc/cinder/cinder.conf DEFAULT enabled_backends rbd-disk') + run('sudo cat /etc/cinder/cinder.conf |grep -v "\\[rbd-disk\\]"| sed s/rbd-disk/"rbd-disk\\n\\n[rbd-disk]"/ > /etc/cinder/cinder.conf.bk') + run('sudo cp /etc/cinder/cinder.conf.bk /etc/cinder/cinder.conf') + run('sudo openstack-config --set /etc/cinder/cinder.conf rbd-disk volume_driver cinder.volume.drivers.rbd.RBDDriver') + run('sudo openstack-config --set /etc/cinder/cinder.conf rbd-disk rbd_pool volumes') + run('sudo openstack-config --set /etc/cinder/cinder.conf rbd-disk rbd_user volumes') + run('sudo openstack-config --set /etc/cinder/cinder.conf rbd-disk rbd_secret_uuid %s' % (virsh_secret)) + run('sudo openstack-config --set /etc/cinder/cinder.conf rbd-disk glance_api_version 2') + run('sudo openstack-config --set /etc/cinder/cinder.conf rbd-disk volume_backend_name RBD') + run('sudo openstack-config --set /etc/cinder/cinder.conf keystone_authtoken auth_host %s' % (self._args.storage_master)) + run('sudo openstack-config --set /etc/cinder/cinder.conf keystone_authtoken admin_tenant_name service') + run('sudo openstack-config --set /etc/cinder/cinder.conf keystone_authtoken admin_user cinder') + run('sudo openstack-config --set /etc/cinder/cinder.conf keystone_authtoken admin_password %s' % (admin_pass)) #Glance configuration local('sudo openstack-config --set /etc/glance/glance-api.conf DEFAULT default_store rbd') local('sudo openstack-config --set /etc/glance/glance-api.conf DEFAULT show_image_direct_url True') local('sudo openstack-config --set /etc/glance/glance-api.conf DEFAULT rbd_store_user images') #Restart services - if pdist == 'centos': - local('sudo service qpidd restart') - local('sudo service quantum-server restart') - local('sudo chkconfig openstack-cinder-api on') - local('sudo service openstack-cinder-api restart') - local('sudo chkconfig openstack-cinder-scheduler on') - local('sudo service openstack-cinder-scheduler restart') - bash_cephargs = local('grep "bashrc" /etc/init.d/openstack-cinder-volume | wc -l', capture=True) - if bash_cephargs == "0": - local('cat /etc/init.d/openstack-cinder-volume | sed "s/start)/start) source ~\/.bashrc/" > /tmp/openstack-cinder-volume.tmp') - local('mv -f /tmp/openstack-cinder-volume.tmp /etc/init.d/openstack-cinder-volume; chmod a+x /etc/init.d/openstack-cinder-volume') - local('sudo chkconfig openstack-cinder-volume on') - local('sudo service openstack-cinder-volume restart') - local('sudo service openstack-glance-api restart') - local('sudo service openstack-nova-api restart') - local('sudo service openstack-nova-conductor restart') - local('sudo service openstack-nova-scheduler restart') - local('sudo service libvirtd restart') - local('sudo service openstack-nova-api restart') - local('sudo service openstack-nova-scheduler restart') - if pdist == 'Ubuntu': - local('sudo chkconfig cinder-api on') - local('sudo service cinder-api restart') - local('sudo chkconfig cinder-scheduler on') - local('sudo service cinder-scheduler restart') - bash_cephargs = local('grep "CEPH_ARGS" /etc/init.d/cinder-volume | wc -l', capture=True) - print bash_cephargs - if bash_cephargs == "0": - local('cat /etc/init.d/cinder-volume | awk \'{ print; if ($1== "start|stop)") print \" CEPH_ARGS=\\"--id volumes\\"\" }\' > /tmp/cinder-volume.tmp') - local('mv -f /tmp/cinder-volume.tmp /etc/init.d/cinder-volume; chmod a+x /etc/init.d/cinder-volume') - local('sudo chkconfig cinder-volume on') - local('sudo service cinder-volume restart') - local('sudo service glance-api restart') - local('sudo service nova-api restart') - local('sudo service nova-conductor restart') - local('sudo service nova-scheduler restart') - local('sudo service libvirt-bin restart') - local('sudo service nova-api restart') - local('sudo service nova-scheduler restart') - local('(. /etc/contrail/openstackrc ; cinder type-create ocs-block-disk)') - local('(. /etc/contrail/openstackrc ; cinder type-key ocs-block-disk set volume_backend_name=RBD)') - local('sudo service cinder-volume restart') - avail=local('rados df | grep avail | awk \'{ print $3 }\'', capture = True) - # use only half the space as 1 replica is enabled - avail_gb = int(avail)/1024/1024/2 - local('(. /etc/contrail/openstackrc ; cinder quota-update ocs-block-disk --gigabytes %s)' % (avail_gb)) - #local('(. /etc/contrail/openstackrc ; cinder quota-update ocs-block-disk --gigabytes 1000)') - local('(. /etc/contrail/openstackrc ; cinder quota-update ocs-block-disk --volumes 100)') - local('(. /etc/contrail/openstackrc ; cinder quota-update ocs-block-disk --snapshots 100)') + local('sudo service qpidd restart') + local('sudo service quantum-server restart') + local('sudo chkconfig openstack-cinder-api on') + local('sudo service openstack-cinder-api restart') + local('sudo chkconfig openstack-cinder-scheduler on') + local('sudo service openstack-cinder-scheduler restart') + bash_cephargs = local('grep "bashrc" /etc/init.d/openstack-cinder-volume | wc -l', capture=True) + if bash_cephargs == "0": + local('cat /etc/init.d/openstack-cinder-volume | sed "s/start)/start) source ~\/.bashrc/" > /tmp/openstack-cinder-volume.tmp') + local('mv -f /tmp/openstack-cinder-volume.tmp /etc/init.d/openstack-cinder-volume; chmod a+x /etc/init.d/openstack-cinder-volume') + local('sudo chkconfig openstack-cinder-volume on') + local('sudo service openstack-cinder-volume restart') + local('sudo service openstack-glance-api restart') + local('sudo service openstack-nova-api restart') + local('sudo service openstack-nova-conductor restart') + local('sudo service openstack-nova-scheduler restart') + local('sudo service libvirtd restart') + local('sudo service openstack-nova-api restart') + local('sudo service openstack-nova-scheduler restart') + ocs_blk_disk = local('(source /etc/contrail/openstackrc ; cinder type-list | grep ocs-block-disk | cut -d"|" -f 2)', capture=True) + if ocs_blk_disk != "": + local('source /etc/contrail/openstackrc ; cinder type-delete %s' % (ocs_blk_disk)) + local('(source /etc/contrail/openstackrc ; cinder type-create ocs-block-disk)') + local('(source /etc/contrail/openstackrc ; cinder type-key ocs-block-disk set volume_backend_name=RBD)') for entries, entry_token in zip(self._args.storage_hosts, self._args.storage_host_tokens): if entries != self._args.storage_master: with settings(host_string = 'root@%s' %(entries), password = entry_token): - if pdist == 'centos': - run('sudo service openstack-cinder-api restart') - run('sudo chkconfig openstack-cinder-api on') - run('sudo service openstack-cinder-scheduler restart') - run('sudo chkconfig openstack-cinder-scheduler on') - bash_cephargs = run('grep "bashrc" /etc/init.d/openstack-cinder-volume | wc -l') - if bash_cephargs == "0": - run('cat /etc/init.d/openstack-cinder-volume | sed "s/start)/start) source ~\/.bashrc/" > /tmp/openstack-cinder-volume.tmp') - run('mv -f /tmp/openstack-cinder-volume.tmp /etc/init.d/openstack-cinder-volume; chmod a+x /etc/init.d/openstack-cinder-volume') - run('sudo chkconfig openstack-cinder-volume on') - run('sudo service openstack-cinder-volume restart') - run('sudo service libvirtd restart') - run('sudo service openstack-nova-compute restart') - if pdist == 'Ubuntu': - run('sudo service libvirt-bin restart') - run('sudo service nova-compute restart') + run('sudo service openstack-cinder-api restart') + run('sudo chkconfig openstack-cinder-api on') + run('sudo service openstack-cinder-scheduler restart') + run('sudo chkconfig openstack-cinder-scheduler on') + bash_cephargs = run('grep "bashrc" /etc/init.d/openstack-cinder-volume | wc -l') + if bash_cephargs == "0": + run('cat /etc/init.d/openstack-cinder-volume | sed "s/start)/start) source ~\/.bashrc/" > /tmp/openstack-cinder-volume.tmp') + run('mv -f /tmp/openstack-cinder-volume.tmp /etc/init.d/openstack-cinder-volume; chmod a+x /etc/init.d/openstack-cinder-volume') + run('sudo chkconfig openstack-cinder-volume on') + run('sudo service openstack-cinder-volume restart') + run('sudo service libvirtd restart') + run('sudo service openstack-nova-compute restart') #end __init__ diff --git a/setup-vnc-cfgm.py b/setup-vnc-cfgm.py index 33cd6b1b..9842dde5 100755 --- a/setup-vnc-cfgm.py +++ b/setup-vnc-cfgm.py @@ -16,25 +16,22 @@ def __init__(self, args_str = None): args_str = ' '.join(sys.argv[1:]) self._parse_args(args_str) self_ip = self._args.self_ip - keystone_ip = self._args.keystone_ip + openstack_ip = self._args.openstack_ip collector_ip = self._args.collector_ip redis_ip = self._args.redis_ip quantum_port = self._args.quantum_port nworkers = self._args.nworkers service_token = self._args.service_token - region_name = self._args.region_name setup_args_str = "--role config " - setup_args_str = setup_args_str + " --cfgm_ip %s --keystone_ip %s --collector_ip %s " \ - %(self_ip, keystone_ip, collector_ip) + setup_args_str = setup_args_str + " --cfgm_ip %s --openstack_ip %s --collector_ip %s " \ + %(self_ip, openstack_ip, collector_ip) setup_args_str = setup_args_str + " --redis_master_ip %s" %(redis_ip) setup_args_str = setup_args_str + " --quantum_port %s" %(quantum_port) setup_args_str = setup_args_str + " --n_api_workers %s" %(nworkers) if service_token: setup_args_str = setup_args_str + " --service_token %s " %(service_token) - if region_name: - setup_args_str = setup_args_str + " --region_name %s " %(region_name) if self._args.use_certs: setup_args_str = setup_args_str + " --use_certs" if self._args.multi_tenancy: @@ -54,14 +51,13 @@ def __init__(self, args_str = None): def _parse_args(self, args_str): ''' - Eg. python setup-vnc-cfgm.py --self_ip 10.1.5.11 --keystone_ip 10.1.5.12 + Eg. python setup-vnc-cfgm.py --self_ip 10.1.5.11 --openstack_ip 10.1.5.12 --collector_ip 10.1.5.12 --service_token contrail123 --cassandra_ip_list 10.1.5.11 10.1.5.12 --zookeeper_ip_list 10.1.5.11 10.1.5.12 --cfgm_index 1 --nworkers 1 optional: --use_certs, --multi_tenancy --haproxy - --region_name ''' # Source any specified config/ini file @@ -75,14 +71,13 @@ def _parse_args(self, args_str): global_defaults = { 'self_ip': '127.0.0.1', 'collector_ip': '127.0.0.1', - 'keystone_ip': '127.0.0.1', + 'openstack_ip': '127.0.0.1', 'redis_ip': '127.0.0.1', 'service_token': '', 'use_certs': False, 'multi_tenancy': False, 'nworkers': '1', 'haproxy': False, - 'region_name': None, } if args.conf_file: @@ -106,7 +101,7 @@ def _parse_args(self, args_str): parser.add_argument("--self_ip", help = "IP Address of this system") parser.add_argument("--collector_ip", help = "IP Address of collector node") - parser.add_argument("--keystone_ip", help = "IP Address of keystone node") + parser.add_argument("--openstack_ip", help = "IP Address of openstack node") parser.add_argument("--redis_ip", help = "IP Address of redis server") parser.add_argument("--service_token", help = "The service password to access keystone") @@ -126,7 +121,6 @@ def _parse_args(self, args_str): help = "Number of worker processes for api and discovery services", default = '1') parser.add_argument("--haproxy", help = "Enable haproxy", action="store_true") - parser.add_argument("--region_name", help = "The Region name for the openstack") self._args = parser.parse_args(remaining_argv) diff --git a/setup-vnc-database.py b/setup-vnc-database.py index 316bdaa6..2e41915e 100755 --- a/setup-vnc-database.py +++ b/setup-vnc-database.py @@ -21,8 +21,6 @@ def __init__(self, args_str = None): data_dir = self._args.data_dir initial_token = self._args.initial_token seed_list = self._args.seed_list - analytics_data_dir = self._args.analytics_data_dir - ssd_data_dir = self._args.ssd_data_dir setup_args_str = "--role database" setup_args_str = setup_args_str + " --database_listen_ip %s" \ @@ -33,20 +31,11 @@ def __init__(self, args_str = None): if data_dir: setup_args_str = setup_args_str + " --data_dir %s" \ % (data_dir) - if analytics_data_dir: - setup_args_str = setup_args_str + " --analytics_data_dir %s" \ - % (analytics_data_dir) - if ssd_data_dir: - setup_args_str = setup_args_str + " --ssd_data_dir %s" \ - % (ssd_data_dir) if initial_token: setup_args_str = setup_args_str + " --database_initial_token %s" \ % (initial_token) if seed_list: setup_args_str = setup_args_str + " --database_seed_list %s" % (' '.join(seed_list)) - if self._args.cfgm_ip: - setup_args_str = setup_args_str + " --cfgm_ip %s" \ - % (self._args.cfgm_ip) setup_obj = Setup(setup_args_str) setup_obj.do_setup() @@ -89,13 +78,10 @@ def _parse_args(self, args_str): all_defaults = {'global': global_defaults} parser.set_defaults(**all_defaults) parser.add_argument("--self_ip", help = "IP Address of this database node") - parser.add_argument("--cfgm_ip", help = "IP Address of the config node") parser.add_argument("--dir", help = "Directory where database binary exists") parser.add_argument("--initial_token", help = "Initial token for database node") parser.add_argument("--seed_list", help = "List of seed nodes for database", nargs='+') parser.add_argument("--data_dir", help = "Directory where database stores data") - parser.add_argument("--analytics_data_dir", help = "Directory where database stores analytics data") - parser.add_argument("--ssd_data_dir", help = "SSD directory that database stores data") self._args = parser.parse_args(remaining_argv) #end _parse_args diff --git a/setup-vnc-interfaces.py b/setup-vnc-interfaces.py index 390de769..0aa7a0f8 100755 --- a/setup-vnc-interfaces.py +++ b/setup-vnc-interfaces.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -'''Provision Interface''' +'''Provision Interface and Configure Bond Interface''' # # Copyright (c) 2013 Juniper Networks, Inc. All rights reserved. # @@ -10,16 +10,14 @@ import re import sys import argparse +import shutil import socket import fcntl import struct import logging import platform import time -import json -import subprocess from netaddr import IPNetwork -from tempfile import NamedTemporaryFile logging.basicConfig(format='%(asctime)-15s:: %(funcName)s:%(levelname)s::\ %(message)s', @@ -27,76 +25,18 @@ log = logging.getLogger(__name__) PLATFORM = platform.dist()[0] -bond_opts_dict = {'arp_interval' : 'int', - 'arp_ip_target': 'ipaddr_list', - 'arp_validate' : ['none', 'active', 'backup', 'all'], - 'downdelay' : 'int', - 'fail_over_mac': 'macaddr', - 'lacp_rate' : ['slow', 'fast'], - 'miimon' : 'int', - 'mode' : ['balance-rr', 'active-backup', - 'balance-xor', 'broadcast', '802.3ad', - 'balance-tlb', 'balance-alb'], - 'primary' : 'string', - 'updelay' : 'int', - 'use_carrier' : 'int', - 'xmit_hash_policy': ['layer2', 'layer2+3', 'layer3+4'] - } - class BaseInterface(object): '''Base class containing common methods for configuring interface ''' def __init__(self, **kwargs): self.device = kwargs['device'] self.members = kwargs.get('members', []) + self.mode = kwargs.get('mode', 'balance-xor') self.ip = kwargs.get('ip', None) self.gw = kwargs.get('gw', None) - self.vlan = kwargs.get('vlan', None) - self.bond_opts = {'miimon': '100', 'mode': '802.3ad', - 'xmit_hash_policy': 'layer3+4'} - try: - self.bond_opts.update(json.loads(kwargs.get('bopts', {}))) - except ValueError: - log.warn("No bonding options specified using default %s", - self.bond_opts) - self.bond_opts_str = '' - self.mac_list = {} - self.tempfile = NamedTemporaryFile(delete=False) - - def validate_bond_opts(self): - for key in list(self.bond_opts): - if not self.is_valid_opts(key, self.bond_opts[key], bond_opts_dict): - del self.bond_opts[key] - else: - self.bond_opts_str += '%s=%s '%(key, self.bond_opts[key]) - - def is_valid_mac(self, mac): - if re.match("[0-9a-f]{2}(:)[0-9a-f]{2}(\\1[0-9a-f]{2}){4}$", mac.lower()): - return True - else: - return False - - def is_valid_ipaddr_list(p): - addr_list = ip.split(",") - for addr in addr_list: - socket.inet_pton(socket.AF_INET, addr) - return True - - def is_valid_opts(self, key, value, compare_dict): - if key in compare_dict: - try: - if (not isinstance(value, int) and value in compare_dict[key]) or\ - ('int' in compare_dict[key] and int(value)) or\ - ('macaddr' in compare_dict[key] and self.isvalid_mac(value)) or\ - ('ipaddr_list' in compare_dict[key] and - self.isvalid_ipaddr_list(value)) or\ - ('string' in compare_dict[key] and isinstance(value,basestring)): - return True - except: - log.warn("Caught Exception while processing (%s, %s)" %(key, value)) - log.warn("Supported options for key %s are %s" %(key, - str(compare_dict[key]))) - return False + self.type = kwargs.get('type', 'Ethernet') + self.ipaddr = None + self.netmask = None def write_network_script(self, device, cfg): '''Create an interface config file in network-scripts with given @@ -108,91 +48,55 @@ def write_network_script(self, device, cfg): if os.path.isfile(nwfile): tmpfile = os.path.join(os.path.dirname(nwfile), \ 'moved-%s' %os.path.basename(nwfile)) - log.info('Backup existing file %s to %s' %(nwfile, tmpfile)) - os.system('sudo mv %s %s' %(nwfile, tmpfile)) - with open(self.tempfile.name, 'w') as fd: - fd.write('\n'.join(['%s=%s' %(key, value) \ + shutil.move(nwfile, tmpfile) + with open(nwfile, 'w') as fid: + fid.write('\n'.join(['%s=%s' %(key, value) \ for key, value in cfg.items()])) - fd.write('\n') - os.system('sudo cp -f %s %s'%(self.tempfile.name, nwfile)) + fid.write('\n') + fid.flush() def get_mac_addr(self, iface): '''Retrieve mac address for the given interface in the system''' macaddr = None - if self.mac_list.has_key(iface): - return self.mac_list[iface] try: sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) - macinfo = fcntl.ioctl(sock.fileno(), 0x8927, - struct.pack('256s', iface[:15])) + macinfo = fcntl.ioctl(sock.fileno(), 0x8927, struct.pack('256s', iface[:15])) macaddr = ''.join(['%02x:' % ord(each) for each in macinfo[18:24]])[:-1] except IOError, err: log.warn('Seems there is no such interface (%s)' %iface) return macaddr - def create_vlan_interface(self): - '''Create interface config for vlan sub interface''' - vlanif = "%s.%s"%(self.device, self.vlan) - log.info('Creating vlan interface: %s' %vlanif) - cfg = {'DEVICE' : vlanif, - 'ONBOOT' : 'yes', - 'BOOTPROTO' : 'none', - 'NM_CONTROLLED' : 'no', - 'NETMASK' : self.netmask, - 'IPADDR' : self.ipaddr, - 'VLAN' : 'yes' - } - if self.gw: - cfg['GATEWAY'] = self.gw - self.write_network_script(vlanif, cfg) - - def create_bond_members(self): + def create_bond_members(self, master): '''Create interface config for each bond members''' # create slave interface - if not self.members: - log.warn('No slaves are specified for bond interface. Please use --members') for each in self.members: log.info('Creating bond member: %s' %each) + cfg = {} mac = self.get_mac_addr(each) cfg = {'DEVICE' : each, - 'ONBOOT' : 'yes', - 'BOOTPROTO' : 'none', + 'MASTER' : master, + 'SLAVE' : 'yes', + 'TYPE' : self.type, 'NM_CONTROLLED' : 'no', - 'HWADDR' : mac, - 'MASTER' : self.device, - 'SLAVE' : 'yes' - } + 'IPADDR' : '', + 'NETMASK' : '', + 'HWADDR' : mac} self.write_network_script(each, cfg) - - def get_mac_from_bond_intf(self): - output= os.popen("sudo cat /proc/net/bonding/%s"%self.device).read() - device_list= re.findall('Slave Interface:\s+(\S+)$', output, flags=re.M) - mac_list= re.findall('HW addr:\s+(\S+)$', output, flags=re.M) - if len(device_list) == len(mac_list): - for (device, mac) in zip(device_list, mac_list): - self.mac_list[device]= mac.lower() - + time.sleep(2) + def create_bonding_interface(self): '''Create interface config for bond master''' # create slave interface - self.get_mac_from_bond_intf() - self.create_bond_members() + self.create_bond_members(self.device) log.info('Creating bond master: %s' %self.device) cfg = {'DEVICE' : self.device, 'ONBOOT' : 'yes', - 'BOOTPROTO' : 'none', 'NM_CONTROLLED' : 'no', 'BONDING_MASTER': 'yes', - 'BONDING_OPTS' : "\"%s\""%self.bond_opts_str.strip() - } - if not self.vlan: - cfg.update({'NETMASK' : self.netmask, - 'IPADDR' : self.ipaddr - }) - if self.gw: - cfg['GATEWAY'] = self.gw - else: - self.create_vlan_interface() + 'BONDING_OPTS' : 'mode=%s' %self.mode, + 'BOOTPROTO' : 'none', + 'NETMASK' : self.netmask, + 'IPADDR' : self.ipaddr} self.write_network_script(self.device, cfg) def create_interface(self): @@ -201,23 +105,17 @@ def create_interface(self): mac = self.get_mac_addr(self.device) cfg = {'DEVICE' : self.device, 'ONBOOT' : 'yes', - 'BOOTPROTO' : 'none', 'NM_CONTROLLED' : 'no', + 'BOOTPROTO' : 'none', + 'NETMASK' : self.netmask, + 'IPADDR' : self.ipaddr, 'HWADDR' : mac} - if not self.vlan: - cfg.update({'NETMASK' : self.netmask, - 'IPADDR' : self.ipaddr - }) - if self.gw: - cfg['GATEWAY'] = self.gw - else: - self.create_vlan_interface() self.write_network_script(self.device, cfg) - + def restart_service(self): '''Restart network service''' log.info('Restarting Network Services...') - os.system('sudo service network restart') + os.system('service network restart') time.sleep(5) def post_conf(self): @@ -232,15 +130,12 @@ def setup(self): '''High level method to call individual methods to configure interface ''' - self.validate_bond_opts() self.pre_conf() if self.ip: ip = IPNetwork(self.ip) self.ipaddr = str(ip.ip) self.netmask = str(ip.netmask) - else: - raise Exception("IP address/mask is not specified") - if 'bond' in self.device.lower(): + if re.match(r'^bond', self.device): self.create_bonding_interface() else: self.create_interface() @@ -250,7 +145,7 @@ class UbuntuInterface(BaseInterface): def restart_service(self): '''Restart network service for Ubuntu''' log.info('Restarting Network Services...') - os.system('sudo /etc/init.d/networking restart') + os.system('/etc/init.d/networking restart') time.sleep(5) def remove_lines(self, ifaces, filename): @@ -261,9 +156,8 @@ def remove_lines(self, ifaces, filename): # read existing file if not filename: filename = os.path.join(os.path.sep, 'etc', 'network', 'interfaces') - - with open(filename, 'r') as fd: - cfg_file = fd.read() + with open(filename, 'r') as fid: + cfg_file = fid.read() # get blocks keywords = ['allow-', 'auto', 'iface', 'source', 'mapping'] @@ -273,116 +167,75 @@ def remove_lines(self, ifaces, filename): matches = map(cfg_file.__getslice__, indices, indices[1:] + [len(cfg_file)]) # backup old file - bckup = os.path.join(os.path.dirname(filename), 'orig.%s.%s' %( + bckup = os.path.join(os.path.dirname(filename), 'org.%s.%s' %( os.path.basename(filename),time.strftime('%d%m%y%H%M%S'))) - os.system('sudo cp %s %s' %(filename, bckup)) - os.system('sudo cp %s %s' %(filename, self.tempfile.name)) + shutil.copy(filename, bckup) + # write new file + fid = open(filename, 'w') + fid.write('%s\n' %cfg_file[0:indices[0]]) iface_pattern = '^\s*iface ' + " |^\s*iface ".join(ifaces) + ' ' auto_pattern = '^\s*auto ' + "|^\s*auto ".join(ifaces) - # write new file - with open(self.tempfile.name, 'w') as fd: - fd.write('%s\n' %cfg_file[0:indices[0]]) - for each in matches: - each = each.strip() - if re.match(auto_pattern, each) or re.match(iface_pattern, each): - continue - else: - fd.write('%s\n' %each) - fd.flush() - os.system('sudo cp -f %s %s'%(self.tempfile.name, filename)) + for each in matches: + each = each.strip() + if re.match(auto_pattern, each) or re.match(iface_pattern, each): + continue + else: + fid.write('%s\n' %each) + fid.flush() + fid.close() def pre_conf(self): '''Execute commands before interface configuration for Ubuntu''' filename = os.path.join(os.path.sep, 'etc', 'network', 'interfaces') ifaces = [self.device] + self.members - if self.vlan: - ifaces += [self.device + '.' + self.vlan, 'vlan'+self.vlan] self.remove_lines(ifaces, filename) - def validate_bond_opts(self): - self.bond_opts_str = 'bond-slaves none\n' - for key in list(self.bond_opts): - if not self.is_valid_opts(key, self.bond_opts[key], bond_opts_dict): - del self.bond_opts[key] - else: - self.bond_opts_str += 'bond-%s %s\n'%(key, self.bond_opts[key]) - def write_network_script(self, cfg): '''Append new configs to interfaces file''' interface_file = os.path.join(os.path.sep, 'etc', 'network', 'interfaces') - os.system('sudo cp %s %s' %(interface_file, self.tempfile.name)) - - # write new file - with open(self.tempfile.name, 'a+') as fd: - fd.write('\n%s\n' %cfg[0]) - fd.write('\n '.join(cfg[1:])) - fd.write('\n') - os.system('sudo cp -f %s %s'%(self.tempfile.name, interface_file)) + with open(interface_file, 'a') as fid: + fid.write('\n') + fid.write('%s\n' %cfg[0]) + fid.write('\n '.join(cfg[1:])) + fid.write('\n') + fid.flush() def create_interface(self): '''Create interface config for normal interface for Ubuntu''' - log.info('Creating Interface: %s' %interface) - mac = self.get_mac_addr(self.device) - if not self.vlan: - cfg = ['auto %s' %self.device, - 'iface %s inet static' %self.device, - 'hwaddress ether %s' %mac, - 'address %s' %self.ipaddr, - 'netmask %s' %self.netmask] - if self.gw: - cfg.append('gateway %s' %self.gw) - else: - cfg = ['auto %s' %self.device, - 'iface %s inet manual' %self.device, - 'hwaddress ether %s' %mac] + log.info('Creating Interface: %s' %self.device) + cfg = ['auto %s' %self.device, + 'iface %s inet static' %self.device, + 'address %s' %self.ipaddr, + 'netmask %s' %self.netmask] self.write_network_script(cfg) - if self.vlan: - self.create_vlan_interface() - def create_bond_members(self): + def create_bond_members(self, master): '''Create interface config for each bond members for Ubuntu''' + if len(self.members) != 0: + bprimary = self.members[0] for each in self.members: log.info('Create Bond Members: %s' %each) - mac = self.get_mac_addr(each) cfg = ['auto %s' %each, 'iface %s inet manual' %each, - 'hwaddress ether %s' %mac, - 'down ip addr flush dev %s' %each, - 'bond-master %s' %self.device] + 'bond-master %s' %master, + 'bond-primary %s' %bprimary] self.write_network_script(cfg) - def create_vlan_interface(self): - '''Create interface config for vlan sub interface''' - interface = 'vlan'+self.vlan - cfg = ['auto %s' %interface, - 'iface %s inet static' %interface, - 'address %s' %self.ipaddr, - 'netmask %s' %self.netmask, - 'vlan-raw-device %s' %self.device] - if self.gw: - cfg.append('gateway %s' %self.gw) - self.write_network_script(cfg) - def create_bonding_interface(self): '''Create interface config for bond master''' - self.get_mac_from_bond_intf() - self.create_bond_members() - log.info('Creating bond master: %s' %self.device) - if not self.vlan: - cfg = ['auto %s' %self.device, - 'iface %s inet static' %self.device, - 'address %s' %self.ipaddr, - 'netmask %s' %self.netmask] - if self.gw: - cfg.append('gateway %s' %self.gw) - else: - cfg = ['auto %s' %self.device, - 'iface %s inet manual' %self.device] - cfg += self.bond_opts_str.split("\n") + #create slave interfaces + self.create_bond_members(self.device) + log.info('Create Bond master: %s' %self.device) + cfg = ['auto %s' %self.device, + 'iface %s inet static' %self.device, + 'address %s' %self.ipaddr, + 'netmask %s' %self.netmask, + 'bond-mode %s' %self.mode, + 'bond-miimon 100', + 'bond-slaves %s' %" ".join(self.members)] self.write_network_script(cfg) - if self.vlan: - self.create_vlan_interface() + def parse_cli(args): '''Define and Parser arguments for the script''' @@ -393,28 +246,28 @@ def parse_cli(args): help='Display version and exit') parser.add_argument('--device', action='store', - required=True, + default='bond0', help='Interface Name') parser.add_argument('--members', action='store', default=[], nargs='+', help='Name of Member interfaces') + parser.add_argument('--mode', + action='store', + default='balance-xor', + help='Mode of Bonding Interface') parser.add_argument('--ip', action='store', - required=True, help='IP address of the new Interface') parser.add_argument('--gw', action='store', help='Gateway Address of the Interface') - parser.add_argument('--bond-opts', - dest='bopts', - action='store', - default='', - help='Interface Bonding options') - parser.add_argument('--vlan', - action='store', - help='vLAN ID') + parser.add_argument('--interface-type', + dest='type', + action='store', + default='Ethernet', + help='Specify Interface type') pargs = parser.parse_args(args) if len(args) == 0: parser.print_help() diff --git a/setup-vnc-openstack.py b/setup-vnc-openstack.py index 3b96ff2e..d28ef148 100755 --- a/setup-vnc-openstack.py +++ b/setup-vnc-openstack.py @@ -20,12 +20,11 @@ def __init__(self, args_str = None): self._parse_args(args_str) self_ip = self._args.self_ip cfgm_ip = self._args.cfgm_ip - keystone_ip = self._args.keystone_ip service_token = self._args.service_token setup_args_str = "--role openstack " setup_args_str = setup_args_str + " --cfgm_ip %s " %(cfgm_ip) - setup_args_str = setup_args_str + " --keystone_ip %s " %(keystone_ip) + setup_args_str = setup_args_str + " --openstack_ip %s " %(self_ip) if service_token: setup_args_str = setup_args_str + " --service_token %s " %(service_token) if self._args.haproxy: @@ -39,7 +38,7 @@ def __init__(self, args_str = None): def _parse_args(self, args_str): ''' Eg. python setup-vnc-openstack.py --self_ip 10.1.5.11 --cfgm_ip 10.1.5.12 - --keystone_ip 10.1.5.13 --service_token c0ntrail123 --haproxy + --service_token c0ntrail123 --haproxy ''' # Source any specified config/ini file @@ -54,7 +53,6 @@ def _parse_args(self, args_str): 'self_ip': '127.0.0.1', 'service_token': '', 'cfgm_ip': '127.0.0.1', - 'keystone_ip': '127.0.0.1', 'haproxy': False, } @@ -79,7 +77,6 @@ def _parse_args(self, args_str): parser.add_argument("--self_ip", help = "IP Address of this system") parser.add_argument("--cfgm_ip", help = "IP Address of quantum node") - parser.add_argument("--keystone_ip", help = "IP Address of keystone node") parser.add_argument("--service_token", help = "The service password to access keystone") parser.add_argument("--haproxy", help = "Enable haproxy", action="store_true") diff --git a/setup-vnc-static-routes.py b/setup-vnc-static-routes.py index ed41c2bc..9054ee5c 100644 --- a/setup-vnc-static-routes.py +++ b/setup-vnc-static-routes.py @@ -9,14 +9,12 @@ import re import sys import time +import shutil import os.path import logging import platform import argparse -import socket -import struct from netaddr import IPNetwork -from tempfile import NamedTemporaryFile logging.basicConfig(format='%(asctime)-15s:: %(funcName)s:%(levelname)s:: %(message)s', level=logging.INFO) @@ -28,63 +26,54 @@ class StaticRoute(object): ''' def __init__(self, **kwargs): self.device = kwargs['device'] - self.netw = kwargs.get('network', []) - self.gw = kwargs.get('gw', []) - self.mask = kwargs.get('netmask', []) - self.vlan = kwargs.get('vlan', None) - self.cmd = [] - self.tempfile = NamedTemporaryFile(delete=False) - self.config_route_list = [] - + self.netw = kwargs['network'] + self.gw = kwargs['gw'] + self.mask = kwargs['netmask'] + self.prefix = 32 + def write_network_script(self): '''Create an interface config file in network-scripts with given config ''' if os.path.isfile(self.nwfile): - tmpfile = os.path.join(os.path.dirname(self.nwfile), + tmpfile = os.path.join(os.path.dirname(self.nwfile), \ 'moved-%s' %os.path.basename(self.nwfile)) log.info('Backup existing file %s to %s' %(self.nwfile, tmpfile)) - os.system('sudo cp %s %s'%(self.nwfile, tmpfile)) + shutil.move(self.nwfile, tmpfile) # read existing file - with open(self.tempfile.name, 'w') as fd: - fd.write('\n'.join(self.cmd)) - fd.write('\n') - os.system('sudo cp -f %s %s'%(self.tempfile.name, self.nwfile)) + with open(self.nwfile, 'w') as fid: + fid.write('%s\n' %self.cmd) + fid.flush() + log.info('New file %s has ben created' %self.nwfile) def restart_service(self): '''Restart network service''' log.info('Restarting Network Services...') - os.system('sudo service network restart') - time.sleep(3) - + os.system('service network restart') + time.sleep(5) + def pre_config(self): '''Setup env before static route configuration''' - if self.vlan: - self.device += "."+self.vlan self.nwfile = os.path.join(os.path.sep, 'etc', 'sysconfig', 'network-scripts', 'route-%s' %self.device) - i = 0 - for destination in self.netw: - prefix = IPNetwork('%s/%s' %(destination, self.mask[i])).prefixlen - self.cmd += ['%s/%s via %s dev %s' %( - destination, prefix, self.gw[i], self.device)] - self.config_route_list.append('%s %s %s' %(destination, self.mask[i], self.gw[i])) - i+=1 + self.cmd = '%s/%s via %s dev %s' %( + self.netw, self.prefix, self.gw, self.device) def verify_route(self): '''verify configured static routes''' - actual_list = [] - for route in open('/proc/net/route', 'r').readlines(): - if route.startswith(self.device): - route_fields = route.split() - flags = int(route_fields[3], 16) - destination = socket.inet_ntoa(struct.pack('I', int(route_fields[1], 16))) - if flags & 0x2 and int(route_fields[1], 16): - gateway = socket.inet_ntoa(struct.pack('I', int(route_fields[2], 16))) - mask = socket.inet_ntoa(struct.pack('I', int(route_fields[7], 16))) - actual_list.append('%s %s %s' %(destination, mask, gateway)) - if cmp(sorted(actual_list), sorted(self.config_route_list)): + with os.popen('ip route') as cmd: + output = cmd.read().split('\n') + exp_route = r'%s/%s\s+via\s+%s\s+dev\s+%s' %(self.netw, + self.prefix, self.gw, self.device) + pattern = re.compile(exp_route) + routes = filter(pattern.match, output) + if len(routes) == 0: + print 'INFO: Available Routes :\n%s' %"\n".join(output) + print 'ERROR: Searched Route Pattern: \n%s' %exp_route + print 'ERROR: Matched Routes (%s)' %routes raise RuntimeError('Seems Routes are not properly configured') + else: + print 'ROUTE (%s) configured Sucessfully' %routes def post_config(self): '''Execute commands after static route configuration''' @@ -95,58 +84,60 @@ def setup(self): '''High level method to call individual methods to configure static routes ''' + self.prefix = IPNetwork('%s/%s' %(self.netw, self.mask)).prefixlen self.pre_config() self.write_network_script() self.post_config() - os.unlink(self.tempfile.name) - + + class UbuntuStaticRoute(StaticRoute): '''Configure Static Route in Ubuntu''' def restart_service(self): '''Restart network service for Ubuntu''' log.info('Restarting Network Services...') - os.system('sudo /etc/init.d/networking restart') - time.sleep(3) + os.system('/etc/init.d/networking restart') + time.sleep(5) + + def remove_lines(self): + '''Remove existing config related to given route if the same + needs to be re-configured + ''' + log.info('Remove Existing Static Route in %s' %self.nwfile) + newfile = [] + # backup existing file + bckup = os.path.join(os.path.dirname(self.nwfile), 'org.%s.%s' %( + os.path.basename(self.nwfile),time.strftime('%d%m%y%H%M%S'))) + shutil.copy(self.nwfile, bckup) - def write_network_script(self): - '''Add route to ifup-parts dir and set the correct permission''' - if os.path.isfile(self.nwfile): - tmpfile = os.path.join(os.path.join(os.path.sep, 'tmp'), - 'moved-%s' %os.path.basename(self.nwfile)) - log.info('Backup existing file %s to %s' %(self.nwfile, tmpfile)) - os.system('sudo cp %s %s'%(self.nwfile, tmpfile)) # read existing file - with open(self.tempfile.name, 'w') as fd: - fd.write('#!/bin/bash\n[ "$IFACE" != "%s" ] && exit 0\n' %self.device) - fd.write('\n'.join(self.cmd)) - fd.write('\n') - os.system('sudo cp -f %s %s'%(self.tempfile.name, self.nwfile)) - os.system('sudo chmod 755 %s'%(self.nwfile)) - with open(self.tempfile.name, 'w') as fd: - fd.write('#!/bin/bash\n[ "$IFACE" != "%s" ] && exit 0\n' %self.device) - fd.write('\n'.join(self.downcmd)) - fd.write('\n') - os.system('sudo cp -f %s %s'%(self.tempfile.name, self.downfile)) - os.system('sudo chmod 755 %s'%(self.downfile)) + with open(self.nwfile, 'r') as fid: + cfg_file = fid.read().split('\n') + # remove config that match with new config + for line in cfg_file: + if self.cmd.replace(' ', '') == line.replace(' ', ''): + log.info('Removing existing Static Route: \n%s' %line) + continue + else: + newfile.append(line) + # write new file + with open(self.nwfile, 'w') as fid: + fid.write('%s\n' %"\n".join(newfile)) + fid.flush() + log.info('%s file has been updated' %self.nwfile) + + def write_network_script(self): + '''Append new configs to interfaces file''' + with open(self.nwfile, 'a') as fid: + fid.write('%s\n' %self.cmd) + fid.flush() def pre_config(self): '''Setup env before static route configuration in Ubuntu''' - # Any changes to the file/logic with static routes has to be - # reflected in setup.py too - if self.vlan: - self.device = 'vlan'+self.vlan - i = 0 - for destination in self.netw: - prefix = IPNetwork('%s/%s' %(destination, self.mask[i])).prefixlen - self.cmd += ['%s/%s via %s dev %s' %( - destination, prefix, self.gw[i], self.device)] - self.config_route_list.append('%s %s %s' %(destination, self.mask[i], self.gw[i])) - i+=1 - self.downfile = os.path.join(os.path.sep, 'etc', 'network', 'if-down.d', 'routes') - self.downcmd = ['ip route del '+x for x in self.cmd] - self.nwfile = os.path.join(os.path.sep, 'etc', 'network', 'if-up.d', 'routes') - self.cmd = ['ip route add '+x for x in self.cmd] + self.nwfile = os.path.join(os.path.sep, 'etc', 'network', 'interfaces') + self.cmd = 'up route add -net %s/%s gw %s dev %s' %( + self.netw, self.prefix, self.gw, self.device) + self.remove_lines() def parse_cli(args): parser = argparse.ArgumentParser(description=__doc__) @@ -154,30 +145,20 @@ def parse_cli(args): action='version', version=__version__, help='Display version and exit') - parser.add_argument('--device', + parser.add_argument('--device', action='store', help='Interface Name') - parser.add_argument('--network', + parser.add_argument('--network', action='store', - default=[], - nargs='+', - metavar='DESTINATION', help='Network address of the Static route') - parser.add_argument('--netmask', + parser.add_argument('--netmask', action='store', - default=[], - nargs='+', - metavar='NETMASK', help='Netmask of the Static route') - parser.add_argument('--gw', + parser.add_argument('--gw', action='store', - default=[], - nargs='+', metavar='GATEWAY', help='Gateway Address of the Static route') - parser.add_argument('--vlan', - action='store', - help='vLAN ID') + pargs = parser.parse_args(args) if len(args) == 0: parser.print_help() diff --git a/setup-vnc-vrouter.py b/setup-vnc-vrouter.py index 9850bb2f..7ece5a30 100755 --- a/setup-vnc-vrouter.py +++ b/setup-vnc-vrouter.py @@ -17,7 +17,7 @@ def __init__(self, args_str = None): self._parse_args(args_str) cfgm_ip = self._args.cfgm_ip - keystone_ip = self._args.keystone_ip + openstack_ip = self._args.openstack_ip service_token = self._args.service_token ncontrols = self._args.ncontrols non_mgmt_ip = self._args.non_mgmt_ip @@ -27,13 +27,13 @@ def __init__(self, args_str = None): vgw_intf_list = self._args.vgw_intf vgw_gateway_routes = self._args.gateway_routes if not self._args.openstack_mgmt_ip : - openstack_mgmt_ip = keystone_ip + openstack_mgmt_ip = openstack_ip else: openstack_mgmt_ip = self._args.openstack_mgmt_ip setup_args_str = "--role compute --compute_ip %s " %(self._args.self_ip) setup_args_str = setup_args_str + " --cfgm_ip %s " %(cfgm_ip) - setup_args_str = setup_args_str + " --keystone_ip %s " %(keystone_ip) + setup_args_str = setup_args_str + " --openstack_ip %s " %(openstack_ip) setup_args_str = setup_args_str + " --openstack_mgmt_ip %s " %(openstack_mgmt_ip) if service_token: setup_args_str = setup_args_str + " --service_token %s " %(service_token) @@ -57,7 +57,7 @@ def __init__(self, args_str = None): def _parse_args(self, args_str): ''' - Eg. python setup-vnc-vrouter.py --cfgm_ip 10.1.5.11 --keystone_ip 10.1.5.12 + Eg. python setup-vnc-vrouter.py --cfgm_ip 10.1.5.11 --openstack_ip 10.1.5.12 --self_ip 10.1.5.12 --service_token 'c0ntrail123' --ncontrols 1 --haproxy ''' @@ -72,7 +72,7 @@ def _parse_args(self, args_str): global_defaults = { 'cfgm_ip': '127.0.0.1', - 'keystone_ip': '127.0.0.1', + 'openstack_ip': '127.0.0.1', 'openstack_mgmt_ip': None, 'service_token': '', 'self_ip': '127.0.0.1', @@ -107,7 +107,7 @@ def _parse_args(self, args_str): parser.set_defaults(**all_defaults) parser.add_argument("--cfgm_ip", help = "IP Address of the config node") - parser.add_argument("--keystone_ip", help = "IP Address of the keystone node") + parser.add_argument("--openstack_ip", help = "IP Address of the openstack node") parser.add_argument("--openstack_mgmt_ip", help = "Mgmt IP Address of the openstack node if it is different from openstack_IP") parser.add_argument("--service_token", help = "The service password to access keystone") parser.add_argument("--self_ip", help = "IP Address of this(compute) node") diff --git a/setup-vnc-webui.py b/setup-vnc-webui.py index 660659a0..47e70938 100755 --- a/setup-vnc-webui.py +++ b/setup-vnc-webui.py @@ -17,12 +17,10 @@ def __init__(self, args_str = None): self._parse_args(args_str) cfgm_ip = self._args.cfgm_ip openstack_ip = self._args.openstack_ip - keystone_ip = self._args.keystone_ip collector_ip = self._args.collector_ip setup_args_str = "--role webui" setup_args_str = setup_args_str + " --cfgm_ip %s" % (cfgm_ip) - setup_args_str = setup_args_str + " --keystone_ip %s" % (keystone_ip) setup_args_str = setup_args_str + " --openstack_ip %s" % (openstack_ip) if collector_ip: setup_args_str = setup_args_str + " --collector_ip %s" \ @@ -38,9 +36,8 @@ def __init__(self, args_str = None): def _parse_args(self, args_str): ''' - Eg. python setup-vnc-webui.py --cfgm_ip 10.84.12.11 --keystone_ip 10.84.12.12 - --openstack_ip 10.84.12.12 --collector_ip 10.84.12.12 - --cassandra_ip_list 10.1.5.11 10.1.5.12 + Eg. python setup-vnc-webui.py --cfgm_ip 10.84.12.11 --openstack_ip 10.84.12.12 + --collector_ip 10.84.12.12 --cassandra_ip_list 10.1.5.11 10.1.5.12 ''' # Source any specified config/ini file @@ -53,7 +50,6 @@ def _parse_args(self, args_str): global_defaults = { 'cfgm_ip': '127.0.0.1', - 'keystone_ip': '127.0.0.1', 'openstack_ip': '127.0.0.1', 'collector_ip' : '127.0.0.1', } @@ -78,7 +74,6 @@ def _parse_args(self, args_str): parser.set_defaults(**all_defaults) parser.add_argument("--cfgm_ip", help = "IP Address of the cfgm node") - parser.add_argument("--keystone_ip", help = "IP Address of the keystone node") parser.add_argument("--openstack_ip", help = "IP Address of the openstack controller") parser.add_argument("--collector_ip", help = "IP Address of the Collector node") parser.add_argument("--cassandra_ip_list", help = "List of IP Addresses of cassandra nodes", diff --git a/templates/agent_conf_template.py b/templates/agent_conf_template.py new file mode 100644 index 00000000..b4ef15e7 --- /dev/null +++ b/templates/agent_conf_template.py @@ -0,0 +1,22 @@ +import string + +template = string.Template(""" + + + + + + vhost0 + $__contrail_box_ip__/$__contrail_box_prefix__ + $__contrail_gateway__ + + + $__contrail_eth_if__ + + + + + $__contrail_discovery_server__ + + +""") diff --git a/templates/agent_xml2ini.py b/templates/agent_xml2ini.py deleted file mode 100644 index d4213e2d..00000000 --- a/templates/agent_xml2ini.py +++ /dev/null @@ -1,377 +0,0 @@ -import sys -import os -import argparse -import ConfigParser -import xml.etree.ElementTree as ET - -class AgentXmlParams(): - def __init__(self): - self.xmpp_server1="" - self.xmpp_server2="" - self.dns_server1="" - self.dns_server2="" - self.flow_timeout="" - self.tunnel_type="" - self.discovery_ip="" - self.hypervisor_type="" - self.xen_ll_ip="" - self.xen_ll_interface="" - self.vmware_interface="" - self.max_control_nodes="" - self.max_system_flows="" - self.max_vm_flows="" - self.metadata_secret="" - self.control_network_ip="" - self.vhost_name="" - self.vhost_ip="" - self.vhost_gw="" - self.physical_interface="" - self.gateway_idx=0 - self.gateway_str="" - #end __init__ - -class Xml2Ini(): - def __init__(self, args_str = None): - self._args = None - if not args_str: - args_str = ' '.join(sys.argv[1:]) - self._parse_args(args_str) - #end __init__ - - def _parse_args(self, args_str): - ''' - Eg. python xml2ini.py --source_file filename1 --target_file filename2 - --overwrite_target_file - ''' - # Source any specified config/ini file - # Turn off help, so we print all options in response to -h - conf_parser = argparse.ArgumentParser(add_help = False, - formatter_class=argparse.ArgumentDefaultsHelpFormatter) - - args, remaining_argv = conf_parser.parse_known_args(args_str.split()) - - # Override with CLI options - # Don't surpress add_help here so it will handle -h - parser = argparse.ArgumentParser( - # Inherit options from config_parser - parents=[conf_parser], - # print script description with -h/--help - description=__doc__, - # Don't mess with format of description - formatter_class=argparse.RawDescriptionHelpFormatter, - ) - parser.add_argument("--source_file", default="/etc/contrail/agent.conf", help = "Agent conf file name having config in XML format (default: %(default)s)") - parser.add_argument("--target_file", default="/etc/contrail/contrail-vrouter-agent.conf", help = "Target Agent conf file name which will have INI config (default: %(default)s)") - parser.add_argument("--overwrite_target_file", help = "Overwrite target file if it is already present", action='store_true') - self._args = parser.parse_args(remaining_argv) - - #end __parse_args__ - - def process_vhost(self, item, obj): - for child_item in item: - if child_item.tag == "name": - obj.vhost_name = child_item.text - elif child_item.tag == "ip-address": - obj.vhost_ip = child_item.text - elif child_item.tag == "gateway": - obj.vhost_gw = child_item.text - #end process_vhost - - def process_eth_port(self, item, obj): - for child_item in item: - if child_item.tag == "name": - obj.physical_interface=child_item.text - #end process_eth_port - - def process_discovery(self, item, obj): - for child_item in item: - if child_item.tag == "ip-address": - obj.discovery_ip = child_item.text - elif child_item.tag == "control-instances": - obj.max_control_nodes = child_item.text - #end process_discovery - - def process_control(self, item, obj): - for child_item in item: - if child_item.tag == "ip-address": - obj.control_network_ip = child_item.text - #end process_control - - def process_hypervisor(self, item, obj): - self.hypervisor_type = item.attrib["mode"] - for child_item in item: - if child_item.tag == "xen-ll-port": - self.xen_ll_interface = child_item.text - elif child_item.tag == "xen-ll-ip-address": - self.en_ll_ip = child_item.text - if child_item.tag == "port": - self.vmware_interface = child_item.text - #end process_hypervisor - - def process_metadata(self, item, obj): - for child_item in item: - if child_item.tag == "shared-secret": - obj.metadata_secret = child_item.text - #end process_metadata - - def process_flow_cache(self, item, obj): - for child_item in item: - if child_item.tag == "timeout": - obj.flow_timeout = child_item.text - #end process_flow_cache - - def process_xmpp_server(self, item, obj): - for child_item in item: - if child_item.tag == "ip-address": - if not obj.xmpp_server1: - obj.xmpp_server1 = child_item.text - else: - obj.xmpp_server2 = child_item.text - #end process_xmpp_server - - def process_dns_server(self, item, obj): - for child_item in item: - if child_item.tag == "ip-address": - if not obj.dns_server1: - obj.dns_server1 = child_item.text - else: - obj.dns_server2 = child_item.text - #end process_dns_server - - def process_gateway(self, item, obj): - subnet_list = [] - route_list = [] - obj.gateway_str += "[GATEWAY-%d]\n" %(obj.gateway_idx) - obj.gateway_str += "# Name of the routing_instance for which the gateway is being configured\n" - ri_name = item.attrib["virtual-network"] - if not ri_name: - ri_name = item.attrib["routing-instance"] - obj.gateway_str += "routing_instance=%s\n\n" %(ri_name) - for child_item in item: - if child_item.tag == "interface": - obj.gateway_str += "# Gateway interface name\n" - obj.gateway_str += "interface=%s\n\n" %(child_item.text) - elif child_item.tag == "subnet": - subnet_list.append(child_item.text) - elif child_item.tag == "": - route_list.append(child_item.text) - obj.gateway_str += "# Virtual network ip blocks for which gateway service is required. Each IP\n" - obj.gateway_str += "# block is represented as ip/prefix. Multiple IP blocks are represented by\n" - obj.gateway_str += "# separating each with a space\n" - if subnet_list: - obj.gateway_str += "ip_blocks=" - for subnet in subnet_list: - obj.gateway_str += "%s " %(subnet) - obj.gateway_str += "\n\n" - else: - obj.gateway_str += "# ip_blocks=ip1/prefix1 ip2/prefix2\n\n" - obj.gateway_str += "# Routes to be exported in routing_instance. Each route is represented as\n" - obj.gateway_str += "# ip/prefix. Multiple routes are represented by separating each with a space\n" - if route_list: - obj.gateway_str += "routes=" - for route in route_list: - obj.gateway_str += "%s " %(route) - route_str += "\n\n" - else: - obj.gateway_str += "# routes=ip1/prefix1 ip2/prefix2\n\n" - obj.gateway_idx = obj.gateway_idx + 1 - #end process_gateway - - def convert(self): - if not os.path.isfile(self._args.source_file): - print 'Source file %s does not exist' %(self._args.source_file) - return - if os.path.isfile(self._args.target_file): - if not self._args.overwrite_target_file: - print 'Target file %s already exists' %(self._args.target_file) - return - agent_tree = ET.parse(self._args.source_file) - agent_root = agent_tree.getroot() - agent_elem = agent_root.find('agent') - obj = AgentXmlParams() - for item in agent_elem: - if item.tag == "vhost": - self.process_vhost(item, obj) - elif item.tag == "eth-port": - self.process_eth_port(item, obj) - elif item.tag == "discovery-server": - self.process_discovery(item, obj) - elif item.tag == "control": - self.process_control(item, obj) - elif item.tag == "hypervisor": - self.process_hypervisor(item, obj) - elif item.tag == "tunnel-type": - obj.tunnel_type = item.text - elif item.tag == "metadata-proxy": - self.process_metadata(item, obj) - elif item.tag == "xmpp-server": - self.process_xmpp_server(item, obj) - elif item.tag == "dns-server": - self.process_dns_server(item, obj) - elif item.tag == "flow-cache": - self.process_flow_cache(item, obj) - elif item.tag == "gateway": - self.process_gateway(item, obj) - - #Generate the agent config file in INI format. - #Collector configuration was not supported via conf file in 1.05 and earlier releases - #Add only commented section for collector - ini_str = "[COLLECTOR]\n" - ini_str += "# IP address and port to be used to connect to collector. If IP is not\n" - ini_str += "# configured, value provided by discovery service will be used. (Optional)\n" - ini_str += "# port=8086\n# server=\n\n" - ini_str += "[CONTROL-NODE]\n" - ini_str += "# IP address to be used to connect to control-node. Maximum of 2 IP addresses\n" - ini_str += "# (separated by a space) can be provided. If no IP is configured then the\n" - ini_str += "# value provided by discovery service will be used. (Optional)\n" - if obj.xmpp_server1 or obj.xmpp_server2: - ini_str += "server=%s %s\n\n" %(obj.xmpp_server1, obj.xmpp_server2) - else: - ini_str += "# server=x.x.x.x y.y.y.y\n\n" - - ini_str += "[DEFAULT]\n" - #Debug logging configuration was not supported in 1.05 and earlier releases - #Add only commented item for debug logging config - ini_str += "# Everything in this section is optional\n\n" - ini_str += "# Enable/disable debug logging. Possible values are 0 (disable) and 1 (enable)\n" - ini_str += "# debug=0\n\n" - ini_str += "# Aging time for flow-records in seconds\n" - if obj.flow_timeout: - ini_str += "flow_cache_timeout=%s\n\n" %(obj.flow_timeout) - else: - ini_str += "# flow_cache_timeout=0\n\n" - - #The following configuration was not supported via conf file in 1.05 and earlier releases - #Add only commented items for these config - ini_str += "# Hostname of compute-node. If this is not configured value from `hostname`\n" - ini_str += "# will be taken\n" - ini_str += "# hostname=\n\n" - ini_str += "# Http server port for inspecting vnswad state (useful for debugging)\n" - ini_str += "# http_server_port=8085\n\n" - ini_str += "# Category for logging. Default value is '*'\n" - ini_str += "# log_category=\n\n" - ini_str += "# Local log file name\n" - ini_str += "# log_file=/var/log/contrail/vrouter.log\n\n" - ini_str += "# Log severity levels. Possible values are SYS_EMERG, SYS_ALERT, SYS_CRIT,\n" - ini_str += "# SYS_ERR, SYS_WARN, SYS_NOTICE, SYS_INFO and SYS_DEBUG. Default is SYS_DEBUG\n" - ini_str += "# log_level=SYS_DEBUG\n\n" - ini_str += "# Enable/Disable local file logging. Possible values are 0 (disable) and 1 (enable)\n" - ini_str += "# log_local=0\n\n" - ini_str += "# Encapsulation type for tunnel. Possible values are MPLSoGRE, MPLSoUDP, VXLAN\n" - if obj.tunnel_type: - ini_str += "tunnel_type=%s\n\n" %(obj.tunnel_type) - else: - ini_str += "# tunnel_type=\n\n" - - ini_str += "[DISCOVERY]\n" - ini_str += "# If COLLECTOR and/or CONTROL-NODE and/or DNS is not specified this section is\n" - ini_str += "# mandatory. Else this section is optional\n\n" - ini_str += "# IP address of discovery server\n" - if obj.discovery_ip: - ini_str += "server=%s\n\n" %(obj.discovery_ip) - else: - ini_str += "# server=10.204.217.52\n\n" - ini_str += "# Number of control-nodes info to be provided by Discovery service. Possible\n" - ini_str += "# values are 1 and 2\n" - if obj.max_control_nodes: - ini_str += "max_control_nodes=%s\n\n" %(obj.max_control_nodes) - else: - ini_str += "# max_control_nodes=1\n\n" - ini_str += "[DNS]\n" - ini_str += "# IP address to be used to connect to dns-node. Maximum of 2 IP addresses\n" - ini_str += "# (separated by a space) can be provided. If no IP is configured then the\n" - ini_str += "# value provided by discovery service will be used. (Optional)\n" - if obj.dns_server1 or obj.dns_server2: - ini_str += "server=%s %s\n\n" %(obj.dns_server1, obj.dns_server2) - else: - ini_str += "# server=x.x.x.x y.y.y.y\n\n" - - ini_str += "[HYPERVISOR]\n" - ini_str += "# Everything in this section is optional\n\n" - ini_str += "# Hypervisor type. Possible values are kvm, xen and vmware\n" - if obj.hypervisor_type: - ini_str += "# type=%s\n\n" %(obj.hypervisor_type) - else: - ini_str += "# type=kvm\n\n" - - ini_str += "# Link-local IP address and prefix in ip/prefix_len format (for xen)\n" - if obj.xen_ll_ip: - ini_str += "xen_ll_ip=%s\n\n" %(obj.xen_ll_ip) - else: - ini_str += "# xen_ll_ip=\n\n" - - ini_str += "# Link-local interface name when hypervisor type is Xen\n" - if obj.xen_ll_interface: - ini_str += "xen_ll_interface=%s\n\n" %(obj.xen_ll_interface) - else: - ini_str += "# xen_ll_interface=\n\n" - - ini_str += "# Physical interface name when hypervisor type is vmware\n" - if obj.vmware_interface: - ini_str += "vmware_physical_interface=%s\n\n" %(obj.vmware_interface) - else: - ini_str += "# vmware_physical_interface=\n\n" - - ini_str += "[FLOWS]\n" - ini_str += "# Everything in this section is optional\n\n" - ini_str += "# Maximum flows allowed per VM - given as \% of maximum system flows\n" - ini_str += "# max_vm_flows=100\n\n" - ini_str += "# Maximum number of link-local flows allowed across all VMs\n" - if obj.max_system_flows: - ini_str += "max_system_linklocal_flows=%s\n\n" %(obj.max_system_flows) - else: - ini_str += "# max_system_linklocal_flows=4096\n\n" - ini_str += "# Maximum number of link-local flows allowed per VM\n" - if obj.max_vm_flows: - ini_str += "max_vm_linklocal_flows=%s\n\n" %(obj.max_vm_flows) - else: - ini_str += "# max_vm_linklocal_flows=1024\n\n" - - ini_str += "[METADATA]\n" - ini_str += "# Shared secret for metadata proxy service. (Optional)\n" - if obj.metadata_secret: - ini_str += "metadata_proxy_secret=%s\n\n" %(obj.metadata_secret) - else: - ini_str += "# metadata_proxy_secret=contrail\n\n" - - ini_str += "[NETWORKS]\n" - ini_str += "# control-channel IP address used by WEB-UI to connect to vnswad to fetch\n" - ini_str += "# required information (Optional)\n" - if obj.control_network_ip: - ini_str += "control_network_ip=%s\n\n" %(obj.control_network_ip) - else: - ini_str += "# control_network_ip=\n\n" - - ini_str += "[VIRTUAL-HOST-INTERFACE]\n" - ini_str += "# Everything in this section is mandatory\n\n" - ini_str += "# name of virtual host interface\n" - ini_str += "name=%s\n\n" %(obj.vhost_name) - - ini_str += "# IP address and prefix in ip/prefix_len format\n" - ini_str += "ip=%s\n\n" %(obj.vhost_ip) - - ini_str += "# Gateway IP address for virtual host\n" - ini_str += "gateway=%s\n\n" %(obj.vhost_gw) - - ini_str += "# Physical interface name to which virtual host interface maps to\n" - ini_str += "physical_interface=%s\n\n" %(obj.physical_interface) - - ini_str += obj.gateway_str - - with open(self._args.target_file, "w") as f: - f.write(ini_str) - - #end __convert__ - - def convert_supervisor_ini(self): - os.system("sed -i 's/command=.*/command=\/usr\/bin\/vnswad/g' /etc/contrail/supervisord_vrouter_files/contrail-vrouter.ini") - #end __convert_supervisor_ini__ - -def main(args_str = None): - obj = Xml2Ini(args_str) - obj.convert() - obj.convert_supervisor_ini() -#end main - -if __name__ == "__main__": - main() diff --git a/templates/api_server_conf_template.py b/templates/api_server_conf_template.py index 7bf1756a..f977573a 100644 --- a/templates/api_server_conf_template.py +++ b/templates/api_server_conf_template.py @@ -24,12 +24,11 @@ ca_certs=$__contrail_cacertfile_location__ [KEYSTONE] -auth_host=$__contrail_keystone_ip__ +auth_host=$__contrail_openstack_ip__ auth_protocol=http auth_port=35357 admin_user=$__contrail_admin_user__ admin_password=$__contrail_admin_password__ -admin_token=$__contrail_admin_token__ admin_tenant_name=$__contrail_admin_tenant_name__ $__contrail_memcached_opt__ """) diff --git a/templates/bgp_param_template.py b/templates/bgp_param_template.py index f0cf619d..b822512d 100644 --- a/templates/bgp_param_template.py +++ b/templates/bgp_param_template.py @@ -1,7 +1,7 @@ import string template = string.Template("""# -# Copyright (c) 2014 Juniper Networks, Inc. All rights reserved. +# Copyright (c) 2013 Juniper Networks, Inc. All rights reserved. # # Control-node configuration options # @@ -9,7 +9,6 @@ [DEFAULT] # bgp_config_file=bgp_config.xml # bgp_port=179 -# collectors= # Provided by discovery server hostip=$__contrail_host_ip__ # Resolved IP of `hostname` hostname=$__contrail_hostname__ # Retrieved as `hostname` # http_server_port=8083 @@ -23,6 +22,10 @@ # test_mode=0 # xmpp_server_port=5269 +[COLLECTOR] +# port=8086 +# server= # Provided by discovery server + [DISCOVERY] # port=5998 server=$__contrail_discovery_ip__ # discovery-server IP address diff --git a/templates/collector.conf.sh b/templates/collector.conf.sh deleted file mode 100644 index 5b2edd19..00000000 --- a/templates/collector.conf.sh +++ /dev/null @@ -1,77 +0,0 @@ -#!/usr/bin/env bash - -CONFIG_FILE="/etc/contrail/collector.conf" -OLD_CONFIG_FILE=/etc/contrail/vizd_param -SIGNATURE="Collector configuration options, generated from $OLD_CONFIG_FILE" - -# Remove old style command line arguments from .ini file. -perl -ni -e 's/command=.*/command=\/usr\/bin\/vizd/g; print $_;' /etc/contrail/supervisord_analytics_files/contrail-collector.ini - -if [ ! -e $OLD_CONFIG_FILE ]; then - exit -fi - -# Ignore if the converted file is already generated once before -if [ -e $CONFIG_FILE ]; then - grep --quiet "$SIGNATURE" $CONFIG_FILE > /dev/null - - # Exit if configuraiton already converted! - if [ $? == 0 ]; then - exit - fi -fi - -source $OLD_CONFIG_FILE 2>/dev/null || true - -if [ -z $ANALYTICS_DATA_TTL ]; then - ANALYTICS_DATA_TTL=48 -fi - -if [ -z $ANALYTICS_SYSLOG_PORT ]; then - ANALYTICS_SYSLOG_PORT=0 -fi - -if [ -z $CASSANDRA_SERVER_LIST ]; then - # Try to retrieve ' ' separated list of tokens, - CASSANDRA_SERVER_LIST=`\grep CASSANDRA_SERVER_LIST $OLD_CONFIG_FILE | awk -F '=' '{print $2}'` || true -fi - -( -cat << EOF -# -# Copyright (c) 2014 Juniper Networks, Inc. All rights reserved. -# -# $SIGNATURE -# - -[DEFAULT] - analytics_data_ttl=$ANALYTICS_DATA_TTL - cassandra_server_list=$CASSANDRA_SERVER_LIST -# dup=0 - hostip=$HOST_IP # Resolved IP of `hostname` -# hostname= # Retrieved as `hostname` - http_server_port=$HTTP_SERVER_PORT -# log_category= -# log_disable=0 - log_file=$LOG_FILE -# log_files_count=10 -# log_file_size=1048576 # 1MB -# log_level=SYS_NOTICE -# log_local=0 - syslog_port=$ANALYTICS_SYSLOG_PORT -# test_mode=0 - -[COLLECTOR] - port=$LISTEN_PORT -# server=0.0.0.0 - -[DISCOVERY] -# port=5998 - server=$DISCOVERY # discovery_server IP address - -[REDIS] - port=6381 - server=127.0.0.1 - -EOF -) > $CONFIG_FILE diff --git a/templates/control-node.conf.sh b/templates/control-node.conf.sh index d826a5e4..702ade56 100755 --- a/templates/control-node.conf.sh +++ b/templates/control-node.conf.sh @@ -1,13 +1,12 @@ #!/usr/bin/env bash CONFIG_FILE="/etc/contrail/control-node.conf" -OLD_CONFIG_FILE=/etc/contrail/control_param -SIGNATURE="Control-node configuration options, generated from $OLD_CONFIG_FILE" +SIGNATURE="Control-node configuration options, generated from control_param" # Remove old style command line arguments from .ini file. perl -ni -e 's/command=.*/command=\/usr\/bin\/control-node/g; print $_;' /etc/contrail/supervisord_control_files/contrail-control.ini -if [ ! -e $OLD_CONFIG_FILE ]; then +if [ ! -e /etc/contrail/control_param ]; then exit fi @@ -21,12 +20,12 @@ if [ -e $CONFIG_FILE ]; then fi fi -source $OLD_CONFIG_FILE 2>/dev/null || true +source /etc/contrail/control_param ( cat << EOF # -# Copyright (c) 2014 Juniper Networks, Inc. All rights reserved. +# Copyright (c) 2013 Juniper Networks, Inc. All rights reserved. # # $SIGNATURE # @@ -34,7 +33,6 @@ cat << EOF [DEFAULT] # bgp_config_file=bgp_config.xml # bgp_port=179 -# collectors= # Provided by discovery server hostip=$HOSTIP # Resolved IP of `hostname` hostname=$HOSTNAME # Retrieved as `hostname` # http_server_port=8083 @@ -48,6 +46,10 @@ cat << EOF # test_mode=0 # xmpp_server_port=5269 +[COLLECTOR] +# port=8086 +# server= # Provided by discovery server + [DISCOVERY] # port=5998 server=$DISCOVERY # discovery-server IP address diff --git a/templates/database_nodemgr_param_template.py b/templates/database_nodemgr_param_template.py deleted file mode 100644 index 05f0c878..00000000 --- a/templates/database_nodemgr_param_template.py +++ /dev/null @@ -1,5 +0,0 @@ -import string - -template = string.Template(""" -DISCOVERY=$__contrail_discovery_ip__ -""") diff --git a/templates/dns.conf.sh b/templates/dns.conf.sh index ed6a6e26..b6ff6e95 100755 --- a/templates/dns.conf.sh +++ b/templates/dns.conf.sh @@ -1,13 +1,12 @@ #!/usr/bin/env bash CONFIG_FILE="/etc/contrail/dns.conf" -OLD_CONFIG_FILE=/etc/contrail/dns_param -SIGNATURE="DNS configuration options, generated from $OLD_CONFIG_FILE" +SIGNATURE="DNS configuration options, generated from dns_param" # Remove old style command line arguments from .ini file. perl -ni -e 's/command=.*/command=\/usr\/bin\/dnsd/g; print $_;' /etc/contrail/supervisord_control_files/contrail-dns.ini -if [ ! -e $OLD_CONFIG_FILE ]; then +if [ ! -e /etc/contrail/dns_param ]; then exit fi @@ -21,7 +20,7 @@ if [ -e $CONFIG_FILE ]; then fi fi -source $OLD_CONFIG_FILE 2>/dev/null || true +source /etc/contrail/dns_param ( cat << EOF @@ -32,7 +31,6 @@ cat << EOF # [DEFAULT] -# collectors= # Provided by discovery server # dns_config_file=dns_config.xml hostip=$HOSTIP # Resolved IP of `hostname` hostname=$HOSTNAME # Retrieved as `hostname` @@ -46,6 +44,10 @@ cat << EOF # log_local=0 # test_mode=0 +[COLLECTOR] +# port=8086 +# server= # Provided by discovery server + [DISCOVERY] # port=5998 server=$DISCOVERY # discovery-server IP address diff --git a/templates/dns_param_template.py b/templates/dns_param_template.py index ddf5d594..ddd5dc14 100644 --- a/templates/dns_param_template.py +++ b/templates/dns_param_template.py @@ -7,7 +7,6 @@ # [DEFAULT] -# collectors= # Provided by discovery server # dns_config_file=dns_config.xml hostip=$__contrail_host_ip__ # Resolved IP of `hostname` hostname=$__contrail_hostname__ # Retrieved as `hostname` @@ -21,6 +20,10 @@ # log_local=0 # test_mode=0 +[COLLECTOR] +# port=8086 +# server= # Provided by discovery server + [DISCOVERY] # port=5998 server=$__contrail_discovery_ip__ # discovery-server IP address diff --git a/templates/opserver_param_template.py b/templates/opserver_param_template.py index b3d6c912..c36ba186 100644 --- a/templates/opserver_param_template.py +++ b/templates/opserver_param_template.py @@ -1,23 +1,14 @@ import string template = string.Template(""" -[DEFAULTS] -host_ip = $__contrail_host_ip__ -collectors = $__contrail_collector__:$__contrail_collector_port__ -http_server_port = $__contrail_http_server_port__ -rest_api_port = $__contrail_rest_api_port__ -rest_api_ip = $__contrail_host_ip__ -log_local = $__contrail_log_local__ -log_level = $__contrail_log_level__ -log_category = $__contrail_log_category__ -log_file = $__contrail_log_file__ - -[DISCOVERY] -disc_server_ip = $__contrail_discovery_ip__ -disc_server_port = $__contrail_discovery_port__ - -[REDIS] -redis_server_port = $__contrail_redis_server_port__ -redis_query_port = $__contrail_redis_query_port__ - +REDIS_SERVER_PORT=$__contrail_redis_server_port__ +REDIS_QUERY_PORT=$__contrail_redis_query_port__ +HOST_IP=$__contrail_host_ip__ +COLLECTOR=$__contrail_collector__ +COLLECTOR_PORT=$__contrail_collector_port__ +HTTP_SERVER_PORT=$__contrail_http_server_port__ +REST_API_PORT=$__contrail_rest_api_port__ +LOG_FILE=$__contrail_log_file__ +LOG_LOCAL=$__contrail_log_local__ +DISCOVERY=$__contrail_discovery_ip__ """) diff --git a/templates/qe_param_template.py b/templates/qe_param_template.py index 8ab93b45..fe45bc35 100644 --- a/templates/qe_param_template.py +++ b/templates/qe_param_template.py @@ -1,33 +1,12 @@ import string -template = string.Template("""# -# Copyright (c) 2014 Juniper Networks, Inc. All rights reserved. -# -# Query-Engine configuration options -# - -[DEFAULT] -# analytics_data_ttl=48 - cassandra_server_list=$__contrail_cassandra_server_list__ - collectors=$__contrail_collector__:$__contrail_collector_port__ - hostip=$__contrail_host_ip__ # Resolved IP of `hostname` -# hostname= # Retrieved as `hostname` - http_server_port=$__contrail_http_server_port__ -# log_category= -# log_disable=0 - log_file=$__contrail_log_file__ -# log_files_count=10 -# log_file_size=1048576 # 1MB -# log_level=SYS_NOTICE -# log_local=0 -# test_mode=0 - -[DISCOVERY] -# port=5998 -# server= # discovery_server IP address - -[REDIS] - port=$__contrail_redis_server_port__ - server=$__contrail_redis_server__ - +template = string.Template(""" +CASSANDRA_SERVER_LIST=$__contrail_cassandra_server_list__ +REDIS_SERVER=$__contrail_redis_server__ +REDIS_SERVER_PORT=$__contrail_redis_server_port__ +HTTP_SERVER_PORT=$__contrail_http_server_port__ +LOG_FILE=$__contrail_log_file__ +LOG_LOCAL=$__contrail_log_local__ +COLLECTOR=$__contrail_collector__ +COLLECTOR_PORT=$__contrail_collector_port__ """) diff --git a/templates/query-engine.conf.sh b/templates/query-engine.conf.sh deleted file mode 100644 index f280a117..00000000 --- a/templates/query-engine.conf.sh +++ /dev/null @@ -1,76 +0,0 @@ -#!/usr/bin/env bash - -CONFIG_FILE="/etc/contrail/query-engine.conf" -OLD_CONFIG_FILE=/etc/contrail/qe_param -SIGNATURE="Query-Engine configuration options, generated from $OLD_CONFIG_FILE" - -# Remove old style command line arguments from .ini file. -perl -ni -e 's/command=.*/command=\/usr\/bin\/qed/g; print $_;' /etc/contrail/supervisord_analytics_files/qed.ini - -if [ ! -e $OLD_CONFIG_FILE ]; then - exit -fi - -# Ignore if the converted file is already generated once before -if [ -e $CONFIG_FILE ]; then - grep --quiet "$SIGNATURE" $CONFIG_FILE > /dev/null - - # Exit if configuraiton already converted! - if [ $? == 0 ]; then - exit - fi -fi - -source $OLD_CONFIG_FILE 2>/dev/null || true - -if [ -z $ANALYTICS_DATA_TTL ]; then - ANALYTICS_SYSLOG_PORT=48 -fi - -if [ -z $HTTP_SERVER_PORT ]; then - HTTP_SERVER_PORT=8091 -fi - -if [ -z $REDIS_SERVER_PORT ]; then - REDIS_SERVER_PORT=6379 -fi - -if [ -z $CASSANDRA_SERVER_LIST ]; then - # Try to retrieve ' ' separated list of tokens, - CASSANDRA_SERVER_LIST=`\grep CASSANDRA_SERVER_LIST $OLD_CONFIG_FILE | awk -F '=' '{print $2}'` || true -fi - -( -cat << EOF -# -# Copyright (c) 2014 Juniper Networks, Inc. All rights reserved. -# -# $SIGNATURE -# - -[DEFAULT] - analytics_data_ttl=$ANALYTICS_DATA_TTL - cassandra_server_list=$CASSANDRA_SERVER_LIST - collectors=$COLLECTOR:$COLLECTOR_PORT -# hostip= # Resolved IP of `hostname` -# hostname= # Retrieved as `hostname` - http_server_port=$HTTP_SERVER_PORT -# log_category= -# log_disable=0 - log_file=$LOG_FILE -# log_files_count=10 -# log_file_size=1048576 # 1MB -# log_level=SYS_NOTICE -# log_local=0 -# test_mode=0 - -[DISCOVERY] -# port=5998 -# server= # discovery_server IP address - -[REDIS] - port=$REDIS_SERVER_PORT - server=$REDIS_SERVER - -EOF -) > $CONFIG_FILE diff --git a/templates/schema_transformer_conf_template.py b/templates/schema_transformer_conf_template.py index 9b049015..e5b76243 100644 --- a/templates/schema_transformer_conf_template.py +++ b/templates/schema_transformer_conf_template.py @@ -24,5 +24,4 @@ admin_user=$__contrail_admin_user__ admin_password=$__contrail_admin_password__ admin_tenant_name=$__contrail_admin_tenant_name__ -admin_token=$__contrail_admin_token__ """) diff --git a/templates/svc_monitor_conf_template.py b/templates/svc_monitor_conf_template.py index f33d6a48..06ead8ea 100644 --- a/templates/svc_monitor_conf_template.py +++ b/templates/svc_monitor_conf_template.py @@ -13,7 +13,6 @@ cassandra_server_list=$__contrail_cassandra_server_list__ disc_server_ip=$__contrail_disc_server_ip__ disc_server_port=$__contrail_disc_server_port__ -region_name=$__contrail_region_name__ [SECURITY] use_certs=$__contrail_use_certs__ @@ -22,9 +21,8 @@ ca_certs=$__contrail_cacertfile_location__ [KEYSTONE] -auth_host=$__contrail_keystone_ip__ +auth_host=$__contrail_openstack_ip__ admin_user=$__contrail_admin_user__ admin_password=$__contrail_admin_password__ admin_tenant_name=$__contrail_admin_tenant_name__ -admin_token=$__contrail_admin_token__ """) diff --git a/templates/vizd_param_template.py b/templates/vizd_param_template.py index b475b20a..d9eafbe0 100644 --- a/templates/vizd_param_template.py +++ b/templates/vizd_param_template.py @@ -1,38 +1,15 @@ import string -template = string.Template("""# -# Copyright (c) 2014 Juniper Networks, Inc. All rights reserved. -# -# Control-node configuration options -# - -[DEFAULT] - analytics_data_ttl=$__contrail_analytics_data_ttl__ - cassandra_server_list=$__contrail_cassandra_server_list__ -# dup=0 - hostip=$__contrail_host_ip__ # Resolved IP of `hostname` -# hostname= # Retrieved as `hostname` - http_server_port=$__contrail_http_server_port__ -# log_category= -# log_disable=0 - log_file=$__contrail_log_file__ -# log_files_count=10 -# log_file_size=1048576 # 1MB -# log_level=SYS_NOTICE -# log_local=0 - syslog_port=$__contrail_analytics_syslog_port__ -# test_mode=0 - -[COLLECTOR] - port=$__contrail_listen_port__ -# server= 0.0.0.0 - -[DISCOVERY] -# port=5998 - server=$__contrail_discovery_ip__ # discovery_server IP address - -[REDIS] - port=6381 - server=127.0.0.1 - +template = string.Template(""" +CASSANDRA_SERVER_LIST=$__contrail_cassandra_server_list__ +REDIS_SERVER=$__contrail_redis_server__ +REDIS_SERVER_PORT=$__contrail_redis_server_port__ +DISCOVERY=$__contrail_discovery_ip__ +HOST_IP=$__contrail_host_ip__ +LISTEN_PORT=$__contrail_listen_port__ +HTTP_SERVER_PORT=$__contrail_http_server_port__ +LOG_FILE=$__contrail_log_file__ +LOG_LOCAL=$__contrail_log_local__ +ANALYTICS_DATA_TTL=$__contrail_analytics_data_ttl__ +ANALYTICS_SYSLOG_PORT=$__contrail_analytics_syslog_port__ """) diff --git a/templates/vnc_api_lib_ini_template.py b/templates/vnc_api_lib_ini_template.py index 1ac38bbc..ea2a6f7c 100644 --- a/templates/vnc_api_lib_ini_template.py +++ b/templates/vnc_api_lib_ini_template.py @@ -13,8 +13,7 @@ ; Authentication settings (optional) [auth] AUTHN_TYPE = keystone -AUTHN_PROTOCOL = http -AUTHN_SERVER=$__contrail_keystone_ip__ +AUTHN_SERVER=$__contrail_openstack_ip__ AUTHN_PORT = 35357 AUTHN_URL = /v2.0/tokens """) diff --git a/templates/vnswad_conf_template.py b/templates/vnswad_conf_template.py deleted file mode 100644 index a7fd2c7a..00000000 --- a/templates/vnswad_conf_template.py +++ /dev/null @@ -1,147 +0,0 @@ -import string - -template = string.Template(""" -# -# Vnswad configuration options -# - -[COLLECTOR] -# IP address and port to be used to connect to collector. If IP is not configured, -# value provided by discovery service will be used. (Optional) -# port=8086 -# server= - -[CONTROL-NODE] -# IP address to be used to connect to control-node. Maximum of 2 IP addresses -# (separated by a space) can be provided. If no IP is configured then the -# value provided by discovery service will be used. (Optional) -# server=10.0.0.1 10.0.0.2 - -[DEFAULT] -# Everything in this section is optional - -# Enable/disable debug logging. Possible values are 0 (disable) and 1 (enable) -# debug=0 - -# Aging time for flow-records in seconds -# flow_cache_timeout=0 - -# Hostname of compute-node. If this is not configured value from `hostname` -# will be taken -# hostname= - -# Http server port for inspecting vnswad state (useful for debugging) -# http_server_port=8085 - -# Category for logging. Default value is '*' -# log_category= - -# Local log file name -# log_file=/var/log/contrail/vrouter.log - -# Log severity levels. Possible values are SYS_EMERG, SYS_ALERT, SYS_CRIT, -# SYS_ERR, SYS_WARN, SYS_NOTICE, SYS_INFO and SYS_DEBUG. Default is SYS_DEBUG -# log_level=SYS_DEBUG - -# Enable/Disable local file logging. Possible values are 0 (disable) and 1 (enable) -# log_local=0 - -# Encapsulation type for tunnel. Possible values are MPLSoGRE, MPLSoUDP, VXLAN -# tunnel_type= - -[DISCOVERY] -# If COLLECTOR and/or CONTROL-NODE and/or DNS is not specified this section is -# mandatory. Else this section is optional - -# IP address of discovery server -server=$__contrail_discovery_ip__ - -# Number of control-nodes info to be provided by Discovery service. Possible -# values are 1 and 2 -max_control_nodes=$__contrail_discovery_ncontrol__ - -[DNS] -# IP address to be used to connect to dns-node. Maximum of 2 IP addresses -# (separated by a space) can be provided. If no IP is configured then the -# value provided by discovery service will be used. (Optional) -# server=10.0.0.1 10.0.0.2 - -[HYPERVISOR] -# Everything in this section is optional - -# Hypervisor type. Possible values are kvm, xen and vmware -# type=kvm - -# Link-local IP address and prefix in ip/prefix_len format (for xen) -# xen_ll_ip= - -# Link-local interface name when hypervisor type is Xen -# xen_ll_interface= - -# Physical interface name when hypervisor type is vmware -# vmware_physical_interface= - -[FLOWS] -# Everything in this section is optional - -# Maximum flows allowed per VM (given as % of maximum system flows) -# max_vm_flows=100 -# Maximum number of link-local flows allowed across all VMs -# max_system_linklocal_flows=4096 -# Maximum number of link-local flows allowed per VM -# max_vm_linklocal_flows=1024 - -[METADATA] -# Shared secret for metadata proxy service (Optional) -# metadata_proxy_secret=contrail - -[NETWORKS] -# control-channel IP address used by WEB-UI to connect to vnswad to fetch -# required information (Optional) -control_network_ip=$__contrail_control_ip__ - -[VIRTUAL-HOST-INTERFACE] -# Everything in this section is mandatory - -# name of virtual host interface -name=vhost0 - -# IP address and prefix in ip/prefix_len format -ip=$__contrail_vhost_ip__ - -# Gateway IP address for virtual host -gateway=$__contrail_vhost_gateway__ - -# Physical interface name to which virtual host interface maps to -physical_interface=$__contrail_physical_intf__ - -# We can have multiple gateway sections with different indices in the -# following format -[GATEWAY-0] -# Name of the routing_instance for which the gateway is being configured -# routing_instance=default-domain:admin:public:public - -# Gateway interface name -# interface=vgw - -# Virtual network ip blocks for which gateway service is required. Each IP -# block is represented as ip/prefix. Multiple IP blocks are represented by -# separating each with a space -# ip_blocks=1.1.1.1/24 - -[GATEWAY-1] -# Name of the routing_instance for which the gateway is being configured -# routing_instance=default-domain:admin:public1:public1 - -# Gateway interface name -# interface=vgw1 - -# Virtual network ip blocks for which gateway service is required. Each IP -# block is represented as ip/prefix. Multiple IP blocks are represented by -# separating each with a space -# ip_blocks=2.2.1.0/24 2.2.2.0/24 - -# Routes to be exported in routing_instance. Each route is represented as -# ip/prefix. Multiple routes are represented by separating each with a space -# routes=10.10.10.1/24 11.11.11.1/24 -""")