Пример #1
0
def main(args=None):
    state = Configurer.read_state(args)
    c_args = Configurer.Struct(**state.get('args', args))
    Configurer.enable_config(c_args.project_name)
    state['status'] = 'enabled'
    Configurer.write_state(state, c_args)
    pass
Пример #2
0
def main(args=None):
    state = Configurer.read_state(args)
    c_args = Configurer.Struct(**state.get('args', args))
    print("Disabling project at %s" % c_args.host)
    Configurer.disable_config(c_args.project_name)
    state['status'] = 'disabled'
    Configurer.write_state(state, c_args)
Пример #3
0
def install_with_template(args, name, template):
    state = {
        'ts': time.time(),
        'status': 'enabled',
        'template_name': name,
        'args': vars(args)
    }
    print("Preparing to initialize template, host is %s" % args.host)
    if template.TEMPLATE_TYPE == Template_Type.managed:
        state['template_type'] = 'managed'
        config = template.construct_config(args, shelf)
        Configurer.install_config(args.project_name)
        Configurer.set_config(args.project_name, config)
        Configurer.enable_config(args.project_name)
    elif template.TEMPLATE_TYPE == Template_Type.unmanaged:
        state['template_type'] = 'unmanaged'
        template.initialize(args, shelf)
    else:
        raise RuntimeError('Malformed template!')

    if getattr(template, 'post_install', None):
        state['has_post_install'] = True
        template.post_install(args, shelf)

    Configurer.write_state(state, args)
    shelf.sync()