当前位置: 首页>>代码示例>>Python>>正文


Python bootstrap.Bootstrap类代码示例

本文整理汇总了Python中bootstrap.Bootstrap的典型用法代码示例。如果您正苦于以下问题:Python Bootstrap类的具体用法?Python Bootstrap怎么用?Python Bootstrap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Bootstrap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

	def __init__(self):
		Bootstrap.__init__(self)
		self._msfile = tempfile.NamedTemporaryFile()
		self._msfile.delete = False
		self._items=0
		self._done=0
	        progs.register("multistrap");
开发者ID:ahedlund,项目名称:raptz,代码行数:7,代码来源:multistrap.py

示例2: test_copyPasswordFile

 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
开发者ID:fanzhidongyzby,项目名称:ambari,代码行数:28,代码来源:TestBootstrap.py

示例3: test_try_to_execute

 def test_try_to_execute(self, write_mock):
   expected = 43
   shared_state = SharedState("root", "sshkey_file", "scriptDir", "bootdir",
                              "setupAgentFile", "ambariServer", "centos6",
                              None, "8440", "root")
   bootstrap_obj = Bootstrap("hostname", shared_state)
   # Normal case
   def act_normal_return_int():
     return 43
   ret = bootstrap_obj.try_to_execute(act_normal_return_int)
   self.assertEqual(ret["exitstatus"], expected)
   self.assertFalse(write_mock.called)
   write_mock.reset_mock()
   def act_normal_return():
       return {"exitstatus": 43}
   ret = bootstrap_obj.try_to_execute(act_normal_return)
   self.assertEqual(ret["exitstatus"], expected)
   self.assertFalse(write_mock.called)
   write_mock.reset_mock()
   # Exception scenario
   def act():
     raise IOError()
   ret = bootstrap_obj.try_to_execute(act)
   self.assertEqual(ret["exitstatus"], 177)
   self.assertTrue(write_mock.called)
开发者ID:fanzhidongyzby,项目名称:ambari,代码行数:25,代码来源:TestBootstrap.py

示例4: test_getOsCheckScript

 def test_getOsCheckScript(self):
   shared_state = SharedState("root", "sshkey_file", "scriptDir", "bootdir",
                              "setupAgentFile", "ambariServer", "centos6",
                              None, "8440", "root")
   bootstrap_obj = Bootstrap("hostname", shared_state)
   ocs = bootstrap_obj.getOsCheckScript()
   self.assertEquals(ocs, "scriptDir/os_check_type.py")
开发者ID:fanzhidongyzby,项目名称:ambari,代码行数:7,代码来源:TestBootstrap.py

示例5: test_interruptBootstrap

 def test_interruptBootstrap(self, write_mock, createDoneFile_mock):
   shared_state = SharedState("root", "sshkey_file", "scriptDir", "bootdir",
                              "setupAgentFile", "ambariServer", "centos6",
                              None, "8440", "root")
   bootstrap_obj = Bootstrap("hostname", shared_state)
   bootstrap_obj.interruptBootstrap()
   self.assertTrue(createDoneFile_mock.called)
开发者ID:fanzhidongyzby,项目名称:ambari,代码行数:7,代码来源:TestBootstrap.py

示例6: test_getRepoFile

 def test_getRepoFile(self, is_suse_mock):
   shared_state = SharedState("root", "sshkey_file", "scriptDir", "bootdir",
                              "setupAgentFile", "ambariServer", "centos6",
                              None, "8440", "root")
   bootstrap_obj = Bootstrap("hostname", shared_state)
   is_suse_mock.return_value = False
   rf = bootstrap_obj.getRepoFile()
   self.assertEquals(rf, "/etc/yum.repos.d/ambari.repo")
开发者ID:fanzhidongyzby,项目名称:ambari,代码行数:8,代码来源:TestBootstrap.py

示例7: test_getOsCheckScriptRemoteLocation

 def test_getOsCheckScriptRemoteLocation(self, getRemoteName_mock):
   shared_state = SharedState("root", "sshkey_file", "scriptDir", "bootdir",
                              "setupAgentFile", "ambariServer", "centos6",
                              None, "8440", "root")
   bootstrap_obj = Bootstrap("hostname", shared_state)
   v = "/tmp/os_check_type1374259902.py"
   getRemoteName_mock.return_value = v
   ocs = bootstrap_obj.getOsCheckScriptRemoteLocation()
   self.assertEquals(ocs, v)
开发者ID:fanzhidongyzby,项目名称:ambari,代码行数:9,代码来源:TestBootstrap.py

示例8: test_getAmbariPort

 def test_getAmbariPort(self):
   shared_state = SharedState("root", "sshkey_file", "scriptDir", "bootdir",
                              "setupAgentFile", "ambariServer", "centos6",
                              None, "8440", "root")
   bootstrap_obj = Bootstrap("hostname", shared_state)
   self.assertEquals(bootstrap_obj.getAmbariPort(),"8440")
   shared_state.server_port = None
   bootstrap_obj = Bootstrap("hostname", shared_state)
   self.assertEquals(bootstrap_obj.getAmbariPort(),"null")
开发者ID:fanzhidongyzby,项目名称:ambari,代码行数:9,代码来源:TestBootstrap.py

