Beispiel #1
0
    def test_normalize_nova_secgroups(self):
        nova_secgroup = dict(id='abc123',
                             name='nova_secgroup',
                             description='A Nova security group',
                             rules=[
                                 dict(id='123',
                                      from_port=80,
                                      to_port=81,
                                      ip_protocol='tcp',
                                      ip_range={'cidr': '0.0.0.0/0'},
                                      parent_group_id='xyz123')
                             ])

        expected = dict(id='abc123',
                        name='nova_secgroup',
                        description='A Nova security group',
                        security_group_rules=[
                            dict(id='123',
                                 direction='ingress',
                                 ethertype='IPv4',
                                 port_range_min=80,
                                 port_range_max=81,
                                 protocol='tcp',
                                 remote_ip_prefix='0.0.0.0/0',
                                 security_group_id='xyz123')
                        ])

        retval = _utils.normalize_nova_secgroups([nova_secgroup])[0]
        self.assertEqual(expected, retval)
Beispiel #2
0
    def test_normalize_nova_secgroups_negone_port(self):
        nova_secgroup = dict(
            id='abc123',
            name='nova_secgroup',
            description='A Nova security group with -1 ports',
            rules=[
                dict(id='123', from_port=-1, to_port=-1, ip_protocol='icmp',
                     ip_range={'cidr': '0.0.0.0/0'}, parent_group_id='xyz123')
            ]
        )

        retval = _utils.normalize_nova_secgroups([nova_secgroup])[0]
        self.assertIsNone(retval['security_group_rules'][0]['port_range_min'])
        self.assertIsNone(retval['security_group_rules'][0]['port_range_max'])
Beispiel #3
0
    def test_normalize_nova_secgroups_negone_port(self):
        nova_secgroup = dict(id='abc123',
                             name='nova_secgroup',
                             description='A Nova security group with -1 ports',
                             rules=[
                                 dict(id='123',
                                      from_port=-1,
                                      to_port=-1,
                                      ip_protocol='icmp',
                                      ip_range={'cidr': '0.0.0.0/0'},
                                      parent_group_id='xyz123')
                             ])

        retval = _utils.normalize_nova_secgroups([nova_secgroup])[0]
        self.assertIsNone(retval['security_group_rules'][0]['port_range_min'])
        self.assertIsNone(retval['security_group_rules'][0]['port_range_max'])
Beispiel #4
0
    def test_normalize_nova_secgroups_negone_port(self):
        nova_secgroup = dict(
            id="abc123",
            name="nova_secgroup",
            description="A Nova security group with -1 ports",
            rules=[
                dict(
                    id="123",
                    from_port=-1,
                    to_port=-1,
                    ip_protocol="icmp",
                    ip_range={"cidr": "0.0.0.0/0"},
                    parent_group_id="xyz123",
                )
            ],
        )

        retval = _utils.normalize_nova_secgroups([nova_secgroup])[0]
        self.assertIsNone(retval["security_group_rules"][0]["port_range_min"])
        self.assertIsNone(retval["security_group_rules"][0]["port_range_max"])
Beispiel #5
0
    def test_normalize_nova_secgroups(self):
        nova_secgroup = dict(
            id="abc123",
            name="nova_secgroup",
            description="A Nova security group",
            rules=[
                dict(
                    id="123",
                    from_port=80,
                    to_port=81,
                    ip_protocol="tcp",
                    ip_range={"cidr": "0.0.0.0/0"},
                    parent_group_id="xyz123",
                )
            ],
        )

        expected = dict(
            id="abc123",
            name="nova_secgroup",
            description="A Nova security group",
            security_group_rules=[
                dict(
                    id="123",
                    direction="ingress",
                    ethertype="IPv4",
                    port_range_min=80,
                    port_range_max=81,
                    protocol="tcp",
                    remote_ip_prefix="0.0.0.0/0",
                    security_group_id="xyz123",
                )
            ],
        )

        retval = _utils.normalize_nova_secgroups([nova_secgroup])[0]
        self.assertEqual(expected, retval)
Beispiel #6
0
    def test_normalize_nova_secgroups(self):
        nova_secgroup = dict(
            id='abc123',
            name='nova_secgroup',
            description='A Nova security group',
            rules=[
                dict(id='123', from_port=80, to_port=81, ip_protocol='tcp',
                     ip_range={'cidr': '0.0.0.0/0'}, parent_group_id='xyz123')
            ]
        )

        expected = dict(
            id='abc123',
            name='nova_secgroup',
            description='A Nova security group',
            security_group_rules=[
                dict(id='123', direction='ingress', ethertype='IPv4',
                     port_range_min=80, port_range_max=81, protocol='tcp',
                     remote_ip_prefix='0.0.0.0/0', security_group_id='xyz123')
            ]
        )

        retval = _utils.normalize_nova_secgroups([nova_secgroup])[0]
        self.assertEqual(expected, retval)