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
############ 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) ########### ShellCmdExecutor.execCmd('bash /opt/ostf_network_init.sh') pass #mark: OSTF network is installed os.system('touch %s' % NETWORK_INSTALL_TAG_FILE) pass pass if Role.isGlanceRole() : #To sync image on glance hosts IMAGE_INSTALL_TAG_FILE = '/opt/initOSTFGlance' if os.path.exists(IMAGE_INSTALL_TAG_FILE) : print 'ostf glance image initted####' print 'exit====' pass else : if os.path.exists('/opt/existGlanceFileOnHost') : output, exitcode = ShellCmdExecutor.execCmd('bash /opt/getDefaultImageID.sh') imageID = output.strip() # listImageFileCmd = 'ls /var/lib/glance/images/ | grep %s' % imageID # output, exitcode = ShellCmdExecutor.execCmd(listImageFileCmd) # output = output.strip() imageFileName = imageID