~ubuntu-branches/ubuntu/raring/nova/raring-proposed

« back to all changes in this revision

Viewing changes to nova/tests/api/openstack/compute/contrib/test_quantum_security_groups.py

  • Committer: Package Import Robot
  • Author(s): Adam Gandelman
  • Date: 2013-08-09 10:12:27 UTC
  • mfrom: (1.1.74)
  • Revision ID: package-import@ubuntu.com-20130809101227-4n60fzcgra8dzk3d
Tags: 1:2013.1.3-0ubuntu1
* Resynchronize with stable/grizzly (89c7ee4) (LP: #1210447):
  - [8e6edd2] Bump stable/grizzly next version to 2013.1.3
  - [61fc529] attach quantum security group to an existing vm failed
    LP: 1189059
  - [60774bd] nova-compute fails to start if quantum is down LP: 1186357
  - [8e6d4b6] asymmetric routes in nova network with external gateway and
    routing_source_ip LP: 1182143
  - [8849413] Failed VM's not set to error state on exception LP: 1182056
  - [ef10eee] Double healing of info_cache with cells LP: 1180304
  - [7422d83] Can't log into  VM after powervm is resized LP: 1169848
  - [49ab0e8] stack trace when instance_actions extension can not find
    instance in GET LP: 1182867
  - [e71247c] nova service-list returns illegal result with non db service
    heartbeat LP: 1168861
  - [3f60606] Volume IO usage gets reset to 0 after a reboot / crash
    LP: 1169097
  - [19c443b] unused method  list_interfaces in vmware driver can be removed
    LP: 1187251
  - [a8dab9f] No cleanup done when file transfer fails with powervm driver
    LP: 1173017
  - [fc98015] nova consoleauth depends on Conductor Service LP: 1186123
  - [1066418] VMware drivers are no longer passing quantum port-id to
    vCenter LP: 1183452
  - [b92075c] nova net-list fails on empty list with Quantum backend
    LP: 1189976
  - [3ba31f2] Create VM with no networks with Quantum Gives SecurityGroups
    Exception LP: 1191044
  - [89150b2] Periodic ValueErrors when using qpid LP: 1185465
  - [0e0d615] Libvirt pre-Grizzly instances cannot be block migrated
    LP: 1185588
  - [27960ef] ZMQ ipc socket file is created using un-sanitized network
    input LP: 1122763
  - [265b868] cannot block migrate old style instances libvirt complains
    LP: 1175286
  - [008a68a] code logical error exists in vmwareapi vif.py  LP: 1177635
  - [378c045] Instance IP addresses are re-used even when previous instance
    could not be powered off LP: 1180178
  - [48ddffe] Reboot of compute node breaks VMs with volumes LP: 1188326
  - [f427f01] Missing dashes from console-log LP: 1194032
  - [78ebf1a] network-create returns an internal error when network
    conflicts LP: 1158075
  - [767c850] Instance nics are reorder after reboot LP: 1187092
  - [0b45996] instance directory naming update to use uuid  LP: 1186944
  - [06cfad5] Disassociate failed dhcp fixed ip in deallocate_for_instance()
    method LP: 1180766
  - [cbcdfc5] Allow confirm_resize action on an instance in 'deleting'
    status LP: 1189391
  - [2563c44] aggregate_get_by_host returns aggregates from other hosts
    LP: 1201277
  - [109f3a9] nova libvirt driver requires iscsi initiator name regardless
    of using it in volume drivers LP: 1007084
  - [7f1c336] Host is always set to None in get_instance_nw_info(...)
    LP: 1194178
  - [1cf30a3] nova boot with colume should fail if the volume is already
    attached to another instance LP: 1166770
  - [9cb9361] Aggregate metadata filtering by key returns unrelated metadata
    LP: 1201283
  - [a61872b] Need clean up  ftp transfer faiure  in powervm driver
    LP: 1188884
  - [91bcd15] Race can cause soft deleted instance to be erased by mistake
    LP: 1186243
  - [c57fded] Nova fails to create a security group rule if ::0/0 is used as
    cidr LP: 1199943
  - [c698dd3] VMwareESXDriver and VMwareVCDriver report incorrect stat
    LP: 1180779
  - [e572faf] novnc fails when amqp_rpc_single_reply_queue=True LP: 1193031
  - [34ddd27] eventlet.monkey_patch() for spice and vnc proxy
  - [864837f] hypervisor_hostname not updated on evacuate LP: 1198284
  - [756a772] libvirt migrate/resize on shared storage can cause data loss
    LP: 1177247
  - [889b215] nova live-migration of volume-backed VM fails because of image
    is None LP: 1199811
  - [60712a4] VNC console does not work with VCDriver LP: 1178369
  - [e0aa0f5] metadata service throws error 500 when compute_driver is not
    set LP: 1184641
  - [340d337] Instance IP addresses are re-used even when previous instance
    could not be powered off LP: 1180178
  - [8247dc8] Resource limit circumvention in Nova private flavors
    (CVE-2013-2256) LP: 1194093
  - [bd7e467] Denial of Service in Nova network source security groups
    (CVE-2013-4185) LP: 1184041
  - [c3fddb7] Resize a VM when a volume is attached fails LP: 1190364
  - [01edbaa] Hyper-V versions before 2012 are not properly recognized
    LP: 1203059
  - [b18818a] driver libvirt doesn't honor vif quota LP: 1185030
  - [798984d] config drive not visible to windows LP: 1155842
  - [d18ceb1] nova live-migration failed due to exception.MigrationError
    LP: 1171526
  - [1934dbc] vmware Hyper for nova vnc console url parameters error
    LP: 1172177
  - [89c7ee4] [OSSA 2013-023] Potential unsafe XML usage (CVE-2013-4179,
    CVE-2013-4202) LP: 1190229
* debian/rules: Clean new setuptools-git cruft.
* debian/control: Update Vcs fields.

Show diffs side-by-side

added added

removed removed

Lines of Context:
199
199
        req = fakes.HTTPRequest.blank('/v2/fake/servers/1/action')
200
200
        self.manager._addSecurityGroup(req, '1', body)
201
201
 
 
202
    def test_associate_port_security_enabled_true(self):
 
203
        sg = self._create_sg_template().get('security_group')
 
204
        net = self._create_network()
 
205
        self._create_port(
 
206
            network_id=net['network']['id'], security_groups=[sg['id']],
 
207
            port_security_enabled=True,
 
208
            device_id=test_security_groups.FAKE_UUID1)
 
209
 
 
210
        self.stubs.Set(nova.db, 'instance_get',
 
211
                       test_security_groups.return_server)
 
212
        body = dict(addSecurityGroup=dict(name="test"))
 
213
 
 
214
        req = fakes.HTTPRequest.blank('/v2/fake/servers/1/action')
 
215
        self.manager._addSecurityGroup(req, '1', body)
 
216
 
 
217
    def test_associate_port_security_enabled_false(self):
 
218
        self._create_sg_template().get('security_group')
 
219
        net = self._create_network()
 
220
        self._create_port(
 
221
            network_id=net['network']['id'], port_security_enabled=False,
 
222
            device_id=test_security_groups.FAKE_UUID1)
 
223
 
 
224
        self.stubs.Set(nova.db, 'instance_get',
 
225
                       test_security_groups.return_server)
 
226
        body = dict(addSecurityGroup=dict(name="test"))
 
227
 
 
228
        req = fakes.HTTPRequest.blank('/v2/fake/servers/1/action')
 
229
        self.assertRaises(webob.exc.HTTPBadRequest,
 
230
                          self.manager._addSecurityGroup,
 
231
                          req, '1', body)
 
232
 
202
233
    def test_disassociate_by_non_existing_security_group_name(self):
203
234
        self.stubs.Set(nova.db, 'instance_get',
204
235
                       test_security_groups.return_server)
277
308
            context.get_admin_context(), test_security_groups.FAKE_UUID1)
