def test_inject_ssh_key_succeeds(self): instance = _get_fake_instance() agent = self._create_agent(instance) self.mox.StubOutWithMock(agent, "inject_file") agent.inject_file("/root/.ssh/authorized_keys", "\n# The following ssh key was injected by Nova" "\nssh-rsa asdf\n") self.mox.ReplayAll() agent.inject_ssh_key()
def test_inject_files(self): instance = _get_fake_instance() agent = self._create_agent(instance) self.mox.StubOutWithMock(agent, "inject_file") files = [("path1", "content1"), ("path2", "content2")] agent.inject_file(*files[0]) agent.inject_file(*files[1]) self.mox.ReplayAll() agent.inject_files(files)
def test_inject_ssh_key_succeeds(self): instance = _get_fake_instance() agent = self._create_agent(instance) self.mox.StubOutWithMock(agent, "inject_file") agent.inject_file( "/root/.ssh/authorized_keys", "\n# The following ssh key was injected by Nova" "\nssh-rsa asdf\n") self.mox.ReplayAll() agent.inject_ssh_key()
def test_inject_file(self): instance = _get_fake_instance() agent = self._create_agent(instance) self.mox.StubOutWithMock(agent, "_call_agent") b64_path = base64.b64encode('path') b64_contents = base64.b64encode('contents') agent._call_agent('inject_file', {'b64_contents': b64_contents, 'b64_path': b64_path}) self.mox.ReplayAll() agent.inject_file("path", "contents")
def test_inject_file(self): instance = _get_fake_instance() agent = self._create_agent(instance) self.mox.StubOutWithMock(agent, "_call_agent") b64_path = base64.b64encode('path') b64_contents = base64.b64encode('contents') agent._call_agent('inject_file', { 'b64_contents': b64_contents, 'b64_path': b64_path }) self.mox.ReplayAll() agent.inject_file("path", "contents")