yadutaf / ovh-cli

Bare simple Command Line Interface (CLI) for OVH.
Other
31 stars 13 forks source link

Update operation fail with error #3

Closed AsLY4 closed 8 years ago

AsLY4 commented 8 years ago

I try to update a object (dedicated-server for example)

ovh-eu dedicated-server ns7654321.ip-1-2-3.eu update --monitoring false

Return :

Traceback (most recent call last): File "./ovh-eu", line 194, in verb, method, arguments = parser.parse('', args) File "/opt/ovh-cli/ovhcli/parser.py", line 185, in parse return parser.parse(base_url, args) File "/opt/ovh-cli/ovhcli/parser.py", line 199, in parse return parser.parse(base_url, args) File "/opt/ovh-cli/ovhcli/parser.py", line 191, in parse args = self.parse_action_params(verb, args, base_url) File "/opt/ovh-cli/ovhcli/parser.py", line 250, in parse_action_params '--'+param['name'], KeyError: 'name'

yadutaf commented 8 years ago

This one is a nasty one. https://api.ovh.com/console/#/dedicated/server/{serviceName}#PUT expects a param of type "dedicated.server.Dedicated". But of course, this does not exist. So you have to expand the object. Won't be fun to do.

yadutaf commented 8 years ago
./ovh-eu --debug dedicated-server ks1234.kimsufi.com update --monitoring true 
PUT, /dedicated/server/ks390517.kimsufi.com({'monitoring': 'true'})
Success

Can you confirm this fix works for you and does not break anything else ?

AsLY4 commented 8 years ago

fix for another domain {IP}.

./ovh-eu ip 8.9.1.2/32 update --description Message
Success

But for dedicated-server, monitoring become mandatory and other arguments still unknow

./ovh-eu dedicated-server ns7654321.ip-1-2-3.eu update --bootId 22 --monitoring true
usage: PUT /dedicated/server/ns7654321.ip-1-2-3.eu [-h] --monitoring
                                                        MONITORING
PUT /dedicated/server/ns7654321.ip-1-2-3.eu: error: unrecognized arguments: --bootId 22
yadutaf commented 8 years ago

Stupid keybord...

diff --git a/ovhcli/parser.py b/ovhcli/parser.py
index 8d28ec2..71d0cff 100644
--- a/ovhcli/parser.py
+++ b/ovhcli/parser.py
@@ -246,7 +246,7 @@ class ArgParser(object):
                             not bool(prop.get('canBeNull', 0)),
                             prop.get('description', ''),
                         )
-                        return
+                    return
                 else:
                     pass
             else:

Will yield:

usage: PUT /dedicated/server/ks390517.kimsufi.com [-h] --monitoring MONITORING
                                                  [--rescueMail RESCUEMAIL]
                                                  [--bootId BOOTID] --state
                                                  {error,hacked,hackedBlocked,ok}
                                                  [--rootDevice ROOTDEVICE]

optional arguments:
  -h, --help            show this help message and exit
  --monitoring MONITORING
                        Icmp monitoring state
  --rescueMail RESCUEMAIL
  --bootId BOOTID
  --state {error,hacked,hackedBlocked,ok}
  --rootDevice ROOTDEVICE
yadutaf commented 8 years ago

The issue above is fixed, and all parameters have been made option on "update". Can you confirm ?

AsLY4 commented 8 years ago

Yes it's good. ./ovh-eu dedicated-server ns7654321.ip-1-2-3.eu update --monitoring false --state ok --bootId 1 Success

But in fact --monitoring and --state parameters seems to be mandatory (maybe in API definition) usage: PUT /dedicated/server/ns7654321.ip-1-2-3.eu [-h] --monitoring MONITORING [--rescueMail RESCUEMAIL] [--bootId BOOTID] --state {error,hacked,hackedBlocked,ok} [--rootDevice ROOTDEVICE]

yadutaf commented 8 years ago

Fix pushed to master. Thx!