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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)