Arubacloud / pyArubaCloud

Python Interface for ArubaCloud IaaS Service
Apache License 2.0
33 stars 26 forks source link

Upgrade Smart VM #23

Closed Melius-Group closed 8 years ago

Melius-Group commented 8 years ago

Hi, please help me, how can I upgrade smart vm? I found just edit pro vm hardware.

Thank You! Regards: Gabor

szepeviktor commented 8 years ago

Smart instances can only be cloned manually.

szepeviktor commented 8 years ago

For example https://github.com/szepeviktor/debian-server-tools/blob/master/clone-server-debconf.sh

Melius-Group commented 8 years ago

The web dashboard allows to upgrade smart instances too. eg: small to large So may be api can do this...

blackms commented 8 years ago

Hello, at the moment is not possible to upgrade a VM via API. I'm going to add the method.

Melius-Group commented 8 years ago

Thank You. When expected?

blackms commented 8 years ago

I just added the method on the library with the relative example, try it.

Melius-Group commented 8 years ago

The method can't work for me.

import argparse

from ArubaCloud.PyArubaAPI import CloudInterface

if name == 'main': parser = argparse.ArgumentParser() parser.add_argument('-d', '--datacenter', help='Specify datacenter to login.', action='store', dest='dc') parser.add_argument('-p', '--pattern', help='Specify pattern to search.', action='store', dest='pattern') parser.add_argument('-u', '--username', help='Specify username.', action='store', dest='username') parser.add_argument('-w', '--password', help='Specify password.', action='store', dest='password') parser.add_argument('-n', '--new_pkg', help='Specify password.', action='store', dest='newpkg') p = parser.parse_args()

i = CloudInterface(dc=p.dc)
i.login(username=p.username, password=p.password, load=True)

i.get_servers()

#vm = i.vmlist.find(name='Test')[0]
vm = i.get_vm(pattern=p.pattern)[0]
vm.upgrade_vm(package_id=p.newpkg)

And I initiate it with python /pyArubaCloud/examples/upgrade_smart.py -d 6 -u FHU-4_5 -w pa_**0-p -p Teszt -n 2

Nothing happen.

When I run this python /pyArubaCloud/examples/upgrade_smart.py -d 6 -u FHU-4_5 -w pa_**0-p -p Teszt -n 20

Nothing happen, but the init.py contains if package_id > 4 or package_id <= 0: return MalformedJsonRequest("Packages available are: 1, 2, 3, 4.")

Why I can't get any response?

blackms commented 8 years ago

In the first case, you should have upgraded the vm correctly, call the method in this way to see the response:

vm.upgrade_vm(package_id=p.newpkg, debug=True)

Let me know.

Melius-Group commented 8 years ago

Nothing, no response, just some wait and shows prompt. If I mistype the function name, drop error, but if correct seems exit with ture. If I hardcode debug=True in init.py also nothing... no error, no json output, nothing...

blackms commented 8 years ago

I tried right now, and I'm able to upgrade the VM, have you turned off the vm before call the API method?

Melius-Group commented 8 years ago

yes pf course,, but the fuction examine the state of vm and drop error msg if the state not equal 2.... I tryed and drop exception as required:

Traceback (most recent call last): File "/pyArubaCloud/examples/upgrade_smart.py", line 21, in vm.upgrade_vm(package_id=p.newpkg, debug=True) File "build/bdist.linux-x86_64/egg/ArubaCloud/objects/VmTypes/init.py", line 22, in upgrade_vm

But if status stopped, and run the script,... no response...

Melius-Group commented 8 years ago

This syntax fails: vm.upgrade_vm(package_id=p.newpkg)

If I use vm.upgrade_vm(package_id=2) it was correct....

I add parser.add_argument('-g', '--newpkg', help='Specify new package id.', action='store', dest='newpkg')

and use -g 2 when i start script....

blackms commented 8 years ago

Oh, maybe because u were storing it as string and not as integer. I need to add documentation for methods.

Melius-Group commented 8 years ago

vm.upgrade_vm(package_id=int(p.newpkg)) solv the problem :))) Sorry :) I'm waiting for upgrade methode for pro vm, and os change methodes :)) Thank You for lots of help

blackms commented 8 years ago

Perfect, I'm glad that it works. I have to ask you to open another Issue for upgrade_vm method on Pro Servers, so we can track it easily.

I'm going to close this ticket now.

Thank you!