Merge "Updting networks, subnets and ports client comments with @type Adding query params for filtering and pagination at list client methods Updating update_subnet client method with allocation_pools param (now updatable)"
This commit is contained in:
commit
5e1a70b4b6
@ -26,12 +26,17 @@ class NetworksClient(AutoMarshallingHTTPClient):
|
|||||||
def __init__(self, url, auth_token, serialize_format=None,
|
def __init__(self, url, auth_token, serialize_format=None,
|
||||||
deserialize_format=None, tenant_id=None):
|
deserialize_format=None, tenant_id=None):
|
||||||
"""
|
"""
|
||||||
@param string url: Base URL for the networks service
|
@param url: Base URL for the networks service
|
||||||
@param string auth_token: Auth token to be used for all requests
|
@type url: string
|
||||||
@param string serialize_format: Format for serializing requests
|
@param auth_token: Auth token to be used for all requests
|
||||||
@param string deserialize_format: Format for de-serializing responses
|
@type auth_token: string
|
||||||
@param string tenant_id: optional tenant id to be included in the
|
@param serialize_format: Format for serializing requests
|
||||||
|
@type serialize_format: string
|
||||||
|
@param deserialize_format: Format for de-serializing responses
|
||||||
|
@type deserialize_format: string
|
||||||
|
@param tenant_id: optional tenant id to be included in the
|
||||||
header if given
|
header if given
|
||||||
|
@type tenant_id: string
|
||||||
"""
|
"""
|
||||||
super(NetworksClient, self).__init__(serialize_format,
|
super(NetworksClient, self).__init__(serialize_format,
|
||||||
deserialize_format)
|
deserialize_format)
|
||||||
@ -53,14 +58,20 @@ class NetworksClient(AutoMarshallingHTTPClient):
|
|||||||
tenant_id=None, requestslib_kwargs=None):
|
tenant_id=None, requestslib_kwargs=None):
|
||||||
"""
|
"""
|
||||||
@summary: Creates a Network
|
@summary: Creates a Network
|
||||||
@param string name: human readable name for the network,
|
@param name: human readable name for the network,
|
||||||
may not be unique. (CRUD: CRU)
|
may not be unique. (CRUD: CRU)
|
||||||
@param bool admin_state_up: true or false, the admin state
|
@type name: string
|
||||||
|
@param admin_state_up: true or false, the admin state
|
||||||
of the network. If down, the network does not forward packets.
|
of the network. If down, the network does not forward packets.
|
||||||
Default value is True (CRUD: CRU)
|
Default value is True (CRUD: CRU)
|
||||||
@param bool shared: specifies if the network can be accessed by any
|
@type admin_state_up: bool
|
||||||
|
@param shared: specifies if the network can be accessed by any
|
||||||
tenant. Default value is False. (CRUD: CRU)
|
tenant. Default value is False. (CRUD: CRU)
|
||||||
@param string tenant_id: owner of the network. (CRUD: CR)
|
@type shared: bool
|
||||||
|
@param tenant_id: owner of the network. (CRUD: CR)
|
||||||
|
@type tenant_id: string
|
||||||
|
@return: network create response
|
||||||
|
@rtype: Requests.response
|
||||||
"""
|
"""
|
||||||
url = '{base_url}/networks'.format(base_url=self.url)
|
url = '{base_url}/networks'.format(base_url=self.url)
|
||||||
|
|
||||||
@ -77,15 +88,22 @@ class NetworksClient(AutoMarshallingHTTPClient):
|
|||||||
shared=None, tenant_id=None, requestslib_kwargs=None):
|
shared=None, tenant_id=None, requestslib_kwargs=None):
|
||||||
"""
|
"""
|
||||||
@summary: Updates a specified Network
|
@summary: Updates a specified Network
|
||||||
@param string network_id: The UUID for the network
|
@param network_id: The UUID for the network
|
||||||
@param string name: human readable name for the network,
|
@type network_id: string
|
||||||
may not be unique. (CRUD: CRU)
|
@param name: human readable name for the network, may not be unique.
|
||||||
@param bool admin_state_up: true or false, the admin state
|
(CRUD: CRU)
|
||||||
of the network. If down, the network does not forward packets.
|
@type name: string
|
||||||
Default value is True (CRUD: CRU)
|
@param admin_state_up: true or false, the admin state of the network.
|
||||||
@param bool shared: specifies if the network can be accessed by any
|
If down, the network does not forward packets. Default value is
|
||||||
tenant. Default value is False. (CRUD: CRU)
|
True (CRUD: CRU)
|
||||||
@param string tenant_id: owner of the network. (CRUD: CR)
|
@type admin_state_up: bool
|
||||||
|
@param shared: specifies if the network can be accessed by any tenant.
|
||||||
|
Default value is False. (CRUD: CRU)
|
||||||
|
@type shared: bool
|
||||||
|
@param tenant_id: owner of the network. (CRUD: CR)
|
||||||
|
@type tenant_id: string
|
||||||
|
@return: update network response
|
||||||
|
@rtype: Requests.response
|
||||||
"""
|
"""
|
||||||
|
|
||||||
url = '{base_url}/networks/{network_id}'.format(
|
url = '{base_url}/networks/{network_id}'.format(
|
||||||
@ -102,7 +120,10 @@ class NetworksClient(AutoMarshallingHTTPClient):
|
|||||||
def get_network(self, network_id, requestslib_kwargs=None):
|
def get_network(self, network_id, requestslib_kwargs=None):
|
||||||
"""
|
"""
|
||||||
@summary: Shows information for a specified network
|
@summary: Shows information for a specified network
|
||||||
@param string network_id: The UUID for the network
|
@param network_id: The UUID for the network
|
||||||
|
@type network_id: string
|
||||||
|
@return: get network response
|
||||||
|
@rtype: Requests.response
|
||||||
"""
|
"""
|
||||||
|
|
||||||
url = '{base_url}/networks/{network_id}'.format(
|
url = '{base_url}/networks/{network_id}'.format(
|
||||||
@ -112,14 +133,40 @@ class NetworksClient(AutoMarshallingHTTPClient):
|
|||||||
requestslib_kwargs=requestslib_kwargs)
|
requestslib_kwargs=requestslib_kwargs)
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
def list_networks(self, requestslib_kwargs=None):
|
def list_networks(self, network_id=None, name=None, status=None,
|
||||||
|
admin_state_up=None, shared=None, tenant_id=None,
|
||||||
|
limit=None, marker=None, page_reverse=None,
|
||||||
|
requestslib_kwargs=None):
|
||||||
"""
|
"""
|
||||||
@summary: Lists networks
|
@summary: Lists networks, filtered by params if given
|
||||||
|
@param network_id: network ID to filter by
|
||||||
|
@type network_id: string
|
||||||
|
@param name: network name to filter by
|
||||||
|
@type name: string
|
||||||
|
@param status: network status to filter by
|
||||||
|
@type status: string
|
||||||
|
@param admin_state_up: Admin state of the network to filter by
|
||||||
|
@type admin_state_up: bool
|
||||||
|
@param shared: If network is shared across tenants status to filter by
|
||||||
|
@type shared: bool
|
||||||
|
@param tenant_id: tenant ID network owner to filter by
|
||||||
|
@type tenant_id: string
|
||||||
|
@param limit: page size
|
||||||
|
@type limit: int
|
||||||
|
@param marker: Id of the last item of the previous page
|
||||||
|
@type marker: string
|
||||||
|
@param page_reverse: direction of the page
|
||||||
|
@type page_reverse: bool
|
||||||
|
@return: list networks response
|
||||||
|
@rtype: Requests.response
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# TODO: add field query params to filter the response
|
params = {'id': network_id, 'name': name, 'status': status,
|
||||||
|
'admin_state_up': admin_state_up, 'shared': shared,
|
||||||
|
'tenant_id': tenant_id, 'limit': limit, 'marker': marker,
|
||||||
|
'page_reverse': page_reverse}
|
||||||
url = '{base_url}/networks'.format(base_url=self.url)
|
url = '{base_url}/networks'.format(base_url=self.url)
|
||||||
resp = self.request('GET', url,
|
resp = self.request('GET', url, params=params,
|
||||||
response_entity_type=Networks,
|
response_entity_type=Networks,
|
||||||
requestslib_kwargs=requestslib_kwargs)
|
requestslib_kwargs=requestslib_kwargs)
|
||||||
return resp
|
return resp
|
||||||
@ -127,7 +174,10 @@ class NetworksClient(AutoMarshallingHTTPClient):
|
|||||||
def delete_network(self, network_id, requestslib_kwargs=None):
|
def delete_network(self, network_id, requestslib_kwargs=None):
|
||||||
"""
|
"""
|
||||||
@summary: Deletes a specified network and its associated resources
|
@summary: Deletes a specified network and its associated resources
|
||||||
@param string network_id: The UUID for the network
|
@param network_id: The UUID for the network
|
||||||
|
@type network_id: string
|
||||||
|
@return: delete network response
|
||||||
|
@rtype: Requests.response
|
||||||
"""
|
"""
|
||||||
|
|
||||||
url = '{base_url}/networks/{network_id}'.format(
|
url = '{base_url}/networks/{network_id}'.format(
|
||||||
|
@ -25,12 +25,17 @@ class PortsClient(AutoMarshallingHTTPClient):
|
|||||||
def __init__(self, url, auth_token, serialize_format=None,
|
def __init__(self, url, auth_token, serialize_format=None,
|
||||||
deserialize_format=None, tenant_id=None):
|
deserialize_format=None, tenant_id=None):
|
||||||
"""
|
"""
|
||||||
@param string url: Base URL for the ports service
|
@param url: Base URL for the ports service
|
||||||
@param string auth_token: Auth token to be used for all requests
|
@type url: string
|
||||||
@param string serialize_format: Format for serializing requests
|
@param auth_token: Auth token to be used for all requests
|
||||||
@param string deserialize_format: Format for de-serializing responses
|
@type auth_token: string
|
||||||
@param string tenant_id: optional tenant id to be included in the
|
@param serialize_format: Format for serializing requests
|
||||||
|
@type serialize_format: string
|
||||||
|
@param deserialize_format: Format for de-serializing responses
|
||||||
|
@type deserialize_format: string
|
||||||
|
@param tenant_id: optional tenant id to be included in the
|
||||||
header if given
|
header if given
|
||||||
|
@type tenant_id: string
|
||||||
"""
|
"""
|
||||||
super(PortsClient, self).__init__(serialize_format,
|
super(PortsClient, self).__init__(serialize_format,
|
||||||
deserialize_format)
|
deserialize_format)
|
||||||
@ -54,21 +59,31 @@ class PortsClient(AutoMarshallingHTTPClient):
|
|||||||
requestslib_kwargs=None):
|
requestslib_kwargs=None):
|
||||||
"""
|
"""
|
||||||
@summary: Creates a Port
|
@summary: Creates a Port
|
||||||
@param string network_id: network port is associated with (CRUD: CR)
|
@param network_id: network port is associated with (CRUD: CR)
|
||||||
@param string name: human readable name for the port,
|
@type network_id: string
|
||||||
|
@param name: human readable name for the port,
|
||||||
may not be unique. (CRUD: CRU)
|
may not be unique. (CRUD: CRU)
|
||||||
@param bool admin_state_up: true or false (default true),
|
@type name: string
|
||||||
|
@param admin_state_up: true or false (default true),
|
||||||
the admin state of the port. If down, the port does not forward
|
the admin state of the port. If down, the port does not forward
|
||||||
packets (CRUD: CRU)
|
packets (CRUD: CRU)
|
||||||
@param string mac_address: mac address to use on the port (CRUD: CR)
|
@type admin_state_up: bool
|
||||||
@param list(dict) fixed_ips: ip addresses for the port associating the
|
@param mac_address: mac address to use on the port (CRUD: CR)
|
||||||
port with the subnets where the IPs come from (CRUD: CRU)
|
@type mac_address: string
|
||||||
@param string device_id: id of device using this port (CRUD: CRUD)
|
@param fixed_ips: ip addresses for the port associating the port with
|
||||||
@param string device_owner: entity using this port (ex. dhcp agent,
|
the subnets where the IPs come from (CRUD: CRU)
|
||||||
CRUD: CRUD)
|
@type fixed_ips: list(dict)
|
||||||
@param string tenant_id: owner of the port (CRUD: CR)
|
@param device_id: id of device using this port (CRUD: CRUD)
|
||||||
@param list(dict) security_groups: ids of any security groups
|
@type device_id: string
|
||||||
associated with the port (CRUD: CRUD)
|
@param device_owner: entity using this port (ex. dhcp agent,CRUD: CRUD)
|
||||||
|
@type device_owner: string
|
||||||
|
@param tenant_id: owner of the port (CRUD: CR)
|
||||||
|
@type tenant_id: string
|
||||||
|
@param security_groups: ids of any security groups associated with the
|
||||||
|
port (CRUD: CRUD)
|
||||||
|
@type security_groups: list(dict)
|
||||||
|
@return: port create response
|
||||||
|
@rtype: Requests.response
|
||||||
"""
|
"""
|
||||||
|
|
||||||
url = '{base_url}/ports'.format(base_url=self.url)
|
url = '{base_url}/ports'.format(base_url=self.url)
|
||||||
@ -90,19 +105,27 @@ class PortsClient(AutoMarshallingHTTPClient):
|
|||||||
security_groups=None, requestslib_kwargs=None):
|
security_groups=None, requestslib_kwargs=None):
|
||||||
"""
|
"""
|
||||||
@summary: Updates a specified Port
|
@summary: Updates a specified Port
|
||||||
@param string port_id: The UUID for the port
|
@param port_id: The UUID for the port
|
||||||
@param string name: human readable name for the port,
|
@type port_id: string
|
||||||
may not be unique. (CRUD: CRU)
|
@param name: human readable name for the port, may not be unique
|
||||||
@param bool admin_state_up: true or false (default true),
|
(CRUD: CRU)
|
||||||
the admin state of the port. If down, the port does not forward
|
@type name: string
|
||||||
packets (CRUD: CRU)
|
@param admin_state_up: true or false (default true), the admin state
|
||||||
@param list(dict) fixed_ips: ip addresses for the port associating the
|
of the port. If down, the port does not forward packets (CRUD: CRU)
|
||||||
port with the subnets where the IPs come from (CRUD: CRU)
|
@type admin_state_up: bool
|
||||||
@param string device_id: id of device using this port (CRUD: CRUD)
|
@param fixed_ips: ip addresses for the port associating the port with
|
||||||
|
the subnets where the IPs come from (CRUD: CRU)
|
||||||
|
@type fixed_ips: list(dict)
|
||||||
|
@param device_id: id of device using this port (CRUD: CRUD)
|
||||||
|
@type device_id: string
|
||||||
@param string device_owner: entity using this port (ex. dhcp agent,
|
@param string device_owner: entity using this port (ex. dhcp agent,
|
||||||
CRUD: CRUD)
|
CRUD: CRUD)
|
||||||
@param list(dict) security_groups: ids of any security groups
|
@type device_owner: string
|
||||||
associated with the port (CRUD: CRUD)
|
@param security_groups: ids of any security groups associated with the
|
||||||
|
port (CRUD: CRUD)
|
||||||
|
@type security_groups: list(dict)
|
||||||
|
@return: update port response
|
||||||
|
@rtype: Requests.response
|
||||||
"""
|
"""
|
||||||
|
|
||||||
url = '{base_url}/ports/{port_id}'.format(
|
url = '{base_url}/ports/{port_id}'.format(
|
||||||
@ -120,7 +143,10 @@ class PortsClient(AutoMarshallingHTTPClient):
|
|||||||
def get_port(self, port_id, requestslib_kwargs=None):
|
def get_port(self, port_id, requestslib_kwargs=None):
|
||||||
"""
|
"""
|
||||||
@summary: Shows information for a specified port
|
@summary: Shows information for a specified port
|
||||||
@param string port_id: The UUID for the port
|
@param port_id: The UUID for the port
|
||||||
|
@type port_id: string
|
||||||
|
@return: get port response
|
||||||
|
@rtype: Requests.response
|
||||||
"""
|
"""
|
||||||
|
|
||||||
url = '{base_url}/ports/{port_id}'.format(
|
url = '{base_url}/ports/{port_id}'.format(
|
||||||
@ -130,14 +156,48 @@ class PortsClient(AutoMarshallingHTTPClient):
|
|||||||
requestslib_kwargs=requestslib_kwargs)
|
requestslib_kwargs=requestslib_kwargs)
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
def list_ports(self, requestslib_kwargs=None):
|
def list_ports(self, port_id=None, network_id=None, name=None, status=None,
|
||||||
|
admin_state_up=None, device_id=None, tenant_id=None,
|
||||||
|
device_owner=None, mac_address=None, limit=None,
|
||||||
|
marker=None, page_reverse=None, requestslib_kwargs=None):
|
||||||
"""
|
"""
|
||||||
@summary: Lists ports
|
@summary: Lists ports, filtered by params if given
|
||||||
|
@param port_id: The UUID for the port to filter by
|
||||||
|
@type port_id: string
|
||||||
|
@param network_id: network ID to filter by
|
||||||
|
@type network_id: string
|
||||||
|
@param name: port name to filter by
|
||||||
|
@type name: string
|
||||||
|
@param status: port status to filter by
|
||||||
|
@type status: string
|
||||||
|
@param admin_state_up: Admin state of the port to filter by
|
||||||
|
@type admin_state_up: bool
|
||||||
|
@param device_id: id of device to filter by
|
||||||
|
@type device_id: string
|
||||||
|
@param tenant_id: owner of the port to filter by
|
||||||
|
@type tenant_id: string
|
||||||
|
@param device_owner: device owner to filter by
|
||||||
|
@type device_owner: string
|
||||||
|
@param mac_address: mac address to filter by
|
||||||
|
@type mac_address: string
|
||||||
|
@param limit: page size
|
||||||
|
@type limit: int
|
||||||
|
@param marker: Id of the last item of the previous page
|
||||||
|
@type marker: string
|
||||||
|
@param page_reverse: direction of the page
|
||||||
|
@type page_reverse: bool
|
||||||
|
@return: list ports response
|
||||||
|
@rtype: Requests.response
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# TODO: add field query params to filter the response
|
params = {'id': port_id, 'network_id': network_id, 'name': name,
|
||||||
|
'status': status, 'admin_state_up': admin_state_up,
|
||||||
|
'device_id': device_id, 'tenant_id': tenant_id,
|
||||||
|
'device_owner': device_owner, 'mac_address': mac_address,
|
||||||
|
'limit': limit, 'marker': marker,
|
||||||
|
'page_reverse': page_reverse}
|
||||||
url = '{base_url}/ports'.format(base_url=self.url)
|
url = '{base_url}/ports'.format(base_url=self.url)
|
||||||
resp = self.request('GET', url,
|
resp = self.request('GET', url, params=params,
|
||||||
response_entity_type=Ports,
|
response_entity_type=Ports,
|
||||||
requestslib_kwargs=requestslib_kwargs)
|
requestslib_kwargs=requestslib_kwargs)
|
||||||
return resp
|
return resp
|
||||||
@ -146,6 +206,9 @@ class PortsClient(AutoMarshallingHTTPClient):
|
|||||||
"""
|
"""
|
||||||
@summary: Deletes a specified port
|
@summary: Deletes a specified port
|
||||||
@param string port_id: The UUID for the port
|
@param string port_id: The UUID for the port
|
||||||
|
@type port_id: string
|
||||||
|
@return: delete port response
|
||||||
|
@rtype: Requests.response
|
||||||
"""
|
"""
|
||||||
|
|
||||||
url = '{base_url}/ports/{port_id}'.format(
|
url = '{base_url}/ports/{port_id}'.format(
|
||||||
|
@ -25,12 +25,17 @@ class SubnetsClient(AutoMarshallingHTTPClient):
|
|||||||
def __init__(self, url, auth_token, serialize_format=None,
|
def __init__(self, url, auth_token, serialize_format=None,
|
||||||
deserialize_format=None, tenant_id=None):
|
deserialize_format=None, tenant_id=None):
|
||||||
"""
|
"""
|
||||||
@param string url: Base URL for the subnets service
|
@param url: Base URL for the subnets service
|
||||||
@param string auth_token: Auth token to be used for all requests
|
@type url: string
|
||||||
@param string serialize_format: Format for serializing requests
|
@param auth_token: Auth token to be used for all requests
|
||||||
@param string deserialize_format: Format for de-serializing responses
|
@type auth_token: string
|
||||||
@param string tenant_id: optional tenant id to be included in the
|
@param serialize_format: Format for serializing requests
|
||||||
header if given
|
@type serialize_format: string
|
||||||
|
@param deserialize_format: Format for de-serializing responses
|
||||||
|
@type deserialize_format: string
|
||||||
|
@param tenant_id: optional tenant id to be included in the header if
|
||||||
|
given
|
||||||
|
@type tenant_id: string
|
||||||
"""
|
"""
|
||||||
super(SubnetsClient, self).__init__(serialize_format,
|
super(SubnetsClient, self).__init__(serialize_format,
|
||||||
deserialize_format)
|
deserialize_format)
|
||||||
@ -54,23 +59,34 @@ class SubnetsClient(AutoMarshallingHTTPClient):
|
|||||||
enable_dhcp=None, requestslib_kwargs=None):
|
enable_dhcp=None, requestslib_kwargs=None):
|
||||||
"""
|
"""
|
||||||
@summary: Creates a Subnet
|
@summary: Creates a Subnet
|
||||||
@param string name: human readable name for the subnet,
|
@param name: human readable name for the subnet, may not be unique
|
||||||
may not be unique. (CRUD: CRU)
|
|
||||||
@param string tenant_id: owner of the network. (CRUD: CR)
|
|
||||||
@param string network_id: network subnet is associated with (CRUD: CR)
|
|
||||||
@param int ip_version: IP version 4 or 6 (CRUD: CR)
|
|
||||||
@param string cidr: represents IP range for the subnet and should be in
|
|
||||||
the form <network_address>/<prefix> (CRUD: CR)
|
|
||||||
@param string gateway_ip: default gateway used by devices in the subnet
|
|
||||||
(CRUD: CRUD)
|
|
||||||
@param list(str) dns_nameservers: DNS name servers used by subnet hosts
|
|
||||||
(CRUD: CRU)
|
(CRUD: CRU)
|
||||||
@param list(dict) allocation_pools: sub range of cidr available for
|
@type name: string
|
||||||
dynamic allocation to ports (CRUD: CR)
|
@param tenant_id: owner of the network. (CRUD: CR)
|
||||||
@param list(dict) host_routes: routes that should be used by devices
|
@type tenant_id: string
|
||||||
with IPs from this subnet (does not includes the local route,
|
@param network_id: network subnet is associated with (CRUD: CR)
|
||||||
CRUD: CRU)
|
@type network_id: string
|
||||||
@param bool enable_dhcp: whether DHCP is enabled (CRUD:CRU)
|
@param ip_version: IP version 4 or 6 (CRUD: CR)
|
||||||
|
@type ip_version: int
|
||||||
|
@param cidr: represents IP range for the subnet and should be in the
|
||||||
|
form <network_address>/<prefix> (CRUD: CR)
|
||||||
|
@type cidr: string
|
||||||
|
@param gateway_ip: default gateway used by devices in the subnet
|
||||||
|
(CRUD: CRUD)
|
||||||
|
@type gateway_ip: string
|
||||||
|
@param dns_nameservers: DNS name servers used by subnet hosts
|
||||||
|
(CRUD: CRU)
|
||||||
|
@type dns_nameservers: list(str)
|
||||||
|
@param allocation_pools: sub range of cidr available for dynamic
|
||||||
|
allocation to ports (CRUD: CRU)
|
||||||
|
@type allocation_pools: list(dict)
|
||||||
|
@param host_routes: routes that should be used by devices with IPs
|
||||||
|
from this subnet (does not includes the local route, CRUD: CRU)
|
||||||
|
@type host_routes: list(dict)
|
||||||
|
@param enable_dhcp: whether DHCP is enabled (CRUD:CRU)
|
||||||
|
@type enable_dhcp: bool
|
||||||
|
@return: subnet create response
|
||||||
|
@rtype: Requests.response
|
||||||
"""
|
"""
|
||||||
url = '{base_url}/subnets'.format(base_url=self.url)
|
url = '{base_url}/subnets'.format(base_url=self.url)
|
||||||
|
|
||||||
@ -90,20 +106,31 @@ class SubnetsClient(AutoMarshallingHTTPClient):
|
|||||||
|
|
||||||
def update_subnet(self, subnet_id, name=None, gateway_ip=None,
|
def update_subnet(self, subnet_id, name=None, gateway_ip=None,
|
||||||
dns_nameservers=None, host_routes=None,
|
dns_nameservers=None, host_routes=None,
|
||||||
enable_dhcp=None, requestslib_kwargs=None):
|
enable_dhcp=None, allocation_pools=None,
|
||||||
|
requestslib_kwargs=None):
|
||||||
"""
|
"""
|
||||||
@summary: Updates a specified Subnet
|
@summary: Updates a specified Subnet
|
||||||
@param string subnet_id: The UUID for the subnet
|
@param subnet_id: The UUID for the subnet
|
||||||
@param string name: human readable name for the subnet,
|
@type subnet_id: string
|
||||||
may not be unique. (CRUD: CRU)
|
@param name: human readable name for the subnet, may not be unique
|
||||||
@param string gateway_ip: default gateway used by devices in the subnet
|
|
||||||
(CRUD: CRUD)
|
|
||||||
@param list(str) dns_nameservers: DNS name servers used by subnet hosts
|
|
||||||
(CRUD: CRU)
|
(CRUD: CRU)
|
||||||
@param list(dict) host_routes: routes that should be used by devices
|
@type name: string
|
||||||
with IPs from this subnet (does not includes the local route,
|
@param gateway_ip: default gateway used by devices in the subnet
|
||||||
CRUD: CRU)
|
(CRUD: CRUD)
|
||||||
@param bool enable_dhcp: whether DHCP is enabled (CRUD:CRU)
|
@type gateway_ip: string
|
||||||
|
@param dns_nameservers: DNS name servers used by subnet hosts
|
||||||
|
(CRUD: CRU)
|
||||||
|
@type dns_nameservers: list(str)
|
||||||
|
@param host_routes: routes that should be used by devices with IPs
|
||||||
|
from this subnet (does not includes the local route (CRUD: CRU)
|
||||||
|
@type host_routes: list(dict)
|
||||||
|
@param enable_dhcp: whether DHCP is enabled (CRUD:CRU)
|
||||||
|
@type enable_dhcp: bool
|
||||||
|
@param allocation_pools: sub range of cidr available for dynamic
|
||||||
|
allocation to ports (CRUD: CRU)
|
||||||
|
@type allocation_pools: list(dict)
|
||||||
|
@return: subnet update response
|
||||||
|
@rtype: Requests.response
|
||||||
"""
|
"""
|
||||||
|
|
||||||
url = '{base_url}/subnets/{subnet_id}'.format(
|
url = '{base_url}/subnets/{subnet_id}'.format(
|
||||||
@ -112,7 +139,8 @@ class SubnetsClient(AutoMarshallingHTTPClient):
|
|||||||
request = SubnetRequest(name=name, gateway_ip=gateway_ip,
|
request = SubnetRequest(name=name, gateway_ip=gateway_ip,
|
||||||
dns_nameservers=dns_nameservers,
|
dns_nameservers=dns_nameservers,
|
||||||
host_routes=host_routes,
|
host_routes=host_routes,
|
||||||
enable_dhcp=enable_dhcp)
|
enable_dhcp=enable_dhcp,
|
||||||
|
allocation_pools=allocation_pools)
|
||||||
resp = self.request('PUT', url,
|
resp = self.request('PUT', url,
|
||||||
response_entity_type=Subnet,
|
response_entity_type=Subnet,
|
||||||
request_entity=request,
|
request_entity=request,
|
||||||
@ -122,7 +150,10 @@ class SubnetsClient(AutoMarshallingHTTPClient):
|
|||||||
def get_subnet(self, subnet_id, requestslib_kwargs=None):
|
def get_subnet(self, subnet_id, requestslib_kwargs=None):
|
||||||
"""
|
"""
|
||||||
@summary: Shows information for a specified subnet
|
@summary: Shows information for a specified subnet
|
||||||
@param string subnet_id: The UUID for the subnet
|
@param subnet_id: The UUID for the subnet
|
||||||
|
@type subnet_id: string
|
||||||
|
@return: get subnet response
|
||||||
|
@rtype: Requests.response
|
||||||
"""
|
"""
|
||||||
|
|
||||||
url = '{base_url}/subnets/{subnet_id}'.format(
|
url = '{base_url}/subnets/{subnet_id}'.format(
|
||||||
@ -132,14 +163,45 @@ class SubnetsClient(AutoMarshallingHTTPClient):
|
|||||||
requestslib_kwargs=requestslib_kwargs)
|
requestslib_kwargs=requestslib_kwargs)
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
def list_subnets(self, requestslib_kwargs=None):
|
def list_subnets(self, subnet_id=None, network_id=None, cidr=None,
|
||||||
|
tenant_id=None, gateway_ip=None, ip_version=None,
|
||||||
|
enable_dhcp=None, name=None, limit=None, marker=None,
|
||||||
|
page_reverse=None, requestslib_kwargs=None):
|
||||||
"""
|
"""
|
||||||
@summary: Lists subnets
|
@summary: Lists subnets, filtered by params if given
|
||||||
|
@param subnet_id: subnet ID to filter by
|
||||||
|
@type subnet_id: string
|
||||||
|
@param network_id: network ID to filter by
|
||||||
|
@type network_id: string
|
||||||
|
@param cidr: cider to filter by
|
||||||
|
@type cidr: string
|
||||||
|
@param tenant_id: owner of the network to filter by
|
||||||
|
@type tenant_id: string
|
||||||
|
@param gateway_ip: gateway_ip to filter by
|
||||||
|
@type gateway_ip: string
|
||||||
|
@param ip_version: IP version 4 or 6 to filter by
|
||||||
|
@type ip_version: int
|
||||||
|
@param enable_dhcp: enable_dhcp status to filter by
|
||||||
|
@type enable_dhcp: bool
|
||||||
|
@param name: subnet name to filter by
|
||||||
|
@type name: string
|
||||||
|
@param limit: page size
|
||||||
|
@type limit: int
|
||||||
|
@param marker: Id of the last item of the previous page
|
||||||
|
@type marker: string
|
||||||
|
@param page_reverse: direction of the page
|
||||||
|
@type page_reverse: bool
|
||||||
|
@return: list subnet response
|
||||||
|
@rtype: Requests.response
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# TODO: add field query params to filter the response
|
params = {'id': subnet_id, 'network_id': network_id, 'cidr': cidr,
|
||||||
|
'tenant_id': tenant_id, 'gteway_ip': gateway_ip,
|
||||||
|
'ip_version': ip_version, 'enable_dhcp': enable_dhcp,
|
||||||
|
'name': name, 'limit': limit, 'marker': marker,
|
||||||
|
'page_reverse': page_reverse}
|
||||||
url = '{base_url}/subnets'.format(base_url=self.url)
|
url = '{base_url}/subnets'.format(base_url=self.url)
|
||||||
resp = self.request('GET', url,
|
resp = self.request('GET', url, params=params,
|
||||||
response_entity_type=Subnets,
|
response_entity_type=Subnets,
|
||||||
requestslib_kwargs=requestslib_kwargs)
|
requestslib_kwargs=requestslib_kwargs)
|
||||||
return resp
|
return resp
|
||||||
@ -147,7 +209,10 @@ class SubnetsClient(AutoMarshallingHTTPClient):
|
|||||||
def delete_subnet(self, subnet_id, requestslib_kwargs=None):
|
def delete_subnet(self, subnet_id, requestslib_kwargs=None):
|
||||||
"""
|
"""
|
||||||
@summary: Deletes a specified subnet
|
@summary: Deletes a specified subnet
|
||||||
@param string subnet_id: The UUID for the subnet
|
@param subnet_id: The UUID for the subnet
|
||||||
|
@type subnet_id: string
|
||||||
|
@return: delete subnet response
|
||||||
|
@rtype: Requests.response
|
||||||
"""
|
"""
|
||||||
|
|
||||||
url = '{base_url}/subnets/{subnet_id}'.format(
|
url = '{base_url}/subnets/{subnet_id}'.format(
|
||||||
|
Loading…
Reference in New Issue
Block a user