1
# vim: tabstop=4 shiftwidth=4 softtabstop=4
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
8
# http://www.apache.org/licenses/LICENSE-2.0
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
16
from heat.engine import clients
17
from heat.openstack.common import log as logging
18
from heat.engine.resources.neutron import neutron
19
from heat.engine import scheduler
21
if clients.neutronclient is not None:
22
from neutronclient.common.exceptions import NeutronClientException
24
logger = logging.getLogger(__name__)
27
class Net(neutron.NeutronResource):
28
properties_schema = {'name': {'Type': 'String'},
29
'value_specs': {'Type': 'Map',
31
'admin_state_up': {'Default': True,
34
"id": "the unique identifier for this network",
35
"status": "the status of the network",
36
"name": "the name of the network",
37
"subnets": "subnets of this network",
38
"admin_state_up": "the administrative status of the network",
39
"tenant_id": "the tenant owning this network"
42
def handle_create(self):
43
props = self.prepare_properties(
45
self.physical_resource_name())
46
net = self.neutron().create_network({'network': props})['network']
47
self.resource_id_set(net['id'])
49
def _show_resource(self):
50
return self.neutron().show_network(
51
self.resource_id)['network']
53
def check_create_complete(self, *args):
54
attributes = self._show_resource()
55
return self.is_built(attributes)
57
def handle_delete(self):
58
client = self.neutron()
60
client.delete_network(self.resource_id)
61
except NeutronClientException as ex:
62
if ex.status_code != 404:
65
return scheduler.TaskRunner(self._confirm_delete)()
68
def resource_mapping():
69
if clients.neutronclient is None:
73
'OS::Neutron::Net': Net,
74
'OS::Quantum::Net': Net,