def configOVS(): output, exitcode = ShellCmdExecutor.execCmd('systemctl enable openvswitch.service') output, exitcode = ShellCmdExecutor.execCmd('systemctl start openvswitch.service') time.sleep(3) #Add the external bridge: ShellCmdExecutor.execCmd('ovs-vsctl add-br br-ex') time.sleep(2) #Add a port to the external bridge that connects to the physical external network interface: #Replace INTERFACE_NAME with the actual interface name. For example, eth2 or ens256. #REFACTOR LATER:on physical, the below is bond1 or bond2 physical_external_network_interface = 'eth2' # addExternalBridgeCmd = 'ovs-vsctl add-port br-ex %s' % physical_external_network_interface addExternalBridgeTemplateScriptPath = os.path.join(OPENSTACK_CONF_FILE_TEMPLATE_DIR, 'network', 'addExternalBridge.sh') ShellCmdExecutor.execCmd('cp -r %s /opt/' % addExternalBridgeTemplateScriptPath) FileUtil.replaceFileContent('/opt/addExternalBridge.sh', '<PHYSICAL_EXTERNAL_NETWORK_INTERFACE>', physical_external_network_interface) # output, exitcode = ShellCmdExecutor.execCmd('cat /opt/localip') # localIP = output.strip() # FileUtil.replaceFileContent('/opt/addExternalBridge.sh', # '<LOCAL_IP>', # localIP) ShellCmdExecutor.execCmd('bash /opt/addExternalBridge.sh') pass
def install(): print 'Cinder-storage.install start====' keystone_vip = JSONUtility.getValue('keystone_vip') print 'start to install prerequisites=============' script_file_path = os.path.join(OPENSTACK_CONF_FILE_TEMPLATE_DIR, 'cinder-storage', 'cinder_storage_service.sh') ShellCmdExecutor.execCmd('cp -r %s /opt/' % script_file_path) ShellCmdExecutor.execCmd('chmod 777 /opt/cinder_storage_service.sh') FileUtil.replaceFileContent('/opt/cinder_storage_service.sh', '<KEYSTONE_VIP>', keystone_vip) ShellCmdExecutor.execCmd('bash /opt/cinder_storage_service.sh') print 'install prerequisites done####' yumCmd = 'yum install lvm2 -y' ShellCmdExecutor.execCmd(yumCmd) ShellCmdExecutor.execCmd("/etc/init.d/lvm2-lvmetad start") ShellCmdExecutor.execCmd("chkconfig lvm2-lvmetad on") #Default create volume #Create the LVM physical volume /dev/sdb1: # createCmd = 'pvcreate /dev/sdb1' # ShellCmdExecutor.execCmd(createCmd) # createCmd = 'vgcreate cinder-volumes /dev/sdb1' # ShellCmdExecutor.execCmd(createCmd) yumCmd = 'yum install openstack-cinder python-oslo-db MySQL-python -y' ShellCmdExecutor.execCmd(yumCmd) print 'Cinder-storage.install done####' pass
def install(): #KEYSTONE_ADMIN_PASSWORD print 'Cinder-storage.install start====' # keystone_vip = JSONUtility.getValue('keystone_vip') keystone_admin_password = JSONUtility.getValue('keystone_admin_password') print 'start to install prerequisites=============' script_file_path = os.path.join(OPENSTACK_CONF_FILE_TEMPLATE_DIR, 'cinder-storage', 'cinder_storage_service.sh') ShellCmdExecutor.execCmd('cp -r %s /opt/' % script_file_path) ShellCmdExecutor.execCmd('chmod 777 /opt/cinder_storage_service.sh') FileUtil.replaceFileContent('/opt/cinder_storage_service.sh', '<KEYSTONE_VIP>', keystone_vip) ShellCmdExecutor.execCmd('bash /opt/cinder_storage_service.sh') ShellCmdExecutor.execCmd("systemctl restart lvm2-lvmetad.service") #Default create volume #Create the LVM physical volume /dev/sdb1: # createCmd = 'pvcreate /dev/sdb1' # ShellCmdExecutor.execCmd(createCmd) # createCmd = 'vgcreate cinder-volumes /dev/sdb1' # ShellCmdExecutor.execCmd(createCmd) yumCmd = 'yum install openstack-cinder targetcli python-oslo-db python-oslo-log MySQL-python -y' ShellCmdExecutor.execCmd(yumCmd) print 'Cinder-storage.install done####' pass
def confiugureNeutron(): neutronConfTemplateFilePath = os.path.join(OPENSTACK_CONF_FILE_TEMPLATE_DIR, 'nova-compute', 'neutron.conf') ShellCmdExecutor.execCmd('cp -r %s /etc/neutron/' % neutronConfTemplateFilePath) #configure neutron keystone_vip = JSONUtility.getValue('keystone_vip') # rabbit_host = JSONUtility.getValue("rabbit_host") # rabbit_vip = JSONUtility.getValue("rabbit_vip") rabbit_hosts = JSONUtility.getValue("rabbit_hosts") rabbit_userid = JSONUtility.getValue("rabbit_userid") rabbit_password = JSONUtility.getValue("rabbit_password") #REFACTOR LATER neutron_pass = '******' neutronConfFilePath = '/etc/neutron/neutron.conf' ShellCmdExecutor.execCmd('chmod 777 /etc/neutron/neutron.conf') FileUtil.replaceFileContent(neutronConfFilePath, '<KEYSTONE_VIP>', keystone_vip) FileUtil.replaceFileContent(neutronConfFilePath, '<NEUTRON_PASS>', neutron_pass) # FileUtil.replaceFileContent(neutronConfFilePath, '<RABBIT_HOST>', rabbit_vip) FileUtil.replaceFileContent(neutronConfFilePath, '<RABBIT_HOSTS>', rabbit_hosts) FileUtil.replaceFileContent(neutronConfFilePath, '<RABBIT_USERID>', rabbit_userid) FileUtil.replaceFileContent(neutronConfFilePath, '<RABBIT_PASSWORD>', rabbit_password) ShellCmdExecutor.execCmd('chown -R neutron:neutron /etc/neutron') pass
def configConfFile(): localSettingsFileTemplatePath = os.path.join(OPENSTACK_CONF_FILE_TEMPLATE_DIR, 'dashboard', 'local_settings') dashboardConfFileDir = '/etc/openstack-dashboard/' if os.path.exists(Dashboard.DASHBOARD_CONF_FILE_PATH) : ShellCmdExecutor.execCmd("rm -rf %s" % Dashboard.DASHBOARD_CONF_FILE_PATH) pass else : ShellCmdExecutor.execCmd("sudo mkdir %s" % dashboardConfFileDir) pass print 'localSettingsFileTemplatePath=%s--' % localSettingsFileTemplatePath ShellCmdExecutor.execCmd("sudo chmod 777 %s" % dashboardConfFileDir) ####NEW ShellCmdExecutor.execCmd('cat %s > /tmp/local_settings' % localSettingsFileTemplatePath) ShellCmdExecutor.execCmd('mv /tmp/local_settings %s' % dashboardConfFileDir) keystone_vip = JSONUtility.getValue("keystone_vip") ShellCmdExecutor.execCmd('sudo chmod 777 %s' % Dashboard.DASHBOARD_CONF_FILE_PATH) FileUtil.replaceFileContent(Dashboard.DASHBOARD_CONF_FILE_PATH, '<KEYSTONE_VIP>', keystone_vip) ShellCmdExecutor.execCmd('sudo chmod 644 %s' % Dashboard.DASHBOARD_CONF_FILE_PATH) #Assign rights: can be accessed DIR_PATH = '/usr/share/openstack-dashboard/openstack_dashboard/local' if os.path.exists(DIR_PATH) : ShellCmdExecutor.execCmd('sudo chmod 777 %s' % DIR_PATH) pass pass
def configureML2(): ml2ConfTemplatePath = os.path.join(OPENSTACK_CONF_FILE_TEMPLATE_DIR, 'nova-compute', 'ml2_conf.ini') ShellCmdExecutor.execCmd('cp -r %s /etc/neutron/plugins/ml2/' % ml2ConfTemplatePath) output, exitcode = ShellCmdExecutor.execCmd('cat /opt/localip') localIP = output.strip() FileUtil.replaceFileContent('/etc/neutron/plugins/ml2/ml2_conf.ini', '<INSTANCE_TUNNELS_INTERFACE_IP_ADDRESS>', localIP) pass
def prepareAdminOpenrc(): adminOpenrcTemplateFilePath = os.path.join(OPENSTACK_CONF_FILE_TEMPLATE_DIR, 'admin-openrc.sh') ShellCmdExecutor.execCmd('cp -r %s /opt/openstack_conf' % adminOpenrcTemplateFilePath) keystone_admin_password = JSONUtility.getValue('keystone_admin_password') keystone_vip = JSONUtility.getValue('keystone_vip') FileUtil.replaceFileContent('/opt/openstack_conf/admin-openrc.sh', '<KEYSTONE_ADMIN_PASSWORD>', keystone_admin_password) FileUtil.replaceFileContent('/opt/openstack_conf/admin-openrc.sh', '<KEYSTONE_VIP>', keystone_vip) pass
def configureKeystoneHAProxy(): dashboard_vip = JSONUtility.getValue("dashboard_vip") openstackConfPopertiesFilePath = PropertiesUtility.getOpenstackConfPropertiesFilePath() HAProxyTemplateFilePath = os.path.join(OPENSTACK_CONF_FILE_TEMPLATE_DIR, 'haproxy.cfg') haproxyConfFilePath = PropertiesUtility.getValue(openstackConfPopertiesFilePath, 'HAPROXY_CONF_FILE_PATH') print 'haproxyConfFilePath=%s' % haproxyConfFilePath if not os.path.exists('/etc/haproxy') : ShellCmdExecutor.execCmd('sudo mkdir /etc/haproxy') pass if not os.path.exists(haproxyConfFilePath) : ShellCmdExecutor.execCmd('sudo cp -rf %s %s' % (HAProxyTemplateFilePath, haproxyConfFilePath)) pass ShellCmdExecutor.execCmd('sudo chmod 777 %s' % haproxyConfFilePath) dashboardBackendStringTemplate = ''' listen dashboard_cluster bind <DASHBOARD_VIP>:80 balance source option tcpka option httpchk option tcplog <DASHBOARD_SERVER_LIST> ''' ############### dashboardBackendString = dashboardBackendStringTemplate.replace('<DASHBOARD_VIP>', dashboard_vip) ################new dashboard_ips = JSONUtility.getValue("dashboard_ips") dashboard_ip_list = dashboard_ips.strip().split(',') serverDashboardBackendTemplate = 'server dashboard-<INDEX> <SERVER_IP>:8080 weight 3 check inter 2000 rise 2 fall 3' dashboardServerListContent = '' index = 1 for dashboard_ip in dashboard_ip_list: print 'dashboard_ip=%s' % dashboard_ip dashboardServerListContent += serverDashboardBackendTemplate.replace('<INDEX>', str(index)).replace('<SERVER_IP>', dashboard_ip) dashboardServerListContent += '\n' dashboardServerListContent += ' ' index += 1 pass dashboardServerListContent = dashboardServerListContent.strip() print 'dashboardServerListContent=%s--' % dashboardServerListContent dashboardBackendString = dashboardBackendString.replace('<DASHBOARD_SERVER_LIST>', dashboardServerListContent) print 'dashboardBackendString=%s--' % dashboardBackendString #append FileUtil.replaceFileContent(haproxyConfFilePath, '<DASHBOARD_LIST>', dashboardBackendString) ShellCmdExecutor.execCmd('sudo chmod 644 %s' % haproxyConfFilePath)
def configConfFile(): print "configure keystone conf file======" mysql_vip = JSONUtility.getValue("mysql_vip") admin_token = JSONUtility.getValue("admin_token") #memcache service list keystone_ips_string = JSONUtility.getValue("keystone_ips") keystone_ip_list = keystone_ips_string.split(',') memcached_service_list = [] for ip in keystone_ip_list: memcached_service_list.append(ip.strip() + ':11211') pass memcached_service_string = ','.join(memcached_service_list) print 'memcached_service_string=%s--' % memcached_service_string openstackConfPopertiesFilePath = PropertiesUtility.getOpenstackConfPropertiesFilePath() keystoneConfDir = PropertiesUtility.getValue(openstackConfPopertiesFilePath, 'KEYSTONE_CONF_DIR') keystone_conf_file_path = os.path.join(keystoneConfDir, 'keystone.conf') if not os.path.exists(keystoneConfDir) : os.system("sudo mkdir -p %s" % keystoneConfDir) pass ShellCmdExecutor.execCmd("cp -r %s %s" % (SOURCE_KEYSTONE_CONF_FILE_TEMPLATE_PATH, keystoneConfDir)) ShellCmdExecutor.execCmd("sudo chmod 777 %s" % keystone_conf_file_path) # #if exist, remove original conf files # if os.path.exists(keystone_conf_file_path) : # os.system("sudo rm -rf %s" % keystone_conf_file_path) # pass # # ShellCmdExecutor.execCmd('chmod 777 /etc/keystone') # # # os.system("sudo cp -r %s %s" % (SOURCE_KEYSTONE_CONF_FILE_TEMPLATE_PATH, keystoneConfDir)) # ###NEW # ShellCmdExecutor.execCmd('cat %s > /tmp/keystone.conf' % SOURCE_KEYSTONE_CONF_FILE_TEMPLATE_PATH) # ShellCmdExecutor.execCmd('mv /tmp/keystone.conf /etc/keystone/') # # ShellCmdExecutor.execCmd("sudo chmod 777 %s" % keystone_conf_file_path) ###########LOCAL_IP:retrieve it from one file, the LOCAL_IP file is generated when this project inits. localIP = Keystone.getLocalIP() print 'localip=%s--' % localIP # FileUtil.replaceByRegularExpression(keystone_conf_file_path, '<LOCAL_IP>', localIP) # FileUtil.replaceByRegularExpression(keystone_conf_file_path, '<MYSQL_VIP>', mysql_vip) keystoneDbPass = JSONUtility.getValue('keystone_dbpass') FileUtil.replaceFileContent(keystone_conf_file_path, '<ADMIN_TOKEN>', admin_token) FileUtil.replaceFileContent(keystone_conf_file_path, '<LOCAL_MANAGEMENT_IP>', localIP) FileUtil.replaceFileContent(keystone_conf_file_path, '<MYSQL_VIP>', mysql_vip) FileUtil.replaceFileContent(keystone_conf_file_path, '<KEYSTONE_DBPASS>', keystoneDbPass) FileUtil.replaceFileContent(keystone_conf_file_path, '<MEMCACHED_LIST>', memcached_service_string) ShellCmdExecutor.execCmd("chmod 644 %s" % keystone_conf_file_path) print "configure keystone conf file done####" pass
def sourceAdminOpenRC(): adminOpenRCScriptPath = os.path.join(OPENSTACK_CONF_FILE_TEMPLATE_DIR, 'admin_openrc.sh') print 'adminOpenRCScriptPath=%s' % adminOpenRCScriptPath ShellCmdExecutor.execCmd('cp -rf %s /opt/' % adminOpenRCScriptPath) keystone_vip = JSONUtility.getValue("keystone_vip") FileUtil.replaceFileContent('/opt/admin_openrc.sh', '<KEYSTONE_VIP>', keystone_vip) time.sleep(2) ShellCmdExecutor.execCmd('source /opt/admin_openrc.sh') pass
def configureOVS(): ShellCmdExecutor.execCmd("service openvswitch start") ShellCmdExecutor.execCmd("chkconfig openvswitch on") scriptPath = os.path.join(OPENSTACK_CONF_FILE_TEMPLATE_DIR, 'nova-compute', 'addBridgeAndInterface.sh') ShellCmdExecutor.execCmd('cp -r %s /opt/' % scriptPath) output, exitcode = ShellCmdExecutor.execCmd('cat /opt/localip') localIP = output.strip() FileUtil.replaceFileContent('/opt/addBridgeAndInterface.sh', '<LOCAL_IP>', localIP) ShellCmdExecutor.execCmd('bash /opt/addBridgeAndInterface.sh') pass
def initNeutron(): ha_vip1 = JSONUtility.getValue('ha_vip1') ha_vip2 = JSONUtility.getValue('ha_vip2') keystone_admin_password = JSONUtility.getValue('keystone_admin_password') keystone_vip = ha_vip1 keystone_neutron_password = JSONUtility.getValue('keystone_neutron_password') neutron_vip = ha_vip1 initNeutronScriptTemplatePath = os.path.join(OPENSTACK_CONF_FILE_TEMPLATE_DIR, 'neutron-server', 'initNeutron.sh') ## openstackConfPopertiesFilePath = PropertiesUtility.getOpenstackConfPropertiesFilePath() openstackScriptDirPath = PropertiesUtility.getValue(openstackConfPopertiesFilePath, 'OPENSTACK_SCRIPT_DIR') if os.path.exists(openstackScriptDirPath) : os.system('mkdir -p %s' % openstackScriptDirPath) pass ShellCmdExecutor.execCmd('cp -r %s %s' % (initNeutronScriptTemplatePath, openstackScriptDirPath)) initNeutronScriptPath = os.path.join(openstackScriptDirPath, 'initNeutron.sh') FileUtil.replaceFileContent(initNeutronScriptPath, '<KEYSTONE_ADMIN_PASSWORD>', keystone_admin_password) FileUtil.replaceFileContent(initNeutronScriptPath, '<KEYSTONE_VIP>', keystone_vip) FileUtil.replaceFileContent(initNeutronScriptPath, '<KEYSTONE_NEUTRON_PASSWORD>', keystone_neutron_password) FileUtil.replaceFileContent(initNeutronScriptPath, '<NEUTRON_VIP>', neutron_vip) ShellCmdExecutor.execCmd('bash %s' % initNeutronScriptPath) pass
def configML2(): if os.path.exists(Network.NEUTRON_ML2_CONF_FILE_PATH) : ShellCmdExecutor.execCmd("rm -rf %s" % Network.NEUTRON_ML2_CONF_FILE_PATH) pass ml2_template_conf_file_path = os.path.join(OPENSTACK_CONF_FILE_TEMPLATE_DIR, 'network', 'ml2_conf.ini') ShellCmdExecutor.execCmd('cat %s > /tmp/ml2_conf.ini' % ml2_template_conf_file_path) ShellCmdExecutor.execCmd('mv /tmp/ml2_conf.ini /etc/neutron/plugins/ml2/') output, exitcode = ShellCmdExecutor.execCmd('cat /opt/localip') localIP = output.strip() FileUtil.replaceFileContent(Network.NEUTRON_ML2_CONF_FILE_PATH, '<INSTANCE_TUNNELS_INTERFACE_IP_ADDRESS>', localIP) pass
def configKeepalived(): ha_vip1 = JSONUtility.getValue('ha_vip1') ha_vip2 = JSONUtility.getValue('ha_vip2') ha_vip1_interface = JSONUtility.getValue('ha_vip1_interface') ha_vip2_interface = JSONUtility.getValue('ha_vip2_interface') keepalived_conf_1_template_path = os.path.join(OPENSTACK_CONF_FILE_TEMPLATE_DIR, 'ha', 'keepalived.conf.1') keepalived_conf_2_template_path = os.path.join(OPENSTACK_CONF_FILE_TEMPLATE_DIR, 'ha', 'keepalived.conf.2') keepalived_conf_dest_path = '/etc/keepalived/keepalived.conf' haproxy_keepalived_ips = JSONUtility.getValue('haproxy_keepalived_ips') haproxy_keepalived_ip_list = haproxy_keepalived_ips.split(',') output, exitcode = ShellCmdExecutor.execCmd('cat /opt/localip') local_management_ip = output.strip() serverIndex = ServerSequence.getIndex(haproxy_keepalived_ip_list, local_management_ip) if serverIndex == 0 : ShellCmdExecutor.execCmd('cp -r %s %s' % (keepalived_conf_1_template_path, keepalived_conf_dest_path)) FileUtil.replaceFileContent(keepalived_conf_dest_path, '<HA_VIP1>', ha_vip1) FileUtil.replaceFileContent(keepalived_conf_dest_path, '<HA_VIP1_INTERFACE>', ha_vip1_interface) pass if serverIndex == 1 : ShellCmdExecutor.execCmd('cp -r %s %s' % (keepalived_conf_2_template_path, keepalived_conf_dest_path)) FileUtil.replaceFileContent(keepalived_conf_dest_path, '<HA_VIP2>', ha_vip2) FileUtil.replaceFileContent(keepalived_conf_dest_path, '<HA_VIP1_INTERFACE>', ha_vip2_interface) pass haproxy_check_script_path = os.path.join(OPENSTACK_CONF_FILE_TEMPLATE_DIR, 'ha', 'haproxy_check.sh') ShellCmdExecutor.execCmd('cp -r %s /etc/keepalived/' % haproxy_check_script_path) ShellCmdExecutor.execCmd('chmod 644 %s' % keepalived_conf_dest_path) ShellCmdExecutor.execCmd('chmod 644 /etc/keepalived/haproxy_check.sh') pass
def configConfFile(): ''' LOCAL_MANAGEMENT_IP KEYSTONE_VIP ''' localSettingsFileTemplatePath = os.path.join(OPENSTACK_CONF_FILE_TEMPLATE_DIR, 'dashboard', 'local_settings') dashboardConfFileDir = '/etc/openstack-dashboard/' if os.path.exists(Dashboard.DASHBOARD_CONF_FILE_PATH) : ShellCmdExecutor.execCmd("rm -rf %s" % Dashboard.DASHBOARD_CONF_FILE_PATH) pass else : ShellCmdExecutor.execCmd("sudo mkdir %s" % dashboardConfFileDir) pass print 'localSettingsFileTemplatePath=%s--' % localSettingsFileTemplatePath ShellCmdExecutor.execCmd("sudo chmod 777 %s" % dashboardConfFileDir) ####NEW ShellCmdExecutor.execCmd('cat %s > /tmp/local_settings' % localSettingsFileTemplatePath) ShellCmdExecutor.execCmd('cp -r /tmp/local_settings %s' % dashboardConfFileDir) ShellCmdExecutor.execCmd('rm -rf /tmp/local_settings') keystone_vip = JSONUtility.getValue("keystone_vip") print "keystone_vip=%s" % keystone_vip output, exitcode = ShellCmdExecutor.execCmd('cat /opt/localip') localIP = output.strip() dashboard_ips_string = JSONUtility.getValue("dashboard_ips") dashboard_ip_list = dashboard_ips_string.split(',') memcached_service_list = [] for ip in dashboard_ip_list: memcached_service_list.append(ip.strip() + ':11211') pass memcached_service_string = ','.join(memcached_service_list) print 'memcached_service_string=%s--' % memcached_service_string ShellCmdExecutor.execCmd('sudo chmod 777 %s' % Dashboard.DASHBOARD_CONF_FILE_PATH) FileUtil.replaceFileContent(Dashboard.DASHBOARD_CONF_FILE_PATH, '<KEYSTONE_VIP>', keystone_vip) FileUtil.replaceFileContent(Dashboard.DASHBOARD_CONF_FILE_PATH, '<LOCAL_MANAGEMENT_IP>', localIP) ShellCmdExecutor.execCmd('sudo chmod 644 %s' % Dashboard.DASHBOARD_CONF_FILE_PATH) #Assign rights: can be accessed DIR_PATH = '/usr/share/openstack-dashboard/openstack_dashboard/local' if os.path.exists(DIR_PATH) : ShellCmdExecutor.execCmd('sudo chmod 777 %s' % DIR_PATH) pass pass
def start(): init_script_template_file_path = os.path.join(OPENSTACK_CONF_FILE_TEMPLATE_DIR, 'rabbitmq', 'initRabbitmqCluster.sh') '<RABBIT_USER_ID> <RABBIT_PASS>' if not os.path.exists('/opt/openstack_conf/') : ShellCmdExecutor.execCmd('mkdir /opt/openstack_conf') pass ShellCmdExecutor.execCmd('cp -r %s /opt/openstack_conf/' % init_script_template_file_path) init_script_path = '/opt/openstack_conf/initRabbitmqCluster.sh' rabbit_user_id = 'nova' rabbit_password = JSONUtility.getValue('rabbit_password') FileUtil.replaceFileContent(init_script_path, '<RABBIT_USER_ID>', rabbit_user_id) FileUtil.replaceFileContent(init_script_path, '<RABBIT_PASS>', rabbit_password) output,exitcode = ShellCmdExecutor.execCmd('bash %s' % init_script_path) pass
def config(): rabbitmq_config_template_file_path = os.path.join(OPENSTACK_CONF_FILE_TEMPLATE_DIR, 'rabbitmq', 'rabbitmq.config') rabbitmq_env_conf_template_file_path = os.path.join(OPENSTACK_CONF_FILE_TEMPLATE_DIR, 'rabbitmq', 'rabbitmq-env.conf') rabbitmq_config_file_path = '/etc/rabbitmq/rabbitmq.config' # if os.path.exists(rabbitmq_config_file_path) : # os.system("rm -rf %s" % rabbitmq_config_file_path) # pass rabbitmq_env_conf_file_path = '/etc/rabbitmq/rabbitmq-env.conf' # if os.path.exists(rabbitmq_env_conf_file_path) : # os.system("rm -rf %s" % rabbitmq_env_conf_file_path) # pass ShellCmdExecutor.execCmd('cp -r %s /etc/rabbitmq/' % rabbitmq_config_template_file_path) ShellCmdExecutor.execCmd('cp -r %s /etc/rabbitmq/' % rabbitmq_env_conf_template_file_path) output, exitcode = ShellCmdExecutor.execCmd('cat /opt/localip') management_ip = output.strip() print 'management_ip=%s--' % management_ip print '' FileUtil.replaceFileContent(rabbitmq_config_file_path, '<MANAGEMENT_IP>', management_ip) rabbitmq_ips = JSONUtility.getValue('rabbitmq_ips') rabbit_at_ip_list = [] rabbitmq_ip_list = rabbitmq_ips.split(',') for ip in rabbitmq_ip_list: rabbit_at_ip_list.append("'"+'rabbit@'+ip+"'") pass rabbitmq_cluster_string = ','.join(rabbit_at_ip_list) FileUtil.replaceFileContent(rabbitmq_config_file_path, '<RABBITMQ_CLUSTER>', rabbitmq_cluster_string) ShellCmdExecutor.execCmd('chown -R root:root /etc/rabbitmq') #rabbitmq cookie erlang_cookie_template_file_path = os.path.join(OPENSTACK_CONF_FILE_TEMPLATE_DIR, 'rabbitmq', 'erlang.cookie') erlang_cookie_dest_file_path = '/var/lib/rabbitmq/.erlang.cookie' if os.path.exists(erlang_cookie_dest_file_path) : os.system('rm -rf %s' % erlang_cookie_dest_file_path) pass ShellCmdExecutor.execCmd('cp -r %s /var/lib/rabbitmq/' % erlang_cookie_template_file_path) ShellCmdExecutor.execCmd('mv /var/lib/rabbitmq/erlang.cookie %s' % erlang_cookie_dest_file_path) ShellCmdExecutor.execCmd('chown -R rabbitmq:rabbitmq /var/lib/rabbitmq/') ShellCmdExecutor.execCmd('chmod 400 %s' % erlang_cookie_dest_file_path) pass
def reConfigureML2(): #support vxlan network mode network_mode = JSONUtility.getValue('neutron_network_mode') network_mode = network_mode.strip() if network_mode == 'vxlan' : FileUtil.replaceFileContent(VXLANConfig.NEUTRON_ML2_CONF_FILE_PATH, 'type_drivers = flat,gre', 'type_drivers = vxlan,flat,gre') FileUtil.replaceFileContent(VXLANConfig.NEUTRON_ML2_CONF_FILE_PATH, 'tenant_network_types = gre', 'tenant_network_types = vxlan,gre') FileUtil.replaceFileContent(VXLANConfig.NEUTRON_ML2_CONF_FILE_PATH, '#vni_ranges = 1:1000', 'vni_ranges = 1:1000') FileUtil.replaceFileContent(VXLANConfig.NEUTRON_ML2_CONF_FILE_PATH, 'tunnel_types = gre', 'tunnel_types = vxlan') pass pass
def getServiceTenantID(): #install keystone client ShellCmdExecutor.execCmd('yum install python-keystoneclient -y') serviceTenantIDScriptPath = os.path.join(OPENSTACK_CONF_FILE_TEMPLATE_DIR, 'neutron-server','serviceTenantID.sh') print 'serviceTenantIDScriptPath=%s' % serviceTenantIDScriptPath ShellCmdExecutor.execCmd('cp -r %s /opt/' % serviceTenantIDScriptPath) keystone_vip = JSONUtility.getValue("keystone_vip") FileUtil.replaceFileContent('/opt/serviceTenantID.sh', '<KEYSTONE_VIP>', keystone_vip) output, exitcode = ShellCmdExecutor.execCmd('bash /opt/serviceTenantID.sh') serviceTenantID = output.strip() if debug == True : #fake for local debug serviceTenantID = '112233445566' pass print 'serviceTenantID=%s--' % serviceTenantID return serviceTenantID pass
def config(): SOURCE_RDB_CONF_FILE_TEMPLATE_PATH = os.path.join(OPENSTACK_CONF_FILE_TEMPLATE_DIR, 'mysql', 'my.cnf') RDB_DEPLOY_DIR = '/opt/bcrdb' DEST_RDB_CONF_DIR = os.path.join(RDB_DEPLOY_DIR, 'conf') RDB_CONF_FILE_PATH = os.path.join(DEST_RDB_CONF_DIR, 'my.cnf') EXECUTE_MYSQL_PATH = os.path.join(RDB_DEPLOY_DIR, 'bin', 'mysql') MYSQLADMIN_BIN_PATH = os.path.join(RDB_DEPLOY_DIR, 'bin', 'mysqladmin') ShellCmdExecutor.execCmd('cp -r %s %s' % (SOURCE_RDB_CONF_FILE_TEMPLATE_PATH, DEST_RDB_CONF_DIR)) mysql_ips = JSONUtility.getValue("mysql_ips") print 'mysql_ips=%s---' % mysql_ips mysql_ip_list = mysql_ips.strip().split(',') print 'mysql_ip_list=%s--' % mysql_ip_list output, exitcode = ShellCmdExecutor.execCmd('cat /opt/localip') local_management_ip = output.strip() mysql_ip_list1 = [] for ip in mysql_ip_list : if ip.strip() != local_management_ip : mysql_ip_list1.append(ip) pass pass print 'mysql_ip_list1=%s--' % mysql_ip_list1 mysql_ip_list_string = ','.join(mysql_ip_list1) #The rest mysql except itself print 'mysql_ip_list_string=%s--' % mysql_ip_list_string FileUtil.replaceFileContent(RDB_CONF_FILE_PATH, '<MYSQL_IP_LIST>', mysql_ip_list_string) #add user bcrdb ShellCmdExecutor.execCmd('useradd bcrdb') #assign rights ShellCmdExecutor.execCmd('chown -R bcrdb:bcrdb /opt/bcrdb') #cp mysql to /usr/bin ShellCmdExecutor.execCmd('cp -r %s /usr/bin/' % EXECUTE_MYSQL_PATH) ShellCmdExecutor.execCmd('cp -r %s /usr/bin/' % MYSQLADMIN_BIN_PATH) pass
def configConfFile(): openstackConfPopertiesFilePath = PropertiesUtility.getOpenstackConfPropertiesFilePath() local_ip_file_path = PropertiesUtility.getValue(openstackConfPopertiesFilePath, 'LOCAL_IP_FILE_PATH') output, exitcode = ShellCmdExecutor.execCmd('cat %s' % local_ip_file_path) localIP = output.strip() print 'locaIP=%s' % localIP openstackConfPopertiesFilePath = PropertiesUtility.getOpenstackConfPropertiesFilePath() mongodb_conf_template_file_path = os.path.join(OPENSTACK_CONF_FILE_TEMPLATE_DIR, 'mongodb', 'mongodb.conf') print 'mongodb_conf_template_file_path=%s' % mongodb_conf_template_file_path mongodb_conf_file_path = '/etc/mongodb.conf' if os.path.exists(mongodb_conf_file_path) : ShellCmdExecutor.execCmd("rm -rf %s" % mongodb_conf_file_path) pass ShellCmdExecutor.execCmd('cat %s > /tmp/mongodb.conf' % mongodb_conf_template_file_path) ShellCmdExecutor.execCmd('mv /tmp/mongodb.conf /etc/') ShellCmdExecutor.execCmd("sudo chmod 777 %s" % mongodb_conf_file_path) FileUtil.replaceFileContent(mongodb_conf_file_path, '<LOCAL_IP>', localIP) ShellCmdExecutor.execCmd("sudo chmod 755 %s" % mongodb_conf_file_path) pass
def configureKeepalived(): openstackConfPopertiesFilePath = PropertiesUtility.getOpenstackConfPropertiesFilePath() ###################configure keepalived glanceKeepalivedTemplateFilePath = os.path.join(OPENSTACK_CONF_FILE_TEMPLATE_DIR, 'keepalived.conf') keepalivedConfFilePath = PropertiesUtility.getValue(openstackConfPopertiesFilePath, 'KEEPALIVED_CONF_FILE_PATH') print 'keepalivedConfFilePath=%s' % keepalivedConfFilePath if not os.path.exists('/etc/keepalived') : ShellCmdExecutor.execCmd('sudo mkdir /etc/keepalived') pass #configure haproxy check script in keepalived checkHAProxyScriptPath = os.path.join(OPENSTACK_CONF_FILE_TEMPLATE_DIR, 'check_haproxy.sh') print 'checkHAProxyScriptPath=%s===========================---' % checkHAProxyScriptPath ShellCmdExecutor.execCmd('sudo cp -r %s %s' % (checkHAProxyScriptPath, '/etc/keepalived')) if os.path.exists(keepalivedConfFilePath) : ShellCmdExecutor.execCmd("sudo rm -rf %s" % keepalivedConfFilePath) pass ShellCmdExecutor.execCmd('sudo cp -r %s %s' % (glanceKeepalivedTemplateFilePath, '/etc/keepalived')) ShellCmdExecutor.execCmd("sudo chmod 777 %s" % keepalivedConfFilePath) ##configure nova_vip = JSONUtility.getValue("nova_vip") nova_vip_interface = JSONUtility.getValue("nova_vip_interface") weight_counter = 300 if NovaHA.isMasterNode() : weight_counter = 300 state = 'MASTER' pass else : index = NovaHA.getIndex() #get this host index which is indexed by the gid in /etc/astutue.yaml responding with this role weight_counter = 300 - index state = 'SLAVE' + str(index) pass FileUtil.replaceFileContent(keepalivedConfFilePath, '<WEIGHT>', str(weight_counter)) FileUtil.replaceFileContent(keepalivedConfFilePath, '<STATE>', state) FileUtil.replaceFileContent(keepalivedConfFilePath, '<INTERFACE>', nova_vip_interface) FileUtil.replaceFileContent(keepalivedConfFilePath, '<VIRTURL_IPADDR>', nova_vip) ##temporary: if current user is not root ShellCmdExecutor.execCmd("sudo chmod 644 %s" % keepalivedConfFilePath) #If keepalived need to support more VIP: append here pass
def reconfigureNovaCompute(): neutron_vip = JSONUtility.getValue("neutron_vip") keystone_vip = JSONUtility.getValue("keystone_vip") APIsAndDrivers = ''' network_api_class = nova.network.neutronv2.api.API security_group_api = neutron linuxnet_interface_driver = nova.network.linux_net.LinuxOVSInterfaceDriver firewall_driver = nova.virt.firewall.NoopFirewallDriver ''' APIsAndDrivers = APIsAndDrivers.strip() AccessParameters = ''' [neutron] url = http://<NEUTRON_VIP>:9696 auth_strategy = keystone admin_auth_url = http://<KEYSTONE_VIP>:35357/v2.0 admin_tenant_name = service admin_username = neutron admin_password = <NEUTRON_PASS> ''' AccessParameters = AccessParameters.strip() AccessParameters = AccessParameters.replace('<NEUTRON_VIP>', neutron_vip) AccessParameters = AccessParameters.replace('<KEYSTONE_VIP>', keystone_vip) #REFACTOR LATER neutron_pass = '******' AccessParameters = AccessParameters.replace('<NEUTRON_PASS>', neutron_pass) NOVA_CONF_FILE_PATH = '/etc/nova/nova.conf' FileUtil.replaceFileContent(NOVA_CONF_FILE_PATH, '#APIsAndDrivers', APIsAndDrivers) FileUtil.replaceFileContent(NOVA_CONF_FILE_PATH, '#AccessParameters', AccessParameters) ############################## FileUtil.replaceFileContent(NOVA_CONF_FILE_PATH, '#vif_plugging_is_fatal=true', 'vif_plugging_is_fatal=false') FileUtil.replaceFileContent(NOVA_CONF_FILE_PATH, '#vif_plugging_timeout=300', 'vif_plugging_timeout=0') pass
def reConfigureML2(): # support vxlan network mode network_mode = JSONUtility.getValue("neutron_network_mode") network_mode = network_mode.strip() if network_mode == "vxlan": FileUtil.replaceFileContent( VXLANConfig.NEUTRON_ML2_CONF_FILE_PATH, "type_drivers = flat,gre", "type_drivers = vxlan,flat,gre" ) FileUtil.replaceFileContent( VXLANConfig.NEUTRON_ML2_CONF_FILE_PATH, "tenant_network_types = gre", "tenant_network_types = vxlan,gre" ) FileUtil.replaceFileContent( VXLANConfig.NEUTRON_ML2_CONF_FILE_PATH, "#vni_ranges = 1:1000", "vni_ranges = 1:1000" ) FileUtil.replaceFileContent( VXLANConfig.NEUTRON_ML2_CONF_FILE_PATH, "tunnel_types = gre", "tunnel_types = vxlan" ) pass pass
def configMetadataAgent(): if os.path.exists(Network.NEUTRON_METADATA_CONF_FILE_PATH) : ShellCmdExecutor.execCmd("rm -rf %s" % Network.NEUTRON_METADATA_CONF_FILE_PATH) pass neutron_metadata_template_conf_file_path = os.path.join(OPENSTACK_CONF_FILE_TEMPLATE_DIR, 'network', 'metadata_agent.ini') ShellCmdExecutor.execCmd('cat %s > /tmp/metadata_agent.ini' % neutron_metadata_template_conf_file_path) ShellCmdExecutor.execCmd('mv /tmp/metadata_agent.ini /etc/neutron/') keystone_vip = JSONUtility.getValue("keystone_vip") nova_vip = JSONUtility.getValue("nova_vip") keystone_neutron_password = JSONUtility.getValue("keystone_neutron_password") #REFACTOR LATER metadata_secret = '123456'#JSONUtility.getValue("metadata_secret") FileUtil.replaceFileContent(Network.NEUTRON_METADATA_CONF_FILE_PATH, '<KEYSTONE_VIP>', keystone_vip) FileUtil.replaceFileContent(Network.NEUTRON_METADATA_CONF_FILE_PATH, '<NOVA_VIP>', nova_vip) FileUtil.replaceFileContent(Network.NEUTRON_METADATA_CONF_FILE_PATH, '<KEYSTONE_NEUTRON_PASSWORD>', keystone_neutron_password) FileUtil.replaceFileContent(Network.NEUTRON_METADATA_CONF_FILE_PATH, '<METADATA_SECRET>', metadata_secret) pass
def initNova(): #to replace in template: KEYSTONE_ADMIN_PASSWORD KEYSTONE_VIP KEYSTONE_NOVA_PASSWORD NOVA_VIP keystone_admin_password = JSONUtility.getValue('keystone_admin_password') keystone_vip = JSONUtility.getValue('keystone_vip') keystone_nova_password = JSONUtility.getValue('keystone_nova_password') nova_vip = JSONUtility.getValue('ha_vip1') initNovaScriptTemplatePath = os.path.join(OPENSTACK_CONF_FILE_TEMPLATE_DIR, 'nova', 'initNova.sh') ## openstackConfPopertiesFilePath = PropertiesUtility.getOpenstackConfPropertiesFilePath() openstackScriptDirPath = PropertiesUtility.getValue(openstackConfPopertiesFilePath, 'OPENSTACK_SCRIPT_DIR') if os.path.exists(openstackScriptDirPath) : os.system('mkdir -p %s' % openstackScriptDirPath) pass ShellCmdExecutor.execCmd('cp -r %s %s' % (initNovaScriptTemplatePath, openstackScriptDirPath)) initNovaScriptPath = os.path.join(openstackScriptDirPath, 'initNova.sh') FileUtil.replaceFileContent(initNovaScriptPath, '<KEYSTONE_ADMIN_PASSWORD>', keystone_admin_password) FileUtil.replaceFileContent(initNovaScriptPath, '<KEYSTONE_VIP>', keystone_vip) FileUtil.replaceFileContent(initNovaScriptPath, '<KEYSTONE_NOVA_PASSWORD>', keystone_nova_password) FileUtil.replaceFileContent(initNovaScriptPath, '<NOVA_VIP>', nova_vip) ShellCmdExecutor.execCmd('bash %s' % initNovaScriptPath) pass
def configConfFile(): print "configure keystone conf file======" mysql_vip = JSONUtility.getValue("mysql_vip") mysql_password = JSONUtility.getValue("mysql_password") openstackConfPopertiesFilePath = PropertiesUtility.getOpenstackConfPropertiesFilePath() keystoneConfDir = PropertiesUtility.getValue(openstackConfPopertiesFilePath, 'KEYSTONE_CONF_DIR') print 'keystoneConfDir=%s' % keystoneConfDir #/etc/keystone keystone_conf_file_path = os.path.join(keystoneConfDir, 'keystone.conf') if not os.path.exists(keystoneConfDir) : os.system("sudo mkdir -p %s" % keystoneConfDir) pass #if exist, remove original conf files if os.path.exists(keystone_conf_file_path) : os.system("sudo rm -rf %s" % keystone_conf_file_path) pass ShellCmdExecutor.execCmd('chmod 777 /etc/keystone') # os.system("sudo cp -r %s %s" % (SOURCE_KEYSTONE_CONF_FILE_TEMPLATE_PATH, keystoneConfDir)) ###NEW ShellCmdExecutor.execCmd('cat %s > /tmp/keystone.conf' % SOURCE_KEYSTONE_CONF_FILE_TEMPLATE_PATH) ShellCmdExecutor.execCmd('mv /tmp/keystone.conf /etc/keystone/') ShellCmdExecutor.execCmd("sudo chmod 777 %s" % keystone_conf_file_path) ###########LOCAL_IP:retrieve it from one file, the LOCAL_IP file is generated when this project inits. localIP = Keystone.getLocalIP() print 'localip=%s--' % localIP # FileUtil.replaceByRegularExpression(keystone_conf_file_path, '<LOCAL_IP>', localIP) # FileUtil.replaceByRegularExpression(keystone_conf_file_path, '<MYSQL_VIP>', mysql_vip) FileUtil.replaceFileContent(keystone_conf_file_path, '<LOCAL_IP>', localIP) FileUtil.replaceFileContent(keystone_conf_file_path, '<MYSQL_VIP>', mysql_vip) FileUtil.replaceFileContent(keystone_conf_file_path, '<MYSQL_PASSWORD>', mysql_password) ShellCmdExecutor.execCmd("sudo chmod 644 %s" % keystone_conf_file_path) print "configure keystone conf file done####" pass
def initKeystone(): keystoneInitScriptPath = os.path.join(OPENSTACK_CONF_FILE_TEMPLATE_DIR, 'keystone', 'keystone_init.sh') print 'keystoneInitScriptPath=%s' % keystoneInitScriptPath if os.path.exists('/opt/keystone_init.sh') : ShellCmdExecutor.execCmd('sudo rm -rf /opt/keystone_init.sh') pass ShellCmdExecutor.execCmd('cp -r %s /opt/' % keystoneInitScriptPath) localIP = Keystone.getLocalIP() FileUtil.replaceFileContent('/opt/keystone_init.sh', '<LOCAL_IP>', localIP) keystoneAdminEmail = JSONUtility.getValue("admin_email") print 'keystoneAdminEmail=%s' % keystoneAdminEmail FileUtil.replaceFileContent('/opt/keystone_init.sh', '<ADMIN_EMAIL>', keystoneAdminEmail) keystone_vip = JSONUtility.getValue("keystone_vip") FileUtil.replaceFileContent('/opt/keystone_init.sh', '<KEYSTONE_VIP>', keystone_vip) ShellCmdExecutor.execCmd('bash /opt/keystone_init.sh') pass
def configConfFile(): #use conf template file to replace <CONTROLLER_IP> ''' #modify nova.conf: [database] connection=mysql://nova:123456@controller/nova [DEFAULT] rpc_backend=rabbit rabbit_host=<CONTROLLER_IP> rabbit_password=123456 my_ip=<CONTROLLER_IP> vncserver_listen=<CONTROLLER_IP> vncserver_proxyclient_address=<CONTROLLER_IP> ######### # rpc_backend=rabbit rabbit_host=<CONTROLLER_IP> rabbit_password=123456 my_ip=<CONTROLLER_IP> vncserver_listen=<CONTROLLER_IP> vncserver_proxyclient_address=<CONTROLLER_IP> 5).modify nova.conf: set the auth info of keystone: [DEFAULT] auth_strategy=keystone [keystone_authtoken] auth_uri=http://controller:5000 auth_host=<CONTROLLER_IP> auth_protocal=http auth_port=35357 admin_tenant_name=service admin_user=nova admin_password=123456 ''' mysql_vip = JSONUtility.getValue("mysql_vip") mysql_password = JSONUtility.getValue("mysql_password") nova_mysql_password = JSONUtility.getValue("nova_mysql_password") # rabbit_host = JSONUtility.getValue("rabbit_host") # rabbit_vip = JSONUtility.getValue("rabbit_vip") rabbit_hosts = JSONUtility.getValue("rabbit_hosts") rabbit_userid = JSONUtility.getValue("rabbit_userid") rabbit_password = JSONUtility.getValue("rabbit_password") glance_vip = JSONUtility.getValue("glance_vip") keystone_vip = JSONUtility.getValue("keystone_vip") nova_vip = JSONUtility.getValue("nova_vip") virt_type = JSONUtility.getValue("virt_type") output, exitcode = ShellCmdExecutor.execCmd('cat /opt/localip') localIP = output.strip() print 'nova compute configuration=========' print 'mysql_vip=%s' % mysql_vip print 'mysql_password=%s' % mysql_password print 'rabbit_hosts=%s' % rabbit_hosts print 'rabbit_userid=%s' % rabbit_userid print 'rabbit_password=%s' % rabbit_password print 'keystone_vip=%s' % keystone_vip print 'nova_vip=%s' % nova_vip print 'locaIP=%s' % localIP openstackConfPopertiesFilePath = PropertiesUtility.getOpenstackConfPropertiesFilePath() nova_api_conf_template_file_path = os.path.join(OPENSTACK_CONF_FILE_TEMPLATE_DIR, 'nova-compute', 'nova.conf') print 'nova_api_conf_template_file_path=%s' % nova_api_conf_template_file_path novaConfDir = PropertiesUtility.getValue(openstackConfPopertiesFilePath, 'NOVA_CONF_DIR') print 'novaConfDir=%s' % novaConfDir #/etc/nova nova_conf_file_path = os.path.join(novaConfDir, 'nova.conf') print 'nova_conf_file_path=%s' % nova_conf_file_path if not os.path.exists(novaConfDir) : ShellCmdExecutor.execCmd("sudo mkdir %s" % novaConfDir) pass ShellCmdExecutor.execCmd("sudo chmod 777 %s" % novaConfDir) if os.path.exists(nova_conf_file_path) : ShellCmdExecutor.execCmd("sudo rm -rf %s" % nova_conf_file_path) pass # ShellCmdExecutor.execCmd('sudo cp -r %s %s' % (nova_api_conf_template_file_path, novaConfDir)) ShellCmdExecutor.execCmd("cat %s > /tmp/nova.conf" % nova_api_conf_template_file_path) ShellCmdExecutor.execCmd("mv /tmp/nova.conf /etc/nova/") ShellCmdExecutor.execCmd("sudo chmod 777 %s" % nova_conf_file_path) FileUtil.replaceFileContent(nova_conf_file_path, '<MYSQL_VIP>', mysql_vip) FileUtil.replaceFileContent(nova_conf_file_path, '<MYSQL_PASSWORD>', mysql_password) FileUtil.replaceFileContent(nova_conf_file_path, '<NOVA_MYSQL_PASSWORD>', nova_mysql_password) # FileUtil.replaceFileContent(nova_conf_file_path, '<RABBIT_HOST>', rabbit_vip) FileUtil.replaceFileContent(nova_conf_file_path, '<RABBIT_HOSTS>', rabbit_hosts) FileUtil.replaceFileContent(nova_conf_file_path, '<RABBIT_USERID>', rabbit_userid) FileUtil.replaceFileContent(nova_conf_file_path, '<RABBIT_PASSWORD>', rabbit_password) FileUtil.replaceFileContent(nova_conf_file_path, '<KEYSTONE_VIP>', keystone_vip) FileUtil.replaceFileContent(nova_conf_file_path, '<GLANCE_VIP>', glance_vip) FileUtil.replaceFileContent(nova_conf_file_path, '<VIRT_TYPE>', virt_type) FileUtil.replaceFileContent(nova_conf_file_path, '<LOCAL_IP>', localIP) FileUtil.replaceFileContent(nova_conf_file_path, '<NOVA_VIP>', nova_vip) ShellCmdExecutor.execCmd("sudo chmod 644 %s" % nova_conf_file_path) #configure libvirtd.conf libvirtd_conf_template_file_path = os.path.join(OPENSTACK_CONF_FILE_TEMPLATE_DIR, 'nova-compute', 'libvirtd.conf') libvirtd_conf_file_path = '/etc/libvirt/libvirtd.conf' print "libvirtd_conf_template_file_path=%s--" % libvirtd_conf_template_file_path if os.path.exists(libvirtd_conf_file_path) : ShellCmdExecutor.execCmd("rm -rf %s" % libvirtd_conf_file_path) pass ShellCmdExecutor.execCmd('cat %s > /tmp/libvirtd.conf' % libvirtd_conf_template_file_path) ShellCmdExecutor.execCmd('mv /tmp/libvirtd.conf /etc/libvirt/') #special handling PYTHON_SITE_PACKAGE_DIR = '/usr/lib/python2.6/site-packages' if os.path.exists(PYTHON_SITE_PACKAGE_DIR) : ShellCmdExecutor.execCmd('chmod 777 %s' % PYTHON_SITE_PACKAGE_DIR) pass LIB_NOVA_DIR = '/var/lib/nova' if os.path.exists(LIB_NOVA_DIR) : ShellCmdExecutor.execCmd('chown -R nova:nova %s' % LIB_NOVA_DIR) pass pass
TAG_FILE = '/opt/configureNovaAfterMetadata' if os.path.exists(TAG_FILE) : print 'When configure metadata-agent on neutron-agent, nova configured####' print 'exit====' pass else : print 'When configure metadata-agent on neutron-agent, start to configure nova-api=========' neutron_vip = JSONUtility.getValue("neutron_vip") keystone_vip = JSONUtility.getValue("keystone_vip") metadata_secret = JSONUtility.getValue("metadata_secret") #MetadataConfiguration metadata_configuration = ''' service_metadata_proxy = True metadata_proxy_shared_secret = <METADATA_SECRET> ''' metadata_configuration = metadata_configuration.strip() metadata_configuration = metadata_configuration.replace('<METADATA_SECRET>', metadata_secret) NOVA_API_CONF_FILE_PATH = '/etc/nova/nova.conf' FileUtil.replaceFileContent(NOVA_API_CONF_FILE_PATH, '#MetadataConfiguration', metadata_configuration) ShellCmdExecutor.execCmd('service openstack-nova-api restart') os.system('touch %s' % TAG_FILE) pass print 'Nova is configured after metadata configured#######' pass