def get_aggregates_from_node(self, node): # Use the aggregates we cached rps = self._resource_providers for id, rp in rps.items(): if node == rp['name']: rp_uuid = id break else: raise exception.NodeNotFound(node=node) aggs = self._provider_aggregate_map[rp_uuid] return {'aggregates': list(aggs)}
def get_manageable_node(self, node_uuid): try: node = self.ironicclient.call('node.get', node_uuid) except ironic_exc.NotFound: raise exception.NodeNotFound(node=node_uuid) if (node.instance_uuid is not None or node.provision_state != ironic_states.ACTIVE or node.resource_class is None): LOG.error( "The node's instance uuid is %(instance_uuid)s, " "node's provision state is %(provision_state)s, " "node's resource class is %(resource_class)s", { "instance_uuid": node.instance_uuid, "provision_state": node.provision_state, "resource_class": node.resource_class }) raise exception.NodeNotAllowedManaged(node_uuid=node_uuid) # Retrieves ports params = { 'limit': 0, 'fields': ('uuid', 'node_uuid', 'extra', 'address', 'internal_info') } port_list = self.ironicclient.call("port.list", **params) portgroup_list = self.ironicclient.call("portgroup.list", **params) # Add ports to the associated node node.ports = [ self._port_resource(port) for port in port_list if node.uuid == port.node_uuid ] # Add portgroups to the associated node node.portgroups = [ self._portgroup_resource(portgroup) for portgroup in portgroup_list if node.uuid == portgroup.node_uuid ] node.power_state = map_power_state(node.power_state) manageable_node = self._node_resource(node) manageable_node['uuid'] = node_uuid return manageable_node
def update_aggregate_node(self, aggregate_uuid, node, action): rps = self._resource_providers for id, rp in rps.items(): if node == rp['name']: rp_uuid = id break else: raise exception.NodeNotFound(node=node) aggs = self._provider_aggregate_map[rp_uuid] if action == 'add': new_aggs = aggs | set([aggregate_uuid]) elif action == 'remove': if aggregate_uuid in aggs: new_aggs = aggs - set([aggregate_uuid]) else: return else: LOG.info('Bad action parameter for update_aggregate_node() %s', action) return self._put_provider_aggregates(rp_uuid, list(new_aggs))