From c28e07ba15f0a672d275f4577445d0d761711316 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 13 Apr 2024 06:19:13 +0000 Subject: [PATCH 1/5] feat(Dependencies): Update pre-commit hook psf/black-pre-commit-mirror to v24.4.0 | datasource | package | from | to | | ----------- | --------------------------- | ------ | ------ | | github-tags | psf/black-pre-commit-mirror | 24.3.0 | 24.4.0 | --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5a448f9..acfd896 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,7 +11,7 @@ repos: - repo: https://github.com/psf/black-pre-commit-mirror - rev: 24.3.0 + rev: 24.4.0 hooks: - id: black language_version: python3.11 From 9e4f279a0766a658276b3a2d7b0c6c0b6e11297b Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 13 Apr 2024 22:39:14 +0000 Subject: [PATCH 2/5] feat(Dependencies): Update dependency setuptools to v69.5.1 | datasource | package | from | to | | ---------- | ---------- | ------ | ------ | | pypi | setuptools | 69.2.0 | 69.5.1 | --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index a65ae14..a098975 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -setuptools==69.2.0 +setuptools==69.5.1 thrift==0.20.0 python-keystoneclient==5.4.0 openstacksdk==3.0.0 From a902206a8c3e5b615bdf2b8dee289d5156e81a3d Mon Sep 17 00:00:00 2001 From: dweinholz Date: Mon, 15 Apr 2024 15:05:52 +0200 Subject: [PATCH 3/5] fix(Cluster):add default security group after starting --- portal_client.thrift | 4 +- simple_vm_client/VirtualMachineHandler.py | 9 +- simple_vm_client/VirtualMachineService-remote | 15 +- simple_vm_client/VirtualMachineService.py | 406 ++++++++++++++---- .../bibigrid_connector/bibigrid_connector.py | 4 +- .../openstack_connector.py | 18 +- 6 files changed, 364 insertions(+), 92 deletions(-) diff --git a/portal_client.thrift b/portal_client.thrift index 63cb444..30d0427 100644 --- a/portal_client.thrift +++ b/portal_client.thrift @@ -591,7 +591,7 @@ service VirtualMachineService { string get_keypair_public_key_by_name(1:string key_name) void delete_keypair(1:string key_name) - + void add_default_security_groups_to_server(1:string openstack_id) throws (1:ServerNotFoundException e) /** * Get a Server. @@ -654,7 +654,7 @@ service VirtualMachineService { */ map get_limits() - map start_cluster(1:string public_key,2: ClusterInstance master_instance,3:list worker_instances,4:string user) + map start_cluster(1:list public_keys,2: ClusterInstance master_instance,3:list worker_instances,4:string user) map terminate_cluster(1:string cluster_id) throws(1:ClusterNotFoundException c) diff --git a/simple_vm_client/VirtualMachineHandler.py b/simple_vm_client/VirtualMachineHandler.py index 9070254..4ec5936 100644 --- a/simple_vm_client/VirtualMachineHandler.py +++ b/simple_vm_client/VirtualMachineHandler.py @@ -321,6 +321,11 @@ def delete_security_group_rule(self, openstack_id): openstack_id=openstack_id ) + def add_default_security_groups_to_server(self, openstack_id): + return self.openstack_connector.add_default_security_groups_to_server( + openstack_id=openstack_id + ) + def open_port_range_for_vm_in_project( self, range_start, @@ -462,13 +467,13 @@ def get_cluster_status(self, cluster_id: str) -> dict[str, str]: def start_cluster( self, - public_key: str, + public_keys: list[str], master_instance: ClusterInstance, worker_instances: list[ClusterInstance], user: str, ) -> dict[str, str]: return self.bibigrid_connector.start_cluster( - public_key=public_key, + public_keys=public_keys, master_instance=master_instance, worker_instances=worker_instances, user=user, diff --git a/simple_vm_client/VirtualMachineService-remote b/simple_vm_client/VirtualMachineService-remote index 748b8bf..975476c 100755 --- a/simple_vm_client/VirtualMachineService-remote +++ b/simple_vm_client/VirtualMachineService-remote @@ -92,6 +92,7 @@ if len(sys.argv) <= 1 or sys.argv[1] == "--help": print(" get_cluster_status(string cluster_id)") print(" string get_keypair_public_key_by_name(string key_name)") print(" void delete_keypair(string key_name)") + print(" void add_default_security_groups_to_server(string openstack_id)") print(" VM get_server(string openstack_id)") print(" VM get_server_by_unique_name(string unique_name)") print(" void stop_server(string openstack_id)") @@ -100,7 +101,7 @@ if len(sys.argv) <= 1 or sys.argv[1] == "--help": ) print(" get_limits()") print( - " start_cluster(string public_key, ClusterInstance master_instance, worker_instances, string user)" + " start_cluster( public_keys, ClusterInstance master_instance, worker_instances, string user)" ) print(" terminate_cluster(string cluster_id)") print(" void delete_image(string image_id)") @@ -688,6 +689,16 @@ elif cmd == "delete_keypair": ) ) +elif cmd == "add_default_security_groups_to_server": + if len(args) != 1: + print("add_default_security_groups_to_server requires 1 args") + sys.exit(1) + pp.pprint( + client.add_default_security_groups_to_server( + args[0], + ) + ) + elif cmd == "get_server": if len(args) != 1: print("get_server requires 1 args") @@ -744,7 +755,7 @@ elif cmd == "start_cluster": sys.exit(1) pp.pprint( client.start_cluster( - args[0], + eval(args[0]), eval(args[1]), eval(args[2]), args[3], diff --git a/simple_vm_client/VirtualMachineService.py b/simple_vm_client/VirtualMachineService.py index 967eed5..4717f50 100644 --- a/simple_vm_client/VirtualMachineService.py +++ b/simple_vm_client/VirtualMachineService.py @@ -490,6 +490,13 @@ def delete_keypair(self, key_name): """ + def add_default_security_groups_to_server(self, openstack_id): + """ + Parameters: + - openstack_id + + """ + def get_server(self, openstack_id): """ Get a Server. @@ -541,10 +548,10 @@ def get_limits(self): """ - def start_cluster(self, public_key, master_instance, worker_instances, user): + def start_cluster(self, public_keys, master_instance, worker_instances, user): """ Parameters: - - public_key + - public_keys - master_instance - worker_instances - user @@ -2728,6 +2735,40 @@ def recv_delete_keypair(self): iprot.readMessageEnd() return + def add_default_security_groups_to_server(self, openstack_id): + """ + Parameters: + - openstack_id + + """ + self.send_add_default_security_groups_to_server(openstack_id) + self.recv_add_default_security_groups_to_server() + + def send_add_default_security_groups_to_server(self, openstack_id): + self._oprot.writeMessageBegin( + "add_default_security_groups_to_server", TMessageType.CALL, self._seqid + ) + args = add_default_security_groups_to_server_args() + args.openstack_id = openstack_id + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_add_default_security_groups_to_server(self): + iprot = self._iprot + (fname, mtype, rseqid) = iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(iprot) + iprot.readMessageEnd() + raise x + result = add_default_security_groups_to_server_result() + result.read(iprot) + iprot.readMessageEnd() + if result.e is not None: + raise result.e + return + def get_server(self, openstack_id): """ Get a Server. @@ -2931,22 +2972,22 @@ def recv_get_limits(self): TApplicationException.MISSING_RESULT, "get_limits failed: unknown result" ) - def start_cluster(self, public_key, master_instance, worker_instances, user): + def start_cluster(self, public_keys, master_instance, worker_instances, user): """ Parameters: - - public_key + - public_keys - master_instance - worker_instances - user """ - self.send_start_cluster(public_key, master_instance, worker_instances, user) + self.send_start_cluster(public_keys, master_instance, worker_instances, user) return self.recv_start_cluster() - def send_start_cluster(self, public_key, master_instance, worker_instances, user): + def send_start_cluster(self, public_keys, master_instance, worker_instances, user): self._oprot.writeMessageBegin("start_cluster", TMessageType.CALL, self._seqid) args = start_cluster_args() - args.public_key = public_key + args.public_keys = public_keys args.master_instance = master_instance args.worker_instances = worker_instances args.user = user @@ -3636,6 +3677,9 @@ def __init__(self, handler): Processor.process_get_keypair_public_key_by_name ) self._processMap["delete_keypair"] = Processor.process_delete_keypair + self._processMap["add_default_security_groups_to_server"] = ( + Processor.process_add_default_security_groups_to_server + ) self._processMap["get_server"] = Processor.process_get_server self._processMap["get_server_by_unique_name"] = ( Processor.process_get_server_by_unique_name @@ -5086,6 +5130,36 @@ def process_delete_keypair(self, seqid, iprot, oprot): oprot.writeMessageEnd() oprot.trans.flush() + def process_add_default_security_groups_to_server(self, seqid, iprot, oprot): + args = add_default_security_groups_to_server_args() + args.read(iprot) + iprot.readMessageEnd() + result = add_default_security_groups_to_server_result() + try: + self._handler.add_default_security_groups_to_server(args.openstack_id) + msg_type = TMessageType.REPLY + except TTransport.TTransportException: + raise + except ServerNotFoundException as e: + msg_type = TMessageType.REPLY + result.e = e + 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_default_security_groups_to_server", msg_type, seqid + ) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + def process_get_server(self, seqid, iprot, oprot): args = get_server_args() args.read(iprot) @@ -5242,7 +5316,7 @@ def process_start_cluster(self, seqid, iprot, oprot): result = start_cluster_result() try: result.success = self._handler.start_cluster( - args.public_key, args.master_instance, args.worker_instances, args.user + args.public_keys, args.master_instance, args.worker_instances, args.user ) msg_type = TMessageType.REPLY except TTransport.TTransportException: @@ -15411,6 +15485,168 @@ def __ne__(self, other): delete_keypair_result.thrift_spec = () +class add_default_security_groups_to_server_args(object): + """ + Attributes: + - openstack_id + + """ + + def __init__( + self, + openstack_id=None, + ): + self.openstack_id = openstack_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.STRING: + self.openstack_id = ( + iprot.readString().decode("utf-8", errors="replace") + 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("add_default_security_groups_to_server_args") + if self.openstack_id is not None: + oprot.writeFieldBegin("openstack_id", TType.STRING, 1) + oprot.writeString( + self.openstack_id.encode("utf-8") + if sys.version_info[0] == 2 + else self.openstack_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(add_default_security_groups_to_server_args) +add_default_security_groups_to_server_args.thrift_spec = ( + None, # 0 + ( + 1, + TType.STRING, + "openstack_id", + "UTF8", + None, + ), # 1 +) + + +class add_default_security_groups_to_server_result(object): + """ + Attributes: + - e + + """ + + def __init__( + self, + e=None, + ): + self.e = e + + 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.STRUCT: + self.e = ServerNotFoundException.read(iprot) + 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("add_default_security_groups_to_server_result") + if self.e is not None: + oprot.writeFieldBegin("e", TType.STRUCT, 1) + self.e.write(oprot) + 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(add_default_security_groups_to_server_result) +add_default_security_groups_to_server_result.thrift_spec = ( + None, # 0 + ( + 1, + TType.STRUCT, + "e", + [ServerNotFoundException, None], + None, + ), # 1 +) + + class get_server_args(object): """ Attributes: @@ -16422,7 +16658,7 @@ def __ne__(self, other): class start_cluster_args(object): """ Attributes: - - public_key + - public_keys - master_instance - worker_instances - user @@ -16431,12 +16667,12 @@ class start_cluster_args(object): def __init__( self, - public_key=None, + public_keys=None, master_instance=None, worker_instances=None, user=None, ): - self.public_key = public_key + self.public_keys = public_keys self.master_instance = master_instance self.worker_instances = worker_instances self.user = user @@ -16455,12 +16691,17 @@ def read(self, iprot): if ftype == TType.STOP: break if fid == 1: - if ftype == TType.STRING: - self.public_key = ( - iprot.readString().decode("utf-8", errors="replace") - if sys.version_info[0] == 2 - else iprot.readString() - ) + if ftype == TType.LIST: + self.public_keys = [] + (_etype359, _size356) = iprot.readListBegin() + for _i360 in range(_size356): + _elem361 = ( + iprot.readString().decode("utf-8", errors="replace") + if sys.version_info[0] == 2 + else iprot.readString() + ) + self.public_keys.append(_elem361) + iprot.readListEnd() else: iprot.skip(ftype) elif fid == 2: @@ -16472,11 +16713,11 @@ def read(self, iprot): elif fid == 3: if ftype == TType.LIST: self.worker_instances = [] - (_etype359, _size356) = iprot.readListBegin() - for _i360 in range(_size356): - _elem361 = ClusterInstance() - _elem361.read(iprot) - self.worker_instances.append(_elem361) + (_etype365, _size362) = iprot.readListBegin() + for _i366 in range(_size362): + _elem367 = ClusterInstance() + _elem367.read(iprot) + self.worker_instances.append(_elem367) iprot.readListEnd() else: iprot.skip(ftype) @@ -16501,13 +16742,14 @@ def write(self, oprot): ) return oprot.writeStructBegin("start_cluster_args") - if self.public_key is not None: - oprot.writeFieldBegin("public_key", TType.STRING, 1) - oprot.writeString( - self.public_key.encode("utf-8") - if sys.version_info[0] == 2 - else self.public_key - ) + if self.public_keys is not None: + oprot.writeFieldBegin("public_keys", TType.LIST, 1) + oprot.writeListBegin(TType.STRING, len(self.public_keys)) + for iter368 in self.public_keys: + oprot.writeString( + iter368.encode("utf-8") if sys.version_info[0] == 2 else iter368 + ) + oprot.writeListEnd() oprot.writeFieldEnd() if self.master_instance is not None: oprot.writeFieldBegin("master_instance", TType.STRUCT, 2) @@ -16516,8 +16758,8 @@ def write(self, oprot): if self.worker_instances is not None: oprot.writeFieldBegin("worker_instances", TType.LIST, 3) oprot.writeListBegin(TType.STRUCT, len(self.worker_instances)) - for iter362 in self.worker_instances: - iter362.write(oprot) + for iter369 in self.worker_instances: + iter369.write(oprot) oprot.writeListEnd() oprot.writeFieldEnd() if self.user is not None: @@ -16548,9 +16790,9 @@ def __ne__(self, other): None, # 0 ( 1, - TType.STRING, - "public_key", - "UTF8", + TType.LIST, + "public_keys", + (TType.STRING, "UTF8", False), None, ), # 1 ( @@ -16606,19 +16848,19 @@ def read(self, iprot): if fid == 0: if ftype == TType.MAP: self.success = {} - (_ktype364, _vtype365, _size363) = iprot.readMapBegin() - for _i367 in range(_size363): - _key368 = ( + (_ktype371, _vtype372, _size370) = iprot.readMapBegin() + for _i374 in range(_size370): + _key375 = ( iprot.readString().decode("utf-8", errors="replace") if sys.version_info[0] == 2 else iprot.readString() ) - _val369 = ( + _val376 = ( iprot.readString().decode("utf-8", errors="replace") if sys.version_info[0] == 2 else iprot.readString() ) - self.success[_key368] = _val369 + self.success[_key375] = _val376 iprot.readMapEnd() else: iprot.skip(ftype) @@ -16637,12 +16879,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 kiter370, viter371 in self.success.items(): + for kiter377, viter378 in self.success.items(): oprot.writeString( - kiter370.encode("utf-8") if sys.version_info[0] == 2 else kiter370 + kiter377.encode("utf-8") if sys.version_info[0] == 2 else kiter377 ) oprot.writeString( - viter371.encode("utf-8") if sys.version_info[0] == 2 else viter371 + viter378.encode("utf-8") if sys.version_info[0] == 2 else viter378 ) oprot.writeMapEnd() oprot.writeFieldEnd() @@ -16792,19 +17034,19 @@ def read(self, iprot): if fid == 0: if ftype == TType.MAP: self.success = {} - (_ktype373, _vtype374, _size372) = iprot.readMapBegin() - for _i376 in range(_size372): - _key377 = ( + (_ktype380, _vtype381, _size379) = iprot.readMapBegin() + for _i383 in range(_size379): + _key384 = ( iprot.readString().decode("utf-8", errors="replace") if sys.version_info[0] == 2 else iprot.readString() ) - _val378 = ( + _val385 = ( iprot.readString().decode("utf-8", errors="replace") if sys.version_info[0] == 2 else iprot.readString() ) - self.success[_key377] = _val378 + self.success[_key384] = _val385 iprot.readMapEnd() else: iprot.skip(ftype) @@ -16828,12 +17070,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 kiter379, viter380 in self.success.items(): + for kiter386, viter387 in self.success.items(): oprot.writeString( - kiter379.encode("utf-8") if sys.version_info[0] == 2 else kiter379 + kiter386.encode("utf-8") if sys.version_info[0] == 2 else kiter386 ) oprot.writeString( - viter380.encode("utf-8") if sys.version_info[0] == 2 else viter380 + viter387.encode("utf-8") if sys.version_info[0] == 2 else viter387 ) oprot.writeMapEnd() oprot.writeFieldEnd() @@ -17594,19 +17836,19 @@ def read(self, iprot): if fid == 0: if ftype == TType.MAP: self.success = {} - (_ktype382, _vtype383, _size381) = iprot.readMapBegin() - for _i385 in range(_size381): - _key386 = ( + (_ktype389, _vtype390, _size388) = iprot.readMapBegin() + for _i392 in range(_size388): + _key393 = ( iprot.readString().decode("utf-8", errors="replace") if sys.version_info[0] == 2 else iprot.readString() ) - _val387 = ( + _val394 = ( iprot.readString().decode("utf-8", errors="replace") if sys.version_info[0] == 2 else iprot.readString() ) - self.success[_key386] = _val387 + self.success[_key393] = _val394 iprot.readMapEnd() else: iprot.skip(ftype) @@ -17635,12 +17877,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 kiter388, viter389 in self.success.items(): + for kiter395, viter396 in self.success.items(): oprot.writeString( - kiter388.encode("utf-8") if sys.version_info[0] == 2 else kiter388 + kiter395.encode("utf-8") if sys.version_info[0] == 2 else kiter395 ) oprot.writeString( - viter389.encode("utf-8") if sys.version_info[0] == 2 else viter389 + viter396.encode("utf-8") if sys.version_info[0] == 2 else viter396 ) oprot.writeMapEnd() oprot.writeFieldEnd() @@ -17925,19 +18167,19 @@ def read(self, iprot): elif fid == 3: if ftype == TType.MAP: self.metadata = {} - (_ktype391, _vtype392, _size390) = iprot.readMapBegin() - for _i394 in range(_size390): - _key395 = ( + (_ktype398, _vtype399, _size397) = iprot.readMapBegin() + for _i401 in range(_size397): + _key402 = ( iprot.readString().decode("utf-8", errors="replace") if sys.version_info[0] == 2 else iprot.readString() ) - _val396 = ( + _val403 = ( iprot.readString().decode("utf-8", errors="replace") if sys.version_info[0] == 2 else iprot.readString() ) - self.metadata[_key395] = _val396 + self.metadata[_key402] = _val403 iprot.readMapEnd() else: iprot.skip(ftype) @@ -17968,12 +18210,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 kiter397, viter398 in self.metadata.items(): + for kiter404, viter405 in self.metadata.items(): oprot.writeString( - kiter397.encode("utf-8") if sys.version_info[0] == 2 else kiter397 + kiter404.encode("utf-8") if sys.version_info[0] == 2 else kiter404 ) oprot.writeString( - viter398.encode("utf-8") if sys.version_info[0] == 2 else viter398 + viter405.encode("utf-8") if sys.version_info[0] == 2 else viter405 ) oprot.writeMapEnd() oprot.writeFieldEnd() @@ -18180,19 +18422,19 @@ def read(self, iprot): elif fid == 2: if ftype == TType.MAP: self.metadata = {} - (_ktype400, _vtype401, _size399) = iprot.readMapBegin() - for _i403 in range(_size399): - _key404 = ( + (_ktype407, _vtype408, _size406) = iprot.readMapBegin() + for _i410 in range(_size406): + _key411 = ( iprot.readString().decode("utf-8", errors="replace") if sys.version_info[0] == 2 else iprot.readString() ) - _val405 = ( + _val412 = ( iprot.readString().decode("utf-8", errors="replace") if sys.version_info[0] == 2 else iprot.readString() ) - self.metadata[_key404] = _val405 + self.metadata[_key411] = _val412 iprot.readMapEnd() else: iprot.skip(ftype) @@ -18228,12 +18470,12 @@ def write(self, oprot): if self.metadata is not None: oprot.writeFieldBegin("metadata", TType.MAP, 2) oprot.writeMapBegin(TType.STRING, TType.STRING, len(self.metadata)) - for kiter406, viter407 in self.metadata.items(): + for kiter413, viter414 in self.metadata.items(): oprot.writeString( - kiter406.encode("utf-8") if sys.version_info[0] == 2 else kiter406 + kiter413.encode("utf-8") if sys.version_info[0] == 2 else kiter413 ) oprot.writeString( - viter407.encode("utf-8") if sys.version_info[0] == 2 else viter407 + viter414.encode("utf-8") if sys.version_info[0] == 2 else viter414 ) oprot.writeMapEnd() oprot.writeFieldEnd() @@ -18448,19 +18690,19 @@ def read(self, iprot): elif fid == 2: if ftype == TType.MAP: self.metadata = {} - (_ktype409, _vtype410, _size408) = iprot.readMapBegin() - for _i412 in range(_size408): - _key413 = ( + (_ktype416, _vtype417, _size415) = iprot.readMapBegin() + for _i419 in range(_size415): + _key420 = ( iprot.readString().decode("utf-8", errors="replace") if sys.version_info[0] == 2 else iprot.readString() ) - _val414 = ( + _val421 = ( iprot.readString().decode("utf-8", errors="replace") if sys.version_info[0] == 2 else iprot.readString() ) - self.metadata[_key413] = _val414 + self.metadata[_key420] = _val421 iprot.readMapEnd() else: iprot.skip(ftype) @@ -18496,12 +18738,12 @@ def write(self, oprot): if self.metadata is not None: oprot.writeFieldBegin("metadata", TType.MAP, 2) oprot.writeMapBegin(TType.STRING, TType.STRING, len(self.metadata)) - for kiter415, viter416 in self.metadata.items(): + for kiter422, viter423 in self.metadata.items(): oprot.writeString( - kiter415.encode("utf-8") if sys.version_info[0] == 2 else kiter415 + kiter422.encode("utf-8") if sys.version_info[0] == 2 else kiter422 ) oprot.writeString( - viter416.encode("utf-8") if sys.version_info[0] == 2 else viter416 + viter423.encode("utf-8") if sys.version_info[0] == 2 else viter423 ) oprot.writeMapEnd() oprot.writeFieldEnd() diff --git a/simple_vm_client/bibigrid_connector/bibigrid_connector.py b/simple_vm_client/bibigrid_connector/bibigrid_connector.py index ab99daf..9a67a21 100644 --- a/simple_vm_client/bibigrid_connector/bibigrid_connector.py +++ b/simple_vm_client/bibigrid_connector/bibigrid_connector.py @@ -168,7 +168,7 @@ def terminate_cluster(self, cluster_id: str) -> dict[str, str]: def start_cluster( self, - public_key: str, + public_keys: list[str], master_instance: ClusterInstance, worker_instances: list[ClusterInstance], user: str, @@ -186,7 +186,7 @@ def start_cluster( body = { "mode": "openstack", "subnet": self._SUB_NETWORK, - "sshPublicKeys": [public_key], + "sshPublicKeys": public_keys, "user": user, "sshUser": "ubuntu", "masterInstance": master_instance, diff --git a/simple_vm_client/openstack_connector/openstack_connector.py b/simple_vm_client/openstack_connector/openstack_connector.py index ea3a350..893dc42 100644 --- a/simple_vm_client/openstack_connector/openstack_connector.py +++ b/simple_vm_client/openstack_connector/openstack_connector.py @@ -8,6 +8,7 @@ import urllib.parse from contextlib import closing from typing import Union +from uuid import uuid4 import sympy import yaml @@ -787,6 +788,14 @@ def create_or_get_default_ssh_security_group(self): ) return sec + def add_default_security_groups_to_server(self, openstack_id): + logger.info(f"Add default Security Group Rule to vm -- {openstack_id}") + server = self.get_server(openstack_id=openstack_id) + sec_group = self._get_default_security_groups() + self.openstack_connection.add_server_security_groups( + server=server, security_groups=sec_group + ) + def delete_security_group_rule(self, openstack_id): logger.info(f"Delete Security Group Rule -- {openstack_id}") deleted = self.openstack_connection.delete_security_group_rule( @@ -1308,7 +1317,13 @@ def start_server( ) -> str: logger.info(f"Start Server {servername}") - key_name: str = None # type: ignore + key_name: str = ( + str(uuid4())[0:3] + + "_" + + servername[:10] + + "_" + + metadata.get("project_name", "") + ) try: image: Image = self.get_image( @@ -1320,7 +1335,6 @@ def start_server( ) flavor: Flavor = self.get_flavor(name_or_id=flavor_name) network: Network = self.get_network() - key_name = f"{servername}_{metadata['project_name']}" logger.info(f"Key name {key_name}") project_name = metadata.get("project_name") project_id = metadata.get("project_id") From 6ffb2144f10dade29e4385036bfd336b701a0906 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 17 Apr 2024 04:09:05 +0000 Subject: [PATCH 4/5] feat(Dependencies): Update dependency types-redis to v4.6.0.20240417 | datasource | package | from | to | | ---------- | ----------- | -------------- | -------------- | | pypi | types-redis | 4.6.0.20240409 | 4.6.0.20240417 | --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index a65ae14..ae3e1ee 100644 --- a/requirements.txt +++ b/requirements.txt @@ -16,4 +16,4 @@ pre-commit==3.7.0 types-PyYAML==6.0.12.20240311 sympy==1.12 colorama==0.4.6 -types-redis==4.6.0.20240409 +types-redis==4.6.0.20240417 From 74473a558546288db90b1f100fb93bae1e71629b Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 17 Apr 2024 10:23:29 +0000 Subject: [PATCH 5/5] feat(Dependencies): Update dependency openstacksdk to v3.1.0 | datasource | package | from | to | | ---------- | ------------ | ----- | ----- | | pypi | openstacksdk | 3.0.0 | 3.1.0 | --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index ae3e1ee..4157ff2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ setuptools==69.2.0 thrift==0.20.0 python-keystoneclient==5.4.0 -openstacksdk==3.0.0 +openstacksdk==3.1.0 deprecated==1.2.14 Click==8.1.7 ansible==9.4.0