Пример #1
0
    def test_create_security_group_neutron(self):
        self.cloud.secgroup_source = 'neutron'
        group_name = self.getUniqueString()
        group_desc = self.getUniqueString('description')
        new_group = fakes.make_fake_neutron_security_group(
            id='2', name=group_name, description=group_desc, rules=[])
        self.register_uris([
            dict(method='POST',
                 uri=self.get_mock_url('network',
                                       'public',
                                       append=['v2.0',
                                               'security-groups.json']),
                 json={'security_group': new_group},
                 validate=dict(
                     json={
                         'security_group': {
                             'name': group_name,
                             'description': group_desc
                         }
                     }))
        ])

        r = self.cloud.create_security_group(group_name, group_desc)
        self.assertEqual(group_name, r['name'])
        self.assertEqual(group_desc, r['description'])

        self.assert_calls()
Пример #2
0
    def test_create_security_group_neutron(self):
        self.cloud.secgroup_source = 'neutron'
        group_name = self.getUniqueString()
        group_desc = self.getUniqueString('description')
        new_group = fakes.make_fake_neutron_security_group(
            id='2',
            name=group_name,
            description=group_desc,
            rules=[])
        self.register_uris([
            dict(method='POST',
                 uri=self.get_mock_url(
                     'network', 'public',
                     append=['v2.0', 'security-groups.json']),
                 json={'security_group': new_group},
                 validate=dict(
                     json={'security_group': {
                         'name': group_name,
                         'description': group_desc
                     }}))
        ])

        r = self.cloud.create_security_group(group_name, group_desc)
        self.assertEqual(group_name, r['name'])
        self.assertEqual(group_desc, r['description'])

        self.assert_calls()
Пример #3
0
    def test_create_security_group_neutron_specific_tenant(self):
        self.cloud.secgroup_source = 'neutron'
        project_id = "861808a93da0484ea1767967c4df8a23"
        group_name = self.getUniqueString()
        group_desc = 'security group from' \
                     ' test_create_security_group_neutron_specific_tenant'
        new_group = fakes.make_fake_neutron_security_group(
            id='2',
            name=group_name,
            description=group_desc,
            project_id=project_id,
            rules=[])
        self.register_uris([
            dict(method='POST',
                 uri=self.get_mock_url('network',
                                       'public',
                                       append=['v2.0',
                                               'security-groups.json']),
                 json={'security_group': new_group},
                 validate=dict(
                     json={
                         'security_group': {
                             'name': group_name,
                             'description': group_desc,
                             'tenant_id': project_id
                         }
                     }))
        ])

        r = self.cloud.create_security_group(group_name, group_desc,
                                             project_id)
        self.assertEqual(group_name, r['name'])
        self.assertEqual(group_desc, r['description'])
        self.assertEqual(project_id, r['tenant_id'])

        self.assert_calls()
Пример #4
0
    def test_create_security_group_neutron_specific_tenant(self):
        self.cloud.secgroup_source = 'neutron'
        project_id = "861808a93da0484ea1767967c4df8a23"
        group_name = self.getUniqueString()
        group_desc = 'security group from' \
                     ' test_create_security_group_neutron_specific_tenant'
        new_group = fakes.make_fake_neutron_security_group(
            id='2',
            name=group_name,
            description=group_desc,
            project_id=project_id,
            rules=[])
        self.register_uris([
            dict(method='POST',
                 uri=self.get_mock_url(
                     'network', 'public',
                     append=['v2.0', 'security-groups.json']),
                 json={'security_group': new_group},
                 validate=dict(
                     json={'security_group': {
                         'name': group_name,
                         'description': group_desc,
                         'tenant_id': project_id
                     }}))
        ])

        r = self.cloud.create_security_group(
            group_name,
            group_desc,
            project_id
        )
        self.assertEqual(group_name, r['name'])
        self.assertEqual(group_desc, r['description'])
        self.assertEqual(project_id, r['tenant_id'])

        self.assert_calls()
Пример #5
0
# under the License.

import copy

import shade
from shade.tests.unit import base
from shade.tests import fakes

# TODO(mordred): Move id and name to using a getUniqueString() value

neutron_grp_dict = fakes.make_fake_neutron_security_group(
    id='1',
    name='neutron-sec-group',
    description='Test Neutron security group',
    rules=[
        dict(id='1',
             port_range_min=80,
             port_range_max=81,
             protocol='tcp',
             remote_ip_prefix='0.0.0.0/0')
    ])

nova_grp_dict = fakes.make_fake_nova_security_group(
    id='2',
    name='nova-sec-group',
    description='Test Nova security group #1',
    rules=[
        fakes.make_fake_nova_security_group_rule(id='2',
                                                 from_port=8000,
                                                 to_port=8001,
                                                 ip_protocol='tcp',
Пример #6
0
# under the License.


import copy

import shade
from shade.tests.unit import base
from shade.tests import fakes

# TODO(mordred): Move id and name to using a getUniqueString() value

neutron_grp_dict = fakes.make_fake_neutron_security_group(
    id='1',
    name='neutron-sec-group',
    description='Test Neutron security group',
    rules=[
        dict(id='1', port_range_min=80, port_range_max=81,
             protocol='tcp', remote_ip_prefix='0.0.0.0/0')
    ]
)


nova_grp_dict = fakes.make_fake_nova_security_group(
    id='2',
    name='nova-sec-group',
    description='Test Nova security group #1',
    rules=[
        fakes.make_fake_nova_security_group_rule(
            id='2', from_port=8000, to_port=8001, ip_protocol='tcp',
            cidr='0.0.0.0/0'),
    ]