X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=rwlaunchpad%2Fplugins%2Frwautoscaler%2Frift%2Ftasklets%2Frwautoscaler%2Fsubscribers.py;h=30d494f50aeb2022ea5de8ebf716aedfbdb9bb30;hb=f314b4af9744068a7ed7a6a6314220c3aa857523;hp=04185b6802151586d814c1074ddefe885d385c2a;hpb=255ff03a528a3090ce7f46f0a63b65da3e6f9bcf;p=osm%2FSO.git diff --git a/rwlaunchpad/plugins/rwautoscaler/rift/tasklets/rwautoscaler/subscribers.py b/rwlaunchpad/plugins/rwautoscaler/rift/tasklets/rwautoscaler/subscribers.py index 04185b68..30d494f5 100644 --- a/rwlaunchpad/plugins/rwautoscaler/rift/tasklets/rwautoscaler/subscribers.py +++ b/rwlaunchpad/plugins/rwautoscaler/rift/tasklets/rwautoscaler/subscribers.py @@ -1,6 +1,6 @@ -# -# Copyright 2016 RIFT.IO Inc +# +# Copyright 2016-2017 RIFT.IO Inc # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,26 +15,41 @@ # limitations under the License. # +import gi + import rift.mano.dts as mano_dts +gi.require_version('RwKeyspec', '1.0') +from gi.repository.RwKeyspec import quoted_key class NsrMonParamSubscriber(mano_dts.AbstractOpdataSubscriber): """Registers for NSR monitoring parameter changes. - + Attributes: monp_id (str): Monitoring Param ID nsr_id (str): NSR ID """ - def __init__(self, log, dts, loop, nsr_id, monp_id=None, callback=None): - super().__init__(log, dts, loop, callback) + def __init__(self, log, dts, loop, project, nsr_id, monp_id=None, callback=None): + super().__init__(log, dts, loop, project, callback) self.nsr_id = nsr_id self.monp_id = monp_id def get_xpath(self): - return ("D,/nsr:ns-instance-opdata/nsr:nsr" + - "[nsr:ns-instance-config-ref='{}']".format(self.nsr_id) + + return self.project.add_project("D,/nsr:ns-instance-opdata/nsr:nsr" + + "[nsr:ns-instance-config-ref={}]".format(quoted_key(self.nsr_id)) + "/nsr:monitoring-param" + - ("[nsr:id='{}']".format(self.monp_id) if self.monp_id else "")) + ("[nsr:id={}]".format(quoted_key(self.monp_id)) if self.monp_id else "")) +class NsrScalingGroupRecordSubscriber(mano_dts.AbstractOpdataSubscriber): + def __init__(self, log, dts, loop, project, nsr_id, scaling_group, callback=None): + super().__init__(log, dts, loop, project, callback) + self.nsr_id = nsr_id + self.scaling_group = scaling_group + + def get_xpath(self): + return self.project.add_project("D,/nsr:ns-instance-opdata/nsr:nsr" + + "[nsr:ns-instance-config-ref={}]".format(quoted_key(self.nsr_id)) + + "/nsr:scaling-group-record" + + "[nsr:scaling-group-name-ref={}]/instance".format(quoted_key(self.scaling_group)))