278
309
        self.assertEquals(sgs, expected)
279
310
 
 
311
    def test_create_port_with_sg_and_port_security_enabled_true(self):
 
312
        sg1 = self._create_sg_template(name='test1').get('security_group')
 
313
        net = self._create_network()
 
314
        self._create_port(
 
315
            network_id=net['network']['id'], security_groups=[sg1['id']],
 
316
            port_security_enabled=True,
 
317
            device_id=test_security_groups.FAKE_UUID1)
 
318
        security_group_api = self.controller.security_group_api
 
319
        sgs = security_group_api.get_instance_security_groups(
 
320
            context.get_admin_context(), test_security_groups.FAKE_UUID1)
 
321
        self.assertEquals(sgs, [{'name': 'test1'}])
 
322
 
 
323
    def test_create_port_with_sg_and_port_security_enabled_false(self):
 
324
        sg1 = self._create_sg_template(name='test1').get('security_group')
 
325
        net = self._create_network()
 
326
        self.assertRaises(exception.SecurityGroupCannotBeApplied,
 
327
                          self._create_port,
 
328
                           network_id=net['network']['id'],
 
329
                           security_groups=[sg1['id']],
 
330
                           port_security_enabled=False,
 
331
                           device_id=test_security_groups.FAKE_UUID1)
 
