def delete(self, request, database_name, format=None): """This method unbinds a App to a database through tsuru.""" env = get_url_env(request) data = request.DATA LOG.debug("Tsuru Unbind App DELETE Request DATA {}".format(data)) response = check_database_status(database_name, env) if not isinstance(response, Database): return response database = response acl_from_hell_client = ACLFromHellClient(database.environment) acl_from_hell_client.remove_acl( database, self._handle_app_name(data['app-name'])) return Response(status=status.HTTP_204_NO_CONTENT)
def add_acl_for_hosts(self, database, app_name): infra = database.infra hosts = infra.hosts acl_from_hell_client = ACLFromHellClient(database.environment) for host in hosts: resp = acl_from_hell_client.add_acl(database, app_name, host.hostname) if not resp.ok: msg = "Error for {} on {}.".format(database.name, database.environment.name) return log_and_response( msg=msg, e=resp.content, http_status=status.HTTP_500_INTERNAL_SERVER_ERROR) acl_from_hell_client.add_acl_for_vip_if_needed(database, app_name) return None
def add_acl_for_hosts(self, database, app_name): infra = database.infra hosts = infra.hosts acl_from_hell_client = ACLFromHellClient(database.environment) if not acl_from_hell_client.aclfromhell_allowed: raise AclFromHellNotAllowerForEnvException( "ACL from hell credential not found for env {}".format( database.environment)) for host in hosts: acl_from_hell_client.add_acl(database, app_name, host.hostname) acl_from_hell_client.add_acl_for_vip_if_needed(database, app_name)
def acl_from_hell_client(self): return ACLFromHellClient(self.environment)