コード例 #1
0
    def __rancher_up__(self,
                       deployment,
                       style=None,
                       force=False,
                       pull=False,
                       dry=False):
        config = ufunc.__parse_deployment__(deployment)
        stack_name = config['stack_name']
        service_name = config['service_name']
        docker_file = config['docker_compose_file']
        env_file = config['env_file']
        rancher_file = config['rancher_compose_file']
        force_flag = "--force-upgrade" if force else ""
        pull_flag = "--pull" if pull else ""
        style_flag = "--%s" % style if style is not None else ""
        command_line = "rancher up %s -s %s %s %s -f %s -e %s --rancher-file %s -d %s" % (
            service_name, stack_name, force_flag, pull_flag, docker_file,
            env_file, rancher_file, style_flag)
        command_line = re.sub(' +', ' ', command_line)

        vars = {
            'VERSION':
            config['version'],
            'DEPLOY_TIMESTAMP':
            datetime.strftime(datetime.utcnow(), '%Y-%m-%dT%H:%M:%SUTC')
        }

        return ufunc.__call_command__(ufunc.clean_command_line(command_line),
                                      config, vars, dry)
コード例 #2
0
 def __example_wrapper__(self, deployment, style=None, upgrade=False, force=False, pull=False,
                         dry=False):
     config = ufunc.__parse_deployment__(deployment)
     stack_name = config['stack_name']
     service_name = config['service_name']
     docker_file = config['docker_compose_file']
     env_file = config['env_file']
     rancher_file = config['rancher_compose_file']
     upgrade_flag = "--upgrade" if upgrade else ""
     force_flag = "--force-upgrade" if force else ""
     pull_flag = "--pull" if pull else ""
     style_flag = "--%s" % style if style is not None else ""
     command_line = "rancher up %s -s %s %s %s %s -f %s -e %s --rancher-file %s -d %s" % (
         service_name, stack_name, upgrade_flag, force_flag, pull_flag,
         docker_file, env_file,
         rancher_file, style_flag)
     command_line = re.sub(' +', ' ', command_line)
     ufunc.__call_command__(command_line, config, dry)
コード例 #3
0
    def logs(self, deployment, follow=False, dry=False):
        config = ufunc.__parse_deployment__(deployment)
        if follow:
            follow = "-f"
        else:
            follow = ""
        command_line = "rancher logs %s %s" % (config['rancher_service'],
                                               follow)

        return ufunc.__call_command__(ufunc.clean_command_line(command_line),
                                      config, {}, dry)
コード例 #4
0
 def install_catalog(self, deployment, catalog_name, dry=False):
     config = ufunc.__parse_deployment__(deployment)
     command_line = "rancher catalog install %s -a %s" % (
         catalog_name, config['rancher_catalog_file'])
     return ufunc.__call_command__(ufunc.clean_command_line(command_line),
                                   config, {}, dry)
コード例 #5
0
 def restart(self, deployment, dry=False):
     config = ufunc.__parse_deployment__(deployment)
     command_line = "rancher restart %s" % config['rancher_service']
     return ufunc.__call_command__(ufunc.clean_command_line(command_line),
                                   config, {}, dry)