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


Python OSConf.get_embed_info方法代码示例

本文整理汇总了Python中OSConf.get_embed_info方法的典型用法代码示例。如果您正苦于以下问题:Python OSConf.get_embed_info方法的具体用法?Python OSConf.get_embed_info怎么用?Python OSConf.get_embed_info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OSConf的用法示例。


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

示例1: process_mongo_data

# 需要导入模块: import OSConf [as 别名]
# 或者: from OSConf import get_embed_info [as 别名]
    def process_mongo_data(self, operation, data, expect_str=None, unexpect_str=None):
        mongo_cred = OSConf.get_embed_info(self.app_name, common.cartridge_types[self.mongo_type])
        
        #print mongo_cred
        #print mongo_cred["username"]
        script = "db.test.%s(%s)"%(operation, data)
        if (operation == 'find'):
            script += ".forEach(printjson)"
        script += ";"

        js_script = "/tmp/m.js"
        mongo_cmds = "echo 'use %s;' >%s"%(self.app_name,js_script)
        mongo_cmds += "; echo '%s' >>%s"%(script, js_script)
        mongo_cmds += "; mongo --verbose -u %s -p %s %s:%s/admin < %s "%(
                            mongo_cred["username"],
                            mongo_cred["password"],
                            mongo_cred['url'],
                            mongo_cred['port'],
                            js_script)
        if operation == 'find':
            mongo_cmds += " | grep ObjectId "

        (status, output) = common.run_remote_cmd(self.app_name, mongo_cmds)

        if expect_str:
            self.assert_match(expect_str, output, "Unable to find `%s` string in the output."%expect_str)
        if unexpect_str:
            self.assert_not_match(unexpect_str, output, "Unexpected `%s` string in the output."%unexpect_str)

        return status
开发者ID:xiama,项目名称:automations,代码行数:32,代码来源:snapshot_restore_mongodb.py

示例2: check_rockmongo

# 需要导入模块: import OSConf [as 别名]
# 或者: from OSConf import get_embed_info [as 别名]
 def check_rockmongo(self, negative = False):
     keyword = "RockMongo"
     if negative:
         keyword = "503 Service Temporarily Unavailable"
     url = OSConf.get_embed_info(self.app_name, common.cartridge_types["rockmongo"], "url")+"/index.php?action=login.index"
     ret = common.grep_web_page(url, keyword, options="-k -H 'Pragma: no-cache'", delay=8, count=10)
     os.system("curl -k -H 'Pragma: no-cache' %s"% url)
     return ret
开发者ID:xiama,项目名称:automations,代码行数:10,代码来源:rhc_ctl_rockmongo.py

示例3: post_configuration_steps

# 需要导入模块: import OSConf [as 别名]
# 或者: from OSConf import get_embed_info [as 别名]
 def post_configuration_steps(self):
     self.log_info("Post-configuration steps...")
     mysql = OSConf.get_embed_info(self.config.application_name, common.cartridge_types['mysql'])
     steps = [
         "cd %s" % self.config.application_name,
         "sed -i -e 's/password:.*/password: %s/' -e 's/database: redmine/database: %s/' -e 's/host:.*/host: %s/' config/database.yml" % ( mysql["password"], self.config.application_name, mysql["url"] ) 
     ]
     common.command_get_status(" && ".join(steps))
开发者ID:xiama,项目名称:automations,代码行数:10,代码来源:quick_start_redmine.py

示例4: check_port

# 需要导入模块: import OSConf [as 别名]
# 或者: from OSConf import get_embed_info [as 别名]
 def check_port(self, serv, host, port):
     self.info("Checking service %s at %s:%s" % (serv, host, port))
     if serv in ('haproxy'):
         return common.grep_web_page("%s:%s" % (host, port), "(openshift)|(Statistics Report)")
     elif serv in ['mysqld', 'mysql']:
         db_info = OSConf.get_embed_info(self.app_name, common.cartridge_types['mysql'])
         cmd = "echo 'show databases;' | mysql -h %s -P %s -u %s -p%s %s" % (host, port, db_info['username'], db_info['password'], self.app_name)
     elif serv in ['postgres', 'postgresql']:
         db_info = OSConf.get_embed_info(self.app_name, common.cartridge_types['postgresql'])
         cmd = 'echo "%s:%s:%s:%s:%s" > $HOME/.pgpass ; chmod 0600 $HOME/.pgpass ; echo "\d" | psql -w -h %s --port %s -U %s %s' % (host, port, self.app_name, db_info['username'], db_info['password'], host, port, db_info['username'], self.app_name)
     elif serv in ['mongod', 'mongodb']:
         db_info = OSConf.get_embed_info(self.app_name, common.cartridge_types['mongodb'])
         cmd = 'echo "show collections;" | mongo -u %s -p %s %s:%s/%s' % (db_info['username'], db_info['password'], host, port, self.app_name)
     elif port == '8080':
         return common.grep_web_page("%s:%s" % (host, port), "(openshift)|(Statistics Report)")
     else:
         self.info("No check for service: %s %s:%s" % (serv, host, port))
         return 0
     return common.command_get_status(cmd)
