本文整理汇总了Python中bootstrap.Bootstrap.copyPasswordFile方法的典型用法代码示例。如果您正苦于以下问题:Python Bootstrap.copyPasswordFile方法的具体用法?Python Bootstrap.copyPasswordFile怎么用?Python Bootstrap.copyPasswordFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bootstrap.Bootstrap
的用法示例。
在下文中一共展示了Bootstrap.copyPasswordFile方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_copyPasswordFile
# 需要导入模块: from bootstrap import Bootstrap [as 别名]
# 或者: from bootstrap.Bootstrap import copyPasswordFile [as 别名]
def test_copyPasswordFile(self, write_mock, ssh_run_mock,
ssh_init_mock, scp_run_mock,
scp_init_mock, getPasswordFile_mock):
shared_state = SharedState("root", "sshkey_file", "scriptDir", "bootdir",
"setupAgentFile", "ambariServer", "centos6",
None, "8440", "root", password_file="PasswordFile")
bootstrap_obj = Bootstrap("hostname", shared_state)
getPasswordFile_mock.return_value = "PasswordFile"
# Testing max retcode return
expected1 = {"exitstatus": 42, "log": "log42", "errormsg": "errorMsg"}
expected2 = {"exitstatus": 17, "log": "log17", "errormsg": "errorMsg"}
scp_init_mock.return_value = None
scp_run_mock.return_value = expected1
ssh_init_mock.return_value = None
ssh_run_mock.return_value = expected2
res = bootstrap_obj.copyPasswordFile()
self.assertEquals(res, expected1["exitstatus"])
input_file = str(scp_init_mock.call_args[0][3])
remote_file = str(scp_init_mock.call_args[0][4])
self.assertEqual(input_file, "PasswordFile")
self.assertEqual(remote_file, "PasswordFile")
command = str(ssh_init_mock.call_args[0][3])
self.assertEqual(command, "chmod 600 PasswordFile")
# Another order
expected1 = {"exitstatus": 0, "log": "log0", "errormsg": "errorMsg"}
expected2 = {"exitstatus": 17, "log": "log17", "errormsg": "errorMsg"}
scp_run_mock.return_value = expected1
ssh_run_mock.return_value = expected2