~ubuntu-branches/ubuntu/trusty/heat/trusty

« back to all changes in this revision

Viewing changes to .pc/rename-quantumclient.patch/heat/engine/resources/quantum/subnet.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short, Chuck Short
  • Date: 2013-08-08 01:08:42 UTC
  • Revision ID: package-import@ubuntu.com-20130808010842-77cni2v4vlib7rus
Tags: 2013.2~b2-0ubuntu4
[ Chuck Short ]
* debian/rules: Enable testsuite during builds.
* debian/patches/fix-sqlalchemy-0.8.patch: Build against sqlalchemy 0.8.
* debian/patches/rename-quantumclient.patch: quantumclient -> neutronclient.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# vim: tabstop=4 shiftwidth=4 softtabstop=4
 
2
 
 
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
from heat.engine import clients
 
17
from heat.openstack.common import log as logging
 
18
from heat.engine.resources.quantum import quantum
 
19
from heat.engine import scheduler
 
20
 
 
21
if clients.quantumclient is not None:
 
22
    from quantumclient.common.exceptions import QuantumClientException
 
23
 
 
24
logger = logging.getLogger(__name__)
 
25
 
 
26
 
 
27
class Subnet(quantum.QuantumResource):
 
28
 
 
29
    allocation_schema = {'start': {'Type': 'String',
 
30
                                   'Required': True},
 
31
                         'end': {'Type': 'String',
 
32
                                 'Required': True}}
 
33
 
 
34
    properties_schema = {'network_id': {'Type': 'String',
 
35
                                        'Required': True},
 
36
                         'cidr': {'Type': 'String',
 
37
                                  'Required': True},
 
38
                         'value_specs': {'Type': 'Map',
 
39
                                         'Default': {}},
 
40
                         'name': {'Type': 'String'},
 
41
                         'ip_version': {'Type': 'Integer',
 
42
                                        'AllowedValues': [4, 6],
 
43
                                        'Default': 4},
 
44
                         'dns_nameservers': {'Type': 'List'},
 
45
                         'gateway_ip': {'Type': 'String'},
 
46
                         'enable_dhcp': {'Type': 'Boolean'},
 
47
                         'allocation_pools': {'Type': 'List',
 
48
                                              'Schema': {
 
49
                                              'Type': 'Map',
 
50
                                              'Schema': allocation_schema
 
51
                                              }}}
 
52
    attributes_schema = {
 
53
        "name": "friendly name of the subnet",
 
54
        "network_id": "parent network of the subnet",
 
55
        "tenant_id": "tenant owning the subnet",
 
56
        "allocation_pools": "ip allocation pools and their ranges",
 
57
        "gateway_ip": "ip of the subnet's gateway",
 
58
        "ip_version": "ip version for the subnet",
 
59
        "cidr": "CIDR block notation for this subnet",
 
60
        "id": "unique identifier for this subnet",
 
61
        # dns_nameservers isn't in the api docs; is it right?
 
62
        "dns_nameservers": "list of dns nameservers",
 
63
        "enable_dhcp": ("'true' if DHCP is enabled for this subnet; 'false'"
 
64
                        "otherwise")
 
65
    }
 
66
 
 
67
    def handle_create(self):
 
68
        props = self.prepare_properties(
 
69
            self.properties,
 
70
            self.physical_resource_name())
 
71
        subnet = self.quantum().create_subnet({'subnet': props})['subnet']
 
72
        self.resource_id_set(subnet['id'])
 
73
 
 
74
    def handle_delete(self):
 
75
        client = self.quantum()
 
76
        try:
 
77
            client.delete_subnet(self.resource_id)
 
78
        except QuantumClientException as ex:
 
79
            if ex.status_code != 404:
 
80
                raise ex
 
81
        else:
 
82
            return scheduler.TaskRunner(self._confirm_delete)()
 
83
 
 
84
    def _show_resource(self):
 
85
        return self.quantum().show_subnet(self.resource_id)['subnet']
 
86
 
 
87
 
 
88
def resource_mapping():
 
89
    if clients.quantumclient is None:
 
90
        return {}
 
91
 
 
92
    return {
 
93
        'OS::Quantum::Subnet': Subnet,
 
94
    }