def apply(): iptable4ComputeTemplatePath = os.path.join(OPENSTACK_CONF_FILE_TEMPLATE_DIR, 'iptables', 'iptables.compute') iptable4ControllerTemplatePath = os.path.join(OPENSTACK_CONF_FILE_TEMPLATE_DIR, 'iptables', 'iptables.controller') if Role.isNovaComputeRole() : ShellCmdExecutor.execCmd('rm -rf /etc/sysconfig/iptables') ShellCmdExecutor.execCmd('cp -r %s /etc/sysconfig' % iptable4ComputeTemplatePath) ShellCmdExecutor.execCmd('mv /etc/sysconfig/iptables.compute /etc/sysconfig/iptables') pass else : ShellCmdExecutor.execCmd('rm -rf /etc/sysconfig/iptables') ShellCmdExecutor.execCmd('cp -r %s /etc/sysconfig' % iptable4ControllerTemplatePath) ShellCmdExecutor.execCmd('mv /etc/sysconfig/iptables.controller /etc/sysconfig/iptables') pass ShellCmdExecutor.execCmd('/bin/systemctl restart iptables.service') pass
ShellCmdExecutor.execCmd('cp -r %s /opt/' % import_image_script_path) ShellCmdExecutor.execCmd('chmod 777 /opt/import_image.sh') ShellCmdExecutor.execCmd('cp -r %s /opt/' % get_image_id_script_path) ShellCmdExecutor.execCmd('chmod 777 /opt/getDefaultImageID.sh') ShellCmdExecutor.execCmd('cp -r %s /opt/' % get_image_size_script_path) ShellCmdExecutor.execCmd('chmod 777 /opt/getDefaultImageFileSize.sh') FileUtil.replaceFileContent('/opt/import_image.sh', '<KEYSTONE_VIP>', keystone_vip) FileUtil.replaceFileContent('/opt/getDefaultImageID.sh', '<KEYSTONE_VIP>', keystone_vip) FileUtil.replaceFileContent('/opt/getDefaultImageFileSize.sh', '<KEYSTONE_VIP>', keystone_vip) time.sleep(1) from openstack.common.role import Role if Role.isGlanceRole() and GlanceHA.isMasterNode(): # if GlanceHA.isMasterNode() : imported_tag = False retry = 1 while retry > 0 : ShellCmdExecutor.execCmd('bash /opt/import_image.sh') imageFileSize, exitcode = ShellCmdExecutor.execCmd('bash /opt/getDefaultImageFileSize.sh') imageID, exitcode = ShellCmdExecutor.execCmd('bash /opt/getDefaultImageID.sh') importedImageSizeCmd = "ls -lt /etc/puppet/modules/glance/files/ | grep cirros | awk '{print $5}'" importedImageSize, exitcode = ShellCmdExecutor.execCmd(importedImageSizeCmd) imageID = imageID.strip() imageFileSize = imageFileSize.strip() importedImageSize = importedImageSize.strip() if imageFileSize == importedImageSize : imported_tag = True
OPENSTACK_VERSION_TAG = 'kilo' OPENSTACK_CONF_FILE_TEMPLATE_DIR = os.path.join(PROJ_HOME_DIR, 'openstack', OPENSTACK_VERSION_TAG, 'configfile_template') SOURCE_NOVA_API_CONF_FILE_TEMPLATE_PATH = os.path.join(OPENSTACK_CONF_FILE_TEMPLATE_DIR,'nova', 'nova.conf') sys.path.append(PROJ_HOME_DIR) from common.shell.ShellCmdExecutor import ShellCmdExecutor from openstack.common.role import Role if __name__ == '__main__': print 'hello openstack-icehouse:init ostf============' print 'start time: %s' % time.ctime() #when execute script,exec: python <this file absolute path> ############################### if Role.isGlanceRole() : IMAGE_INSTALL_TAG_FILE = '/opt/initOSTFGlancePrivilege' if os.path.exists(IMAGE_INSTALL_TAG_FILE) : print 'ostf glance image privilege initted####' print 'exit====' pass else : # listImageFileCmd = 'ls /var/lib/glance/images/' # output, exitcode = ShellCmdExecutor.execCmd(listImageFileCmd) # output, exitcode = ShellCmdExecutor.execCmd('bash /opt/getDefaultImageID.sh') # imageFileName = output.strip() # imageFilePath = os.path.join('/var/lib/glance/images', imageFileName) time.sleep(5) imageFileDir = '/var/lib/glance/images/' output, exitcode = ShellCmdExecutor.execCmd('chown -R glance:glance %s' % imageFileDir)
time.sleep(5) child.sendline('exit') child.sendcontrol('c') child.interact() except OSError: print 'Catch exception %s when sync glance image.' % OSError.strerror sys.exit(0) pass pass if __name__ == '__main__': print 'hello openstack-icehouse:init ostf============' print 'start time: %s' % time.ctime() #when execute script,exec: python <this file absolute path> ############################### if Role.isNeutronServerRole() : NETWORK_INSTALL_TAG_FILE = '/opt/initOSTFNetwork' if os.path.exists(NETWORK_INSTALL_TAG_FILE) : print 'ostf network initted####' print 'exit====' pass else : if NeutronServerHA.isMasterNode() : network_init_script_path = os.path.join(OPENSTACK_CONF_FILE_TEMPLATE_DIR, 'neutron-server', 'ostf_network_init.sh') ShellCmdExecutor.execCmd('cp -r %s /opt/' % network_init_script_path) ############ keystone_vip = JSONUtility.getValue('keystone_vip') ShellCmdExecutor.execCmd('chmod 777 /opt/ostf_network_init.sh') FileUtil.replaceFileContent('/opt/ostf_network_init.sh', '<KEYSTONE_VIP>', keystone_vip)
PROJ_HOME_DIR, "openstack", OPENSTACK_VERSION_TAG, "configfile_template" ) SOURCE_NOVA_API_CONF_FILE_TEMPLATE_PATH = os.path.join(OPENSTACK_CONF_FILE_TEMPLATE_DIR, "nova", "nova.conf") sys.path.append(PROJ_HOME_DIR) from common.shell.ShellCmdExecutor import ShellCmdExecutor from openstack.common.role import Role if __name__ == "__main__": print "hello openstack-icehouse:init rabbitmq============" print "start time: %s" % time.ctime() # when execute script,exec: python <this file absolute path> ############################### if Role.isRabbitMQRole(): INSTALL_TAG_FILE = "/opt/initRabbitmq" if os.path.exists(INSTALL_TAG_FILE): print "rabbitmq initted####" print "exit====" pass else: ShellCmdExecutor.execCmd("bash /tmp/killrabbitmq.sh") # mark: rabbitmq is installed os.system("touch %s" % INSTALL_TAG_FILE) pass pass print "hello rabbitmq initted#######" pass