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


Python OSConf类代码示例

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


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

示例1: test_method

    def test_method(self):
        ret_list = []
        for i in range(3):
            common.env_setup()
            step = testcase.TestCaseStep(
                    "Try %s: Create more apps than app_limit_per_user setting upon %s concurrent creation" %(i + 1, self.app_limit_per_user + 2),
                    self.concrrent_creation_step,
                    function_parameters=[1, self.app_limit_per_user + 2],
                    expect_description="No more apps beyond limit should be created")

            (ret_dict, output) = step.run()
            # print ret_dict
            if ret_dict.values().count(0) == self.app_limit_per_user:
                ret_list.append(0)
                # Init OSConf to clean these apps in next iterval
                OSConf.initial_conf()
            else:
                ret_list.append(1)
                # Init OSConf to clean these apps in next script
                OSConf.initial_conf()
                break


        #print ret_list
        if ret_list.count(1) > 0:
            print "Upon %s concurrent creation, more apps than app_limit_per_user is created - [FAIL]" %(self.app_limit_per_user + 2)
            return self.failed("%s failed" % self.__class__.__name__)
        else:
            return self.passed("%s passed" % self.__class__.__name__)
开发者ID:xiama,项目名称:automations,代码行数:29,代码来源:app_limit_per_user-concurrent_creation.py

示例2: get_process_id

 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
开发者ID:xiama,项目名称:automations,代码行数:29,代码来源:hot_deploy_test.py

示例3: create_app

def create_app(app_name, app_type, user_email=None, user_passwd=None,
               clone_repo=True, git_repo="./", scalable=False,
               gear_size = "small", timeout=None,
               disable_autoscaling=True):
    if user_email is None:
        (user_email, user_passwd) = get_default_rhlogin()
    if clone_repo == True:
        if git_repo == "./":
            options = ""
            cmd = "ls %s" % (app_name)
        else:
            options = "-r %s" %(git_repo)
            cmd = "ls %s" % (git_repo)
    else:
        options = "--no-git"
        cmd = "true"
    try:
        if os.path.exists(app_name):
            shutil.rmtree(app_name)
    except:
        pass

    cmd = ("rhc app create %s %s -l %s -p %s"
           " %s %s")% (app_name, app_type,
                                  user_email, user_passwd, 
                                  options, RHTEST_RHC_CLIENT_OPTIONS)
    if scalable:
        cmd += " -s "

    if gear_size != "small":
        cmd += " -g %s " % ( gear_size )

    (ret, output) = command_getstatusoutput(cmd, quiet=False)

    if ret == 0:
        if not isDNS(output):
            OSConf.add_app(app_name, app_type, output)
        else:
            log.info("DNS issue - try to update cache via REST API")
            OSConf.add_app(app_name, app_type, output)
    else:
        print "ERROR!\n",output
        if is500(output): #or isDNS(output):
            raise MercyException("500")
        return ret

    if scalable and disable_autoscaling:
        if clone_repo:
            touch(os.path.join(app_name,".openshift/markers/disable_auto_scaling"))
            cmd = "cd %s && git add . && git commit -amt && git push" % (app_name)
            log.debug("Disabling autoscaling...")
            (retcode, output) = command_getstatusoutput(cmd, quiet = True)
            if retcode != 0:
                log.error("Unable to disable autoscaling: %s"%output)
        else:
            log.warning("Unable to disable autoscaling->disabled clone_repo")
    if app_type == app_types['jenkins']:
        print 'Waiting for jenkins server to get ready...'
        time.sleep(30)
    return ret
开发者ID:xiama,项目名称:automations,代码行数:60,代码来源:client.py

示例4: create_scalable_app2

def create_scalable_app2(app_name, app_type, user_email=None, user_passwd=None, 
                        clone_repo=True, git_repo="./", gear_size="small", 
                        disable_autoscaling=True):
    """Create app with REST API"""
    if user_email is None:
        (user_email, user_passwd) = get_default_rhlogin()

    rest = openshift.Openshift(host=get_instance_ip(), 
                               user=user_email, 
                               passwd=user_passwd)
    (status, response) = rest.app_create_scale(app_name, app_type)
    if status in ('OK', 'Created'):
        OSConf.setup_by_rest()
        if clone_repo:
            git_clone_app(app_name)
        if disable_autoscaling:
            if clone_repo:
                touch(os.path.join(app_name,".openshift/markers/disable_auto_scaling"))
                cmd = "cd %s && git add . && git commit -amt && git push" % (app_name)
                log.debug("Disabling autoscaling...")
                (retcode, output) = command_getstatusoutput(cmd, quiet = True)
                if retcode != 0:
                    log.error("Unable to disable autoscaling: %s"%output)
            else:
                log.warning("Unable to disable autoscaling->disabled clone_repo")
    else:
        log.error(response)
    if status in ('OK', 'Created'):
        return 0
    else:
        return 1
