def construct_normal(self): cloud_init = CloudInit() cloud_init.add_ssh_key("chubb") cloud_init.set_machine_id("passport") cloud_init.set_provider_type("dummy") cloud_init.set_zookeeper_machines([ DummyMachine("blah", "blah", "cotswold"), DummyMachine("blah", "blah", "longleat")]) return cloud_init
def construct_bootstrap(self, with_zookeepers=False): cloud_init = CloudInit() cloud_init.enable_bootstrap() cloud_init.add_ssh_key("chubb") cloud_init.set_machine_id("passport") cloud_init.set_provider_type("dummy") cloud_init.set_instance_id_accessor("token") cloud_init.set_zookeeper_secret("seekrit") cloud_init.set_juju_source(distro=True) if with_zookeepers: cloud_init.set_zookeeper_machines([ DummyMachine("blah", "blah", "cotswold"), DummyMachine("blah", "blah", "longleat")]) return cloud_init
def test_works_with_zookeeper(self): """Creating a non-zookeeper machine should not alter provider state""" d = self.assert_success(False, DummyMachine("i-keepzoos")) def verify(provider): provider_state = yield provider.load_state() self.assertEquals(provider_state, False) d.addCallback(verify) return d
def test_zookeeper_exists(self): log = self.capture_logging("juju.common", level=logging.DEBUG) provider = DummyProvider(WorkingFileStorage(), DummyMachine("i-alreadykeepzoos")) d = provider.bootstrap() def verify(machines): (machine, ) = machines self.assertTrue(isinstance(machine, DummyMachine)) self.assertEquals(machine.instance_id, "i-alreadykeepzoos") log_text = log.getvalue() self.assertIn("juju environment previously bootstrapped", log_text) self.assertNotIn("Launching", log_text) d.addCallback(verify) return d
def start_machine(self, machine_id, zookeepers): test.assertEquals(machine_id, "1234") test.assertEquals(zookeepers, filter(None, [zookeeper])) test.assertEquals(self._master, master) test.assertEquals(self._constraints, {}) return succeed([DummyMachine("i-malive")])
def start_machine(self, machine_id, master=False): assert master is True return [DummyMachine("i-keepzoos")]
def test_shutdown_rejects_unknown_machine(self): machine = DummyMachine(1) d = self.provider.shutdown_machine(machine) self.assertFailure(d, ProviderError) return d