Re: [PATCH master 3/4] set-mem rapi and tests
On Tue, Jan 10, 2012 at 06:28:51PM +, Guido Trotter wrote: We still need --running-mem: this is meant for ballooning without changing min and max, which are the only values we currently save. Guid, can you confirm this is correct? - we have min/max mem, which are config values - we have oper_ram, which is the current running memory (between min/max) - currently gnt-instance modify only allows changing min/max _in the config_ - we want to be able to modify min/max at runtime and also oper_ram at runtime iustin On Jan 10, 2012 3:47 PM, Michael Hanselmann han...@google.com wrote: Am 10. Januar 2012 12:29 schrieb Iustin Pop ius...@google.com: Hmm, right. But then I'd make it a different key (e.g. running-mem or such), but still in instance modify. Or add a new parameter “--live” to apply the changes right away. Michael
Re: [PATCH master 3/4] set-mem rapi and tests
Not exactly. - There is no such thing as min at run time - As for max it cannot be modified without a reboot. So it's all true except the last sentence: we just want a way to modify oper_ram, live. (there is no sense in doing it non-live) Guido On Jan 11, 2012 11:02 AM, Iustin Pop ius...@google.com wrote: On Tue, Jan 10, 2012 at 06:28:51PM +, Guido Trotter wrote: We still need --running-mem: this is meant for ballooning without changing min and max, which are the only values we currently save. Guid, can you confirm this is correct? - we have min/max mem, which are config values - we have oper_ram, which is the current running memory (between min/max) - currently gnt-instance modify only allows changing min/max _in the config_ - we want to be able to modify min/max at runtime and also oper_ram at runtime iustin On Jan 10, 2012 3:47 PM, Michael Hanselmann han...@google.com wrote: Am 10. Januar 2012 12:29 schrieb Iustin Pop ius...@google.com: Hmm, right. But then I'd make it a different key (e.g. running-mem or such), but still in instance modify. Or add a new parameter “--live” to apply the changes right away. Michael
Re: [PATCH master 3/4] set-mem rapi and tests
On Wed, Jan 11, 2012 at 10:58:54AM +, Guido Trotter wrote: Not exactly. - There is no such thing as min at run time Hmm. Right now (in 2.6) not, but this would have been the value that Xen (or KVM) is allowed to auto-balloon-down the instance. But I might be wrong indeed and there's no such memory. Hrmm… Then would the oper_mem (running_mem) be the minimum for the hypervisor? I think I misjudged a bit these, I'll have to rethink and see how all the thinks (capacity, auto-ballooning, etc.) will work. - As for max it cannot be modified without a reboot. So it's all true except the last sentence: we just want a way to modify oper_ram, live. (there is no sense in doing it non-live) Ack. Whether we keep oper_ram (for consistency with instance list) or we rename it to running_ram it's for decision. thanks! iustin On Jan 11, 2012 11:02 AM, Iustin Pop ius...@google.com wrote: On Tue, Jan 10, 2012 at 06:28:51PM +, Guido Trotter wrote: We still need --running-mem: this is meant for ballooning without changing min and max, which are the only values we currently save. Guid, can you confirm this is correct? - we have min/max mem, which are config values - we have oper_ram, which is the current running memory (between min/max) - currently gnt-instance modify only allows changing min/max _in the config_ - we want to be able to modify min/max at runtime and also oper_ram at runtime iustin On Jan 10, 2012 3:47 PM, Michael Hanselmann han...@google.com wrote: Am 10. Januar 2012 12:29 schrieb Iustin Pop ius...@google.com: Hmm, right. But then I'd make it a different key (e.g. running-mem or such), but still in instance modify. Or add a new parameter “--live” to apply the changes right away. Michael
Re: [PATCH master 3/4] set-mem rapi and tests
I think auto_ballooning will go as much as it can. I've seen no minimum there. oper_ram is just the current one, not the minimum, the hypervisor might go lower. I think that min is the minimum ganeti will guarantee to be available (never start instances if all of them are nit guaranteed to have at least their min) oper is just the current runtime and max is the max an instance can go to. G On Jan 11, 2012 12:11 PM, Iustin Pop ius...@google.com wrote: On Wed, Jan 11, 2012 at 10:58:54AM +, Guido Trotter wrote: Not exactly. - There is no such thing as min at run time Hmm. Right now (in 2.6) not, but this would have been the value that Xen (or KVM) is allowed to auto-balloon-down the instance. But I might be wrong indeed and there's no such memory. Hrmm… Then would the oper_mem (running_mem) be the minimum for the hypervisor? I think I misjudged a bit these, I'll have to rethink and see how all the thinks (capacity, auto-ballooning, etc.) will work. - As for max it cannot be modified without a reboot. So it's all true except the last sentence: we just want a way to modify oper_ram, live. (there is no sense in doing it non-live) Ack. Whether we keep oper_ram (for consistency with instance list) or we rename it to running_ram it's for decision. thanks! iustin On Jan 11, 2012 11:02 AM, Iustin Pop ius...@google.com wrote: On Tue, Jan 10, 2012 at 06:28:51PM +, Guido Trotter wrote: We still need --running-mem: this is meant for ballooning without changing min and max, which are the only values we currently save. Guid, can you confirm this is correct? - we have min/max mem, which are config values - we have oper_ram, which is the current running memory (between min/max) - currently gnt-instance modify only allows changing min/max _in the config_ - we want to be able to modify min/max at runtime and also oper_ram at runtime iustin On Jan 10, 2012 3:47 PM, Michael Hanselmann han...@google.com wrote: Am 10. Januar 2012 12:29 schrieb Iustin Pop ius...@google.com: Hmm, right. But then I'd make it a different key (e.g. running-mem or such), but still in instance modify. Or add a new parameter “--live” to apply the changes right away. Michael
Re: [PATCH master 3/4] set-mem rapi and tests
On Mon, Jan 9, 2012 at 19:18, Guido Trotter ultrot...@google.com wrote: Signed-off-by: Guido Trotter ultrot...@google.com --- doc/rapi.rst | 18 ++ lib/rapi/client.py | 25 + lib/rapi/connector.py | 2 ++ lib/rapi/rlib2.py | 18 ++ test/ganeti.rapi.client_unittest.py | 8 test/ganeti.rapi.rlib2_unittest.py | 22 ++ 6 files changed, 93 insertions(+), 0 deletions(-) diff --git a/doc/rapi.rst b/doc/rapi.rst index c80a309..930eb8d 100644 --- a/doc/rapi.rst +++ b/doc/rapi.rst @@ -736,6 +736,24 @@ instance even if secondary disks are failing. It supports the ``dry-run`` argument. +``/2/instances/[instance_name]/setmem`` + +Instance set-memory URI. + +It supports the following commands: ``PUT``. + +``PUT`` +~~~ + +Modifies the runtime memory of an instance. + +It supports the ``dry-run`` argument. + +.. opcode_params:: OP_INSTANCE_SET_MEMORY + :exclude: instance_name, dry_run + + ``/2/instances/[instance_name]/reinstall`` ++ diff --git a/lib/rapi/client.py b/lib/rapi/client.py index 4e9f96c..92a463e 100644 --- a/lib/rapi/client.py +++ b/lib/rapi/client.py @@ -968,6 +968,31 @@ class GanetiRapiClient(object): # pylint: disable=R0904 (/%s/instances/%s/startup % (GANETI_RAPI_VERSION, instance)), query, None) + def SetInstanceMemory(self, instance, memory, dry_run=False, force=False): + Grows a disk of an instance. + + More details for parameters can be found in the RAPI documentation. + + @type instance: string + @param instance: Instance name + @type memory: integer + @param memory: Target memory size (MiB) + @type dry_run: bool + @param dry_run: whether to perform a dry run + @type force: bool + @param force: whether to force the memory change + @rtype: string + @return: job id + + + query = [(memory, memory)] + _AppendDryRunIf(query, dry_run) + _AppendForceIf(query, force) + + return self._SendRequest(HTTP_PUT, + (/%s/instances/%s/setmem % + (GANETI_RAPI_VERSION, instance)), query, None) + def ReinstallInstance(self, instance, os=None, no_startup=False, osparams=None): Reinstalls an instance. diff --git a/lib/rapi/connector.py b/lib/rapi/connector.py index b701d71..5d381d2 100644 --- a/lib/rapi/connector.py +++ b/lib/rapi/connector.py @@ -141,6 +141,8 @@ def GetHandlers(node_name_pattern, instance_name_pattern, rlib2.R_2_instances_name_replace_disks, re.compile(r^/2/instances/(%s)/shutdown$ % instance_name_pattern): rlib2.R_2_instances_name_shutdown, + re.compile(r^/2/instances/(%s)/setmem$ % instance_name_pattern): + rlib2.R_2_instances_name_setmem, re.compile(r^/2/instances/(%s)/startup$ % instance_name_pattern): rlib2.R_2_instances_name_startup, re.compile(r^/2/instances/(%s)/activate-disks$ % instance_name_pattern): diff --git a/lib/rapi/rlib2.py b/lib/rapi/rlib2.py index 46e0029..7a92c61 100644 --- a/lib/rapi/rlib2.py +++ b/lib/rapi/rlib2.py @@ -907,6 +907,24 @@ class R_2_instances_name_shutdown(baserlib.OpcodeResource): }) +class R_2_instances_name_setmem(baserlib.OpcodeResource): + /2/instances/[instance_name]/setmem resource. + + + PUT_OPCODE = opcodes.OpInstanceSetMemory + + def GetPutOpInput(self): + Modifies an instance's runtime memory + + + return (self.request_body, { + instance_name: self.items[0], + memory: self._checkIntVariable(memory, default=None), I wonder if that is a sane default value. Wouldn't it be better to have a 0 (and therefore an int) here? I'm fine with None too, just test it please! René
Re: [PATCH master 3/4] set-mem rapi and tests
The idea is that it has to fail if they don't pass in a param, right? But I'm fine with going with 0 and add a 0 assertion in the LU. G On Jan 10, 2012 9:29 AM, René Nussbaumer r...@google.com wrote: On Mon, Jan 9, 2012 at 19:18, Guido Trotter ultrot...@google.com wrote: Signed-off-by: Guido Trotter ultrot...@google.com --- doc/rapi.rst| 18 ++ lib/rapi/client.py | 25 + lib/rapi/connector.py |2 ++ lib/rapi/rlib2.py | 18 ++ test/ganeti.rapi.client_unittest.py |8 test/ganeti.rapi.rlib2_unittest.py | 22 ++ 6 files changed, 93 insertions(+), 0 deletions(-) diff --git a/doc/rapi.rst b/doc/rapi.rst index c80a309..930eb8d 100644 --- a/doc/rapi.rst +++ b/doc/rapi.rst @@ -736,6 +736,24 @@ instance even if secondary disks are failing. It supports the ``dry-run`` argument. +``/2/instances/[instance_name]/setmem`` + +Instance set-memory URI. + +It supports the following commands: ``PUT``. + +``PUT`` +~~~ + +Modifies the runtime memory of an instance. + +It supports the ``dry-run`` argument. + +.. opcode_params:: OP_INSTANCE_SET_MEMORY + :exclude: instance_name, dry_run + + ``/2/instances/[instance_name]/reinstall`` ++ diff --git a/lib/rapi/client.py b/lib/rapi/client.py index 4e9f96c..92a463e 100644 --- a/lib/rapi/client.py +++ b/lib/rapi/client.py @@ -968,6 +968,31 @@ class GanetiRapiClient(object): # pylint: disable=R0904 (/%s/instances/%s/startup % (GANETI_RAPI_VERSION, instance)), query, None) + def SetInstanceMemory(self, instance, memory, dry_run=False, force=False): +Grows a disk of an instance. + +More details for parameters can be found in the RAPI documentation. + +@type instance: string +@param instance: Instance name +@type memory: integer +@param memory: Target memory size (MiB) +@type dry_run: bool +@param dry_run: whether to perform a dry run +@type force: bool +@param force: whether to force the memory change +@rtype: string +@return: job id + + +query = [(memory, memory)] +_AppendDryRunIf(query, dry_run) +_AppendForceIf(query, force) + +return self._SendRequest(HTTP_PUT, + (/%s/instances/%s/setmem % + (GANETI_RAPI_VERSION, instance)), query, None) + def ReinstallInstance(self, instance, os=None, no_startup=False, osparams=None): Reinstalls an instance. diff --git a/lib/rapi/connector.py b/lib/rapi/connector.py index b701d71..5d381d2 100644 --- a/lib/rapi/connector.py +++ b/lib/rapi/connector.py @@ -141,6 +141,8 @@ def GetHandlers(node_name_pattern, instance_name_pattern, rlib2.R_2_instances_name_replace_disks, re.compile(r^/2/instances/(%s)/shutdown$ % instance_name_pattern): rlib2.R_2_instances_name_shutdown, +re.compile(r^/2/instances/(%s)/setmem$ % instance_name_pattern): + rlib2.R_2_instances_name_setmem, re.compile(r^/2/instances/(%s)/startup$ % instance_name_pattern): rlib2.R_2_instances_name_startup, re.compile(r^/2/instances/(%s)/activate-disks$ % instance_name_pattern): diff --git a/lib/rapi/rlib2.py b/lib/rapi/rlib2.py index 46e0029..7a92c61 100644 --- a/lib/rapi/rlib2.py +++ b/lib/rapi/rlib2.py @@ -907,6 +907,24 @@ class R_2_instances_name_shutdown(baserlib.OpcodeResource): }) +class R_2_instances_name_setmem(baserlib.OpcodeResource): + /2/instances/[instance_name]/setmem resource. + + + PUT_OPCODE = opcodes.OpInstanceSetMemory + + def GetPutOpInput(self): +Modifies an instance's runtime memory + + +return (self.request_body, { + instance_name: self.items[0], + memory: self._checkIntVariable(memory, default=None), I wonder if that is a sane default value. Wouldn't it be better to have a 0 (and therefore an int) here? I'm fine with None too, just test it please! René
Re: [PATCH master 3/4] set-mem rapi and tests
Am 9. Januar 2012 16:18 schrieb Guido Trotter ultrot...@google.com: --- a/doc/rapi.rst +++ b/doc/rapi.rst +``/2/instances/[instance_name]/setmem`` No, why is this not part of “OpInstanceModify”? Michael
Re: [PATCH master 3/4] set-mem rapi and tests
On Tue, Jan 10, 2012 at 10:06:23AM -0200, Michael Hanselmann wrote: Am 9. Januar 2012 16:18 schrieb Guido Trotter ultrot...@google.com: --- a/doc/rapi.rst +++ b/doc/rapi.rst +``/2/instances/[instance_name]/setmem`` No, why is this not part of “OpInstanceModify”? That's what I asked too on 1/4 and still waiting for an answer… iustin
Re: [PATCH master 3/4] set-mem rapi and tests
I thought it was slightly different as modify for now only modifies config, not runtime. But I can change it to adding a flag there instead. Can I still leave a gnt-instance set-mem command, calling that? It'll be easier to find. Guido G On Jan 10, 2012 12:08 PM, Iustin Pop ius...@google.com wrote: On Tue, Jan 10, 2012 at 10:06:23AM -0200, Michael Hanselmann wrote: Am 9. Januar 2012 16:18 schrieb Guido Trotter ultrot...@google.com: --- a/doc/rapi.rst +++ b/doc/rapi.rst +``/2/instances/[instance_name]/setmem`` No, why is this not part of “OpInstanceModify”? That's what I asked too on 1/4 and still waiting for an answer… iustin
Re: [PATCH master 3/4] set-mem rapi and tests
Am 10. Januar 2012 11:44 schrieb Guido Trotter ultrot...@google.com: I thought it was slightly different as modify for now only modifies config, not runtime. But I can change it to adding a flag there instead. Add it to “modify”. There are other flags for which it would be good if they could be changed at runtime. Can I still leave a gnt-instance set-mem command, calling that? It'll be easier to find. Maybe, but it's certainly more confusing. Consistency is very important. Michael
Re: [PATCH master 3/4] set-mem rapi and tests
On Tue, Jan 10, 2012 at 11:46:50AM -0200, Michael Hanselmann wrote: Am 10. Januar 2012 11:44 schrieb Guido Trotter ultrot...@google.com: I thought it was slightly different as modify for now only modifies config, not runtime. But I can change it to adding a flag there instead. Add it to “modify”. There are other flags for which it would be good if they could be changed at runtime. Can I still leave a gnt-instance set-mem command, calling that? It'll be easier to find. Maybe, but it's certainly more confusing. Consistency is very important. We don't want two commands that modify the memory. And especially not one top-level that is memory specific. iustin
Re: [PATCH master 3/4] set-mem rapi and tests
On Tue, Jan 10, 2012 at 15:17, Iustin Pop ius...@google.com wrote: On Tue, Jan 10, 2012 at 11:46:50AM -0200, Michael Hanselmann wrote: Am 10. Januar 2012 11:44 schrieb Guido Trotter ultrot...@google.com: I thought it was slightly different as modify for now only modifies config, not runtime. But I can change it to adding a flag there instead. Add it to “modify”. There are other flags for which it would be good if they could be changed at runtime. Can I still leave a gnt-instance set-mem command, calling that? It'll be easier to find. Maybe, but it's certainly more confusing. Consistency is very important. We don't want two commands that modify the memory. And especially not one top-level that is memory specific. I see that from the point of view how the instance is being left. If the set-memory also modifies the value in the config when the instance starts up next time, modify is the right place. For temporary effects this might be confusing. Just my 2 cents. René
Re: [PATCH master 3/4] set-mem rapi and tests
On Tue, Jan 10, 2012 at 03:28:25PM +0100, René Nussbaumer wrote: On Tue, Jan 10, 2012 at 15:17, Iustin Pop ius...@google.com wrote: On Tue, Jan 10, 2012 at 11:46:50AM -0200, Michael Hanselmann wrote: Am 10. Januar 2012 11:44 schrieb Guido Trotter ultrot...@google.com: I thought it was slightly different as modify for now only modifies config, not runtime. But I can change it to adding a flag there instead. Add it to “modify”. There are other flags for which it would be good if they could be changed at runtime. Can I still leave a gnt-instance set-mem command, calling that? It'll be easier to find. Maybe, but it's certainly more confusing. Consistency is very important. We don't want two commands that modify the memory. And especially not one top-level that is memory specific. I see that from the point of view how the instance is being left. If the set-memory also modifies the value in the config when the instance starts up next time, modify is the right place. For temporary effects this might be confusing. Hmm, right. But then I'd make it a different key (e.g. running-mem or such), but still in instance modify. iustin
Re: [PATCH master 3/4] set-mem rapi and tests
On Tue, Jan 10, 2012 at 15:29, Iustin Pop ius...@google.com wrote: On Tue, Jan 10, 2012 at 03:28:25PM +0100, René Nussbaumer wrote: On Tue, Jan 10, 2012 at 15:17, Iustin Pop ius...@google.com wrote: On Tue, Jan 10, 2012 at 11:46:50AM -0200, Michael Hanselmann wrote: Am 10. Januar 2012 11:44 schrieb Guido Trotter ultrot...@google.com: I thought it was slightly different as modify for now only modifies config, not runtime. But I can change it to adding a flag there instead. Add it to “modify”. There are other flags for which it would be good if they could be changed at runtime. Can I still leave a gnt-instance set-mem command, calling that? It'll be easier to find. Maybe, but it's certainly more confusing. Consistency is very important. We don't want two commands that modify the memory. And especially not one top-level that is memory specific. I see that from the point of view how the instance is being left. If the set-memory also modifies the value in the config when the instance starts up next time, modify is the right place. For temporary effects this might be confusing. Hmm, right. But then I'd make it a different key (e.g. running-mem or such), but still in instance modify. WFM. René
Re: [PATCH master 3/4] set-mem rapi and tests
Am 10. Januar 2012 12:29 schrieb Iustin Pop ius...@google.com: Hmm, right. But then I'd make it a different key (e.g. running-mem or such), but still in instance modify. Or add a new parameter “--live” to apply the changes right away. Michael
Re: [PATCH master 3/4] set-mem rapi and tests
We still need --running-mem: this is meant for ballooning without changing min and max, which are the only values we currently save. Guido On Jan 10, 2012 3:47 PM, Michael Hanselmann han...@google.com wrote: Am 10. Januar 2012 12:29 schrieb Iustin Pop ius...@google.com: Hmm, right. But then I'd make it a different key (e.g. running-mem or such), but still in instance modify. Or add a new parameter “--live” to apply the changes right away. Michael