def deploy(): ret_code = 0 # noinspection PyBroadException try: logger.debug("=================================") logger.info("=== Starting up ...") logger.debug("=================================") parser = argparse.ArgumentParser( description='JetPack 10.x deployer') parser.add_argument('-s', '--settings', help='ini settings file, e.g settings/acme.ini', required=True) parser.add_argument('-undercloud_only', '--undercloud_only', help='Only reinstall the undercloud', action='store_true', required=False) parser.add_argument('-overcloud_only', '--overcloud_only', help='Only reinstall the overcloud', action='store_true', required=False) parser.add_argument('-skip_dashboard_vm', '--skip_dashboard_vm', help='Do not reinstall the Dashboard VM', action='store_true', required=False) parser.add_argument('-validate_only', '--validate_only', help='No deployment - just validate config values', action='store_true', required=False) args, others = parser.parse_known_args() if len(others) > 0: parser.print_help() msg = "Invalid argument(s) :" for each in others: msg += " " + each + ";" raise AssertionError(msg) if args.validate_only is True: logger.info("Only validating ini/properties config values") else: if args.overcloud_only is True: logger.info("Only redeploying the overcloud") if args.skip_dashboard_vm is True: logger.info("Skipping Dashboard VM install") logger.debug("loading settings files " + args.settings) settings = Settings(args.settings) logger.info("Settings .ini: " + settings.settings_file) logger.info("Settings .properties " + settings.network_conf) settings.get_version_info() logger.info("source version # : " + settings.source_version) tester = Checkpoints() tester.verify_deployer_settings() if args.validate_only is True: logger.info("Settings validated") os._exit(0) if settings.retreive_switches_config is True: tester.retreive_switches_config() non_sah_nodes = (settings.controller_nodes + settings.compute_nodes + settings.ceph_nodes) sah_node = Sah() tester.sah_health_check() logger.info("Uploading configs/iso/scripts..") sah_node.clear_known_hosts() sah_node.handle_lock_files() sah_node.upload_iso() sah_node.upload_director_scripts() director_ip = settings.director_node.public_api_ip if args.overcloud_only is False: Ssh.execute_command(director_ip, "root", settings.director_node.root_password, "subscription-manager remove --all") Ssh.execute_command(director_ip, "root", settings.director_node.root_password, "subscription-manager unregister") sah_node.delete_director_vm() logger.info("=== create the director vm") sah_node.create_director_vm() tester.director_vm_health_check() logger.info("Preparing the Director VM") director_vm = Director() director_vm.apply_internal_repos() logger.debug( "=== Uploading & configuring undercloud.conf . " "environment yaml ===") director_vm.upload_update_conf_files() logger.info("=== installing the director & undercloud ===") director_vm.inject_ssh_key() director_vm.upload_cloud_images() director_vm.install_director() tester.verify_undercloud_installed() if args.undercloud_only: return else: logger.info("=== Skipped Director VM/Undercloud install") director_vm = Director() logger.debug("Deleting overcloud stack") director_vm.delete_overcloud() if args.skip_dashboard_vm is False: logger.debug("Delete the Dashboard VM") dashboard_ip = settings.dashboard_node.public_api_ip logger.debug( Ssh.execute_command(dashboard_ip, "root", settings.dashboard_node.root_password, "subscription-manager remove --all")) Ssh.execute_command(dashboard_ip, "root", settings.dashboard_node.root_password, "subscription-manager unregister") sah_node.delete_dashboard_vm() logger.info("=== creating Dashboard VM") sah_node.create_dashboard_vm() tester.dashboard_vm_health_check() else: logger.info("Skipped the Dashboard VM install") logger.info("=== Preparing the overcloud ===") # The network-environment.yaml must be setup for use during DHCP # server configuration director_vm.setup_net_envt() director_vm.configure_dhcp_server() director_vm.node_discovery() director_vm.configure_idracs() director_vm.import_nodes() director_vm.node_introspection() director_vm.update_sshd_conf() director_vm.assign_node_roles() director_vm.revert_sshd_conf director_vm.setup_templates() logger.info("=== Installing the overcloud ") logger.debug("installing the overcloud ... this might take a while") director_vm.deploy_overcloud() cmd = "source ~/stackrc; openstack stack list | grep " \ + settings.overcloud_name + " | awk '{print $6}'" overcloud_status = \ Ssh.execute_command_tty(director_ip, settings.director_install_account_user, settings.director_install_account_pwd, cmd)[0] logger.debug("=== Overcloud stack state : " + overcloud_status) if settings.hpg_enable: logger.info( " HugePages has been successfully configured with size: " + settings.hpg_size) if settings.numa_enable: logger.info( " NUMA has been successfully configured" " with hostos_cpus count: " + settings.hostos_cpu_count) logger.info("====================================") logger.info(" OverCloud deployment status: " + overcloud_status) logger.info(" log : /auto_results/ ") logger.info("====================================") if "CREATE_COMPLETE" not in overcloud_status: raise AssertionError( "OverCloud did not install properly : " + overcloud_status) director_vm.summarize_deployment() tester.verify_computes_virtualization_enabled() tester.verify_backends_connectivity() if args.skip_dashboard_vm is False: director_vm.configure_dashboard() director_vm.enable_fencing() director_vm.enable_instance_ha() director_vm.configure_tempest() director_vm.run_sanity_test() run_tempest() logger.info("Deployment summary info; useful ip's etc.. " + "/auto_results/deployment_summary.log") except: logger.error(traceback.format_exc()) e = sys.exc_info()[0] logger.error(e) print e print traceback.format_exc() ret_code = 1 logger.info("log : /auto_results/ ") sys.exit(ret_code)
def deploy(): ret_code = 0 # noinspection PyBroadException logger.debug("=================================") logger.info("=== Starting up ...") logger.debug("=================================") try: settings, args = get_settings() if args.validate_only is True: logger.info("Only validating ini/properties config values") else: if args.overcloud_only is True: logger.info("Only redeploying the overcloud") if args.skip_dashboard_vm is True: logger.info("Skipping Dashboard VM install") logger.info("Settings .ini: " + settings.settings_file) logger.info("Settings .properties " + settings.network_conf) settings.get_version_info() logger.info("source version # : " + settings.source_version) tester = Checkpoints() tester.verify_deployer_settings() if args.validate_only is True: logger.info("Settings validated") os._exit(0) tester.retreive_switches_config() non_sah_nodes = (settings.controller_nodes + settings.compute_nodes + settings.ceph_nodes) sah_node = Sah() tester.sah_health_check() # mutually exclusive command, configure tempest and quit. if args.tempest_config_only: logger.info("Only (re-)generating tempest.conf") director_vm = Director() director_vm.configure_tempest() os._exit(0) # mutually exclusive command, run tempest and quit. if args.run_tempest_only: logger.info("Only running tempest, will configure " + "tempest.conf if needed.") director_vm = Director() director_vm.run_tempest() os._exit(0) logger.info("Uploading configs/iso/scripts.") sah_node.clear_known_hosts() sah_node.handle_lock_files() sah_node.upload_iso() sah_node.upload_director_scripts() director_ip = settings.director_node.public_api_ip if args.overcloud_only is False: Ssh.execute_command(director_ip, "root", settings.director_node.root_password, "subscription-manager remove --all") Ssh.execute_command(director_ip, "root", settings.director_node.root_password, "subscription-manager unregister") sah_node.delete_director_vm() logger.info("=== create the director vm") sah_node.create_director_vm() tester.director_vm_health_check() logger.info("Preparing the Director VM") director_vm = Director() director_vm.apply_internal_repos() logger.debug("=== Uploading & configuring undercloud.conf . " "environment yaml ===") director_vm.upload_update_conf_files() logger.info("=== installing the director & undercloud ===") director_vm.inject_ssh_key() director_vm.upload_cloud_images() director_vm.install_director() tester.verify_undercloud_installed() if args.undercloud_only: return else: logger.info("=== Skipped Director VM/Undercloud install") director_vm = Director() logger.debug("Deleting overcloud stack") director_vm.delete_overcloud() if args.skip_dashboard_vm is False: logger.debug("Delete the Dashboard VM") dashboard_ip = settings.dashboard_node.public_api_ip logger.debug( Ssh.execute_command(dashboard_ip, "root", settings.dashboard_node.root_password, "subscription-manager remove --all")) Ssh.execute_command(dashboard_ip, "root", settings.dashboard_node.root_password, "subscription-manager unregister") sah_node.delete_dashboard_vm() logger.info("=== creating Dashboard VM") sah_node.create_dashboard_vm() tester.dashboard_vm_health_check() else: logger.info("Skipped the Dashboard VM install") logger.info("=== Preparing the overcloud ===") # The network-environment.yaml must be setup for use during DHCP # server configuration director_vm.setup_net_envt() director_vm.configure_dhcp_server() director_vm.node_discovery() director_vm.configure_idracs() director_vm.import_nodes() director_vm.node_introspection() director_vm.update_sshd_conf() director_vm.assign_node_roles() director_vm.revert_sshd_conf() director_vm.setup_templates() logger.info("=== Installing the overcloud ") logger.debug("installing the overcloud ... this might take a while") director_vm.deploy_overcloud() cmd = "source ~/stackrc; openstack stack list | grep " \ + settings.overcloud_name + " | awk '{print $8}'" overcloud_status = \ Ssh.execute_command_tty(director_ip, settings.director_install_account_user, settings.director_install_account_pwd, cmd)[0] logger.debug("=== Overcloud stack state : " + overcloud_status) if settings.hpg_enable: logger.info( " HugePages has been successfully configured with size: " + settings.hpg_size) if settings.numa_enable: logger.info(" NUMA has been successfully configured" " with hostos_cpus count: " + settings.hostos_cpu_count) logger.info("====================================") logger.info(" OverCloud deployment status: " + overcloud_status) logger.info(" log : /auto_results/ ") logger.info("====================================") if "CREATE_COMPLETE" not in overcloud_status: raise AssertionError("OverCloud did not install properly : " + overcloud_status) director_vm.summarize_deployment() tester.verify_computes_virtualization_enabled() tester.verify_backends_connectivity() if args.skip_dashboard_vm is False: director_vm.configure_dashboard() director_vm.enable_fencing() director_vm.run_sanity_test() external_sub_guid = director_vm.get_sanity_subnet() if external_sub_guid: director_vm.configure_tempest() run_tempest() logger.info("Deployment summary info; useful ip's etc.. " + "/auto_results/deployment_summary.log") except: # noqa: E722 logger.error(traceback.format_exc()) e = sys.exc_info()[0] logger.error(e) print e print traceback.format_exc() ret_code = 1 logger.info("log : /auto_results/ ") sys.exit(ret_code)
def setup(): try: hdlr = logging.FileHandler('setup_usb_idrac.log') formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s') hdlr.setFormatter(formatter) logger.addHandler(hdlr) logger.setLevel(logging.DEBUG) out = logging.StreamHandler(sys.stdout) out.setLevel(logging.INFO) logger.addHandler(out) logger.info("* Creating the SAH node usb image.") parser = argparse.ArgumentParser(description='CHANGEME 10.x usb ' + ' image prep.') parser.add_argument('-s', '--settings', help='ini settings file, e.g settings/acme.ini', required=True) parser.add_argument('-usb_key', '--usb_key', help='Use a physical USB key - device to use ' + ' eg : -usb_key /dev/sdb', required=False) parser.add_argument('-idrac_vmedia_img', '--idrac_vmedia_img', help='Use an idrac virtual media image', action='store_true', required=False) args, ignore = parser.parse_known_args() if args.usb_key is None and args.idrac_vmedia_img is False: raise AssertionError("You need to spefify the type of" + " installation to perform \n" + "-usb_key devideID if using a " + "physical key\n" + "-idrac_vmedia_img if using " + "an idrac virtual media image") logger.debug("loading settings files " + args.settings) settings = Settings(args.settings) logger.info("Settings .ini: " + settings.settings_file) logger.info("Settings .properties " + settings.network_conf) # Check to verify RHEL ISO exists rhel_iso = settings.rhel_iso assert os.path.isfile(settings.rhel_iso), settings.rhel_iso +\ " ISO file is not present" sah = Sah() sah.update_kickstart_usb() # Create the usb Media & update path references target_ini = settings.settings_file.replace('/root', "/mnt/usb") iso_path = os.path.dirname(settings.rhel_iso) if args.idrac_vmedia_img is True: cmds = ['cd ~;rm -f osp_ks.img', 'cd ~;dd if=/dev/zero of=osp_ks.img bs=1M count=5000', 'cd ~;mkfs ext3 -F osp_ks.img', 'mkdir -p /mnt/usb', 'cd ~;mount -o loop osp_ks.img /mnt/usb', 'cd ~;cp -R ~/JetPack /mnt/usb', 'cd ~;cp ' + settings.rhel_iso + ' /mnt/usb', 'cd ~;cp ' + settings.settings_file + ' /mnt/usb', 'cd ~;cp ' + settings.network_conf + ' /mnt/usb', 'cd ~;cp osp-sah.ks /mnt/usb', "sed -i 's|" + iso_path + "|/root|' " + target_ini, 'sync; umount /mnt/usb'] else: cmds = ['mkfs.ext3 -F ' + args.usb_key, 'mkdir -p /mnt/usb', 'cd ~;mount -o loop ' + args.usb_key + ' /mnt/usb', 'cd ~;cp -R ~/JetPack /mnt/usb', 'cd ~;cp ' + settings.rhel_iso + ' /mnt/usb', 'cd ~;cp ' + settings.settings_file + ' /mnt/usb', 'cd ~;cp ' + settings.network_conf + ' /mnt/usb', 'cd ~;cp osp-sah.ks /mnt/usb', "sed -i 's|" + iso_path + "|/root|' " + target_ini, 'sync; umount /mnt/usb'] for cmd in cmds: logger.debug("running " + cmd) logger.debug(subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)) if args.idrac_vmedia_img: logger.info("All done - attach ~/osp_ks.img to the sah node" + " & continue with the deployment ...") else: logger.info("All done - plug the usb into the sah node" + " & continue with the deployment ...") except: logger.error(traceback.format_exc()) e = sys.exc_info()[0] logger.error(e) print e print traceback.format_exc()
def deploy(): ret_code = 0 # noinspection PyBroadException logger.debug("=================================") logger.info("=== Starting up ...") logger.debug("=================================") try: settings, args = get_settings() director_vm = Director() sah_node = Sah() if args.list_edge_sites: list_edge_sites(settings, director_vm) os._exit(0) is_deploy_edge_site = bool(args.edge_sites) or args.edge_sites_all logger.info("Deploying edge site(s) from CLI argument? %s", str(is_deploy_edge_site)) edge_sites = None # deploying edge site(s)?, validate sites are in settings, if # valid return a list of sites based on args. if is_deploy_edge_site: edge_sites = validate_edge_sites_in_settings(args, settings) logger.info("Edge sites after validation: {}".format(str(edge_sites))) if args.validate_only is True: logger.info("Only validating ini/properties config values") else: if args.overcloud_only is True: logger.info("Only redeploying the overcloud") logger.info("Settings .ini: " + settings.settings_file) logger.info("Settings .properties " + settings.network_conf) settings.get_version_info() logger.info("source version # : " + settings.source_version.decode('utf-8')) tester = Checkpoints() tester.verify_deployer_settings() if args.validate_only is True: logger.info("Settings validated") os._exit(0) tester.retreive_switches_config() tester.sah_health_check() # mutually exclusive command, configure tempest and quit. if args.tempest_config_only: logger.info("Only (re-)generating tempest.conf") director_vm.configure_tempest() os._exit(0) # mutually exclusive command, run tempest and quit. if args.run_tempest_only: logger.info("Only running tempest, will configure " + "tempest.conf if needed.") director_vm.run_tempest() os._exit(0) logger.info("Uploading configs/iso/scripts.") sah_node.clear_known_hosts() sah_node.handle_lock_files() sah_node.upload_iso() sah_node.upload_director_scripts() sah_node.upload_powerflexgw_scripts() sah_node.upload_powerflexmgmt_scripts() sah_node.enable_chrony_ports() if args.overcloud_only is False and is_deploy_edge_site is False: deploy_undercloud(settings, sah_node, tester, director_vm) if args.undercloud_only: return elif is_deploy_edge_site is False: logger.info("=== Skipped Director VM/Undercloud install") logger.debug("Deleting overcloud stack") director_vm.delete_overcloud() if is_deploy_edge_site: _is_oc_failed, _error_oc = tester.verify_overcloud_deployed() if _is_oc_failed: logger.error("Attempted to deploy edge site(s) but the " "overcloud has not been deployed, " "or failed to deploy. " "Edge sites cannot be deployed without an " "existing overcloud, exiting") os._exit(0) deploy_edge_sites(sah_node, director_vm, edge_sites) os._exit(0) else: # no edge sites arguments, just deploy overcloud deploy_overcloud(director_vm) _is_oc_failed, _err_oc = tester.verify_overcloud_deployed() if _is_oc_failed: raise _err_oc # lastly, if there are edge sites defined in .ini # and deploy_edge_sites is set to true in ini deploy the sites if settings.deploy_edge_sites and settings.edge_sites: logger.info( "Automatic edge site deployment is set to true " "in the ini (deploy_edge_sites==true), " "deploying all defined edge sites: %s", str(settings.edge_sites)) deploy_edge_sites(sah_node, director_vm, settings.edge_sites) if settings.hpg_enable: logger.info("HugePages has been successfully configured " "with size: " + settings.hpg_size) if settings.numa_enable: logger.info("NUMA has been successfully configured " "with hostos_cpus count: " + settings.hostos_cpu_count) director_vm.summarize_deployment() tester.verify_computes_virtualization_enabled() tester.verify_backends_connectivity() director_vm.enable_fencing() director_vm.run_sanity_test() external_sub_guid = director_vm.get_sanity_subnet() if external_sub_guid: director_vm.configure_tempest() run_tempest(director_vm) if len(settings.powerflex_nodes) > 0: powerflexgw_vm = Powerflexgw() deploy_powerflex_gw(settings, sah_node, tester, powerflexgw_vm) if settings.enable_powerflex_mgmt: powerflexmgmt_vm = Powerflexmgmt() deploy_powerflex_mgmt(settings, sah_node, tester, powerflexmgmt_vm) logger.info("Deployment summary info; useful ip's etc.. " + "/auto_results/deployment_summary.log") except: # noqa: E722 logger.error(traceback.format_exc()) e = sys.exc_info()[0] logger.error(e) print(e) print(traceback.format_exc()) ret_code = 1 logger.info("log : /auto_results/ ") sys.exit(ret_code)