Vinzenz Feenstra has posted comments on this change.
Change subject: GuestIF Refactoring
......................................................................
Patch Set 3:
(3 comments)
http://gerrit.ovirt.org/#/c/24618/3/vdsm/guestIF.py
File vdsm/guestIF.py:
Line 51: self.log = agent.log
Line 52: self._agent = agent
Line 53:
Line 54: def __call__(self, message, args):
Line 55: handler = getattr(self, message.replace('-', '_'), None)
maybe this is a good case for (something inspired to) the
Done
Line 56: if handler:
Line 57: handler(args)
Line 58: else:
Line 59: raise UnknownMessageError(message, args)
Line 70: def os_version(self, args):
Line 71: self._agent.guestInfo['guestOs'] = args['version']
Line 72:
Line 73: def session_lock(self, args):
Line 74: self.agent.guestInfo['session'] = 'Locked'
typo? here and below
Done
Line 75:
Line 76: def session_logoff(self, args):
Line 77: self.agent.guestInfo['session'] = 'LoggedOff'
Line 78:
Line 76: def session_logoff(self, args):
Line 77: self.agent.guestInfo['session'] = 'LoggedOff'
Line 78:
Line 79: def session_logon(self, args):
Line 80: self.agent.guestInfo['session'] = 'UserLoggedOn'
all the above are maybe repleacable with some generic dict juggling,
but I
The only thing I could imagine is something like:
session_logoff = _session_fun('LoggedOff')
os_version = _assign_fun('guestOs', 'version')
applications = _assign_fun('appsList', 'applications')
but this makes it rather hacky than nice
There will be on top of this refactoring some unit tests, so issues like this typo should
be caught, and the implementation is rather straight forward than saving some lines here
and there.
Line 81:
Line 82: def session_unlock(self, args):
Line 83: self.agent.guestInfo['session'] = 'Active'
Line 84:
--
To view, visit
http://gerrit.ovirt.org/24618
To unsubscribe, visit
http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib357d770a26ef1dc80b89a32bf6808551a7d622d
Gerrit-PatchSet: 3
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Vinzenz Feenstra <vfeenstr(a)redhat.com>
Gerrit-Reviewer: Francesco Romani <fromani(a)redhat.com>
Gerrit-Reviewer: Vinzenz Feenstra <vfeenstr(a)redhat.com>
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: Yes