Beispiel #1
0
    def test_new_system(self):
        options = Mock()
        options.force_register = True
        s = Satellite(self.logger, options)

        config, d = self.create_fake_config('test', **TestSatellite.default_config_args)
        report = HostGuestAssociationReport(config, self.mapping)
        s.hypervisorCheckIn(report, options)
Beispiel #2
0
    def test_new_system(self):
        options = Options("http://localhost:%s" % TEST_PORT, "username", "password")
        options.force_register = True
        s = Satellite(self.logger, options)

        config = Config('test', 'libvirt')
        report = HostGuestAssociationReport(config, self.mapping)
        s.hypervisorCheckIn(report, options)
Beispiel #3
0
    def test_new_system(self):
        options = Options("http://localhost:%s" % TEST_PORT, "username",
                          "password")
        options.force_register = True
        s = Satellite(self.logger, options)

        config = Config('test', 'libvirt')
        report = HostGuestAssociationReport(config, self.mapping)
        s.hypervisorCheckIn(report, options)
Beispiel #4
0
    def test_creating_channel(self):
        options = Options("http://localhost:%s" % TEST_PORT, "username", "password")
        options.force_register = True
        s = Satellite(self.logger, options)

        config = Config('test', 'libvirt')
        report = HostGuestAssociationReport(config, self.mapping)
        result = s.hypervisorCheckIn(report, options)
        self.assertTrue(self.fake_server.channel_created)
        self.assertIsNotNone(self.fake_server.created_system)
        self.assertTrue("created" in result)
Beispiel #5
0
    def test_per_config_options(self):
        options = Options(None, None, None)
        options.force_register = True
        config = Config('test', 'libvirt', sat_server="http://localhost:%s" % TEST_PORT, sat_username='******', sat_password='******')
        s = Satellite(self.logger, options)

        report = HostGuestAssociationReport(config, self.mapping)
        result = s.hypervisorCheckIn(report, options)
        self.assertTrue("failedUpdate" in result)
        self.assertTrue("created" in result)
        self.assertTrue("updated" in result)
Beispiel #6
0
    def test_per_config_options(self):
        options = Mock()
        options.force_register = True
        config, d = self.create_fake_config('test', **TestSatellite.default_config_args)
        s = Satellite(self.logger, options)

        report = HostGuestAssociationReport(config, self.mapping)
        result = s.hypervisorCheckIn(report, options)
        self.assertTrue("failedUpdate" in result)
        self.assertTrue("created" in result)
        self.assertTrue("updated" in result)
Beispiel #7
0
    def test_hypervisorCheckIn(self):
        options = Options("http://localhost:%s" % TEST_PORT, "username", "password")
        options.force_register = True
        s = Satellite(self.logger, options)

        config = Config('test', 'libvirt')
        report = HostGuestAssociationReport(config, self.mapping)
        result = s.hypervisorCheckIn(report, options)
        self.assertTrue("failedUpdate" in result)
        self.assertTrue("created" in result)
        self.assertTrue("updated" in result)
Beispiel #8
0
    def test_using_existing_channel(self):
        options = Mock()
        options.force_register = True
        s = Satellite(self.logger, options)
        self.fake_server.channel_created = True

        config, d = self.create_fake_config('test', **TestSatellite.default_config_args)
        report = HostGuestAssociationReport(config, self.mapping)
        result = s.hypervisorCheckIn(report, options)
        self.assertTrue(self.fake_server.channel_created)
        self.assertIsNotNone(self.fake_server.created_system)
        self.assertTrue("created" in result)
Beispiel #9
0
    def test_creating_channel(self):
        options = Options("http://localhost:%s" % TEST_PORT, "username",
                          "password")
        options.force_register = True
        s = Satellite(self.logger, options)

        config = Config('test', 'libvirt')
        report = HostGuestAssociationReport(config, self.mapping)
        result = s.hypervisorCheckIn(report, options)
        self.assertTrue(self.fake_server.channel_created)
        self.assertIsNotNone(self.fake_server.created_system)
        self.assertTrue("created" in result)
Beispiel #10
0
    def test_hypervisorCheckIn(self):
        options = Options("http://localhost:%s" % TEST_PORT, "username",
                          "password")
        options.force_register = True
        s = Satellite(self.logger, options)

        config = Config('test', 'libvirt')
        report = HostGuestAssociationReport(config, self.mapping)
        result = s.hypervisorCheckIn(report, options)
        self.assertTrue("failedUpdate" in result)
        self.assertTrue("created" in result)
        self.assertTrue("updated" in result)
