Esempio n. 1
0
 def __call__(self, prefix, parsed_args, **kwargs):
     with DirectNode(parsed_args) as node:
         controllers = list_controllers(
             node, parsed_args.controller_manager).controller
         return [
             c.name for c in controllers if c.state in self.valid_states
         ]
Esempio n. 2
0
    def main(self, *, args):
        with NodeStrategy(args) as node:
            controllers = list_controllers(node,
                                           args.controller_manager).controller
            for c in controllers:
                print(f'{c.name:20s}[{c.type:20s}] {c.state:10s}')

            return 0
Esempio n. 3
0
 def main(self, *, args):
     with NodeStrategy(args) as node:
         controllers = list_controllers(node,
                                        args.controller_manager).controller
         for c in controllers:
             print('{:20s}{:20s} {:10s}'.format(c.name, '[' + c.type + ']',
                                                c.state))
         return 0
    def main(self, *, args):
        with NodeStrategy(args) as node:
            controllers = list_controllers(node, args.controller_manager).controller

            try:
                matched_controller = [c for c in controllers if c.name == args.controller_name][0]
            except IndexError:
                return 'controller {} does not seem to be loaded'.format(args.controller_name)

            if args.state == 'configure':
                if matched_controller.state != 'unconfigured':
                    return "can't configure {} from its current state {}{}".format(
                            matched_controller.name, matched_controller.state)

                response = configure_controller(
                    node, args.controller_manager, args.controller_name)
                if not response.ok:
                    return 'Error configuring controller, check controller_manager logs'
                return 'successfully configured {}'.format(args.controller_name)

            if args.state == 'start':
                if matched_controller.state != 'inactive':
                    return "can't start {} from its current state {}".format(
                            matched_controller.name, matched_controller.state)
                response = switch_controllers(
                    node,
                    args.controller_manager,
                    [],
                    [args.controller_name],
                    True,
                    True,
                    5.0)
                if not response.ok:
                    return 'Error starting controller, check controller_manager logs'
                return 'successfully started {}'.format(args.controller_name)

            if args.state == 'stop':
                if matched_controller.state != 'active':
                    return "can't stop {} from its current state {}".format(
                            matched_controller.name, matched_controller.state)
                response = switch_controllers(
                    node,
                    args.controller_manager,
                    [args.controller_name],
                    [],
                    True,
                    True,
                    5.0)
                if not response.ok:
                    return 'Error stopping controller, check controller_manager logs'
                return 'successfully stopped {}'.format(args.controller_name)
Esempio n. 5
0
    def main(self, *, args):
        with NodeStrategy(args) as node:
            controllers = list_controllers(node,
                                           args.controller_manager).controller
            for c in controllers:
                print(f'{c.name:20s}[{c.type:20s}] {c.state:10s}')
                if args.claimed_interfaces or args.verbose:
                    print('\tclaimed interfaces:')
                    for claimed_interface in c.claimed_interfaces:
                        print(f'\t\t{claimed_interface}')
                if args.required_command_interfaces or args.verbose:
                    print('\trequired command interfaces:')
                    for required_command_interface in c.required_command_interfaces:
                        print(f'\t\t{required_command_interface}')
                if args.required_state_interfaces or args.verbose:
                    print('\trequired state interfaces:')
                    for required_state_interface in c.required_state_interfaces:
                        print(f'\t\t{required_state_interface}')

            return 0
Esempio n. 6
0
def is_controller_loaded(node, controller_manager, controller_name):
    controllers = list_controllers(node, controller_manager).controller
    return any(c.name == controller_name for c in controllers)