summaryrefslogtreecommitdiff
path: root/novaclient/v2/contrib/tenant_networks.py
diff options
context:
space:
mode:
authorAndrey Kurilin <akurilin@mirantis.com>2015-02-03 02:32:58 +0200
committerAndrey Kurilin <akurilin@mirantis.com>2015-02-04 17:40:46 +0200
commit0a60aae852d2688861d0b4ba097a1a00529f0611 (patch)
treeb08ba9344b88e38767f54c5d5c7366c2ef306608 /novaclient/v2/contrib/tenant_networks.py
parent4e76f9590b49c925703cbbf42d1e232725465eff (diff)
Rename v1_1 to v2
Module novaclient.v1_1 is used as implementation of V1.1, V2 and V3. Since future development(microversioning) will be done across V2, implementation should be done in appropriate module(to prevent misleading). Despite the fact that implementation for all versions are equal, discover method for contrib path worked only for v1.1. This patch fixes this bug and modifies shell tests to check all versions. Change-Id: Ib6798f4dfe177586302141f522dc593560ce6a5b
Notes
Notes (review): Verified+2: Jenkins Code-Review+2: Kevin L. Mitchell <kevin.mitchell@rackspace.com> Code-Review+2: Sean Dague <sean@dague.net> Workflow+1: Sean Dague <sean@dague.net> Submitted-by: Jenkins Submitted-at: Thu, 05 Feb 2015 00:17:20 +0000 Reviewed-on: https://review.openstack.org/149006 Project: openstack/python-novaclient Branch: refs/heads/master
Diffstat (limited to 'novaclient/v2/contrib/tenant_networks.py')
-rw-r--r--novaclient/v2/contrib/tenant_networks.py82
1 files changed, 82 insertions, 0 deletions
diff --git a/novaclient/v2/contrib/tenant_networks.py b/novaclient/v2/contrib/tenant_networks.py
new file mode 100644
index 0000000..06edeb1
--- /dev/null
+++ b/novaclient/v2/contrib/tenant_networks.py
@@ -0,0 +1,82 @@
1# Copyright 2013 OpenStack Foundation
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15from novaclient import base
16from novaclient.i18n import _
17from novaclient.openstack.common import cliutils
18from novaclient import utils
19
20
21class TenantNetwork(base.Resource):
22 def delete(self):
23 self.manager.delete(network=self)
24
25
26class TenantNetworkManager(base.ManagerWithFind):
27 resource_class = base.Resource
28
29 def list(self):
30 return self._list('/os-tenant-networks', 'networks')
31
32 def get(self, network):
33 return self._get('/os-tenant-networks/%s' % base.getid(network),
34 'network')
35
36 def delete(self, network):
37 self._delete('/os-tenant-networks/%s' % base.getid(network))
38
39 def create(self, label, cidr):
40 body = {'network': {'label': label, 'cidr': cidr}}
41 return self._create('/os-tenant-networks', body, 'network')
42
43
44@cliutils.arg('network_id', metavar='<network_id>', help='ID of network')
45def do_net(cs, args):
46 """
47 Show a network
48 """
49 network = cs.tenant_networks.get(args.network_id)
50 utils.print_dict(network._info)
51
52
53def do_net_list(cs, args):
54 """
55 List networks
56 """
57 networks = cs.tenant_networks.list()
58 utils.print_list(networks, ['ID', 'Label', 'CIDR'])
59
60
61@cliutils.arg(
62 'label',
63 metavar='<network_label>',
64 help=_('Network label (ex. my_new_network)'))
65@cliutils.arg(
66 'cidr',
67 metavar='<cidr>',
68 help=_('IP block to allocate from (ex. 172.16.0.0/24 or 2001:DB8::/64)'))
69def do_net_create(cs, args):
70 """
71 Create a network
72 """
73 network = cs.tenant_networks.create(args.label, args.cidr)
74 utils.print_dict(network._info)
75
76
77@cliutils.arg('network_id', metavar='<network_id>', help='ID of network')
78def do_net_delete(cs, args):
79 """
80 Delete a network
81 """
82 cs.tenant_networks.delete(args.network_id)