コード例 #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()))
コード例 #2
0
 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
コード例 #3
0
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()
コード例 #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
コード例 #5
0
    def _test_yum_rpm_sanity(self, agent_ssh, auth_args, address):
        from chroma_core.services.job_scheduler.agent_rpc import AgentException
        from chroma_core.models import ServerProfile

        can_update = False

        try:
            # Check to see if yum can or ever has gotten OS repo metadata or if base packages are
            # already installed and no repos are enabled
            check_yum = """
python -c "from yum import YumBase
yb = YumBase()
baselist = %s
if len([x for x in yb.doPackageLists(pkgnarrow='installed', patterns=baselist)]) >= len(baselist):
    exit(0)
missing_electric_fence = not [p.name for p in yb.pkgSack.returnNewestByNameArch() if p.name == 'ElectricFence']
exit(missing_electric_fence)"
""" % [x for x in ServerProfile().base_packages]
            rc, _, _ = try_ssh_cmd(agent_ssh, auth_args, check_yum)
            if rc == 0:
                can_update = True
            else:
                job_log.error(
                    "Failed configuration check on '%s': Unable to access any yum mirrors"
                    % address)
        except AgentException:
            job_log.exception(
                "Exception thrown while trying to invoke agent on '%s':" %
                address)
            return False, False

        return can_update
コード例 #6
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
コード例 #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()
コード例 #8
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()