本文整理汇总了Python中OSConf.get_ssh_url方法的典型用法代码示例。如果您正苦于以下问题:Python OSConf.get_ssh_url方法的具体用法?Python OSConf.get_ssh_url怎么用?Python OSConf.get_ssh_url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OSConf
的用法示例。
在下文中一共展示了OSConf.get_ssh_url方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_process_id
# 需要导入模块: import OSConf [as 别名]
# 或者: from OSConf import get_ssh_url [as 别名]
def get_process_id(self):
pids = []
if self.app_type.split('-')[0] in ('jbossas', 'jbosseap'):
cmd = "ssh %s 'ps aux |grep -v grep| grep -i standalone'" % (OSConf.get_ssh_url(self.app_name))
elif 'jbossews' in self.app_type:
cmd = "ssh %s 'ps aux |grep -v grep| grep jre'" % (OSConf.get_ssh_url(self.app_name))
else:
cmd = "ssh %s 'ps aux |grep -v grep| grep bin/httpd'" % (OSConf.get_ssh_url(self.app_name))
child = pexpect.spawn(cmd)
print ">>"*50
print cmd
print "<<"*50
for line in child.readlines():
match = None
if self.app_type.split('-')[0] in ('jbossas', 'jbosseap'):
if 'jre' in line or 'standalone.sh' in line:
print line
match = re.search(r'^\d+\s+(\d+)', line, re.M)
elif 'jbossews' in self.app_type:
if 'java' in line:
match = re.search(r'^\d+\s+(\d+)', line, re.M)
else:
if 'httpd -C Include' in line:
match = re.search(r'^\d+\s+(\d+)', line, re.M)
if match:
if match.group(1) not in pids:
pids.append(int(match.group(1)))
pids.sort()
return pids
示例2: test_method
# 需要导入模块: import OSConf [as 别名]
# 或者: from OSConf import get_ssh_url [as 别名]
def test_method(self):
# Create app
ret = common.create_app(self.app_name, self.app_type, self.config.OPENSHIFT_user_email, self.config.OPENSHIFT_user_passwd, True, "./", self.scalable)
self.assert_equal(ret, 0, "App creation failed")
# Add postgresql-9.2 to the app
ret = common.embed(self.app_name, 'add-' + common.cartridge_types['postgresql-9.2'])
self.assert_equal(ret, 0, "Failed to add Postgresql-9.2 to the app")
#Check the version of cartridge
cmd = "ssh %s 'psql --version | grep psql '" % (OSConf.get_ssh_url(self.app_name))
(status, output) = common.command_getstatusoutput(cmd)
self.assert_equal(status, 0, "Check Version Failed")
#Scale up
if self.scalable:
ret = common.scale_up(self.app_name)
self.assert_equal(0, ret, "Unable to scale_up.")
#Stop
cmd = "rhc cartridge stop %s -a %s -l %s -p '%s' %s" %(common.cartridge_types['postgresql-9.2'], self.app_name, self.config.OPENSHIFT_user_email, self.config.OPENSHIFT_user_passwd, common.RHTEST_RHC_CLIENT_OPTIONS)
(status, output) = common.command_getstatusoutput(cmd)
self.assert_equal(status, 0, "Stop failed")
#Start
cmd = "rhc cartridge start %s -a %s -l %s -p '%s' %s" %(common.cartridge_types['postgresql-9.2'], self.app_name, self.config.OPENSHIFT_user_email, self.config.OPENSHIFT_user_passwd, common.RHTEST_RHC_CLIENT_OPTIONS)
(status, output) = common.command_getstatusoutput(cmd)
self.assert_equal(status, 0, "Start failed")
#Restart
cmd = "rhc cartridge restart %s -a %s -l %s -p '%s' %s" %(common.cartridge_types['postgresql-9.2'], self.app_name, self.config.OPENSHIFT_user_email, self.config.OPENSHIFT_user_passwd, common.RHTEST_RHC_CLIENT_OPTIONS)
(status, output) = common.command_getstatusoutput(cmd)
self.assert_equal(status, 0, "Restart failed")
#Reload
cmd = "rhc cartridge reload %s -a %s -l %s -p '%s' %s" %(common.cartridge_types['postgresql-9.2'], self.app_name, self.config.OPENSHIFT_user_email, self.config.OPENSHIFT_user_passwd, common.RHTEST_RHC_CLIENT_OPTIONS)
(status, output) = common.command_getstatusoutput(cmd)
self.assert_equal(status, 0, "Reload failed")
#Status
cmd = "rhc cartridge status %s -a %s -l %s -p '%s' %s" %(common.cartridge_types['postgresql-9.2'], self.app_name, self.config.OPENSHIFT_user_email, self.config.OPENSHIFT_user_passwd, common.RHTEST_RHC_CLIENT_OPTIONS)
(status, output) = common.command_getstatusoutput(cmd)
self.assert_equal(status, 0, "Show status failed")
#Remove
cmd = "rhc cartridge remove %s -a %s -l %s -p '%s' %s --confirm" %(common.cartridge_types['postgresql-9.2'], self.app_name, self.config.OPENSHIFT_user_email, self.config.OPENSHIFT_user_passwd, common.RHTEST_RHC_CLIENT_OPTIONS)
(status, output) = common.command_getstatusoutput(cmd)
self.assert_equal(status, 0, "Remove failed")
return self.passed()
示例3: run_remote_cmd
# 需要导入模块: import OSConf [as 别名]
# 或者: from OSConf import get_ssh_url [as 别名]
def run_remote_cmd(app_name, cmd, as_root=False, host=None, quiet=False):
"""Using paramiko client"""
if as_root:
user = 'root'
if not host:
#host = get_instance_ip()
ssh_url = OSConf.get_ssh_url(app_name)
host = os.popen('ssh %s hostname'%ssh_url).read().strip('\n')
key_filename = get_root_ssh_key()
else:
user = OSConf.get_app_uuid(app_name)
if not host:
host = OSConf.get_app_url(app_name)
key_filename = get_default_ssh_key()
return rcmd_get_status_output(cmd, user, host, key_filename, quiet)
示例4: rhcsh_test_1
# 需要导入模块: import OSConf [as 别名]
# 或者: from OSConf import get_ssh_url [as 别名]
def rhcsh_test_1(self):
app_url = OSConf.get_app_url(self.app_name)
ssh_url = OSConf.get_ssh_url(self.app_name)
p = pexpect.spawn('ssh %s'% ssh_url, timeout=400)
p.logfile = sys.stdout
#index = p.expect([OSConf.get_app_url(self.app_name), pexpect.EOF, pexpect.TIMEOUT])
p.expect('Welcome to OpenShift shell')
p.expect(app_url)
p.sendline('ls -l ~/app-root/data/.bash_profile')
p.expect('-rwx.*.bash_profile')
#p.sendline('ls -l ~/app-root/data/.bash_history')
#p.expect('-rwx.*.bash_history')
p.sendline('ls')
p.expect('git')
p.sendline('cd %s/data/ && touch test && echo "test_text" > test ; echo $?'% self.app_type)
p.expect('0')
p.sendline('cat test')
p.expect('test_text')
p.sendline('rm -f test ; ls test || echo "ok"')
p.expect('ok')
p.sendline('ps -efww')
p.expect('/usr/bin/rhcsh -i')
p.sendline('export test="rhcsh-test"; echo $test')
p.expect('rhcsh-test')
p.sendline('help')
p.expect('Help menu:')
#p.sendline('tail_all') ### XXX do we need tail_all test?
#p.expect('==> /var/lib/(.*)-000000-(.*) <==')
#p.expect('==> /var/lib/(.*)-000000-(.*) <==')
# p.sendcontrol('c')
#p.sendcontrol('d')
#p.sendline('exit')
p.expect('timed out waiting for input: auto-logout', timeout=360)
p.expect('Connection to %s closed.'% app_url)
return 0
示例5: rhcsh_test_2
# 需要导入模块: import OSConf [as 别名]
# 或者: from OSConf import get_ssh_url [as 别名]
def rhcsh_test_2(self):
app_url = OSConf.get_app_url(self.app_name)
ssh_url = OSConf.get_ssh_url(self.app_name)
app_uuid = OSConf.get_app_uuid(self.app_name)
p = pexpect.spawn('ssh -t %s rhcsh'% ssh_url)
p.logfile = sys.stdout
p.expect('Welcome to OpenShift shell')
p.expect(app_url)
p.sendline('ps -efww | grep "/usr/sbin/httpd" | grep -v "grep" | wc -l')
#p.sendline('pgrep -u %s httpd | wc -l' %(app_uuid))
if self.get_run_mode() == 'OnPremise':
p.expect("2")
else:
p.expect("6")
p.sendline('ctl_app stop')
time.sleep(2)
p.expect(app_url)
#p.expect("Waiting for stop to finish")
p.sendline('ps -efww | grep "/usr/sbin/httpd" | grep -v "grep" | wc -l')
#p.sendline('pgrep -u %s httpd | wc -l' %(app_uuid))
if self.get_run_mode() == 'OnPremise':
p.expect("0")
else:
p.expect(["4"])
p.sendline('ctl_app start')
time.sleep(2)
p.expect(app_url)
p.sendline('ps -efww | grep "/usr/sbin/httpd" | grep -v "grep" | wc -l')
#p.sendline('pgrep -u %s httpd | wc -l' %(app_uuid))
if self.get_run_mode() == 'OnPremise':
p.expect("2")
else:
p.expect(["6"])
#p.sendline('ctl_app restart')
#time.sleep(2)
#p.expect(app_url)
#p.sendline('ps -efww | grep "/usr/sbin/httpd" | grep -v "grep" | wc -l')
##p.sendline('pgrep -u %s httpd | wc -l' %(app_uuid))
#if self.get_run_mode() == 'OnPremise':
# p.expect("2")
#else:
# p.expect(["6"])
p.sendline('ctl_all stop')
p.expect(app_url)
time.sleep(2)
p.sendline('ps -efww | grep -v "grep" | wc -l')
#p.sendline('pgrep -u %s | wc -l' %(app_uuid))
p.expect(["5"])
p.sendline('ctl_all start')
p.expect(app_url)
time.sleep(2)
p.sendline('ps -efww | grep -v "grep" | wc -l')
#p.sendline('pgrep -u %s | wc -l' %(app_uuid))
if self.get_run_mode() == 'OnPremise':
p.expect(["10", "11"])
else:
p.expect(["17", "18"])
p.sendline('exit')
p.expect('Connection to %s closed.'% app_url)
return 0
示例6: mongo_shell_test
# 需要导入模块: import OSConf [as 别名]
# 或者: from OSConf import get_ssh_url [as 别名]
def mongo_shell_test(self):
app_url = OSConf.get_app_url(self.app_name)
ssh_url = OSConf.get_ssh_url(self.app_name)
db_info = OSConf.get_embed_info(self.app_name, 'mongodb-2.2')
p = pexpect.spawn('ssh %s'% ssh_url)
p.logfile = sys.stdout
# index = p.expect([OSConf.get_app_url(self.app_name), pexpect.EOF, pexpect.TIMEOUT])
p.expect('Welcome to OpenShift shell')
p.expect(app_url)
p.sendline('help')
p.expect('Help menu:')
p.expect('interactive MongoDB shell')
p.sendline('mongo')
p.expect('MongoDB shell version:')
p.expect('connecting to:')
p.expect('>', timeout=20)
#p.sendcontrol('c')
p.sendline('exit')
p.expect('bye', timeout=20)
p.expect('.*')
db_path = '%s:%s/%s'% (db_info['url'], db_info['port'], db_info['database'])
self.info("db_path=%s"%db_path)
p.sendline('mongo %s'% db_path)
p.expect('MongoDB shell version:', timeout=30)
p.expect('connecting to: %s'% db_path, timeout=30)
p.expect('>')
p.sendline('db.auth("%s","%s")'% (db_info['username'], db_info['password']))
p.expect('1')
p.expect('>')
p.sendline('help')
p.expect('help on db methods')
p.expect('quit the mongo shell')
p.expect('>')
p.sendline('db')
p.expect(db_info['database'])
p.sendline('show collections')
p.expect('system.users')
p.sendline('db.createCollection("test")')
p.expect('{ "ok" : 1 }')
p.sendline('show collections')
p.expect('test')
p.sendline('db.test.save({"name":"lilu"})')
p.sendline('db.test.find()')
p.expect('"name" : "lilu"')
p.sendline('person=db.test.findOne({ name : "lilu" } )')
p.expect('"name" : "lilu"')
p.sendline('person.name="newlilu"')
p.expect('newlilu')
p.sendline('db.test.save(person)')
p.sendline('db.test.find()')
p.expect('"name" : "newlilu"')
p.sendline('db.test.save({"name":"lilu"})')
p.sendline('db.test.find()')
p.expect('"name" : "newlilu"')
p.expect('"name" : "lilu"')
p.sendline('db.test.remove({"name":"newlilu"})')
p.sendline('db.test.find()')
index = p.expect(['"name" : "newlilu"', '"name" : "lilu"', pexpect.TIMEOUT])
if index == 0 or index == 2:
return 1
p.sendline('exit')
p.expect('bye')
p.sendline('exit')
p.expect('Connection to %s closed.'% app_url)
return 0