def main(): parser = argparse.ArgumentParser() parser.add_argument("--power", required=True, default=None, choices=["on", "off", "reset", "cycle"], help="Control power state of all overcloud nodes") args = parser.parse_args() os_auth_url, os_tenant_name, os_username, os_password, \ os_user_domain_name, os_project_domain_name = \ CredentialHelper.get_undercloud_creds() kwargs = { 'os_username': os_username, 'os_password': os_password, 'os_auth_url': os_auth_url, 'os_tenant_name': os_tenant_name, 'os_user_domain_name': os_user_domain_name, 'os_project_domain_name': os_project_domain_name } ironic = client.get_client(1, **kwargs) for node in ironic.node.list(detail=True): ip, username, password = \ CredentialHelper.get_drac_creds_from_node(node) cmd = "ipmitool -H {} -I lanplus -U {} -P '{}' chassis power {}". \ format(ip, username, password, args.power) print cmd os.system(cmd)
def main(): args = parse_arguments() LoggingHelper.configure_logging(args.logging_level) ironic_client = IronicHelper.get_ironic_client() for node in ironic_client.node.list(detail=True): ip, username, password = \ CredentialHelper.get_drac_creds_from_node(node) # Power off the node cmd = "ipmitool -H {} -I lanplus -U {} -P '{}' chassis " \ "power off".format(ip, username, password) logger.info("Powering off {}".format(ip)) logger.debug(" {}".format(cmd)) os.system(cmd) # Set the first boot device to PXE cmd = "ipmitool -H {} -I lanplus -U {} -P '{}' chassis " \ "bootdev pxe options=persistent".format(ip, username, password) logger.info( "Setting the provisioning NIC to PXE boot on {}".format(ip)) logger.debug(" {}".format(cmd)) os.system(cmd) if not args.skip: os_auth_url, os_tenant_name, os_username, os_password = \ CredentialHelper.get_undercloud_creds() cmd = "openstack baremetal configure boot " \ "--os-auth-url {} " \ "--os-project-name {} " \ "--os-username {} " \ "--os-password {} " \ "".format(os_auth_url, os_tenant_name, os_username, os_password) logger.info("Assigning the kernel and ramdisk image to all nodes") logger.debug(cmd) os.system(cmd)