yakumo.neutron.v2.subnet_pool

Package yakumo :: Package neutron :: Package v2 :: Module subnet_pool |
[hide private]
[frames] | no frames]

# Source Code for Module yakumo.neutron.v2.subnet_pool

      1  # Copyright 2014-2017 by Akira Yoshiyama <akirayoshiyama@gmail.com>.
      2  # All Rights Reserved.
      3  #
      4  #    Licensed under the Apache License, Version 2.0 (the "License"); you may
      5  #    not use this file except in compliance with the License. You may obtain
      6  #    a copy of the License at
      7  #
      8  #         http://www.apache.org/licenses/LICENSE-2.0
      9  #
     10  #    Unless required by applicable law or agreed to in writing, software
     11  #    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
     12  #    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
     13  #    License for the specific language governing permissions and limitations
     14  #    under the License.
     15
     16  """
     17  Resource class and its manager for subnet pools in Compute API v2
     18  """
     19
     20  from yakumo import base
     21  from yakumo.constant import UNDEF
     22  from yakumo import mapper
     23  from yakumo import utils
     24
     25
     26  ATTRIBUTE_MAPPING = [
     27      ('id', 'id', mapper.Noop),
     28      ('name', 'name', mapper.Noop),
     29      ('prefixes', 'prefixes', mapper.Noop),
     30      ('ip_version', 'ip_version', mapper.Noop),
     31      ('min_prefixlen', 'min_prefixlen', mapper.Noop),
     32      ('default_prefixlen', 'default_prefixlen', mapper.Noop),
     33      ('max_prefixlen', 'max_prefixlen', mapper.Noop),
     34      ('default_quota', 'default_quota', mapper.Noop),
     35      ('is_shared', 'shared', mapper.Noop,),
     36      ('address_scope_id', 'address_scope_id', mapper.Noop),
     37      ('project', 'tenant_id', mapper.Resource('project')),
     38  ]
     39
     40
     41 -class Resource(base.Resource):
     42      """Resource class for subnet pools in Compute API v2"""
     43
     44 -    def update(self, name=UNDEF, address_scope_id=UNDEF, prefixes=UNDEF,
     45                 default_prefixlen=UNDEF, min_prefixlen=UNDEF,
     46                 max_prefixlen=UNDEF, default_quota=UNDEF, project=UNDEF):
     47          """
     48          Update a subnet pool
     49
     50          @keyword name: Subnet pool name
     51          @type name: str
     52          @keyword address_scope_id: UUID of address scope
     53          @type address_scope_id: str
     54          @keyword prefixes: a list of subnets
     55          @type prefixes: [str]
     56          @keyword default_prefixlen: Default prefix length
     57          @type default_prefixlen: int
     58          @keyword min_prefixlen: Minimum prefix length
     59          @type min_prefixlen: int
     60          @keyword max_prefixlen: Maximum prefix length
     61          @type max_prefixlen: int
     62          @keyword default_quota: Default quota
     63          @type default_quota: int
     64          @keyword project: Project
     65          @type project: yakumo.project.Resource
     66          @rtype: None
     67          """
     68          super(Resource, self).update(
     69              name=name,
     70              address_scope_id=address_scope_id,
     71              prefixes=prefixes,
     72              default_prefixlen=default_prefixlen,
     73              min_prefixlen=min_prefixlen,
     74              max_prefixlen=max_prefixlen,
     75              default_quota=default_quota,
     76              project=project)
     77
     78
     79 -class Manager(base.Manager):
     80      """Manager class for subnet pools in Compute API v2"""
     81
     82      resource_class = Resource
     83      service_type = 'network'
     84      _attr_mapping = ATTRIBUTE_MAPPING
     85      _json_resource_key = 'subnetpool'
     86      _json_resources_key = 'subnetpools'
     87      _url_resource_path = '/v2.0/subnetpools'
     88
     89 -    def create(self, name=UNDEF, address_scope_id=UNDEF, prefixes=UNDEF,
     90                 default_prefixlen=UNDEF, min_prefixlen=UNDEF,
     91                 max_prefixlen=UNDEF, default_quota=UNDEF, project=UNDEF,
     92                 is_shared=UNDEF):
     93          """
     94          Create a subnet pool
     95
     96          @keyword name: Subnet pool name
     97          @type name: str
     98          @keyword address_scope_id: UUID of address scope
     99          @type address_scope_id: str
    100          @keyword prefixes: a list of subnets
    101          @type prefixes: [str]
    102          @keyword default_prefixlen: Default prefix length
    103          @type default_prefixlen: int
    104          @keyword min_prefixlen: Minimum prefix length
    105          @type min_prefixlen: int
    106          @keyword max_prefixlen: Maximum prefix length
    107          @type max_prefixlen: int
    108          @keyword default_quota: Default quota
    109          @type default_quota: int
    110          @keyword project: Project
    111          @type project: yakumo.porject.Resource
    112          @keyword is_shared: Whether the subnet pool is shared
    113          @type is_shared: bool
    114          @return: Created subnet pool
    115          @rtype: yakumo.neutron.v2.subnet_pool.Resource
    116          """
    117          return super(Manager, self).create(
    118              name=name,
    119              address_scope_id=address_scope_id,
    120              prefixes=prefixes,
    121              default_prefixlen=default_prefixlen,
    122              min_prefixlen=min_prefixlen,
    123              max_prefixlen=max_prefixlen,
    124              default_quota=default_quota,
    125              project=project,
    126              is_shared=is_shared)
    127