示例9: test_is_suse

 def test_is_suse(self, open_mock, isfile_mock):
   shared_state = SharedState("root", "sshkey_file", "scriptDir", "bootdir",
                              "setupAgentFile", "ambariServer", "centos6",
                              None, "8440", "root")
   bootstrap_obj = Bootstrap("hostname", shared_state)
   isfile_mock.return_value = True
   f = open_mock.return_value
   f.read.return_value = " suse  "
   self.assertTrue(bootstrap_obj.is_suse())
开发者ID:fanzhidongyzby,项目名称:ambari,代码行数:9,代码来源:TestBootstrap.py

示例10: test_agent_setup_command_without_project_version

 def test_agent_setup_command_without_project_version(self):
   os.environ[AMBARI_PASSPHRASE_VAR_NAME] = ""
   version = None
   shared_state = SharedState("root", "sshkey_file", "scriptDir", "bootdir",
                              "setupAgentFile", "ambariServer", "centos6",
                              version, "8440", "root")
   bootstrap_obj = Bootstrap("hostname", shared_state)
   runSetupCommand = bootstrap_obj.getRunSetupCommand("hostname")
   self.assertTrue(runSetupCommand.endswith(" 8440"))
开发者ID:fanzhidongyzby,项目名称:ambari,代码行数:9,代码来源:TestBootstrap.py

示例11: test_checkSudoPackage

 def test_checkSudoPackage(self, write_mock, run_mock, init_mock):
   shared_state = SharedState("root", "sshkey_file", "scriptDir", "bootdir",
                              "setupAgentFile", "ambariServer", "centos6",
                              None, "8440")
   bootstrap_obj = Bootstrap("hostname", shared_state)
   expected = 42
   init_mock.return_value = None
   run_mock.return_value = expected
   res = bootstrap_obj.checkSudoPackage()
   self.assertEquals(res, expected)
   command = str(init_mock.call_args[0][3])
   self.assertEqual(command, "rpm -qa | grep sudo")
开发者ID:adamosloizou,项目名称:fiware-cosmos-ambari,代码行数:12,代码来源:TestBootstrap.py

示例12: test_getRunSetupWithPasswordCommand

 def test_getRunSetupWithPasswordCommand(self, environ_mock):
   shared_state = SharedState("root", "sshkey_file", "scriptDir", "bootdir",
                              "setupAgentFile", "ambariServer", "centos6",
                              None, "8440", "root")
   environ_mock.__getitem__.return_value = "TEST_PASSPHRASE"
   bootstrap_obj = Bootstrap("hostname", shared_state)
   utime = 1234
   bootstrap_obj.getUtime = MagicMock(return_value=utime)
   ret = bootstrap_obj.getRunSetupWithPasswordCommand("hostname")
   expected = "sudo -S python /var/lib/ambari-agent/data/tmp/setupAgent{0}.py hostname TEST_PASSPHRASE " \
              "ambariServer root  8440 < /var/lib/ambari-agent/data/tmp/host_pass{0}".format(utime)
   self.assertEquals(ret, expected)
开发者ID:fanzhidongyzby,项目名称:ambari,代码行数:12,代码来源:TestBootstrap.py

示例13: test_createDoneFile

 def test_createDoneFile(self, write_mock):
   tmp_dir = tempfile.gettempdir()
   shared_state = SharedState("root", "sshkey_file", "scriptDir", tmp_dir,
                              "setupAgentFile", "ambariServer", "centos6",
                              None, "8440", "root")
   bootstrap_obj = Bootstrap("hostname", shared_state)
   done_file = os.path.join(tmp_dir, "hostname.done")
   expected = 42
   bootstrap_obj.createDoneFile(expected)
   with open(done_file) as df:
     res = df.read()
     self.assertEqual(res, str(expected))
   os.unlink(done_file)
开发者ID:fanzhidongyzby,项目名称:ambari,代码行数:13,代码来源:TestBootstrap.py

示例14: test_getRepoDir

 def test_getRepoDir(self, is_suse_mock):
   shared_state = SharedState("root", "sshkey_file", "scriptDir", "bootdir",
                              "setupAgentFile", "ambariServer", "centos6",
                              None, "8440", "root")
   bootstrap_obj = Bootstrap("hostname", shared_state)
   # Suse
   is_suse_mock.return_value = True
   res = bootstrap_obj.getRepoDir()
   self.assertEquals(res, "/etc/zypp/repos.d")
   # non-Suse
   is_suse_mock.return_value = False
   res = bootstrap_obj.getRepoDir()
   self.assertEquals(res, "/etc/yum.repos.d")
开发者ID:fanzhidongyzby,项目名称:ambari,代码行数:13,代码来源:TestBootstrap.py

示例15: test_checkSudoPackageUbuntu

 def test_checkSudoPackageUbuntu(self, write_mock, run_mock, init_mock, server_family_mock):
   shared_state = SharedState("root", "sshkey_file", "scriptDir", "bootdir",
                              "setupAgentFile", "ambariServer", "ubuntu12",
                              None, "8440", "root")
   bootstrap_obj = Bootstrap("hostname", shared_state)
   expected = 42
   init_mock.return_value = None
   run_mock.return_value = expected
   server_family_mock.return_value = ["ubuntu", "12"]
   res = bootstrap_obj.checkSudoPackage()
   self.assertEquals(res, expected)
   command = str(init_mock.call_args[0][3])
   self.assertEqual(command, "dpkg --get-selections|grep -e '^sudo\s*install'")
开发者ID:fanzhidongyzby,项目名称:ambari,代码行数:13,代码来源:TestBootstrap.py


注:本文中的bootstrap.Bootstrap类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。