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
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)
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)
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')
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
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
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')
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()
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
def flush_cache(session, task, id): instance = Instance.get(session, id) instance.flush_cache()
def disable(session, task, id): instance = Instance.get(session, id) instance.enabled = False
def enable(session, task, id): instance = Instance.get(session, id) instance.enabled = True
def delete(session, task, id, archive=False): instance = Instance.get(session, id) instance.delete(archive=archive)
def restore(session, task, id, archive_name): instance = Instance.get(session, id) instance.restore(archive_name)
def archive(session, task, id, name): instance = Instance.get(session, id) instance.archive(name)