当前位置: 首页>>代码示例>>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;未经允许,请勿转载。