Esempio n. 1
0
    def test_creation_different_profile(self):
        test_sp = ServerProfile(
            name="test",
            ui_name="test UI",
            ui_description="a test description",
            managed=False,
            worker=False,
            ntp=False,
            corosync=False,
            corosync2=False,
            initial_state="monitored",
        )
        test_sp.save()
        test_sp.bundles.add(Bundle.objects.get(bundle_name="agent"))

        response = self.api_client.post(
            self.RESOURCE_PATH, data={"address": "foo", "server_profile": "/api/server_profile/test/"}
        )
        self.assertHttpAccepted(response)
        self.assertEqual(ManagedHost.objects.count(), 1)

        current_profile = ManagedHost.objects.get().server_profile
        self.assertEquals(test_sp.name, current_profile.name)
        self.assertEquals(test_sp.ui_name, current_profile.ui_name)
        self.assertEquals(test_sp.managed, current_profile.managed)
        self.assertEquals(list(test_sp.bundles.all()), list(current_profile.bundles.all()))
 def load_worker_profile(self):
     worker_profile = ServerProfile(name='test_worker_profile',
                                    ui_name='Managed Lustre client',
                                    ui_description='Client available for IML admin tasks',
                                    managed=True, worker=True,
                                    initial_state="managed")
     worker_profile.save()
     return worker_profile
def load_default_profile():
    default_sp = ServerProfile(
        name="test_profile",
        ui_name="Managed storage server",
        ui_description="A storage server suitable for creating new HA-enabled filesystem targets",
        managed=True,
        default=True,
        corosync=True,
        corosync2=False,
        ntp=True,
        initial_state="managed",
    )
    default_sp.save()
Esempio n. 4
0
    def _create_hosts_and_validation_profiles(self, validations):
        profile = ServerProfile(
            name="test_profile_2",
            ui_name="Not Test Profile",
            ui_description="Not Test Profile",
            managed=False,
            worker=False,
            corosync=False,
            corosync2=False,
            ntp=False,
            user_selectable=False,
            initial_state="monitored",
        )
        profile.save()

        for profile in ServerProfile.objects.all():
            for validation in validations:
                x = ServerProfileValidation(**validation)
                profile.serverprofilevalidation_set.add(x, bulk=False)
                x.save()

        response = self.api_client.post(
            self.RESOURCE_PATH,
            data={
                "objects": [{
                    "address":
                    host_name,
                    "server_profile":
                    "/api/server_profile/test_profile_2/"
                } for host_name in MockAgentRpc.mock_servers]
            },
        )

        self.assertHttpAccepted(response)
        content = json.loads(response.content)

        self.assertEqual(len(content["objects"]),
                         len(MockAgentRpc.mock_servers))

        for object in content["objects"]:
            self.assertEqual(object["error"], None)
            self.assertEqual(object["traceback"], None)
            self.assertEqual(object["command_and_host"].keys(),
                             ["host", "command"])

        hosts = ManagedHost.objects.all()
        self.assertEqual(hosts[0].server_profile.name, "test_profile_2")

        return hosts
Esempio n. 5
0
    def _create_hosts_and_validation_profiles(self, validations):
        profile = ServerProfile(name='test_profile_2',
                                ui_name='Not Test Profile',
                                ui_description='Not Test Profile',
                                managed=False,
                                worker=False,
                                corosync=False,
                                corosync2=False,
                                ntp=False,
                                user_selectable=False,
                                initial_state="monitored")
        profile.save()
        profile.bundles.add(Bundle.objects.get(bundle_name='agent'))

        for profile in ServerProfile.objects.all():
            for validation in validations:
                profile.serverprofilevalidation_set.add(
                    ServerProfileValidation(**validation))

        response = self.api_client.post(
            self.RESOURCE_PATH,
            data={
                'objects': [{
                    'address':
                    host_name,
                    'server_profile':
                    '/api/server_profile/test_profile_2/'
                } for host_name in MockAgentRpc.mock_servers]
            })

        self.assertHttpAccepted(response)
        content = json.loads(response.content)

        self.assertEqual(len(content['objects']),
                         len(MockAgentRpc.mock_servers))

        for object in content['objects']:
            self.assertEqual(object['error'], None)
            self.assertEqual(object['traceback'], None)
            self.assertEqual(object['command_and_host'].keys(),
                             ['host', 'command'])

        hosts = ManagedHost.objects.all()
        self.assertEqual(hosts[0].server_profile.name, 'test_profile_2')

        return hosts
Esempio n. 6
0
def load_default_profile():
    load_default_bundles()
    default_sp = ServerProfile(
        name='test_profile',
        ui_name='Managed storage server',
        ui_description=
        'A storage server suitable for creating new HA-enabled filesystem targets',
        managed=True,
        default=True,
        corosync=True,
        corosync2=False,
        ntp=True,
        initial_state="managed")
    default_sp.bundles.add('lustre')
    default_sp.bundles.add('agent')
    default_sp.bundles.add('agent_dependencies')
    default_sp.save()
Esempio n. 7
0
def load_default_profile():
    load_default_bundles()
    default_sp = ServerProfile(
        name="test_profile",
        ui_name="Managed storage server",
        ui_description=
        "A storage server suitable for creating new HA-enabled filesystem targets",
        managed=True,
        default=True,
        corosync=True,
        corosync2=False,
        ntp=True,
        initial_state="managed",
    )
    default_sp.bundles.add("lustre")
    default_sp.bundles.add("agent")
    default_sp.bundles.add("agent_dependencies")
    default_sp.save()