Example #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
Example #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)
Example #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)
Example #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')
Example #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
Example #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
Example #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')
Example #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()
Example #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
Example #10
0
def flush_cache(session, task, id):
    instance = Instance.get(session, id)
    instance.flush_cache()
Example #11
0
def disable(session, task, id):
    instance = Instance.get(session, id)
    instance.enabled = False
Example #12
0
def enable(session, task, id):
    instance = Instance.get(session, id)
    instance.enabled = True
Example #13
0
def delete(session, task, id, archive=False):
    instance = Instance.get(session, id)
    instance.delete(archive=archive)
Example #14
0
def restore(session, task, id, archive_name):
    instance = Instance.get(session, id)
    instance.restore(archive_name)
Example #15
0
def archive(session, task, id, name):
    instance = Instance.get(session, id)
    instance.archive(name)