@@ -103,12 +103,23 @@ def populate_sub_parser_by_class(cls, sub_parser):
103103 for x in cls .optionalCreateAttrs ]
104104
105105 elif action_name == UPDATE :
106+ id_attr = cls .idAttr .replace ('_' , '-' )
107+ sub_parser_action .add_argument ("--%s" % id_attr ,
108+ required = True )
109+
110+ attrs = (cls .requiredUpdateAttrs
111+ if cls .requiredUpdateAttrs is not None
112+ else cls .requiredCreateAttrs )
106113 [sub_parser_action .add_argument ("--%s" % x .replace ('_' , '-' ),
107114 required = True )
108- for x in cls .requiredCreateAttrs ]
115+ for x in attrs ]
116+
117+ attrs = (cls .optionalUpdateAttrs
118+ if cls .optionalUpdateAttrs is not None
119+ else cls .optionalCreateAttrs )
109120 [sub_parser_action .add_argument ("--%s" % x .replace ('_' , '-' ),
110121 required = False )
111- for x in cls . optionalCreateAttrs ]
122+ for x in attrs ]
112123
113124 if cls in extra_actions :
114125 for action_name in sorted (extra_actions [cls ]):
@@ -182,7 +193,7 @@ def do_delete(cls, gl, what, args):
182193 if not cls .canDelete :
183194 die ("%s objects can't be deleted" % what )
184195
185- o = do_get (cls , args , what , args )
196+ o = do_get (cls , gl , what , args )
186197 try :
187198 o .delete ()
188199 except Exception as e :
@@ -193,7 +204,7 @@ def do_update(cls, gl, what, args):
193204 if not cls .canUpdate :
194205 die ("%s objects can't be updated" % what )
195206
196- o = do_get (cls , args , what , args )
207+ o = do_get (cls , gl , what , args )
197208 try :
198209 for k , v in args .items ():
199210 o .__dict__ [k ] = v
0 commit comments