Beispiel #1
0
    def run_check(self, template_name=None, service_dir=None):
        " Run checking scripts. "

        print_header('Check requirements', sep='-')
        map(lambda cmd: call("bash %s" % cmd), self._gen_scripts(
            'check', template_name=template_name, service_dir=service_dir))
        return True
Beispiel #2
0
def info(args):
    " Show information about site. "

    site = find_site(args.PATH)
    print_header("%s -- install information" % site.get_name())
    print site.get_info(full=True)
    return True
Beispiel #3
0
def ls(args):
    " Show list of installed sites. "

    print_header("Installed sites:")
    for site in gen_sites(args.path):
        print site.get_info()
    return True
Beispiel #4
0
    def run_remove(self, template_name=None, service_dir=None):
        " Run remove scripts. "

        print_header('Uninstall %s' % self.get_name())
        map(call, self._gen_scripts(
            'remove', template_name=template_name, service_dir=service_dir))
        LOGGER.info('Site Remove done.')
        return True
Beispiel #5
0
    def run_update(self, template_name=None, service_dir=None):
        " Run update scripts. "

        LOGGER.info('Site Update start.')
        print_header('Update %s' % self.get_name())
        map(call, self._gen_scripts(
            'update', template_name=template_name, service_dir=service_dir))
        LOGGER.info('Site Update done.')
        return True
Beispiel #6
0
    def run_install(self, template_name=None, service_dir=None):
        " Run instalation scripts. "

        LOGGER.info('Site Install start.')
        print_header('Install %s' % self.get_name())
        map(call, self._gen_scripts(
            'install', template_name=template_name, service_dir=service_dir))
        LOGGER.info('Site Install done.')
        return True
Beispiel #7
0
    def run_check(self, template_name=None, service_dir=None):
        " Run checking scripts. "

        print_header('Check requirements', sep='-')
        map(
            lambda cmd: call("bash %s" % cmd),
            self._gen_scripts('check',
                              template_name=template_name,
                              service_dir=service_dir))
        return True
Beispiel #8
0
 def remove_template(self, template_name):
     assert template_name in self.templates, "Template not installed."
     print_header("Remove template: %s" % template_name)
     template = self._get_template_path(template_name)
     if not template.startswith(self.source_dir):
         for f in gen_template_files(template):
             call('sudo rm -f %s' % op.join(self.deploy_dir, f))
     self.templates = filter(lambda x: x != template_name, self.templates)
     self['template'] = ','.join(self.templates)
     self.write()
Beispiel #9
0
def module(args):
    " Copy module source to current directory. "

    mod = op.join(settings.MOD_DIR, args.MODULE)
    assert op.exists(mod), "Not found module: %s" % args.MODULE
    if not args.DEST.startswith(op.sep):
        args.DEST = op.join(getcwd(), args.DEST)
    print_header("Copy module source")
    copytree(mod, args.DEST)
    print "Done: %s" % args.DEST
Beispiel #10
0
 def remove_template(self, template_name):
     assert template_name in self.templates, "Template not installed."
     print_header("Remove template: %s" % template_name)
     template = self._get_template_path(template_name)
     if not template.startswith(self.source_dir):
         for f in gen_template_files(template):
             call('sudo rm -f %s' % op.join(self.deploy_dir, f))
     self.templates = filter(lambda x: x != template_name, self.templates)
     self['template'] = ','.join(self.templates)
     self.write()
Beispiel #11
0
    def run_remove(self, template_name=None, service_dir=None):
        " Run remove scripts. "

        print_header('Uninstall %s' % self.get_name())
        map(
            call,
            self._gen_scripts('remove',
                              template_name=template_name,
                              service_dir=service_dir))
        LOGGER.info('Site Remove done.')
        return True
Beispiel #12
0
 def add_template(self, template_name):
     assert not template_name in self.templates, "Template already installed."
     print_header("Append template: %s" % template_name)
     deploy_tmpdir = mkdtemp()
     self.paste_template(template_name, deploy_dir=deploy_tmpdir)
     call('sudo cp -r %s/* %s' % (deploy_tmpdir, self.deploy_dir))
     call('sudo chown %s:%s %s' %
          (self.site_user, self.site_group, self.deploy_dir))
     self.templates.append(template_name)
     self['template'] = ','.join(self.templates)
     self.write()
Beispiel #13
0
 def add_template(self, template_name):
     assert not template_name in self.templates, "Template already installed."
     print_header("Append template: %s" % template_name)
     deploy_tmpdir = mkdtemp()
     self.paste_template(template_name, deploy_dir=deploy_tmpdir)
     call('sudo cp -r %s/* %s' % (deploy_tmpdir, self.deploy_dir))
     call('sudo chown %s:%s %s' % (self.site_user,
          self.site_group, self.deploy_dir))
     self.templates.append(template_name)
     self['template'] = ','.join(self.templates)
     self.write()
Beispiel #14
0
    def run_install(self, template_name=None, service_dir=None):
        " Run instalation scripts. "

        LOGGER.info('Site Install start.')
        print_header('Install %s' % self.get_name())
        map(
            call,
            self._gen_scripts('install',
                              template_name=template_name,
                              service_dir=service_dir))
        LOGGER.info('Site Install done.')
        return True
Beispiel #15
0
    def run_update(self, template_name=None, service_dir=None):
        " Run update scripts. "

        LOGGER.info('Site Update start.')
        print_header('Update %s' % self.get_name())
        map(
            call,
            self._gen_scripts('update',
                              template_name=template_name,
                              service_dir=service_dir))
        LOGGER.info('Site Update done.')
        return True
Beispiel #16
0
    def clone_source(self):
        " Clone source and prepare templates "

        print_header('Clone src: %s' % self.src, '-')

        # Get source
        source_dir = self._get_source()

        # Append settings from source
        self.read(op.join(source_dir, settings.CFGNAME))

        self.templates += (self.args.template or self.template).split(',')
        self.templates = OrderedSet(self._gen_templates(self.templates))
        self['template'] = ','.join(str(x[0]) for x in self.templates)

        print_header('Deploy templates: %s' % self.template, sep='-')
        with open(op.join(self.deploy_dir, settings.TPLNAME), 'w') as f:
            f.write(self.template)

        with open(op.join(self.deploy_dir, settings.CFGNAME), 'w') as f:
            self['deploy_dir'], tmp_dir = self.target_dir, self.deploy_dir
            self.write(f)
            self['deploy_dir'] = tmp_dir

        # Create site
        site = Site(self.deploy_dir)

        # Prepare templates
        for template_name, template in self.templates:
            site.paste_template(template_name, template, tmp_dir)

        # Create site
        if self.args.info:
            print_header('Project context', sep='-')
            LOGGER.info(site.get_info(full=True))
            return None

        # Check requirements
        call('sudo chmod +x %s/*.sh' % self.service_dir)
        site.run_check(service_dir=self.service_dir)

        # Save options
        site.write()

        return site
Beispiel #17
0
 def clean(self):
     print_header('Delete %s' % self.get_name(), sep="-")
     call('sudo rm -rf %s' % self.deploy_dir)
Beispiel #18
0
 def build(self):
     print_header('Build site', sep='-')
     call('sudo mkdir -p %s' % op.dirname(self.target_dir))
     call('sudo mv %s %s' % (self.deploy_dir, self.target_dir))
     call('sudo chmod 0755 %s' % self.target_dir)
Beispiel #19
0
 def clean(self):
     print_header('Delete %s' % self.get_name(), sep="-")
     call('sudo rm -rf %s' % self.deploy_dir)