class TestPlumberyFacility(unittest.TestCase): def setUp(self): self.plumbery = PlumberyEngine() self.plumbery.set_user_name('fake_user') self.plumbery.set_user_password('fake_password') self.fittings = PlumberyFittings(**fakeFittings) DimensionDataNodeDriver.connectionCls.conn_classes = ( None, DimensionDataMockHttp) DimensionDataMockHttp.type = None self.facility = PlumberyFacility(plumbery=self.plumbery, fittings=self.fittings) self.facility.region = DimensionDataNodeDriver(*DIMENSIONDATA_PARAMS) def tearDown(self): self.facility = None def test_build_all_blueprints(self): self.facility.build_all_blueprints() def test_build_blueprint(self): self.facility.build_blueprint('fake') def test_destroy_all_nodes(self): self.facility.destroy_all_nodes() def test_destroy_nodes(self): self.facility.destroy_nodes('fake') def test_focus(self): self.facility.focus() def test_get_blueprint(self): self.facility.get_blueprint('fake') def test_start_all_nodes(self): self.facility.start_all_nodes() def test_start_nodes(self): self.facility.start_nodes('fake') def test_stop_all_nodes(self): self.facility.stop_all_nodes() def test_stop_nodes(self): self.facility.stop_nodes('fake')
class TestPlumberyFacility(unittest.TestCase): def setUp(self): self.plumbery = PlumberyEngine() self.plumbery.set_user_name('fake_user') self.plumbery.set_user_password('fake_password') self.fittings = PlumberyFittings(**fakeFittings) self.facility = PlumberyFacility(plumbery=self.plumbery, fittings=self.fittings) self.facility.region = FakeRegion() def tearDown(self): self.facility = None def test_build_all_blueprints(self): self.facility.build_all_blueprints() def test_build_blueprint(self): self.facility.build_blueprint('fake') def test_destroy_all_nodes(self): self.facility.destroy_all_nodes() def test_destroy_nodes(self): self.facility.destroy_nodes('fake') def test_focus(self): self.facility.focus() def test_get_blueprint(self): self.facility.get_blueprint('fake') def test_start_all_nodes(self): self.facility.start_all_nodes() def test_start_nodes(self): self.facility.start_nodes('fake') def test_stop_all_nodes(self): self.facility.stop_all_nodes() def test_stop_nodes(self): self.facility.stop_nodes('fake')
class TestPlumberyFacility(unittest.TestCase): def setUp(self): self.plumbery = PlumberyEngine() self.plumbery.set_user_name('fake_user') self.plumbery.set_user_password('fake_password') DimensionDataNodeDriver.connectionCls.conn_classes = ( None, DimensionDataMockHttp) DimensionDataMockHttp.type = None self.plumbery.region = DimensionDataNodeDriver(*DIMENSIONDATA_PARAMS) self.facility = PlumberyFacility( plumbery=self.plumbery, fittings=fakeFittings) self.facility.power_on() def tearDown(self): self.facility = None def test_get_location_id(self): self.assertEqual(self.facility.get_location_id(), 'NA9') def test_list_basement(self): self.assertEqual(self.facility.list_basement(), ['fake1']) def test_list_blueprints(self): self.assertEqual(self.facility.list_blueprints(), ['fake1', 'fake2']) def test_expand_blueprint(self): self.assertEqual( self.facility.expand_blueprint('fake1'), ['fake1']) self.assertEqual( self.facility.expand_blueprint('fake1 unknown fake'), ['fake1']) self.assertEqual( self.facility.expand_blueprint('macro'), ['fake2']) self.assertEqual( self.facility.expand_blueprint('basement'), ['fake1']) def test_get_blueprint(self): self.assertEqual( self.facility.get_blueprint('fake2')['target'], 'fake2') self.assertIsNone(self.facility.get_blueprint('macro')) self.assertIsNone(self.facility.get_blueprint('crazyAndunknown')) def test_list_domains(self): self.assertEqual(self.facility.list_domains(), ['VDC1']) def test_list_ethernets(self): self.assertEqual(self.facility.list_ethernets(), ['vlan1']) def test_list_nodes(self): self.assertEqual(self.facility.list_nodes(), ['stackstorm1', 'stackstorm2']) def test_get_image(self): self.assertRegexpMatches( self.facility.get_image().name, "^RedHat ") self.assertIsNone(self.facility.get_image('perfectlyUnknown')) def test_focus(self): self.facility.focus() def test_process_all_blueprints(self): action = FakeAction({}) self.facility.process_all_blueprints(action) self.assertEqual(action.count, 14) def test_process_blueprint(self): action = FakeAction({}) self.facility.process_blueprint(action, names='fake') self.assertEqual(action.count, 4) def test_build_all_blueprints(self): self.facility.build_all_blueprints() def test_build_blueprint(self): self.facility.build_blueprint('fake') def test_start_all_blueprints(self): self.facility.start_all_blueprints() def test_start_blueprint(self): self.facility.start_blueprint('fake') def test_polish_all_blueprints(self): self.facility.polish_all_blueprints(polishers='ping') def test_polish_blueprint(self): self.facility.polish_blueprint(names='fake', polishers='ping') def test_stop_all_blueprints(self): self.facility.stop_all_blueprints() def test_stop_blueprint(self): self.facility.stop_blueprint('fake') def test_wipe_all_blueprints(self): self.facility.wipe_all_blueprints() def test_wipe_blueprint(self): self.facility.wipe_blueprint('fake') def test_destroy_all_blueprints(self): self.facility.destroy_all_blueprints() def test_destroy_blueprint(self): self.facility.destroy_blueprint('fake') def test_lookup(self): self.assertEqual(self.facility.lookup('location.country'), 'US') self.assertEqual(self.facility.lookup('location.id'), 'NA9') self.assertEqual(self.facility.lookup('*unknown*'), None) def test_settings(self): engine = PlumberyEngine(defaultsPlan) facility = engine.list_facility('EU6')[0] self.assertEqual(facility.get_setting('locationId'), 'EU6') self.assertEqual(facility.get_setting('regionId'), 'dd-eu') self.assertEqual(facility.get_setting('prepare'), None) self.assertEqual(facility.get_setting('basement'), 'myBlueprint') def test_settings_private(self): settings = { 'apiHost': 'smee.com', 'locationId': 'NA5', 'safeMode': True } engine = PlumberyEngine(plan=settings) engine.set_user_name('smee') engine.set_user_password('smee') facility = engine.list_facility()[0] # facility.power_on() self.assertEqual(facility.get_setting('locationId'), 'NA5') self.assertIsNone(facility.get_setting('regionId')) def test_blueprints(self): engine = PlumberyEngine(defaultsPlan) facility = engine.list_facility('EU6')[0] blueprint = facility.get_blueprint('myBlueprint') self.assertEqual(isinstance(blueprint, dict), True) self.assertEqual(blueprint['domain']['name'], 'myDC') self.assertEqual(blueprint['domain']['ipv4'], 'auto') self.assertEqual(blueprint['ethernet']['name'], 'myVLAN') self.assertEqual(blueprint['ethernet']['subnet'], '10.1.10.0') self.assertEqual(len(blueprint['ethernet']['accept']), 1) label = list(blueprint['nodes'][0])[0] node = blueprint['nodes'][0][label] self.assertEqual('default' not in node, True) self.assertEqual(node['cpu'], 3) self.assertEqual(node['memory'], 5) self.assertEqual(len(node['information']), 2) config = node['cloud-config'] self.assertEqual(isinstance(config, dict), True) self.assertEqual(config['disable_root'], True) self.assertEqual(config['ssh_pwauth'], True) self.assertEqual(len(config['packages']), 4) self.assertEqual(len(config['runcmd']), 4)
class TestPlumberyFacility(unittest.TestCase): def setUp(self): self.plumbery = PlumberyEngine() self.plumbery.set_user_name('fake_user') self.plumbery.set_user_password('fake_password') DimensionDataNodeDriver.connectionCls.conn_classes = ( None, DimensionDataMockHttp) DimensionDataMockHttp.type = None self.facility = PlumberyFacility( plumbery=self.plumbery, fittings=fakeFittings) self.facility.region = DimensionDataNodeDriver(*DIMENSIONDATA_PARAMS) def tearDown(self): self.facility = None def test_get_location_id(self): self.assertEqual(self.facility.get_location_id(), 'NA9') def test_list_basement(self): self.assertEqual(self.facility.list_basement(), ['fake']) def test_list_blueprints(self): self.assertEqual(self.facility.list_blueprints(), ['fake']) def test_expand_blueprint(self): self.assertEqual( self.facility.expand_blueprint('fake'), ['fake']) self.assertEqual( self.facility.expand_blueprint('fake unknown fake'), ['fake']) self.assertEqual( self.facility.expand_blueprint('macro'), ['fake']) self.assertEqual( self.facility.expand_blueprint('basement'), ['fake']) def test_get_blueprint(self): self.assertEqual( self.facility.get_blueprint('fake')['target'], 'fake') self.assertIsNone(self.facility.get_blueprint('macro')) self.assertIsNone(self.facility.get_blueprint('crazyAndunknown')) def test_list_domains(self): self.assertEqual(self.facility.list_domains(), ['VDC1']) def test_list_ethernets(self): self.assertEqual(self.facility.list_ethernets(), ['vlan1']) def test_list_nodes(self): self.assertEqual(self.facility.list_nodes(), ['stackstorm']) def test_get_image(self): self.assertRegexpMatches( self.facility.get_image().name, "^RedHat ") self.assertIsNone(self.facility.get_image('perfectlyUnknown')) def test_focus(self): self.facility.focus() def test_build_all_blueprints(self): self.facility.build_all_blueprints() def test_build_blueprint(self): self.facility.build_blueprint('fake') def test_start_all_blueprints(self): self.facility.start_all_blueprints() def test_start_blueprint(self): self.facility.start_blueprint('fake') def test_polish_all_blueprints(self): self.facility.polish_all_blueprints(polishers='ping') def test_polish_blueprint(self): self.facility.polish_blueprint(names='fake', polishers='ping') def test_stop_all_blueprints(self): self.facility.stop_all_blueprints() def test_stop_blueprint(self): self.facility.stop_blueprint('fake') def test_wipe_all_blueprints(self): self.facility.wipe_all_blueprints() def test_wipe_blueprint(self): self.facility.wipe_blueprint('fake') def test_destroy_all_blueprints(self): self.facility.destroy_all_blueprints() def test_destroy_blueprint(self): self.facility.destroy_blueprint('fake') def test_lookup(self): self.assertEqual(self.facility.lookup('*unknown*'), None) def test_get_parameter(self): engine = PlumberyEngine() engine.from_text(defaultsPlan) facility = engine.list_facility('EU6')[0] self.assertEqual(facility.get_parameter('locationId'), 'EU6') self.assertEqual(facility.get_parameter('regionId'), 'dd-eu') self.assertEqual(facility.get_parameter('rub'), None) self.assertEqual(facility.get_parameter('ipv4'), 'auto') self.assertEqual(facility.get_parameter('basement'), 'myBlueprint')