Ejemplo n.º 1
0
def create(session, task, source, instance_id, http_code=301, target_path=''):
    instance = Instance.get(session, instance_id)
    redirect = Redirect(source=source, instance=instance, http_code=http_code,
                        target_path=target_path)
    session.add(redirect)
    session.flush()
    return redirect.source
Ejemplo n.º 2
0
def migrate(session, task, id, revision):
    if id == 'all':
        instances = Instance.all(session)
    else:
        instances = [Instance.get(session, id)]

    for instance in instances:
        instance.upgrade_schema(revision)
Ejemplo n.º 3
0
def reload(session, task, id, force=False, kill=False):
    if id == 'all':
        instances = Instance.all(session)
    else:
        instances = [Instance.get(session, id)]

    for instance in instances:
        if instance.enabled:
            instance.reload(force=force, kill=kill)
Ejemplo n.º 4
0
def update(session, task, domain, new_domain=None, instance_id=None):
    try:
        alias = Alias.get(session, domain)
        if instance_id:
            alias.instance = Instance.get(session, instance_id)
        if new_domain:
            alias.domain = new_domain
        session.flush()

    except:
        log.exception('alias.update')
Ejemplo n.º 5
0
def change_domain(session, task, id, domain):
    instance = Instance.get(session, id)
    reenable = False

    if instance.enabled:
        reenable = True
        instance.enabled = False

    instance.change_domain(domain)

    if reenable:
        instance.enabled = True
Ejemplo n.º 6
0
def switch_environment(session, task, id, environment):
    instance = Instance.get(session, id)
    new_env = Environment.get(session, environment)
    reenable = False

    if instance.enabled:
        reenable = True
        instance.enabled = False

    instance.environment = new_env

    if reenable:
        instance.enabled = True
Ejemplo n.º 7
0
def update(session, task, source, instance_id=None, http_code=None,
           target_path=None, new_source=None):
    try:
        redirect = Redirect.get(session, source)
        if instance_id:
            redirect.instance = Instance.get(session, instance_id)
        if http_code:
            redirect.http_code = http_code
        if target_path:
            redirect.target_path = target_path
        if new_source:
            redirect.source = new_source

    except:
        log.exception('redirect.update')
Ejemplo n.º 8
0
def rewrite(session, task, id):
    if id == "all":
        instances = Instance.all(session)
    else:
        instances = [Instance.get(session, id)]

    envs = {}
    for instance in instances:
        if not instance.enabled:
            continue

        env = instance.environment
        envs[env.name] = env
        instance.rewrite(restart_services=False)

    for env in envs.values():
        env.restart_services()
Ejemplo n.º 9
0
def create(session, task, domain, instance_id):
    instance = Instance.get(session, instance_id)
    alias = Alias(domain=domain, instance=instance)
    session.add(alias)
    session.flush()
    return alias.domain
Ejemplo n.º 10
0
def flush_cache(session, task, id):
    instance = Instance.get(session, id)
    instance.flush_cache()
Ejemplo n.º 11
0
def disable(session, task, id):
    instance = Instance.get(session, id)
    instance.enabled = False
Ejemplo n.º 12
0
def enable(session, task, id):
    instance = Instance.get(session, id)
    instance.enabled = True
Ejemplo n.º 13
0
def delete(session, task, id, archive=False):
    instance = Instance.get(session, id)
    instance.delete(archive=archive)
Ejemplo n.º 14
0
def restore(session, task, id, archive_name):
    instance = Instance.get(session, id)
    instance.restore(archive_name)
Ejemplo n.º 15
0
def archive(session, task, id, name):
    instance = Instance.get(session, id)
    instance.archive(name)