Royce Lv has uploaded a new change for review.
Change subject: [WIP]extend setPolicy to support mom multi-policy ......................................................................
[WIP]extend setPolicy to support mom multi-policy
set all policies at a single str brings difficulty to enable and disable a single policy. extend the setPolicy from str to policyDict. Depend on mom implementation to be ready.
Change-Id: I94e601a8b1cb30d43005918dbee7d83c64f7f19b Signed-off-by: Royce Lvlvroyce@linux.vnet.ibm.com --- M tests/functional/momTests.py M vdsm/API.py M vdsm/BindingXMLRPC.py M vdsm/momIF.py M vdsm_api/vdsmapi-schema.json M vdsm_cli/vdsClient.py 6 files changed, 22 insertions(+), 12 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/52/9152/1
diff --git a/tests/functional/momTests.py b/tests/functional/momTests.py index 1981e05..30da052 100644 --- a/tests/functional/momTests.py +++ b/tests/functional/momTests.py @@ -44,8 +44,9 @@ (Host.Control "ksm_run" %d) (Host.Control "ksm_pages_to_scan" %d)""" % \ (run, pages_to_scan) + testPolicyDict = {"ksm": testPolicyStr} s = vdscli.connect() - r = s.setMOMPolicy(testPolicyStr) + r = s.setMOMPolicy(testPolicyDict) self.assertEqual(r['status']['code'], 0, str(r))
# Wait for the policy taking effect @@ -54,3 +55,10 @@ hostStats = s.getVdsStats()['info'] self.assertEqual(bool(run), hostStats['ksmState']) self.assertEqual(pages_to_scan, hostStats['ksmPages']) + + def testMultiPolicy(self): + testPolicyDict = {"10_test": "(+1 1)", "20_test": "(-1 1)"} + + s = vdscli.connect() + r = s.setMOMPolicy(testPolicyDict) + self.assertEqual(r['status']['code'], 0, str(r)) diff --git a/vdsm/API.py b/vdsm/API.py index 896767c..7c1dad9 100644 --- a/vdsm/API.py +++ b/vdsm/API.py @@ -1329,9 +1329,11 @@ def getAllTasks(self): return self._irs.getAllTasks()
- def setMOMPolicy(self, policy): + def setMOMPolicy(self, policyDict): try: - self._cif.mom.setPolicy(policy) + for policyName, policyStr in policyDict.iteritems(): + self._cif.mom.setPolicyItem(policyName, policyStr) + return dict(status=doneCode) except: return errCode['momErr'] diff --git a/vdsm/BindingXMLRPC.py b/vdsm/BindingXMLRPC.py index b833cf3..de35a3f 100644 --- a/vdsm/BindingXMLRPC.py +++ b/vdsm/BindingXMLRPC.py @@ -376,9 +376,9 @@ api = API.Global() return api.setLogLevel(level)
- def setMOMPolicy(self, policy): + def setMOMPolicy(self, policyDict): api = API.Global() - return api.setMOMPolicy(policy) + return api.setMOMPolicy(policyDict)
def domainActivate(self, sdUUID, spUUID, options=None): domain = API.StorageDomain(sdUUID, spUUID) diff --git a/vdsm/momIF.py b/vdsm/momIF.py index 827e9e4..c95d5fc 100644 --- a/vdsm/momIF.py +++ b/vdsm/momIF.py @@ -47,9 +47,9 @@ ret['ksmCpu'] = stats['ksmd_cpu_usage'] return ret
- def setPolicy(self, policyStr): + def setPolicyItem(self, policyName, policyStr): # mom.setPolicy will raise an exception on failure. - self._mom.setPolicy(policyStr) + self._mom.setNamedPolicy(policyName, policyStr)
def stop(self): if self._mom is not None: diff --git a/vdsm_api/vdsmapi-schema.json b/vdsm_api/vdsmapi-schema.json index 5f0b391..03bc7c1 100644 --- a/vdsm_api/vdsmapi-schema.json +++ b/vdsm_api/vdsmapi-schema.json @@ -444,12 +444,12 @@ # # Set MOM policy for different level of overcommitments. # -# @policy: MOM policy string. +# @policyDict: MOM policy dictionary. # # Since: 4.10.0 ## {'command': {'class': 'Host', 'name': 'setMOMPolicy'}, - 'data': {'policy': 'str'}} + 'data': {'policyDict': 'StringMap'}}
## # @TaskDetails: diff --git a/vdsm_cli/vdsClient.py b/vdsm_cli/vdsClient.py index 8cb78ed..b65ecd7 100644 --- a/vdsm_cli/vdsClient.py +++ b/vdsm_cli/vdsClient.py @@ -1387,8 +1387,8 @@ return stats['status']['code'], stats['status']['message'] return 0, ''
- def do_setMOMPolicy(self, policyFile): - stats = self.s.setMOMPolicy(policyFile) + def do_setMOMPolicy(self, policyDict): + stats = self.s.setMOMPolicy(policyDict) if stats['status']['code']: return stats['status']['code'], stats['status']['message'] return 0, '' @@ -2207,7 +2207,7 @@ ' level (10=DEBUG, 50=CRITICAL' )), 'setMOMPolicy': (serv.do_setMOMPolicy, - ('<policyfile>', 'set MOM policy')), + ('<policyDict>', 'set MOM policy')), 'deleteImage': (serv.deleteImage, ('<sdUUID> <spUUID> <imgUUID> [<postZero>] [<force>]', 'Delete Image folder with all volumes.',
-- To view, visit http://gerrit.ovirt.org/9152 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange Gerrit-Change-Id: I94e601a8b1cb30d43005918dbee7d83c64f7f19b Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Royce Lv lvroyce@linux.vnet.ibm.com
Itamar Heim has posted comments on this change.
Change subject: [WIP]extend setPolicy to support mom multi-policy ......................................................................
Patch Set 1:
ping?
Itamar Heim has abandoned this change.
Change subject: [WIP]extend setPolicy to support mom multi-policy ......................................................................
Abandoned
no comment for 30 days post last ping. abandoning. please re-open if/when relevant and/or ping reviewers directly / promote discussion about the patch in the mailing list.
vdsm-patches@lists.fedorahosted.org