Ravi Nori has uploaded a new change for review. Change subject: cli: construct object using factory on update, rather than fetching live instance ......................................................................
cli: construct object using factory on update, rather than fetching live instance Construct object using factory and set parameters to it instead of fetching it from server and updating it. Change-Id: I34a910a7f1ecae5385e2a6dcd2297a65f419bc9c Bug-Url: https://bugzilla.redhat.com/950684 Signed-off-by: Ravi Nori <[email protected]> --- M src/ovirtcli/command/update.py 1 file changed, 20 insertions(+), 2 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine-cli refs/changes/57/14557/1 diff --git a/src/ovirtcli/command/update.py b/src/ovirtcli/command/update.py index 8cea028..1feb0c6 100644 --- a/src/ovirtcli/command/update.py +++ b/src/ovirtcli/command/update.py @@ -16,6 +16,10 @@ from ovirtcli.command.command import OvirtCommand +from ovirtsdk.utils.parsehelper import ParseHelper +from ovirtcli.utils.methodhelper import MethodHelper +from ovirtsdk.infrastructure import brokers +from ovirtsdk.utils.ordereddict import OrderedDict from ovirtcli.utils.typehelper import TypeHelper from cli.messages import Messages @@ -149,13 +153,27 @@ if resource is None: self.error(Messages.Error.NO_SUCH_OBJECT % (args[0], args[1])) elif hasattr(resource, 'update'): - obj = self.update_object_data(resource, opts) - result = self.execute_method(obj, 'update', opts) + param_obj = self.create_params_obj() + param_obj = self.update_object_data(param_obj, opts) + if hasattr(resource, 'superclass'): + setattr(param_obj, 'id', getattr(resource, 'id')) + setattr(resource, 'superclass', param_obj ) + result = self.execute_method(resource, 'update', opts) else: self.error(Messages.Error.OBJECT_IS_IMMUTABLE % (args[0], args[1])) self.context.formatter.format(self.context, result) + def create_params_obj(self): + """Create an instance of param object.""" + args = self.arguments + params_xml_type = ParseHelper.getXmlType(args[0]) + param_obj = None + if params_xml_type: + param_obj = params_xml_type.factory() + print ' param obj = ' + str(param_obj) + return param_obj + def show_help(self): """Show help for "update".""" -- To view, visit http://gerrit.ovirt.org/14557 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I34a910a7f1ecae5385e2a6dcd2297a65f419bc9c Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine-cli Gerrit-Branch: master Gerrit-Owner: Ravi Nori <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
