Ejemplo n.º 1
0
def do_node_set_provision_state(cc, args):
    """Initiate a provisioning state change for a node."""
    if args.config_drive and args.provision_state != 'active':
        raise exceptions.CommandError(_('--config-drive is only valid when '
                                        'setting provision state to "active"'))
    elif args.clean_steps and args.provision_state != 'clean':
        raise exceptions.CommandError(_('--clean-steps is only valid when '
                                        'setting provision state to "clean"'))
    elif args.provision_state == 'clean' and not args.clean_steps:
        raise exceptions.CommandError(_('--clean-steps must be specified when '
                                        'setting provision state to "clean"'))

    if args.wait_timeout is not None:
        wait_args = v1_utils.PROVISION_ACTIONS.get(args.provision_state)
        if wait_args is None:
            raise exceptions.CommandError(
                _("--wait is not supported for provision state '%s'")
                % args.provision_state)

    clean_steps = args.clean_steps
    if args.clean_steps == '-':
        clean_steps = utils.get_from_stdin('clean steps')
    if clean_steps:
        clean_steps = utils.handle_json_or_file_arg(clean_steps)
    cc.node.set_provision_state(args.node, args.provision_state,
                                configdrive=args.config_drive,
                                cleansteps=clean_steps)
    if args.wait_timeout is not None:
        print(_('Waiting for provision state %(state)s on node %(node)s') %
              {'state': wait_args['expected_state'], 'node': args.node})
        cc.node.wait_for_provision_state(args.node, timeout=args.wait_timeout,
                                         **wait_args)
Ejemplo n.º 2
0
def do_node_set_provision_state(cc, args):
    """Initiate a provisioning state change for a node."""
    if args.config_drive and args.provision_state != 'active':
        raise exceptions.CommandError(
            _('--config-drive is only valid when '
              'setting provision state to "active"'))
    cc.node.set_provision_state(args.node,
                                args.provision_state,
                                configdrive=args.config_drive)
Ejemplo n.º 3
0
def do_node_set_maintenance(cc, args):
    """Enable or disable maintenance mode for a node."""
    maintenance_mode = utils.bool_argument_value("<maintenance-mode>",
                                                 args.maintenance_mode)
    if args.reason and not maintenance_mode:
        raise exceptions.CommandError(_('Cannot set "reason" when turning off '
                                        'maintenance mode.'))
    cc.node.set_maintenance(args.node, maintenance_mode,
                            maint_reason=args.reason)
Ejemplo n.º 4
0
def do_node_set_provision_state(cc, args):
    """Initiate a provisioning state change for a node."""
    if args.config_drive and args.provision_state != 'active':
        raise exceptions.CommandError(_('--config-drive is only valid when '
                                        'setting provision state to "active"'))
    elif args.clean_steps and args.provision_state != 'clean':
        raise exceptions.CommandError(_('--clean-steps is only valid when '
                                        'setting provision state to "clean"'))
    elif args.provision_state == 'clean' and not args.clean_steps:
        raise exceptions.CommandError(_('--clean-steps must be specified when '
                                        'setting provision state to "clean"'))

    clean_steps = args.clean_steps
    if args.clean_steps == '-':
        clean_steps = utils.get_from_stdin('clean steps')
    if clean_steps:
        clean_steps = utils.handle_json_or_file_arg(clean_steps)
    cc.node.set_provision_state(args.node, args.provision_state,
                                configdrive=args.config_drive,
                                cleansteps=clean_steps)