diff --git a/Dockerfile b/Dockerfile index 367b7e1f..9d66f96c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,11 @@ -FROM python:3.8.2-slim -ADD . /code -WORKDIR /code +FROM python:3.8.2-buster RUN apt-get update -y -RUN apt install -y build-essential -RUN apt-get install -y python3-dev +RUN apt-get install -y build-essential +WORKDIR /code +ADD requirements.txt /code RUN pip install -r requirements.txt -COPY ansible.cfg /etc/ansible/ +ADD requirements.yml /code +ADD ansible.cfg /etc/ansible/ RUN ansible-galaxy install -r requirements.yml +ADD . /code WORKDIR /code/VirtualMachineService diff --git a/Makefile b/Makefile index fe55f00b..9760d98b 100644 --- a/Makefile +++ b/Makefile @@ -23,12 +23,43 @@ thrift_py: ## Builds python code from thrift file dev-build: ## Build and Start the docker-compose.dev.yml docker-compose -f docker-compose.dev.yml up --build +dev-d: ## Build and Start the docker-compose.dev.yml + docker-compose -f docker-compose.dev.yml up -d + +dev-build-d: ## Build and Start the docker-compose.dev.yml + docker-compose -f docker-compose.dev.yml up --build -d + dev: ## Build and Start the docker-compose.dev.yml - docker-compose -f docker-compose.dev.yml up + docker-compose -f docker-compose.dev.yml up + +dev-build-bibigrid: ## Build and Start the docker-compose.dev.yml with bibigrid + docker-compose -f docker-compose.dev.bibigrid.yml up --build + +dev-bibigrid: ## Build and Start the docker-compose.dev.yml with bibigrid + docker-compose -f docker-compose.dev.bibigrid.yml up + +dev-build-bibigrid-d: ## Build and Start the docker-compose.dev.yml with bibigrid + docker-compose -f docker-compose.dev.bibigrid.yml up --build -d + +dev-bibigrid-d: ## Build and Start the docker-compose.dev.yml with bibigrid + docker-compose -f docker-compose.dev.bibigrid.yml up -d production: ## Build Release from .env docker-compose -f docker-compose.yml up --build -d +production-bibigrid: ## Build Release from .env and with bibigrid + docker-compose -f docker-compose.bibigrid.yml up --build -d + +client_logs: ## Logs from Client + docker logs client_portal-client_1 + +bibigrid_logs: ## Logs from Bibigrid + docker logs client_bibigrid_1 + +enter_client_container: ## Enter Client container + docker exec -it client_portal-client_1 bash + + .PHONY: help lint docs thrift_py diff --git a/README.md b/README.md index da2fd8f6..0b275cd6 100644 --- a/README.md +++ b/README.md @@ -250,5 +250,6 @@ Optional Keys are: + env_file + secrets_file + client_server_pem ++ client_config **Note:** Default repository is always master. Also by default, the files are taken from the folders as for local start. diff --git a/VirtualMachineService/VirtualMachineHandler.py b/VirtualMachineService/VirtualMachineHandler.py index 2db6b520..42cda7a8 100644 --- a/VirtualMachineService/VirtualMachineHandler.py +++ b/VirtualMachineService/VirtualMachineHandler.py @@ -71,6 +71,8 @@ class VirtualMachineHandler(Iface): """Handler which the PortalClient uses.""" global active_playbooks + API_TOKEN = None + API_TOKEN_BUFFER = 15 BUILD = "BUILD" ACTIVE = "ACTIVE" ERROR = "ERROR" @@ -511,10 +513,8 @@ def get_server(self, openstack_id): self.logger.exception( "No Server found {0} | Error {1}".format(openstack_id, e) ) - return VM(status="DELETED") - if server is None: - self.logger.exception("No Server {0}".format(openstack_id)) - raise serverNotFoundException(Reason="No Server {0}".format(openstack_id)) + return VM(status="NOT FOUND") + serv = server.to_dict() if serv["attached_volumes"]: @@ -676,37 +676,71 @@ def create_mount_init_script( return init_script def get_api_token(self): - auth_url = self.conn.endpoint_for("identity") - self.logger.info(auth_url) - auth = { - "auth": { - "identity": { - "methods": ["password"], - "password": { - "user": { - "name": self.USERNAME, - "domain": {"name": self.USER_DOMAIN_NAME}, - "password": self.PASSWORD, + self.get_or_refresh_token() + return str(self.API_TOKEN["token"]) + + def get_or_refresh_token(self): + self.logger.info("Get API Token") + if not self.API_TOKEN: + self.logger.info("Create a new API Token") + auth_url = self.conn.endpoint_for("identity") + self.logger.info(auth_url) + auth = { + "auth": { + "identity": { + "methods": ["password"], + "password": { + "user": { + "name": self.USERNAME, + "domain": {"name": self.USER_DOMAIN_NAME}, + "password": self.PASSWORD, + } + }, + }, + "scope": { + "project": { + "domain": {"id": "default"}, + "name": self.PROJECT_NAME, } }, } } - } - res = req.post(url=auth_url + "/auth/tokens?nocatalog", json=auth) - self.logger.info(res.headers) - return res.headers["X-Subject-Token"] + res = req.post(url=auth_url + "/auth/tokens?nocatalog", json=auth) + + expires_at = datetime.datetime.strptime( + res.json()["token"]["expires_at"], "%Y-%m-%dT%H:%M:%S.%fZ" + ) + + self.API_TOKEN = { + "token": res.headers["X-Subject-Token"], + "expires_at": expires_at, + } + self.logger.info("New Token: {}".format(self.API_TOKEN)) + else: + self.logger.info("Check existing token") + now = datetime.datetime.now() + # some buffer + now = now - datetime.timedelta(minutes=self.API_TOKEN_BUFFER) + api_token_expires_at = self.API_TOKEN["expires_at"] + if now.time() > api_token_expires_at.time(): + expired_since = api_token_expires_at - now + self.logger.info( + "Old token is expired since {} minutes!".format( + expired_since.seconds // 60 + ) + ) + self.API_TOKEN = None + self.get_api_token() + else: + self.logger.info("Token still valid!") def resize_volume(self, volume_id, size): - token = self.get_api_token() - vol3 = self.conn.endpoint_for("volumev3") - header = {"X-Auth-Token": str(token)} - body = {"os-extend": {"new_size": size}} - url = vol3 + "/volumes/" + volume_id + "/action" - self.logger.info(url) - res = req.post(url=url, json=body, headers=header) - self.logger.info(res.status_code) - self.logger.info(res.content) - return int(res.status_code) + try: + self.conn.block_storage.extend_volume(volume_id, size) + except Exception as e: + self.logger.exception(e) + return 1 + return 0 def create_volume(self, volume_name, volume_storage, metadata): """ @@ -1296,6 +1330,76 @@ def delete_backend(self, id): self.logger.exception(e) return str(-1) + def add_user_to_backend(self, backend_id, owner_id, user_id): + try: + post_url = "{0}users/{1}".format(self.RE_BACKEND_URL, backend_id) + user_info = { + "owner": owner_id, + "user": user_id, + } + except Exception as e: + self.logger.exception(e) + return {"Error": "Could not create url or json body."} + try: + response = req.post( + post_url, + json=user_info, + timeout=(30, 30), + headers={"X-API-KEY": self.FORC_API_KEY}, + verify=self.PRODUCTION, + ) + try: + data = response.json() + except Exception as e: + self.logger.exception(e) + return {"Error": "Error in POST."} + return data + except Timeout as e: + self.logger.info(msg="create_backend timed out. {0}".format(e)) + return {"Error": "Timeout."} + except Exception as e: + self.logger.exception(e) + return {"Error": "An error occured."} + + def get_users_from_backend(self, backend_id): + get_url = "{0}/users/{1}".format(self.RE_BACKEND_URL, backend_id) + try: + response = req.get( + get_url, + timeout=(30, 30), + headers={"X-API-KEY": self.FORC_API_KEY}, + verify=self.PRODUCTION, + ) + if response.status_code == 401: + return ["Error: 401"] + else: + return response.json() + except Timeout as e: + self.logger.info(msg="Get users for backend timed out. {0}".format(e)) + return [] + + def delete_user_from_backend(self, backend_id, owner_id, user_id): + delete_url = "{0}/users/{1}".format(self.RE_BACKEND_URL, backend_id) + user_info = { + "owner": owner_id, + "user": user_id, + } + try: + response = req.delete( + delete_url, + json=user_info, + timeout=(30, 30), + headers={"X-API-KEY": self.FORC_API_KEY}, + verify=self.PRODUCTION, + ) + return response.json() + except Timeout as e: + self.logger.info(msg="Delete user from backend timed out. {0}".format(e)) + return {"Error": "Timeout."} + except Exception as e: + self.logger.exception(e) + return {"Error": "An Exception occured."} + def exist_server(self, name): if self.conn.compute.find_server(name) is not None: return True diff --git a/VirtualMachineService/VirtualMachineService-remote b/VirtualMachineService/VirtualMachineService-remote index 668a78e7..8e8e4cdb 100755 --- a/VirtualMachineService/VirtualMachineService-remote +++ b/VirtualMachineService/VirtualMachineService-remote @@ -59,6 +59,9 @@ if len(sys.argv) <= 1 or sys.argv[1] == '--help': print(' get_backends_by_template(string template)') print(' Backend get_backend_by_id(i64 id)') print(' string delete_backend(i64 id)') + print(' add_user_to_backend(i64 backend_id, string owner_id, string user_id)') + print(' get_users_from_backend(i64 backend_id)') + print(' delete_user_from_backend(i64 backend_id, string owner_id, string user_id)') print(' get_templates()') print(' get_allowed_templates()') print(' get_templates_by_template(string template_name)') @@ -373,6 +376,24 @@ elif cmd == 'delete_backend': sys.exit(1) pp.pprint(client.delete_backend(eval(args[0]),)) +elif cmd == 'add_user_to_backend': + if len(args) != 3: + print('add_user_to_backend requires 3 args') + sys.exit(1) + pp.pprint(client.add_user_to_backend(eval(args[0]), args[1], args[2],)) + +elif cmd == 'get_users_from_backend': + if len(args) != 1: + print('get_users_from_backend requires 1 args') + sys.exit(1) + pp.pprint(client.get_users_from_backend(eval(args[0]),)) + +elif cmd == 'delete_user_from_backend': + if len(args) != 3: + print('delete_user_from_backend requires 3 args') + sys.exit(1) + pp.pprint(client.delete_user_from_backend(eval(args[0]), args[1], args[2],)) + elif cmd == 'get_templates': if len(args) != 0: print('get_templates requires 0 args') diff --git a/VirtualMachineService/VirtualMachineService.py b/VirtualMachineService/VirtualMachineService.py index 8315b5d2..a592c393 100644 --- a/VirtualMachineService/VirtualMachineService.py +++ b/VirtualMachineService/VirtualMachineService.py @@ -438,6 +438,40 @@ def delete_backend(self, id): """ pass + def add_user_to_backend(self, backend_id, owner_id, user_id): + """ + Add a user to a backend + + Parameters: + - backend_id + - owner_id + - user_id + + """ + pass + + def get_users_from_backend(self, backend_id): + """ + Get users from a backend + + Parameters: + - backend_id + + """ + pass + + def delete_user_from_backend(self, backend_id, owner_id, user_id): + """ + Delete user from a backend + + Parameters: + - backend_id + - owner_id + - user_id + + """ + pass + def get_templates(self): pass @@ -2287,6 +2321,131 @@ def recv_delete_backend(self): "delete_backend failed: unknown result", ) + def add_user_to_backend(self, backend_id, owner_id, user_id): + """ + Add a user to a backend + + Parameters: + - backend_id + - owner_id + - user_id + + """ + self.send_add_user_to_backend(backend_id, owner_id, user_id) + return self.recv_add_user_to_backend() + + def send_add_user_to_backend(self, backend_id, owner_id, user_id): + self._oprot.writeMessageBegin( + "add_user_to_backend", TMessageType.CALL, self._seqid + ) + args = add_user_to_backend_args() + args.backend_id = backend_id + args.owner_id = owner_id + args.user_id = user_id + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_add_user_to_backend(self): + iprot = self._iprot + (fname, mtype, rseqid) = iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(iprot) + iprot.readMessageEnd() + raise x + result = add_user_to_backend_result() + result.read(iprot) + iprot.readMessageEnd() + if result.success is not None: + return result.success + raise TApplicationException( + TApplicationException.MISSING_RESULT, + "add_user_to_backend failed: unknown result", + ) + + def get_users_from_backend(self, backend_id): + """ + Get users from a backend + + Parameters: + - backend_id + + """ + self.send_get_users_from_backend(backend_id) + return self.recv_get_users_from_backend() + + def send_get_users_from_backend(self, backend_id): + self._oprot.writeMessageBegin( + "get_users_from_backend", TMessageType.CALL, self._seqid + ) + args = get_users_from_backend_args() + args.backend_id = backend_id + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_get_users_from_backend(self): + iprot = self._iprot + (fname, mtype, rseqid) = iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(iprot) + iprot.readMessageEnd() + raise x + result = get_users_from_backend_result() + result.read(iprot) + iprot.readMessageEnd() + if result.success is not None: + return result.success + raise TApplicationException( + TApplicationException.MISSING_RESULT, + "get_users_from_backend failed: unknown result", + ) + + def delete_user_from_backend(self, backend_id, owner_id, user_id): + """ + Delete user from a backend + + Parameters: + - backend_id + - owner_id + - user_id + + """ + self.send_delete_user_from_backend(backend_id, owner_id, user_id) + return self.recv_delete_user_from_backend() + + def send_delete_user_from_backend(self, backend_id, owner_id, user_id): + self._oprot.writeMessageBegin( + "delete_user_from_backend", TMessageType.CALL, self._seqid + ) + args = delete_user_from_backend_args() + args.backend_id = backend_id + args.owner_id = owner_id + args.user_id = user_id + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_delete_user_from_backend(self): + iprot = self._iprot + (fname, mtype, rseqid) = iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(iprot) + iprot.readMessageEnd() + raise x + result = delete_user_from_backend_result() + result.read(iprot) + iprot.readMessageEnd() + if result.success is not None: + return result.success + raise TApplicationException( + TApplicationException.MISSING_RESULT, + "delete_user_from_backend failed: unknown result", + ) + def get_templates(self): self.send_get_templates() return self.recv_get_templates() @@ -3328,6 +3487,13 @@ def __init__(self, handler): ] = Processor.process_get_backends_by_template self._processMap["get_backend_by_id"] = Processor.process_get_backend_by_id self._processMap["delete_backend"] = Processor.process_delete_backend + self._processMap["add_user_to_backend"] = Processor.process_add_user_to_backend + self._processMap[ + "get_users_from_backend" + ] = Processor.process_get_users_from_backend + self._processMap[ + "delete_user_from_backend" + ] = Processor.process_delete_user_from_backend self._processMap["get_templates"] = Processor.process_get_templates self._processMap[ "get_allowed_templates" @@ -4421,6 +4587,85 @@ def process_delete_backend(self, seqid, iprot, oprot): oprot.writeMessageEnd() oprot.trans.flush() + def process_add_user_to_backend(self, seqid, iprot, oprot): + args = add_user_to_backend_args() + args.read(iprot) + iprot.readMessageEnd() + result = add_user_to_backend_result() + try: + result.success = self._handler.add_user_to_backend( + args.backend_id, args.owner_id, args.user_id + ) + msg_type = TMessageType.REPLY + except TTransport.TTransportException: + raise + except TApplicationException as ex: + logging.exception("TApplication exception in handler") + msg_type = TMessageType.EXCEPTION + result = ex + except Exception: + logging.exception("Unexpected exception in handler") + msg_type = TMessageType.EXCEPTION + result = TApplicationException( + TApplicationException.INTERNAL_ERROR, "Internal error" + ) + oprot.writeMessageBegin("add_user_to_backend", msg_type, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + def process_get_users_from_backend(self, seqid, iprot, oprot): + args = get_users_from_backend_args() + args.read(iprot) + iprot.readMessageEnd() + result = get_users_from_backend_result() + try: + result.success = self._handler.get_users_from_backend(args.backend_id) + msg_type = TMessageType.REPLY + except TTransport.TTransportException: + raise + except TApplicationException as ex: + logging.exception("TApplication exception in handler") + msg_type = TMessageType.EXCEPTION + result = ex + except Exception: + logging.exception("Unexpected exception in handler") + msg_type = TMessageType.EXCEPTION + result = TApplicationException( + TApplicationException.INTERNAL_ERROR, "Internal error" + ) + oprot.writeMessageBegin("get_users_from_backend", msg_type, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + def process_delete_user_from_backend(self, seqid, iprot, oprot): + args = delete_user_from_backend_args() + args.read(iprot) + iprot.readMessageEnd() + result = delete_user_from_backend_result() + try: + result.success = self._handler.delete_user_from_backend( + args.backend_id, args.owner_id, args.user_id + ) + msg_type = TMessageType.REPLY + except TTransport.TTransportException: + raise + except TApplicationException as ex: + logging.exception("TApplication exception in handler") + msg_type = TMessageType.EXCEPTION + result = ex + except Exception: + logging.exception("Unexpected exception in handler") + msg_type = TMessageType.EXCEPTION + result = TApplicationException( + TApplicationException.INTERNAL_ERROR, "Internal error" + ) + oprot.writeMessageBegin("delete_user_from_backend", msg_type, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + def process_get_templates(self, seqid, iprot, oprot): args = get_templates_args() args.read(iprot) @@ -12079,7 +12324,22 @@ def __ne__(self, other): delete_backend_result.thrift_spec = ((0, TType.STRING, "success", "UTF8", None,),) # 0 -class get_templates_args(object): +class add_user_to_backend_args(object): + """ + Attributes: + - backend_id + - owner_id + - user_id + + """ + + def __init__( + self, backend_id=None, owner_id=None, user_id=None, + ): + self.backend_id = backend_id + self.owner_id = owner_id + self.user_id = user_id + def read(self, iprot): if ( iprot._fast_decode is not None @@ -12093,6 +12353,29 @@ def read(self, iprot): (fname, ftype, fid) = iprot.readFieldBegin() if ftype == TType.STOP: break + if fid == 1: + if ftype == TType.I64: + self.backend_id = iprot.readI64() + else: + iprot.skip(ftype) + elif fid == 2: + if ftype == TType.STRING: + self.owner_id = ( + iprot.readString().decode("utf-8") + if sys.version_info[0] == 2 + else iprot.readString() + ) + else: + iprot.skip(ftype) + elif fid == 3: + if ftype == TType.STRING: + self.user_id = ( + iprot.readString().decode("utf-8") + if sys.version_info[0] == 2 + else iprot.readString() + ) + else: + iprot.skip(ftype) else: iprot.skip(ftype) iprot.readFieldEnd() @@ -12104,7 +12387,27 @@ def write(self, oprot): oprot._fast_encode(self, [self.__class__, self.thrift_spec]) ) return - oprot.writeStructBegin("get_templates_args") + oprot.writeStructBegin("add_user_to_backend_args") + if self.backend_id is not None: + oprot.writeFieldBegin("backend_id", TType.I64, 1) + oprot.writeI64(self.backend_id) + oprot.writeFieldEnd() + if self.owner_id is not None: + oprot.writeFieldBegin("owner_id", TType.STRING, 2) + oprot.writeString( + self.owner_id.encode("utf-8") + if sys.version_info[0] == 2 + else self.owner_id + ) + oprot.writeFieldEnd() + if self.user_id is not None: + oprot.writeFieldBegin("user_id", TType.STRING, 3) + oprot.writeString( + self.user_id.encode("utf-8") + if sys.version_info[0] == 2 + else self.user_id + ) + oprot.writeFieldEnd() oprot.writeFieldStop() oprot.writeStructEnd() @@ -12122,11 +12425,16 @@ def __ne__(self, other): return not (self == other) -all_structs.append(get_templates_args) -get_templates_args.thrift_spec = () +all_structs.append(add_user_to_backend_args) +add_user_to_backend_args.thrift_spec = ( + None, # 0 + (1, TType.I64, "backend_id", None, None,), # 1 + (2, TType.STRING, "owner_id", "UTF8", None,), # 2 + (3, TType.STRING, "user_id", "UTF8", None,), # 3 +) -class get_templates_result(object): +class add_user_to_backend_result(object): """ Attributes: - success @@ -12152,27 +12460,22 @@ def read(self, iprot): if ftype == TType.STOP: break if fid == 0: - if ftype == TType.LIST: - self.success = [] - (_etype364, _size361) = iprot.readListBegin() + if ftype == TType.MAP: + self.success = {} + (_ktype362, _vtype363, _size361) = iprot.readMapBegin() for _i365 in range(_size361): - _elem366 = {} - (_ktype368, _vtype369, _size367) = iprot.readMapBegin() - for _i371 in range(_size367): - _key372 = ( - iprot.readString().decode("utf-8") - if sys.version_info[0] == 2 - else iprot.readString() - ) - _val373 = ( - iprot.readString().decode("utf-8") - if sys.version_info[0] == 2 - else iprot.readString() - ) - _elem366[_key372] = _val373 - iprot.readMapEnd() - self.success.append(_elem366) - iprot.readListEnd() + _key366 = ( + iprot.readString().decode("utf-8") + if sys.version_info[0] == 2 + else iprot.readString() + ) + _val367 = ( + iprot.readString().decode("utf-8") + if sys.version_info[0] == 2 + else iprot.readString() + ) + self.success[_key366] = _val367 + iprot.readMapEnd() else: iprot.skip(ftype) else: @@ -12186,25 +12489,18 @@ def write(self, oprot): oprot._fast_encode(self, [self.__class__, self.thrift_spec]) ) return - oprot.writeStructBegin("get_templates_result") + oprot.writeStructBegin("add_user_to_backend_result") if self.success is not None: - oprot.writeFieldBegin("success", TType.LIST, 0) - oprot.writeListBegin(TType.MAP, len(self.success)) - for iter374 in self.success: - oprot.writeMapBegin(TType.STRING, TType.STRING, len(iter374)) - for kiter375, viter376 in iter374.items(): - oprot.writeString( - kiter375.encode("utf-8") - if sys.version_info[0] == 2 - else kiter375 - ) - oprot.writeString( - viter376.encode("utf-8") - if sys.version_info[0] == 2 - else viter376 - ) - oprot.writeMapEnd() - oprot.writeListEnd() + oprot.writeFieldBegin("success", TType.MAP, 0) + oprot.writeMapBegin(TType.STRING, TType.STRING, len(self.success)) + for kiter368, viter369 in self.success.items(): + oprot.writeString( + kiter368.encode("utf-8") if sys.version_info[0] == 2 else kiter368 + ) + oprot.writeString( + viter369.encode("utf-8") if sys.version_info[0] == 2 else viter369 + ) + oprot.writeMapEnd() oprot.writeFieldEnd() oprot.writeFieldStop() oprot.writeStructEnd() @@ -12223,13 +12519,529 @@ def __ne__(self, other): return not (self == other) -all_structs.append(get_templates_result) -get_templates_result.thrift_spec = ( +all_structs.append(add_user_to_backend_result) +add_user_to_backend_result.thrift_spec = ( ( 0, - TType.LIST, + TType.MAP, "success", - (TType.MAP, (TType.STRING, "UTF8", TType.STRING, "UTF8", False), False), + (TType.STRING, "UTF8", TType.STRING, "UTF8", False), + None, + ), # 0 +) + + +class get_users_from_backend_args(object): + """ + Attributes: + - backend_id + + """ + + def __init__( + self, backend_id=None, + ): + self.backend_id = backend_id + + def read(self, iprot): + if ( + iprot._fast_decode is not None + and isinstance(iprot.trans, TTransport.CReadableTransport) + and self.thrift_spec is not None + ): + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.I64: + self.backend_id = iprot.readI64() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write( + oprot._fast_encode(self, [self.__class__, self.thrift_spec]) + ) + return + oprot.writeStructBegin("get_users_from_backend_args") + if self.backend_id is not None: + oprot.writeFieldBegin("backend_id", TType.I64, 1) + oprot.writeI64(self.backend_id) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] + return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) + + +all_structs.append(get_users_from_backend_args) +get_users_from_backend_args.thrift_spec = ( + None, # 0 + (1, TType.I64, "backend_id", None, None,), # 1 +) + + +class get_users_from_backend_result(object): + """ + Attributes: + - success + + """ + + def __init__( + self, success=None, + ): + self.success = success + + def read(self, iprot): + if ( + iprot._fast_decode is not None + and isinstance(iprot.trans, TTransport.CReadableTransport) + and self.thrift_spec is not None + ): + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 0: + if ftype == TType.LIST: + self.success = [] + (_etype373, _size370) = iprot.readListBegin() + for _i374 in range(_size370): + _elem375 = ( + iprot.readString().decode("utf-8") + if sys.version_info[0] == 2 + else iprot.readString() + ) + self.success.append(_elem375) + iprot.readListEnd() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write( + oprot._fast_encode(self, [self.__class__, self.thrift_spec]) + ) + return + oprot.writeStructBegin("get_users_from_backend_result") + if self.success is not None: + oprot.writeFieldBegin("success", TType.LIST, 0) + oprot.writeListBegin(TType.STRING, len(self.success)) + for iter376 in self.success: + oprot.writeString( + iter376.encode("utf-8") if sys.version_info[0] == 2 else iter376 + ) + oprot.writeListEnd() + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] + return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) + + +all_structs.append(get_users_from_backend_result) +get_users_from_backend_result.thrift_spec = ( + (0, TType.LIST, "success", (TType.STRING, "UTF8", False), None,), # 0 +) + + +class delete_user_from_backend_args(object): + """ + Attributes: + - backend_id + - owner_id + - user_id + + """ + + def __init__( + self, backend_id=None, owner_id=None, user_id=None, + ): + self.backend_id = backend_id + self.owner_id = owner_id + self.user_id = user_id + + def read(self, iprot): + if ( + iprot._fast_decode is not None + and isinstance(iprot.trans, TTransport.CReadableTransport) + and self.thrift_spec is not None + ): + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.I64: + self.backend_id = iprot.readI64() + else: + iprot.skip(ftype) + elif fid == 2: + if ftype == TType.STRING: + self.owner_id = ( + iprot.readString().decode("utf-8") + if sys.version_info[0] == 2 + else iprot.readString() + ) + else: + iprot.skip(ftype) + elif fid == 3: + if ftype == TType.STRING: + self.user_id = ( + iprot.readString().decode("utf-8") + if sys.version_info[0] == 2 + else iprot.readString() + ) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write( + oprot._fast_encode(self, [self.__class__, self.thrift_spec]) + ) + return + oprot.writeStructBegin("delete_user_from_backend_args") + if self.backend_id is not None: + oprot.writeFieldBegin("backend_id", TType.I64, 1) + oprot.writeI64(self.backend_id) + oprot.writeFieldEnd() + if self.owner_id is not None: + oprot.writeFieldBegin("owner_id", TType.STRING, 2) + oprot.writeString( + self.owner_id.encode("utf-8") + if sys.version_info[0] == 2 + else self.owner_id + ) + oprot.writeFieldEnd() + if self.user_id is not None: + oprot.writeFieldBegin("user_id", TType.STRING, 3) + oprot.writeString( + self.user_id.encode("utf-8") + if sys.version_info[0] == 2 + else self.user_id + ) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] + return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) + + +all_structs.append(delete_user_from_backend_args) +delete_user_from_backend_args.thrift_spec = ( + None, # 0 + (1, TType.I64, "backend_id", None, None,), # 1 + (2, TType.STRING, "owner_id", "UTF8", None,), # 2 + (3, TType.STRING, "user_id", "UTF8", None,), # 3 +) + + +class delete_user_from_backend_result(object): + """ + Attributes: + - success + + """ + + def __init__( + self, success=None, + ): + self.success = success + + def read(self, iprot): + if ( + iprot._fast_decode is not None + and isinstance(iprot.trans, TTransport.CReadableTransport) + and self.thrift_spec is not None + ): + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 0: + if ftype == TType.MAP: + self.success = {} + (_ktype378, _vtype379, _size377) = iprot.readMapBegin() + for _i381 in range(_size377): + _key382 = ( + iprot.readString().decode("utf-8") + if sys.version_info[0] == 2 + else iprot.readString() + ) + _val383 = ( + iprot.readString().decode("utf-8") + if sys.version_info[0] == 2 + else iprot.readString() + ) + self.success[_key382] = _val383 + iprot.readMapEnd() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write( + oprot._fast_encode(self, [self.__class__, self.thrift_spec]) + ) + return + oprot.writeStructBegin("delete_user_from_backend_result") + if self.success is not None: + oprot.writeFieldBegin("success", TType.MAP, 0) + oprot.writeMapBegin(TType.STRING, TType.STRING, len(self.success)) + for kiter384, viter385 in self.success.items(): + oprot.writeString( + kiter384.encode("utf-8") if sys.version_info[0] == 2 else kiter384 + ) + oprot.writeString( + viter385.encode("utf-8") if sys.version_info[0] == 2 else viter385 + ) + oprot.writeMapEnd() + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] + return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) + + +all_structs.append(delete_user_from_backend_result) +delete_user_from_backend_result.thrift_spec = ( + ( + 0, + TType.MAP, + "success", + (TType.STRING, "UTF8", TType.STRING, "UTF8", False), + None, + ), # 0 +) + + +class get_templates_args(object): + def read(self, iprot): + if ( + iprot._fast_decode is not None + and isinstance(iprot.trans, TTransport.CReadableTransport) + and self.thrift_spec is not None + ): + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write( + oprot._fast_encode(self, [self.__class__, self.thrift_spec]) + ) + return + oprot.writeStructBegin("get_templates_args") + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] + return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) + + +all_structs.append(get_templates_args) +get_templates_args.thrift_spec = () + + +class get_templates_result(object): + """ + Attributes: + - success + + """ + + def __init__( + self, success=None, + ): + self.success = success + + def read(self, iprot): + if ( + iprot._fast_decode is not None + and isinstance(iprot.trans, TTransport.CReadableTransport) + and self.thrift_spec is not None + ): + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 0: + if ftype == TType.LIST: + self.success = [] + (_etype389, _size386) = iprot.readListBegin() + for _i390 in range(_size386): + _elem391 = {} + (_ktype393, _vtype394, _size392) = iprot.readMapBegin() + for _i396 in range(_size392): + _key397 = ( + iprot.readString().decode("utf-8") + if sys.version_info[0] == 2 + else iprot.readString() + ) + _val398 = ( + iprot.readString().decode("utf-8") + if sys.version_info[0] == 2 + else iprot.readString() + ) + _elem391[_key397] = _val398 + iprot.readMapEnd() + self.success.append(_elem391) + iprot.readListEnd() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write( + oprot._fast_encode(self, [self.__class__, self.thrift_spec]) + ) + return + oprot.writeStructBegin("get_templates_result") + if self.success is not None: + oprot.writeFieldBegin("success", TType.LIST, 0) + oprot.writeListBegin(TType.MAP, len(self.success)) + for iter399 in self.success: + oprot.writeMapBegin(TType.STRING, TType.STRING, len(iter399)) + for kiter400, viter401 in iter399.items(): + oprot.writeString( + kiter400.encode("utf-8") + if sys.version_info[0] == 2 + else kiter400 + ) + oprot.writeString( + viter401.encode("utf-8") + if sys.version_info[0] == 2 + else viter401 + ) + oprot.writeMapEnd() + oprot.writeListEnd() + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] + return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) + + +all_structs.append(get_templates_result) +get_templates_result.thrift_spec = ( + ( + 0, + TType.LIST, + "success", + (TType.MAP, (TType.STRING, "UTF8", TType.STRING, "UTF8", False), False), None, ), # 0 ) @@ -12310,14 +13122,14 @@ def read(self, iprot): if fid == 0: if ftype == TType.LIST: self.success = [] - (_etype380, _size377) = iprot.readListBegin() - for _i381 in range(_size377): - _elem382 = ( + (_etype405, _size402) = iprot.readListBegin() + for _i406 in range(_size402): + _elem407 = ( iprot.readString().decode("utf-8") if sys.version_info[0] == 2 else iprot.readString() ) - self.success.append(_elem382) + self.success.append(_elem407) iprot.readListEnd() else: iprot.skip(ftype) @@ -12336,9 +13148,9 @@ def write(self, oprot): if self.success is not None: oprot.writeFieldBegin("success", TType.LIST, 0) oprot.writeListBegin(TType.STRING, len(self.success)) - for iter383 in self.success: + for iter408 in self.success: oprot.writeString( - iter383.encode("utf-8") if sys.version_info[0] == 2 else iter383 + iter408.encode("utf-8") if sys.version_info[0] == 2 else iter408 ) oprot.writeListEnd() oprot.writeFieldEnd() @@ -12471,24 +13283,24 @@ def read(self, iprot): if fid == 0: if ftype == TType.LIST: self.success = [] - (_etype387, _size384) = iprot.readListBegin() - for _i388 in range(_size384): - _elem389 = {} - (_ktype391, _vtype392, _size390) = iprot.readMapBegin() - for _i394 in range(_size390): - _key395 = ( + (_etype412, _size409) = iprot.readListBegin() + for _i413 in range(_size409): + _elem414 = {} + (_ktype416, _vtype417, _size415) = iprot.readMapBegin() + for _i419 in range(_size415): + _key420 = ( iprot.readString().decode("utf-8") if sys.version_info[0] == 2 else iprot.readString() ) - _val396 = ( + _val421 = ( iprot.readString().decode("utf-8") if sys.version_info[0] == 2 else iprot.readString() ) - _elem389[_key395] = _val396 + _elem414[_key420] = _val421 iprot.readMapEnd() - self.success.append(_elem389) + self.success.append(_elem414) iprot.readListEnd() else: iprot.skip(ftype) @@ -12507,18 +13319,18 @@ def write(self, oprot): if self.success is not None: oprot.writeFieldBegin("success", TType.LIST, 0) oprot.writeListBegin(TType.MAP, len(self.success)) - for iter397 in self.success: - oprot.writeMapBegin(TType.STRING, TType.STRING, len(iter397)) - for kiter398, viter399 in iter397.items(): + for iter422 in self.success: + oprot.writeMapBegin(TType.STRING, TType.STRING, len(iter422)) + for kiter423, viter424 in iter422.items(): oprot.writeString( - kiter398.encode("utf-8") + kiter423.encode("utf-8") if sys.version_info[0] == 2 - else kiter398 + else kiter423 ) oprot.writeString( - viter399.encode("utf-8") + viter424.encode("utf-8") if sys.version_info[0] == 2 - else viter399 + else viter424 ) oprot.writeMapEnd() oprot.writeListEnd() @@ -12678,19 +13490,19 @@ def read(self, iprot): if fid == 0: if ftype == TType.MAP: self.success = {} - (_ktype401, _vtype402, _size400) = iprot.readMapBegin() - for _i404 in range(_size400): - _key405 = ( + (_ktype426, _vtype427, _size425) = iprot.readMapBegin() + for _i429 in range(_size425): + _key430 = ( iprot.readString().decode("utf-8") if sys.version_info[0] == 2 else iprot.readString() ) - _val406 = ( + _val431 = ( iprot.readString().decode("utf-8") if sys.version_info[0] == 2 else iprot.readString() ) - self.success[_key405] = _val406 + self.success[_key430] = _val431 iprot.readMapEnd() else: iprot.skip(ftype) @@ -12709,12 +13521,12 @@ def write(self, oprot): if self.success is not None: oprot.writeFieldBegin("success", TType.MAP, 0) oprot.writeMapBegin(TType.STRING, TType.STRING, len(self.success)) - for kiter407, viter408 in self.success.items(): + for kiter432, viter433 in self.success.items(): oprot.writeString( - kiter407.encode("utf-8") if sys.version_info[0] == 2 else kiter407 + kiter432.encode("utf-8") if sys.version_info[0] == 2 else kiter432 ) oprot.writeString( - viter408.encode("utf-8") if sys.version_info[0] == 2 else viter408 + viter433.encode("utf-8") if sys.version_info[0] == 2 else viter433 ) oprot.writeMapEnd() oprot.writeFieldEnd() @@ -12995,11 +13807,11 @@ def read(self, iprot): if fid == 0: if ftype == TType.LIST: self.success = [] - (_etype412, _size409) = iprot.readListBegin() - for _i413 in range(_size409): - _elem414 = VM() - _elem414.read(iprot) - self.success.append(_elem414) + (_etype437, _size434) = iprot.readListBegin() + for _i438 in range(_size434): + _elem439 = VM() + _elem439.read(iprot) + self.success.append(_elem439) iprot.readListEnd() else: iprot.skip(ftype) @@ -13018,8 +13830,8 @@ def write(self, oprot): if self.success is not None: oprot.writeFieldBegin("success", TType.LIST, 0) oprot.writeListBegin(TType.STRUCT, len(self.success)) - for iter415 in self.success: - iter415.write(oprot) + for iter440 in self.success: + iter440.write(oprot) oprot.writeListEnd() oprot.writeFieldEnd() oprot.writeFieldStop() @@ -13073,14 +13885,14 @@ def read(self, iprot): if fid == 1: if ftype == TType.LIST: self.server_ids = [] - (_etype419, _size416) = iprot.readListBegin() - for _i420 in range(_size416): - _elem421 = ( + (_etype444, _size441) = iprot.readListBegin() + for _i445 in range(_size441): + _elem446 = ( iprot.readString().decode("utf-8") if sys.version_info[0] == 2 else iprot.readString() ) - self.server_ids.append(_elem421) + self.server_ids.append(_elem446) iprot.readListEnd() else: iprot.skip(ftype) @@ -13099,9 +13911,9 @@ def write(self, oprot): if self.server_ids is not None: oprot.writeFieldBegin("server_ids", TType.LIST, 1) oprot.writeListBegin(TType.STRING, len(self.server_ids)) - for iter422 in self.server_ids: + for iter447 in self.server_ids: oprot.writeString( - iter422.encode("utf-8") if sys.version_info[0] == 2 else iter422 + iter447.encode("utf-8") if sys.version_info[0] == 2 else iter447 ) oprot.writeListEnd() oprot.writeFieldEnd() @@ -13157,11 +13969,11 @@ def read(self, iprot): if fid == 0: if ftype == TType.LIST: self.success = [] - (_etype426, _size423) = iprot.readListBegin() - for _i427 in range(_size423): - _elem428 = VM() - _elem428.read(iprot) - self.success.append(_elem428) + (_etype451, _size448) = iprot.readListBegin() + for _i452 in range(_size448): + _elem453 = VM() + _elem453.read(iprot) + self.success.append(_elem453) iprot.readListEnd() else: iprot.skip(ftype) @@ -13180,8 +13992,8 @@ def write(self, oprot): if self.success is not None: oprot.writeFieldBegin("success", TType.LIST, 0) oprot.writeListBegin(TType.STRUCT, len(self.success)) - for iter429 in self.success: - iter429.write(oprot) + for iter454 in self.success: + iter454.write(oprot) oprot.writeListEnd() oprot.writeFieldEnd() oprot.writeFieldStop() @@ -13313,11 +14125,11 @@ def read(self, iprot): if fid == 0: if ftype == TType.LIST: self.success = [] - (_etype433, _size430) = iprot.readListBegin() - for _i434 in range(_size430): - _elem435 = VM() - _elem435.read(iprot) - self.success.append(_elem435) + (_etype458, _size455) = iprot.readListBegin() + for _i459 in range(_size455): + _elem460 = VM() + _elem460.read(iprot) + self.success.append(_elem460) iprot.readListEnd() else: iprot.skip(ftype) @@ -13336,8 +14148,8 @@ def write(self, oprot): if self.success is not None: oprot.writeFieldBegin("success", TType.LIST, 0) oprot.writeListBegin(TType.STRUCT, len(self.success)) - for iter436 in self.success: - iter436.write(oprot) + for iter461 in self.success: + iter461.write(oprot) oprot.writeListEnd() oprot.writeFieldEnd() oprot.writeFieldStop() @@ -13617,19 +14429,19 @@ def read(self, iprot): if fid == 0: if ftype == TType.MAP: self.success = {} - (_ktype438, _vtype439, _size437) = iprot.readMapBegin() - for _i441 in range(_size437): - _key442 = ( + (_ktype463, _vtype464, _size462) = iprot.readMapBegin() + for _i466 in range(_size462): + _key467 = ( iprot.readString().decode("utf-8") if sys.version_info[0] == 2 else iprot.readString() ) - _val443 = ( + _val468 = ( iprot.readString().decode("utf-8") if sys.version_info[0] == 2 else iprot.readString() ) - self.success[_key442] = _val443 + self.success[_key467] = _val468 iprot.readMapEnd() else: iprot.skip(ftype) @@ -13648,12 +14460,12 @@ def write(self, oprot): if self.success is not None: oprot.writeFieldBegin("success", TType.MAP, 0) oprot.writeMapBegin(TType.STRING, TType.STRING, len(self.success)) - for kiter444, viter445 in self.success.items(): + for kiter469, viter470 in self.success.items(): oprot.writeString( - kiter444.encode("utf-8") if sys.version_info[0] == 2 else kiter444 + kiter469.encode("utf-8") if sys.version_info[0] == 2 else kiter469 ) oprot.writeString( - viter445.encode("utf-8") if sys.version_info[0] == 2 else viter445 + viter470.encode("utf-8") if sys.version_info[0] == 2 else viter470 ) oprot.writeMapEnd() oprot.writeFieldEnd() @@ -14075,14 +14887,14 @@ def read(self, iprot): elif fid == 4: if ftype == TType.LIST: self.base_tags = [] - (_etype449, _size446) = iprot.readListBegin() - for _i450 in range(_size446): - _elem451 = ( + (_etype474, _size471) = iprot.readListBegin() + for _i475 in range(_size471): + _elem476 = ( iprot.readString().decode("utf-8") if sys.version_info[0] == 2 else iprot.readString() ) - self.base_tags.append(_elem451) + self.base_tags.append(_elem476) iprot.readListEnd() else: iprot.skip(ftype) @@ -14132,9 +14944,9 @@ def write(self, oprot): if self.base_tags is not None: oprot.writeFieldBegin("base_tags", TType.LIST, 4) oprot.writeListBegin(TType.STRING, len(self.base_tags)) - for iter452 in self.base_tags: + for iter477 in self.base_tags: oprot.writeString( - iter452.encode("utf-8") if sys.version_info[0] == 2 else iter452 + iter477.encode("utf-8") if sys.version_info[0] == 2 else iter477 ) oprot.writeListEnd() oprot.writeFieldEnd() @@ -14339,19 +15151,19 @@ def read(self, iprot): if fid == 0: if ftype == TType.MAP: self.success = {} - (_ktype454, _vtype455, _size453) = iprot.readMapBegin() - for _i457 in range(_size453): - _key458 = ( + (_ktype479, _vtype480, _size478) = iprot.readMapBegin() + for _i482 in range(_size478): + _key483 = ( iprot.readString().decode("utf-8") if sys.version_info[0] == 2 else iprot.readString() ) - _val459 = ( + _val484 = ( iprot.readString().decode("utf-8") if sys.version_info[0] == 2 else iprot.readString() ) - self.success[_key458] = _val459 + self.success[_key483] = _val484 iprot.readMapEnd() else: iprot.skip(ftype) @@ -14370,12 +15182,12 @@ def write(self, oprot): if self.success is not None: oprot.writeFieldBegin("success", TType.MAP, 0) oprot.writeMapBegin(TType.STRING, TType.STRING, len(self.success)) - for kiter460, viter461 in self.success.items(): + for kiter485, viter486 in self.success.items(): oprot.writeString( - kiter460.encode("utf-8") if sys.version_info[0] == 2 else kiter460 + kiter485.encode("utf-8") if sys.version_info[0] == 2 else kiter485 ) oprot.writeString( - viter461.encode("utf-8") if sys.version_info[0] == 2 else viter461 + viter486.encode("utf-8") if sys.version_info[0] == 2 else viter486 ) oprot.writeMapEnd() oprot.writeFieldEnd() @@ -14457,11 +15269,11 @@ def read(self, iprot): elif fid == 3: if ftype == TType.LIST: self.worker_instance = [] - (_etype465, _size462) = iprot.readListBegin() - for _i466 in range(_size462): - _elem467 = ClusterInstance() - _elem467.read(iprot) - self.worker_instance.append(_elem467) + (_etype490, _size487) = iprot.readListBegin() + for _i491 in range(_size487): + _elem492 = ClusterInstance() + _elem492.read(iprot) + self.worker_instance.append(_elem492) iprot.readListEnd() else: iprot.skip(ftype) @@ -14501,8 +15313,8 @@ def write(self, oprot): if self.worker_instance is not None: oprot.writeFieldBegin("worker_instance", TType.LIST, 3) oprot.writeListBegin(TType.STRUCT, len(self.worker_instance)) - for iter468 in self.worker_instance: - iter468.write(oprot) + for iter493 in self.worker_instance: + iter493.write(oprot) oprot.writeListEnd() oprot.writeFieldEnd() if self.user is not None: @@ -14572,19 +15384,19 @@ def read(self, iprot): if fid == 0: if ftype == TType.MAP: self.success = {} - (_ktype470, _vtype471, _size469) = iprot.readMapBegin() - for _i473 in range(_size469): - _key474 = ( + (_ktype495, _vtype496, _size494) = iprot.readMapBegin() + for _i498 in range(_size494): + _key499 = ( iprot.readString().decode("utf-8") if sys.version_info[0] == 2 else iprot.readString() ) - _val475 = ( + _val500 = ( iprot.readString().decode("utf-8") if sys.version_info[0] == 2 else iprot.readString() ) - self.success[_key474] = _val475 + self.success[_key499] = _val500 iprot.readMapEnd() else: iprot.skip(ftype) @@ -14603,12 +15415,12 @@ def write(self, oprot): if self.success is not None: oprot.writeFieldBegin("success", TType.MAP, 0) oprot.writeMapBegin(TType.STRING, TType.STRING, len(self.success)) - for kiter476, viter477 in self.success.items(): + for kiter501, viter502 in self.success.items(): oprot.writeString( - kiter476.encode("utf-8") if sys.version_info[0] == 2 else kiter476 + kiter501.encode("utf-8") if sys.version_info[0] == 2 else kiter501 ) oprot.writeString( - viter477.encode("utf-8") if sys.version_info[0] == 2 else viter477 + viter502.encode("utf-8") if sys.version_info[0] == 2 else viter502 ) oprot.writeMapEnd() oprot.writeFieldEnd() @@ -14747,19 +15559,19 @@ def read(self, iprot): if fid == 0: if ftype == TType.MAP: self.success = {} - (_ktype479, _vtype480, _size478) = iprot.readMapBegin() - for _i482 in range(_size478): - _key483 = ( + (_ktype504, _vtype505, _size503) = iprot.readMapBegin() + for _i507 in range(_size503): + _key508 = ( iprot.readString().decode("utf-8") if sys.version_info[0] == 2 else iprot.readString() ) - _val484 = ( + _val509 = ( iprot.readString().decode("utf-8") if sys.version_info[0] == 2 else iprot.readString() ) - self.success[_key483] = _val484 + self.success[_key508] = _val509 iprot.readMapEnd() else: iprot.skip(ftype) @@ -14778,12 +15590,12 @@ def write(self, oprot): if self.success is not None: oprot.writeFieldBegin("success", TType.MAP, 0) oprot.writeMapBegin(TType.STRING, TType.STRING, len(self.success)) - for kiter485, viter486 in self.success.items(): + for kiter510, viter511 in self.success.items(): oprot.writeString( - kiter485.encode("utf-8") if sys.version_info[0] == 2 else kiter485 + kiter510.encode("utf-8") if sys.version_info[0] == 2 else kiter510 ) oprot.writeString( - viter486.encode("utf-8") if sys.version_info[0] == 2 else viter486 + viter511.encode("utf-8") if sys.version_info[0] == 2 else viter511 ) oprot.writeMapEnd() oprot.writeFieldEnd() @@ -15429,19 +16241,19 @@ def read(self, iprot): if fid == 0: if ftype == TType.MAP: self.success = {} - (_ktype488, _vtype489, _size487) = iprot.readMapBegin() - for _i491 in range(_size487): - _key492 = ( + (_ktype513, _vtype514, _size512) = iprot.readMapBegin() + for _i516 in range(_size512): + _key517 = ( iprot.readString().decode("utf-8") if sys.version_info[0] == 2 else iprot.readString() ) - _val493 = ( + _val518 = ( iprot.readString().decode("utf-8") if sys.version_info[0] == 2 else iprot.readString() ) - self.success[_key492] = _val493 + self.success[_key517] = _val518 iprot.readMapEnd() else: iprot.skip(ftype) @@ -15466,12 +16278,12 @@ def write(self, oprot): if self.success is not None: oprot.writeFieldBegin("success", TType.MAP, 0) oprot.writeMapBegin(TType.STRING, TType.STRING, len(self.success)) - for kiter494, viter495 in self.success.items(): + for kiter519, viter520 in self.success.items(): oprot.writeString( - kiter494.encode("utf-8") if sys.version_info[0] == 2 else kiter494 + kiter519.encode("utf-8") if sys.version_info[0] == 2 else kiter519 ) oprot.writeString( - viter495.encode("utf-8") if sys.version_info[0] == 2 else viter495 + viter520.encode("utf-8") if sys.version_info[0] == 2 else viter520 ) oprot.writeMapEnd() oprot.writeFieldEnd() @@ -16075,19 +16887,19 @@ def read(self, iprot): elif fid == 3: if ftype == TType.MAP: self.metadata = {} - (_ktype497, _vtype498, _size496) = iprot.readMapBegin() - for _i500 in range(_size496): - _key501 = ( + (_ktype522, _vtype523, _size521) = iprot.readMapBegin() + for _i525 in range(_size521): + _key526 = ( iprot.readString().decode("utf-8") if sys.version_info[0] == 2 else iprot.readString() ) - _val502 = ( + _val527 = ( iprot.readString().decode("utf-8") if sys.version_info[0] == 2 else iprot.readString() ) - self.metadata[_key501] = _val502 + self.metadata[_key526] = _val527 iprot.readMapEnd() else: iprot.skip(ftype) @@ -16118,12 +16930,12 @@ def write(self, oprot): if self.metadata is not None: oprot.writeFieldBegin("metadata", TType.MAP, 3) oprot.writeMapBegin(TType.STRING, TType.STRING, len(self.metadata)) - for kiter503, viter504 in self.metadata.items(): + for kiter528, viter529 in self.metadata.items(): oprot.writeString( - kiter503.encode("utf-8") if sys.version_info[0] == 2 else kiter503 + kiter528.encode("utf-8") if sys.version_info[0] == 2 else kiter528 ) oprot.writeString( - viter504.encode("utf-8") if sys.version_info[0] == 2 else viter504 + viter529.encode("utf-8") if sys.version_info[0] == 2 else viter529 ) oprot.writeMapEnd() oprot.writeFieldEnd() @@ -16189,19 +17001,19 @@ def read(self, iprot): if fid == 0: if ftype == TType.MAP: self.success = {} - (_ktype506, _vtype507, _size505) = iprot.readMapBegin() - for _i509 in range(_size505): - _key510 = ( + (_ktype531, _vtype532, _size530) = iprot.readMapBegin() + for _i534 in range(_size530): + _key535 = ( iprot.readString().decode("utf-8") if sys.version_info[0] == 2 else iprot.readString() ) - _val511 = ( + _val536 = ( iprot.readString().decode("utf-8") if sys.version_info[0] == 2 else iprot.readString() ) - self.success[_key510] = _val511 + self.success[_key535] = _val536 iprot.readMapEnd() else: iprot.skip(ftype) @@ -16226,12 +17038,12 @@ def write(self, oprot): if self.success is not None: oprot.writeFieldBegin("success", TType.MAP, 0) oprot.writeMapBegin(TType.STRING, TType.STRING, len(self.success)) - for kiter512, viter513 in self.success.items(): + for kiter537, viter538 in self.success.items(): oprot.writeString( - kiter512.encode("utf-8") if sys.version_info[0] == 2 else kiter512 + kiter537.encode("utf-8") if sys.version_info[0] == 2 else kiter537 ) oprot.writeString( - viter513.encode("utf-8") if sys.version_info[0] == 2 else viter513 + viter538.encode("utf-8") if sys.version_info[0] == 2 else viter538 ) oprot.writeMapEnd() oprot.writeFieldEnd() diff --git a/VirtualMachineService/config/config.yml b/VirtualMachineService/config/config.yml index ee81794d..68d7afe6 100644 --- a/VirtualMachineService/config/config.yml +++ b/VirtualMachineService/config/config.yml @@ -30,18 +30,21 @@ openstack_connection: bibigrid: # Url for Bibigrid API - bibigrid_url: https://172.21.0.1:8443/bibigrid/ + bibigrid_url: http://bibigrid:8080/bibigrid/ sub_network: portalexternalsubnetwork bibigrid_modes: - slurm - + forc: forc_url: https://proxy-dev.bi.denbi.de:5000/ forc_allowed: theiaide: + - v02 - v01 guacamole: + - v02 - v01 rstudio: + - v03 - v02 - v01 diff --git a/docker-compose.bibigrid.yml b/docker-compose.bibigrid.yml new file mode 100644 index 00000000..d5d035e1 --- /dev/null +++ b/docker-compose.bibigrid.yml @@ -0,0 +1,74 @@ +version: '3.5' +services: + portal-client: + image: denbicloud/cloud-portal-client:${CLOUD_CLIENT_TAG} + ports: + - "9090:9090" + + env_file: + - .env + + environment: + - OS_AUTH_URL + - OS_PROJECT_ID + - OS_PROJECT_NAME + - OS_USERNAME + - OS_PASSWORD + - OS_USER_DOMAIN_NAME + - OS_PROJECT_DOMAIN_ID + - FORC_API_KEY + + volumes: + - ${client_PERSISTENT_PATH}/config.yml:/code/VirtualMachineService/config.yml + - ${client_PERSISTENT_PATH}/server.pem:/code/VirtualMachineService/keys/server.pem + - ./logs/client:/code/VirtualMachineService/log:rw + command: python3 VirtualMachineServer.py /code/VirtualMachineService/config.yml + networks: + - portal + + redis: + image: redis:5.0.5 + expose: + - "6379" + networks: + - portal + + bibigrid: + image: bibiserv/bibigrid:bibigrid_rest_http_enabled + environment: + - OS_AUTH_URL + - OS_PROJECT_ID + - OS_PROJECT_NAME + - OS_USERNAME + - OS_PASSWORD + - OS_USER_DOMAIN_NAME + - OS_PROJECT_DOMAIN_ID + expose: + - "8080" + networks: + - portal + + # filebeat + filebeat: + image: docker.elastic.co/beats/filebeat:${FILEBEAT_TAG} + environment: + - ELASTIC_USER + - ELASTIC_PASSWORD + volumes: + - ./filebeat/filebeat.yml:/usr/share/filebeat/filebeat.yml + - ./logs:/usr/share/filebeat/log:ro + - ./filebeat/data:/usr/share/filebeat/data:rw + command: [sh, -c, "chmod go-w /usr/share/filebeat/filebeat.yml && filebeat run -e"] + networks: + - portal + +networks: + portal: + name: portal_default + driver: bridge + driver_opts: + com.docker.network.driver.mtu: 1440 + default: + driver: bridge + driver_opts: + com.docker.network.driver.mtu: 1440 diff --git a/docker-compose.dev.bibigrid.yml b/docker-compose.dev.bibigrid.yml new file mode 100644 index 00000000..38e5df22 --- /dev/null +++ b/docker-compose.dev.bibigrid.yml @@ -0,0 +1,63 @@ +version: '3.5' +services: + portal-client: + build: + context: . + dockerfile: Dockerfile + ports: + - "9090:9090" + + env_file: + - .env + + environment: + - OS_AUTH_URL + - OS_PROJECT_ID + - OS_PROJECT_NAME + - OS_USERNAME + - OS_PASSWORD + - OS_USER_DOMAIN_NAME + - OS_PROJECT_DOMAIN_ID + - FORC_API_KEY + + volumes: + - ./VirtualMachineService/config/config.yml:/code/VirtualMachineService/config.yml + - ./VirtualMachineService/keys/localhost/server.pem:/code/VirtualMachineService/keys/server.pem + command: python3 VirtualMachineServer.py /code/VirtualMachineService/config.yml + networks: + - portal + + redis: + image: redis:5.0.5 + expose: + - "6379" + networks: + - portal + + bibigrid: + image: bibiserv/bibigrid:bibigrid_rest_http_enabled + environment: + - OS_AUTH_URL + - OS_PROJECT_ID + - OS_PROJECT_NAME + - OS_USERNAME + - OS_PASSWORD + - OS_USER_DOMAIN_NAME + - OS_PROJECT_DOMAIN_ID + expose: + - "8080" + networks: + - portal + + + +networks: + portal: + name: portal_default + driver: bridge + driver_opts: + com.docker.network.driver.mtu: 1440 + default: + driver: bridge + driver_opts: + com.docker.network.driver.mtu: 1440 diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index 2ab95dae..f3bc2e42 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -6,7 +6,7 @@ services: dockerfile: Dockerfile ports: - "9090:9090" - + env_file: - .env @@ -34,29 +34,14 @@ services: networks: - portal - # filebeat - filebeat: - image: docker.elastic.co/beats/filebeat:${FILEBEAT_TAG} - environment: - - ELASTIC_USER - - ELASTIC_PASSWORD - volumes: - - ./filebeat/filebeat.yml:/usr/share/filebeat/filebeat.yml - - ./logs:/usr/share/filebeat/log:ro - - ./filebeat/data:/usr/share/filebeat/data:rw - command: [sh, -c, "chmod go-w /usr/share/filebeat/filebeat.yml && filebeat run -e"] - networks: - - portal - - networks: portal: name: portal_default - driver: bridge - driver_opts: + driver: bridge + driver_opts: com.docker.network.driver.mtu: 1440 - default: - driver: bridge - driver_opts: + default: + driver: bridge + driver_opts: com.docker.network.driver.mtu: 1440 diff --git a/portal_client.thrift b/portal_client.thrift index da7dc64e..9cbc93ac 100644 --- a/portal_client.thrift +++ b/portal_client.thrift @@ -521,6 +521,25 @@ service VirtualMachineService { 1:i64 id ) + /** Add a user to a backend*/ + map add_user_to_backend( + 1:i64 backend_id, + 2:string owner_id, + 3:string user_id + ) + + /** Get users from a backend*/ + list get_users_from_backend( + 1:i64 backend_id + ) + + /** Delete user from a backend*/ + map delete_user_from_backend( + 1:i64 backend_id, + 2:string owner_id, + 3:string user_id + ) + list> get_templates() list get_allowed_templates() diff --git a/requirements.txt b/requirements.txt index 6ea0a90e..7821f42e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,13 +1,13 @@ -setuptools==46.1.3 +setuptools==46.2.0 thrift >= 0.11.0,<0.20.0 python-keystoneclient openstacksdk ==0.46.0 deprecated == 1.2.9 -Click==7.1.1 +Click==7.1.2 flake8==3.7.9 -ansible==2.9.6 +ansible==2.9.7 ruamel.yaml<0.17.0 paramiko==2.7.1 pyvim==3.0.2 -redis==3.4.1 +redis==3.5.1 requests==2.23.0 diff --git a/scripts/gateway/gateway-setup-variables.yml b/scripts/gateway/gateway-setup-variables.yml new file mode 100644 index 00000000..ae4c779e --- /dev/null +++ b/scripts/gateway/gateway-setup-variables.yml @@ -0,0 +1,5 @@ +general: + REPO_PATH: /home/ubuntu/cloud-portal-client + SCRIPT_PERSISTENT_PATH: /home/ubuntu/gateway_persistent + TCP_SCRIPT_PERSISTENT_NAME: gateway_TCP.sh + UDP_SCRIPT_PERSISTENT_NAME: gateway_UDP.sh \ No newline at end of file diff --git a/scripts/gateway/gateway-setup.yml b/scripts/gateway/gateway-setup.yml new file mode 100644 index 00000000..76bcf6d6 --- /dev/null +++ b/scripts/gateway/gateway-setup.yml @@ -0,0 +1,58 @@ +- name: Setting up gateway + hosts: all + become: yes + vars_files: + - gateway-setup-variables.yml + tasks: + + - name: Create persistent gateway script directorie + file: + path: "{{ general.SCRIPT_PERSISTENT_PATH }}" + state: directory + + - name: Checkout cloud-portal-client repository + git: + repo: "git@github.com:deNBI/cloud-portal-client.git" + dest: "{{ general.REPO_PATH }}" + accept_hostkey: yes + force: yes + version: "{{ repo_version | default('master') }}" + become: no + + - name: Copy TCP script from repository + copy: + src: "{{ general.REPO_PATH }}/scripts/gateway/{{ general.TCP_SCRIPT_PERSISTENT_NAME }}" + dest: "{{ SCRIPT_PERSISTENT_PATH }}/{{ general.TCP_SCRIPT_PERSISTENT_NAME }}" + mode: 0774 + remote_src: yes + when: tcp_script_in is not defined + + - name: Copy UDP script from repository + copy: + src: "{{ general.REPO_PATH }}/scripts/gateway/{{ general.UDP_SCRIPT_PERSISTENT_NAME }}" + dest: "{{ SCRIPT_PERSISTENT_PATH }}/{{ general.UDP_SCRIPT_PERSISTENT_NAME }}" + mode: 0774 + remote_src: yes + when: udp_script_in is not defined + + - name: Copy specified TCP script + copy: + src: "{{ tcp_script_in }}" + dest: "{{ SCRIPT_PERSISTENT_PATH }}/{{ general.TCP_SCRIPT_PERSISTENT_NAME }}" + mode: 0774 + when: tcp_script_in is defined + + - name: Copy specified UDP script + copy: + src: "{{ udp_script_in }}" + dest: "{{ SCRIPT_PERSISTENT_PATH }}/{{ general.UDP_SCRIPT_PERSISTENT_NAME }}" + mode: 0774 + when: udp_script_in is defined + + - name: Run TCP script + become: yes + command: "{{ SCRIPT_PERSISTENT_PATH }}/{{ general.TCP_SCRIPT_PERSISTENT_NAME }}" + + - name: Run UDP script + become: yes + command: "{{ SCRIPT_PERSISTENT_PATH }}/{{ general.UDP_SCRIPT_PERSISTENT_NAME }}"