def delete_node_collection(collectionpath, configmanager): if len(collectionpath) == 2: # just node node = collectionpath[-1] configmanager.del_nodes([node]) yield msg.DeletedResource(node) else: raise Exception("Not implemented")
def delete_nodegroup_collection(collectionpath, configmanager): if len(collectionpath) == 2: # just the nodegroup group = collectionpath[-1] configmanager.del_groups([group]) yield msg.DeletedResource(group) else: raise Exception("Not implemented")
def handle_api_request(configmanager, inputdata, operation, pathcomponents): if operation == 'retrieve': return handle_read_api_request(pathcomponents) elif (operation in ('update', 'create') and pathcomponents == ['discovery', 'rescan']): if inputdata != {'rescan': 'start'}: raise exc.InvalidArgumentException() rescan() return (msg.KeyValueData({'rescan': 'started'}), ) elif operation in ('update', 'create'): if 'node' not in inputdata: raise exc.InvalidArgumentException('Missing node name in input') mac = _get_mac_from_query(pathcomponents) info = known_info[mac] if info['handler'] is None: raise exc.NotImplementedException('Unable to {0} to {1}'.format( operation, '/'.join(pathcomponents))) handler = info['handler'].NodeHandler(info, configmanager) eval_node(configmanager, handler, info, inputdata['node'], manual=True) return [msg.AssignedResource(inputdata['node'])] elif operation == 'delete': mac = _get_mac_from_query(pathcomponents) del known_info[mac] return [msg.DeletedResource(mac)] raise exc.NotImplementedException('Unable to {0} to {1}'.format( operation, '/'.join(pathcomponents)))
def delete_node_collection(collectionpath, configmanager, isnoderange): if len(collectionpath) == 2: # just node nodes = [collectionpath[-1]] if isnoderange: nodes = noderange.NodeRange(nodes[0], configmanager).nodes configmanager.del_nodes(nodes) for node in nodes: yield msg.DeletedResource(node) else: raise Exception("Not implemented")
def remove_updates(nodes, tenant, element): if len(element) < 5: raise exc.InvalidArgumentException() upid = element[-1] for node in nodes: try: upd = updatesbytarget[(node, tenant)][upid] except KeyError: raise exc.NotFoundException('No active update matches request') upd.cancel() del updatesbytarget[(node, tenant)][upid] yield msg.DeletedResource( 'nodes/{0}/inventory/firmware/updates/active/{1}'.format( node, upid))
def remove_updates(nodes, tenant, element, type='firmware'): if len(element) < 5 and element[:2] != ['media', 'uploads']: raise exc.InvalidArgumentException() upid = element[-1] if type == 'firmware': myparty = updatesbytarget else: myparty = uploadsbytarget for node in nodes: try: upd = myparty[(node, tenant)][upid] except KeyError: raise exc.NotFoundException('No active update matches request') upd.cancel() del myparty[(node, tenant)][upid] yield msg.DeletedResource( 'nodes/{0}/inventory/firmware/updates/active/{1}'.format( node, upid))
def remove_importing(importkey): importing[importkey].stop() del importing[importkey] yield msg.DeletedResource('deployment/importing/{0}'.format(importkey))
def delete_usergroup(usergroup, configmanager): configmanager.del_usergroup(usergroup) yield msg.DeletedResource(usergroup)
def delete_user(user, configmanager): configmanager.del_user(user) yield msg.DeletedResource(user)