當前位置: 首頁>>代碼示例>>Python>>正文


Python Node.delete方法代碼示例

本文整理匯總了Python中chef.Node.delete方法的典型用法代碼示例。如果您正苦於以下問題:Python Node.delete方法的具體用法?Python Node.delete怎麽用?Python Node.delete使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在chef.Node的用法示例。


在下文中一共展示了Node.delete方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: handle

# 需要導入模塊: from chef import Node [as 別名]
# 或者: from chef.Node import delete [as 別名]
def handle(event, _context):
    """Lambda Handler"""
    log_event(event)

    with ChefAPI(CHEF_SERVER_URL, get_pem(), USERNAME):
        instance_id = get_instance_id(event)
        try:
            search = Search('node', 'ec2_instance_id:' + instance_id)
        except ChefServerNotFoundError as err:
            LOGGER.error(err)
            return False

        if len(search) != 0:
            for instance in search:
                node = Node(instance.object.name)
                client = Client(instance.object.name)
                try:
                    node.delete()
                    LOGGER.info('===Node Delete: SUCCESS===')
                    client.delete()
                    LOGGER.info('===Client Delete: SUCCESS===')
                    return True
                except ChefServerNotFoundError as err:
                    LOGGER.error(err)
                    return False
        else:
            LOGGER.info('=Instance does not appear to be Chef Server managed.=')
            return True
開發者ID:novu,項目名稱:lambda-chef-node-cleanup,代碼行數:30,代碼來源:main.py

示例2: destroy_node

# 需要導入模塊: from chef import Node [as 別名]
# 或者: from chef.Node import delete [as 別名]
 def destroy_node(self, node):
     """
     Destroys a node provisioned by razor
     :param node: Node to destroy
     :type node: ChefNode
     """
     cnode = Node(node.name, node.environment.local_api)
     in_use = node['in_use']
     if in_use == "provisioning" or in_use == 0:
         # Return to pool if the node is clean
         cnode['in_use'] = 0
         cnode['archive'] = {}
         cnode.chef_environment = "_default"
         cnode.save()
     else:
         # Remove active model if the node is dirty
         active_model = cnode['razor_metadata']['razor_active_model_uuid']
         try:
             if node.feature_in('controller'):
                 # rabbit can cause the node to not actually reboot
                 kill = ("for i in `ps -U rabbitmq | tail -n +2 | "
                         "awk '{print $1}' `; do kill -9 $i; done")
                 node.run_cmd(kill)
             node.run_cmd("shutdown -r now")
             self.api.remove_active_model(active_model)
             Client(node.name).delete()
             cnode.delete()
             sleep(15)
         except:
             util.logger.error("Node unreachable. "
                               "Manual restart required:{0}".
                               format(str(node)))
開發者ID:cjoelrun,項目名稱:monster,代碼行數:34,代碼來源:razor.py

示例3: computer_deleted

# 需要導入模塊: from chef import Node [as 別名]
# 或者: from chef.Node import delete [as 別名]
 def computer_deleted(self, user, obj, computers=None):
     node_chef_id = obj.get('node_chef_id', None)
     if node_chef_id:
         api = get_chef_api(self.app.conf, user)
         node = Node(node_chef_id, api)
         node.delete()
         client = Client(node_chef_id, api=api)
         client.delete()
     self.log_action('deleted', 'Computer', obj)
開發者ID:Emergya,項目名稱:gecoscc-ui,代碼行數:11,代碼來源:tasks.py

示例4: destroy_node

# 需要導入模塊: from chef import Node [as 別名]
# 或者: from chef.Node import delete [as 別名]
 def destroy_node(self, node):
     """
     Destroys chef node from openstack
     :param node: node to destroy
     :type node: ChefNode
     """
     cnode = Node(node.name, node.environment.local_api)
     if cnode.exists:
         self.compute_client.servers.get(node['uuid']).delete()
         cnode.delete()
     client = Client(node.name, node.environment.local_api)
     if client.exists:
         client.delete()
開發者ID:CharlesKimpolo,項目名稱:monster,代碼行數:15,代碼來源:openstack.py

示例5: destroy

# 需要導入模塊: from chef import Node [as 別名]
# 或者: from chef.Node import delete [as 別名]
 def destroy(self):
     cnode = CNode(self.name)
     if self['in_use'] == "provisioned":
         # Return to pool if the node is clean
         cnode.chef_environment = "_default"
         cnode.save()
     else:
         # Remove active model if the node is dirty
         active_model = cnode['razor_metadata']['razor_active_model_uuid']
         self.razor.remove_active_model(active_model)
         self.run_cmd("reboot 0")
         CClient(self.name).delete()
         cnode.delete()
         sleep(15)
開發者ID:AsherBond,項目名稱:jenkins-build,代碼行數:16,代碼來源:Nodes.py

示例6: _clean_node

# 需要導入模塊: from chef import Node [as 別名]
# 或者: from chef.Node import delete [as 別名]
 def _clean_node(self, hostid, config, target_system, **kwargs):
     """clean node"""
     from chef import Node
     try:
         node = Node(
             self._get_node_name(
                 config['hostname'], config['clusterid'], target_system),
             api=self.api_
         ) 
         node.delete()
         logging.debug('node is removed for host %s '
                       'config %s target_system %s',
                       hostid, config, target_system)
     except Exception as error:
         logging.debug('no node to delete for host %s '
                       'config %s target_system %s',
                       hostid, config, target_system)
開發者ID:SysCompass,項目名稱:compass-core,代碼行數:19,代碼來源:chefhandler.py

示例7: delete

# 需要導入模塊: from chef import Node [as 別名]
# 或者: from chef.Node import delete [as 別名]
    def delete(self):
        node_id = self.request.GET.get('node_id')
        if node_id is None:
            return {'ok': False, 'message': 'Missing node ID'}
        
        settings = get_current_registry().settings
        api = get_chef_api(settings, self.request.user)

        chef_node = ChefNode(node_id, api)
        if not chef_node.exists:
            return {'ok': False, 'message': 'This node does not exists'}
        chef_node.delete()

        chef_client = ChefClient(node_id, api)
        if not chef_client.exists:
            return {'ok': False, 'message': 'This client does not exists'}
        chef_client.delete()

        return {'ok': True, 'message': 'Node and client have been deleted'}
開發者ID:gecos-team,項目名稱:gecoscc-ui,代碼行數:21,代碼來源:register_chef_node.py


注:本文中的chef.Node.delete方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。