~ubuntu-branches/ubuntu/saucy/heat/saucy-updates

« back to all changes in this revision

Viewing changes to heat/engine/resources/vpc.py

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2013-08-08 15:23:59 UTC
  • mto: This revision was merged to the branch mainline in revision 12.
  • Revision ID: package-import@ubuntu.com-20130808152359-187gmaw0nx1oduxy
Tags: upstream-2013.2~b2.a186.g2b4b248
ImportĀ upstreamĀ versionĀ 2013.2~b2.a186.g2b4b248

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
from heat.engine import clients
18
18
from heat.openstack.common import log as logging
19
19
from heat.engine import resource
20
 
from heat.engine.resources.quantum import quantum
 
20
from heat.engine.resources.neutron import neutron
21
21
 
22
22
logger = logging.getLogger(__name__)
23
23
 
43
43
    }
44
44
 
45
45
    def handle_create(self):
46
 
        client = self.quantum()
 
46
        client = self.neutron()
47
47
        # The VPC's net and router are associated by having identical names.
48
48
        net_props = {'name': self.physical_resource_name()}
49
49
        router_props = {'name': self.physical_resource_name()}
59
59
 
60
60
    @staticmethod
61
61
    def router_for_vpc(client, network_id):
62
 
        # first get the quantum net
 
62
        # first get the neutron net
63
63
        net = VPC.network_for_vpc(client, network_id)
64
64
        # then find a router with the same name
65
65
        routers = client.list_routers(name=net['name'])['routers']
73
73
        return routers[0]
74
74
 
75
75
    def check_create_complete(self, *args):
76
 
        net = self.network_for_vpc(self.quantum(), self.resource_id)
77
 
        if not quantum.QuantumResource.is_built(net):
 
76
        net = self.network_for_vpc(self.neutron(), self.resource_id)
 
77
        if not neutron.NeutronResource.is_built(net):
78
78
            return False
79
 
        router = self.router_for_vpc(self.quantum(), self.resource_id)
80
 
        return quantum.QuantumResource.is_built(router)
 
79
        router = self.router_for_vpc(self.neutron(), self.resource_id)
 
80
        return neutron.NeutronResource.is_built(router)
81
81
 
82
82
    def handle_delete(self):
83
 
        from quantumclient.common.exceptions import QuantumClientException
84
 
        client = self.quantum()
 
83
        from neutronclient.common.exceptions import NeutronClientException
 
84
        client = self.neutron()
85
85
        router = self.router_for_vpc(client, self.resource_id)
86
86
        try:
87
87
            client.delete_router(router['id'])
88
 
        except QuantumClientException as ex:
 
88
        except NeutronClientException as ex:
89
89
            if ex.status_code != 404:
90
90
                raise ex
91
91
 
92
92
        try:
93
93
            client.delete_network(self.resource_id)
94
 
        except QuantumClientException as ex:
 
94
        except NeutronClientException as ex:
95
95
            if ex.status_code != 404:
96
96
                raise ex
97
97
 
98
98
 
99
99
def resource_mapping():
100
 
    if clients.quantumclient is None:
 
100
    if clients.neutronclient is None:
101
101
        return {}
102
102
 
103
103
    return {