本文整理汇总了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
示例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)))
示例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)
示例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()
示例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)
示例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)
示例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'}