Beispiel #11
0
    def test_per_config_options(self):
        options = Options(None, None, None)
        options.force_register = True
        config = Config('test',
                        'libvirt',
                        sat_server="http://localhost:%s" % TEST_PORT,
                        sat_username='******',
                        sat_password='******')
        s = Satellite(self.logger, options)

        report = HostGuestAssociationReport(config, self.mapping)
        result = s.hypervisorCheckIn(report, options)
        self.assertTrue("failedUpdate" in result)
        self.assertTrue("created" in result)
        self.assertTrue("updated" in result)
Beispiel #12
0
 def test_wrong_password(self):
     options = Options("http://localhost:%s" % TEST_PORT, "username",
                       "wrong")
     options.force_register = True
     s = Satellite(self.logger, options)
     config = Config('test', 'libvirt')
     report = HostGuestAssociationReport(config, self.mapping)
     self.assertRaises(SatelliteError, s.hypervisorCheckIn, report, options)
Beispiel #13
0
    def test_hypervisorCheckIn_preregistered(self):
        temp, filename = tempfile.mkstemp(suffix=TEST_SYSTEM_ID)
        self.addCleanup(os.unlink, filename)
        f = os.fdopen(temp, "wb")
        pickle.dump({'system_id': TEST_SYSTEM_ID}, f)
        f.close()

        options = Mock()
        s = Satellite(self.logger, options)

        s.HYPERVISOR_SYSTEMID_FILE = filename.replace(TEST_SYSTEM_ID, '%s')

        config, d = self.create_fake_config('test', **TestSatellite.default_config_args)
        report = HostGuestAssociationReport(config, self.mapping)
        result = s.hypervisorCheckIn(report, options)
        self.assertTrue("failedUpdate" in result)
        self.assertTrue("created" in result)
        self.assertTrue("updated" in result)
Beispiel #14
0
    def test_hypervisorCheckIn_preregistered(self):
        temp, filename = tempfile.mkstemp(suffix=TEST_SYSTEM_ID)
        self.addCleanup(os.unlink, filename)
        f = os.fdopen(temp, "wb")
        pickle.dump({'system_id': TEST_SYSTEM_ID}, f)
        f.close()

        options = Options("http://localhost:%s" % TEST_PORT, "username", "password")
        s = Satellite(self.logger, options)

        s.HYPERVISOR_SYSTEMID_FILE = filename.replace(TEST_SYSTEM_ID, '%s')

        config = Config('test', 'libvirt')
        report = HostGuestAssociationReport(config, self.mapping)
        result = s.hypervisorCheckIn(report, options)
        self.assertTrue("failedUpdate" in result)
        self.assertTrue("created" in result)
        self.assertTrue("updated" in result)
Beispiel #15
0
 def test_wrong_server(self):
     options = Mock()
     s = Satellite(self.logger, options)
     config, d = self.create_fake_config('test', **TestSatellite.default_config_args)
     d['sat_server'] = "wrong_server"
     d['sat_username'] = "******"
     d['sat_password'] = "******"
     report = HostGuestAssociationReport(config, self.mapping)
     self.assertRaises(SatelliteError, s.hypervisorCheckIn, report, options)
Beispiel #16
0
    def test_hypervisorCheckIn_preregistered(self):
        temp, filename = tempfile.mkstemp(suffix=TEST_SYSTEM_ID)
        self.addCleanup(os.unlink, filename)
        f = os.fdopen(temp, "wb")
        pickle.dump({'system_id': TEST_SYSTEM_ID}, f)
        f.close()

        options = Options("http://localhost:%s" % TEST_PORT, "username",
                          "password")
        s = Satellite(self.logger, options)

        s.HYPERVISOR_SYSTEMID_FILE = filename.replace(TEST_SYSTEM_ID, '%s')

        config = Config('test', 'libvirt')
        report = HostGuestAssociationReport(config, self.mapping)
        result = s.hypervisorCheckIn(report, options)
        self.assertTrue("failedUpdate" in result)
        self.assertTrue("created" in result)
        self.assertTrue("updated" in result)
Beispiel #17
0
 def test_wrong_password(self):
     options = Mock()
     options.force_register = True
     s = Satellite(self.logger, options)
     config, d = self.create_fake_config('test', **TestSatellite.default_config_args)
     d['sat_server'] = "http://localhost:%s" % TEST_PORT
     d['sat_username'] = "******"
     d['sat_password'] = "******"
     report = HostGuestAssociationReport(config, self.mapping)
     self.assertRaises(SatelliteError, s.hypervisorCheckIn, report, options)
