3 # Copyright 2016 RIFT.IO Inc
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
25 gi
.require_version('RwDts', '1.0')
26 gi
.require_version('RwVnfrYang', '1.0')
27 from gi
.repository
import (
32 import rift
.openmano
.rift2openmano
as rift2openmano
33 import rift
.openmano
.openmano_client
as openmano_client
34 from . import rwnsmplugin
38 if sys
.version_info
< (3, 4, 4):
39 asyncio
.ensure_future
= asyncio
.async
42 DUMP_OPENMANO_DIR
= os
.path
.join(
43 os
.environ
["RIFT_ARTIFACTS"],
44 "openmano_descriptors"
48 def dump_openmano_descriptor(name
, descriptor_str
):
49 filename
= "{}_{}.yaml".format(
50 time
.strftime("%Y%m%d-%H%M%S"),
54 filepath
= os
.path
.join(
60 if not os
.path
.exists(DUMP_OPENMANO_DIR
):
61 os
.makedirs(DUMP_OPENMANO_DIR
)
63 with
open(filepath
, 'w') as hdl
:
64 hdl
.write(descriptor_str
)
67 print("Failed to dump openmano descriptor: %s" % str(e
))
71 class VnfrConsoleOperdataDtsHandler(object):
72 """ registers 'D,/vnfr:vnfr-console/vnfr:vnfr[id]/vdur[id]' and handles CRUD from DTS"""
74 def vnfr_vdu_console_xpath(self
):
75 """ path for resource-mgr"""
76 return ("D,/rw-vnfr:vnfr-console/rw-vnfr:vnfr[rw-vnfr:id='{}']/rw-vnfr:vdur[vnfr:id='{}']".format(self
._vnfr
_id
,self
._vdur
_id
))
78 def __init__(self
, dts
, log
, loop
, nsr
, vnfr_id
, vdur_id
, vdu_id
):
85 self
._vnfr
_id
= vnfr_id
86 self
._vdur
_id
= vdur_id
91 """ Register for VNFR VDU Operational Data read from dts """
94 def on_prepare(xact_info
, action
, ks_path
, msg
):
95 """ prepare callback from dts """
96 xpath
= ks_path
.to_xpath(RwVnfrYang
.get_schema())
98 "Got VNFR VDU Opdata xact_info: %s, action: %s): %s:%s",
99 xact_info
, action
, xpath
, msg
102 if action
== rwdts
.QueryAction
.READ
:
103 schema
= RwVnfrYang
.YangData_RwVnfr_VnfrConsole_Vnfr_Vdur
.schema()
104 path_entry
= schema
.keyspec_to_entry(ks_path
)
107 console_url
= yield from self
._loop
.run_in_executor(
109 self
._nsr
._http
_api
.get_instance_vm_console_url
,
114 self
._log
.debug("Got console response: %s for NSR ID %s vdur ID %s",
119 vdur_console
= RwVnfrYang
.YangData_RwVnfr_VnfrConsole_Vnfr_Vdur()
120 vdur_console
.id = self
._vdur
_id
122 vdur_console
.console_url
= console_url
124 vdur_console
.console_url
= 'none'
125 self
._log
.debug("Recevied console URL for vdu {} is {}".format(self
._vdu
_id
,vdur_console
))
126 except openmano_client
.InstanceStatusError
as e
:
127 self
._log
.error("Could not get NS instance console URL: %s",
129 vdur_console
= RwVnfrYang
.YangData_RwVnfr_VnfrConsole_Vnfr_Vdur()
130 vdur_console
.id = self
._vdur
_id
131 vdur_console
.console_url
= 'none'
133 xact_info
.respond_xpath(rsp_code
=rwdts
.XactRspCode
.ACK
,
134 xpath
=self
.vnfr_vdu_console_xpath
,
137 #raise VnfRecordError("Not supported operation %s" % action)
138 self
._log
.error("Not supported operation %s" % action
)
139 xact_info
.respond_xpath(rsp_code
=rwdts
.XactRspCode
.ACK
)
142 self
._log
.debug("Registering for VNFR VDU using xpath: %s",
143 self
.vnfr_vdu_console_xpath
)
144 hdl
= rift
.tasklets
.DTS
.RegistrationHandler(on_prepare
=on_prepare
,)
145 with self
._dts
.group_create() as group
:
146 self
._regh
= group
.register(xpath
=self
.vnfr_vdu_console_xpath
,
148 flags
=rwdts
.Flag
.PUBLISHER
,
153 class OpenmanoVnfr(object):
154 def __init__(self
, log
, loop
, cli_api
, vnfr
):
157 self
._cli
_api
= cli_api
159 self
._vnfd
_id
= vnfr
.vnfd
.id
163 self
._created
= False
167 return rift2openmano
.RiftVNFD(self
._vnfr
.vnfd
)
174 def rift_vnfd_id(self
):
178 def openmano_vnfd_id(self
):
182 def openmano_vnfd(self
):
183 self
._log
.debug("Converting vnfd %s from rift to openmano", self
.vnfd
.id)
184 openmano_vnfd
= rift2openmano
.rift2openmano_vnfd(self
.vnfd
)
188 def openmano_vnfd_yaml(self
):
189 return yaml
.safe_dump(self
.openmano_vnfd
, default_flow_style
=False)
193 self
._log
.debug("Creating openmano vnfd")
194 openmano_vnfd
= self
.openmano_vnfd
195 name
= openmano_vnfd
["vnf"]["name"]
197 # If the name already exists, get the openmano vnfd id
198 name_uuid_map
= yield from self
._loop
.run_in_executor(
200 self
._cli
_api
.vnf_list
,
203 if name
in name_uuid_map
:
204 vnf_id
= name_uuid_map
[name
]
205 self
._log
.debug("Vnf already created. Got existing openmano vnfd id: %s", vnf_id
)
206 self
._vnf
_id
= vnf_id
209 self
._vnf
_id
, _
= yield from self
._loop
.run_in_executor(
211 self
._cli
_api
.vnf_create
,
212 self
.openmano_vnfd_yaml
,
215 fpath
= dump_openmano_descriptor(
216 "{}_vnf".format(name
),
217 self
.openmano_vnfd_yaml
220 self
._log
.debug("Dumped Openmano VNF descriptor to: %s", fpath
)
226 if not self
._created
:
229 self
._log
.debug("Deleting openmano vnfd")
230 if self
._vnf
_id
is None:
231 self
._log
.warning("Openmano vnf id not set. Cannot delete.")
234 yield from self
._loop
.run_in_executor(
236 self
._cli
_api
.vnf_delete
,
241 class OpenmanoNsr(object):
244 def __init__(self
, dts
, log
, loop
, publisher
, cli_api
, http_api
, nsd_msg
, nsr_config_msg
,key_pairs
):
248 self
._publisher
= publisher
249 self
._cli
_api
= cli_api
250 self
._http
_api
= http_api
252 self
._nsd
_msg
= nsd_msg
253 self
._nsr
_config
_msg
= nsr_config_msg
257 self
._vdur
_console
_handler
= {}
258 self
._key
_pairs
= key_pairs
260 self
._nsd
_uuid
= None
261 self
._nsr
_uuid
= None
265 self
._created
= False
267 self
._monitor
_task
= None
271 return rift2openmano
.RiftNSD(self
._nsd
_msg
)
275 return {v
.rift_vnfd_id
: v
.vnfd
for v
in self
._vnfrs
}
279 return {v
.rift_vnfd_id
: v
.openmano_vnfd_id
for v
in self
._vnfrs
}
286 def openmano_nsd_yaml(self
):
287 self
._log
.debug("Converting nsd %s from rift to openmano", self
.nsd
.id)
288 openmano_nsd
= rift2openmano
.rift2openmano_nsd(self
.nsd
, self
.vnfds
,self
.vnfr_ids
)
289 return yaml
.safe_dump(openmano_nsd
, default_flow_style
=False)
291 def get_ssh_key_pairs(self
):
294 for authorized_key
in self
._nsr
_config
_msg
.ssh_authorized_key
:
295 self
._log
.debug("Key pair ref present is %s",authorized_key
.key_pair_ref
)
296 if authorized_key
.key_pair_ref
in self
._key
_pairs
:
297 key_pairs
.append(self
._key
_pairs
[authorized_key
.key_pair_ref
].key
)
299 for authorized_key
in self
._nsd
_msg
.key_pair
:
300 self
._log
.debug("Key pair NSD is %s",authorized_key
)
301 key_pairs
.append(authorized_key
.key
)
304 cloud_config
["key-pairs"] = key_pairs
307 for user_entry
in self
._nsr
_config
_msg
.user
:
308 self
._log
.debug("User present is %s",user_entry
)
310 user
["name"] = user_entry
.name
311 user
["key-pairs"] = list()
312 for ssh_key
in user_entry
.key_pair
:
313 user
["key-pairs"].append(ssh_key
.key
)
316 for user_entry
in self
._nsd
_msg
.user
:
317 self
._log
.debug("User present in NSD is %s",user_entry
)
319 user
["name"] = user_entry
.name
320 user
["key-pairs"] = list()
321 for ssh_key
in user_entry
.key_pair
:
322 user
["key-pairs"].append(ssh_key
.key
)
326 cloud_config
["users"] = users
328 self
._log
.debug("Cloud config formed is %s",cloud_config
)
333 def openmano_instance_create_yaml(self
):
334 self
._log
.debug("Creating instance-scenario-create input file for nsd %s with name %s", self
.nsd
.id, self
._nsr
_config
_msg
.name
)
335 openmano_instance_create
= {}
336 openmano_instance_create
["name"] = self
._nsr
_config
_msg
.name
337 openmano_instance_create
["description"] = self
._nsr
_config
_msg
.description
338 openmano_instance_create
["scenario"] = self
._nsd
_uuid
340 cloud_config
= self
.get_ssh_key_pairs()
342 openmano_instance_create
["cloud-config"] = cloud_config
343 if self
._nsr
_config
_msg
.has_field("om_datacenter"):
344 openmano_instance_create
["datacenter"] = self
._nsr
_config
_msg
.om_datacenter
345 openmano_instance_create
["vnfs"] = {}
346 for vnfr
in self
._vnfrs
:
347 if "om_datacenter" in vnfr
.vnfr
.vnfr_msg
:
348 vnfr_name
= vnfr
.vnfr
.vnfd
.name
+ "__" + str(vnfr
.vnfr
.vnfr_msg
.member_vnf_index_ref
)
349 openmano_instance_create
["vnfs"][vnfr_name
] = {"datacenter": vnfr
.vnfr
.vnfr_msg
.om_datacenter
}
350 openmano_instance_create
["networks"] = {}
351 for vld_msg
in self
._nsd
_msg
.vld
:
352 openmano_instance_create
["networks"][vld_msg
.name
] = {}
353 openmano_instance_create
["networks"][vld_msg
.name
]["sites"] = list()
354 for vlr
in self
._vlrs
:
355 if vlr
.vld_msg
.name
== vld_msg
.name
:
356 self
._log
.debug("Received VLR name %s, VLR DC: %s for VLD: %s",vlr
.vld_msg
.name
,
357 vlr
.om_datacenter_name
,vld_msg
.name
)
358 #network["vim-network-name"] = vld_msg.name
361 if vld_msg
.vim_network_name
:
362 network
["netmap-use"] = vld_msg
.vim_network_name
363 elif vlr
._ip
_profile
and vlr
._ip
_profile
.has_field("ip_profile_params"):
364 ip_profile_params
= vlr
._ip
_profile
.ip_profile_params
365 if ip_profile_params
.ip_version
== "ipv6":
366 ip_profile
['ip-version'] = "IPv6"
368 ip_profile
['ip-version'] = "IPv4"
369 if ip_profile_params
.has_field('subnet_address'):
370 ip_profile
['subnet-address'] = ip_profile_params
.subnet_address
371 if ip_profile_params
.has_field('gateway_address'):
372 ip_profile
['gateway-address'] = ip_profile_params
.gateway_address
373 if ip_profile_params
.has_field('dns_server') and len(ip_profile_params
.dns_server
) > 0:
374 ip_profile
['dns-address'] = ip_profile_params
.dns_server
[0].address
375 if ip_profile_params
.has_field('dhcp_params'):
376 ip_profile
['dhcp'] = {}
377 ip_profile
['dhcp']['enabled'] = ip_profile_params
.dhcp_params
.enabled
378 ip_profile
['dhcp']['start-address'] = ip_profile_params
.dhcp_params
.start_address
379 ip_profile
['dhcp']['count'] = ip_profile_params
.dhcp_params
.count
381 network
["netmap-create"] = vlr
.name
382 if vlr
.om_datacenter_name
:
383 network
["datacenter"] = vlr
.om_datacenter_name
384 elif vld_msg
.has_field("om_datacenter"):
385 network
["datacenter"] = vld_msg
.om_datacenter
386 elif "datacenter" in openmano_instance_create
:
387 network
["datacenter"] = openmano_instance_create
["datacenter"]
389 openmano_instance_create
["networks"][vld_msg
.name
]["sites"].append(network
)
391 openmano_instance_create
["networks"][vld_msg
.name
]['ip-profile'] = ip_profile
394 return yaml
.safe_dump(openmano_instance_create
, default_flow_style
=False)
397 def add_vlr(self
, vlr
):
398 self
._vlrs
.append(vlr
)
399 yield from asyncio
.sleep(1, loop
=self
._loop
)
402 def add_vnfr(self
, vnfr
):
403 vnfr
= OpenmanoVnfr(self
._log
, self
._loop
, self
._cli
_api
, vnfr
)
404 yield from vnfr
.create()
405 self
._vnfrs
.append(vnfr
)
409 if not self
._created
:
410 self
._log
.debug("NSD wasn't created. Skipping delete.")
413 self
._log
.debug("Deleting openmano nsr")
415 yield from self
._loop
.run_in_executor(
417 self
._cli
_api
.ns_delete
,
421 self
._log
.debug("Deleting openmano vnfrs")
422 for vnfr
in self
._vnfrs
:
423 yield from vnfr
.delete()
428 self
._log
.debug("Creating openmano scenario")
429 name_uuid_map
= yield from self
._loop
.run_in_executor(
431 self
._cli
_api
.ns_list
,
434 if self
._nsd
_msg
.name
in name_uuid_map
:
435 self
._log
.debug("Found existing openmano scenario")
436 self
._nsd
_uuid
= name_uuid_map
[self
._nsd
_msg
.name
]
440 # Use the nsd uuid as the scenario name to rebind to existing
441 # scenario on reload or to support muliple instances of the name
443 self
._nsd
_uuid
, _
= yield from self
._loop
.run_in_executor(
445 self
._cli
_api
.ns_create
,
446 self
.openmano_nsd_yaml
,
449 fpath
= dump_openmano_descriptor(
450 "{}_nsd".format(self
._nsd
_msg
.name
),
451 self
.openmano_nsd_yaml
,
454 self
._log
.debug("Dumped Openmano NS descriptor to: %s", fpath
)
459 def instance_monitor_task(self
):
460 self
._log
.debug("Starting Instance monitoring task")
462 start_time
= time
.time()
466 yield from asyncio
.sleep(1, loop
=self
._loop
)
469 instance_resp_json
= yield from self
._loop
.run_in_executor(
471 self
._http
_api
.get_instance
,
475 self
._log
.debug("Got instance response: %s for NSR ID %s",
479 except openmano_client
.InstanceStatusError
as e
:
480 self
._log
.error("Could not get NS instance status: %s", str(e
))
483 def all_vms_active(vnf
):
484 for vm
in vnf
["vms"]:
485 vm_status
= vm
["status"]
487 if vm_status
!= "ACTIVE":
488 self
._log
.debug("VM is not yet active: %s (status: %s)", vm_uuid
, vm_status
)
493 def any_vm_active_nomgmtip(vnf
):
494 for vm
in vnf
["vms"]:
495 vm_status
= vm
["status"]
497 if vm_status
!= "ACTIVE":
498 self
._log
.debug("VM is not yet active: %s (status: %s)", vm_uuid
, vm_status
)
503 def any_vms_error(vnf
):
504 for vm
in vnf
["vms"]:
505 vm_status
= vm
["status"]
506 vm_vim_info
= vm
["vim_info"]
508 if vm_status
== "ERROR":
509 self
._log
.error("VM Error: %s (vim_info: %s)", vm_uuid
, vm_vim_info
)
514 def get_vnf_ip_address(vnf
):
515 if "ip_address" in vnf
:
516 return vnf
["ip_address"].strip()
519 def get_ext_cp_info(vnf
):
521 for vm
in vnf
["vms"]:
522 if "interfaces" not in vm
:
525 for intf
in vm
["interfaces"]:
526 if "external_name" not in intf
:
529 if not intf
["external_name"]:
532 ip_address
= intf
["ip_address"]
533 if ip_address
is None:
534 ip_address
= "0.0.0.0"
536 cp_info_list
.append((intf
["external_name"], ip_address
))
540 def get_vnf_status(vnfr
):
541 # When we create an openmano descriptor we use <name>__<idx>
542 # to come up with openmano constituent VNF name. Use this
543 # knowledge to map the vnfr back.
544 openmano_vnfr_suffix
= "__{}".format(
545 vnfr
.vnfr
.vnfr_msg
.member_vnf_index_ref
548 for vnf
in instance_resp_json
["vnfs"]:
549 if vnf
["vnf_name"].endswith(openmano_vnfr_suffix
):
552 self
._log
.warning("Could not find vnf status with name that ends with: %s",
553 openmano_vnfr_suffix
)
556 for vnfr
in self
._vnfrs
:
557 if vnfr
in active_vnfs
:
558 # Skipping, so we don't re-publish the same VNF message.
561 vnfr_msg
= vnfr
.vnfr
.vnfr_msg
.deep_copy()
562 vnfr_msg
.operational_status
= "init"
565 vnf_status
= get_vnf_status(vnfr
)
566 self
._log
.debug("Found VNF status: %s", vnf_status
)
567 if vnf_status
is None:
568 self
._log
.error("Could not find VNF status from openmano")
569 vnfr_msg
.operational_status
= "failed"
570 yield from self
._publisher
.publish_vnfr(None, vnfr_msg
)
573 # If there was a VNF that has a errored VM, then just fail the VNF and stop monitoring.
574 if any_vms_error(vnf_status
):
575 self
._log
.debug("VM was found to be in error state. Marking as failed.")
576 vnfr_msg
.operational_status
= "failed"
577 yield from self
._publisher
.publish_vnfr(None, vnfr_msg
)
580 if all_vms_active(vnf_status
):
581 vnf_ip_address
= get_vnf_ip_address(vnf_status
)
583 if vnf_ip_address
is None:
584 self
._log
.warning("No IP address obtained "
585 "for VNF: {}, will retry.".format(
586 vnf_status
['vnf_name']))
589 self
._log
.debug("All VMs in VNF are active. Marking as running.")
590 vnfr_msg
.operational_status
= "running"
592 self
._log
.debug("Got VNF ip address: %s", vnf_ip_address
)
593 vnfr_msg
.mgmt_interface
.ip_address
= vnf_ip_address
594 vnfr_msg
.vnf_configuration
.config_access
.mgmt_ip_address
= vnf_ip_address
597 for vm
in vnf_status
["vms"]:
598 if vm
["uuid"] not in self
._vdur
_console
_handler
:
599 vdur_console_handler
= VnfrConsoleOperdataDtsHandler(self
._dts
, self
._log
, self
._loop
,
600 self
, vnfr_msg
.id,vm
["uuid"],vm
["name"])
601 yield from vdur_console_handler
.register()
602 self
._vdur
_console
_handler
[vm
["uuid"]] = vdur_console_handler
604 vdur_msg
= vnfr_msg
.vdur
.add()
605 vdur_msg
.vim_id
= vm
["vim_vm_id"]
606 vdur_msg
.id = vm
["uuid"]
608 # Add connection point information for the config manager
609 cp_info_list
= get_ext_cp_info(vnf_status
)
610 for (cp_name
, cp_ip
) in cp_info_list
:
611 cp
= vnfr_msg
.connection_point
.add()
613 cp
.short_name
= cp_name
614 cp
.ip_address
= cp_ip
616 yield from self
._publisher
.publish_vnfr(None, vnfr_msg
)
617 active_vnfs
.append(vnfr
)
619 if (time
.time() - start_time
) > OpenmanoNsr
.TIMEOUT_SECS
:
620 self
._log
.error("NSR timed out before reaching running state")
621 vnfr_msg
.operational_status
= "failed"
622 yield from self
._publisher
.publish_vnfr(None, vnfr_msg
)
625 except Exception as e
:
626 vnfr_msg
.operational_status
= "failed"
627 yield from self
._publisher
.publish_vnfr(None, vnfr_msg
)
628 self
._log
.exception("Caught exception publishing vnfr info: %s", str(e
))
631 if len(active_vnfs
) == len(self
._vnfrs
):
632 self
._log
.info("All VNF's are active. Exiting NSR monitoring task")
636 def deploy(self
,nsr_msg
):
637 if self
._nsd
_uuid
is None:
638 raise ValueError("Cannot deploy an uncreated nsd")
640 self
._log
.debug("Deploying openmano scenario")
642 name_uuid_map
= yield from self
._loop
.run_in_executor(
644 self
._cli
_api
.ns_instance_list
,
647 if self
._nsr
_config
_msg
.name
in name_uuid_map
:
648 self
._log
.debug("Found existing instance with nsr name: %s", self
._nsr
_config
_msg
.name
)
649 self
._nsr
_uuid
= name_uuid_map
[self
._nsr
_config
_msg
.name
]
651 self
._nsr
_msg
= nsr_msg
652 fpath
= dump_openmano_descriptor(
653 "{}_instance_sce_create".format(self
._nsr
_config
_msg
.name
),
654 self
.openmano_instance_create_yaml
,
656 self
._log
.debug("Dumped Openmano NS Scenario Cretae to: %s", fpath
)
658 self
._nsr
_uuid
= yield from self
._loop
.run_in_executor(
660 self
._cli
_api
.ns_instance_scenario_create
,
661 self
.openmano_instance_create_yaml
)
664 self
._monitor
_task
= asyncio
.ensure_future(
665 self
.instance_monitor_task(), loop
=self
._loop
671 for _
,handler
in self
._vdur
_console
_handler
.items():
672 handler
._regh
.deregister()
674 if self
._nsr
_uuid
is None:
675 self
._log
.warning("Cannot terminate an un-instantiated nsr")
678 if self
._monitor
_task
is not None:
679 self
._monitor
_task
.cancel()
680 self
._monitor
_task
= None
682 self
._log
.debug("Terminating openmano nsr")
683 yield from self
._loop
.run_in_executor(
685 self
._cli
_api
.ns_terminate
,
690 class OpenmanoNsPlugin(rwnsmplugin
.NsmPluginBase
):
692 RW Implentation of the NsmPluginBase
694 def __init__(self
, dts
, log
, loop
, publisher
, ro_account
):
698 self
._publisher
= publisher
701 self
._http
_api
= None
702 self
._openmano
_nsrs
= {}
704 self
._set
_ro
_account
(ro_account
)
706 def _set_ro_account(self
, ro_account
):
707 self
._log
.debug("Setting openmano plugin cloud account: %s", ro_account
)
708 self
._cli
_api
= openmano_client
.OpenmanoCliAPI(
710 ro_account
.openmano
.host
,
711 ro_account
.openmano
.port
,
712 ro_account
.openmano
.tenant_id
,
715 self
._http
_api
= openmano_client
.OpenmanoHttpAPI(
717 ro_account
.openmano
.host
,
718 ro_account
.openmano
.port
,
719 ro_account
.openmano
.tenant_id
,
722 def create_nsr(self
, nsr_config_msg
, nsd_msg
, key_pairs
=None):
724 Create Network service record
726 openmano_nsr
= OpenmanoNsr(
737 self
._openmano
_nsrs
[nsr_config_msg
.id] = openmano_nsr
740 def deploy(self
, nsr_msg
):
741 self
._log
.debug("Received NSR Deploy msg : %s", nsr_msg
)
742 openmano_nsr
= self
._openmano
_nsrs
[nsr_msg
.ns_instance_config_ref
]
743 yield from openmano_nsr
.create()
744 yield from openmano_nsr
.deploy(nsr_msg
)
747 def instantiate_ns(self
, nsr
, xact
):
749 Instantiate NSR with the passed nsr id
751 yield from nsr
.instantiate(xact
)
754 def instantiate_vnf(self
, nsr
, vnfr
):
756 Instantiate NSR with the passed nsr id
758 openmano_nsr
= self
._openmano
_nsrs
[nsr
.id]
759 yield from openmano_nsr
.add_vnfr(vnfr
)
761 # Mark the VNFR as running
762 # TODO: Create a task to monitor nsr/vnfr status
763 vnfr_msg
= vnfr
.vnfr_msg
.deep_copy()
764 vnfr_msg
.operational_status
= "init"
766 self
._log
.debug("Attempting to publish openmano vnf: %s", vnfr_msg
)
767 with self
._dts
.transaction() as xact
:
768 yield from self
._publisher
.publish_vnfr(xact
, vnfr_msg
)
771 def instantiate_vl(self
, nsr
, vlr
):
773 Instantiate NSR with the passed nsr id
775 self
._log
.debug("Received instantiate VL for NSR {}; VLR {}".format(nsr
.id,vlr
))
776 openmano_nsr
= self
._openmano
_nsrs
[nsr
.id]
777 yield from openmano_nsr
.add_vlr(vlr
)
780 def terminate_ns(self
, nsr
):
782 Terminate the network service
785 openmano_nsr
= self
._openmano
_nsrs
[nsr_id
]
786 yield from openmano_nsr
.terminate()
787 yield from openmano_nsr
.delete()
789 with self
._dts
.transaction() as xact
:
790 for vnfr
in openmano_nsr
.vnfrs
:
791 self
._log
.debug("Unpublishing VNFR: %s", vnfr
.vnfr
.vnfr_msg
)
792 yield from self
._publisher
.unpublish_vnfr(xact
, vnfr
.vnfr
.vnfr_msg
)
794 del self
._openmano
_nsrs
[nsr_id
]
797 def terminate_vnf(self
, vnfr
):
799 Terminate the network service
804 def terminate_vl(self
, vlr
):
806 Terminate the virtual link