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
23 gi
.require_version('RwNsrYang', '1.0')
25 from gi
.repository
import (
32 gi
.require_version('RwKeyspec', '1.0')
33 from gi
.repository
.RwKeyspec
import quoted_key
36 import rift
.mano
.utils
.juju_api
as juju
39 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
)
55 def validate_account_creds(self
):
56 status
= RwcalYang
.YangData_Rwcal_ConnectionStatus()
58 env
= self
._api
._get
_env
()
59 except juju
.JujuEnvError
as e
:
60 msg
= "JujuClient: Invalid account credentials: %s", str(e
)
63 except ConnectionRefusedError
as e
:
64 msg
= "JujuClient: Wrong IP or Port: %s", str(e
)
67 except Exception as e
:
68 msg
= "JujuClient: Connection Failed: %s", str(e
)
72 status
.status
= "success"
73 status
.details
= "Connection was successful"
74 self
._log
.info("JujuClient: Connection Successful")
79 class ConfigAgentAccount(object):
80 def __init__(self
, log
, account_msg
):
82 self
._account
_msg
= account_msg
.deep_copy()
84 if account_msg
.account_type
== "juju":
85 self
._cfg
_agent
_client
_plugin
= JujuClient(
87 account_msg
.juju
.ip_address
,
88 account_msg
.juju
.port
,
89 account_msg
.juju
.user
,
90 account_msg
.juju
.secret
)
92 self
._cfg
_agent
_client
_plugin
= None
94 self
._status
= RwConfigAgentYang
.YangData_RwProject_Project_ConfigAgent_Account_ConnectionStatus(
96 details
="Connection status lookup not started"
99 self
._validate
_task
= None
103 return self
._account
_msg
.name
106 def account_msg(self
):
107 return self
._account
_msg
110 def account_type(self
):
111 return self
._account
_msg
.account_type
114 def connection_status(self
):
117 def update_from_cfg(self
, cfg
):
118 self
._log
.debug("Updating parent ConfigAgentAccount to %s", cfg
)
119 raise NotImplementedError("Update config agent account not yet supported")
122 def validate_cfg_agent_account_credentials(self
, loop
):
123 self
._log
.debug("Validating Config Agent Account %s, credential status %s", self
._account
_msg
, self
._status
)
125 self
._status
= RwConfigAgentYang
.YangData_RwProject_Project_ConfigAgent_Account_ConnectionStatus(
127 details
="Config Agent account connection validation in progress"
130 if self
._cfg
_agent
_client
_plugin
is None:
131 self
._status
= RwConfigAgentYang
.YangData_RwProject_Project_ConfigAgent_Account_ConnectionStatus(
133 details
="Config Agent account does not support validation of account creds"
137 status
= yield from loop
.run_in_executor(
139 self
._cfg
_agent
_client
_plugin
.validate_account_creds
141 self
._status
= RwConfigAgentYang
.YangData_RwProject_Project_ConfigAgent_Account_ConnectionStatus
.from_dict(status
.as_dict())
142 except Exception as e
:
143 self
._status
= RwConfigAgentYang
.YangData_RwProject_Project_ConfigAgent_Account_ConnectionStatus(
145 details
="Error - " + str(e
)
148 self
._log
.info("Got config agent account validation response: %s", self
._status
)
150 def start_validate_credentials(self
, loop
):
151 if self
._validate
_task
is not None:
152 self
._validate
_task
.cancel()
153 self
._validate
_task
= None
155 self
._validate
_task
= asyncio
.ensure_future(
156 self
.validate_cfg_agent_account_credentials(loop
),
160 class CfgAgentDtsOperdataHandler(object):
161 def __init__(self
, dts
, log
, loop
, project
):
165 self
._project
= project
167 self
.cfg_agent_accounts
= {}
168 self
._show
_reg
= None
171 def add_cfg_agent_account(self
, account_msg
):
172 account
= ConfigAgentAccount(self
._log
, account_msg
)
173 self
.cfg_agent_accounts
[account
.name
] = account
174 self
._log
.info("ConfigAgent Operdata Handler added. Starting account validation")
176 account
.start_validate_credentials(self
._loop
)
178 def delete_cfg_agent_account(self
, account_name
):
179 del self
.cfg_agent_accounts
[account_name
]
180 self
._log
.info("ConfigAgent Operdata Handler deleted.")
182 def get_saved_cfg_agent_accounts(self
, cfg_agent_account_name
):
183 ''' Get Config Agent Account corresponding to passed name, or all saved accounts if name is None'''
184 saved_cfg_agent_accounts
= []
186 if cfg_agent_account_name
is None or cfg_agent_account_name
== "":
187 cfg_agent_accounts
= list(self
.cfg_agent_accounts
.values())
188 saved_cfg_agent_accounts
.extend(cfg_agent_accounts
)
189 elif cfg_agent_account_name
in self
.cfg_agent_accounts
:
190 account
= self
.cfg_agent_accounts
[cfg_agent_account_name
]
191 saved_cfg_agent_accounts
.append(account
)
193 errstr
= "Config Agent account {} does not exist".format(cfg_agent_account_name
)
194 raise KeyError(errstr
)
196 return saved_cfg_agent_accounts
199 def _register_show_status(self
):
200 def get_xpath(cfg_agent_name
=None):
201 return "D,/rw-config-agent:config-agent/account{}/connection-status".format(
202 "[name=%s]" % quoted_key(cfg_agent_name
) if cfg_agent_name
is not None else ''
206 def on_prepare(xact_info
, action
, ks_path
, msg
):
207 path_entry
= RwConfigAgentYang
.YangData_RwProject_Project_ConfigAgent_Account
.schema().keyspec_to_entry(ks_path
)
208 cfg_agent_account_name
= path_entry
.key00
.name
209 self
._log
.debug("Got show cfg_agent connection status request: %s", ks_path
.create_string())
212 saved_accounts
= self
.get_saved_cfg_agent_accounts(cfg_agent_account_name
)
213 for account
in saved_accounts
:
214 connection_status
= account
.connection_status
215 self
._log
.debug("Responding to config agent connection status request: %s", connection_status
)
216 xpath
= self
._project
.add_project(get_xpath(account
.name
))
217 xact_info
.respond_xpath(
218 rwdts
.XactRspCode
.MORE
,
220 msg
=account
.connection_status
,
222 except KeyError as e
:
223 self
._log
.warning(str(e
))
224 xact_info
.respond_xpath(rwdts
.XactRspCode
.NA
)
227 xact_info
.respond_xpath(rwdts
.XactRspCode
.ACK
)
229 xpath
= self
._project
.add_project(get_xpath())
230 self
._show
_reg
= yield from self
._dts
.register(
232 handler
=rift
.tasklets
.DTS
.RegistrationHandler(
233 on_prepare
=on_prepare
),
234 flags
=rwdts
.Flag
.PUBLISHER
,
237 def _register_validate_rpc(self
):
239 return "/rw-config-agent:update-cfg-agent-status"
242 def on_prepare(xact_info
, action
, ks_path
, msg
):
243 if not msg
.has_field("cfg_agent_account"):
244 raise ConfigAgentAccountNotFound("Config Agent account name not provided")
246 cfg_agent_account_name
= msg
.cfg_agent_account
248 if not self
._project
.rpc_check(msg
, xact_info
=xact_info
):
252 account
= self
.cfg_agent_accounts
[cfg_agent_account_name
]
254 raise ConfigAgentAccountNotFound("Config Agent account name %s not found" % cfg_agent_account_name
)
256 account
.start_validate_credentials(self
._loop
)
258 xact_info
.respond_xpath(rwdts
.XactRspCode
.ACK
)
260 self
._rpc
_reg
= yield from self
._dts
.register(
262 handler
=rift
.tasklets
.DTS
.RegistrationHandler(
263 on_prepare
=on_prepare
265 flags
=rwdts
.Flag
.PUBLISHER
,
270 yield from self
._register
_show
_status
()
271 yield from self
._register
_validate
_rpc
()
273 def deregister(self
):
274 self
._show
_reg
.deregister()
275 self
._rpc
_reg
.deregister()
278 class ConfigAgentJob(object):
279 """A wrapper over the config agent job object, providing some
280 convenience functions.
282 YangData_RwProject_Project_NsInstanceOpdata_Nsr_ConfigAgentJob contains
289 # The normalizes the state terms from Juju to our yang models
291 STATUS_MAP
= {"completed": "success",
292 "pending" : "pending",
293 "running" : "pending",
294 "failed" : "failure"}
296 def __init__(self
, nsr_id
, job
, project
, tasks
=None):
299 nsr_id (uuid): ID of NSR record
300 job (YangData_RwProject_Project_NsInstanceOpdata_Nsr_ConfigAgentJob): Gi object
301 tasks: List of asyncio.tasks. If provided the job monitor will
302 use it to monitor the tasks instead of the execution IDs
307 self
._project
= project
314 return self
._job
.job_id
319 return self
._job
.job_name
322 def job_status(self
):
323 """Status of the job (success|pending|failure)"""
324 return self
._job
.job_status
327 def job_status(self
, value
):
328 """Setter for job status"""
329 self
._job
.job_status
= value
338 """Xpath of the job"""
339 return self
._project
.add_project(("D,/nsr:ns-instance-opdata" +
340 "/nsr:nsr[nsr:ns-instance-config-ref={}]" +
341 "/nsr:config-agent-job[nsr:job-id={}]"
342 ).format(quoted_key(self
.nsr_id
), quoted_key(str(self
.id))))
346 """Registration handle for the job"""
351 """Setter for registration handle"""
355 def convert_rpc_input_to_job(nsr_id
, rpc_output
, tasks
, project
):
356 """A helper function to convert the YangOutput_Nsr_ExecNsConfigPrimitive
357 to YangData_RwProject_Project_NsInstanceOpdata_Nsr_ConfigAgentJob (NsrYang)
360 nsr_id (uuid): NSR ID
361 rpc_output (YangOutput_Nsr_ExecNsConfigPrimitive): RPC output
362 tasks (list): A list of asyncio.Tasks
367 # Shortcuts to prevent the HUUGE names.
368 CfgAgentJob
= NsrYang
.YangData_RwProject_Project_NsInstanceOpdata_Nsr_ConfigAgentJob
369 CfgAgentVnfr
= NsrYang
.YangData_RwProject_Project_NsInstanceOpdata_Nsr_ConfigAgentJob_Vnfr
370 CfgAgentPrimitive
= NsrYang
.YangData_RwProject_Project_NsInstanceOpdata_Nsr_ConfigAgentJob_Vnfr_Primitive
371 CfgAgentPrimitiveParam
= NsrYang
.YangData_RwProject_Project_NsInstanceOpdata_Nsr_ConfigAgentJob_Vnfr_Primitive_Parameter
373 job
= CfgAgentJob
.from_dict({
374 "job_id": rpc_output
.job_id
,
375 "job_name" : rpc_output
.name
,
376 "job_status": "pending",
377 "triggered_by": rpc_output
.triggered_by
,
378 "create_time": rpc_output
.create_time
,
379 "job_status_details": rpc_output
.job_status_details
if rpc_output
.job_status_details
is not None else None,
380 "parameter": [param
.as_dict() for param
in rpc_output
.parameter
],
381 "parameter_group": [pg
.as_dict() for pg
in rpc_output
.parameter_group
]
384 for vnfr
in rpc_output
.vnf_out_list
:
385 vnfr_job
= CfgAgentVnfr
.from_dict({
386 "id": vnfr
.vnfr_id_ref
,
387 "vnf_job_status": "pending",
390 for primitive
in vnfr
.vnf_out_primitive
:
391 vnf_primitive
= CfgAgentPrimitive
.from_dict({
392 "name": primitive
.name
,
393 "execution_status": ConfigAgentJob
.STATUS_MAP
[primitive
.execution_status
],
394 "execution_id": primitive
.execution_id
,
395 "execution_error_details": primitive
.execution_error_details
,
398 # Copy over the input param
399 for param
in primitive
.parameter
:
400 vnf_primitive
.parameter
.append(
401 CfgAgentPrimitiveParam
.from_dict({
406 vnfr_job
.primitive
.append(vnf_primitive
)
408 job
.vnfr
.append(vnfr_job
)
410 return ConfigAgentJob(nsr_id
, job
, project
, tasks
)
413 class ConfigAgentJobMonitor(object):
414 """Job monitor: Polls the Juju controller and get the status.
416 If all Primitive are success, then vnf & nsr status will be "success"
417 If any one Primitive reaches a failed state then both vnf and nsr will fail.
421 def __init__(self
, dts
, log
, job
, executor
, loop
, config_plugin
):
426 job (ConfigAgentJob): ConfigAgentJob instance
427 executor (concurrent.futures): Executor for juju status api calls
428 loop (eventloop): Current event loop instance
429 config_plugin : Config plugin to be used.
434 self
.executor
= executor
435 self
.polling_period
= ConfigAgentJobMonitor
.POLLING_PERIOD
436 self
.config_plugin
= config_plugin
440 def _monitor_processes(self
, registration_handle
):
443 for process
in self
.job
.tasks
:
444 if isinstance(process
, asyncio
.subprocess
.Process
):
445 rc
= yield from process
.wait()
446 err
= yield from process
.stderr
.read()
450 rc
= yield from process
453 self
.log
.debug("Process {} returned rc: {}, err: {}".
454 format(process
, rc
, err
))
458 errs
+= "<success>{}</success>".format(err
)
460 errs
+= "<error>{}</error>".format(err
)
464 self
.job
.job_status
= "success"
466 self
.job
.job_status
= "failure"
469 self
.job
.job
.job_status_details
= errs
471 registration_handle
.update_element(self
.job
.xpath
, self
.job
.job
)
473 def get_execution_details(self
):
474 '''Get the error details from failed primitives'''
476 for vnfr
in self
.job
.job
.vnfr
:
477 for primitive
in vnfr
.primitive
:
478 if primitive
.execution_status
== "failure":
480 if primitive
.execution_error_details
:
481 errs
+= primitive
.execution_error_details
483 errs
+= '{}: Unknown error'.format(primitive
.name
)
486 if primitive
.execution_error_details
:
487 errs
+= '<{status}>{details}</{status}>'.format(
488 status
=primitive
.execution_status
,
489 details
=primitive
.execution_error_details
)
493 def publish_action_status(self
):
495 Starts publishing the status for jobs/primitives
497 registration_handle
= yield from self
.dts
.register(
498 xpath
=self
.job
.xpath
,
499 handler
=rift
.tasklets
.DTS
.RegistrationHandler(),
500 flags
=(rwdts
.Flag
.PUBLISHER | rwdts
.Flag
.NO_PREP_READ
),
503 self
.log
.debug('preparing to publish job status for {}'.format(self
.job
.xpath
))
504 self
.job
.regh
= registration_handle
507 registration_handle
.create_element(self
.job
.xpath
, self
.job
.job
)
509 # If the config is done via a user defined script
510 if self
.job
.tasks
is not None:
511 yield from self
._monitor
_processes
(registration_handle
)
515 # Run until pending moves to either failure/success
516 while self
.job
.job_status
== "pending":
519 if curr
- prev
< self
.polling_period
:
520 pause
= self
.polling_period
- (curr
- prev
)
521 yield from asyncio
.sleep(pause
, loop
=self
.loop
)
526 for vnfr
in self
.job
.job
.vnfr
:
527 task
= self
.loop
.create_task(self
.get_vnfr_status(vnfr
))
530 # Exit, if no tasks are found
534 yield from asyncio
.wait(tasks
, loop
=self
.loop
)
536 job_status
= [task
.result() for task
in tasks
]
538 if "failure" in job_status
:
539 self
.job
.job_status
= "failure"
540 elif "pending" in job_status
:
541 self
.job
.job_status
= "pending"
543 self
.job
.job_status
= "success"
545 errs
= self
.get_execution_details()
547 self
.job
.job
.job_status_details
= errs
549 # self.log.debug("Publishing job status: {} at {} for nsr id: {}".format(
550 # self.job.job_status,
554 registration_handle
.update_element(self
.job
.xpath
, self
.job
.job
)
556 registration_handle
.update_element(self
.job
.xpath
, self
.job
.job
)
558 except Exception as e
:
559 self
.log
.exception(e
)
564 def get_vnfr_status(self
, vnfr
):
565 """Schedules tasks for all containing primitives and updates it's own
569 vnfr : Vnfr job record containing primitives.
572 (str): "success|failure|pending"
577 for primitive
in vnfr
.primitive
:
578 if primitive
.execution_status
!= 'pending':
579 if primitive
.execution_id
== "":
580 # We may not have processed the status for these yet
581 job_status
.append(primitive
.execution_status
)
584 if primitive
.execution_id
== "":
585 # Actions which failed to queue can have empty id
586 job_status
.append(primitive
.execution_status
)
589 if primitive
.execution_id
== "config":
590 # Config job. Check if service is active
591 task
= self
.loop
.create_task(self
.get_service_status(vnfr
.id, primitive
))
594 task
= self
.loop
.create_task(self
.get_primitive_status(primitive
))
599 yield from asyncio
.wait(tasks
, loop
=self
.loop
)
601 job_status
.extend([task
.result() for task
in tasks
])
602 if "failure" in job_status
:
603 vnfr
.vnf_job_status
= "failure"
606 elif "pending" in job_status
:
607 vnfr
.vnf_job_status
= "pending"
611 vnfr
.vnf_job_status
= "success"
615 def get_service_status(self
, vnfr_id
, primitive
):
617 status
= yield from self
.loop
.run_in_executor(
619 self
.config_plugin
.get_service_status
,
623 self
.log
.debug("Service status: {}".format(status
))
624 if status
in ['error', 'blocked']:
625 self
.log
.warning("Execution of config {} failed: {}".
626 format(primitive
.execution_id
, status
))
627 primitive
.execution_error_details
= 'Config failed'
629 elif status
in ['active']:
636 except Exception as e
:
637 self
.log
.exception(e
)
640 primitive
.execution_status
= status
641 return primitive
.execution_status
644 def get_primitive_status(self
, primitive
):
646 Queries the juju api and gets the status of the execution id.
649 primitive : Primitive containing the execution ID.
653 resp
= yield from self
.loop
.run_in_executor(
655 self
.config_plugin
.get_action_status
,
656 primitive
.execution_id
659 self
.log
.debug("Action status: {}".format(resp
))
660 status
= resp
['status']
661 if status
== 'failed':
662 self
.log
.warning("Execution of action {} failed: {}".
663 format(primitive
.execution_id
, resp
))
664 primitive
.execution_error_details
= resp
['message']
666 except Exception as e
:
667 self
.log
.exception(e
)
670 # Handle case status is None
672 primitive
.execution_status
= ConfigAgentJob
.STATUS_MAP
[status
]
674 primitive
.execution_status
= "failure"
676 return primitive
.execution_status
679 class CfgAgentJobDtsHandler(object):
680 """Dts Handler for CfgAgent"""
681 XPATH
= "D,/nsr:ns-instance-opdata/nsr:nsr/nsr:config-agent-job"
683 def __init__(self
, dts
, log
, loop
, nsm
, cfgm
):
690 cfgm : ConfigManager.
699 self
._project
= cfgm
.project
703 """ Return registration handle """
708 """ Return the NSManager manager instance """
713 """ Return the ConfigManager manager instance """
716 def cfg_job_xpath(self
, nsr_id
, job_id
):
717 return self
._project
.add_project(("D,/nsr:ns-instance-opdata" +
718 "/nsr:nsr[nsr:ns-instance-config-ref={}]" +
719 "/nsr:config-agent-job[nsr:job-id={}]").format(quoted_key(nsr_id
), quoted_key(str(job_id
))))
723 """ Register for NS monitoring read from dts """
726 def on_prepare(xact_info
, action
, ks_path
, msg
):
727 """ prepare callback from dts """
728 xpath
= ks_path
.to_xpath(RwNsrYang
.get_schema())
729 if action
== rwdts
.QueryAction
.READ
:
730 schema
= RwNsrYang
.YangData_RwProject_Project_NsInstanceOpdata_Nsr
.schema()
731 path_entry
= schema
.keyspec_to_entry(ks_path
)
733 nsr_id
= path_entry
.key00
.ns_instance_config_ref
735 #print("###>>> self.nsm.nsrs:", self.nsm.nsrs)
737 if nsr_id
is None or nsr_id
== "":
738 nsrs
= list(self
.nsm
.nsrs
.values())
739 nsr_ids
= [nsr
.id for nsr
in nsrs
if nsr
is not None]
743 for nsr_id
in nsr_ids
:
744 jobs
= self
.cfgm
.get_job(nsr_id
)
747 xact_info
.respond_xpath(
748 rwdts
.XactRspCode
.MORE
,
749 self
.cfg_job_xpath(nsr_id
, job
.id),
752 except Exception as e
:
753 self
._log
.exception("Caught exception:%s", str(e
))
754 xact_info
.respond_xpath(rwdts
.XactRspCode
.ACK
)
757 xact_info
.respond_xpath(rwdts
.XactRspCode
.NA
)
759 hdl
= rift
.tasklets
.DTS
.RegistrationHandler(on_prepare
=on_prepare
,)
760 with self
._dts
.group_create() as group
:
761 self
._regh
= group
.register(xpath
=self
._project
.add_project(
762 CfgAgentJobDtsHandler
.XPATH
),
764 flags
=rwdts
.Flag
.PUBLISHER
,
767 def _terminate_nsr(self
, nsr_id
):
768 self
._log
.debug("NSR {} being terminated".format(nsr_id
))
769 jobs
= self
.cfgm
.get_job(nsr_id
)
771 path
= self
.cfg_job_xpath(nsr_id
, job
.id)
772 with self
._dts
.transaction() as xact
:
773 self
._log
.debug("Deleting job: {}".format(path
))
774 job
.regh
.delete_element(path
)
775 self
._log
.debug("Deleted job: {}".format(path
))
777 # Remove the NSR id in manager
778 self
.cfgm
.del_nsr(nsr_id
)
782 return self
._project
.add_project("D,/nsr:ns-instance-opdata/nsr:nsr")
784 def deregister(self
):
785 self
._log
.debug("De-register config agent job for project".
786 format(self
._project
.name
))
788 self
._regh
.deregister()
792 class ConfigAgentJobManager(object):
793 """A central class that manager all the Config Agent related data,
794 Including updating the status
796 TODO: Needs to support multiple config agents.
798 def __init__(self
, dts
, log
, loop
, project
, nsm
):
804 nsm : NsmTasklet instance
811 self
.project
= project
812 self
.handler
= CfgAgentJobDtsHandler(dts
, log
, loop
, nsm
, self
)
813 self
.executor
= concurrent
.futures
.ThreadPoolExecutor(max_workers
=1)
815 def add_job(self
, rpc_output
, tasks
=None):
816 """Once an RPC is triggered, add a new job
819 rpc_output (YangOutput_Nsr_ExecNsConfigPrimitive): Rpc output
820 rpc_input (YangInput_Nsr_ExecNsConfigPrimitive): Rpc input
821 tasks(list) A list of asyncio.Tasks
824 nsr_id
= rpc_output
.nsr_id_ref
826 job
= ConfigAgentJob
.convert_rpc_input_to_job(nsr_id
, rpc_output
,
829 self
.log
.debug("Creating a job monitor for Job id: {}".format(
832 if nsr_id
not in self
.jobs
:
833 self
.jobs
[nsr_id
] = [job
]
835 self
.jobs
[nsr_id
].append(job
)
837 # If the tasks are none, assume juju actions
838 # TBD: This logic need to be revisited
839 ca
= self
.nsm
.config_agent_plugins
[0]
841 for agent
in self
.nsm
.config_agent_plugins
:
842 if agent
.agent_type
== 'juju':
846 def done_callback(fut
):
849 self
.log
.error("Exception on monitor job {}: {}".
850 format(rpc_output
.job_id
, e
))
852 self
.log
.debug("Monitor job done for {}".format(rpc_output
.job_id
))
854 # For every Job we will schedule a new monitoring process.
855 job_monitor
= ConfigAgentJobMonitor(
863 task
= self
.loop
.create_task(job_monitor
.publish_action_status())
864 task
.add_done_callback(done_callback
)
866 def get_job(self
, nsr_id
):
867 """Get the job associated with the NSR Id, if present."""
869 return self
.jobs
[nsr_id
]
873 def del_nsr(self
, nsr_id
):
874 """Delete a NSR id from the jobs list"""
875 if nsr_id
in self
.jobs
:
876 self
.jobs
.pop(nsr_id
)
880 yield from self
.handler
.register()
881 # yield from self.handler.register_for_nsr()
883 def deregister(self
):
884 self
.handler
.deregister()