diff --git a/VirtualMachineService/VirtualMachineHandler.py b/VirtualMachineService/VirtualMachineHandler.py index 346de7d8..01b2c6f7 100644 --- a/VirtualMachineService/VirtualMachineHandler.py +++ b/VirtualMachineService/VirtualMachineHandler.py @@ -466,13 +466,13 @@ def get_network(self): ) return network - def create_volume_by_start(self, volume_storage, volume_name, server_name): + def create_volume_by_start(self, volume_storage, volume_name, server_name, metadata): self.logger.info( "Creating volume with {0} GB diskspace".format(volume_storage) ) try: volume = self.conn.block_storage.create_volume( - name=volume_name, size=int(volume_storage) + name=volume_name, size=int(volume_storage), metadata=metadata ).to_dict() except Exception as e: self.logger.exception( @@ -493,7 +493,7 @@ def create_mount_init_script(self, volume_id): init_script = base64.b64encode(text).decode("utf-8") return init_script - def create_volume(self, volume_name, diskspace): + def create_volume(self, volume_name, diskspace, metadata): """ Create volume. :param volume_name: Name of volume @@ -503,7 +503,7 @@ def create_volume(self, volume_name, diskspace): self.logger.info("Creating volume with {0} GB diskspace".format(diskspace)) try: volume = self.conn.block_storage.create_volume( - name=volume_name, size=int(diskspace) + name=volume_name, size=int(diskspace), metadata=metadata ).to_dict() volumeId = volume["id"] return volumeId @@ -521,7 +521,7 @@ def start_server( image, public_key, servername, - elixir_id, + metadata, diskspace, volumename, ): @@ -540,11 +540,10 @@ def start_server( volume_id = '' self.logger.info("Start Server {0}".format(servername)) try: - metadata = {"elixir_id": elixir_id} image = self.get_image(image=image) flavor = self.get_flavor(flavor=flavor) network = self.get_network() - key_name = elixir_id[:-18] + key_name = metadata.get("elixir_id")[:-18] public_key = urllib.parse.unquote(public_key) key_pair = self.import_keypair(key_name, public_key) @@ -581,7 +580,7 @@ def start_server( self.logger.exception("Start Server {1} error:{0}".format(e, servername)) return {} - def start_server_with_custom_key(self, flavor, image, servername, elixir_id, diskspace, + def start_server_with_custom_key(self, flavor, image, servername, metadata, diskspace, volumename): """ @@ -599,7 +598,6 @@ def start_server_with_custom_key(self, flavor, image, servername, elixir_id, dis self.logger.info("Start Server {} with custom key".format(servername)) volume_id = '' try: - metadata = {"elixir_id": elixir_id} image = self.get_image(image=image) flavor = self.get_flavor(flavor=flavor) network = self.get_network() diff --git a/VirtualMachineService/VirtualMachineService-remote b/VirtualMachineService/VirtualMachineService-remote index 5b23e73e..1a02a76f 100755 --- a/VirtualMachineService/VirtualMachineService-remote +++ b/VirtualMachineService/VirtualMachineService-remote @@ -36,8 +36,8 @@ if len(sys.argv) <= 1 or sys.argv[1] == '--help': print(' delete_metadata_from_server(string servername, keys)') print(' string add_floating_ip_to_server(string openstack_id, string network)') print(' bool create_connection(string username, string password, string auth_url, string user_domain_name, string project_domain_name)') - print(' start_server(string flavor, string image, string public_key, string servername, string elixir_id, string diskspace, string volumename)') - print(' start_server_with_custom_key(string flavor, string image, string servername, string elixir_id, string diskspace, string volumename)') + print(' start_server(string flavor, string image, string public_key, string servername, metadata, string diskspace, string volumename)') + print(' start_server_with_custom_key(string flavor, string image, string servername, metadata, string diskspace, string volumename)') print(' int create_and_deploy_playbook(string public_key, playbooks_information, string openstack_id)') print(' PlaybookResult get_playbook_logs(string openstack_id)') print(' bool add_security_group_to_server(bool http, bool https, bool udp, string server_id)') @@ -52,7 +52,7 @@ if len(sys.argv) <= 1 or sys.argv[1] == '--help': print(' VM check_server_status(string openstack_id, int diskspace, string volume_id)') print(' string setUserPassword(string user, string password)') print(' bool resume_server(string openstack_id)') - print(' string create_volume(string volume_name, int diskspace)') + print(' string create_volume(string volume_name, int diskspace, metadata)') print(' bool reboot_server(string server_id, string reboot_type)') print('') sys.exit(0) @@ -209,13 +209,13 @@ elif cmd == 'start_server': if len(args) != 7: print('start_server requires 7 args') sys.exit(1) - pp.pprint(client.start_server(args[0], args[1], args[2], args[3], args[4], args[5], args[6],)) + pp.pprint(client.start_server(args[0], args[1], args[2], args[3], eval(args[4]), args[5], args[6],)) elif cmd == 'start_server_with_custom_key': if len(args) != 6: print('start_server_with_custom_key requires 6 args') sys.exit(1) - pp.pprint(client.start_server_with_custom_key(args[0], args[1], args[2], args[3], args[4], args[5],)) + pp.pprint(client.start_server_with_custom_key(args[0], args[1], args[2], eval(args[3]), args[4], args[5],)) elif cmd == 'create_and_deploy_playbook': if len(args) != 3: @@ -302,10 +302,10 @@ elif cmd == 'resume_server': pp.pprint(client.resume_server(args[0],)) elif cmd == 'create_volume': - if len(args) != 2: - print('create_volume requires 2 args') + if len(args) != 3: + print('create_volume requires 3 args') sys.exit(1) - pp.pprint(client.create_volume(args[0], eval(args[1]),)) + pp.pprint(client.create_volume(args[0], eval(args[1]), eval(args[2]),)) elif cmd == 'reboot_server': if len(args) != 2: diff --git a/VirtualMachineService/VirtualMachineService.py b/VirtualMachineService/VirtualMachineService.py index 023f261e..3a8c64aa 100644 --- a/VirtualMachineService/VirtualMachineService.py +++ b/VirtualMachineService/VirtualMachineService.py @@ -148,7 +148,7 @@ def create_connection(self, username, password, auth_url, user_domain_name, proj """ pass - def start_server(self, flavor, image, public_key, servername, elixir_id, diskspace, volumename): + def start_server(self, flavor, image, public_key, servername, metadata, diskspace, volumename): """ Start a new server. @@ -157,22 +157,22 @@ def start_server(self, flavor, image, public_key, servername, elixir_id, diskspa - image: Name of the image to use. - public_key: Public Key to use - servername: Name for the new server - - elixir_id: Elixir-Id of the user who requested to start a new server + - metadata: Metadata for the new instance - diskspace: Diskspace in GB for additional volume. - volumename: Name of additional Volume """ pass - def start_server_with_custom_key(self, flavor, image, servername, elixir_id, diskspace, volumename): + def start_server_with_custom_key(self, flavor, image, servername, metadata, diskspace, volumename): """ - Start a new server. + Start a new server with custom key for ansible. Parameters: - flavor: Name of the Flavor to use. - image: Name of the image to use. - servername: Name for the new server - - elixir_id: Elixir-Id of the user who requested to start a new server + - metadata: Metadata for the new instance - diskspace: Diskspace in GB for additional volume. - volumename: Name of additional Volume @@ -344,7 +344,7 @@ def resume_server(self, openstack_id): """ pass - def create_volume(self, volume_name, diskspace): + def create_volume(self, volume_name, diskspace, metadata): """ Create volume. Returns: Id of new volume @@ -352,6 +352,7 @@ def create_volume(self, volume_name, diskspace): Parameters: - volume_name: Name of volume - diskspace: Diskspace in GB for new volume + - metadata: Metadata for the new volume """ pass @@ -810,7 +811,7 @@ def recv_create_connection(self): raise result.e raise TApplicationException(TApplicationException.MISSING_RESULT, "create_connection failed: unknown result") - def start_server(self, flavor, image, public_key, servername, elixir_id, diskspace, volumename): + def start_server(self, flavor, image, public_key, servername, metadata, diskspace, volumename): """ Start a new server. @@ -819,22 +820,22 @@ def start_server(self, flavor, image, public_key, servername, elixir_id, diskspa - image: Name of the image to use. - public_key: Public Key to use - servername: Name for the new server - - elixir_id: Elixir-Id of the user who requested to start a new server + - metadata: Metadata for the new instance - diskspace: Diskspace in GB for additional volume. - volumename: Name of additional Volume """ - self.send_start_server(flavor, image, public_key, servername, elixir_id, diskspace, volumename) + self.send_start_server(flavor, image, public_key, servername, metadata, diskspace, volumename) return self.recv_start_server() - def send_start_server(self, flavor, image, public_key, servername, elixir_id, diskspace, volumename): + def send_start_server(self, flavor, image, public_key, servername, metadata, diskspace, volumename): self._oprot.writeMessageBegin('start_server', TMessageType.CALL, self._seqid) args = start_server_args() args.flavor = flavor args.image = image args.public_key = public_key args.servername = servername - args.elixir_id = elixir_id + args.metadata = metadata args.diskspace = diskspace args.volumename = volumename args.write(self._oprot) @@ -870,29 +871,29 @@ def recv_start_server(self): raise result.o raise TApplicationException(TApplicationException.MISSING_RESULT, "start_server failed: unknown result") - def start_server_with_custom_key(self, flavor, image, servername, elixir_id, diskspace, volumename): + def start_server_with_custom_key(self, flavor, image, servername, metadata, diskspace, volumename): """ - Start a new server. + Start a new server with custom key for ansible. Parameters: - flavor: Name of the Flavor to use. - image: Name of the image to use. - servername: Name for the new server - - elixir_id: Elixir-Id of the user who requested to start a new server + - metadata: Metadata for the new instance - diskspace: Diskspace in GB for additional volume. - volumename: Name of additional Volume """ - self.send_start_server_with_custom_key(flavor, image, servername, elixir_id, diskspace, volumename) + self.send_start_server_with_custom_key(flavor, image, servername, metadata, diskspace, volumename) return self.recv_start_server_with_custom_key() - def send_start_server_with_custom_key(self, flavor, image, servername, elixir_id, diskspace, volumename): + def send_start_server_with_custom_key(self, flavor, image, servername, metadata, diskspace, volumename): self._oprot.writeMessageBegin('start_server_with_custom_key', TMessageType.CALL, self._seqid) args = start_server_with_custom_key_args() args.flavor = flavor args.image = image args.servername = servername - args.elixir_id = elixir_id + args.metadata = metadata args.diskspace = diskspace args.volumename = volumename args.write(self._oprot) @@ -1466,7 +1467,7 @@ def recv_resume_server(self): raise result.e raise TApplicationException(TApplicationException.MISSING_RESULT, "resume_server failed: unknown result") - def create_volume(self, volume_name, diskspace): + def create_volume(self, volume_name, diskspace, metadata): """ Create volume. Returns: Id of new volume @@ -1474,16 +1475,18 @@ def create_volume(self, volume_name, diskspace): Parameters: - volume_name: Name of volume - diskspace: Diskspace in GB for new volume + - metadata: Metadata for the new volume """ - self.send_create_volume(volume_name, diskspace) + self.send_create_volume(volume_name, diskspace, metadata) return self.recv_create_volume() - def send_create_volume(self, volume_name, diskspace): + def send_create_volume(self, volume_name, diskspace, metadata): self._oprot.writeMessageBegin('create_volume', TMessageType.CALL, self._seqid) args = create_volume_args() args.volume_name = volume_name args.diskspace = diskspace + args.metadata = metadata args.write(self._oprot) self._oprot.writeMessageEnd() self._oprot.trans.flush() @@ -1895,7 +1898,7 @@ def process_start_server(self, seqid, iprot, oprot): iprot.readMessageEnd() result = start_server_result() try: - result.success = self._handler.start_server(args.flavor, args.image, args.public_key, args.servername, args.elixir_id, args.diskspace, args.volumename) + result.success = self._handler.start_server(args.flavor, args.image, args.public_key, args.servername, args.metadata, args.diskspace, args.volumename) msg_type = TMessageType.REPLY except TTransport.TTransportException: raise @@ -1939,7 +1942,7 @@ def process_start_server_with_custom_key(self, seqid, iprot, oprot): iprot.readMessageEnd() result = start_server_with_custom_key_result() try: - result.success = self._handler.start_server_with_custom_key(args.flavor, args.image, args.servername, args.elixir_id, args.diskspace, args.volumename) + result.success = self._handler.start_server_with_custom_key(args.flavor, args.image, args.servername, args.metadata, args.diskspace, args.volumename) msg_type = TMessageType.REPLY except TTransport.TTransportException: raise @@ -2341,7 +2344,7 @@ def process_create_volume(self, seqid, iprot, oprot): iprot.readMessageEnd() result = create_volume_result() try: - result.success = self._handler.create_volume(args.volume_name, args.diskspace) + result.success = self._handler.create_volume(args.volume_name, args.diskspace, args.metadata) msg_type = TMessageType.REPLY except TTransport.TTransportException: raise @@ -4059,19 +4062,19 @@ class start_server_args(object): - image: Name of the image to use. - public_key: Public Key to use - servername: Name for the new server - - elixir_id: Elixir-Id of the user who requested to start a new server + - metadata: Metadata for the new instance - diskspace: Diskspace in GB for additional volume. - volumename: Name of additional Volume """ - def __init__(self, flavor=None, image=None, public_key=None, servername=None, elixir_id=None, diskspace=None, volumename=None,): + def __init__(self, flavor=None, image=None, public_key=None, servername=None, metadata=None, diskspace=None, volumename=None,): self.flavor = flavor self.image = image self.public_key = public_key self.servername = servername - self.elixir_id = elixir_id + self.metadata = metadata self.diskspace = diskspace self.volumename = volumename @@ -4105,8 +4108,14 @@ def read(self, iprot): else: iprot.skip(ftype) elif fid == 5: - if ftype == TType.STRING: - self.elixir_id = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() + if ftype == TType.MAP: + self.metadata = {} + (_ktype88, _vtype89, _size87) = iprot.readMapBegin() + for _i91 in range(_size87): + _key92 = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() + _val93 = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() + self.metadata[_key92] = _val93 + iprot.readMapEnd() else: iprot.skip(ftype) elif fid == 6: @@ -4145,9 +4154,13 @@ def write(self, oprot): oprot.writeFieldBegin('servername', TType.STRING, 4) oprot.writeString(self.servername.encode('utf-8') if sys.version_info[0] == 2 else self.servername) oprot.writeFieldEnd() - if self.elixir_id is not None: - oprot.writeFieldBegin('elixir_id', TType.STRING, 5) - oprot.writeString(self.elixir_id.encode('utf-8') if sys.version_info[0] == 2 else self.elixir_id) + if self.metadata is not None: + oprot.writeFieldBegin('metadata', TType.MAP, 5) + oprot.writeMapBegin(TType.STRING, TType.STRING, len(self.metadata)) + for kiter94, viter95 in self.metadata.items(): + oprot.writeString(kiter94.encode('utf-8') if sys.version_info[0] == 2 else kiter94) + oprot.writeString(viter95.encode('utf-8') if sys.version_info[0] == 2 else viter95) + oprot.writeMapEnd() oprot.writeFieldEnd() if self.diskspace is not None: oprot.writeFieldBegin('diskspace', TType.STRING, 6) @@ -4180,7 +4193,7 @@ def __ne__(self, other): (2, TType.STRING, 'image', 'UTF8', None, ), # 2 (3, TType.STRING, 'public_key', 'UTF8', None, ), # 3 (4, TType.STRING, 'servername', 'UTF8', None, ), # 4 - (5, TType.STRING, 'elixir_id', 'UTF8', None, ), # 5 + (5, TType.MAP, 'metadata', (TType.STRING, 'UTF8', TType.STRING, 'UTF8', False), None, ), # 5 (6, TType.STRING, 'diskspace', 'UTF8', None, ), # 6 (7, TType.STRING, 'volumename', 'UTF8', None, ), # 7 ) @@ -4223,11 +4236,11 @@ def read(self, iprot): if fid == 0: if ftype == TType.MAP: self.success = {} - (_ktype88, _vtype89, _size87) = iprot.readMapBegin() - for _i91 in range(_size87): - _key92 = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() - _val93 = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() - self.success[_key92] = _val93 + (_ktype97, _vtype98, _size96) = iprot.readMapBegin() + for _i100 in range(_size96): + _key101 = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() + _val102 = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() + self.success[_key101] = _val102 iprot.readMapEnd() else: iprot.skip(ftype) @@ -4286,9 +4299,9 @@ 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 kiter94, viter95 in self.success.items(): - oprot.writeString(kiter94.encode('utf-8') if sys.version_info[0] == 2 else kiter94) - oprot.writeString(viter95.encode('utf-8') if sys.version_info[0] == 2 else viter95) + for kiter103, viter104 in self.success.items(): + oprot.writeString(kiter103.encode('utf-8') if sys.version_info[0] == 2 else kiter103) + oprot.writeString(viter104.encode('utf-8') if sys.version_info[0] == 2 else viter104) oprot.writeMapEnd() oprot.writeFieldEnd() if self.e is not None: @@ -4354,18 +4367,18 @@ class start_server_with_custom_key_args(object): - flavor: Name of the Flavor to use. - image: Name of the image to use. - servername: Name for the new server - - elixir_id: Elixir-Id of the user who requested to start a new server + - metadata: Metadata for the new instance - diskspace: Diskspace in GB for additional volume. - volumename: Name of additional Volume """ - def __init__(self, flavor=None, image=None, servername=None, elixir_id=None, diskspace=None, volumename=None,): + def __init__(self, flavor=None, image=None, servername=None, metadata=None, diskspace=None, volumename=None,): self.flavor = flavor self.image = image self.servername = servername - self.elixir_id = elixir_id + self.metadata = metadata self.diskspace = diskspace self.volumename = volumename @@ -4394,8 +4407,14 @@ def read(self, iprot): else: iprot.skip(ftype) elif fid == 4: - if ftype == TType.STRING: - self.elixir_id = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() + if ftype == TType.MAP: + self.metadata = {} + (_ktype106, _vtype107, _size105) = iprot.readMapBegin() + for _i109 in range(_size105): + _key110 = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() + _val111 = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() + self.metadata[_key110] = _val111 + iprot.readMapEnd() else: iprot.skip(ftype) elif fid == 5: @@ -4430,9 +4449,13 @@ def write(self, oprot): oprot.writeFieldBegin('servername', TType.STRING, 3) oprot.writeString(self.servername.encode('utf-8') if sys.version_info[0] == 2 else self.servername) oprot.writeFieldEnd() - if self.elixir_id is not None: - oprot.writeFieldBegin('elixir_id', TType.STRING, 4) - oprot.writeString(self.elixir_id.encode('utf-8') if sys.version_info[0] == 2 else self.elixir_id) + if self.metadata is not None: + oprot.writeFieldBegin('metadata', TType.MAP, 4) + oprot.writeMapBegin(TType.STRING, TType.STRING, len(self.metadata)) + for kiter112, viter113 in self.metadata.items(): + oprot.writeString(kiter112.encode('utf-8') if sys.version_info[0] == 2 else kiter112) + oprot.writeString(viter113.encode('utf-8') if sys.version_info[0] == 2 else viter113) + oprot.writeMapEnd() oprot.writeFieldEnd() if self.diskspace is not None: oprot.writeFieldBegin('diskspace', TType.STRING, 5) @@ -4464,7 +4487,7 @@ def __ne__(self, other): (1, TType.STRING, 'flavor', 'UTF8', None, ), # 1 (2, TType.STRING, 'image', 'UTF8', None, ), # 2 (3, TType.STRING, 'servername', 'UTF8', None, ), # 3 - (4, TType.STRING, 'elixir_id', 'UTF8', None, ), # 4 + (4, TType.MAP, 'metadata', (TType.STRING, 'UTF8', TType.STRING, 'UTF8', False), None, ), # 4 (5, TType.STRING, 'diskspace', 'UTF8', None, ), # 5 (6, TType.STRING, 'volumename', 'UTF8', None, ), # 6 ) @@ -4507,11 +4530,11 @@ def read(self, iprot): if fid == 0: if ftype == TType.MAP: self.success = {} - (_ktype97, _vtype98, _size96) = iprot.readMapBegin() - for _i100 in range(_size96): - _key101 = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() - _val102 = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() - self.success[_key101] = _val102 + (_ktype115, _vtype116, _size114) = iprot.readMapBegin() + for _i118 in range(_size114): + _key119 = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() + _val120 = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() + self.success[_key119] = _val120 iprot.readMapEnd() else: iprot.skip(ftype) @@ -4570,9 +4593,9 @@ 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 kiter103, viter104 in self.success.items(): - oprot.writeString(kiter103.encode('utf-8') if sys.version_info[0] == 2 else kiter103) - oprot.writeString(viter104.encode('utf-8') if sys.version_info[0] == 2 else viter104) + for kiter121, viter122 in self.success.items(): + oprot.writeString(kiter121.encode('utf-8') if sys.version_info[0] == 2 else kiter121) + oprot.writeString(viter122.encode('utf-8') if sys.version_info[0] == 2 else viter122) oprot.writeMapEnd() oprot.writeFieldEnd() if self.e is not None: @@ -4664,17 +4687,17 @@ def read(self, iprot): elif fid == 2: if ftype == TType.MAP: self.playbooks_information = {} - (_ktype106, _vtype107, _size105) = iprot.readMapBegin() - for _i109 in range(_size105): - _key110 = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() - _val111 = {} - (_ktype113, _vtype114, _size112) = iprot.readMapBegin() - for _i116 in range(_size112): - _key117 = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() - _val118 = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() - _val111[_key117] = _val118 + (_ktype124, _vtype125, _size123) = iprot.readMapBegin() + for _i127 in range(_size123): + _key128 = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() + _val129 = {} + (_ktype131, _vtype132, _size130) = iprot.readMapBegin() + for _i134 in range(_size130): + _key135 = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() + _val136 = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() + _val129[_key135] = _val136 iprot.readMapEnd() - self.playbooks_information[_key110] = _val111 + self.playbooks_information[_key128] = _val129 iprot.readMapEnd() else: iprot.skip(ftype) @@ -4700,12 +4723,12 @@ def write(self, oprot): if self.playbooks_information is not None: oprot.writeFieldBegin('playbooks_information', TType.MAP, 2) oprot.writeMapBegin(TType.STRING, TType.MAP, len(self.playbooks_information)) - for kiter119, viter120 in self.playbooks_information.items(): - oprot.writeString(kiter119.encode('utf-8') if sys.version_info[0] == 2 else kiter119) - oprot.writeMapBegin(TType.STRING, TType.STRING, len(viter120)) - for kiter121, viter122 in viter120.items(): - oprot.writeString(kiter121.encode('utf-8') if sys.version_info[0] == 2 else kiter121) - oprot.writeString(viter122.encode('utf-8') if sys.version_info[0] == 2 else viter122) + for kiter137, viter138 in self.playbooks_information.items(): + oprot.writeString(kiter137.encode('utf-8') if sys.version_info[0] == 2 else kiter137) + oprot.writeMapBegin(TType.STRING, TType.STRING, len(viter138)) + for kiter139, viter140 in viter138.items(): + oprot.writeString(kiter139.encode('utf-8') if sys.version_info[0] == 2 else kiter139) + oprot.writeString(viter140.encode('utf-8') if sys.version_info[0] == 2 else viter140) oprot.writeMapEnd() oprot.writeMapEnd() oprot.writeFieldEnd() @@ -5631,11 +5654,11 @@ def read(self, iprot): if fid == 0: if ftype == TType.MAP: self.success = {} - (_ktype124, _vtype125, _size123) = iprot.readMapBegin() - for _i127 in range(_size123): - _key128 = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() - _val129 = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() - self.success[_key128] = _val129 + (_ktype142, _vtype143, _size141) = iprot.readMapBegin() + for _i145 in range(_size141): + _key146 = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() + _val147 = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() + self.success[_key146] = _val147 iprot.readMapEnd() else: iprot.skip(ftype) @@ -5652,9 +5675,9 @@ 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 kiter130, viter131 in self.success.items(): - oprot.writeString(kiter130.encode('utf-8') if sys.version_info[0] == 2 else kiter130) - oprot.writeString(viter131.encode('utf-8') if sys.version_info[0] == 2 else viter131) + for kiter148, viter149 in self.success.items(): + oprot.writeString(kiter148.encode('utf-8') if sys.version_info[0] == 2 else kiter148) + oprot.writeString(viter149.encode('utf-8') if sys.version_info[0] == 2 else viter149) oprot.writeMapEnd() oprot.writeFieldEnd() oprot.writeFieldStop() @@ -6697,13 +6720,15 @@ class create_volume_args(object): Attributes: - volume_name: Name of volume - diskspace: Diskspace in GB for new volume + - metadata: Metadata for the new volume """ - def __init__(self, volume_name=None, diskspace=None,): + def __init__(self, volume_name=None, diskspace=None, metadata=None,): self.volume_name = volume_name self.diskspace = diskspace + self.metadata = metadata def read(self, iprot): if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: @@ -6724,6 +6749,17 @@ def read(self, iprot): self.diskspace = iprot.readI32() else: iprot.skip(ftype) + elif fid == 3: + if ftype == TType.MAP: + self.metadata = {} + (_ktype151, _vtype152, _size150) = iprot.readMapBegin() + for _i154 in range(_size150): + _key155 = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() + _val156 = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() + self.metadata[_key155] = _val156 + iprot.readMapEnd() + else: + iprot.skip(ftype) else: iprot.skip(ftype) iprot.readFieldEnd() @@ -6742,6 +6778,14 @@ def write(self, oprot): oprot.writeFieldBegin('diskspace', TType.I32, 2) oprot.writeI32(self.diskspace) oprot.writeFieldEnd() + if self.metadata is not None: + oprot.writeFieldBegin('metadata', TType.MAP, 3) + oprot.writeMapBegin(TType.STRING, TType.STRING, len(self.metadata)) + for kiter157, viter158 in self.metadata.items(): + oprot.writeString(kiter157.encode('utf-8') if sys.version_info[0] == 2 else kiter157) + oprot.writeString(viter158.encode('utf-8') if sys.version_info[0] == 2 else viter158) + oprot.writeMapEnd() + oprot.writeFieldEnd() oprot.writeFieldStop() oprot.writeStructEnd() @@ -6763,6 +6807,7 @@ def __ne__(self, other): None, # 0 (1, TType.STRING, 'volume_name', 'UTF8', None, ), # 1 (2, TType.I32, 'diskspace', None, None, ), # 2 + (3, TType.MAP, 'metadata', (TType.STRING, 'UTF8', TType.STRING, 'UTF8', False), None, ), # 3 ) diff --git a/portal_client.thrift b/portal_client.thrift index 7939a5a4..92082fc9 100644 --- a/portal_client.thrift +++ b/portal_client.thrift @@ -306,8 +306,8 @@ service VirtualMachineService { /** Name for the new server */ 4:string servername, - /** Elixir-Id of the user who requested to start a new server*/ - 5:string elixir_id, + /** Metadata for the new instance*/ + 5:map metadata, /** Diskspace in GB for additional volume.*/ 6:string diskspace, @@ -319,7 +319,7 @@ service VirtualMachineService { /** - * Start a new server. + * Start a new server with custom key for ansible. */ map start_server_with_custom_key( @@ -332,8 +332,8 @@ service VirtualMachineService { /** Name for the new server */ 3:string servername, - /** Elixir-Id of the user who requested to start a new server*/ - 4:string elixir_id, + /** Metadata for the new instance*/ + 4:map metadata, /** Diskspace in GB for additional volume.*/ 5:string diskspace, @@ -529,7 +529,10 @@ service VirtualMachineService { 1:string volume_name, /** Diskspace in GB for new volume */ - 2:int diskspace) + 2:int diskspace, + + /** Metadata for the new volume*/ + 3:map metadata) throws (1:ressourceException r)