Example #1
0
 def execute(command, service=None, container=None):
     if command == 'list':
         if container is not None and service is None:
             container = ARContainerManager.get_container_name(container)
             print ARServiceManager(container).list()
         else:
             print ARContainerManager().list()
     elif command == 'status':
         if container is not None and service is None:
             print ARContainerManager().status(container)
         elif container is not None and service is not None:
             print ARServiceManager(container).status(service)
     elif command == 'start':
         if container is not None and service is None:
             print ARContainerManager().start(container)
         elif container is not None and service is not None:
             print ARServiceManager(container).start(service)
     elif command == 'stop':
         if container is not None and service is None:
             print ARContainerManager().stop(container)
         elif container is not None and service is not None:
             print ARServiceManager(container).stop(service)
     elif command == 'restart':
         if container is not None and service is None:
             print ARContainerManager().restart(container)
         elif container is not None and service is not None:
             print ARServiceManager(container).restart(service)
     elif command == 'stats':
         if container is not None and service is None:
             print ARContainerManager().stats(container)
         elif container is not None and service is not None:
             print ARServiceManager(container).stats(service)
     elif command == 'version':
         print ARVersionManager().get_all_version()
Example #2
0
    def get(self):
        self.set_header('Access-Control-Allow-Origin', '*')

        try:
            container = ARContainerManager.get_container_name(self.
                                                              get_argument_value('container'))
            containers_names = ARContainerManager.get_all_containers_names()

            if container in containers_names:
                ar_service_manager = ARServiceManager(container)
                results = ar_service_manager.list()
                import json
                self.write(json.dumps(results))
            else:
                raise ARContainerException(ContainerStatusPool.ID_CONTAINER_DOES_NOT_EXIST)
        except Exception as e:
            self.set_status(202)
            raise e
Example #3
0
    def validate_container_and_service(*args):
        args_num = len(args)
        if args_num == 1:
            container = args[0]
            if container in CONTAINERS_NAMES or (CONTAINERS_IDS and container
                                                 in CONTAINERS_IDS):
                return True
        elif args_num == 2:
            container = args[0]
            service = args[1]
            if container in CONTAINERS_NAMES:
                if service in CONTAINER_CONFIG[container]['services']:
                    return True
            elif CONTAINERS_IDS and container in CONTAINERS_IDS:
                container_name = ARContainerManager.get_container_name(
                    container)
                if service in CONTAINER_CONFIG[container_name]['services']:
                    return True

        return False