Ejemplo n.º 1
0
    def test_prep_ssh_sec_group(self, mock_osclients):
        fake_nova = fakes.FakeNovaClient()
        self.assertEqual(len(fake_nova.security_groups.list()), 1)
        mock_cl = mock.MagicMock()
        mock_cl.nova.return_value = fake_nova
        mock_osclients.return_value = mock_cl

        secgroup._prepare_open_secgroup('endpoint')

        self.assertEqual(len(fake_nova.security_groups.list()), 2)
        self.assertTrue(secgroup.SSH_GROUP_NAME in
                        [sg.name for sg in fake_nova.security_groups.list()])

        # run prep again, check that another security group is not created
        secgroup._prepare_open_secgroup('endpoint')
        self.assertEqual(len(fake_nova.security_groups.list()), 2)
Ejemplo n.º 2
0
    def test__prepare_open_secgroup(self, mock_osclients):
        fake_nova = fakes.FakeNovaClient()
        self.assertEqual(len(fake_nova.security_groups.list()), 1)
        mock_cl = mock.MagicMock()
        mock_cl.nova.return_value = fake_nova
        mock_osclients.return_value = mock_cl

        ret = secgroup._prepare_open_secgroup("endpoint", self.secgroup_name)
        self.assertEqual(self.secgroup_name, ret["name"])

        self.assertEqual(2, len(fake_nova.security_groups.list()))
        self.assertIn(self.secgroup_name,
                      [sg.name for sg in fake_nova.security_groups.list()])

        # run prep again, check that another security group is not created
        secgroup._prepare_open_secgroup("endpoint", self.secgroup_name)
        self.assertEqual(2, len(fake_nova.security_groups.list()))
Ejemplo n.º 3
0
    def test_prep_ssh_sec_group(self, mock_osclients):
        fake_nova = fakes.FakeNovaClient()
        self.assertEqual(len(fake_nova.security_groups.list()), 1)
        mock_cl = mock.MagicMock()
        mock_cl.nova.return_value = fake_nova
        mock_osclients.return_value = mock_cl

        secgroup._prepare_open_secgroup('endpoint')

        self.assertEqual(len(fake_nova.security_groups.list()), 2)
        self.assertTrue(
            secgroup.SSH_GROUP_NAME in [
                sg.name for sg in fake_nova.security_groups.list()
            ])

        # run prep again, check that another security group is not created
        secgroup._prepare_open_secgroup('endpoint')
        self.assertEqual(len(fake_nova.security_groups.list()), 2)
Ejemplo n.º 4
0
    def test__prepare_open_secgroup(self, mock_osclients):
        fake_nova = fakes.FakeNovaClient()
        self.assertEqual(len(fake_nova.security_groups.list()), 1)
        mock_cl = mock.MagicMock()
        mock_cl.nova.return_value = fake_nova
        mock_osclients.return_value = mock_cl

        ret = secgroup._prepare_open_secgroup("endpoint", self.secgroup_name)
        self.assertEqual(self.secgroup_name, ret["name"])

        self.assertEqual(2, len(fake_nova.security_groups.list()))
        self.assertIn(
            self.secgroup_name,
            [sg.name for sg in fake_nova.security_groups.list()])

        # run prep again, check that another security group is not created
        secgroup._prepare_open_secgroup("endpoint", self.secgroup_name)
        self.assertEqual(2, len(fake_nova.security_groups.list()))
Ejemplo n.º 5
0
    def test__prepare_open_secgroup_rules(self, mock_osclients):
        fake_nova = fakes.FakeNovaClient()

        # NOTE(hughsaunders) Default security group is precreated
        self.assertEqual(1, len(fake_nova.security_groups.list()))
        mock_cl = mock.MagicMock()
        mock_cl.nova.return_value = fake_nova
        mock_osclients.return_value = mock_cl

        secgroup._prepare_open_secgroup("endpoint", self.secgroup_name)

        self.assertEqual(2, len(fake_nova.security_groups.list()))
        rally_open = fake_nova.security_groups.find(self.secgroup_name)
        self.assertEqual(3, len(rally_open.rules))

        # run prep again, check that extra rules are not created
        secgroup._prepare_open_secgroup("endpoint", self.secgroup_name)
        rally_open = fake_nova.security_groups.find(self.secgroup_name)
        self.assertEqual(3, len(rally_open.rules))
Ejemplo n.º 6
0
    def test_prep_ssh_sec_group_rules(self, mock_osclients):
        fake_nova = fakes.FakeNovaClient()

        # NOTE(hughsaunders) Default security group is precreated
        self.assertEqual(len(fake_nova.security_groups.list()), 1)
        mock_cl = mock.MagicMock()
        mock_cl.nova.return_value = fake_nova
        mock_osclients.return_value = mock_cl

        secgroup._prepare_open_secgroup('endpoint')

        self.assertEqual(len(fake_nova.security_groups.list()), 2)
        rally_open = fake_nova.security_groups.find(secgroup.SSH_GROUP_NAME)
        self.assertEqual(len(rally_open.rules), 3)

        # run prep again, check that extra rules are not created
        secgroup._prepare_open_secgroup('endpoint')
        rally_open = fake_nova.security_groups.find(secgroup.SSH_GROUP_NAME)
        self.assertEqual(len(rally_open.rules), 3)
Ejemplo n.º 7
0
    def test_prep_ssh_sec_group_rules(self, mock_osclients):
        fake_nova = fakes.FakeNovaClient()

        # NOTE(hughsaunders) Default security group is precreated
        self.assertEqual(len(fake_nova.security_groups.list()), 1)
        mock_cl = mock.MagicMock()
        mock_cl.nova.return_value = fake_nova
        mock_osclients.return_value = mock_cl

        secgroup._prepare_open_secgroup('endpoint')

        self.assertEqual(len(fake_nova.security_groups.list()), 2)
        rally_open = fake_nova.security_groups.find(secgroup.SSH_GROUP_NAME)
        self.assertEqual(len(rally_open.rules), 3)

        # run prep again, check that extra rules are not created
        secgroup._prepare_open_secgroup('endpoint')
        rally_open = fake_nova.security_groups.find(secgroup.SSH_GROUP_NAME)
        self.assertEqual(len(rally_open.rules), 3)
Ejemplo n.º 8
0
    def test__prepare_open_secgroup_rules(self, mock_osclients):
        fake_nova = fakes.FakeNovaClient()

        # NOTE(hughsaunders) Default security group is precreated
        self.assertEqual(1, len(fake_nova.security_groups.list()))
        mock_cl = mock.MagicMock()
        mock_cl.nova.return_value = fake_nova
        mock_osclients.return_value = mock_cl

        secgroup._prepare_open_secgroup("endpoint", self.secgroup_name)

        self.assertEqual(2, len(fake_nova.security_groups.list()))
        rally_open = fake_nova.security_groups.find(self.secgroup_name)
        self.assertEqual(3, len(rally_open.rules))

        # run prep again, check that extra rules are not created
        secgroup._prepare_open_secgroup("endpoint", self.secgroup_name)
        rally_open = fake_nova.security_groups.find(self.secgroup_name)
        self.assertEqual(3, len(rally_open.rules))