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

« back to all changes in this revision

Viewing changes to heat/engine/resources/security_group.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:
29
29
                         'SecurityGroupEgress': {'Type': 'List'}}
30
30
 
31
31
    def handle_create(self):
32
 
        if self.properties['VpcId'] and clients.quantumclient is not None:
33
 
            self._handle_create_quantum()
 
32
        if self.properties['VpcId'] and clients.neutronclient is not None:
 
33
            self._handle_create_neutron()
34
34
        else:
35
35
            self._handle_create_nova()
36
36
 
37
 
    def _handle_create_quantum(self):
38
 
        from quantumclient.common.exceptions import QuantumClientException
39
 
        client = self.quantum()
 
37
    def _handle_create_neutron(self):
 
38
        from neutronclient.common.exceptions import NeutronClientException
 
39
        client = self.neutron()
40
40
 
41
41
        sec = client.create_security_group({'security_group': {
42
42
            'name': self.physical_resource_name(),
46
46
        self.resource_id_set(sec['id'])
47
47
        if self.properties['SecurityGroupIngress']:
48
48
            for i in self.properties['SecurityGroupIngress']:
49
 
                # Quantum only accepts positive ints
 
49
                # Neutron only accepts positive ints
50
50
                if int(i['FromPort']) < 0:
51
51
                    i['FromPort'] = None
52
52
                if int(i['ToPort']) < 0:
66
66
                            'security_group_id': sec['id']
67
67
                        }
68
68
                    })
69
 
                except QuantumClientException as ex:
 
69
                except NeutronClientException as ex:
70
70
                    if ex.status_code == 409:
71
71
                        # no worries, the rule is already there
72
72
                        pass
87
87
                            'security_group_id': sec['id']
88
88
                        }
89
89
                    })
90
 
                except QuantumClientException as ex:
 
90
                except NeutronClientException as ex:
91
91
                    if ex.status_code == 409:
92
92
                        # no worries, the rule is already there
93
93
                        pass
128
128
                        raise
129
129
 
130
130
    def handle_delete(self):
131
 
        if self.properties['VpcId'] and clients.quantumclient is not None:
132
 
            self._handle_delete_quantum()
 
131
        if self.properties['VpcId'] and clients.neutronclient is not None:
 
132
            self._handle_delete_neutron()
133
133
        else:
134
134
            self._handle_delete_nova()
135
135
 
149
149
                self.nova().security_groups.delete(self.resource_id)
150
150
            self.resource_id = None
151
151
 
152
 
    def _handle_delete_quantum(self):
153
 
        from quantumclient.common.exceptions import QuantumClientException
154
 
        client = self.quantum()
 
152
    def _handle_delete_neutron(self):
 
153
        from neutronclient.common.exceptions import NeutronClientException
 
154
        client = self.neutron()
155
155
 
156
156
        if self.resource_id is not None:
157
157
            try:
158
158
                sec = client.show_security_group(
159
159
                    self.resource_id)['security_group']
160
 
            except QuantumClientException as ex:
 
160
            except NeutronClientException as ex:
161
161
                if ex.status_code != 404:
162
162
                    raise
163
163
            else:
164
164
                for rule in sec['security_group_rules']:
165
165
                    try:
166
166
                        client.delete_security_group_rule(rule['id'])
167
 
                    except QuantumClientException as ex:
 
167
                    except NeutronClientException as ex:
168
168
                        if ex.status_code != 404:
169
169
                            raise
170
170
 
171
171
                try:
172
172
                    client.delete_security_group(self.resource_id)
173
 
                except QuantumClientException as ex:
 
173
                except NeutronClientException as ex:
174
174
                    if ex.status_code != 404:
175
175
                        raise
176
176
            self.resource_id = None