Beispiel #18
0
    def test_hypervisorCheckIn_deleted(self):
        '''Test running hypervisorCheckIn on system that was deleted from Satellite'''
        system_id = 'wrong-system-id'
        temp, filename = tempfile.mkstemp(suffix=system_id)
        self.addCleanup(os.unlink, filename)
        with os.fdopen(temp, "wb") as f:
            pickle.dump({'system_id': system_id}, f)

        options = Options("http://localhost:%s" % TEST_PORT, "username",
                          "password")
        s = Satellite(self.logger, options)

        s.HYPERVISOR_SYSTEMID_FILE = filename.replace(system_id, '%s')
        config = Config('test', 'libvirt')
        mapping = {'hypervisors': [Hypervisor(system_id, [])]}
        report = HostGuestAssociationReport(config, mapping)
        s.hypervisorCheckIn(report, options)
        with open(filename, "rb") as f:
            data = pickle.load(f)
        self.assertEqual(data['system_id'], TEST_SYSTEM_ID)
Beispiel #19
0
    def test_hypervisorCheckIn_deleted(self):
        '''Test running hypervisorCheckIn on system that was deleted from Satellite'''
        system_id = 'wrong-system-id'
        temp, filename = tempfile.mkstemp(suffix=system_id)
        self.addCleanup(os.unlink, filename)
        with os.fdopen(temp, "wb") as f:
            pickle.dump({'system_id': system_id}, f)

        options = Mock()
        s = Satellite(self.logger, options)

        s.HYPERVISOR_SYSTEMID_FILE = filename.replace(system_id, '%s')
        config, d = self.create_fake_config(
            'test', **TestSatellite.default_config_args)
        mapping = {'hypervisors': [Hypervisor(system_id, [])]}
        report = HostGuestAssociationReport(config, mapping)
        s.hypervisorCheckIn(report, options)
        with open(filename, "rb") as f:
            data = pickle.load(f)
        self.assertEqual(data['system_id'], TEST_SYSTEM_ID)
Beispiel #20
0
    def test_hypervisorCheckIn_deleted(self):
        '''Test running hypervisorCheckIn on system that was deleted from Satellite'''
        system_id = 'wrong-system-id'
        temp, filename = tempfile.mkstemp(suffix=system_id)
        self.addCleanup(os.unlink, filename)
        with os.fdopen(temp, "wb") as f:
            pickle.dump({'system_id': system_id}, f)

        options = Mock()
        s = Satellite(self.logger, options)

        s.HYPERVISOR_SYSTEMID_FILE = filename.replace(system_id, '%s')
        config, d = self.create_fake_config('test', **TestSatellite.default_config_args)
        mapping = {
            'hypervisors': [
                Hypervisor(system_id, [])
            ]
        }
        report = HostGuestAssociationReport(config, mapping)
        s.hypervisorCheckIn(report, options)
        with open(filename, "rb") as f:
            data = pickle.load(f)
        self.assertEqual(data['system_id'], TEST_SYSTEM_ID)
Beispiel #21
0
    def test_hypervisorCheckIn_deleted(self):
        '''Test running hypervisorCheckIn on system that was deleted from Satellite'''
        system_id = 'wrong-system-id'
        temp, filename = tempfile.mkstemp(suffix=system_id)
        self.addCleanup(os.unlink, filename)
        with os.fdopen(temp, "wb") as f:
            pickle.dump({'system_id': system_id}, f)

        options = Options("http://localhost:%s" % TEST_PORT, "username", "password")
        s = Satellite(self.logger, options)

        s.HYPERVISOR_SYSTEMID_FILE = filename.replace(system_id, '%s')
        config = Config('test', 'libvirt')
        mapping = {
            'hypervisors': [
                Hypervisor(system_id, [])
            ]
        }
        report = HostGuestAssociationReport(config, mapping)
        s.hypervisorCheckIn(report, options)
        with open(filename, "rb") as f:
            data = pickle.load(f)
        self.assertEqual(data['system_id'], TEST_SYSTEM_ID)
Beispiel #22
0
 def test_wrong_server(self):
     options = Options("wrong_server", "abc", "def")
     s = Satellite(self.logger, options)
     config = Config('test', 'libvirt')
     report = HostGuestAssociationReport(config, self.mapping)
     self.assertRaises(SatelliteError, s.hypervisorCheckIn, report, options)