### RPC Client Preparation Example Source: https://github.com/openstack/neutron-lib/blob/master/doc/source/reference/modules/neutron_lib.rpc.md Demonstrates how to use the prepare method of the BackingOffClient to override client properties for a specific method invocation. This example shows setting the version for a 'test' method call. ```python def test(self, ctxt, arg): cctxt = self.prepare(version='2.5') return cctxt.call(ctxt, 'test', arg=arg) ``` -------------------------------- ### Example APIExtensionDescriptor Implementation Source: https://github.com/openstack/neutron-lib/blob/master/api-ref/source/reference/modules/neutron_lib.api.extensions.md Demonstrates how to implement a concrete API extension by inheriting from APIExtensionDescriptor and specifying an api_definition. This example shows the basic structure required for a new API extension. ```python from neutron_lib.api.definitions import provider_net from neutron_lib.api import extensions class Providernet(extensions.APIExtensionDescriptor): api_definition = provider_net # nothing else needed if default behavior is acceptable ``` -------------------------------- ### DBEventPayload Usage Examples for Database Events Source: https://github.com/openstack/neutron-lib/blob/master/api-ref/source/contributor/callbacks.md Demonstrates the construction of DBEventPayload objects for various database event types such as BEFORE_CREATE, AFTER_CREATE, PRECOMMIT_CREATE, BEFORE_DELETE, AFTER_DELETE, BEFORE_UPDATE, and AFTER_UPDATE. These examples illustrate how to pass context, request bodies, resource states, and desired states. ```python DBEventPayload(context, request_body=params_of_create_request, resource_id=id_of_resource_if_avail, desired_state=db_resource_to_commit) DBEventPayload(context, request_body=params_of_create_request, states=[my_new_copy_after_create], resource_id=id_of_resource) DBEventPayload(context, request_body=params_of_create_request, resource_id=id_of_resource_if_avail, desired_state=db_resource_to_commit) DBEventPayload(context, states=[resource_to_delete], resource_id=id_of_resource) DBEventPayload(context, states=[copy_of_deleted_resource], resource_id=id_of_resource) DBEventPayload(context, request_body=body_of_update_request, states=[original_db_resource], resource_id=id_of_resource desired_state=updated_db_resource_to_commit) DBEventPayload(context, request_body=body_of_update_request, states=[original_db_resource, updated_db_resource], resource_id=id_of_resource) ``` -------------------------------- ### Start RPC Listeners (Python) Source: https://github.com/openstack/neutron-lib/blob/master/doc/source/reference/modules/neutron_lib.plugins.ml2.api.md Initializes and starts the necessary RPC listeners for the driver. This method is intended for drivers that require additional RPC methods to fetch data, typically for agents. It's preferred over initializing in `initialize()` to support the separation of RPC and API workers. ```python def start_rpc_listeners(): """ Start RPC listeners. Create and start RPC listeners required by this driver. """ pass ``` -------------------------------- ### Example: Implementing a Neutron Plugin Worker Source: https://github.com/openstack/neutron-lib/blob/master/doc/source/reference/modules/neutron_lib.worker.md Demonstrates how to define a custom worker class inheriting from BaseWorker for specific plugin functionalities, such as database synchronization. This example shows the basic structure for integrating a custom worker into the Neutron plugin system. ```python class MyPlugin(...): def get_workers(self): return [MyPluginWorker()] class MyPluginWorker(BaseWorker): def start(self): super(MyPluginWorker, self).start() do_sync() ``` -------------------------------- ### BaseWorker Class Initialization and Start Method Source: https://github.com/openstack/neutron-lib/blob/master/doc/source/reference/modules/neutron_lib.worker.md Details the initialization of the BaseWorker class, which accepts parameters for worker process count, process title settings, and a description. The start method is crucial for initiating the worker, optionally sending notifications and setting the process title. ```python class BaseWorker(ServiceBase): def __init__(self, worker_process_count=1, set_proctitle='on', desc=None): # ... initialization logic ... pass def start(self, name='neutron-server', desc=None): # ... start logic ... pass ``` -------------------------------- ### RPC Listeners Source: https://github.com/openstack/neutron-lib/blob/master/api-ref/source/reference/modules/neutron_lib.plugins.ml2.api.md Starts the necessary RPC listeners for the driver's agent. ```APIDOC ## start_rpc_listeners() ### Description Initializes and starts the required RPC listeners for the mechanism driver. This is used when the driver's agent needs additional RPC methods to fetch data. It's recommended to initialize listeners here rather than in `initialize()` for better separation of concerns. ### Method N/A (This is a Python method, not an HTTP endpoint) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response N/A (This method performs an action, it does not return a value in the typical sense) #### Response Example N/A ``` -------------------------------- ### APIEventPayload Usage Examples for API Events Source: https://github.com/openstack/neutron-lib/blob/master/api-ref/source/contributor/callbacks.md Provides sample usages of APIEventPayload for API-related callbacks, specifically for 'BEFORE_RESPONSE' scenarios during create, delete, and update operations. These examples show how to include context, method name, action, request body, resource states, and collection name. ```python APIEventPayload(context, method_name, action, request_body=req_body, states=[create_result], collection_name=self._collection_name) APIEventPayload(context, method_name, action, states=[copy_of_deleted_resource], collection_name=self._collection_name) APIEventPayload(context, method_name, action, states=[original, updated], collection_name=self._collection_name) ``` -------------------------------- ### Subscribe and Notify Router Creation Events with Priority Source: https://github.com/openstack/neutron-lib/blob/master/api-ref/source/contributor/callbacks.md Demonstrates subscribing to router creation events with different priorities and then publishing an event. Callbacks with higher priority (lower number) are executed first. This example uses the neutron_lib.callbacks module. ```python from neutron_lib.callbacks import events from neutron_lib.callbacks import resources from neutron_lib.callbacks import registry def callback1(resource, event, trigger, payload): print('Callback1 called by trigger: ', trigger) print('payload: ', payload) def callback2(resource, event, trigger, payload): print('Callback2 called by trigger: ', trigger) print('payload: ', payload) def callbackhighpriority(resource, event, trigger, payload): print("Prepared data for entities") # A is using event in case for some callback or internal operations registry.subscribe(callbackhighpriority, resources.ROUTER, events.BEFORE_CREATE, priority=0) # B and C express interest with I registry.subscribe(callback1, resources.ROUTER, events.BEFORE_CREATE) registry.subscribe(callback2, resources.ROUTER, events.BEFORE_CREATE) print('Subscribed') # A notifies def do_notify(): registry.publish(resources.ROUTER, events.BEFORE_CREATE, do_notify, events.EventPayload(None)) print('Notifying...') do_notify() ``` -------------------------------- ### Networking API v2.0 Overview Source: https://github.com/openstack/neutron-lib/blob/master/api-ref/source/index.md Provides a general overview of the Networking API v2.0, including its guide, versions, and available extensions. ```APIDOC ## Networking API v2.0 ### Description This section provides a comprehensive overview of the Networking API v2.0, detailing the API guide, available API versions, and supported extensions. ### Method GET ### Endpoint /v2 ### Parameters #### Query Parameters - **version** (string) - Optional - Specifies the API version to retrieve. ### Response #### Success Response (200) - **versions** (array) - A list of available API versions. - **id** (string) - The version identifier. - **links** (array) - Links related to the version. - **media-types** (array) - Supported media types for the version. #### Response Example ```json { "versions": [ { "id": "v2.0", "links": [ { "href": "http://:/v2/", "rel": "self" } ], "media-types": [ { "base": "application/json", "type": "application/vnd.openstack.networkv2+json" } ] } ] } ``` ``` -------------------------------- ### Resource Provider Operations Source: https://github.com/openstack/neutron-lib/blob/master/doc/source/reference/modules/neutron_lib.placement.client.md Functions for retrieving information about resource providers, including listing, getting by UUID, and listing their traits and aggregates. ```APIDOC ## GET /resource_providers/{uuid} ### Description Retrieves a specific resource provider by its UUID. ### Method GET ### Endpoint /resource_providers/{uuid} ### Parameters #### Path Parameters - **resource_provider_uuid** (string) - Required - UUID of the resource provider. ### Response #### Success Response (200) - **uuid** (string) - The UUID of the resource provider. - **name** (string) - The name of the resource provider. - **generation** (integer) - The generation number of the resource provider. - **resources** (object) - A dictionary of resource classes and their total/reserved values. - **links** (array) - A list of links associated with the resource provider. #### Response Example ```json { "uuid": "a1b2c3d4-e5f6-7890-1234-567890abcdef", "name": "compute-host-1", "generation": 5, "resources": { "VCPU": { "total": 24, "reserved": 8 }, "MEMORY_MB": { "total": 65536, "reserved": 16384 } }, "links": [ { "href": "/v2/resource_providers/a1b2c3d4-e5f6-7890-1234-567890abcdef", "rel": "self" } ] } ``` ## GET /resource_providers ### Description Retrieves a list of resource providers, with optional filtering. ### Method GET ### Endpoint /resource_providers ### Parameters #### Query Parameters - **name** (string) - Optional - Name of the resource providers to filter by. - **member_of** (string) - Optional - UUID of an aggregate to filter providers that are members of it. - **resources** (object) - Optional - Dictionary of resource classes and requested values to filter by. - **in_tree** (string) - Optional - UUID of a resource provider to limit results to providers within its tree. - **uuid** (string) - Optional - UUID of the resource provider to retrieve. ### Response #### Success Response (200) - **resource_providers** (array) - A list of resource provider objects matching the filters. #### Response Example ```json { "resource_providers": [ { "uuid": "a1b2c3d4-e5f6-7890-1234-567890abcdef", "name": "compute-host-1", "generation": 5, "resources": { "VCPU": { "total": 24, "reserved": 8 } }, "links": [ { "href": "/v2/resource_providers/a1b2c3d4-e5f6-7890-1234-567890abcdef", "rel": "self" } ] } ] } ``` ## GET /resource_providers/{uuid}/traits ### Description Lists all traits associated with a specific resource provider. ### Method GET ### Endpoint /resource_providers/{uuid}/traits ### Parameters #### Path Parameters - **resource_provider_uuid** (string) - Required - UUID of the resource provider. ### Response #### Success Response (200) - **traits** (array) - A list of traits associated with the resource provider. - **generation** (integer) - The generation number of the resource provider. #### Response Example ```json { "traits": [ "HW_CPU", "CUSTOM_TRAIT" ], "generation": 5 } ``` ## GET /resource_providers/{uuid}/aggregates ### Description Lists all aggregates associated with a specific resource provider. ### Method GET ### Endpoint /resource_providers/{uuid}/aggregates ### Parameters #### Path Parameters - **resource_provider_uuid** (string) - Required - UUID of the resource provider. ### Response #### Success Response (200) - **aggregates** (array) - A list of aggregate objects associated with the resource provider. - **generation** (integer) - The generation number of the resource provider. #### Response Example ```json { "aggregates": [ { "uuid": "aggregate-uuid-1", "name": "nova-compute-aggregate", "hosts": ["compute-host-1", "compute-host-2"] } ], "generation": 5 } ``` ``` -------------------------------- ### Get RPC Client Source: https://github.com/openstack/neutron-lib/blob/master/doc/source/reference/modules/neutron_lib.rpc.md Retrieves an RPC client for a specified target. The init() function must be called before using this function. It allows specifying an optional version cap and serializer. ```python def neutron_lib.rpc.get_client(target, version_cap=None, serializer=None): """Get an RPC client for the said target.""" pass ``` -------------------------------- ### PlacementAPIClient: Get Resource Provider Inventory (Python) Source: https://github.com/openstack/neutron-lib/blob/master/doc/source/reference/modules/neutron_lib.placement.client.md Retrieves the inventory details for a specific resource class of a given resource provider. This method is crucial for understanding resource availability. ```python from neutron_lib.placement import client conf = None # Replace with actual configuration object placement_client = client.PlacementAPIClient(conf) resource_provider_uuid = "provider-uuid" resource_class_name = "resource_class_name" inventory = placement_client.get_inventory(resource_provider_uuid, resource_class_name) print(inventory) ``` -------------------------------- ### NoAuthClient: HTTP GET Request Source: https://github.com/openstack/neutron-lib/blob/master/api-ref/source/reference/modules/neutron_lib.placement.client.md Performs an HTTP GET request to a specified URL. This client is designed for full-stack testing and does not require authentication. It accepts optional keyword arguments. ```python client.get(url, endpoint_filter, **kwargs) ``` -------------------------------- ### Driver Initialization Source: https://github.com/openstack/neutron-lib/blob/master/doc/source/reference/modules/neutron_lib.plugins.ml2.api.md Performs driver initialization after all drivers have been loaded and the database initialized. ```APIDOC ## POST /initialize ### Description Perform driver initialization. ### Method POST ### Endpoint /initialize ### Response #### Success Response (200) - **status** (string) - Indicates successful initialization. #### Response Example ```json { "status": "initialized" } ``` ``` -------------------------------- ### Start Neutron Worker Process (Python) Source: https://github.com/openstack/neutron-lib/blob/master/api-ref/source/reference/modules/neutron_lib.worker.md Illustrates the start method of the BaseWorker class, which initiates the worker process. It handles sending callback notifications and setting the process title for child workers. ```python worker_instance.start(name='neutron-server', desc='Optional description') ``` -------------------------------- ### Subscribe and Abort Router Creation Events in Neutron Source: https://github.com/openstack/neutron-lib/blob/master/api-ref/source/contributor/callbacks.md Demonstrates subscribing to 'BEFORE_CREATE' and 'ABORT_CREATE' events for router resources. It shows how a callback can raise an exception to abort an action and how another callback handles the subsequent abort event to revert changes. This is useful for managing shared resources where certain actions should be prevented. ```python from neutron_lib.callbacks import events from neutron_lib.callbacks import exceptions from neutron_lib.callbacks import resources from neutron_lib.callbacks import registry def callback1(resource, event, trigger, payload=None): raise Exception('I am failing!') def callback2(resource, event, trigger, payload=None): print('Callback2 called by %s on event %s' % (trigger, event)) registry.subscribe(callback1, resources.ROUTER, events.BEFORE_CREATE) registry.subscribe(callback2, resources.ROUTER, events.BEFORE_CREATE) registry.subscribe(callback2, resources.ROUTER, events.ABORT_CREATE) print('Subscribed') def do_notify(): registry.publish(resources.ROUTER, events.BEFORE_CREATE, do_notify) print('Notifying...') try: do_notify() except exceptions.CallbackFailure as e: print("Error: %s" % e) ``` -------------------------------- ### neutron_lib.rpc.init Source: https://github.com/openstack/neutron-lib/blob/master/api-ref/source/reference/modules/neutron_lib.rpc.md Initializes the global RPC objects using the provided configuration and optional exception modules. ```APIDOC ## neutron_lib.rpc.init ### Description Initialize the global RPC objects. ### Method Not Applicable (Function Call) ### Endpoint Not Applicable (Function Call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python neutron_lib.rpc.init(conf=oslo_config_object, rpc_ext_mods=['module1', 'module2']) ``` ### Response #### Success Response (200) None. This function does not return any value. #### Response Example None ``` -------------------------------- ### Placement Client Source: https://github.com/openstack/neutron-lib/blob/master/api-ref/source/reference/modules/neutron_lib.md This section details the client implementations for interacting with the Placement API, including authentication and utility functions. ```APIDOC ## Placement Client ### Description Provides client implementations for interacting with the Placement API. ### Classes - **NoAuthClient**: A client that does not perform authentication. - **PlacementAPIClient**: The main client for interacting with the Placement API. - **UUIDEncoder**: An encoder for handling UUIDs in requests. ### Functions - **agent_resource_provider_uuid()**: Retrieves the UUID of an agent's resource provider. - **device_resource_provider_uuid()**: Retrieves the UUID of a device's resource provider. - **parse_rp_bandwidths()**: Parses bandwidth information for resource providers. ``` -------------------------------- ### neutron_lib.rpc.init Source: https://github.com/openstack/neutron-lib/blob/master/doc/source/reference/modules/neutron_lib.rpc.md Initializes the global RPC objects using the provided configuration and optional RPC extension modules. ```APIDOC ## neutron_lib.rpc.init ### Description Initialize the global RPC objects. ### Method Not Applicable (Python function) ### Endpoint Not Applicable (Python function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python # Example usage (conceptual) neutron_lib.rpc.init(conf=oslo_config_object, rpc_ext_mods=['module1', 'module2']) ``` ### Response #### Success Response - **None** - This function does not return any value. #### Response Example ```json { "example": null } ``` ``` -------------------------------- ### Get Collection Query Source: https://github.com/openstack/neutron-lib/blob/master/doc/source/reference/modules/neutron_lib.db.model_query.md Retrieves a paginated query for a collection of objects from a model. ```APIDOC ## POST /db/model_query/get_collection_query ### Description Gets a paginated query for a collection of objects from a specified model, with options for filtering, sorting, and field selection. ### Method POST ### Endpoint /db/model_query/get_collection_query ### Parameters #### Request Body - **context** (object) - Required - The context to use for the DB session. - **model** (object) - Required - The model to use. - **filters** (object) - Optional - The filters to apply in the query. - **sorts** (array) - Optional - The sort keys to use. - **limit** (integer) - Optional - The limit associated with the query. - **marker_obj** (object) - Optional - The marker object if applicable. - **page_reverse** (boolean) - Optional - If reverse paging should be used. - **field** (string) - Optional - The specific column to return from the query. - **lazy_fields** (array) - Optional - A list of fields for lazy loading. ### Response #### Success Response (200) - **query** (object) - A paginated query object for the specified model. #### Response Example ```json { "query": "" } ``` ``` -------------------------------- ### PlacementAPIClient - Aggregate Management Source: https://github.com/openstack/neutron-lib/blob/master/doc/source/reference/modules/neutron_lib.placement.client.md Methods for associating aggregates with resource providers. ```APIDOC ## POST /resource_providers/{resource_provider_uuid}/aggregates ### Description Associate a list of aggregates with a resource provider. ### Method POST ### Endpoint /resource_providers/{resource_provider_uuid}/aggregates ### Parameters #### Path Parameters - **resource_provider_uuid** (string) - Required - UUID of the resource provider. #### Request Body - **aggregates** (list) - Required - aggregates to be associated to the resource provider. ### Response #### Success Response (200) - **associated_aggregates** (list) - All aggregates associated with the resource provider. ### Request Example ```json { "aggregates": [ "availability_zone:nova", "cpu_arch:x86_64" ] } ``` #### Response Example ```json [ "availability_zone:nova", "cpu_arch:x86_64" ] ``` ``` -------------------------------- ### GET /v2.0/metering/metering-labels/{metering_label_id} Source: https://github.com/openstack/neutron-lib/blob/master/api-ref/source/v2/samples/metering/metering-label-show-request-json-http.txt Retrieves details of a specific metering label by its ID. ```APIDOC ## GET /v2.0/metering/metering-labels/{metering_label_id} ### Description Retrieves the details of a specific metering label using its unique identifier. ### Method GET ### Endpoint /v2.0/metering/metering-labels/{metering_label_id} ### Parameters #### Path Parameters - **metering_label_id** (string) - Required - The unique identifier of the metering label to retrieve. ### Request Example ```http GET /v2.0/metering/metering-labels/a6700594-5b7a-4105-8bfe-723b346ce866 HTTP/1.1 Host: controlnode:9696 User-Agent: python-neutronclient Content-Type: application/json Accept: application/json X-Auth-Token: c52a1b304fec4ca0ac85dc1741eec6e2 ``` ### Response #### Success Response (200) - **metering_label** (object) - Contains details of the metering label. - **id** (string) - The unique identifier of the metering label. - **name** (string) - The name of the metering label. - **description** (string) - A description of the metering label. - **project_id** (string) - The ID of the project associated with the metering label. - **created_at** (string) - Timestamp when the metering label was created. - **updated_at** (string) - Timestamp when the metering label was last updated. #### Response Example ```json { "metering_label": { "id": "a6700594-5b7a-4105-8bfe-723b346ce866", "name": "example-label", "description": "An example metering label", "project_id": "1234567890abcdef", "created_at": "2023-10-27T10:00:00Z", "updated_at": "2023-10-27T10:00:00Z" } } ``` ``` -------------------------------- ### Subscribing and Publishing Callbacks Source: https://github.com/openstack/neutron-lib/blob/master/api-ref/source/contributor/callbacks.md Demonstrates how to subscribe various types of functions (module, object, class methods, and nested functions) to events and resources using the Neutron-lib callback registry. It also shows how to publish events and the expected output. ```python from neutron_lib.callbacks import events from neutron_lib.callbacks import resources from neutron_lib.callbacks import registry def callback1(resource, event, trigger, payload): print('module callback') class MyCallback(object): def callback2(self, resource, event, trigger, payload): print('object callback') @classmethod def callback3(cls, resource, event, trigger, payload): print('class callback') c = MyCallback() registry.subscribe(callback1, resources.ROUTER, events.BEFORE_CREATE) registry.subscribe(c.callback2, resources.ROUTER, events.BEFORE_CREATE) registry.subscribe(MyCallback.callback3, resources.ROUTER, events.BEFORE_CREATE) def do_notify(): def nested_subscribe(resource, event, trigger, payload): print('nested callback') registry.subscribe(nested_subscribe, resources.ROUTER, events.BEFORE_CREATE) registry.publish(resources.ROUTER, events.BEFORE_CREATE, do_notify, events.EventPayload(None)) print('Notifying...') do_notify() ``` -------------------------------- ### GET /v2.0/metering/metering-label-rules/{rule_id} Source: https://github.com/openstack/neutron-lib/blob/master/api-ref/source/v2/samples/metering/metering-label-rule-show-request-json-http.txt Retrieves a specific metering label rule by its ID. ```APIDOC ## GET /v2.0/metering/metering-label-rules/{rule_id} ### Description Retrieves the details of a specific metering label rule using its unique identifier. ### Method GET ### Endpoint /v2.0/metering/metering-label-rules/{rule_id} ### Parameters #### Path Parameters - **rule_id** (string) - Required - The unique identifier of the metering label rule to retrieve. ### Request Example ``` GET /v2.0/metering/metering-label-rules/9536641a-7d14-4dc5-afaf-93a973ce0eb8 HTTP/1.1 Host: controlnode:9696 User-Agent: python-neutronclient Content-Type: application/json Accept: application/json X-Auth-Token: c52a1b304fec4ca0ac85dc1741eec6e2 ``` ### Response #### Success Response (200) - **metering_label_rule** (object) - Contains the details of the metering label rule. - **id** (string) - The unique identifier of the rule. - **name** (string) - The name of the rule. - **description** (string) - A description of the rule. - **direction** (string) - The direction of the traffic to which the rule applies ('ingress' or 'egress'). - **remote_ip_prefix** (string) - The remote IP prefix for the rule. - **remote_ip_prefix_len** (integer) - The length of the remote IP prefix. - **project_id** (string) - The ID of the project associated with the rule. - **created_at** (string) - The timestamp when the rule was created. - **updated_at** (string) - The timestamp when the rule was last updated. #### Response Example ```json { "metering_label_rule": { "id": "9536641a-7d14-4dc5-afaf-93a973ce0eb8", "name": "example_rule", "description": "Rule for example traffic", "direction": "ingress", "remote_ip_prefix": "192.168.1.0", "remote_ip_prefix_len": 24, "project_id": "a1b2c3d4e5f678901234567890abcdef", "created_at": "2023-10-27T10:00:00Z", "updated_at": "2023-10-27T10:00:00Z" } } ``` ``` -------------------------------- ### populate_project_info Function Source: https://github.com/openstack/neutron-lib/blob/master/api-ref/source/reference/modules/neutron_lib.api.attributes.md Ensures that both project_id and tenant_id attributes are present in a dictionary. If one is present, the other is added if missing. If neither is present, the dictionary is not modified. ```APIDOC ## Function: populate_project_info(attributes) ### Description Ensure that both project_id and tenant_id attributes are present. If either project_id or tenant_id is present in attributes then ensure that both are present. If neither are present then attributes is not updated. ### Parameters - **attributes** (dict) - A dictionary of resource/API attributes or API request/response dict. ### Returns - dict - Updated attributes (with project_id if applicable). ### Raises - `HTTPBadRequest` - If the attributes project_id and tenant_id don’t match. ``` -------------------------------- ### Allocation Operations Source: https://github.com/openstack/neutron-lib/blob/master/api-ref/source/reference/modules/neutron_lib.placement.client.md APIs for managing resource allocations for consumers. ```APIDOC ## GET /allocations/{consumer_uuid} ### Description Lists all allocation records for a given consumer. ### Method GET ### Endpoint /allocations/{consumer_uuid} ### Parameters #### Path Parameters - **consumer_uuid** (string) - Required - The UUID of the consumer (e.g., VM UUID for a bound port). ### Response #### Success Response (200) - **allocations** (object) - A dictionary where keys are resource provider UUIDs and values are dictionaries of allocated resources. #### Response Example ```json { "allocations": { "a1b2c3d4-e5f6-7890-1234-567890abcdef": { "resources": { "VCPU": 2, "MEMORY_MB": 2048 } } } } ``` ## PUT /allocations/{consumer_uuid} ### Description Updates the allocation record for a given consumer and resource provider. ### Method PUT ### Endpoint /allocations/{consumer_uuid} ### Parameters #### Path Parameters - **consumer_uuid** (string) - Required - The UUID of the consumer. #### Request Body - **allocations** (object) - A dictionary describing the allocations, structured as per the placement API reference. ### Request Example ```json { "allocations": { "a1b2c3d4-e5f6-7890-1234-567890abcdef": { "resources": { "VCPU": 1, "MEMORY_MB": 1024 } } } } ``` ## PUT /allocations/{consumer_uuid}/update_qos ### Description Updates the allocation for a QoS minimum bandwidth consumer. ### Method PUT ### Endpoint /allocations/{consumer_uuid}/update_qos ### Parameters #### Path Parameters - **consumer_uuid** (string) - Required - The UUID of the consumer (e.g., VM UUID for a bound port). #### Request Body - **alloc_diff** (object) - A dictionary where keys are resource provider UUIDs and values are dictionaries containing fields to update for the allocation under the given resource provider. ### Request Example ```json { "alloc_diff": { "a1b2c3d4-e5f6-7890-1234-567890abcdef": { "bandwidth_minimum": { "total": 1000000, "direction": "ingress" } } } } ``` ``` -------------------------------- ### Agent Topics Source: https://github.com/openstack/neutron-lib/blob/master/doc/source/reference/modules/neutron_lib.agent.md Provides functionality to get topic names used in agent communication. ```APIDOC ## GET /openstack/neutron-lib/agent/topics ### Description This endpoint allows retrieval of topic names used for agent communication, utilizing the `get_topic_name` function from the `neutron_lib.agent.topics` module. ### Method GET ### Endpoint /openstack/neutron-lib/agent/topics ### Parameters #### Query Parameters - **topic_key** (string) - Required - The key identifying the topic (e.g., 'L3_ROUTER_INFO'). ### Request Example ```json { "topic_key": "L3_ROUTER_INFO" } ``` ### Response #### Success Response (200) - **topic_name** (string) - The generated topic name. #### Response Example ```json { "topic_name": "neutron.l3.router.info" } ``` ``` -------------------------------- ### Get Values Source: https://github.com/openstack/neutron-lib/blob/master/api-ref/source/reference/modules/neutron_lib.db.model_query.md Retrieves specific field values from a model based on provided filters. ```APIDOC ## get_values ### Description Retrieves specific field values from a model based on provided filters. ### Method (Not specified, likely internal function) ### Endpoint (Not applicable, internal function) ### Parameters #### Path Parameters (None) #### Query Parameters (None) #### Request Body (None) ### Request Example (Not applicable) ### Response #### Success Response (200) - **values** (array) - A list of values for the specified field. #### Response Example (Not applicable) ``` -------------------------------- ### Get Collection Count Source: https://github.com/openstack/neutron-lib/blob/master/api-ref/source/reference/modules/neutron_lib.db.model_query.md Returns the count of objects for a specific model, optionally filtered. ```APIDOC ## get_collection_count ### Description Get the count for a specific collection. ### Method (Not specified, likely internal function) ### Endpoint (Not applicable, internal function) ### Parameters #### Path Parameters (None) #### Query Parameters (None) #### Request Body (None) ### Request Example (Not applicable) ### Response #### Success Response (200) - **count** (integer) - The number of objects for said model with filters applied. #### Response Example (Not applicable) ``` -------------------------------- ### Aggregate Operations Source: https://github.com/openstack/neutron-lib/blob/master/api-ref/source/reference/modules/neutron_lib.placement.client.md APIs for managing resource provider aggregates. ```APIDOC ## GET /resource_providers/{uuid}/aggregates ### Description Lists all aggregates associated with a specific resource provider. ### Method GET ### Endpoint /resource_providers/{uuid}/aggregates ### Parameters #### Path Parameters - **uuid** (string) - Required - The UUID of the resource provider. ### Response #### Success Response (200) - **aggregates** (array) - A list of aggregate objects associated with the resource provider. - **generation** (integer) - The generation number of the resource provider. #### Response Example ```json { "aggregates": [ { "uuid": "f0e1d2c3-b4a5-6789-0123-456789abcdef", "name": "nova::compute::host1::aggregate1" } ], "generation": 5 } ``` ``` -------------------------------- ### Get Object by ID Source: https://github.com/openstack/neutron-lib/blob/master/api-ref/source/reference/modules/neutron_lib.db.model_query.md Retrieves a specific object from a model using its ID and context. ```APIDOC ## get_by_id ### Description Query the said model with the given context for a specific object. ### Method (Not specified, likely internal function) ### Endpoint (Not applicable, internal function) ### Parameters #### Path Parameters (None) #### Query Parameters (None) #### Request Body (None) ### Request Example (Not applicable) ### Response #### Success Response (200) - **object** (object) - The object with the given object_id for the said model. #### Response Example (Not applicable) ``` -------------------------------- ### QoS Policy Creation Methods in DriverBase Source: https://github.com/openstack/neutron-lib/blob/master/doc/source/reference/modules/neutron_lib.services.qos.base.md These methods are part of the DriverBase class and are intended to be implemented by specific driver subclasses. They handle the creation of QoS policies, including pre-commit checks, to update the backend with policy information. ```python def create_policy(context, policy): """Create policy invocation.""" pass def create_policy_precommit(context, policy): """Create policy precommit.""" pass ``` -------------------------------- ### Get Model Query Hooks Source: https://github.com/openstack/neutron-lib/blob/master/api-ref/source/reference/modules/neutron_lib.db.model_query.md Retrieves the query hooks associated with a specific database model. ```APIDOC ## get_hooks ### Description Retrieve the model query hooks for a model. ### Method (Not specified, likely internal function) ### Endpoint (Not applicable, internal function) ### Parameters #### Path Parameters (None) #### Query Parameters (None) #### Request Body (None) ### Request Example (Not applicable) ### Response #### Success Response (200) - **hooks** (array) - A list of hooks. #### Response Example (Not applicable) ``` -------------------------------- ### Neutron Lib Placement Utilities Source: https://github.com/openstack/neutron-lib/blob/master/api-ref/source/reference/modules/neutron_lib.md Utility functions for handling placement-related logic within Neutron. ```APIDOC ## Neutron Lib Placement Utilities ### Description Provides utility functions for managing resource provider inventory defaults, parsing placement properties, and trait manipulation. ### Methods - **parse_rp_inventory_defaults()** - Description: Parses default inventory for resource providers. - **parse_rp_pp_with_direction()** - Description: Parses resource provider placement properties with direction. - **parse_rp_pp_without_direction()** - Description: Parses resource provider placement properties without direction. - **physnet_trait()** - Description: Retrieves the physical network trait. - **resource_request_group_uuid()** - Description: Generates a UUID for a resource request group. - **six_uuid5()** - Description: Generates a UUID using the UUID5 algorithm. - **vnic_type_trait()** - Description: Retrieves the virtual network interface type trait. ``` -------------------------------- ### Get Collection Source: https://github.com/openstack/neutron-lib/blob/master/api-ref/source/reference/modules/neutron_lib.db.model_query.md Retrieves a collection of objects for a given model, with options for filtering, sorting, and pagination. ```APIDOC ## get_collection ### Description Get a collection for a said model. ### Method (Not specified, likely internal function) ### Endpoint (Not applicable, internal function) ### Parameters #### Path Parameters (None) #### Query Parameters (None) #### Request Body (None) ### Request Example (Not applicable) ### Response #### Success Response (200) - **list** (array) - A list of dicts where each dict is an object in the collection. #### Response Example (Not applicable) ``` -------------------------------- ### Initialize Agent Extension Resources Source: https://github.com/openstack/neutron-lib/blob/master/doc/source/reference/modules/neutron_lib.agent.extension.md The `initialize` method is called after all agent extensions are loaded. It's responsible for performing core resource extension initialization using the provided RPC connection and driver type. No resource handling occurs before this method is executed. ```python def initialize(self, connection, driver_type): """Perform agent core resource extension initialization. * **Parameters:** * **connection** – RPC connection that can be reused by the extension to define its RPC endpoints * **driver_type** – String that defines the agent type to the extension. Can be used to choose the right backend implementation. Called after all extensions have been loaded. No resource (port, policy, router, etc.) handling will be called before this method. """ print(f"Initializing extension for driver type: {driver_type}") # Setup RPC endpoints using the connection object # connection.create_consumer(...) pass ``` -------------------------------- ### Port Range Source: https://github.com/openstack/neutron-lib/blob/master/doc/source/reference/modules/neutron_lib.objects.common_types.md Represents a range of port numbers, with a specified start. ```APIDOC ## Class neutron_lib.objects.common_types.PortRange ### Description Represents a range of port numbers, with a specified start. ### Method N/A ### Endpoint N/A ### Parameters - **start** (integer) - Required - The starting port number of the range. ### Request Example N/A ### Response N/A ### Response Example N/A ``` -------------------------------- ### ContextBaseWithSession Class Source: https://github.com/openstack/neutron-lib/blob/master/api-ref/source/reference/modules/neutron_lib.context.md Extends ContextBase to include database session management capabilities. ```APIDOC ## Class neutron_lib.context.ContextBaseWithSession ### Description Extends ContextBase to include database session management capabilities. ### Properties - `connection`: The database connection associated with the session. - `session`: The database session object. - `transaction`: The current transaction object. - `transaction_ctx`: The transaction context. ### Request Example ```json // No direct request body for accessing properties. Use methods of the ContextBaseWithSession object. ``` ### Response #### Success Response (200) - **Database connection/session/transaction object**: Returns the respective database object. #### Response Example ```json // Response will be a database connection, session, or transaction object depending on the property accessed. ``` ``` -------------------------------- ### Configuration and Interface Utilities Source: https://github.com/openstack/neutron-lib/blob/master/doc/source/reference/modules/neutron_lib.plugins.utils.md Functions for retrieving physical network MTU and constructing interface names. ```APIDOC ## GET /openstack/neutron-lib/plugins/utils/get_deployment_physnet_mtu ### Description Retrieves global physical network MTU setting. Plugins should use this function to retrieve the MTU set by the operator that is equal to or less than the MTU of their nodes’ physical interfaces. Note that it is the responsibility of the plugin to deduct the value of any encapsulation overhead required before advertising it to VMs. Note that this function depends on the global_physnet_mtu config option being registered in the global CONF. ### Method GET ### Endpoint /openstack/neutron-lib/plugins/utils/get_deployment_physnet_mtu ### Response #### Success Response (200) - **mtu** (integer) - The global_physnet_mtu from the global CONF. #### Response Example ```json { "mtu": 1500 } ``` ``` ```APIDOC ## GET /openstack/neutron-lib/plugins/utils/get_interface_name ### Description Construct an interface name based on the prefix and name. The interface name can not exceed the maximum length passed in. Longer names are hashed to help ensure uniqueness. ### Method GET ### Endpoint /openstack/neutron-lib/plugins/utils/get_interface_name ### Parameters #### Query Parameters - **name** (string) - Required - The base name for the interface. - **prefix** (string) - Optional - A prefix to prepend to the interface name. Defaults to ''. - **max_len** (integer) - Optional - The maximum length of the generated interface name. Defaults to 15. ### Response #### Success Response (200) - **interface_name** (string) - The constructed interface name. #### Response Example ```json { "interface_name": "tap-abcdef12345" } ``` ``` -------------------------------- ### Port Range Source: https://github.com/openstack/neutron-lib/blob/master/api-ref/source/reference/modules/neutron_lib.objects.common_types.md Defines a range for port numbers, with a specified start. ```APIDOC ## Class: PortRange ### Description Defines a range for port numbers, with a specified start. ### Method N/A (Class definition) ### Endpoint N/A ### Parameters * **start** (integer) - Required - The starting port number of the range. * **kwargs** - Optional - Additional keyword arguments. ### Request Example N/A ### Response N/A ### Error Handling N/A ``` -------------------------------- ### Get RBAC Actions Source: https://github.com/openstack/neutron-lib/blob/master/api-ref/source/reference/modules/neutron_lib.db.model_query.md Retrieves and combines all RBAC (Role-Based Access Control) actions defined for a model. ```APIDOC ## get_rbac_actions ### Description Retrieve and combine all RBAC actions requested in a model ### Method (Not specified, likely internal function) ### Endpoint (Not applicable, internal function) ### Parameters #### Path Parameters (None) #### Query Parameters (None) #### Request Body (None) ### Request Example (Not applicable) ### Response #### Success Response (200) - **actions** (set) - A set of RBAC actions defined in the model or the default RBAC actions. #### Response Example (Not applicable) ``` -------------------------------- ### Resource Class Operations Source: https://github.com/openstack/neutron-lib/blob/master/api-ref/source/reference/modules/neutron_lib.placement.client.md APIs for managing and retrieving resource class information. ```APIDOC ## GET /resource_classes/{name} ### Description Retrieves details for a specific resource class. ### Method GET ### Endpoint /resource_classes/{name} ### Parameters #### Path Parameters - **name** (string) - Required - The name of the resource class to show. ### Response #### Success Response (200) - **name** (string) - The name of the resource class. - **links** (array) - A list of links associated with the resource class. #### Response Example ```json { "name": "VCPU", "links": [ { "href": "/v2/resource_classes/VCPU", "rel": "self" } ] } ``` ## POST /resource_classes ### Description Creates or validates the existence of a custom resource class. ### Method POST ### Endpoint /resource_classes ### Parameters #### Request Body - **name** (string) - Required - The name of the resource class to be updated or validated. ### Request Example ```json { "name": "CUSTOM_RESOURCE" } ``` ### Response #### Success Response (200) - Returns None on successful creation or validation. ## GET /resource_classes ### Description Lists all available resource classes. ### Method GET ### Endpoint /resource_classes ### Response #### Success Response (200) - **resource_classes** (array) - A list of resource class objects. #### Response Example ```json { "resource_classes": [ { "name": "VCPU", "links": [ { "href": "/v2/resource_classes/VCPU", "rel": "self" } ] }, { "name": "MEMORY_MB", "links": [ { "href": "/v2/resource_classes/MEMORY_MB", "rel": "self" } ] } ] } ``` ``` -------------------------------- ### Range Constrained Integer Source: https://github.com/openstack/neutron-lib/blob/master/doc/source/reference/modules/neutron_lib.objects.common_types.md Represents an integer constrained by a start and end value. ```APIDOC ## Class neutron_lib.objects.common_types.RangeConstrainedInteger ### Description Represents an integer constrained by a start and end value. ### Method N/A ### Endpoint N/A ### Parameters - **start** (integer) - Required - The minimum value for the integer. - **end** (integer) - Required - The maximum value for the integer. ### Request Example N/A ### Response N/A ### Response Example N/A ``` -------------------------------- ### Range Constrained Integer Source: https://github.com/openstack/neutron-lib/blob/master/api-ref/source/reference/modules/neutron_lib.objects.common_types.md An integer type with constrained start and end values. ```APIDOC ## Class: RangeConstrainedInteger ### Description An integer type with constrained start and end values. ### Method N/A (Class definition) ### Endpoint N/A ### Parameters * **start** (integer) - Required - The minimum allowed value. * **end** (integer) - Required - The maximum allowed value. * **kwargs** - Optional - Additional keyword arguments. ### Request Example N/A ### Response N/A ### Error Handling N/A ```