332
 
280
333
 
281
334
class TestQuantumSecurityGroupRulesTestCase(TestQuantumSecurityGroupsTestCase):
282
335
    def setUp(self):
549
602
        ret = {'status': 'ACTIVE', 'subnets': [], 'name': n.get('name'),
550
603
               'admin_state_up': n.get('admin_state_up', True),
551
604
               'tenant_id': 'fake_tenant',
552
 
               'port_security_enabled': n.get('port_security_enabled', True),
553
605
               'id': str(uuid.uuid4())}
 
606
        if 'port_security_enabled' in n:
 
607
            ret['port_security_enabled'] = n['port_security_enabled']
554
608
        self._fake_networks[ret['id']] = ret
555
609
        return {'network': ret}
556
610
 
573
627
        p = body.get('port')
574
628
        ret = {'status': 'ACTIVE', 'id': str(uuid.uuid4()),
575
629
               'mac_address': p.get('mac_address', 'fa:16:3e:b8:f5:fb'),
576
 
               'port_security_enabled': p.get('port_security_enabled'),
577
630
               'device_id': p.get('device_id', str(uuid.uuid4())),
578
 
               'security_groups': p.get('security_groups', [])}
579
 
 
580
 
        fields = ['network_id', 'security_groups', 'admin_state_up']
581
 
        for field in fields:
582
 
            ret[field] = p.get(field)
 
631
               'admin_state_up': p.get('admin_state_up', True),
 
632
               'security_groups': p.get('security_groups', []),
 
633
               'network_id': p.get('network_id')}
583
634
 
584
635
        network = self._fake_networks[p['network_id']]
585
 
        if not ret['port_security_enabled']:
 
636
        if 'port_security_enabled' in p:
 
637
            ret['port_security_enabled'] = p['port_security_enabled']
 
638
        elif 'port_security_enabled' in network:
586
639
            ret['port_security_enabled'] = network['port_security_enabled']
 
640
 
 
641
        port_security = ret.get('port_security_enabled', True)
 
642
        # port_security must be True if security groups are present
 
643
        if not port_security and ret['security_groups']:
 
644
            raise exception.SecurityGroupCannotBeApplied()
 
645
 
587
646
        if network['subnets']:
588
647
            ret['fixed_ips'] = [{'subnet_id': network['subnets'][0],
589
648
                                 'ip_address': '10.0.0.1'}]
590
 
        if not ret['security_groups']:
 
649
        if not ret['security_groups'] and (port_security is None or
 
650
                                           port_security is True):
591
651
            for security_group in self._fake_security_groups.values():
592
652
                if security_group['name'] == 'default':
593
653
                    ret['security_groups'] = [security_group['id']]