开发者ID:xiama,项目名称:automations,代码行数:31,代码来源:rest.py

示例5: finalize

 def finalize(self):
     self.remove_apps_from_mongo()
     for app_name in [ self.app_name, self.app_name2 ]:
         uuid = OSConf.get_app_uuid(app_name)
         app_url = OSConf.get_app_url(app_name)
         common.destroy_app(app_name)
         if uuid != 1:
             common.run_remote_cmd_as_root("rm -Rf /var/lib/openshift/%s" % uuid, app_url)
             common.run_remote_cmd_as_root("rm -Rf /var/lib/openshift/%s-*" % app_name, app_url)
开发者ID:xiama,项目名称:automations,代码行数:9,代码来源:rhc_admin_check.py

示例6: clean_up

def clean_up(user_email=None, user_passwd=None):
    """Remove all applications and cleans up cache"""
    if user_email is None:
        (user_email, user_passwd) = get_default_rhlogin()
    try:
        app_dict = user_info(user_email, user_passwd)
        retcode = 0
        for app_name in app_dict.keys():
            ret = destroy_app2(app_name, user_email, user_passwd)
            if ret != 0:
                retcode = ret
                # Hot fix for Bug 958619
                # delete the app a second time
                # ret = destroy_app2(app_name, user_email, user_passwd)
                # if ret != 0:
                #    retcode = ret
    except:
        #this is the case, when cache file is missing
        pass

    try:
        rest = openshift.Openshift(host=get_instance_ip(), 
                                   user=user_email, 
                                   passwd=user_passwd)
        (status, l2) = rest.app_list()

        if (status == 'OK'):
            for app in l2:
                app_name = app['name']
                try:
                    (stat, resp) = rest.app_delete(app_name)
                except Exception as e:
                    log.error("Unable to destroy %s: %s"%(app_name, str(e)))
                try:
                    if os.path.exists(app_name):
                        shutil.rmtree(app_name)
                except:
                    pass
        else:
            log.warning("Unable to get the list of apps to clean up: status = %s"%status)
    except openshift.OpenShiftNullDomainException:
        pass
    except Exception as e:
        import traceback
        traceback.print_exc(file=sys.stderr)
        log.error("Problem when destroying applications: %s"%str(e))

    try:
        OSConf.initial_conf()
    except Exception as e:
        log.warn("Error during initialising cache: %s"% e)

    return retcode
开发者ID:xiama,项目名称:automations,代码行数:53,代码来源:misc.py

示例7: check_the_cron

 def check_the_cron(self):
     self.info("Waiting for a minute to get some results from cron...")
     uuid = OSConf.get_app_uuid(self.app_name)
     app_url = OSConf.get_app_url(self.app_name)
     time.sleep(65)
     p = pexpect.spawn('ssh -t -o ConnectTimeout=20 %[email protected]%s "cat $OPENSHIFT_DATA_DIR/date.txt"' % (uuid, app_url))
     p.wait()
     try:
         ret = p.expect("\d{2}:\d{2}:\d{2}@\d{4}-\d{2}-\d{2}")
         return ret
     except pexpect.TIMEOUT, e:
         print "Failed to find data generated by cron job. %s" % (e)
开发者ID:xiama,项目名称:automations,代码行数:12,代码来源:cron_embed.py

示例8: create_domain

def create_domain(domain_name, user_email=None, user_passwd=None, options=""):
    if user_email is None:
        (user_email, user_passwd) = get_default_rhlogin()
    print domain_name
    cmd = 'rhc domain create %s -l %s -p "%s" %s %s'% (domain_name,
                                                       user_email, 
                                                       user_passwd, 
                                                       options,
                                                       RHTEST_RHC_CLIENT_OPTIONS)
    ret = command_get_status(cmd)
    if ret == 0:
        OSConf.initial_conf()
    return ret
开发者ID:xiama,项目名称:automations,代码行数:13,代码来源:client.py

示例9: destroy_app2

def destroy_app2(app_name, user_email=None, user_passwd=None, clean_repo=False, git_repo="./"):
    """REST variant of destro_app"""
    if user_email is None:
        (user_email, user_passwd) = get_default_rhlogin()
    rest = openshift.Openshift(host=get_instance_ip(), 
                               user=user_email, 
                               passwd=user_passwd)
    rest.app_delete(app_name)

    if clean_repo == True and os.path.exists(git_repo):
        shutil.rmtree(git_repo)

    OSConf.remove_app(app_name)
开发者ID:xiama,项目名称:automations,代码行数:13,代码来源:rest.py

示例10: alter_domain

