| 1 |
# Copyright 2012 OpenStack Foundation. |
| 2 |
# Copyright 2015 Hewlett-Packard Development Company, L.P. |
| 3 |
# Copyright 2017 FUJITSU LIMITED |
| 4 |
# All Rights Reserved |
| 5 |
# |
| 6 |
# Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 7 |
# not use this file except in compliance with the License. You may obtain |
| 8 |
# a copy of the License at |
| 9 |
# |
| 10 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 11 |
# |
| 12 |
# Unless required by applicable law or agreed to in writing, software |
| 13 |
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 14 |
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 15 |
# License for the specific language governing permissions and limitations |
| 16 |
# under the License. |
| 17 |
# |
| 18 |
|
| 19 |
import inspect |
| 20 |
import itertools |
| 21 |
import logging |
| 22 |
import re |
| 23 |
import time |
| 24 |
import urllib.parse as urlparse |
| 25 |
|
| 26 |
import debtcollector.renames |
| 27 |
from keystoneauth1 import exceptions as ksa_exc |
| 28 |
import requests |
| 29 |
|
| 30 |
from neutronclient._i18n import _ |
| 31 |
from neutronclient import client |
| 32 |
from neutronclient.common import exceptions |
| 33 |
from neutronclient.common import extension as client_extension |
| 34 |
from neutronclient.common import serializer |
| 35 |
from neutronclient.common import utils |
| 36 |
|
| 37 |
|
| 38 |
_logger = logging.getLogger(__name__) |
| 39 |
|
| 40 |
HEX_ELEM = '[0-9A-Fa-f]' |
| 41 |
UUID_PATTERN = '-'.join([HEX_ELEM + '{8}', HEX_ELEM + '{4}', |
| 42 |
HEX_ELEM + '{4}', HEX_ELEM + '{4}', |
| 43 |
HEX_ELEM + '{12}']) |
| 44 |
|
| 45 |
|
| 46 |
def exception_handler_v20(status_code, error_content): |
| 47 |
"""Exception handler for API v2.0 client. |
| 48 |
|
| 49 |
This routine generates the appropriate Neutron exception according to |
| 50 |
the contents of the response body. |
| 51 |
|
| 52 |
:param status_code: HTTP error status code |
| 53 |
:param error_content: deserialized body of error response |
| 54 |
""" |
| 55 |
error_dict = None |
| 56 |
request_ids = error_content.request_ids |
| 57 |
if isinstance(error_content, dict): |
| 58 |
error_dict = error_content.get('NeutronError') |
| 59 |
# Find real error type |
| 60 |
client_exc = None |
| 61 |
if error_dict: |
| 62 |
# If Neutron key is found, it will definitely contain |
| 63 |
# a 'message' and 'type' keys? |
| 64 |
try: |
| 65 |
error_type = error_dict['type'] |
| 66 |
error_message = error_dict['message'] |
| 67 |
if error_dict['detail']: |
| 68 |
error_message += "\n" + error_dict['detail'] |
| 69 |
# If corresponding exception is defined, use it. |
| 70 |
client_exc = getattr(exceptions, '%sClient' % error_type, None) |
| 71 |
except Exception: |
| 72 |
error_message = "%s" % error_dict |
| 73 |
else: |
| 74 |
error_message = None |
| 75 |
if isinstance(error_content, dict): |
| 76 |
error_message = error_content.get('message') |
| 77 |
if not error_message: |
| 78 |
# If we end up here the exception was not a neutron error |
| 79 |
error_message = "%s-%s" % (status_code, error_content) |
| 80 |
|
| 81 |
# If an exception corresponding to the error type is not found, |
| 82 |
# look up per status-code client exception. |
| 83 |
if not client_exc: |
| 84 |
client_exc = exceptions.HTTP_EXCEPTION_MAP.get(status_code) |
| 85 |
# If there is no exception per status-code, |
| 86 |
# Use NeutronClientException as fallback. |
| 87 |
if not client_exc: |
| 88 |
client_exc = exceptions.NeutronClientException |
| 89 |
|
| 90 |
raise client_exc(message=error_message, |
| 91 |
status_code=status_code, |
| 92 |
request_ids=request_ids) |
| 93 |
|
| 94 |
|
| 95 |
class _RequestIdMixin(object): |
| 96 |
"""Wrapper class to expose x-openstack-request-id to the caller.""" |
| 97 |
def _request_ids_setup(self): |
| 98 |
self._request_ids = [] |
| 99 |
|
| 100 |
@property |
| 101 |
def request_ids(self): |
| 102 |
return self._request_ids |
| 103 |
|
| 104 |
def _append_request_ids(self, resp): |
| 105 |
"""Add request_ids as an attribute to the object |
| 106 |
|
| 107 |
:param resp: Response object or list of Response objects |
| 108 |
""" |
| 109 |
if isinstance(resp, list): |
| 110 |
# Add list of request_ids if response is of type list. |
| 111 |
for resp_obj in resp: |
| 112 |
self._append_request_id(resp_obj) |
| 113 |
elif resp is not None: |
| 114 |
# Add request_ids if response contains single object. |
| 115 |
self._append_request_id(resp) |
| 116 |
|
| 117 |
def _append_request_id(self, resp): |
| 118 |
if isinstance(resp, requests.Response): |
| 119 |
# Extract 'x-openstack-request-id' from headers if |
| 120 |
# response is a Response object. |
| 121 |
request_id = resp.headers.get('x-openstack-request-id') |
| 122 |
else: |
| 123 |
# If resp is of type string. |
| 124 |
request_id = resp |
| 125 |
if request_id: |
| 126 |
self._request_ids.append(request_id) |
| 127 |
|
| 128 |
|
| 129 |
class _DictWithMeta(dict, _RequestIdMixin): |
| 130 |
def __init__(self, values, resp): |
| 131 |
super(_DictWithMeta, self).__init__(values) |
| 132 |
self._request_ids_setup() |
| 133 |
self._append_request_ids(resp) |
| 134 |
|
| 135 |
|
| 136 |
class _TupleWithMeta(tuple, _RequestIdMixin): |
| 137 |
def __new__(cls, values, resp): |
| 138 |
return super(_TupleWithMeta, cls).__new__(cls, values) |
| 139 |
|
| 140 |
def __init__(self, values, resp): |
| 141 |
self._request_ids_setup() |
| 142 |
self._append_request_ids(resp) |
| 143 |
|
| 144 |
|
| 145 |
class _StrWithMeta(str, _RequestIdMixin): |
| 146 |
def __new__(cls, value, resp): |
| 147 |
return super(_StrWithMeta, cls).__new__(cls, value) |
| 148 |
|
| 149 |
def __init__(self, values, resp): |
| 150 |
self._request_ids_setup() |
| 151 |
self._append_request_ids(resp) |
| 152 |
|
| 153 |
|
| 154 |
class _GeneratorWithMeta(_RequestIdMixin): |
| 155 |
def __init__(self, paginate_func, collection, path, **params): |
| 156 |
self.paginate_func = paginate_func |
| 157 |
self.collection = collection |
| 158 |
self.path = path |
| 159 |
self.params = params |
| 160 |
self.generator = None |
| 161 |
self._request_ids_setup() |
| 162 |
|
| 163 |
def _paginate(self): |
| 164 |
for r in self.paginate_func( |
| 165 |
self.collection, self.path, **self.params): |
| 166 |
yield r, r.request_ids |
| 167 |
|
| 168 |
def __iter__(self): |
| 169 |
return self |
| 170 |
|
| 171 |
# Python 3 compatibility |
| 172 |
def __next__(self): |
| 173 |
return self.next() |
| 174 |
|
| 175 |
def next(self): |
| 176 |
if not self.generator: |
| 177 |
self.generator = self._paginate() |
| 178 |
|
| 179 |
try: |
| 180 |
obj, req_id = next(self.generator) |
| 181 |
self._append_request_ids(req_id) |
| 182 |
except StopIteration: |
| 183 |
raise StopIteration() |
| 184 |
|
| 185 |
return obj |
| 186 |
|
| 187 |
|
| 188 |
class ClientBase(object): |
| 189 |
"""Client for the OpenStack Neutron v2.0 API. |
| 190 |
|
| 191 |
:param string username: Username for authentication. (optional) |
| 192 |
:param string user_id: User ID for authentication. (optional) |
| 193 |
:param string password: Password for authentication. (optional) |
| 194 |
:param string token: Token for authentication. (optional) |
| 195 |
:param string tenant_name: DEPRECATED! Use project_name instead. |
| 196 |
:param string project_name: Project name. (optional) |
| 197 |
:param string tenant_id: DEPRECATED! Use project_id instead. |
| 198 |
:param string project_id: Project id. (optional) |
| 199 |
:param string auth_strategy: 'keystone' by default, 'noauth' for no |
| 200 |
authentication against keystone. (optional) |
| 201 |
:param string auth_url: Keystone service endpoint for authorization. |
| 202 |
:param string service_type: Network service type to pull from the |
| 203 |
keystone catalog (e.g. 'network') (optional) |
| 204 |
:param string endpoint_type: Network service endpoint type to pull from the |
| 205 |
keystone catalog (e.g. 'publicURL', |
| 206 |
'internalURL', or 'adminURL') (optional) |
| 207 |
:param string region_name: Name of a region to select when choosing an |
| 208 |
endpoint from the service catalog. |
| 209 |
:param string endpoint_url: A user-supplied endpoint URL for the neutron |
| 210 |
service. Lazy-authentication is possible for API |
| 211 |
service calls if endpoint is set at |
| 212 |
instantiation.(optional) |
| 213 |
:param integer timeout: Allows customization of the timeout for client |
| 214 |
http requests. (optional) |
| 215 |
:param bool insecure: SSL certificate validation. (optional) |
| 216 |
:param bool log_credentials: Allow for logging of passwords or not. |
| 217 |
Defaults to False. (optional) |
| 218 |
:param string ca_cert: SSL CA bundle file to use. (optional) |
| 219 |
:param cert: A client certificate to pass to requests. These are of the |
| 220 |
same form as requests expects. Either a single filename |
| 221 |
containing both the certificate and key or a tuple containing |
| 222 |
the path to the certificate then a path to the key. (optional) |
| 223 |
:param integer retries: How many times idempotent (GET, PUT, DELETE) |
| 224 |
requests to Neutron server should be retried if |
| 225 |
they fail (default: 0). |
| 226 |
:param bool raise_errors: If True then exceptions caused by connection |
| 227 |
failure are propagated to the caller. |
| 228 |
(default: True) |
| 229 |
:param session: Keystone client auth session to use. (optional) |
| 230 |
:param auth: Keystone auth plugin to use. (optional) |
| 231 |
|
| 232 |
Example:: |
| 233 |
|
| 234 |
from neutronclient.v2_0 import client |
| 235 |
neutron = client.Client(username=USER, |
| 236 |
password=PASS, |
| 237 |
project_name=PROJECT_NAME, |
| 238 |
auth_url=KEYSTONE_URL) |
| 239 |
|
| 240 |
nets = neutron.list_networks() |
| 241 |
... |
| 242 |
""" |
| 243 |
|
| 244 |
# API has no way to report plurals, so we have to hard code them |
| 245 |
# This variable should be overridden by a child class. |
| 246 |
EXTED_PLURALS = {} |
| 247 |
|
| 248 |
@debtcollector.renames.renamed_kwarg( |
| 249 |
'tenant_id', 'project_id', replace=True) |
| 250 |
def __init__(self, **kwargs): |
| 251 |
"""Initialize a new client for the Neutron v2.0 API.""" |
| 252 |
super(ClientBase, self).__init__() |
| 253 |
_logger.warning("The python binding code in neutronclient is " |
| 254 |
"deprecated in favor of OpenstackSDK, please use " |
| 255 |
"that as this will be removed in a future release.") |
| 256 |
self.retries = kwargs.pop('retries', 0) |
| 257 |
self.raise_errors = kwargs.pop('raise_errors', True) |
| 258 |
self.httpclient = client.construct_http_client(**kwargs) |
| 259 |
self.version = '2.0' |
| 260 |
self.action_prefix = "/v%s" % (self.version) |
| 261 |
self.retry_interval = 1 |
| 262 |
|
| 263 |
def _handle_fault_response(self, status_code, response_body, resp): |
| 264 |
# Create exception with HTTP status code and message |
| 265 |
_logger.debug("Error message: %s", response_body) |
| 266 |
# Add deserialized error message to exception arguments |
| 267 |
try: |
| 268 |
des_error_body = self.deserialize(response_body, status_code) |
| 269 |
except Exception: |
| 270 |
# If unable to deserialized body it is probably not a |
| 271 |
# Neutron error |
| 272 |
des_error_body = {'message': response_body} |
| 273 |
error_body = self._convert_into_with_meta(des_error_body, resp) |
| 274 |
# Raise the appropriate exception |
| 275 |
exception_handler_v20(status_code, error_body) |
| 276 |
|
| 277 |
def do_request(self, method, action, body=None, headers=None, params=None): |
| 278 |
# Add format and project_id |
| 279 |
action = self.action_prefix + action |
| 280 |
if isinstance(params, dict) and params: |
| 281 |
params = utils.safe_encode_dict(params) |
| 282 |
action += '?' + urlparse.urlencode(params, doseq=1) |
| 283 |
|
| 284 |
if body: |
| 285 |
body = self.serialize(body) |
| 286 |
|
| 287 |
resp, replybody = self.httpclient.do_request(action, method, body=body, |
| 288 |
headers=headers) |
| 289 |
|
| 290 |
status_code = resp.status_code |
| 291 |
if status_code in (requests.codes.ok, |
| 292 |
requests.codes.created, |
| 293 |
requests.codes.accepted, |
| 294 |
requests.codes.no_content): |
| 295 |
data = self.deserialize(replybody, status_code) |
| 296 |
return self._convert_into_with_meta(data, resp) |
| 297 |
else: |
| 298 |
if not replybody: |
| 299 |
replybody = resp.reason |
| 300 |
self._handle_fault_response(status_code, replybody, resp) |
| 301 |
|
| 302 |
def get_auth_info(self): |
| 303 |
return self.httpclient.get_auth_info() |
| 304 |
|
| 305 |
def serialize(self, data): |
| 306 |
"""Serializes a dictionary into JSON. |
| 307 |
|
| 308 |
A dictionary with a single key can be passed and it can contain any |
| 309 |
structure. |
| 310 |
""" |
| 311 |
if data is None: |
| 312 |
return None |
| 313 |
elif isinstance(data, dict): |
| 314 |
return serializer.Serializer().serialize(data) |
| 315 |
else: |
| 316 |
raise Exception(_("Unable to serialize object of type = '%s'") % |
| 317 |
type(data)) |
| 318 |
|
| 319 |
def deserialize(self, data, status_code): |
| 320 |
"""Deserializes a JSON string into a dictionary.""" |
| 321 |
if not data: |
| 322 |
return data |
| 323 |
return serializer.Serializer().deserialize( |
| 324 |
data)['body'] |
| 325 |
|
| 326 |
def retry_request(self, method, action, body=None, |
| 327 |
headers=None, params=None): |
| 328 |
"""Call do_request with the default retry configuration. |
| 329 |
|
| 330 |
Only idempotent requests should retry failed connection attempts. |
| 331 |
:raises: ConnectionFailed if the maximum # of retries is exceeded |
| 332 |
""" |
| 333 |
max_attempts = self.retries + 1 |
| 334 |
for i in range(max_attempts): |
| 335 |
try: |
| 336 |
return self.do_request(method, action, body=body, |
| 337 |
headers=headers, params=params) |
| 338 |
except (exceptions.ConnectionFailed, ksa_exc.ConnectionError): |
| 339 |
# Exception has already been logged by do_request() |
| 340 |
if i < self.retries: |
| 341 |
_logger.debug('Retrying connection to Neutron service') |
| 342 |
time.sleep(self.retry_interval) |
| 343 |
elif self.raise_errors: |
| 344 |
raise |
| 345 |
|
| 346 |
if self.retries: |
| 347 |
msg = (_("Failed to connect to Neutron server after %d attempts") |
| 348 |
% max_attempts) |
| 349 |
else: |
| 350 |
msg = _("Failed to connect Neutron server") |
| 351 |
|
| 352 |
raise exceptions.ConnectionFailed(reason=msg) |
| 353 |
|
| 354 |
def delete(self, action, body=None, headers=None, params=None): |
| 355 |
return self.retry_request("DELETE", action, body=body, |
| 356 |
headers=headers, params=params) |
| 357 |
|
| 358 |
def get(self, action, body=None, headers=None, params=None): |
| 359 |
return self.retry_request("GET", action, body=body, |
| 360 |
headers=headers, params=params) |
| 361 |
|
| 362 |
def post(self, action, body=None, headers=None, params=None): |
| 363 |
# Do not retry POST requests to avoid the orphan objects problem. |
| 364 |
return self.do_request("POST", action, body=body, |
| 365 |
headers=headers, params=params) |
| 366 |
|
| 367 |
def put(self, action, body=None, headers=None, params=None): |
| 368 |
return self.retry_request("PUT", action, body=body, |
| 369 |
headers=headers, params=params) |
| 370 |
|
| 371 |
def list(self, collection, path, retrieve_all=True, **params): |
| 372 |
if retrieve_all: |
| 373 |
res = [] |
| 374 |
request_ids = [] |
| 375 |
for r in self._pagination(collection, path, **params): |
| 376 |
res.extend(r[collection]) |
| 377 |
request_ids.extend(r.request_ids) |
| 378 |
return _DictWithMeta({collection: res}, request_ids) |
| 379 |
else: |
| 380 |
return _GeneratorWithMeta(self._pagination, collection, |
| 381 |
path, **params) |
| 382 |
|
| 383 |
def _pagination(self, collection, path, **params): |
| 384 |
if params.get('page_reverse', False): |
| 385 |
linkrel = 'previous' |
| 386 |
else: |
| 387 |
linkrel = 'next' |
| 388 |
next = True |
| 389 |
while next: |
| 390 |
res = self.get(path, params=params) |
| 391 |
yield res |
| 392 |
next = False |
| 393 |
try: |
| 394 |
for link in res['%s_links' % collection]: |
| 395 |
if link['rel'] == linkrel: |
| 396 |
query_str = urlparse.urlparse(link['href']).query |
| 397 |
params = urlparse.parse_qs(query_str) |
| 398 |
next = True |
| 399 |
break |
| 400 |
except KeyError: |
| 401 |
break |
| 402 |
|
| 403 |
def _convert_into_with_meta(self, item, resp): |
| 404 |
if item: |
| 405 |
if isinstance(item, dict): |
| 406 |
return _DictWithMeta(item, resp) |
| 407 |
elif isinstance(item, str): |
| 408 |
return _StrWithMeta(item, resp) |
| 409 |
else: |
| 410 |
return _TupleWithMeta((), resp) |
| 411 |
|
| 412 |
def get_resource_plural(self, resource): |
| 413 |
for k in self.EXTED_PLURALS: |
| 414 |
if self.EXTED_PLURALS[k] == resource: |
| 415 |
return k |
| 416 |
return resource + 's' |
| 417 |
|
| 418 |
def find_resource_by_id(self, resource, resource_id, cmd_resource=None, |
| 419 |
parent_id=None, fields=None): |
| 420 |
if not cmd_resource: |
| 421 |
cmd_resource = resource |
| 422 |
cmd_resource_plural = self.get_resource_plural(cmd_resource) |
| 423 |
resource_plural = self.get_resource_plural(resource) |
| 424 |
# TODO(amotoki): Use show_%s instead of list_%s |
| 425 |
obj_lister = getattr(self, "list_%s" % cmd_resource_plural) |
| 426 |
# perform search by id only if we are passing a valid UUID |
| 427 |
match = re.match(UUID_PATTERN, resource_id) |
| 428 |
collection = resource_plural |
| 429 |
if match: |
| 430 |
params = {'id': resource_id} |
| 431 |
if fields: |
| 432 |
params['fields'] = fields |
| 433 |
if parent_id: |
| 434 |
data = obj_lister(parent_id, **params) |
| 435 |
else: |
| 436 |
data = obj_lister(**params) |
| 437 |
if data and data[collection]: |
| 438 |
return data[collection][0] |
| 439 |
not_found_message = (_("Unable to find %(resource)s with id " |
| 440 |
"'%(id)s'") % |
| 441 |
{'resource': resource, 'id': resource_id}) |
| 442 |
# 404 is raised by exceptions.NotFound to simulate serverside behavior |
| 443 |
raise exceptions.NotFound(message=not_found_message) |
| 444 |
|
| 445 |
def _find_resource_by_name(self, resource, name, project_id=None, |
| 446 |
cmd_resource=None, parent_id=None, fields=None): |
| 447 |
if not cmd_resource: |
| 448 |
cmd_resource = resource |
| 449 |
cmd_resource_plural = self.get_resource_plural(cmd_resource) |
| 450 |
resource_plural = self.get_resource_plural(resource) |
| 451 |
obj_lister = getattr(self, "list_%s" % cmd_resource_plural) |
| 452 |
params = {'name': name} |
| 453 |
if fields: |
| 454 |
params['fields'] = fields |
| 455 |
if project_id: |
| 456 |
params['tenant_id'] = project_id |
| 457 |
if parent_id: |
| 458 |
data = obj_lister(parent_id, **params) |
| 459 |
else: |
| 460 |
data = obj_lister(**params) |
| 461 |
collection = resource_plural |
| 462 |
info = data[collection] |
| 463 |
if len(info) > 1: |
| 464 |
raise exceptions.NeutronClientNoUniqueMatch(resource=resource, |
| 465 |
name=name) |
| 466 |
elif len(info) == 0: |
| 467 |
not_found_message = (_("Unable to find %(resource)s with name " |
| 468 |
"'%(name)s'") % |
| 469 |
{'resource': resource, 'name': name}) |
| 470 |
# 404 is raised by exceptions.NotFound |
| 471 |
# to simulate serverside behavior |
| 472 |
raise exceptions.NotFound(message=not_found_message) |
| 473 |
else: |
| 474 |
return info[0] |
| 475 |
|
| 476 |
def find_resource(self, resource, name_or_id, project_id=None, |
| 477 |
cmd_resource=None, parent_id=None, fields=None): |
| 478 |
try: |
| 479 |
return self.find_resource_by_id(resource, name_or_id, |
| 480 |
cmd_resource, parent_id, fields) |
| 481 |
except exceptions.NotFound: |
| 482 |
try: |
| 483 |
return self._find_resource_by_name( |
| 484 |
resource, name_or_id, project_id, |
| 485 |
cmd_resource, parent_id, fields) |
| 486 |
except exceptions.NotFound: |
| 487 |
not_found_message = (_("Unable to find %(resource)s with name " |
| 488 |
"or id '%(name_or_id)s'") % |
| 489 |
{'resource': resource, |
| 490 |
'name_or_id': name_or_id}) |
| 491 |
raise exceptions.NotFound( |
| 492 |
message=not_found_message) |
| 493 |
|
| 494 |
|
| 495 |
class Client(ClientBase): |
| 496 |
|
| 497 |
networks_path = "/networks" |
| 498 |
network_path = "/networks/%s" |
| 499 |
ports_path = "/ports" |
| 500 |
port_path = "/ports/%s" |
| 501 |
port_bindings_path = "/ports/%s/bindings" |
| 502 |
port_binding_path = "/ports/%s/bindings/%s" |
| 503 |
port_binding_path_activate = "/ports/%s/bindings/%s/activate" |
| 504 |
subnets_path = "/subnets" |
| 505 |
subnet_path = "/subnets/%s" |
| 506 |
onboard_network_subnets_path = "/subnetpools/%s/onboard_network_subnets" |
| 507 |
subnetpools_path = "/subnetpools" |
| 508 |
subnetpool_path = "/subnetpools/%s" |
| 509 |
address_scopes_path = "/address-scopes" |
| 510 |
address_scope_path = "/address-scopes/%s" |
| 511 |
quotas_path = "/quotas" |
| 512 |
quota_path = "/quotas/%s" |
| 513 |
quota_default_path = "/quotas/%s/default" |
| 514 |
quota_details_path = "/quotas/%s/details.json" |
| 515 |
extensions_path = "/extensions" |
| 516 |
extension_path = "/extensions/%s" |
| 517 |
routers_path = "/routers" |
| 518 |
router_path = "/routers/%s" |
| 519 |
floatingips_path = "/floatingips" |
| 520 |
floatingip_path = "/floatingips/%s" |
| 521 |
port_forwardings_path = "/floatingips/%s/port_forwardings" |
| 522 |
port_forwarding_path = "/floatingips/%s/port_forwardings/%s" |
| 523 |
security_groups_path = "/security-groups" |
| 524 |
security_group_path = "/security-groups/%s" |
| 525 |
security_group_rules_path = "/security-group-rules" |
| 526 |
security_group_rule_path = "/security-group-rules/%s" |
| 527 |
segments_path = "/segments" |
| 528 |
segment_path = "/segments/%s" |
| 529 |
|
| 530 |
sfc_flow_classifiers_path = "/sfc/flow_classifiers" |
| 531 |
sfc_flow_classifier_path = "/sfc/flow_classifiers/%s" |
| 532 |
sfc_port_pairs_path = "/sfc/port_pairs" |
| 533 |
sfc_port_pair_path = "/sfc/port_pairs/%s" |
| 534 |
sfc_port_pair_groups_path = "/sfc/port_pair_groups" |
| 535 |
sfc_port_pair_group_path = "/sfc/port_pair_groups/%s" |
| 536 |
sfc_port_chains_path = "/sfc/port_chains" |
| 537 |
sfc_port_chain_path = "/sfc/port_chains/%s" |
| 538 |
sfc_service_graphs_path = "/sfc/service_graphs" |
| 539 |
sfc_service_graph_path = "/sfc/service_graphs/%s" |
| 540 |
|
| 541 |
endpoint_groups_path = "/vpn/endpoint-groups" |
| 542 |
endpoint_group_path = "/vpn/endpoint-groups/%s" |
| 543 |
vpnservices_path = "/vpn/vpnservices" |
| 544 |
vpnservice_path = "/vpn/vpnservices/%s" |
| 545 |
ipsecpolicies_path = "/vpn/ipsecpolicies" |
| 546 |
ipsecpolicy_path = "/vpn/ipsecpolicies/%s" |
| 547 |
ikepolicies_path = "/vpn/ikepolicies" |
| 548 |
ikepolicy_path = "/vpn/ikepolicies/%s" |
| 549 |
ipsec_site_connections_path = "/vpn/ipsec-site-connections" |
| 550 |
ipsec_site_connection_path = "/vpn/ipsec-site-connections/%s" |
| 551 |
|
| 552 |
lbaas_loadbalancers_path = "/lbaas/loadbalancers" |
| 553 |
lbaas_loadbalancer_path = "/lbaas/loadbalancers/%s" |
| 554 |
lbaas_loadbalancer_path_stats = "/lbaas/loadbalancers/%s/stats" |
| 555 |
lbaas_loadbalancer_path_status = "/lbaas/loadbalancers/%s/statuses" |
| 556 |
lbaas_listeners_path = "/lbaas/listeners" |
| 557 |
lbaas_listener_path = "/lbaas/listeners/%s" |
| 558 |
lbaas_l7policies_path = "/lbaas/l7policies" |
| 559 |
lbaas_l7policy_path = lbaas_l7policies_path + "/%s" |
| 560 |
lbaas_l7rules_path = lbaas_l7policy_path + "/rules" |
| 561 |
lbaas_l7rule_path = lbaas_l7rules_path + "/%s" |
| 562 |
lbaas_pools_path = "/lbaas/pools" |
| 563 |
lbaas_pool_path = "/lbaas/pools/%s" |
| 564 |
lbaas_healthmonitors_path = "/lbaas/healthmonitors" |
| 565 |
lbaas_healthmonitor_path = "/lbaas/healthmonitors/%s" |
| 566 |
lbaas_members_path = lbaas_pool_path + "/members" |
| 567 |
lbaas_member_path = lbaas_pool_path + "/members/%s" |
| 568 |
|
| 569 |
vips_path = "/lb/vips" |
| 570 |
vip_path = "/lb/vips/%s" |
| 571 |
pools_path = "/lb/pools" |
| 572 |
pool_path = "/lb/pools/%s" |
| 573 |
pool_path_stats = "/lb/pools/%s/stats" |
| 574 |
members_path = "/lb/members" |
| 575 |
member_path = "/lb/members/%s" |
| 576 |
health_monitors_path = "/lb/health_monitors" |
| 577 |
health_monitor_path = "/lb/health_monitors/%s" |
| 578 |
associate_pool_health_monitors_path = "/lb/pools/%s/health_monitors" |
| 579 |
disassociate_pool_health_monitors_path = ( |
| 580 |
"/lb/pools/%(pool)s/health_monitors/%(health_monitor)s") |
| 581 |
qos_queues_path = "/qos-queues" |
| 582 |
qos_queue_path = "/qos-queues/%s" |
| 583 |
agents_path = "/agents" |
| 584 |
agent_path = "/agents/%s" |
| 585 |
network_gateways_path = "/network-gateways" |
| 586 |
network_gateway_path = "/network-gateways/%s" |
| 587 |
gateway_devices_path = "/gateway-devices" |
| 588 |
gateway_device_path = "/gateway-devices/%s" |
| 589 |
service_providers_path = "/service-providers" |
| 590 |
metering_labels_path = "/metering/metering-labels" |
| 591 |
metering_label_path = "/metering/metering-labels/%s" |
| 592 |
metering_label_rules_path = "/metering/metering-label-rules" |
| 593 |
metering_label_rule_path = "/metering/metering-label-rules/%s" |
| 594 |
|
| 595 |
DHCP_NETS = '/dhcp-networks' |
| 596 |
DHCP_AGENTS = '/dhcp-agents' |
| 597 |
L3_ROUTERS = '/l3-routers' |
| 598 |
L3_AGENTS = '/l3-agents' |
| 599 |
LOADBALANCER_POOLS = '/loadbalancer-pools' |
| 600 |
LOADBALANCER_AGENT = '/loadbalancer-agent' |
| 601 |
AGENT_LOADBALANCERS = '/agent-loadbalancers' |
| 602 |
LOADBALANCER_HOSTING_AGENT = '/loadbalancer-hosting-agent' |
| 603 |
firewall_rules_path = "/fw/firewall_rules" |
| 604 |
firewall_rule_path = "/fw/firewall_rules/%s" |
| 605 |
firewall_policies_path = "/fw/firewall_policies" |
| 606 |
firewall_policy_path = "/fw/firewall_policies/%s" |
| 607 |
firewall_policy_insert_path = "/fw/firewall_policies/%s/insert_rule" |
| 608 |
firewall_policy_remove_path = "/fw/firewall_policies/%s/remove_rule" |
| 609 |
firewalls_path = "/fw/firewalls" |
| 610 |
firewall_path = "/fw/firewalls/%s" |
| 611 |
fwaas_firewall_groups_path = "/fwaas/firewall_groups" |
| 612 |
fwaas_firewall_group_path = "/fwaas/firewall_groups/%s" |
| 613 |
fwaas_firewall_rules_path = "/fwaas/firewall_rules" |
| 614 |
fwaas_firewall_rule_path = "/fwaas/firewall_rules/%s" |
| 615 |
fwaas_firewall_policies_path = "/fwaas/firewall_policies" |
| 616 |
fwaas_firewall_policy_path = "/fwaas/firewall_policies/%s" |
| 617 |
fwaas_firewall_policy_insert_path = \ |
| 618 |
"/fwaas/firewall_policies/%s/insert_rule" |
| 619 |
fwaas_firewall_policy_remove_path = \ |
| 620 |
"/fwaas/firewall_policies/%s/remove_rule" |
| 621 |
rbac_policies_path = "/rbac-policies" |
| 622 |
rbac_policy_path = "/rbac-policies/%s" |
| 623 |
qos_policies_path = "/qos/policies" |
| 624 |
qos_policy_path = "/qos/policies/%s" |
| 625 |
qos_bandwidth_limit_rules_path = "/qos/policies/%s/bandwidth_limit_rules" |
| 626 |
qos_bandwidth_limit_rule_path = "/qos/policies/%s/bandwidth_limit_rules/%s" |
| 627 |
qos_packet_rate_limit_rules_path = \ |
| 628 |
"/qos/policies/%s/packet_rate_limit_rules" |
| 629 |
qos_packet_rate_limit_rule_path = \ |
| 630 |
"/qos/policies/%s/packet_rate_limit_rules/%s" |
| 631 |
qos_dscp_marking_rules_path = "/qos/policies/%s/dscp_marking_rules" |
| 632 |
qos_dscp_marking_rule_path = "/qos/policies/%s/dscp_marking_rules/%s" |
| 633 |
qos_minimum_bandwidth_rules_path = \ |
| 634 |
"/qos/policies/%s/minimum_bandwidth_rules" |
| 635 |
qos_minimum_bandwidth_rule_path = \ |
| 636 |
"/qos/policies/%s/minimum_bandwidth_rules/%s" |
| 637 |
qos_minimum_packet_rate_rules_path = \ |
| 638 |
"/qos/policies/%s/minimum_packet_rate_rules" |
| 639 |
qos_minimum_packet_rate_rule_path = \ |
| 640 |
"/qos/policies/%s/minimum_packet_rate_rules/%s" |
| 641 |
qos_rule_types_path = "/qos/rule-types" |
| 642 |
qos_rule_type_path = "/qos/rule-types/%s" |
| 643 |
flavors_path = "/flavors" |
| 644 |
flavor_path = "/flavors/%s" |
| 645 |
service_profiles_path = "/service_profiles" |
| 646 |
service_profile_path = "/service_profiles/%s" |
| 647 |
flavor_profile_bindings_path = flavor_path + service_profiles_path |
| 648 |
flavor_profile_binding_path = flavor_path + service_profile_path |
| 649 |
availability_zones_path = "/availability_zones" |
| 650 |
auto_allocated_topology_path = "/auto-allocated-topology/%s" |
| 651 |
BGP_DRINSTANCES = "/bgp-drinstances" |
| 652 |
BGP_DRINSTANCE = "/bgp-drinstance/%s" |
| 653 |
BGP_DRAGENTS = "/bgp-dragents" |
| 654 |
BGP_DRAGENT = "/bgp-dragents/%s" |
| 655 |
bgp_speakers_path = "/bgp-speakers" |
| 656 |
bgp_speaker_path = "/bgp-speakers/%s" |
| 657 |
bgp_peers_path = "/bgp-peers" |
| 658 |
bgp_peer_path = "/bgp-peers/%s" |
| 659 |
network_ip_availabilities_path = '/network-ip-availabilities' |
| 660 |
network_ip_availability_path = '/network-ip-availabilities/%s' |
| 661 |
tags_path = "/%s/%s/tags" |
| 662 |
tag_path = "/%s/%s/tags/%s" |
| 663 |
trunks_path = "/trunks" |
| 664 |
trunk_path = "/trunks/%s" |
| 665 |
subports_path = "/trunks/%s/get_subports" |
| 666 |
subports_add_path = "/trunks/%s/add_subports" |
| 667 |
subports_remove_path = "/trunks/%s/remove_subports" |
| 668 |
bgpvpns_path = "/bgpvpn/bgpvpns" |
| 669 |
bgpvpn_path = "/bgpvpn/bgpvpns/%s" |
| 670 |
bgpvpn_network_associations_path =\ |
| 671 |
"/bgpvpn/bgpvpns/%s/network_associations" |
| 672 |
bgpvpn_network_association_path =\ |
| 673 |
"/bgpvpn/bgpvpns/%s/network_associations/%s" |
| 674 |
bgpvpn_router_associations_path = "/bgpvpn/bgpvpns/%s/router_associations" |
| 675 |
bgpvpn_router_association_path =\ |
| 676 |
"/bgpvpn/bgpvpns/%s/router_associations/%s" |
| 677 |
bgpvpn_port_associations_path = "/bgpvpn/bgpvpns/%s/port_associations" |
| 678 |
bgpvpn_port_association_path = "/bgpvpn/bgpvpns/%s/port_associations/%s" |
| 679 |
network_logs_path = "/log/logs" |
| 680 |
network_log_path = "/log/logs/%s" |
| 681 |
network_loggables_path = "/log/loggable-resources" |
| 682 |
|
| 683 |
# API has no way to report plurals, so we have to hard code them |
| 684 |
EXTED_PLURALS = {'routers': 'router', |
| 685 |
'floatingips': 'floatingip', |
| 686 |
'service_types': 'service_type', |
| 687 |
'service_definitions': 'service_definition', |
| 688 |
'security_groups': 'security_group', |
| 689 |
'security_group_rules': 'security_group_rule', |
| 690 |
'segments': 'segment', |
| 691 |
'ipsecpolicies': 'ipsecpolicy', |
| 692 |
'ikepolicies': 'ikepolicy', |
| 693 |
'ipsec_site_connections': 'ipsec_site_connection', |
| 694 |
'vpnservices': 'vpnservice', |
| 695 |
'endpoint_groups': 'endpoint_group', |
| 696 |
'vips': 'vip', |
| 697 |
'pools': 'pool', |
| 698 |
'members': 'member', |
| 699 |
'health_monitors': 'health_monitor', |
| 700 |
'quotas': 'quota', |
| 701 |
'service_providers': 'service_provider', |
| 702 |
'firewall_rules': 'firewall_rule', |
| 703 |
'firewall_policies': 'firewall_policy', |
| 704 |
'firewalls': 'firewall', |
| 705 |
'fwaas_firewall_rules': 'fwaas_firewall_rule', |
| 706 |
'fwaas_firewall_policies': 'fwaas_firewall_policy', |
| 707 |
'fwaas_firewall_groups': 'fwaas_firewall_group', |
| 708 |
'metering_labels': 'metering_label', |
| 709 |
'metering_label_rules': 'metering_label_rule', |
| 710 |
'loadbalancers': 'loadbalancer', |
| 711 |
'listeners': 'listener', |
| 712 |
'l7rules': 'l7rule', |
| 713 |
'l7policies': 'l7policy', |
| 714 |
'lbaas_l7policies': 'lbaas_l7policy', |
| 715 |
'lbaas_pools': 'lbaas_pool', |
| 716 |
'lbaas_healthmonitors': 'lbaas_healthmonitor', |
| 717 |
'lbaas_members': 'lbaas_member', |
| 718 |
'healthmonitors': 'healthmonitor', |
| 719 |
'rbac_policies': 'rbac_policy', |
| 720 |
'address_scopes': 'address_scope', |
| 721 |
'qos_policies': 'qos_policy', |
| 722 |
'policies': 'policy', |
| 723 |
'bandwidth_limit_rules': 'bandwidth_limit_rule', |
| 724 |
'packet_rate_limit_rules': 'packet_rate_limit_rule', |
| 725 |
'minimum_bandwidth_rules': 'minimum_bandwidth_rule', |
| 726 |
'minimum_packet_rate_rules': 'minimum_packet_rate_rule', |
| 727 |
'rules': 'rule', |
| 728 |
'dscp_marking_rules': 'dscp_marking_rule', |
| 729 |
'rule_types': 'rule_type', |
| 730 |
'flavors': 'flavor', |
| 731 |
'bgp_speakers': 'bgp_speaker', |
| 732 |
'bgp_peers': 'bgp_peer', |
| 733 |
'network_ip_availabilities': 'network_ip_availability', |
| 734 |
'trunks': 'trunk', |
| 735 |
'bgpvpns': 'bgpvpn', |
| 736 |
'network_associations': 'network_association', |
| 737 |
'router_associations': 'router_association', |
| 738 |
'port_associations': 'port_association', |
| 739 |
'flow_classifiers': 'flow_classifier', |
| 740 |
'port_pairs': 'port_pair', |
| 741 |
'port_pair_groups': 'port_pair_group', |
| 742 |
'port_chains': 'port_chain', |
| 743 |
'service_graphs': 'service_graph', |
| 744 |
'logs': 'log', |
| 745 |
'loggable_resources': 'loggable_resource', |
| 746 |
} |
| 747 |
|
| 748 |
def list_ext(self, collection, path, retrieve_all, **_params): |
| 749 |
"""Client extension hook for list.""" |
| 750 |
return self.list(collection, path, retrieve_all, **_params) |
| 751 |
|
| 752 |
def show_ext(self, path, id, **_params): |
| 753 |
"""Client extension hook for show.""" |
| 754 |
return self.get(path % id, params=_params) |
| 755 |
|
| 756 |
def create_ext(self, path, body=None): |
| 757 |
"""Client extension hook for create.""" |
| 758 |
return self.post(path, body=body) |
| 759 |
|
| 760 |
def update_ext(self, path, id, body=None): |
| 761 |
"""Client extension hook for update.""" |
| 762 |
return self.put(path % id, body=body) |
| 763 |
|
| 764 |
def delete_ext(self, path, id): |
| 765 |
"""Client extension hook for delete.""" |
| 766 |
return self.delete(path % id) |
| 767 |
|
| 768 |
def get_quotas_tenant(self, **_params): |
| 769 |
"""Fetch project info for following quota operation.""" |
| 770 |
return self.get(self.quota_path % 'tenant', params=_params) |
| 771 |
|
| 772 |
def list_quotas(self, **_params): |
| 773 |
"""Fetch all projects' quotas.""" |
| 774 |
return self.get(self.quotas_path, params=_params) |
| 775 |
|
| 776 |
@debtcollector.renames.renamed_kwarg( |
| 777 |
'tenant_id', 'project_id', replace=True) |
| 778 |
def show_quota(self, project_id, **_params): |
| 779 |
"""Fetch information of a certain project's quotas.""" |
| 780 |
return self.get(self.quota_path % (project_id), params=_params) |
| 781 |
|
| 782 |
@debtcollector.renames.renamed_kwarg( |
| 783 |
'tenant_id', 'project_id', replace=True) |
| 784 |
def show_quota_details(self, project_id, **_params): |
| 785 |
"""Fetch information of a certain project's quota details.""" |
| 786 |
return self.get(self.quota_details_path % (project_id), |
| 787 |
params=_params) |
| 788 |
|
| 789 |
@debtcollector.renames.renamed_kwarg( |
| 790 |
'tenant_id', 'project_id', replace=True) |
| 791 |
def show_quota_default(self, project_id, **_params): |
| 792 |
"""Fetch information of a certain project's default quotas.""" |
| 793 |
return self.get(self.quota_default_path % (project_id), params=_params) |
| 794 |
|
| 795 |
@debtcollector.renames.renamed_kwarg( |
| 796 |
'tenant_id', 'project_id', replace=True) |
| 797 |
def update_quota(self, project_id, body=None): |
| 798 |
"""Update a project's quotas.""" |
| 799 |
return self.put(self.quota_path % (project_id), body=body) |
| 800 |
|
| 801 |
@debtcollector.renames.renamed_kwarg( |
| 802 |
'tenant_id', 'project_id', replace=True) |
| 803 |
def delete_quota(self, project_id): |
| 804 |
"""Delete the specified project's quota values.""" |
| 805 |
return self.delete(self.quota_path % (project_id)) |
| 806 |
|
| 807 |
def list_extensions(self, **_params): |
| 808 |
"""Fetch a list of all extensions on server side.""" |
| 809 |
return self.get(self.extensions_path, params=_params) |
| 810 |
|
| 811 |
def show_extension(self, ext_alias, **_params): |
| 812 |
"""Fetches information of a certain extension.""" |
| 813 |
return self.get(self.extension_path % ext_alias, params=_params) |
| 814 |
|
| 815 |
def list_ports(self, retrieve_all=True, **_params): |
| 816 |
"""Fetches a list of all ports for a project.""" |
| 817 |
# Pass filters in "params" argument to do_request |
| 818 |
return self.list('ports', self.ports_path, retrieve_all, |
| 819 |
**_params) |
| 820 |
|
| 821 |
def show_port(self, port, **_params): |
| 822 |
"""Fetches information of a certain port.""" |
| 823 |
return self.get(self.port_path % (port), params=_params) |
| 824 |
|
| 825 |
def create_port(self, body=None): |
| 826 |
"""Creates a new port.""" |
| 827 |
return self.post(self.ports_path, body=body) |
| 828 |
|
| 829 |
def update_port(self, port, body=None, revision_number=None): |
| 830 |
"""Updates a port.""" |
| 831 |
return self._update_resource(self.port_path % (port), body=body, |
| 832 |
revision_number=revision_number) |
| 833 |
|
| 834 |
def delete_port(self, port): |
| 835 |
"""Deletes the specified port.""" |
| 836 |
return self.delete(self.port_path % (port)) |
| 837 |
|
| 838 |
def create_port_binding(self, port_id, body=None): |
| 839 |
"""Creates a new port binding.""" |
| 840 |
return self.post(self.port_bindings_path % port_id, body=body) |
| 841 |
|
| 842 |
def delete_port_binding(self, port_id, host_id): |
| 843 |
"""Deletes the specified port binding.""" |
| 844 |
return self.delete(self.port_binding_path % (port_id, host_id)) |
| 845 |
|
| 846 |
def show_port_binding(self, port_id, host_id, **_params): |
| 847 |
"""Fetches information for a certain port binding.""" |
| 848 |
return self.get(self.port_binding_path % (port_id, host_id), |
| 849 |
params=_params) |
| 850 |
|
| 851 |
def list_port_bindings(self, port_id, retrieve_all=True, **_params): |
| 852 |
"""Fetches a list of all bindings for a certain port.""" |
| 853 |
return self.list('bindings', self.port_bindings_path % port_id, |
| 854 |
retrieve_all, **_params) |
| 855 |
|
| 856 |
def activate_port_binding(self, port_id, host_id): |
| 857 |
"""Activates a port binding.""" |
| 858 |
return self.put(self.port_binding_path_activate % (port_id, host_id)) |
| 859 |
|
| 860 |
def list_networks(self, retrieve_all=True, **_params): |
| 861 |
"""Fetches a list of all networks for a project.""" |
| 862 |
# Pass filters in "params" argument to do_request |
| 863 |
return self.list('networks', self.networks_path, retrieve_all, |
| 864 |
**_params) |
| 865 |
|
| 866 |
def show_network(self, network, **_params): |
| 867 |
"""Fetches information of a certain network.""" |
| 868 |
return self.get(self.network_path % (network), params=_params) |
| 869 |
|
| 870 |
def create_network(self, body=None): |
| 871 |
"""Creates a new network.""" |
| 872 |
return self.post(self.networks_path, body=body) |
| 873 |
|
| 874 |
def update_network(self, network, body=None, revision_number=None): |
| 875 |
"""Updates a network.""" |
| 876 |
return self._update_resource(self.network_path % (network), body=body, |
| 877 |
revision_number=revision_number) |
| 878 |
|
| 879 |
def delete_network(self, network): |
| 880 |
"""Deletes the specified network.""" |
| 881 |
return self.delete(self.network_path % (network)) |
| 882 |
|
| 883 |
def list_subnets(self, retrieve_all=True, **_params): |
| 884 |
"""Fetches a list of all subnets for a project.""" |
| 885 |
return self.list('subnets', self.subnets_path, retrieve_all, |
| 886 |
**_params) |
| 887 |
|
| 888 |
def show_subnet(self, subnet, **_params): |
| 889 |
"""Fetches information of a certain subnet.""" |
| 890 |
return self.get(self.subnet_path % (subnet), params=_params) |
| 891 |
|
| 892 |
def create_subnet(self, body=None): |
| 893 |
"""Creates a new subnet.""" |
| 894 |
return self.post(self.subnets_path, body=body) |
| 895 |
|
| 896 |
def update_subnet(self, subnet, body=None, revision_number=None): |
| 897 |
"""Updates a subnet.""" |
| 898 |
return self._update_resource(self.subnet_path % (subnet), body=body, |
| 899 |
revision_number=revision_number) |
| 900 |
|
| 901 |
def delete_subnet(self, subnet): |
| 902 |
"""Deletes the specified subnet.""" |
| 903 |
return self.delete(self.subnet_path % (subnet)) |
| 904 |
|
| 905 |
def list_subnetpools(self, retrieve_all=True, **_params): |
| 906 |
"""Fetches a list of all subnetpools for a project.""" |
| 907 |
return self.list('subnetpools', self.subnetpools_path, retrieve_all, |
| 908 |
**_params) |
| 909 |
|
| 910 |
def show_subnetpool(self, subnetpool, **_params): |
| 911 |
"""Fetches information of a certain subnetpool.""" |
| 912 |
return self.get(self.subnetpool_path % (subnetpool), params=_params) |
| 913 |
|
| 914 |
def create_subnetpool(self, body=None): |
| 915 |
"""Creates a new subnetpool.""" |
| 916 |
return self.post(self.subnetpools_path, body=body) |
| 917 |
|
| 918 |
def update_subnetpool(self, subnetpool, body=None, revision_number=None): |
| 919 |
"""Updates a subnetpool.""" |
| 920 |
return self._update_resource(self.subnetpool_path % (subnetpool), |
| 921 |
body=body, |
| 922 |
revision_number=revision_number) |
| 923 |
|
| 924 |
def delete_subnetpool(self, subnetpool): |
| 925 |
"""Deletes the specified subnetpool.""" |
| 926 |
return self.delete(self.subnetpool_path % (subnetpool)) |
| 927 |
|
| 928 |
def list_routers(self, retrieve_all=True, **_params): |
| 929 |
"""Fetches a list of all routers for a project.""" |
| 930 |
# Pass filters in "params" argument to do_request |
| 931 |
return self.list('routers', self.routers_path, retrieve_all, |
| 932 |
**_params) |
| 933 |
|
| 934 |
def show_router(self, router, **_params): |
| 935 |
"""Fetches information of a certain router.""" |
| 936 |
return self.get(self.router_path % (router), params=_params) |
| 937 |
|
| 938 |
def create_router(self, body=None): |
| 939 |
"""Creates a new router.""" |
| 940 |
return self.post(self.routers_path, body=body) |
| 941 |
|
| 942 |
def update_router(self, router, body=None, revision_number=None): |
| 943 |
"""Updates a router.""" |
| 944 |
return self._update_resource(self.router_path % (router), body=body, |
| 945 |
revision_number=revision_number) |
| 946 |
|
| 947 |
def delete_router(self, router): |
| 948 |
"""Deletes the specified router.""" |
| 949 |
return self.delete(self.router_path % (router)) |
| 950 |
|
| 951 |
def list_address_scopes(self, retrieve_all=True, **_params): |
| 952 |
"""Fetches a list of all address scopes for a project.""" |
| 953 |
return self.list('address_scopes', self.address_scopes_path, |
| 954 |
retrieve_all, **_params) |
| 955 |
|
| 956 |
def show_address_scope(self, address_scope, **_params): |
| 957 |
"""Fetches information of a certain address scope.""" |
| 958 |
return self.get(self.address_scope_path % (address_scope), |
| 959 |
params=_params) |
| 960 |
|
| 961 |
def create_address_scope(self, body=None): |
| 962 |
"""Creates a new address scope.""" |
| 963 |
return self.post(self.address_scopes_path, body=body) |
| 964 |
|
| 965 |
def update_address_scope(self, address_scope, body=None): |
| 966 |
"""Updates a address scope.""" |
| 967 |
return self.put(self.address_scope_path % (address_scope), body=body) |
| 968 |
|
| 969 |
def delete_address_scope(self, address_scope): |
| 970 |
"""Deletes the specified address scope.""" |
| 971 |
return self.delete(self.address_scope_path % (address_scope)) |
| 972 |
|
| 973 |
def add_interface_router(self, router, body=None): |
| 974 |
"""Adds an internal network interface to the specified router.""" |
| 975 |
return self.put((self.router_path % router) + "/add_router_interface", |
| 976 |
body=body) |
| 977 |
|
| 978 |
def remove_interface_router(self, router, body=None): |
| 979 |
"""Removes an internal network interface from the specified router.""" |
| 980 |
return self.put((self.router_path % router) + |
| 981 |
"/remove_router_interface", body=body) |
| 982 |
|
| 983 |
def add_extra_routes_to_router(self, router, body=None): |
| 984 |
"""Adds extra routes to the specified router.""" |
| 985 |
return self.put((self.router_path % router) + "/add_extraroutes", |
| 986 |
body=body) |
| 987 |
|
| 988 |
def remove_extra_routes_from_router(self, router, body=None): |
| 989 |
"""Removes extra routes from the specified router.""" |
| 990 |
return self.put((self.router_path % router) + "/remove_extraroutes", |
| 991 |
body=body) |
| 992 |
|
| 993 |
def add_gateway_router(self, router, body=None): |
| 994 |
"""Adds an external network gateway to the specified router.""" |
| 995 |
return self.put((self.router_path % router), |
| 996 |
body={'router': {'external_gateway_info': body}}) |
| 997 |
|
| 998 |
def remove_gateway_router(self, router): |
| 999 |
"""Removes an external network gateway from the specified router.""" |
| 1000 |
return self.put((self.router_path % router), |
| 1001 |
body={'router': {'external_gateway_info': {}}}) |
| 1002 |
|
| 1003 |
def list_floatingips(self, retrieve_all=True, **_params): |
| 1004 |
"""Fetches a list of all floatingips for a project.""" |
| 1005 |
# Pass filters in "params" argument to do_request |
| 1006 |
return self.list('floatingips', self.floatingips_path, retrieve_all, |
| 1007 |
**_params) |
| 1008 |
|
| 1009 |
def show_floatingip(self, floatingip, **_params): |
| 1010 |
"""Fetches information of a certain floatingip.""" |
| 1011 |
return self.get(self.floatingip_path % (floatingip), params=_params) |
| 1012 |
|
| 1013 |
def create_floatingip(self, body=None): |
| 1014 |
"""Creates a new floatingip.""" |
| 1015 |
return self.post(self.floatingips_path, body=body) |
| 1016 |
|
| 1017 |
def update_floatingip(self, floatingip, body=None, revision_number=None): |
| 1018 |
"""Updates a floatingip.""" |
| 1019 |
return self._update_resource(self.floatingip_path % (floatingip), |
| 1020 |
body=body, |
| 1021 |
revision_number=revision_number) |
| 1022 |
|
| 1023 |
def delete_floatingip(self, floatingip): |
| 1024 |
"""Deletes the specified floatingip.""" |
| 1025 |
return self.delete(self.floatingip_path % (floatingip)) |
| 1026 |
|
| 1027 |
def show_port_forwarding(self, floatingip, portforwarding): |
| 1028 |
"""Fetches information of a certain portforwarding""" |
| 1029 |
return self.get(self.port_forwarding_path % (floatingip, |
| 1030 |
portforwarding)) |
| 1031 |
|
| 1032 |
def list_port_forwardings(self, floatingip, retrieve_all=True, **_params): |
| 1033 |
"""Fetches a list of all portforwardings for a floatingip.""" |
| 1034 |
return self.list('port_forwardings', |
| 1035 |
self.port_forwardings_path % floatingip, retrieve_all, |
| 1036 |
**_params) |
| 1037 |
|
| 1038 |
def create_port_forwarding(self, floatingip, body=None): |
| 1039 |
"""Creates a new portforwarding.""" |
| 1040 |
return self.post(self.port_forwardings_path % floatingip, body=body) |
| 1041 |
|
| 1042 |
def delete_port_forwarding(self, floatingip, portforwarding): |
| 1043 |
"""Deletes the specified portforwarding.""" |
| 1044 |
return self.delete(self.port_forwarding_path % (floatingip, |
| 1045 |
portforwarding)) |
| 1046 |
|
| 1047 |
def update_port_forwarding(self, floatingip, portforwarding, body=None): |
| 1048 |
"""Updates a portforwarding.""" |
| 1049 |
return self.put(self.port_forwarding_path % (floatingip, |
| 1050 |
portforwarding), |
| 1051 |
body=body) |
| 1052 |
|
| 1053 |
def create_security_group(self, body=None): |
| 1054 |
"""Creates a new security group.""" |
| 1055 |
return self.post(self.security_groups_path, body=body) |
| 1056 |
|
| 1057 |
def update_security_group(self, security_group, body=None, |
| 1058 |
revision_number=None): |
| 1059 |
"""Updates a security group.""" |
| 1060 |
return self._update_resource(self.security_group_path % |
| 1061 |
security_group, body=body, |
| 1062 |
revision_number=revision_number) |
| 1063 |
|
| 1064 |
def list_security_groups(self, retrieve_all=True, **_params): |
| 1065 |
"""Fetches a list of all security groups for a project.""" |
| 1066 |
return self.list('security_groups', self.security_groups_path, |
| 1067 |
retrieve_all, **_params) |
| 1068 |
|
| 1069 |
def show_security_group(self, security_group, **_params): |
| 1070 |
"""Fetches information of a certain security group.""" |
| 1071 |
return self.get(self.security_group_path % (security_group), |
| 1072 |
params=_params) |
| 1073 |
|
| 1074 |
def delete_security_group(self, security_group): |
| 1075 |
"""Deletes the specified security group.""" |
| 1076 |
return self.delete(self.security_group_path % (security_group)) |
| 1077 |
|
| 1078 |
def create_security_group_rule(self, body=None): |
| 1079 |
"""Creates a new security group rule.""" |
| 1080 |
return self.post(self.security_group_rules_path, body=body) |
| 1081 |
|
| 1082 |
def delete_security_group_rule(self, security_group_rule): |
| 1083 |
"""Deletes the specified security group rule.""" |
| 1084 |
return self.delete(self.security_group_rule_path % |
| 1085 |
(security_group_rule)) |
| 1086 |
|
| 1087 |
def list_security_group_rules(self, retrieve_all=True, **_params): |
| 1088 |
"""Fetches a list of all security group rules for a project.""" |
| 1089 |
return self.list('security_group_rules', |
| 1090 |
self.security_group_rules_path, |
| 1091 |
retrieve_all, **_params) |
| 1092 |
|
| 1093 |
def show_security_group_rule(self, security_group_rule, **_params): |
| 1094 |
"""Fetches information of a certain security group rule.""" |
| 1095 |
return self.get(self.security_group_rule_path % (security_group_rule), |
| 1096 |
params=_params) |
| 1097 |
|
| 1098 |
def create_segment(self, body=None): |
| 1099 |
"""Creates a new segment.""" |
| 1100 |
return self.post(self.segments_path, body=body) |
| 1101 |
|
| 1102 |
def update_segment(self, segment, body=None, revision_number=None): |
| 1103 |
"""Updates a segment.""" |
| 1104 |
return self._update_resource(self.segment_path % segment, body=body, |
| 1105 |
revision_number=revision_number) |
| 1106 |
|
| 1107 |
def list_segments(self, retrieve_all=True, **_params): |
| 1108 |
"""Fetches a list of all segments for a project.""" |
| 1109 |
return self.list('segments', self.segments_path, retrieve_all, |
| 1110 |
**_params) |
| 1111 |
|
| 1112 |
def show_segment(self, segment, **_params): |
| 1113 |
"""Fetches information of a certain segment.""" |
| 1114 |
return self.get(self.segment_path % segment, params=_params) |
| 1115 |
|
| 1116 |
def delete_segment(self, segment): |
| 1117 |
"""Deletes the specified segment.""" |
| 1118 |
return self.delete(self.segment_path % segment) |
| 1119 |
|
| 1120 |
def list_endpoint_groups(self, retrieve_all=True, **_params): |
| 1121 |
"""Fetches a list of all VPN endpoint groups for a project.""" |
| 1122 |
return self.list('endpoint_groups', self.endpoint_groups_path, |
| 1123 |
retrieve_all, **_params) |
| 1124 |
|
| 1125 |
def show_endpoint_group(self, endpointgroup, **_params): |
| 1126 |
"""Fetches information for a specific VPN endpoint group.""" |
| 1127 |
return self.get(self.endpoint_group_path % endpointgroup, |
| 1128 |
params=_params) |
| 1129 |
|
| 1130 |
def create_endpoint_group(self, body=None): |
| 1131 |
"""Creates a new VPN endpoint group.""" |
| 1132 |
return self.post(self.endpoint_groups_path, body=body) |
| 1133 |
|
| 1134 |
def update_endpoint_group(self, endpoint_group, body=None): |
| 1135 |
"""Updates a VPN endpoint group.""" |
| 1136 |
return self.put(self.endpoint_group_path % endpoint_group, body=body) |
| 1137 |
|
| 1138 |
def delete_endpoint_group(self, endpoint_group): |
| 1139 |
"""Deletes the specified VPN endpoint group.""" |
| 1140 |
return self.delete(self.endpoint_group_path % endpoint_group) |
| 1141 |
|
| 1142 |
def list_vpnservices(self, retrieve_all=True, **_params): |
| 1143 |
"""Fetches a list of all configured VPN services for a project.""" |
| 1144 |
return self.list('vpnservices', self.vpnservices_path, retrieve_all, |
| 1145 |
**_params) |
| 1146 |
|
| 1147 |
def show_vpnservice(self, vpnservice, **_params): |
| 1148 |
"""Fetches information of a specific VPN service.""" |
| 1149 |
return self.get(self.vpnservice_path % (vpnservice), params=_params) |
| 1150 |
|
| 1151 |
def create_vpnservice(self, body=None): |
| 1152 |
"""Creates a new VPN service.""" |
| 1153 |
return self.post(self.vpnservices_path, body=body) |
| 1154 |
|
| 1155 |
def update_vpnservice(self, vpnservice, body=None): |
| 1156 |
"""Updates a VPN service.""" |
| 1157 |
return self.put(self.vpnservice_path % (vpnservice), body=body) |
| 1158 |
|
| 1159 |
def delete_vpnservice(self, vpnservice): |
| 1160 |
"""Deletes the specified VPN service.""" |
| 1161 |
return self.delete(self.vpnservice_path % (vpnservice)) |
| 1162 |
|
| 1163 |
def list_ipsec_site_connections(self, retrieve_all=True, **_params): |
| 1164 |
"""Fetches all configured IPsecSiteConnections for a project.""" |
| 1165 |
return self.list('ipsec_site_connections', |
| 1166 |
self.ipsec_site_connections_path, |
| 1167 |
retrieve_all, |
| 1168 |
**_params) |
| 1169 |
|
| 1170 |
def show_ipsec_site_connection(self, ipsecsite_conn, **_params): |
| 1171 |
"""Fetches information of a specific IPsecSiteConnection.""" |
| 1172 |
return self.get( |
| 1173 |
self.ipsec_site_connection_path % (ipsecsite_conn), params=_params |
| 1174 |
) |
| 1175 |
|
| 1176 |
def create_ipsec_site_connection(self, body=None): |
| 1177 |
"""Creates a new IPsecSiteConnection.""" |
| 1178 |
return self.post(self.ipsec_site_connections_path, body=body) |
| 1179 |
|
| 1180 |
def update_ipsec_site_connection(self, ipsecsite_conn, body=None): |
| 1181 |
"""Updates an IPsecSiteConnection.""" |
| 1182 |
return self.put( |
| 1183 |
self.ipsec_site_connection_path % (ipsecsite_conn), body=body |
| 1184 |
) |
| 1185 |
|
| 1186 |
def delete_ipsec_site_connection(self, ipsecsite_conn): |
| 1187 |
"""Deletes the specified IPsecSiteConnection.""" |
| 1188 |
return self.delete(self.ipsec_site_connection_path % (ipsecsite_conn)) |
| 1189 |
|
| 1190 |
def list_ikepolicies(self, retrieve_all=True, **_params): |
| 1191 |
"""Fetches a list of all configured IKEPolicies for a project.""" |
| 1192 |
return self.list('ikepolicies', self.ikepolicies_path, retrieve_all, |
| 1193 |
**_params) |
| 1194 |
|
| 1195 |
def show_ikepolicy(self, ikepolicy, **_params): |
| 1196 |
"""Fetches information of a specific IKEPolicy.""" |
| 1197 |
return self.get(self.ikepolicy_path % (ikepolicy), params=_params) |
| 1198 |
|
| 1199 |
def create_ikepolicy(self, body=None): |
| 1200 |
"""Creates a new IKEPolicy.""" |
| 1201 |
return self.post(self.ikepolicies_path, body=body) |
| 1202 |
|
| 1203 |
def update_ikepolicy(self, ikepolicy, body=None): |
| 1204 |
"""Updates an IKEPolicy.""" |
| 1205 |
return self.put(self.ikepolicy_path % (ikepolicy), body=body) |
| 1206 |
|
| 1207 |
def delete_ikepolicy(self, ikepolicy): |
| 1208 |
"""Deletes the specified IKEPolicy.""" |
| 1209 |
return self.delete(self.ikepolicy_path % (ikepolicy)) |
| 1210 |
|
| 1211 |
def list_ipsecpolicies(self, retrieve_all=True, **_params): |
| 1212 |
"""Fetches a list of all configured IPsecPolicies for a project.""" |
| 1213 |
return self.list('ipsecpolicies', |
| 1214 |
self.ipsecpolicies_path, |
| 1215 |
retrieve_all, |
| 1216 |
**_params) |
| 1217 |
|
| 1218 |
def show_ipsecpolicy(self, ipsecpolicy, **_params): |
| 1219 |
"""Fetches information of a specific IPsecPolicy.""" |
| 1220 |
return self.get(self.ipsecpolicy_path % (ipsecpolicy), params=_params) |
| 1221 |
|
| 1222 |
def create_ipsecpolicy(self, body=None): |
| 1223 |
"""Creates a new IPsecPolicy.""" |
| 1224 |
return self.post(self.ipsecpolicies_path, body=body) |
| 1225 |
|
| 1226 |
def update_ipsecpolicy(self, ipsecpolicy, body=None): |
| 1227 |
"""Updates an IPsecPolicy.""" |
| 1228 |
return self.put(self.ipsecpolicy_path % (ipsecpolicy), body=body) |
| 1229 |
|
| 1230 |
def delete_ipsecpolicy(self, ipsecpolicy): |
| 1231 |
"""Deletes the specified IPsecPolicy.""" |
| 1232 |
return self.delete(self.ipsecpolicy_path % (ipsecpolicy)) |
| 1233 |
|
| 1234 |
def list_loadbalancers(self, retrieve_all=True, **_params): |
| 1235 |
"""Fetches a list of all loadbalancers for a project.""" |
| 1236 |
return self.list('loadbalancers', self.lbaas_loadbalancers_path, |
| 1237 |
retrieve_all, **_params) |
| 1238 |
|
| 1239 |
def show_loadbalancer(self, lbaas_loadbalancer, **_params): |
| 1240 |
"""Fetches information for a load balancer.""" |
| 1241 |
return self.get(self.lbaas_loadbalancer_path % (lbaas_loadbalancer), |
| 1242 |
params=_params) |
| 1243 |
|
| 1244 |
def create_loadbalancer(self, body=None): |
| 1245 |
"""Creates a new load balancer.""" |
| 1246 |
return self.post(self.lbaas_loadbalancers_path, body=body) |
| 1247 |
|
| 1248 |
def update_loadbalancer(self, lbaas_loadbalancer, body=None): |
| 1249 |
"""Updates a load balancer.""" |
| 1250 |
return self.put(self.lbaas_loadbalancer_path % (lbaas_loadbalancer), |
| 1251 |
body=body) |
| 1252 |
|
| 1253 |
def delete_loadbalancer(self, lbaas_loadbalancer): |
| 1254 |
"""Deletes the specified load balancer.""" |
| 1255 |
return self.delete(self.lbaas_loadbalancer_path % |
| 1256 |
(lbaas_loadbalancer)) |
| 1257 |
|
| 1258 |
def retrieve_loadbalancer_stats(self, loadbalancer, **_params): |
| 1259 |
"""Retrieves stats for a certain load balancer.""" |
| 1260 |
return self.get(self.lbaas_loadbalancer_path_stats % (loadbalancer), |
| 1261 |
params=_params) |
| 1262 |
|
| 1263 |
def retrieve_loadbalancer_status(self, loadbalancer, **_params): |
| 1264 |
"""Retrieves status for a certain load balancer.""" |
| 1265 |
return self.get(self.lbaas_loadbalancer_path_status % (loadbalancer), |
| 1266 |
params=_params) |
| 1267 |
|
| 1268 |
def list_listeners(self, retrieve_all=True, **_params): |
| 1269 |
"""Fetches a list of all lbaas_listeners for a project.""" |
| 1270 |
return self.list('listeners', self.lbaas_listeners_path, |
| 1271 |
retrieve_all, **_params) |
| 1272 |
|
| 1273 |
def show_listener(self, lbaas_listener, **_params): |
| 1274 |
"""Fetches information for a lbaas_listener.""" |
| 1275 |
return self.get(self.lbaas_listener_path % (lbaas_listener), |
| 1276 |
params=_params) |
| 1277 |
|
| 1278 |
def create_listener(self, body=None): |
| 1279 |
"""Creates a new lbaas_listener.""" |
| 1280 |
return self.post(self.lbaas_listeners_path, body=body) |
| 1281 |
|
| 1282 |
def update_listener(self, lbaas_listener, body=None): |
| 1283 |
"""Updates a lbaas_listener.""" |
| 1284 |
return self.put(self.lbaas_listener_path % (lbaas_listener), |
| 1285 |
body=body) |
| 1286 |
|
| 1287 |
def delete_listener(self, lbaas_listener): |
| 1288 |
"""Deletes the specified lbaas_listener.""" |
| 1289 |
return self.delete(self.lbaas_listener_path % (lbaas_listener)) |
| 1290 |
|
| 1291 |
def list_lbaas_l7policies(self, retrieve_all=True, **_params): |
| 1292 |
"""Fetches a list of all L7 policies for a listener.""" |
| 1293 |
return self.list('l7policies', self.lbaas_l7policies_path, |
| 1294 |
retrieve_all, **_params) |
| 1295 |
|
| 1296 |
def show_lbaas_l7policy(self, l7policy, **_params): |
| 1297 |
"""Fetches information of a certain listener's L7 policy.""" |
| 1298 |
return self.get(self.lbaas_l7policy_path % l7policy, |
| 1299 |
params=_params) |
| 1300 |
|
| 1301 |
def create_lbaas_l7policy(self, body=None): |
| 1302 |
"""Creates L7 policy for a certain listener.""" |
| 1303 |
return self.post(self.lbaas_l7policies_path, body=body) |
| 1304 |
|
| 1305 |
def update_lbaas_l7policy(self, l7policy, body=None): |
| 1306 |
"""Updates L7 policy.""" |
| 1307 |
return self.put(self.lbaas_l7policy_path % l7policy, |
| 1308 |
body=body) |
| 1309 |
|
| 1310 |
def delete_lbaas_l7policy(self, l7policy): |
| 1311 |
"""Deletes the specified L7 policy.""" |
| 1312 |
return self.delete(self.lbaas_l7policy_path % l7policy) |
| 1313 |
|
| 1314 |
def list_lbaas_l7rules(self, l7policy, retrieve_all=True, **_params): |
| 1315 |
"""Fetches a list of all rules for L7 policy.""" |
| 1316 |
return self.list('rules', self.lbaas_l7rules_path % l7policy, |
| 1317 |
retrieve_all, **_params) |
| 1318 |
|
| 1319 |
def show_lbaas_l7rule(self, l7rule, l7policy, **_params): |
| 1320 |
"""Fetches information of a certain L7 policy's rule.""" |
| 1321 |
return self.get(self.lbaas_l7rule_path % (l7policy, l7rule), |
| 1322 |
params=_params) |
| 1323 |
|
| 1324 |
def create_lbaas_l7rule(self, l7policy, body=None): |
| 1325 |
"""Creates rule for a certain L7 policy.""" |
| 1326 |
return self.post(self.lbaas_l7rules_path % l7policy, body=body) |
| 1327 |
|
| 1328 |
def update_lbaas_l7rule(self, l7rule, l7policy, body=None): |
| 1329 |
"""Updates L7 rule.""" |
| 1330 |
return self.put(self.lbaas_l7rule_path % (l7policy, l7rule), |
| 1331 |
body=body) |
| 1332 |
|
| 1333 |
def delete_lbaas_l7rule(self, l7rule, l7policy): |
| 1334 |
"""Deletes the specified L7 rule.""" |
| 1335 |
return self.delete(self.lbaas_l7rule_path % (l7policy, l7rule)) |
| 1336 |
|
| 1337 |
def list_lbaas_pools(self, retrieve_all=True, **_params): |
| 1338 |
"""Fetches a list of all lbaas_pools for a project.""" |
| 1339 |
return self.list('pools', self.lbaas_pools_path, |
| 1340 |
retrieve_all, **_params) |
| 1341 |
|
| 1342 |
def show_lbaas_pool(self, lbaas_pool, **_params): |
| 1343 |
"""Fetches information for a lbaas_pool.""" |
| 1344 |
return self.get(self.lbaas_pool_path % (lbaas_pool), |
| 1345 |
params=_params) |
| 1346 |
|
| 1347 |
def create_lbaas_pool(self, body=None): |
| 1348 |
"""Creates a new lbaas_pool.""" |
| 1349 |
return self.post(self.lbaas_pools_path, body=body) |
| 1350 |
|
| 1351 |
def update_lbaas_pool(self, lbaas_pool, body=None): |
| 1352 |
"""Updates a lbaas_pool.""" |
| 1353 |
return self.put(self.lbaas_pool_path % (lbaas_pool), |
| 1354 |
body=body) |
| 1355 |
|
| 1356 |
def delete_lbaas_pool(self, lbaas_pool): |
| 1357 |
"""Deletes the specified lbaas_pool.""" |
| 1358 |
return self.delete(self.lbaas_pool_path % (lbaas_pool)) |
| 1359 |
|
| 1360 |
def list_lbaas_healthmonitors(self, retrieve_all=True, **_params): |
| 1361 |
"""Fetches a list of all lbaas_healthmonitors for a project.""" |
| 1362 |
return self.list('healthmonitors', self.lbaas_healthmonitors_path, |
| 1363 |
retrieve_all, **_params) |
| 1364 |
|
| 1365 |
def show_lbaas_healthmonitor(self, lbaas_healthmonitor, **_params): |
| 1366 |
"""Fetches information for a lbaas_healthmonitor.""" |
| 1367 |
return self.get(self.lbaas_healthmonitor_path % (lbaas_healthmonitor), |
| 1368 |
params=_params) |
| 1369 |
|
| 1370 |
def create_lbaas_healthmonitor(self, body=None): |
| 1371 |
"""Creates a new lbaas_healthmonitor.""" |
| 1372 |
return self.post(self.lbaas_healthmonitors_path, body=body) |
| 1373 |
|
| 1374 |
def update_lbaas_healthmonitor(self, lbaas_healthmonitor, body=None): |
| 1375 |
"""Updates a lbaas_healthmonitor.""" |
| 1376 |
return self.put(self.lbaas_healthmonitor_path % (lbaas_healthmonitor), |
| 1377 |
body=body) |
| 1378 |
|
| 1379 |
def delete_lbaas_healthmonitor(self, lbaas_healthmonitor): |
| 1380 |
"""Deletes the specified lbaas_healthmonitor.""" |
| 1381 |
return self.delete(self.lbaas_healthmonitor_path % |
| 1382 |
(lbaas_healthmonitor)) |
| 1383 |
|
| 1384 |
def list_lbaas_loadbalancers(self, retrieve_all=True, **_params): |
| 1385 |
"""Fetches a list of all lbaas_loadbalancers for a project.""" |
| 1386 |
return self.list('loadbalancers', self.lbaas_loadbalancers_path, |
| 1387 |
retrieve_all, **_params) |
| 1388 |
|
| 1389 |
def list_lbaas_members(self, lbaas_pool, retrieve_all=True, **_params): |
| 1390 |
"""Fetches a list of all lbaas_members for a project.""" |
| 1391 |
return self.list('members', self.lbaas_members_path % lbaas_pool, |
| 1392 |
retrieve_all, **_params) |
| 1393 |
|
| 1394 |
def show_lbaas_member(self, lbaas_member, lbaas_pool, **_params): |
| 1395 |
"""Fetches information of a certain lbaas_member.""" |
| 1396 |
return self.get(self.lbaas_member_path % (lbaas_pool, lbaas_member), |
| 1397 |
params=_params) |
| 1398 |
|
| 1399 |
def create_lbaas_member(self, lbaas_pool, body=None): |
| 1400 |
"""Creates a lbaas_member.""" |
| 1401 |
return self.post(self.lbaas_members_path % lbaas_pool, body=body) |
| 1402 |
|
| 1403 |
def update_lbaas_member(self, lbaas_member, lbaas_pool, body=None): |
| 1404 |
"""Updates a lbaas_member.""" |
| 1405 |
return self.put(self.lbaas_member_path % (lbaas_pool, lbaas_member), |
| 1406 |
body=body) |
| 1407 |
|
| 1408 |
def delete_lbaas_member(self, lbaas_member, lbaas_pool): |
| 1409 |
"""Deletes the specified lbaas_member.""" |
| 1410 |
return self.delete(self.lbaas_member_path % (lbaas_pool, lbaas_member)) |
| 1411 |
|
| 1412 |
def list_vips(self, retrieve_all=True, **_params): |
| 1413 |
"""Fetches a list of all load balancer vips for a project.""" |
| 1414 |
# Pass filters in "params" argument to do_request |
| 1415 |
return self.list('vips', self.vips_path, retrieve_all, |
| 1416 |
**_params) |
| 1417 |
|
| 1418 |
def show_vip(self, vip, **_params): |
| 1419 |
"""Fetches information of a certain load balancer vip.""" |
| 1420 |
return self.get(self.vip_path % (vip), params=_params) |
| 1421 |
|
| 1422 |
def create_vip(self, body=None): |
| 1423 |
"""Creates a new load balancer vip.""" |
| 1424 |
return self.post(self.vips_path, body=body) |
| 1425 |
|
| 1426 |
def update_vip(self, vip, body=None): |
| 1427 |
"""Updates a load balancer vip.""" |
| 1428 |
return self.put(self.vip_path % (vip), body=body) |
| 1429 |
|
| 1430 |
def delete_vip(self, vip): |
| 1431 |
"""Deletes the specified load balancer vip.""" |
| 1432 |
return self.delete(self.vip_path % (vip)) |
| 1433 |
|
| 1434 |
def list_pools(self, retrieve_all=True, **_params): |
| 1435 |
"""Fetches a list of all load balancer pools for a project.""" |
| 1436 |
# Pass filters in "params" argument to do_request |
| 1437 |
return self.list('pools', self.pools_path, retrieve_all, |
| 1438 |
**_params) |
| 1439 |
|
| 1440 |
def show_pool(self, pool, **_params): |
| 1441 |
"""Fetches information of a certain load balancer pool.""" |
| 1442 |
return self.get(self.pool_path % (pool), params=_params) |
| 1443 |
|
| 1444 |
def create_pool(self, body=None): |
| 1445 |
"""Creates a new load balancer pool.""" |
| 1446 |
return self.post(self.pools_path, body=body) |
| 1447 |
|
| 1448 |
def update_pool(self, pool, body=None): |
| 1449 |
"""Updates a load balancer pool.""" |
| 1450 |
return self.put(self.pool_path % (pool), body=body) |
| 1451 |
|
| 1452 |
def delete_pool(self, pool): |
| 1453 |
"""Deletes the specified load balancer pool.""" |
| 1454 |
return self.delete(self.pool_path % (pool)) |
| 1455 |
|
| 1456 |
def retrieve_pool_stats(self, pool, **_params): |
| 1457 |
"""Retrieves stats for a certain load balancer pool.""" |
| 1458 |
return self.get(self.pool_path_stats % (pool), params=_params) |
| 1459 |
|
| 1460 |
def list_members(self, retrieve_all=True, **_params): |
| 1461 |
"""Fetches a list of all load balancer members for a project.""" |
| 1462 |
# Pass filters in "params" argument to do_request |
| 1463 |
return self.list('members', self.members_path, retrieve_all, |
| 1464 |
**_params) |
| 1465 |
|
| 1466 |
def show_member(self, member, **_params): |
| 1467 |
"""Fetches information of a certain load balancer member.""" |
| 1468 |
return self.get(self.member_path % (member), params=_params) |
| 1469 |
|
| 1470 |
def create_member(self, body=None): |
| 1471 |
"""Creates a new load balancer member.""" |
| 1472 |
return self.post(self.members_path, body=body) |
| 1473 |
|
| 1474 |
def update_member(self, member, body=None): |
| 1475 |
"""Updates a load balancer member.""" |
| 1476 |
return self.put(self.member_path % (member), body=body) |
| 1477 |
|
| 1478 |
def delete_member(self, member): |
| 1479 |
"""Deletes the specified load balancer member.""" |
| 1480 |
return self.delete(self.member_path % (member)) |
| 1481 |
|
| 1482 |
def list_health_monitors(self, retrieve_all=True, **_params): |
| 1483 |
"""Fetches a list of all load balancer health monitors for a project. |
| 1484 |
|
| 1485 |
""" |
| 1486 |
# Pass filters in "params" argument to do_request |
| 1487 |
return self.list('health_monitors', self.health_monitors_path, |
| 1488 |
retrieve_all, **_params) |
| 1489 |
|
| 1490 |
def show_health_monitor(self, health_monitor, **_params): |
| 1491 |
"""Fetches information of a certain load balancer health monitor.""" |
| 1492 |
return self.get(self.health_monitor_path % (health_monitor), |
| 1493 |
params=_params) |
| 1494 |
|
| 1495 |
def create_health_monitor(self, body=None): |
| 1496 |
"""Creates a new load balancer health monitor.""" |
| 1497 |
return self.post(self.health_monitors_path, body=body) |
| 1498 |
|
| 1499 |
def update_health_monitor(self, health_monitor, body=None): |
| 1500 |
"""Updates a load balancer health monitor.""" |
| 1501 |
return self.put(self.health_monitor_path % (health_monitor), body=body) |
| 1502 |
|
| 1503 |
def delete_health_monitor(self, health_monitor): |
| 1504 |
"""Deletes the specified load balancer health monitor.""" |
| 1505 |
return self.delete(self.health_monitor_path % (health_monitor)) |
| 1506 |
|
| 1507 |
def associate_health_monitor(self, pool, body): |
| 1508 |
"""Associate specified load balancer health monitor and pool.""" |
| 1509 |
return self.post(self.associate_pool_health_monitors_path % (pool), |
| 1510 |
body=body) |
| 1511 |
|
| 1512 |
def disassociate_health_monitor(self, pool, health_monitor): |
| 1513 |
"""Disassociate specified load balancer health monitor and pool.""" |
| 1514 |
path = (self.disassociate_pool_health_monitors_path % |
| 1515 |
{'pool': pool, 'health_monitor': health_monitor}) |
| 1516 |
return self.delete(path) |
| 1517 |
|
| 1518 |
def create_qos_queue(self, body=None): |
| 1519 |
"""Creates a new queue.""" |
| 1520 |
return self.post(self.qos_queues_path, body=body) |
| 1521 |
|
| 1522 |
def list_qos_queues(self, **_params): |
| 1523 |
"""Fetches a list of all queues for a project.""" |
| 1524 |
return self.get(self.qos_queues_path, params=_params) |
| 1525 |
|
| 1526 |
def show_qos_queue(self, queue, **_params): |
| 1527 |
"""Fetches information of a certain queue.""" |
| 1528 |
return self.get(self.qos_queue_path % (queue), |
| 1529 |
params=_params) |
| 1530 |
|
| 1531 |
def delete_qos_queue(self, queue): |
| 1532 |
"""Deletes the specified queue.""" |
| 1533 |
return self.delete(self.qos_queue_path % (queue)) |
| 1534 |
|
| 1535 |
def list_agents(self, **_params): |
| 1536 |
"""Fetches agents.""" |
| 1537 |
# Pass filters in "params" argument to do_request |
| 1538 |
return self.get(self.agents_path, params=_params) |
| 1539 |
|
| 1540 |
def show_agent(self, agent, **_params): |
| 1541 |
"""Fetches information of a certain agent.""" |
| 1542 |
return self.get(self.agent_path % (agent), params=_params) |
| 1543 |
|
| 1544 |
def update_agent(self, agent, body=None): |
| 1545 |
"""Updates an agent.""" |
| 1546 |
return self.put(self.agent_path % (agent), body=body) |
| 1547 |
|
| 1548 |
def delete_agent(self, agent): |
| 1549 |
"""Deletes the specified agent.""" |
| 1550 |
return self.delete(self.agent_path % (agent)) |
| 1551 |
|
| 1552 |
def list_network_gateways(self, **_params): |
| 1553 |
"""Retrieve network gateways.""" |
| 1554 |
return self.get(self.network_gateways_path, params=_params) |
| 1555 |
|
| 1556 |
def show_network_gateway(self, gateway_id, **_params): |
| 1557 |
"""Fetch a network gateway.""" |
| 1558 |
return self.get(self.network_gateway_path % gateway_id, params=_params) |
| 1559 |
|
| 1560 |
def create_network_gateway(self, body=None): |
| 1561 |
"""Create a new network gateway.""" |
| 1562 |
return self.post(self.network_gateways_path, body=body) |
| 1563 |
|
| 1564 |
def update_network_gateway(self, gateway_id, body=None): |
| 1565 |
"""Update a network gateway.""" |
| 1566 |
return self.put(self.network_gateway_path % gateway_id, body=body) |
| 1567 |
|
| 1568 |
def delete_network_gateway(self, gateway_id): |
| 1569 |
"""Delete the specified network gateway.""" |
| 1570 |
return self.delete(self.network_gateway_path % gateway_id) |
| 1571 |
|
| 1572 |
def connect_network_gateway(self, gateway_id, body=None): |
| 1573 |
"""Connect a network gateway to the specified network.""" |
| 1574 |
base_uri = self.network_gateway_path % gateway_id |
| 1575 |
return self.put("%s/connect_network" % base_uri, body=body) |
| 1576 |
|
| 1577 |
def disconnect_network_gateway(self, gateway_id, body=None): |
| 1578 |
"""Disconnect a network from the specified gateway.""" |
| 1579 |
base_uri = self.network_gateway_path % gateway_id |
| 1580 |
return self.put("%s/disconnect_network" % base_uri, body=body) |
| 1581 |
|
| 1582 |
def list_gateway_devices(self, **_params): |
| 1583 |
"""Retrieve gateway devices.""" |
| 1584 |
return self.get(self.gateway_devices_path, params=_params) |
| 1585 |
|
| 1586 |
def show_gateway_device(self, gateway_device_id, **_params): |
| 1587 |
"""Fetch a gateway device.""" |
| 1588 |
return self.get(self.gateway_device_path % gateway_device_id, |
| 1589 |
params=_params) |
| 1590 |
|
| 1591 |
def create_gateway_device(self, body=None): |
| 1592 |
"""Create a new gateway device.""" |
| 1593 |
return self.post(self.gateway_devices_path, body=body) |
| 1594 |
|
| 1595 |
def update_gateway_device(self, gateway_device_id, body=None): |
| 1596 |
"""Updates a new gateway device.""" |
| 1597 |
return self.put(self.gateway_device_path % gateway_device_id, |
| 1598 |
body=body) |
| 1599 |
|
| 1600 |
def delete_gateway_device(self, gateway_device_id): |
| 1601 |
"""Delete the specified gateway device.""" |
| 1602 |
return self.delete(self.gateway_device_path % gateway_device_id) |
| 1603 |
|
| 1604 |
def list_dhcp_agent_hosting_networks(self, network, **_params): |
| 1605 |
"""Fetches a list of dhcp agents hosting a network.""" |
| 1606 |
return self.get((self.network_path + self.DHCP_AGENTS) % network, |
| 1607 |
params=_params) |
| 1608 |
|
| 1609 |
def list_networks_on_dhcp_agent(self, dhcp_agent, **_params): |
| 1610 |
"""Fetches a list of networks hosted on a DHCP agent.""" |
| 1611 |
return self.get((self.agent_path + self.DHCP_NETS) % dhcp_agent, |
| 1612 |
params=_params) |
| 1613 |
|
| 1614 |
def add_network_to_dhcp_agent(self, dhcp_agent, body=None): |
| 1615 |
"""Adds a network to dhcp agent.""" |
| 1616 |
return self.post((self.agent_path + self.DHCP_NETS) % dhcp_agent, |
| 1617 |
body=body) |
| 1618 |
|
| 1619 |
def remove_network_from_dhcp_agent(self, dhcp_agent, network_id): |
| 1620 |
"""Remove a network from dhcp agent.""" |
| 1621 |
return self.delete((self.agent_path + self.DHCP_NETS + "/%s") % ( |
| 1622 |
dhcp_agent, network_id)) |
| 1623 |
|
| 1624 |
def list_l3_agent_hosting_routers(self, router, **_params): |
| 1625 |
"""Fetches a list of L3 agents hosting a router.""" |
| 1626 |
return self.get((self.router_path + self.L3_AGENTS) % router, |
| 1627 |
params=_params) |
| 1628 |
|
| 1629 |
def list_routers_on_l3_agent(self, l3_agent, **_params): |
| 1630 |
"""Fetches a list of routers hosted on an L3 agent.""" |
| 1631 |
return self.get((self.agent_path + self.L3_ROUTERS) % l3_agent, |
| 1632 |
params=_params) |
| 1633 |
|
| 1634 |
def add_router_to_l3_agent(self, l3_agent, body): |
| 1635 |
"""Adds a router to L3 agent.""" |
| 1636 |
return self.post((self.agent_path + self.L3_ROUTERS) % l3_agent, |
| 1637 |
body=body) |
| 1638 |
|
| 1639 |
def list_dragents_hosting_bgp_speaker(self, bgp_speaker, **_params): |
| 1640 |
"""Fetches a list of Dynamic Routing agents hosting a BGP speaker.""" |
| 1641 |
return self.get((self.bgp_speaker_path + self.BGP_DRAGENTS) |
| 1642 |
% bgp_speaker, params=_params) |
| 1643 |
|
| 1644 |
def add_bgp_speaker_to_dragent(self, bgp_dragent, body): |
| 1645 |
"""Adds a BGP speaker to Dynamic Routing agent.""" |
| 1646 |
return self.post((self.agent_path + self.BGP_DRINSTANCES) |
| 1647 |
% bgp_dragent, body=body) |
| 1648 |
|
| 1649 |
def remove_bgp_speaker_from_dragent(self, bgp_dragent, bgpspeaker_id): |
| 1650 |
"""Removes a BGP speaker from Dynamic Routing agent.""" |
| 1651 |
return self.delete((self.agent_path + self.BGP_DRINSTANCES + "/%s") |
| 1652 |
% (bgp_dragent, bgpspeaker_id)) |
| 1653 |
|
| 1654 |
def list_bgp_speaker_on_dragent(self, bgp_dragent, **_params): |
| 1655 |
"""Fetches a list of BGP speakers hosted by Dynamic Routing agent.""" |
| 1656 |
return self.get((self.agent_path + self.BGP_DRINSTANCES) |
| 1657 |
% bgp_dragent, params=_params) |
| 1658 |
|
| 1659 |
def list_firewall_rules(self, retrieve_all=True, **_params): |
| 1660 |
"""Fetches a list of all firewall rules for a project.""" |
| 1661 |
# Pass filters in "params" argument to do_request |
| 1662 |
|
| 1663 |
return self.list('firewall_rules', self.firewall_rules_path, |
| 1664 |
retrieve_all, **_params) |
| 1665 |
|
| 1666 |
def show_firewall_rule(self, firewall_rule, **_params): |
| 1667 |
"""Fetches information of a certain firewall rule.""" |
| 1668 |
return self.get(self.firewall_rule_path % (firewall_rule), |
| 1669 |
params=_params) |
| 1670 |
|
| 1671 |
def create_firewall_rule(self, body=None): |
| 1672 |
"""Creates a new firewall rule.""" |
| 1673 |
return self.post(self.firewall_rules_path, body=body) |
| 1674 |
|
| 1675 |
def update_firewall_rule(self, firewall_rule, body=None): |
| 1676 |
"""Updates a firewall rule.""" |
| 1677 |
return self.put(self.firewall_rule_path % (firewall_rule), body=body) |
| 1678 |
|
| 1679 |
def delete_firewall_rule(self, firewall_rule): |
| 1680 |
"""Deletes the specified firewall rule.""" |
| 1681 |
return self.delete(self.firewall_rule_path % (firewall_rule)) |
| 1682 |
|
| 1683 |
def list_firewall_policies(self, retrieve_all=True, **_params): |
| 1684 |
"""Fetches a list of all firewall policies for a project.""" |
| 1685 |
# Pass filters in "params" argument to do_request |
| 1686 |
|
| 1687 |
return self.list('firewall_policies', self.firewall_policies_path, |
| 1688 |
retrieve_all, **_params) |
| 1689 |
|
| 1690 |
def show_firewall_policy(self, firewall_policy, **_params): |
| 1691 |
"""Fetches information of a certain firewall policy.""" |
| 1692 |
return self.get(self.firewall_policy_path % (firewall_policy), |
| 1693 |
params=_params) |
| 1694 |
|
| 1695 |
def create_firewall_policy(self, body=None): |
| 1696 |
"""Creates a new firewall policy.""" |
| 1697 |
return self.post(self.firewall_policies_path, body=body) |
| 1698 |
|
| 1699 |
def update_firewall_policy(self, firewall_policy, body=None): |
| 1700 |
"""Updates a firewall policy.""" |
| 1701 |
return self.put(self.firewall_policy_path % (firewall_policy), |
| 1702 |
body=body) |
| 1703 |
|
| 1704 |
def delete_firewall_policy(self, firewall_policy): |
| 1705 |
"""Deletes the specified firewall policy.""" |
| 1706 |
return self.delete(self.firewall_policy_path % (firewall_policy)) |
| 1707 |
|
| 1708 |
def firewall_policy_insert_rule(self, firewall_policy, body=None): |
| 1709 |
"""Inserts specified rule into firewall policy.""" |
| 1710 |
return self.put(self.firewall_policy_insert_path % (firewall_policy), |
| 1711 |
body=body) |
| 1712 |
|
| 1713 |
def firewall_policy_remove_rule(self, firewall_policy, body=None): |
| 1714 |
"""Removes specified rule from firewall policy.""" |
| 1715 |
return self.put(self.firewall_policy_remove_path % (firewall_policy), |
| 1716 |
body=body) |
| 1717 |
|
| 1718 |
def list_firewalls(self, retrieve_all=True, **_params): |
| 1719 |
"""Fetches a list of all firewalls for a project.""" |
| 1720 |
# Pass filters in "params" argument to do_request |
| 1721 |
|
| 1722 |
return self.list('firewalls', self.firewalls_path, retrieve_all, |
| 1723 |
**_params) |
| 1724 |
|
| 1725 |
def show_firewall(self, firewall, **_params): |
| 1726 |
"""Fetches information of a certain firewall.""" |
| 1727 |
return self.get(self.firewall_path % (firewall), params=_params) |
| 1728 |
|
| 1729 |
def create_firewall(self, body=None): |
| 1730 |
"""Creates a new firewall.""" |
| 1731 |
return self.post(self.firewalls_path, body=body) |
| 1732 |
|
| 1733 |
def update_firewall(self, firewall, body=None): |
| 1734 |
"""Updates a firewall.""" |
| 1735 |
return self.put(self.firewall_path % (firewall), body=body) |
| 1736 |
|
| 1737 |
def delete_firewall(self, firewall): |
| 1738 |
"""Deletes the specified firewall.""" |
| 1739 |
return self.delete(self.firewall_path % (firewall)) |
| 1740 |
|
| 1741 |
def list_fwaas_firewall_groups(self, retrieve_all=True, **_params): |
| 1742 |
"""Fetches a list of all firewall groups for a project""" |
| 1743 |
return self.list('firewall_groups', self.fwaas_firewall_groups_path, |
| 1744 |
retrieve_all, **_params) |
| 1745 |
|
| 1746 |
def show_fwaas_firewall_group(self, fwg, **_params): |
| 1747 |
"""Fetches information of a certain firewall group""" |
| 1748 |
return self.get(self.fwaas_firewall_group_path % (fwg), params=_params) |
| 1749 |
|
| 1750 |
def create_fwaas_firewall_group(self, body=None): |
| 1751 |
"""Creates a new firewall group""" |
| 1752 |
return self.post(self.fwaas_firewall_groups_path, body=body) |
| 1753 |
|
| 1754 |
def update_fwaas_firewall_group(self, fwg, body=None): |
| 1755 |
"""Updates a firewall group""" |
| 1756 |
return self.put(self.fwaas_firewall_group_path % (fwg), body=body) |
| 1757 |
|
| 1758 |
def delete_fwaas_firewall_group(self, fwg): |
| 1759 |
"""Deletes the specified firewall group""" |
| 1760 |
return self.delete(self.fwaas_firewall_group_path % (fwg)) |
| 1761 |
|
| 1762 |
def list_fwaas_firewall_rules(self, retrieve_all=True, **_params): |
| 1763 |
"""Fetches a list of all firewall rules for a project""" |
| 1764 |
# Pass filters in "params" argument to do_request |
| 1765 |
return self.list('firewall_rules', self.fwaas_firewall_rules_path, |
| 1766 |
retrieve_all, **_params) |
| 1767 |
|
| 1768 |
def show_fwaas_firewall_rule(self, firewall_rule, **_params): |
| 1769 |
"""Fetches information of a certain firewall rule""" |
| 1770 |
return self.get(self.fwaas_firewall_rule_path % (firewall_rule), |
| 1771 |
params=_params) |
| 1772 |
|
| 1773 |
def create_fwaas_firewall_rule(self, body=None): |
| 1774 |
"""Creates a new firewall rule""" |
| 1775 |
return self.post(self.fwaas_firewall_rules_path, body=body) |
| 1776 |
|
| 1777 |
def update_fwaas_firewall_rule(self, firewall_rule, body=None): |
| 1778 |
"""Updates a firewall rule""" |
| 1779 |
return self.put(self.fwaas_firewall_rule_path % (firewall_rule), |
| 1780 |
body=body) |
| 1781 |
|
| 1782 |
def delete_fwaas_firewall_rule(self, firewall_rule): |
| 1783 |
"""Deletes the specified firewall rule""" |
| 1784 |
return self.delete(self.fwaas_firewall_rule_path % (firewall_rule)) |
| 1785 |
|
| 1786 |
def list_fwaas_firewall_policies(self, retrieve_all=True, **_params): |
| 1787 |
"""Fetches a list of all firewall policies for a project""" |
| 1788 |
# Pass filters in "params" argument to do_request |
| 1789 |
|
| 1790 |
return self.list('firewall_policies', |
| 1791 |
self.fwaas_firewall_policies_path, |
| 1792 |
retrieve_all, **_params) |
| 1793 |
|
| 1794 |
def show_fwaas_firewall_policy(self, firewall_policy, **_params): |
| 1795 |
"""Fetches information of a certain firewall policy""" |
| 1796 |
return self.get(self.fwaas_firewall_policy_path % (firewall_policy), |
| 1797 |
params=_params) |
| 1798 |
|
| 1799 |
def create_fwaas_firewall_policy(self, body=None): |
| 1800 |
"""Creates a new firewall policy""" |
| 1801 |
return self.post(self.fwaas_firewall_policies_path, body=body) |
| 1802 |
|
| 1803 |
def update_fwaas_firewall_policy(self, firewall_policy, body=None): |
| 1804 |
"""Updates a firewall policy""" |
| 1805 |
return self.put(self.fwaas_firewall_policy_path % (firewall_policy), |
| 1806 |
body=body) |
| 1807 |
|
| 1808 |
def delete_fwaas_firewall_policy(self, firewall_policy): |
| 1809 |
"""Deletes the specified firewall policy""" |
| 1810 |
return self.delete(self.fwaas_firewall_policy_path % (firewall_policy)) |
| 1811 |
|
| 1812 |
def insert_rule_fwaas_firewall_policy(self, firewall_policy, body=None): |
| 1813 |
"""Inserts specified rule into firewall policy""" |
| 1814 |
return self.put((self.fwaas_firewall_policy_insert_path % |
| 1815 |
(firewall_policy)), body=body) |
| 1816 |
|
| 1817 |
def remove_rule_fwaas_firewall_policy(self, firewall_policy, body=None): |
| 1818 |
"""Removes specified rule from firewall policy""" |
| 1819 |
return self.put((self.fwaas_firewall_policy_remove_path % |
| 1820 |
(firewall_policy)), body=body) |
| 1821 |
|
| 1822 |
def remove_router_from_l3_agent(self, l3_agent, router_id): |
| 1823 |
"""Remove a router from l3 agent.""" |
| 1824 |
return self.delete((self.agent_path + self.L3_ROUTERS + "/%s") % ( |
| 1825 |
l3_agent, router_id)) |
| 1826 |
|
| 1827 |
def get_lbaas_agent_hosting_pool(self, pool, **_params): |
| 1828 |
"""Fetches a loadbalancer agent hosting a pool.""" |
| 1829 |
return self.get((self.pool_path + self.LOADBALANCER_AGENT) % pool, |
| 1830 |
params=_params) |
| 1831 |
|
| 1832 |
def list_pools_on_lbaas_agent(self, lbaas_agent, **_params): |
| 1833 |
"""Fetches a list of pools hosted by the loadbalancer agent.""" |
| 1834 |
return self.get((self.agent_path + self.LOADBALANCER_POOLS) % |
| 1835 |
lbaas_agent, params=_params) |
| 1836 |
|
| 1837 |
def get_lbaas_agent_hosting_loadbalancer(self, loadbalancer, **_params): |
| 1838 |
"""Fetches a loadbalancer agent hosting a loadbalancer.""" |
| 1839 |
return self.get((self.lbaas_loadbalancer_path + |
| 1840 |
self.LOADBALANCER_HOSTING_AGENT) % loadbalancer, |
| 1841 |
params=_params) |
| 1842 |
|
| 1843 |
def list_loadbalancers_on_lbaas_agent(self, lbaas_agent, **_params): |
| 1844 |
"""Fetches a list of loadbalancers hosted by the loadbalancer agent.""" |
| 1845 |
return self.get((self.agent_path + self.AGENT_LOADBALANCERS) % |
| 1846 |
lbaas_agent, params=_params) |
| 1847 |
|
| 1848 |
def list_service_providers(self, retrieve_all=True, **_params): |
| 1849 |
"""Fetches service providers.""" |
| 1850 |
# Pass filters in "params" argument to do_request |
| 1851 |
return self.list('service_providers', self.service_providers_path, |
| 1852 |
retrieve_all, **_params) |
| 1853 |
|
| 1854 |
def create_metering_label(self, body=None): |
| 1855 |
"""Creates a metering label.""" |
| 1856 |
return self.post(self.metering_labels_path, body=body) |
| 1857 |
|
| 1858 |
def delete_metering_label(self, label): |
| 1859 |
"""Deletes the specified metering label.""" |
| 1860 |
return self.delete(self.metering_label_path % (label)) |
| 1861 |
|
| 1862 |
def list_metering_labels(self, retrieve_all=True, **_params): |
| 1863 |
"""Fetches a list of all metering labels for a project.""" |
| 1864 |
return self.list('metering_labels', self.metering_labels_path, |
| 1865 |
retrieve_all, **_params) |
| 1866 |
|
| 1867 |
def show_metering_label(self, metering_label, **_params): |
| 1868 |
"""Fetches information of a certain metering label.""" |
| 1869 |
return self.get(self.metering_label_path % |
| 1870 |
(metering_label), params=_params) |
| 1871 |
|
| 1872 |
def create_metering_label_rule(self, body=None): |
| 1873 |
"""Creates a metering label rule.""" |
| 1874 |
return self.post(self.metering_label_rules_path, body=body) |
| 1875 |
|
| 1876 |
def delete_metering_label_rule(self, rule): |
| 1877 |
"""Deletes the specified metering label rule.""" |
| 1878 |
return self.delete(self.metering_label_rule_path % (rule)) |
| 1879 |
|
| 1880 |
def list_metering_label_rules(self, retrieve_all=True, **_params): |
| 1881 |
"""Fetches a list of all metering label rules for a label.""" |
| 1882 |
return self.list('metering_label_rules', |
| 1883 |
self.metering_label_rules_path, retrieve_all, |
| 1884 |
**_params) |
| 1885 |
|
| 1886 |
def show_metering_label_rule(self, metering_label_rule, **_params): |
| 1887 |
"""Fetches information of a certain metering label rule.""" |
| 1888 |
return self.get(self.metering_label_rule_path % |
| 1889 |
(metering_label_rule), params=_params) |
| 1890 |
|
| 1891 |
def create_rbac_policy(self, body=None): |
| 1892 |
"""Create a new RBAC policy.""" |
| 1893 |
return self.post(self.rbac_policies_path, body=body) |
| 1894 |
|
| 1895 |
def update_rbac_policy(self, rbac_policy_id, body=None): |
| 1896 |
"""Update a RBAC policy.""" |
| 1897 |
return self.put(self.rbac_policy_path % rbac_policy_id, body=body) |
| 1898 |
|
| 1899 |
def list_rbac_policies(self, retrieve_all=True, **_params): |
| 1900 |
"""Fetch a list of all RBAC policies for a project.""" |
| 1901 |
return self.list('rbac_policies', self.rbac_policies_path, |
| 1902 |
retrieve_all, **_params) |
| 1903 |
|
| 1904 |
def show_rbac_policy(self, rbac_policy_id, **_params): |
| 1905 |
"""Fetch information of a certain RBAC policy.""" |
| 1906 |
return self.get(self.rbac_policy_path % rbac_policy_id, |
| 1907 |
params=_params) |
| 1908 |
|
| 1909 |
def delete_rbac_policy(self, rbac_policy_id): |
| 1910 |
"""Delete the specified RBAC policy.""" |
| 1911 |
return self.delete(self.rbac_policy_path % rbac_policy_id) |
| 1912 |
|
| 1913 |
def list_qos_policies(self, retrieve_all=True, **_params): |
| 1914 |
"""Fetches a list of all qos policies for a project.""" |
| 1915 |
# Pass filters in "params" argument to do_request |
| 1916 |
return self.list('policies', self.qos_policies_path, |
| 1917 |
retrieve_all, **_params) |
| 1918 |
|
| 1919 |
def show_qos_policy(self, qos_policy, **_params): |
| 1920 |
"""Fetches information of a certain qos policy.""" |
| 1921 |
return self.get(self.qos_policy_path % qos_policy, |
| 1922 |
params=_params) |
| 1923 |
|
| 1924 |
def create_qos_policy(self, body=None): |
| 1925 |
"""Creates a new qos policy.""" |
| 1926 |
return self.post(self.qos_policies_path, body=body) |
| 1927 |
|
| 1928 |
def update_qos_policy(self, qos_policy, body=None, revision_number=None): |
| 1929 |
"""Updates a qos policy.""" |
| 1930 |
return self._update_resource(self.qos_policy_path % qos_policy, |
| 1931 |
body=body, |
| 1932 |
revision_number=revision_number) |
| 1933 |
|
| 1934 |
def delete_qos_policy(self, qos_policy): |
| 1935 |
"""Deletes the specified qos policy.""" |
| 1936 |
return self.delete(self.qos_policy_path % qos_policy) |
| 1937 |
|
| 1938 |
def list_qos_rule_types(self, retrieve_all=True, **_params): |
| 1939 |
"""List available qos rule types.""" |
| 1940 |
return self.list('rule_types', self.qos_rule_types_path, |
| 1941 |
retrieve_all, **_params) |
| 1942 |
|
| 1943 |
def list_bandwidth_limit_rules(self, policy_id, |
| 1944 |
retrieve_all=True, **_params): |
| 1945 |
"""Fetches a list of all bandwidth limit rules for the given policy.""" |
| 1946 |
return self.list('bandwidth_limit_rules', |
| 1947 |
self.qos_bandwidth_limit_rules_path % policy_id, |
| 1948 |
retrieve_all, **_params) |
| 1949 |
|
| 1950 |
def show_bandwidth_limit_rule(self, rule, policy, **_params): |
| 1951 |
"""Fetches information of a certain bandwidth limit rule.""" |
| 1952 |
return self.get(self.qos_bandwidth_limit_rule_path % |
| 1953 |
(policy, rule), params=_params) |
| 1954 |
|
| 1955 |
def create_bandwidth_limit_rule(self, policy, body=None): |
| 1956 |
"""Creates a new bandwidth limit rule.""" |
| 1957 |
return self.post(self.qos_bandwidth_limit_rules_path % policy, |
| 1958 |
body=body) |
| 1959 |
|
| 1960 |
def update_bandwidth_limit_rule(self, rule, policy, body=None): |
| 1961 |
"""Updates a bandwidth limit rule.""" |
| 1962 |
return self.put(self.qos_bandwidth_limit_rule_path % |
| 1963 |
(policy, rule), body=body) |
| 1964 |
|
| 1965 |
def delete_bandwidth_limit_rule(self, rule, policy): |
| 1966 |
"""Deletes a bandwidth limit rule.""" |
| 1967 |
return self.delete(self.qos_bandwidth_limit_rule_path % |
| 1968 |
(policy, rule)) |
| 1969 |
|
| 1970 |
def list_dscp_marking_rules(self, policy_id, |
| 1971 |
retrieve_all=True, **_params): |
| 1972 |
"""Fetches a list of all DSCP marking rules for the given policy.""" |
| 1973 |
return self.list('dscp_marking_rules', |
| 1974 |
self.qos_dscp_marking_rules_path % policy_id, |
| 1975 |
retrieve_all, **_params) |
| 1976 |
|
| 1977 |
def show_dscp_marking_rule(self, rule, policy, **_params): |
| 1978 |
"""Shows information of a certain DSCP marking rule.""" |
| 1979 |
return self.get(self.qos_dscp_marking_rule_path % |
| 1980 |
(policy, rule), params=_params) |
| 1981 |
|
| 1982 |
def create_dscp_marking_rule(self, policy, body=None): |
| 1983 |
"""Creates a new DSCP marking rule.""" |
| 1984 |
return self.post(self.qos_dscp_marking_rules_path % policy, |
| 1985 |
body=body) |
| 1986 |
|
| 1987 |
def update_dscp_marking_rule(self, rule, policy, body=None): |
| 1988 |
"""Updates a DSCP marking rule.""" |
| 1989 |
return self.put(self.qos_dscp_marking_rule_path % |
| 1990 |
(policy, rule), body=body) |
| 1991 |
|
| 1992 |
def delete_dscp_marking_rule(self, rule, policy): |
| 1993 |
"""Deletes a DSCP marking rule.""" |
| 1994 |
return self.delete(self.qos_dscp_marking_rule_path % |
| 1995 |
(policy, rule)) |
| 1996 |
|
| 1997 |
def list_minimum_bandwidth_rules(self, policy_id, retrieve_all=True, |
| 1998 |
**_params): |
| 1999 |
"""Fetches a list of all minimum bandwidth rules for the given policy. |
| 2000 |
|
| 2001 |
""" |
| 2002 |
return self.list('minimum_bandwidth_rules', |
| 2003 |
self.qos_minimum_bandwidth_rules_path % |
| 2004 |
policy_id, retrieve_all, **_params) |
| 2005 |
|
| 2006 |
def show_minimum_bandwidth_rule(self, rule, policy, body=None): |
| 2007 |
"""Fetches information of a certain minimum bandwidth rule.""" |
| 2008 |
return self.get(self.qos_minimum_bandwidth_rule_path % |
| 2009 |
(policy, rule), body=body) |
| 2010 |
|
| 2011 |
def create_minimum_bandwidth_rule(self, policy, body=None): |
| 2012 |
"""Creates a new minimum bandwidth rule.""" |
| 2013 |
return self.post(self.qos_minimum_bandwidth_rules_path % policy, |
| 2014 |
body=body) |
| 2015 |
|
| 2016 |
def list_packet_rate_limit_rules(self, policy_id, retrieve_all=True, |
| 2017 |
**_params): |
| 2018 |
"""Fetches a list of all packet rate limit rules for the given policy |
| 2019 |
|
| 2020 |
""" |
| 2021 |
return self.list('packet_rate_limit_rules', |
| 2022 |
self.qos_packet_rate_limit_rules_path % |
| 2023 |
policy_id, retrieve_all, **_params) |
| 2024 |
|
| 2025 |
def show_packet_rate_limit_rule(self, rule, policy, body=None): |
| 2026 |
"""Fetches information of a certain packet rate limit rule.""" |
| 2027 |
return self.get(self.qos_packet_rate_limit_rule_path % |
| 2028 |
(policy, rule), body=body) |
| 2029 |
|
| 2030 |
def create_packet_rate_limit_rule(self, policy, body=None): |
| 2031 |
"""Creates a new packet rate limit rule.""" |
| 2032 |
return self.post(self.qos_packet_rate_limit_rules_path % policy, |
| 2033 |
body=body) |
| 2034 |
|
| 2035 |
def update_packet_rate_limit_rule(self, rule, policy, body=None): |
| 2036 |
"""Updates a packet rate limit rule.""" |
| 2037 |
return self.put(self.qos_packet_rate_limit_rule_path % |
| 2038 |
(policy, rule), body=body) |
| 2039 |
|
| 2040 |
def delete_packet_rate_limit_rule(self, rule, policy): |
| 2041 |
"""Deletes a packet rate limit rule.""" |
| 2042 |
return self.delete(self.qos_packet_rate_limit_rule_path % |
| 2043 |
(policy, rule)) |
| 2044 |
|
| 2045 |
def update_minimum_bandwidth_rule(self, rule, policy, body=None): |
| 2046 |
"""Updates a minimum bandwidth rule.""" |
| 2047 |
return self.put(self.qos_minimum_bandwidth_rule_path % |
| 2048 |
(policy, rule), body=body) |
| 2049 |
|
| 2050 |
def delete_minimum_bandwidth_rule(self, rule, policy): |
| 2051 |
"""Deletes a minimum bandwidth rule.""" |
| 2052 |
return self.delete(self.qos_minimum_bandwidth_rule_path % |
| 2053 |
(policy, rule)) |
| 2054 |
|
| 2055 |
def list_minimum_packet_rate_rules(self, policy_id, retrieve_all=True, |
| 2056 |
**_params): |
| 2057 |
"""Fetches a list of all minimum packet rate rules for the given policy |
| 2058 |
|
| 2059 |
""" |
| 2060 |
return self.list('minimum_packet_rate_rules', |
| 2061 |
self.qos_minimum_packet_rate_rules_path % |
| 2062 |
policy_id, retrieve_all, **_params) |
| 2063 |
|
| 2064 |
def show_minimum_packet_rate_rule(self, rule, policy, body=None): |
| 2065 |
"""Fetches information of a certain minimum packet rate rule.""" |
| 2066 |
return self.get(self.qos_minimum_packet_rate_rule_path % |
| 2067 |
(policy, rule), body=body) |
| 2068 |
|
| 2069 |
def create_minimum_packet_rate_rule(self, policy, body=None): |
| 2070 |
"""Creates a new minimum packet rate rule.""" |
| 2071 |
return self.post(self.qos_minimum_packet_rate_rules_path % policy, |
| 2072 |
body=body) |
| 2073 |
|
| 2074 |
def update_minimum_packet_rate_rule(self, rule, policy, body=None): |
| 2075 |
"""Updates a minimum packet rate rule.""" |
| 2076 |
return self.put(self.qos_minimum_packet_rate_rule_path % |
| 2077 |
(policy, rule), body=body) |
| 2078 |
|
| 2079 |
def delete_minimum_packet_rate_rule(self, rule, policy): |
| 2080 |
"""Deletes a minimum packet rate rule.""" |
| 2081 |
return self.delete(self.qos_minimum_packet_rate_rule_path % |
| 2082 |
(policy, rule)) |
| 2083 |
|
| 2084 |
def create_flavor(self, body=None): |
| 2085 |
"""Creates a new Neutron service flavor.""" |
| 2086 |
return self.post(self.flavors_path, body=body) |
| 2087 |
|
| 2088 |
def delete_flavor(self, flavor): |
| 2089 |
"""Deletes the specified Neutron service flavor.""" |
| 2090 |
return self.delete(self.flavor_path % (flavor)) |
| 2091 |
|
| 2092 |
def list_flavors(self, retrieve_all=True, **_params): |
| 2093 |
"""Fetches a list of all Neutron service flavors for a project.""" |
| 2094 |
return self.list('flavors', self.flavors_path, retrieve_all, |
| 2095 |
**_params) |
| 2096 |
|
| 2097 |
def show_flavor(self, flavor, **_params): |
| 2098 |
"""Fetches information for a certain Neutron service flavor.""" |
| 2099 |
return self.get(self.flavor_path % (flavor), params=_params) |
| 2100 |
|
| 2101 |
def update_flavor(self, flavor, body): |
| 2102 |
"""Update a Neutron service flavor.""" |
| 2103 |
return self.put(self.flavor_path % (flavor), body=body) |
| 2104 |
|
| 2105 |
def associate_flavor(self, flavor, body): |
| 2106 |
"""Associate a Neutron service flavor with a profile.""" |
| 2107 |
return self.post(self.flavor_profile_bindings_path % |
| 2108 |
(flavor), body=body) |
| 2109 |
|
| 2110 |
def disassociate_flavor(self, flavor, flavor_profile): |
| 2111 |
"""Disassociate a Neutron service flavor with a profile.""" |
| 2112 |
return self.delete(self.flavor_profile_binding_path % |
| 2113 |
(flavor, flavor_profile)) |
| 2114 |
|
| 2115 |
def create_service_profile(self, body=None): |
| 2116 |
"""Creates a new Neutron service flavor profile.""" |
| 2117 |
return self.post(self.service_profiles_path, body=body) |
| 2118 |
|
| 2119 |
def delete_service_profile(self, flavor_profile): |
| 2120 |
"""Deletes the specified Neutron service flavor profile.""" |
| 2121 |
return self.delete(self.service_profile_path % (flavor_profile)) |
| 2122 |
|
| 2123 |
def list_service_profiles(self, retrieve_all=True, **_params): |
| 2124 |
"""Fetches a list of all Neutron service flavor profiles.""" |
| 2125 |
return self.list('service_profiles', self.service_profiles_path, |
| 2126 |
retrieve_all, **_params) |
| 2127 |
|
| 2128 |
def show_service_profile(self, flavor_profile, **_params): |
| 2129 |
"""Fetches information for a certain Neutron service flavor profile.""" |
| 2130 |
return self.get(self.service_profile_path % (flavor_profile), |
| 2131 |
params=_params) |
| 2132 |
|
| 2133 |
def update_service_profile(self, service_profile, body): |
| 2134 |
"""Update a Neutron service profile.""" |
| 2135 |
return self.put(self.service_profile_path % (service_profile), |
| 2136 |
body=body) |
| 2137 |
|
| 2138 |
def list_availability_zones(self, retrieve_all=True, **_params): |
| 2139 |
"""Fetches a list of all availability zones.""" |
| 2140 |
return self.list('availability_zones', self.availability_zones_path, |
| 2141 |
retrieve_all, **_params) |
| 2142 |
|
| 2143 |
@debtcollector.renames.renamed_kwarg( |
| 2144 |
'tenant_id', 'project_id', replace=True) |
| 2145 |
def get_auto_allocated_topology(self, project_id, **_params): |
| 2146 |
"""Fetch information about a project's auto-allocated topology.""" |
| 2147 |
return self.get( |
| 2148 |
self.auto_allocated_topology_path % project_id, |
| 2149 |
params=_params) |
| 2150 |
|
| 2151 |
@debtcollector.renames.renamed_kwarg( |
| 2152 |
'tenant_id', 'project_id', replace=True) |
| 2153 |
def delete_auto_allocated_topology(self, project_id, **_params): |
| 2154 |
"""Delete a project's auto-allocated topology.""" |
| 2155 |
return self.delete( |
| 2156 |
self.auto_allocated_topology_path % project_id, |
| 2157 |
params=_params) |
| 2158 |
|
| 2159 |
@debtcollector.renames.renamed_kwarg( |
| 2160 |
'tenant_id', 'project_id', replace=True) |
| 2161 |
def validate_auto_allocated_topology_requirements(self, project_id): |
| 2162 |
"""Validate requirements for getting an auto-allocated topology.""" |
| 2163 |
return self.get_auto_allocated_topology(project_id, fields=['dry-run']) |
| 2164 |
|
| 2165 |
def list_bgp_speakers(self, retrieve_all=True, **_params): |
| 2166 |
"""Fetches a list of all BGP speakers for a project.""" |
| 2167 |
return self.list('bgp_speakers', self.bgp_speakers_path, retrieve_all, |
| 2168 |
**_params) |
| 2169 |
|
| 2170 |
def show_bgp_speaker(self, bgp_speaker_id, **_params): |
| 2171 |
"""Fetches information of a certain BGP speaker.""" |
| 2172 |
return self.get(self.bgp_speaker_path % (bgp_speaker_id), |
| 2173 |
params=_params) |
| 2174 |
|
| 2175 |
def create_bgp_speaker(self, body=None): |
| 2176 |
"""Creates a new BGP speaker.""" |
| 2177 |
return self.post(self.bgp_speakers_path, body=body) |
| 2178 |
|
| 2179 |
def update_bgp_speaker(self, bgp_speaker_id, body=None): |
| 2180 |
"""Update a BGP speaker.""" |
| 2181 |
return self.put(self.bgp_speaker_path % bgp_speaker_id, body=body) |
| 2182 |
|
| 2183 |
def delete_bgp_speaker(self, speaker_id): |
| 2184 |
"""Deletes the specified BGP speaker.""" |
| 2185 |
return self.delete(self.bgp_speaker_path % (speaker_id)) |
| 2186 |
|
| 2187 |
def add_peer_to_bgp_speaker(self, speaker_id, body=None): |
| 2188 |
"""Adds a peer to BGP speaker.""" |
| 2189 |
return self.put((self.bgp_speaker_path % speaker_id) + |
| 2190 |
"/add_bgp_peer", body=body) |
| 2191 |
|
| 2192 |
def remove_peer_from_bgp_speaker(self, speaker_id, body=None): |
| 2193 |
"""Removes a peer from BGP speaker.""" |
| 2194 |
return self.put((self.bgp_speaker_path % speaker_id) + |
| 2195 |
"/remove_bgp_peer", body=body) |
| 2196 |
|
| 2197 |
def add_network_to_bgp_speaker(self, speaker_id, body=None): |
| 2198 |
"""Adds a network to BGP speaker.""" |
| 2199 |
return self.put((self.bgp_speaker_path % speaker_id) + |
| 2200 |
"/add_gateway_network", body=body) |
| 2201 |
|
| 2202 |
def remove_network_from_bgp_speaker(self, speaker_id, body=None): |
| 2203 |
"""Removes a network from BGP speaker.""" |
| 2204 |
return self.put((self.bgp_speaker_path % speaker_id) + |
| 2205 |
"/remove_gateway_network", body=body) |
| 2206 |
|
| 2207 |
def list_route_advertised_from_bgp_speaker(self, speaker_id, **_params): |
| 2208 |
"""Fetches a list of all routes advertised by BGP speaker.""" |
| 2209 |
return self.get((self.bgp_speaker_path % speaker_id) + |
| 2210 |
"/get_advertised_routes", params=_params) |
| 2211 |
|
| 2212 |
def list_bgp_peers(self, **_params): |
| 2213 |
"""Fetches a list of all BGP peers.""" |
| 2214 |
return self.get(self.bgp_peers_path, params=_params) |
| 2215 |
|
| 2216 |
def show_bgp_peer(self, peer_id, **_params): |
| 2217 |
"""Fetches information of a certain BGP peer.""" |
| 2218 |
return self.get(self.bgp_peer_path % peer_id, |
| 2219 |
params=_params) |
| 2220 |
|
| 2221 |
def create_bgp_peer(self, body=None): |
| 2222 |
"""Create a new BGP peer.""" |
| 2223 |
return self.post(self.bgp_peers_path, body=body) |
| 2224 |
|
| 2225 |
def update_bgp_peer(self, bgp_peer_id, body=None): |
| 2226 |
"""Update a BGP peer.""" |
| 2227 |
return self.put(self.bgp_peer_path % bgp_peer_id, body=body) |
| 2228 |
|
| 2229 |
def delete_bgp_peer(self, peer_id): |
| 2230 |
"""Deletes the specified BGP peer.""" |
| 2231 |
return self.delete(self.bgp_peer_path % peer_id) |
| 2232 |
|
| 2233 |
def list_network_ip_availabilities(self, retrieve_all=True, **_params): |
| 2234 |
"""Fetches IP availability information for all networks""" |
| 2235 |
return self.list('network_ip_availabilities', |
| 2236 |
self.network_ip_availabilities_path, |
| 2237 |
retrieve_all, **_params) |
| 2238 |
|
| 2239 |
def show_network_ip_availability(self, network, **_params): |
| 2240 |
"""Fetches IP availability information for a specified network""" |
| 2241 |
return self.get(self.network_ip_availability_path % (network), |
| 2242 |
params=_params) |
| 2243 |
|
| 2244 |
def add_tag(self, resource_type, resource_id, tag, **_params): |
| 2245 |
"""Add a tag on the resource.""" |
| 2246 |
return self.put(self.tag_path % (resource_type, resource_id, tag)) |
| 2247 |
|
| 2248 |
def replace_tag(self, resource_type, resource_id, body, **_params): |
| 2249 |
"""Replace tags on the resource.""" |
| 2250 |
return self.put(self.tags_path % (resource_type, resource_id), body) |
| 2251 |
|
| 2252 |
def remove_tag(self, resource_type, resource_id, tag, **_params): |
| 2253 |
"""Remove a tag on the resource.""" |
| 2254 |
return self.delete(self.tag_path % (resource_type, resource_id, tag)) |
| 2255 |
|
| 2256 |
def remove_tag_all(self, resource_type, resource_id, **_params): |
| 2257 |
"""Remove all tags on the resource.""" |
| 2258 |
return self.delete(self.tags_path % (resource_type, resource_id)) |
| 2259 |
|
| 2260 |
def create_trunk(self, body=None): |
| 2261 |
"""Create a trunk port.""" |
| 2262 |
return self.post(self.trunks_path, body=body) |
| 2263 |
|
| 2264 |
def update_trunk(self, trunk, body=None, revision_number=None): |
| 2265 |
"""Update a trunk port.""" |
| 2266 |
return self._update_resource(self.trunk_path % trunk, body=body, |
| 2267 |
revision_number=revision_number) |
| 2268 |
|
| 2269 |
def delete_trunk(self, trunk): |
| 2270 |
"""Delete a trunk port.""" |
| 2271 |
return self.delete(self.trunk_path % (trunk)) |
| 2272 |
|
| 2273 |
def list_trunks(self, retrieve_all=True, **_params): |
| 2274 |
"""Fetch a list of all trunk ports.""" |
| 2275 |
return self.list('trunks', self.trunks_path, retrieve_all, |
| 2276 |
**_params) |
| 2277 |
|
| 2278 |
def show_trunk(self, trunk, **_params): |
| 2279 |
"""Fetch information for a certain trunk port.""" |
| 2280 |
return self.get(self.trunk_path % (trunk), params=_params) |
| 2281 |
|
| 2282 |
def trunk_add_subports(self, trunk, body=None): |
| 2283 |
"""Add specified subports to the trunk.""" |
| 2284 |
return self.put(self.subports_add_path % (trunk), body=body) |
| 2285 |
|
| 2286 |
def trunk_remove_subports(self, trunk, body=None): |
| 2287 |
"""Removes specified subports from the trunk.""" |
| 2288 |
return self.put(self.subports_remove_path % (trunk), body=body) |
| 2289 |
|
| 2290 |
def trunk_get_subports(self, trunk, **_params): |
| 2291 |
"""Fetch a list of all subports attached to given trunk.""" |
| 2292 |
return self.get(self.subports_path % (trunk), params=_params) |
| 2293 |
|
| 2294 |
def list_bgpvpns(self, retrieve_all=True, **_params): |
| 2295 |
"""Fetches a list of all BGP VPNs for a project""" |
| 2296 |
return self.list('bgpvpns', self.bgpvpns_path, retrieve_all, **_params) |
| 2297 |
|
| 2298 |
def show_bgpvpn(self, bgpvpn, **_params): |
| 2299 |
"""Fetches information of a certain BGP VPN""" |
| 2300 |
return self.get(self.bgpvpn_path % bgpvpn, params=_params) |
| 2301 |
|
| 2302 |
def create_bgpvpn(self, body=None): |
| 2303 |
"""Creates a new BGP VPN""" |
| 2304 |
return self.post(self.bgpvpns_path, body=body) |
| 2305 |
|
| 2306 |
def update_bgpvpn(self, bgpvpn, body=None): |
| 2307 |
"""Updates a BGP VPN""" |
| 2308 |
return self.put(self.bgpvpn_path % bgpvpn, body=body) |
| 2309 |
|
| 2310 |
def delete_bgpvpn(self, bgpvpn): |
| 2311 |
"""Deletes the specified BGP VPN""" |
| 2312 |
return self.delete(self.bgpvpn_path % bgpvpn) |
| 2313 |
|
| 2314 |
def list_bgpvpn_network_assocs(self, bgpvpn, retrieve_all=True, **_params): |
| 2315 |
"""Fetches a list of network associations for a given BGP VPN.""" |
| 2316 |
return self.list('network_associations', |
| 2317 |
self.bgpvpn_network_associations_path % bgpvpn, |
| 2318 |
retrieve_all, **_params) |
| 2319 |
|
| 2320 |
def show_bgpvpn_network_assoc(self, bgpvpn, net_assoc, **_params): |
| 2321 |
"""Fetches information of a certain BGP VPN's network association""" |
| 2322 |
return self.get( |
| 2323 |
self.bgpvpn_network_association_path % (bgpvpn, net_assoc), |
| 2324 |
params=_params) |
| 2325 |
|
| 2326 |
def create_bgpvpn_network_assoc(self, bgpvpn, body=None): |
| 2327 |
"""Creates a new BGP VPN network association""" |
| 2328 |
return self.post(self.bgpvpn_network_associations_path % bgpvpn, |
| 2329 |
body=body) |
| 2330 |
|
| 2331 |
def update_bgpvpn_network_assoc(self, bgpvpn, net_assoc, body=None): |
| 2332 |
"""Updates a BGP VPN network association""" |
| 2333 |
return self.put( |
| 2334 |
self.bgpvpn_network_association_path % (bgpvpn, net_assoc), |
| 2335 |
body=body) |
| 2336 |
|
| 2337 |
def delete_bgpvpn_network_assoc(self, bgpvpn, net_assoc): |
| 2338 |
"""Deletes the specified BGP VPN network association""" |
| 2339 |
return self.delete( |
| 2340 |
self.bgpvpn_network_association_path % (bgpvpn, net_assoc)) |
| 2341 |
|
| 2342 |
def list_bgpvpn_router_assocs(self, bgpvpn, retrieve_all=True, **_params): |
| 2343 |
"""Fetches a list of router associations for a given BGP VPN.""" |
| 2344 |
return self.list('router_associations', |
| 2345 |
self.bgpvpn_router_associations_path % bgpvpn, |
| 2346 |
retrieve_all, **_params) |
| 2347 |
|
| 2348 |
def show_bgpvpn_router_assoc(self, bgpvpn, router_assoc, **_params): |
| 2349 |
"""Fetches information of a certain BGP VPN's router association""" |
| 2350 |
return self.get( |
| 2351 |
self.bgpvpn_router_association_path % (bgpvpn, router_assoc), |
| 2352 |
params=_params) |
| 2353 |
|
| 2354 |
def create_bgpvpn_router_assoc(self, bgpvpn, body=None): |
| 2355 |
"""Creates a new BGP VPN router association""" |
| 2356 |
return self.post(self.bgpvpn_router_associations_path % bgpvpn, |
| 2357 |
body=body) |
| 2358 |
|
| 2359 |
def update_bgpvpn_router_assoc(self, bgpvpn, router_assoc, body=None): |
| 2360 |
"""Updates a BGP VPN router association""" |
| 2361 |
return self.put( |
| 2362 |
self.bgpvpn_router_association_path % (bgpvpn, router_assoc), |
| 2363 |
body=body) |
| 2364 |
|
| 2365 |
def delete_bgpvpn_router_assoc(self, bgpvpn, router_assoc): |
| 2366 |
"""Deletes the specified BGP VPN router association""" |
| 2367 |
return self.delete( |
| 2368 |
self.bgpvpn_router_association_path % (bgpvpn, router_assoc)) |
| 2369 |
|
| 2370 |
def list_bgpvpn_port_assocs(self, bgpvpn, retrieve_all=True, **_params): |
| 2371 |
"""Fetches a list of port associations for a given BGP VPN.""" |
| 2372 |
return self.list('port_associations', |
| 2373 |
self.bgpvpn_port_associations_path % bgpvpn, |
| 2374 |
retrieve_all, **_params) |
| 2375 |
|
| 2376 |
def show_bgpvpn_port_assoc(self, bgpvpn, port_assoc, **_params): |
| 2377 |
"""Fetches information of a certain BGP VPN's port association""" |
| 2378 |
return self.get( |
| 2379 |
self.bgpvpn_port_association_path % (bgpvpn, port_assoc), |
| 2380 |
params=_params) |
| 2381 |
|
| 2382 |
def create_bgpvpn_port_assoc(self, bgpvpn, body=None): |
| 2383 |
"""Creates a new BGP VPN port association""" |
| 2384 |
return self.post(self.bgpvpn_port_associations_path % bgpvpn, |
| 2385 |
body=body) |
| 2386 |
|
| 2387 |
def update_bgpvpn_port_assoc(self, bgpvpn, port_assoc, body=None): |
| 2388 |
"""Updates a BGP VPN port association""" |
| 2389 |
return self.put( |
| 2390 |
self.bgpvpn_port_association_path % (bgpvpn, port_assoc), |
| 2391 |
body=body) |
| 2392 |
|
| 2393 |
def delete_bgpvpn_port_assoc(self, bgpvpn, port_assoc): |
| 2394 |
"""Deletes the specified BGP VPN port association""" |
| 2395 |
return self.delete( |
| 2396 |
self.bgpvpn_port_association_path % (bgpvpn, port_assoc)) |
| 2397 |
|
| 2398 |
def create_sfc_port_pair(self, body=None): |
| 2399 |
"""Creates a new Port Pair.""" |
| 2400 |
return self.post(self.sfc_port_pairs_path, body=body) |
| 2401 |
|
| 2402 |
def update_sfc_port_pair(self, port_pair, body=None): |
| 2403 |
"""Update a Port Pair.""" |
| 2404 |
return self.put(self.sfc_port_pair_path % port_pair, body=body) |
| 2405 |
|
| 2406 |
def delete_sfc_port_pair(self, port_pair): |
| 2407 |
"""Deletes the specified Port Pair.""" |
| 2408 |
return self.delete(self.sfc_port_pair_path % (port_pair)) |
| 2409 |
|
| 2410 |
def list_sfc_port_pairs(self, retrieve_all=True, **_params): |
| 2411 |
"""Fetches a list of all Port Pairs.""" |
| 2412 |
return self.list('port_pairs', self.sfc_port_pairs_path, retrieve_all, |
| 2413 |
**_params) |
| 2414 |
|
| 2415 |
def show_sfc_port_pair(self, port_pair, **_params): |
| 2416 |
"""Fetches information of a certain Port Pair.""" |
| 2417 |
return self.get(self.sfc_port_pair_path % (port_pair), params=_params) |
| 2418 |
|
| 2419 |
def create_sfc_port_pair_group(self, body=None): |
| 2420 |
"""Creates a new Port Pair Group.""" |
| 2421 |
return self.post(self.sfc_port_pair_groups_path, body=body) |
| 2422 |
|
| 2423 |
def update_sfc_port_pair_group(self, port_pair_group, body=None): |
| 2424 |
"""Update a Port Pair Group.""" |
| 2425 |
return self.put(self.sfc_port_pair_group_path % port_pair_group, |
| 2426 |
body=body) |
| 2427 |
|
| 2428 |
def delete_sfc_port_pair_group(self, port_pair_group): |
| 2429 |
"""Deletes the specified Port Pair Group.""" |
| 2430 |
return self.delete(self.sfc_port_pair_group_path % (port_pair_group)) |
| 2431 |
|
| 2432 |
def list_sfc_port_pair_groups(self, retrieve_all=True, **_params): |
| 2433 |
"""Fetches a list of all Port Pair Groups.""" |
| 2434 |
return self.list('port_pair_groups', self.sfc_port_pair_groups_path, |
| 2435 |
retrieve_all, **_params) |
| 2436 |
|
| 2437 |
def show_sfc_port_pair_group(self, port_pair_group, **_params): |
| 2438 |
"""Fetches information of a certain Port Pair Group.""" |
| 2439 |
return self.get(self.sfc_port_pair_group_path % (port_pair_group), |
| 2440 |
params=_params) |
| 2441 |
|
| 2442 |
def create_sfc_port_chain(self, body=None): |
| 2443 |
"""Creates a new Port Chain.""" |
| 2444 |
return self.post(self.sfc_port_chains_path, body=body) |
| 2445 |
|
| 2446 |
def update_sfc_port_chain(self, port_chain, body=None): |
| 2447 |
"""Update a Port Chain.""" |
| 2448 |
return self.put(self.sfc_port_chain_path % port_chain, body=body) |
| 2449 |
|
| 2450 |
def delete_sfc_port_chain(self, port_chain): |
| 2451 |
"""Deletes the specified Port Chain.""" |
| 2452 |
return self.delete(self.sfc_port_chain_path % (port_chain)) |
| 2453 |
|
| 2454 |
def list_sfc_port_chains(self, retrieve_all=True, **_params): |
| 2455 |
"""Fetches a list of all Port Chains.""" |
| 2456 |
return self.list('port_chains', self.sfc_port_chains_path, |
| 2457 |
retrieve_all, **_params) |
| 2458 |
|
| 2459 |
def show_sfc_port_chain(self, port_chain, **_params): |
| 2460 |
"""Fetches information of a certain Port Chain.""" |
| 2461 |
return self.get(self.sfc_port_chain_path % (port_chain), |
| 2462 |
params=_params) |
| 2463 |
|
| 2464 |
def create_sfc_flow_classifier(self, body=None): |
| 2465 |
"""Creates a new Flow Classifier.""" |
| 2466 |
return self.post(self.sfc_flow_classifiers_path, body=body) |
| 2467 |
|
| 2468 |
def update_sfc_flow_classifier(self, flow_classifier, body=None): |
| 2469 |
"""Update a Flow Classifier.""" |
| 2470 |
return self.put(self.sfc_flow_classifier_path % flow_classifier, |
| 2471 |
body=body) |
| 2472 |
|
| 2473 |
def delete_sfc_flow_classifier(self, flow_classifier): |
| 2474 |
"""Deletes the specified Flow Classifier.""" |
| 2475 |
return self.delete(self.sfc_flow_classifier_path % (flow_classifier)) |
| 2476 |
|
| 2477 |
def list_sfc_flow_classifiers(self, retrieve_all=True, **_params): |
| 2478 |
"""Fetches a list of all Flow Classifiers.""" |
| 2479 |
return self.list('flow_classifiers', self.sfc_flow_classifiers_path, |
| 2480 |
retrieve_all, **_params) |
| 2481 |
|
| 2482 |
def show_sfc_flow_classifier(self, flow_classifier, **_params): |
| 2483 |
"""Fetches information of a certain Flow Classifier.""" |
| 2484 |
return self.get(self.sfc_flow_classifier_path % (flow_classifier), |
| 2485 |
params=_params) |
| 2486 |
|
| 2487 |
def create_sfc_service_graph(self, body=None): |
| 2488 |
"""Create the specified Service Graph.""" |
| 2489 |
return self.post(self.sfc_service_graphs_path, body=body) |
| 2490 |
|
| 2491 |
def update_sfc_service_graph(self, service_graph, body=None): |
| 2492 |
"""Update a Service Graph.""" |
| 2493 |
return self.put(self.sfc_service_graph_path % service_graph, |
| 2494 |
body=body) |
| 2495 |
|
| 2496 |
def delete_sfc_service_graph(self, service_graph): |
| 2497 |
"""Deletes the specified Service Graph.""" |
| 2498 |
return self.delete(self.sfc_service_graph_path % service_graph) |
| 2499 |
|
| 2500 |
def list_sfc_service_graphs(self, retrieve_all=True, **_params): |
| 2501 |
"""Fetches a list of all Service Graphs.""" |
| 2502 |
return self.list('service_graphs', self.sfc_service_graphs_path, |
| 2503 |
retrieve_all, **_params) |
| 2504 |
|
| 2505 |
def show_sfc_service_graph(self, service_graph, **_params): |
| 2506 |
"""Fetches information of a certain Service Graph.""" |
| 2507 |
return self.get(self.sfc_service_graph_path % service_graph, |
| 2508 |
params=_params) |
| 2509 |
|
| 2510 |
def create_network_log(self, body=None): |
| 2511 |
"""Create a network log.""" |
| 2512 |
return self.post(self.network_logs_path, body=body) |
| 2513 |
|
| 2514 |
def delete_network_log(self, net_log): |
| 2515 |
"""Delete a network log.""" |
| 2516 |
return self.delete(self.network_log_path % net_log) |
| 2517 |
|
| 2518 |
def list_network_logs(self, retrieve_all=True, **_params): |
| 2519 |
"""Fetch a list of all network logs.""" |
| 2520 |
return self.list( |
| 2521 |
'logs', self.network_logs_path, retrieve_all, **_params) |
| 2522 |
|
| 2523 |
def show_network_log(self, net_log, **_params): |
| 2524 |
"""Fetch information for a certain network log.""" |
| 2525 |
return self.get(self.network_log_path % net_log, params=_params) |
| 2526 |
|
| 2527 |
def update_network_log(self, net_log, body=None): |
| 2528 |
"""Update a network log.""" |
| 2529 |
return self.put(self.network_log_path % net_log, body=body) |
| 2530 |
|
| 2531 |
def list_network_loggable_resources(self, retrieve_all=True, **_params): |
| 2532 |
"""Fetch a list of supported resource types for network log.""" |
| 2533 |
return self.list('loggable_resources', self.network_loggables_path, |
| 2534 |
retrieve_all, **_params) |
| 2535 |
|
| 2536 |
def onboard_network_subnets(self, subnetpool, body=None): |
| 2537 |
"""Onboard the specified network's subnets into a subnet pool.""" |
| 2538 |
return self.put(self.onboard_network_subnets_path % (subnetpool), |
| 2539 |
body=body) |
| 2540 |
|
| 2541 |
def __init__(self, **kwargs): |
| 2542 |
"""Initialize a new client for the Neutron v2.0 API.""" |
| 2543 |
super(Client, self).__init__(**kwargs) |
| 2544 |
self._register_extensions(self.version) |
| 2545 |
|
| 2546 |
def _update_resource(self, path, **kwargs): |
| 2547 |
revision_number = kwargs.pop('revision_number', None) |
| 2548 |
if revision_number: |
| 2549 |
headers = kwargs.setdefault('headers', {}) |
| 2550 |
headers['If-Match'] = 'revision_number=%s' % revision_number |
| 2551 |
return self.put(path, **kwargs) |
| 2552 |
|
| 2553 |
def extend_show(self, resource_singular, path, parent_resource): |
| 2554 |
def _fx(obj, **_params): |
| 2555 |
return self.show_ext(path, obj, **_params) |
| 2556 |
|
| 2557 |
def _parent_fx(obj, parent_id, **_params): |
| 2558 |
return self.show_ext(path % parent_id, obj, **_params) |
| 2559 |
fn = _fx if not parent_resource else _parent_fx |
| 2560 |
setattr(self, "show_%s" % resource_singular, fn) |
| 2561 |
|
| 2562 |
def extend_list(self, resource_plural, path, parent_resource): |
| 2563 |
def _fx(retrieve_all=True, **_params): |
| 2564 |
return self.list_ext(resource_plural, path, |
| 2565 |
retrieve_all, **_params) |
| 2566 |
|
| 2567 |
def _parent_fx(parent_id, retrieve_all=True, **_params): |
| 2568 |
return self.list_ext(resource_plural, path % parent_id, |
| 2569 |
retrieve_all, **_params) |
| 2570 |
fn = _fx if not parent_resource else _parent_fx |
| 2571 |
setattr(self, "list_%s" % resource_plural, fn) |
| 2572 |
|
| 2573 |
def extend_create(self, resource_singular, path, parent_resource): |
| 2574 |
def _fx(body=None): |
| 2575 |
return self.create_ext(path, body) |
| 2576 |
|
| 2577 |
def _parent_fx(parent_id, body=None): |
| 2578 |
return self.create_ext(path % parent_id, body) |
| 2579 |
fn = _fx if not parent_resource else _parent_fx |
| 2580 |
setattr(self, "create_%s" % resource_singular, fn) |
| 2581 |
|
| 2582 |
def extend_delete(self, resource_singular, path, parent_resource): |
| 2583 |
def _fx(obj): |
| 2584 |
return self.delete_ext(path, obj) |
| 2585 |
|
| 2586 |
def _parent_fx(obj, parent_id): |
| 2587 |
return self.delete_ext(path % parent_id, obj) |
| 2588 |
fn = _fx if not parent_resource else _parent_fx |
| 2589 |
setattr(self, "delete_%s" % resource_singular, fn) |
| 2590 |
|
| 2591 |
def extend_update(self, resource_singular, path, parent_resource): |
| 2592 |
def _fx(obj, body=None): |
| 2593 |
return self.update_ext(path, obj, body) |
| 2594 |
|
| 2595 |
def _parent_fx(obj, parent_id, body=None): |
| 2596 |
return self.update_ext(path % parent_id, obj, body) |
| 2597 |
fn = _fx if not parent_resource else _parent_fx |
| 2598 |
setattr(self, "update_%s" % resource_singular, fn) |
| 2599 |
|
| 2600 |
def _extend_client_with_module(self, module, version): |
| 2601 |
classes = inspect.getmembers(module, inspect.isclass) |
| 2602 |
for cls_name, cls in classes: |
| 2603 |
if hasattr(cls, 'versions'): |
| 2604 |
if version not in cls.versions: |
| 2605 |
continue |
| 2606 |
parent_resource = getattr(cls, 'parent_resource', None) |
| 2607 |
if issubclass(cls, client_extension.ClientExtensionList): |
| 2608 |
self.extend_list(cls.resource_plural, cls.object_path, |
| 2609 |
parent_resource) |
| 2610 |
elif issubclass(cls, client_extension.ClientExtensionCreate): |
| 2611 |
self.extend_create(cls.resource, cls.object_path, |
| 2612 |
parent_resource) |
| 2613 |
elif issubclass(cls, client_extension.ClientExtensionUpdate): |
| 2614 |
self.extend_update(cls.resource, cls.resource_path, |
| 2615 |
parent_resource) |
| 2616 |
elif issubclass(cls, client_extension.ClientExtensionDelete): |
| 2617 |
self.extend_delete(cls.resource, cls.resource_path, |
| 2618 |
parent_resource) |
| 2619 |
elif issubclass(cls, client_extension.ClientExtensionShow): |
| 2620 |
self.extend_show(cls.resource, cls.resource_path, |
| 2621 |
parent_resource) |
| 2622 |
elif issubclass(cls, client_extension.NeutronClientExtension): |
| 2623 |
setattr(self, "%s_path" % cls.resource_plural, |
| 2624 |
cls.object_path) |
| 2625 |
setattr(self, "%s_path" % cls.resource, cls.resource_path) |
| 2626 |
self.EXTED_PLURALS.update({cls.resource_plural: cls.resource}) |
| 2627 |
|
| 2628 |
def _register_extensions(self, version): |
| 2629 |
for name, module in itertools.chain( |
| 2630 |
client_extension._discover_via_entry_points()): |
| 2631 |
self._extend_client_with_module(module, version) |