2 # Copyright 2016 RIFT.IO Inc
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
18 import concurrent
.futures
22 gi
.require_version('RwNsrYang', '1.0')
24 from gi
.repository
import (
31 gi
.require_version('RwKeyspec', '1.0')
32 from gi
.repository
.RwKeyspec
import quoted_key
35 import rift
.mano
.utils
.juju_api
as juju
38 class ConfigAgentAccountNotFound(Exception):
42 class JujuClient(object):
43 def __init__(self
, log
, ip
, port
, user
, passwd
):
50 self
._api
= juju
.JujuApi(log
=log
,
52 user
=user
, secret
=passwd
)
54 def validate_account_creds(self
):
55 """Validate the account credentials.
57 Verifies if the account credentials can connect and login to a Juju
58 controller at the provided IP address.
61 details
= "Connection status not known."
63 loop
= asyncio
.new_event_loop()
64 asyncio
.set_event_loop(loop
)
66 loop
.run_until_complete(asyncio
.gather(
71 except Exception as e
:
74 msg
= "JujuClient: Connection Failed: %s", str(e
)
80 self
._log
.error("Success reached.")
82 details
= "Connection was successful"
83 self
._log
.info("JujuClient: Connection Successful")
87 return RwConfigAgentYang
.YangData_RwProject_Project_ConfigAgent_Account_ConnectionStatus(
93 class ConfigAgentAccount(object):
94 def __init__(self
, log
, account_msg
):
96 self
._account
_msg
= account_msg
.deep_copy()
98 if account_msg
.account_type
== "juju":
99 self
._cfg
_agent
_client
_plugin
= JujuClient(
101 account_msg
.juju
.ip_address
,
102 account_msg
.juju
.port
,
103 account_msg
.juju
.user
,
104 account_msg
.juju
.secret
)
106 self
._cfg
_agent
_client
_plugin
= None
108 self
._status
= RwConfigAgentYang
.YangData_RwProject_Project_ConfigAgent_Account_ConnectionStatus(
110 details
="Connection status lookup not started"
113 self
._validate
_task
= None
117 return self
._account
_msg
.name
120 def account_msg(self
):
121 return self
._account
_msg
124 def account_type(self
):
125 return self
._account
_msg
.account_type
128 def connection_status(self
):
131 def update_from_cfg(self
, cfg
):
132 self
._log
.debug("Updating parent ConfigAgentAccount to %s", cfg
)
133 raise NotImplementedError("Update config agent account not yet supported")
136 def validate_cfg_agent_account_credentials(self
, loop
):
137 self
._log
.debug("Validating Config Agent Account %s, credential status %s", self
._account
_msg
, self
._status
)
139 self
._status
= RwConfigAgentYang
.YangData_RwProject_Project_ConfigAgent_Account_ConnectionStatus(
141 details
="Config Agent account connection validation in progress"
144 if self
._cfg
_agent
_client
_plugin
is None:
145 self
._status
= RwConfigAgentYang
.YangData_RwProject_Project_ConfigAgent_Account_ConnectionStatus(
147 details
="Config Agent account does not support validation of account creds"
151 status
= yield from loop
.run_in_executor(
153 self
._cfg
_agent
_client
_plugin
.validate_account_creds
,
155 self
._status
= RwConfigAgentYang
.YangData_RwProject_Project_ConfigAgent_Account_ConnectionStatus
.from_dict(status
.as_dict())
156 except Exception as e
:
157 self
._status
= RwConfigAgentYang
.YangData_RwProject_Project_ConfigAgent_Account_ConnectionStatus(
159 details
="Error - " + str(e
)
162 self
._log
.info("Got config agent account validation response: %s", self
._status
)
164 def start_validate_credentials(self
, loop
):
165 if self
._validate
_task
is not None:
166 self
._validate
_task
.cancel()
167 self
._validate
_task
= None
169 self
._validate
_task
= asyncio
.ensure_future(
170 self
.validate_cfg_agent_account_credentials(loop
),
174 class CfgAgentDtsOperdataHandler(object):
175 def __init__(self
, dts
, log
, loop
, project
):
179 self
._project
= project
181 self
.cfg_agent_accounts
= {}
182 self
._show
_reg
= None
185 def add_cfg_agent_account(self
, account_msg
):
186 account
= ConfigAgentAccount(self
._log
, account_msg
)
187 self
.cfg_agent_accounts
[account
.name
] = account
188 self
._log
.info("ConfigAgent Operdata Handler added. Starting account validation")
190 account
.start_validate_credentials(self
._loop
)
192 def delete_cfg_agent_account(self
, account_name
):
193 del self
.cfg_agent_accounts
[account_name
]
194 self
._log
.info("ConfigAgent Operdata Handler deleted.")
196 def get_saved_cfg_agent_accounts(self
, cfg_agent_account_name
):
197 ''' Get Config Agent Account corresponding to passed name, or all saved accounts if name is None'''
198 saved_cfg_agent_accounts
= []
200 if cfg_agent_account_name
is None or cfg_agent_account_name
== "":
201 cfg_agent_accounts
= list(self
.cfg_agent_accounts
.values())
202 saved_cfg_agent_accounts
.extend(cfg_agent_accounts
)
203 elif cfg_agent_account_name
in self
.cfg_agent_accounts
:
204 account
= self
.cfg_agent_accounts
[cfg_agent_account_name
]
205 saved_cfg_agent_accounts
.append(account
)
207 errstr
= "Config Agent account {} does not exist".format(cfg_agent_account_name
)
208 raise KeyError(errstr
)
210 return saved_cfg_agent_accounts
213 def _register_show_status(self
):
214 def get_xpath(cfg_agent_name
=None):
215 return "D,/rw-config-agent:config-agent/account{}/connection-status".format(
216 "[name=%s]" % quoted_key(cfg_agent_name
) if cfg_agent_name
is not None else ''
220 def on_prepare(xact_info
, action
, ks_path
, msg
):
221 path_entry
= RwConfigAgentYang
.YangData_RwProject_Project_ConfigAgent_Account
.schema().keyspec_to_entry(ks_path
)
222 cfg_agent_account_name
= path_entry
.key00
.name
223 self
._log
.debug("Got show cfg_agent connection status request: %s", ks_path
.create_string())
226 saved_accounts
= self
.get_saved_cfg_agent_accounts(cfg_agent_account_name
)
227 for account
in saved_accounts
:
228 connection_status
= account
.connection_status
229 self
._log
.debug("Responding to config agent connection status request: %s", connection_status
)
230 xpath
= self
._project
.add_project(get_xpath(account
.name
))
231 xact_info
.respond_xpath(
232 rwdts
.XactRspCode
.MORE
,
234 msg
=account
.connection_status
,
236 except KeyError as e
:
237 self
._log
.warning(str(e
))
238 xact_info
.respond_xpath(rwdts
.XactRspCode
.NA
)
241 xact_info
.respond_xpath(rwdts
.XactRspCode
.ACK
)
243 xpath
= self
._project
.add_project(get_xpath())
244 self
._show
_reg
= yield from self
._dts
.register(
246 handler
=rift
.tasklets
.DTS
.RegistrationHandler(
247 on_prepare
=on_prepare
),
248 flags
=rwdts
.Flag
.PUBLISHER
,
251 def _register_validate_rpc(self
):
253 return "/rw-config-agent:update-cfg-agent-status"
256 def on_prepare(xact_info
, action
, ks_path
, msg
):
257 if not msg
.has_field("cfg_agent_account"):
258 raise ConfigAgentAccountNotFound("Config Agent account name not provided")
260 cfg_agent_account_name
= msg
.cfg_agent_account
262 if not self
._project
.rpc_check(msg
, xact_info
=xact_info
):
266 account
= self
.cfg_agent_accounts
[cfg_agent_account_name
]
268 raise ConfigAgentAccountNotFound("Config Agent account name %s not found" % cfg_agent_account_name
)
270 account
.start_validate_credentials(self
._loop
)
272 xact_info
.respond_xpath(rwdts
.XactRspCode
.ACK
)
274 self
._rpc
_reg
= yield from self
._dts
.register(
276 handler
=rift
.tasklets
.DTS
.RegistrationHandler(
277 on_prepare
=on_prepare
279 flags
=rwdts
.Flag
.PUBLISHER
,
284 yield from self
._register
_show
_status
()
285 yield from self
._register
_validate
_rpc
()
287 def deregister(self
):
288 self
._show
_reg
.deregister()
289 self
._rpc
_reg
.deregister()
292 class ConfigAgentJob(object):
293 """A wrapper over the config agent job object, providing some
294 convenience functions.
296 YangData_RwProject_Project_NsInstanceOpdata_Nsr_ConfigAgentJob contains
303 # The normalizes the state terms from Juju to our yang models
305 STATUS_MAP
= {"completed": "success",
306 "pending" : "pending",
307 "running" : "pending",
308 "failed" : "failure"}
310 def __init__(self
, nsr_id
, job
, project
, tasks
=None):
313 nsr_id (uuid): ID of NSR record
314 job (YangData_RwProject_Project_NsInstanceOpdata_Nsr_ConfigAgentJob): Gi object
315 tasks: List of asyncio.tasks. If provided the job monitor will
316 use it to monitor the tasks instead of the execution IDs
321 self
._project
= project
328 return self
._job
.job_id
333 return self
._job
.job_name
336 def job_status(self
):
337 """Status of the job (success|pending|failure)"""
338 return self
._job
.job_status
341 def job_status(self
, value
):
342 """Setter for job status"""
343 self
._job
.job_status
= value
352 """Xpath of the job"""
353 return self
._project
.add_project(("D,/nsr:ns-instance-opdata" +
354 "/nsr:nsr[nsr:ns-instance-config-ref={}]" +
355 "/nsr:config-agent-job[nsr:job-id={}]"
356 ).format(quoted_key(self
.nsr_id
), quoted_key(str(self
.id))))
360 """Registration handle for the job"""
365 """Setter for registration handle"""
369 def convert_rpc_input_to_job(nsr_id
, rpc_output
, tasks
, project
):
370 """A helper function to convert the YangOutput_Nsr_ExecNsConfigPrimitive
371 to YangData_RwProject_Project_NsInstanceOpdata_Nsr_ConfigAgentJob (NsrYang)
374 nsr_id (uuid): NSR ID
375 rpc_output (YangOutput_Nsr_ExecNsConfigPrimitive): RPC output
376 tasks (list): A list of asyncio.Tasks
381 # Shortcuts to prevent the HUUGE names.
382 CfgAgentJob
= NsrYang
.YangData_RwProject_Project_NsInstanceOpdata_Nsr_ConfigAgentJob
383 CfgAgentVnfr
= NsrYang
.YangData_RwProject_Project_NsInstanceOpdata_Nsr_ConfigAgentJob_Vnfr
384 CfgAgentPrimitive
= NsrYang
.YangData_RwProject_Project_NsInstanceOpdata_Nsr_ConfigAgentJob_Vnfr_Primitive
385 CfgAgentPrimitiveParam
= NsrYang
.YangData_RwProject_Project_NsInstanceOpdata_Nsr_ConfigAgentJob_Vnfr_Primitive_Parameter
387 job
= CfgAgentJob
.from_dict({
388 "job_id": rpc_output
.job_id
,
389 "job_name" : rpc_output
.name
,
390 "job_status": "pending",
391 "triggered_by": rpc_output
.triggered_by
,
392 "create_time": rpc_output
.create_time
,
393 "job_status_details": rpc_output
.job_status_details
if rpc_output
.job_status_details
is not None else None,
394 "parameter": [param
.as_dict() for param
in rpc_output
.parameter
],
395 "parameter_group": [pg
.as_dict() for pg
in rpc_output
.parameter_group
]
398 for vnfr
in rpc_output
.vnf_out_list
:
399 vnfr_job
= CfgAgentVnfr
.from_dict({
400 "id": vnfr
.vnfr_id_ref
,
401 "vnf_job_status": "pending",
404 for primitive
in vnfr
.vnf_out_primitive
:
405 vnf_primitive
= CfgAgentPrimitive
.from_dict({
406 "name": primitive
.name
,
407 "execution_status": ConfigAgentJob
.STATUS_MAP
[primitive
.execution_status
],
408 "execution_id": primitive
.execution_id
,
409 "execution_error_details": primitive
.execution_error_details
,
412 # Copy over the input param
413 for param
in primitive
.parameter
:
414 vnf_primitive
.parameter
.append(
415 CfgAgentPrimitiveParam
.from_dict({
420 vnfr_job
.primitive
.append(vnf_primitive
)
422 job
.vnfr
.append(vnfr_job
)
424 return ConfigAgentJob(nsr_id
, job
, project
, tasks
)
427 class ConfigAgentJobMonitor(object):
428 """Job monitor: Polls the Juju controller and get the status.
430 If all Primitive are success, then vnf & nsr status will be "success"
431 If any one Primitive reaches a failed state then both vnf and nsr will fail.
435 def __init__(self
, dts
, log
, job
, executor
, loop
, config_plugin
):
440 job (ConfigAgentJob): ConfigAgentJob instance
441 executor (concurrent.futures): Executor for juju status api calls
442 loop (eventloop): Current event loop instance
443 config_plugin : Config plugin to be used.
448 self
.executor
= executor
449 self
.polling_period
= ConfigAgentJobMonitor
.POLLING_PERIOD
450 self
.config_plugin
= config_plugin
454 def _monitor_processes(self
, registration_handle
):
457 for process
in self
.job
.tasks
:
458 if isinstance(process
, asyncio
.subprocess
.Process
):
459 rc
= yield from process
.wait()
460 err
= yield from process
.stderr
.read()
464 rc
= yield from process
467 self
.log
.debug("Process {} returned rc: {}, err: {}".
468 format(process
, rc
, err
))
472 errs
+= "<success>{}</success>".format(err
)
474 errs
+= "<error>{}</error>".format(err
)
478 self
.job
.job_status
= "success"
480 self
.job
.job_status
= "failure"
483 self
.job
.job
.job_status_details
= errs
485 registration_handle
.update_element(self
.job
.xpath
, self
.job
.job
)
487 def get_execution_details(self
):
488 '''Get the error details from failed primitives'''
490 for vnfr
in self
.job
.job
.vnfr
:
491 for primitive
in vnfr
.primitive
:
492 if primitive
.execution_status
== "failure":
494 if primitive
.execution_error_details
:
495 errs
+= primitive
.execution_error_details
497 errs
+= '{}: Unknown error'.format(primitive
.name
)
500 if primitive
.execution_error_details
:
501 errs
+= '<{status}>{details}</{status}>'.format(
502 status
=primitive
.execution_status
,
503 details
=primitive
.execution_error_details
)
507 def publish_action_status(self
):
509 Starts publishing the status for jobs/primitives
511 registration_handle
= yield from self
.dts
.register(
512 xpath
=self
.job
.xpath
,
513 handler
=rift
.tasklets
.DTS
.RegistrationHandler(),
514 flags
=(rwdts
.Flag
.PUBLISHER | rwdts
.Flag
.NO_PREP_READ
),
517 self
.log
.debug('preparing to publish job status for {}'.format(self
.job
.xpath
))
518 self
.job
.regh
= registration_handle
521 registration_handle
.create_element(self
.job
.xpath
, self
.job
.job
)
523 # If the config is done via a user defined script
524 if self
.job
.tasks
is not None:
525 yield from self
._monitor
_processes
(registration_handle
)
529 # Run until pending moves to either failure/success
530 while self
.job
.job_status
== "pending":
533 if curr
- prev
< self
.polling_period
:
534 pause
= self
.polling_period
- (curr
- prev
)
535 yield from asyncio
.sleep(pause
, loop
=self
.loop
)
540 for vnfr
in self
.job
.job
.vnfr
:
541 task
= self
.loop
.create_task(self
.get_vnfr_status(vnfr
))
544 # Exit, if no tasks are found
548 yield from asyncio
.wait(tasks
, loop
=self
.loop
)
550 job_status
= [task
.result() for task
in tasks
]
552 if "failure" in job_status
:
553 self
.job
.job_status
= "failure"
554 elif "pending" in job_status
:
555 self
.job
.job_status
= "pending"
557 self
.job
.job_status
= "success"
559 errs
= self
.get_execution_details()
561 self
.job
.job
.job_status_details
= errs
563 # self.log.debug("Publishing job status: {} at {} for nsr id: {}".format(
564 # self.job.job_status,
568 registration_handle
.update_element(self
.job
.xpath
, self
.job
.job
)
570 registration_handle
.update_element(self
.job
.xpath
, self
.job
.job
)
572 except Exception as e
:
573 self
.log
.exception(e
)
578 def get_vnfr_status(self
, vnfr
):
579 """Schedules tasks for all containing primitives and updates it's own
583 vnfr : Vnfr job record containing primitives.
586 (str): "success|failure|pending"
591 for primitive
in vnfr
.primitive
:
592 if primitive
.execution_status
!= 'pending':
593 if primitive
.execution_id
== "":
594 # We may not have processed the status for these yet
595 job_status
.append(primitive
.execution_status
)
598 if primitive
.execution_id
== "":
599 # Actions which failed to queue can have empty id
600 job_status
.append(primitive
.execution_status
)
603 if primitive
.execution_id
== "config":
604 # Config job. Check if service is active
605 task
= self
.loop
.create_task(self
.get_service_status(vnfr
.id, primitive
))
608 task
= self
.loop
.create_task(self
.get_primitive_status(primitive
))
613 yield from asyncio
.wait(tasks
, loop
=self
.loop
)
615 job_status
.extend([task
.result() for task
in tasks
])
616 if "failure" in job_status
:
617 vnfr
.vnf_job_status
= "failure"
620 elif "pending" in job_status
:
621 vnfr
.vnf_job_status
= "pending"
625 vnfr
.vnf_job_status
= "success"
629 def get_service_status(self
, vnfr_id
, primitive
):
631 status
= yield from self
.loop
.run_in_executor(
633 self
.config_plugin
.get_service_status
,
637 self
.log
.debug("Service status: {}".format(status
))
638 if status
in ['error', 'blocked']:
639 self
.log
.warning("Execution of config {} failed: {}".
640 format(primitive
.execution_id
, status
))
641 primitive
.execution_error_details
= 'Config failed'
643 elif status
in ['active']:
650 except Exception as e
:
651 self
.log
.exception(e
)
654 primitive
.execution_status
= status
655 return primitive
.execution_status
658 def get_primitive_status(self
, primitive
):
660 Queries the juju api and gets the status of the execution id.
663 primitive : Primitive containing the execution ID.
667 resp
= yield from self
.loop
.run_in_executor(
669 self
.config_plugin
.get_action_status
,
670 primitive
.execution_id
673 self
.log
.debug("Action status: {}".format(resp
))
674 status
= resp
['status']
675 if status
== 'failed':
676 self
.log
.warning("Execution of action {} failed: {}".
677 format(primitive
.execution_id
, resp
))
678 primitive
.execution_error_details
= resp
['message']
680 except Exception as e
:
681 self
.log
.exception(e
)
684 # Handle case status is None
686 primitive
.execution_status
= ConfigAgentJob
.STATUS_MAP
[status
]
688 primitive
.execution_status
= "failure"
690 return primitive
.execution_status
693 class CfgAgentJobDtsHandler(object):
694 """Dts Handler for CfgAgent"""
695 XPATH
= "D,/nsr:ns-instance-opdata/nsr:nsr/nsr:config-agent-job"
697 def __init__(self
, dts
, log
, loop
, nsm
, cfgm
):
704 cfgm : ConfigManager.
713 self
._project
= cfgm
.project
717 """ Return registration handle """
722 """ Return the NSManager manager instance """
727 """ Return the ConfigManager manager instance """
730 def cfg_job_xpath(self
, nsr_id
, job_id
):
731 return self
._project
.add_project(("D,/nsr:ns-instance-opdata" +
732 "/nsr:nsr[nsr:ns-instance-config-ref={}]" +
733 "/nsr:config-agent-job[nsr:job-id={}]").format(quoted_key(nsr_id
), quoted_key(str(job_id
))))
737 """ Register for NS monitoring read from dts """
740 def on_prepare(xact_info
, action
, ks_path
, msg
):
741 """ prepare callback from dts """
742 xpath
= ks_path
.to_xpath(RwNsrYang
.get_schema())
743 if action
== rwdts
.QueryAction
.READ
:
744 schema
= RwNsrYang
.YangData_RwProject_Project_NsInstanceOpdata_Nsr
.schema()
745 path_entry
= schema
.keyspec_to_entry(ks_path
)
747 nsr_id
= path_entry
.key00
.ns_instance_config_ref
749 #print("###>>> self.nsm.nsrs:", self.nsm.nsrs)
751 if nsr_id
is None or nsr_id
== "":
752 nsrs
= list(self
.nsm
.nsrs
.values())
753 nsr_ids
= [nsr
.id for nsr
in nsrs
if nsr
is not None]
757 for nsr_id
in nsr_ids
:
758 jobs
= self
.cfgm
.get_job(nsr_id
)
761 xact_info
.respond_xpath(
762 rwdts
.XactRspCode
.MORE
,
763 self
.cfg_job_xpath(nsr_id
, job
.id),
766 except Exception as e
:
767 self
._log
.exception("Caught exception:%s", str(e
))
768 xact_info
.respond_xpath(rwdts
.XactRspCode
.ACK
)
771 xact_info
.respond_xpath(rwdts
.XactRspCode
.NA
)
773 hdl
= rift
.tasklets
.DTS
.RegistrationHandler(on_prepare
=on_prepare
,)
774 with self
._dts
.group_create() as group
:
775 self
._regh
= group
.register(xpath
=self
._project
.add_project(
776 CfgAgentJobDtsHandler
.XPATH
),
778 flags
=rwdts
.Flag
.PUBLISHER
,
781 def _terminate_nsr(self
, nsr_id
):
782 self
._log
.debug("NSR {} being terminated".format(nsr_id
))
783 jobs
= self
.cfgm
.get_job(nsr_id
)
785 path
= self
.cfg_job_xpath(nsr_id
, job
.id)
786 with self
._dts
.transaction() as xact
:
787 self
._log
.debug("Deleting job: {}".format(path
))
788 job
.regh
.delete_element(path
)
789 self
._log
.debug("Deleted job: {}".format(path
))
791 # Remove the NSR id in manager
792 self
.cfgm
.del_nsr(nsr_id
)
796 return self
._project
.add_project("D,/nsr:ns-instance-opdata/nsr:nsr")
798 def deregister(self
):
799 self
._log
.debug("De-register config agent job for project".
800 format(self
._project
.name
))
802 self
._regh
.deregister()
806 class ConfigAgentJobManager(object):
807 """A central class that manager all the Config Agent related data,
808 Including updating the status
810 TODO: Needs to support multiple config agents.
812 def __init__(self
, dts
, log
, loop
, project
, nsm
):
818 nsm : NsmTasklet instance
825 self
.project
= project
826 self
.handler
= CfgAgentJobDtsHandler(dts
, log
, loop
, nsm
, self
)
827 self
.executor
= concurrent
.futures
.ThreadPoolExecutor(max_workers
=1)
829 def add_job(self
, rpc_output
, tasks
=None):
830 """Once an RPC is triggered, add a new job
833 rpc_output (YangOutput_Nsr_ExecNsConfigPrimitive): Rpc output
834 rpc_input (YangInput_Nsr_ExecNsConfigPrimitive): Rpc input
835 tasks(list) A list of asyncio.Tasks
838 nsr_id
= rpc_output
.nsr_id_ref
840 job
= ConfigAgentJob
.convert_rpc_input_to_job(nsr_id
, rpc_output
,
843 self
.log
.debug("Creating a job monitor for Job id: {}".format(
846 if nsr_id
not in self
.jobs
:
847 self
.jobs
[nsr_id
] = [job
]
849 self
.jobs
[nsr_id
].append(job
)
851 # If the tasks are none, assume juju actions
852 # TBD: This logic need to be revisited
853 ca
= self
.nsm
.config_agent_plugins
[0]
855 for agent
in self
.nsm
.config_agent_plugins
:
856 if agent
.agent_type
== 'juju':
860 def done_callback(fut
):
863 self
.log
.error("Exception on monitor job {}: {}".
864 format(rpc_output
.job_id
, e
))
866 self
.log
.debug("Monitor job done for {}".format(rpc_output
.job_id
))
868 # For every Job we will schedule a new monitoring process.
869 job_monitor
= ConfigAgentJobMonitor(
877 task
= self
.loop
.create_task(job_monitor
.publish_action_status())
878 task
.add_done_callback(done_callback
)
880 def get_job(self
, nsr_id
):
881 """Get the job associated with the NSR Id, if present."""
883 return self
.jobs
[nsr_id
]
887 def del_nsr(self
, nsr_id
):
888 """Delete a NSR id from the jobs list"""
889 if nsr_id
in self
.jobs
:
890 self
.jobs
.pop(nsr_id
)
894 yield from self
.handler
.register()
895 # yield from self.handler.register_for_nsr()
897 def deregister(self
):
898 self
.handler
.deregister()