def alter_domain(domain_name, user_email=None, user_passwd=None, options=""):
    if user_email is None:
        (user_email, user_passwd) = get_default_rhlogin()
    old_domain = get_domain_name(user_email, user_passwd)
    cmd = 'rhc domain update %s %s -l %s -p "%s" %s %s'% (old_domain,
                                                          domain_name,
                                                          user_email, 
                                                          user_passwd, 
                                                          options,
                                                          RHTEST_RHC_CLIENT_OPTIONS)
    ret = command_get_status(cmd)
    if ret == 0:
        OSConf.alter_domain(domain_name)
    return ret
开发者ID:xiama,项目名称:automations,代码行数:14,代码来源:client.py

示例11: run_remote_cmd

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)
开发者ID:xiama,项目名称:automations,代码行数:15,代码来源:misc.py

示例12: run_remote_cmd2

def run_remote_cmd2(app_name, cmd, as_root=False, host=None, quiet=False):
    """
    Using ssh client
    """
    if as_root:
        user = 'root'
        if not host:
            host = get_instance_ip()
        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_output2(cmd, user, host, key_filename, quiet)
开发者ID:xiama,项目名称:automations,代码行数:15,代码来源:misc.py

示例13: verify

    def verify(self, app_name, hook_name, expected_re=None, expected_return=None):
        uuid = OSConf.get_app_uuid(app_name)
        cmd = '''cd /usr/libexec/openshift/cartridges/embedded/%s/info/hooks && ./%s %s %s %s '''%(common.cartridge_types['mysql'], hook_name, app_name, self.domain_name, uuid)
        (status, output) = common.run_remote_cmd(None, cmd, as_root=True)
        #this is stronger condition
        if (expected_re!=None):
            obj = re.search(r"%s"%expected_re, output)
            if obj:
                if (hook_name=='expose-port'):
                    obj = re.search(r"PROXY_HOST=(.*)",output)
                    obj2 = re.search(r"PROXY_PORT=(.*)",output)
                    if (obj and obj2):
                        self.proxy_host = obj.group(1)
                        self.proxy_port = obj2.group(1)
                    else:
                        print "WARNING: Unable to capture PROXY_HOST from output..."
                return 0
            else:
                return 1

        if (expected_return!=None):
            if status==expected_return:
                return 0
            else:
                return 1
        print "WARNING: Nothing to verify?"
        return 1
开发者ID:xiama,项目名称:automations,代码行数:27,代码来源:expose_conceal_port_hooks.py

示例14: add_sshkey

def add_sshkey(key_filepath="~/.ssh/id_rsa.pub", key_name="default", user_email=None, user_passwd=None, options=""):
    if user_email is None:
        (user_email, user_passwd) = get_default_rhlogin()
    cmd = 'rhc sshkey add %s %s -l %s -p %s %s %s'% (key_name,
                                                     key_filepath,
                                                     user_email,
                                                     user_passwd,
                                                     options,
                                                     RHTEST_RHC_CLIENT_OPTIONS)
    (ret, output) = command_getstatusoutput(cmd)
    if ret == 0:
        cmd = "ssh-keygen -lf %s" % (key_filepath)
        (ret, output) = command_getstatusoutput(cmd, quiet=True)
        try:
            pattern = re.compile(r'\d+ ([\w:]+) .*\(([DR]SA)\)')
            match_obj = pattern.search(output)
            fingerprint = match_obj.group(1)
            key_type = match_obj.group(2).lower()
            ret2 = OSConf.add_sshkey(key_name, key_type, fingerprint)
            if ret2 != 0:
                print "Warning: Failed to add ssh key to OSConf"
        except:
            print "Warning: Failed to add ssh key to OSConf"
    else:
        print output
    return ret
开发者ID:xiama,项目名称:automations,代码行数:26,代码来源:client.py

示例15: test_method

    def test_method(self):
        self.info("Create a %s application" %(self.app_type))
        ret = common.create_app(self.app_name, self.app_type, self.config.OPENSHIFT_user_email, self.config.OPENSHIFT_user_passwd)
        self.assert_equal(ret, 0, "App should be created successfully")

        source_file = "%s/data/qpid_fuzzing_stage.php" %(WORK_DIR)
        target_file = "%s/php/index.php" %(self.app_name)

        self.info("2.Copying test files to app git repo") 
        ret = common.command_get_status("cp -f %s %s" %(source_file, target_file))
        self.assert_equal(ret, 0)

        self.info("3. Do git commit") 
        ret = common.command_get_status("cd %s && git add . && git commit -m test && git push" %(self.app_name)) 

        self.assert_equal(ret, 0, "File and directories are added to your git repo successfully")

        self.info("4. Get app url") 
        app_url = OSConf.get_app_url(self.app_name)

        self.info("Access app's URL to tigger test") 
        ret = common.grep_web_page("%s/index.php?action=create"%app_url, "###RESULT###: PASS")
        self.assert_equal(ret, 0)

        return self.passed("%s passed" % self.__class__.__name__)
开发者ID:xiama,项目名称:automations,代码行数:25,代码来源:qpid_binding_stage.py


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