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.
16 from . import nsmpluginbase
17 from . import openmano_nsm
20 class RwNsPlugin(nsmpluginbase
.NsmPluginBase
):
22 RW Implentation of the NsmPluginBase
24 def __init__(self
, dts
, log
, loop
, publisher
, ro_account
, project
):
28 self
._project
= project
30 def set_state(self
, nsr_id
, state
):
33 def create_nsr(self
, nsr_msg
, nsd
, key_pairs
=None, ssh_key
=None):
35 Create Network service record
40 def deploy(self
, nsr
):
44 def instantiate_ns(self
, nsr
, config_xact
):
46 Instantiate NSR with the passed nsr id
48 yield from nsr
.instantiate(config_xact
)
51 def instantiate_vnf(self
, nsr
, vnfr
, scaleout
=False):
53 Instantiate NSR with the passed nsr id
55 yield from vnfr
.instantiate(nsr
)
58 def instantiate_vl(self
, nsr
, vlr
):
60 Instantiate NSR with the passed nsr id
62 yield from vlr
.instantiate()
65 def terminate_ns(self
, nsr
):
67 Terminate the network service
72 def terminate_vnf(self
, nsr
, vnfr
, scalein
=False):
76 yield from vnfr
.terminate()
79 def terminate_vl(self
, vlr
):
81 Terminate the virtual link
83 yield from vlr
.terminate()
86 def update_vnfr(self
, vnfr
):
87 """ Update the virtual network function record """
88 yield from vnfr
.update_vnfm()
90 class NsmPlugins(object):
93 self
._plugin
_classes
= {
94 "openmano": openmano_nsm
.OpenmanoNsPlugin
,
100 return self
._plugin
_classes
102 def __getitem__(self
, name
):
104 return self
._plugin
_classes
[name
]
106 def register(self
, plugin_name
, plugin_class
, *args
):
107 """ Register a plugin to this Nsm"""
108 self
._plugin
_classes
[plugin_name
] = plugin_class
110 def deregister(self
, plugin_name
, plugin_class
, *args
):
111 """ Deregister a plugin to this Nsm"""
112 if plugin_name
in self
._plugin
_classes
:
113 del self
._plugin
_classes
[plugin_name
]
115 def class_by_plugin_name(self
, name
):
116 """ Get class by plugin name """
117 return self
._plugin
_classes
[name
]