开发者ID:xiama,项目名称:automations,代码行数:21,代码来源:rhc_port_forward.py

示例5: prepare_jsp_file

# 需要导入模块: import OSConf [as 别名]
# 或者: from OSConf import get_embed_info [as 别名]
 def prepare_jsp_file(self):
     try:
         mysql = OSConf.get_embed_info(self.app_name,common.cartridge_types['mysql'])
         self.info(mysql)
     except Exception as e:
         self.error(str(e))
         return False
     # Prepare jsp file
     fr = file("%s/../cartridge/app_template/bigdata/mysql/mysql.jsp" % (WORK_DIR), "r")
     jsp = fr.read()
     fr.close()
     fw = file("%s/src/main/webapp/mysql.jsp" % (self.app_name), "w")
     fw.write(jsp)
     fw.close()
     # Prepare mysql connector
     os.mkdir("%s/src/main/webapp/WEB-INF/lib" % (self.app_name))
     shutil.copyfile("%s/../cartridge/app_template/bigdata/mysql/mysql-connector-java-5.1.20-bin.jar" % (WORK_DIR), "%s/src/main/webapp/WEB-INF/lib/mysql-connector-java-5.1.20-bin.jar" % (self.app_name))
     return True
开发者ID:xiama,项目名称:automations,代码行数:20,代码来源:jbossews_mysql_scaling.py

示例6: test_port_forward

# 需要导入模块: import OSConf [as 别名]
# 或者: from OSConf import get_embed_info [as 别名]
 def test_port_forward(self, new_syntax=True):
     self.services = []
     result = True
     db_info = OSConf.get_embed_info(self.app_name, common.cartridge_types[self.db_variant])
     self.info("db_cartridge info: %s"%db_info)
     if new_syntax:
         cmd = "rhc port-forward %s -l %s -p '%s' %s" % (self.app_name, self.config.OPENSHIFT_user_email, self.config.OPENSHIFT_user_passwd, common.RHTEST_RHC_CLIENT_OPTIONS)
     else:
         cmd = "rhc port-forward -a %s -l %s -p '%s' %s" % (self.app_name, self.config.OPENSHIFT_user_email, self.config.OPENSHIFT_user_passwd, common.RHTEST_RHC_CLIENT_OPTIONS)
     self.debug("Command: %s" % (cmd))
     proc = pexpect.spawn(cmd)
     # expand the timeout from 20 to 40 to avoid slow response
     proc.expect('--', timeout=40)
     line = proc.readline()
     while 'terminate' not in line:
         line = proc.readline()
         self.info(line)
         #match = re.search(r'(\w+)\s+[\d.:]+\s+=>\s+((\d+\.){3}\d+):(\d+)', line)
         #match = re.search(r'(\w+)\s+((\d+\.){3}\d+):(\d+)+\s+=>\s+[\w\.\:\-\d]+', line)
         match = re.search(r'(\w+)\s+((\d+\.){3}\d+):(\d+)+\s+=>[\w\s\.\:]*', line)
         self.info(line)
         print match
         if match:
             serv = match.group(1)
             host = match.group(2)
             port = match.group(4)
             print serv
             self.services.append(serv)
             ret = self.check_port(serv, host, port)
             print ret
             if ret != 0:
                 result = False
                 self.debug("Check failed: %s %s:%s" % (serv, host, port))
         #line = proc.readline()
     self.info(self.services)
     proc.terminate()
     return result
开发者ID:xiama,项目名称:automations,代码行数:39,代码来源:rhc_port_forward_postgresql92.py

示例7: mongo_shell_test

# 需要导入模块: import OSConf [as 别名]
# 或者: from OSConf import get_embed_info [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
开发者ID:xiama,项目名称:automations,代码行数:68,代码来源:mongodb_via_rhcsh.py


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