Пример #1
0
 def unload_app(node):
     body = {
         "operationList": [{
             "op": "replace",
             "path": "/status",
             "value": "unloaded"
         }]
     }
     response = monitors.update_node_properties(self.connection,
                                                node,
                                                self.id,
                                                body,
                                                whitelist=[('ERR001',
                                                            500)])
     if response.status_code == 202:
         tmp = helper.filter_list_of_dicts(self.nodes, name=node)
         tmp[0]['projects'] = [response.json()['project']]
         super(Entity, self).__setattr__('nodes', tmp)
         if tmp[0]['projects'][0]['status'] != 'unloaded':
             self.fetch('nodes')
         if config.verbose:
             print("'{}' unloaded on node '{}'.".format(
                 self.name, node))
     if response.status_code == 500 and config.verbose:  # handle whitelisted
         print("'{}' already unloaded on node '{}'.".format(
             self.name, node))
Пример #2
0
 def load_project(node):
     body = {
         "operationList": [{
             "op": "replace",
             "path": self._STATUS_PATH,
             "value": "loaded"
         }]
     }
     response = monitors.update_node_properties(self.connection, node, self.id, body)
     if response.status_code == 202:
         tmp = helper.filter_list_of_dicts(self.nodes, name=node)
         tmp[0]['projects'] = [response.json()['project']]
         self._nodes = tmp
         if tmp[0]['projects'][0]['status'] != 'loaded':
             self.fetch('nodes')
         if config.verbose:
             logger.info(f"Project '{self.id}' loaded on node '{node}'.")
Пример #3
0
 def load_app(node):
     body = {
         "operationList": [{
             "op": "replace",
             "path": "/status",
             "value": "loaded"
         }]
     }
     response = monitors.update_node_properties(self.connection, node,
                                                self.id, body)
     if response.status_code == 202:
         tmp = helper.filter_list_of_dicts(self.nodes, name=node)
         tmp[0]['projects'] = [response.json()['project']]
         self._nodes = tmp
         if tmp[0]['projects'][0]['status'] != 'loaded':
             self.fetch('nodes')
         if config.verbose:
             print("Application '{}' loaded on node '{}'.".format(
                 self.id, node))
Пример #4
0
 def unload_project(node):
     body = {
         "operationList": [{
             "op": "replace",
             "path": self._STATUS_PATH,
             "value": "unloaded"
         }]
     }
     response = monitors.update_node_properties(self.connection, node, self.id, body,
                                                whitelist=[('ERR001', 500)])
     if response.status_code == 202:
         tmp = helper.filter_list_of_dicts(self.nodes, name=node)
         tmp[0]['projects'] = [response.json()['project']]
         self._nodes = tmp
         if tmp[0]['projects'][0]['status'] != 'unloaded':
             self.fetch('nodes')
         if config.verbose:
             logger.info(f"Project '{self.id}' unloaded on node '{node}'.")
     if response.status_code == 500 and config.verbose:  # handle whitelisted
         logger.warning(f"Project '{self.id}' already unloaded on node '{node}'.")
Пример #5
0
 def idle_app(node, mode):
     formatted_mode = Application._IDLE_MODE_DICT.get(mode)
     body = {
         "operationList": [{
             "op": "replace",
             "path": "/status",
             "value": formatted_mode
         }]
     }
     response = monitors.update_node_properties(self.connection, node,
                                                self.id, body)
     if response.status_code == 202:
         tmp = helper.filter_list_of_dicts(self.nodes, name=node)
         tmp[0]['projects'] = [response.json()['project']]
         super(Entity, self).__setattr__('nodes', tmp)
         if tmp[0]['projects'][0]['status'] != formatted_mode:
             self.fetch('nodes')
         if config.verbose:
             print("'{}' changed status to '{}' on node '{}'.".format(
                 self.name, mode, node))