Revert "Bug 240 - NS Scaling Scale-out" 65/1565/1
authorvelandy <rajesh.velandy@riftio.com>
Thu, 13 Apr 2017 21:48:10 +0000 (22:48 +0100)
committervelandy <rajesh.velandy@riftio.com>
Thu, 13 Apr 2017 21:48:10 +0000 (22:48 +0100)
This reverts commit 1db958d9bb3ea59931b613b0d9be18da6ae523ad.

Change-Id: I7a3b8bf7e300641dcebffc41c639dc0e4e777383

models/openmano/python/rift/openmano/rift2openmano.py
rwlaunchpad/plugins/rwnsm/rift/tasklets/rwnsmtasklet/openmano_nsm.py
rwlaunchpad/plugins/rwnsm/rift/tasklets/rwnsmtasklet/rwnsmplugin.py
rwlaunchpad/plugins/rwnsm/rift/tasklets/rwnsmtasklet/rwnsmtasklet.py

index 5b9faeb..178cc1e 100755 (executable)
@@ -34,7 +34,7 @@ from gi.repository import (
     RwYang,
     RwVnfdYang,
     RwNsdYang,
-    )
+)
 
 import rift.package.store
 import rift.package.cloud_init
@@ -230,7 +230,7 @@ def rift2openmano_nsd(rift_nsd, rift_vnfds, openmano_vnfd_ids, rift_vnfd_id=None
     openmano = {}
     openmano["name"] = rift_nsd.name
     if rift_vnfd_id is not None:
-         openmano["name"] += "scale1"
+        openmano["name"] += "scale1"
     openmano["description"] = rift_nsd.description
     topology = {}
     openmano["topology"] = topology
@@ -247,12 +247,12 @@ def rift2openmano_nsd(rift_nsd, rift_vnfds, openmano_vnfd_ids, rift_vnfd_id=None
             topology["nodes"][rift_vnfd.name + "__" + str(member_idx)] = {
                 "type": "VNF",
                 "vnf_id": openmano_vnfd_id
-                }
+            }
         else:
             topology["nodes"][rift_vnfd.name + "__" + str(member_idx)] = {
                 "type": "VNF",
                 "VNF model": rift_vnfd.name
-                }
+            }
 
     for vld in rift_nsd.vlds:
         # Openmano has both bridge_net and dataplane_net models for network types
@@ -272,14 +272,14 @@ def rift2openmano_nsd(rift_nsd, rift_vnfds, openmano_vnfd_ids, rift_vnfd_id=None
         if True:
             if vld.name not in topology["nodes"]:
                 topology["nodes"][vld.name] = {
-                        "type": "external_network",
-                        "model": vld.name,
-                        }
+                    "type": "external_network",
+                    "model": vld.name,
+                }
 
             # Add the external network to the list of connection points
             topology["connections"][vld.name]["nodes"].append(
-                    {vld.name: "0"}
-                    )
+                {vld.name: "0"}
+            )
         elif vld.provider_network.has_field("physical_network"):
             # Add the external datacenter network to the topology
             # node list if it isn't already added
@@ -290,14 +290,14 @@ def rift2openmano_nsd(rift_nsd, rift_vnfds, openmano_vnfd_ids, rift_vnfd_id=None
 
             if ext_net_name not in topology["nodes"]:
                 topology["nodes"][ext_net_name] = {
-                        "type": "external_network",
-                        "model": ext_net_name_with_seg,
-                        }
+                    "type": "external_network",
+                    "model": ext_net_name_with_seg,
+                }
 
             # Add the external network to the list of connection points
             topology["connections"][vld.name]["nodes"].append(
-                    {ext_net_name: "0"}
-                    )
+                {ext_net_name: "0"}
+            )
 
 
         for vnfd_cp in vld.vnfd_connection_point_ref:
@@ -317,56 +317,39 @@ def rift2openmano_nsd(rift_nsd, rift_vnfds, openmano_vnfd_ids, rift_vnfd_id=None
             )
     return openmano
 
-def rift2openmano_vnfd_nsd(rift_nsd, rift_vnfds, openmano_vnfd_ids,rift_vnfd_id=None):
-
+def rift2openmano_vnfd_nsd(rift_nsd, rift_vnfds, rift_vnfd_id):
 
     if rift_vnfd_id not in rift_vnfds:
-            print ("IDS", rift_vnfds)
-            raise VNFNotFoundError("VNF id %s not provided" % rift_vnfd_id)
+        print ("IDS", rift_vnfds)
+        raise VNFNotFoundError("VNF id %s not provided" % rift_vnfd_id)
 
     openmano_vnfd_nsd = {}
-    openmano_vnfd_nsd["name"] = rift_vnfd_id+'__'+'scaling_group'
+    openmano_vnfd_nsd["name"] = rift_vnfd_id+'-'+'scaling_group'
     openmano_vnfd_nsd["description"] = "Scaling Group"
     topology = {}
     openmano_vnfd_nsd["topology"] = topology
+
+    topology["nodes"] = {}
+    openmano_vnfd_nsd["topology"] = topology
     topology["connections"] = {}
     topology["nodes"] = {}
-    tst_index = []
-    openmano_vnfd_id = openmano_vnfd_ids.get(rift_vnfd_id,None)
-    logger.debug("CONSTVNF %s", rift_nsd.constituent_vnfds)
-    for rvnfd_id in rift_nsd.constituent_vnfds:
-        if rvnfd_id.vnfd_id_ref == rift_vnfd_id:
-            topology["nodes"][rift_vnfd_id+'__'+str(rvnfd_id.member_vnf_index)] = {
-                "type": "VNF",
-                "vnf_id": openmano_vnfd_id
-            }
+    topology["nodes"] = {
+        "type": "VNF",
+        "vnf_id": rift_vnfd_id
+    }
 
     for vld in rift_nsd.vlds:
 
         # Create a connections entry for each external VLD
         topology["connections"][vld.name] = {}
         topology["connections"][vld.name]["nodes"] = []
-        if True:
-            if vld.name not in topology["nodes"]:
-                topology["nodes"][vld.name] = {
-                        "type": "external_network",
-                        "model": vld.name,
-                        }
-            topology["connections"][vld.name]["nodes"].append(
-                    {vld.name: "0"}
-                    )
-
-            
 
     for vnfd_cp in vld.vnfd_connection_point_ref:
-        if not rift_vnfd_id in vnfd_cp.vnfd_id_ref:
+        if not rit_vnfd_id in vnfd_cp.vnfd_id_ref:
             continue
         if rift_vnfd_id in vnfd_cp.vnfd_id_ref:
-
             # Get the RIFT VNF for this external VLD connection point
             vnfd = rift_vnfds[vnfd_cp.vnfd_id_ref]
-            
-
             # For each VNF in this connection, use the same interface name
             topology["connections"][vld.name]["type"] = "link"
             # Vnf ref is the vnf name with the member_vnf_idx appended
@@ -379,7 +362,6 @@ def rift2openmano_vnfd_nsd(rift_nsd, rift_vnfds, openmano_vnfd_ids,rift_vnfd_id=
             )
     return openmano_vnfd_nsd
 
-
 def cloud_init(rift_vnfd_id, vdu):
     """ Populate cloud_init with script from
          either the inline contents or from the file provided
@@ -391,7 +373,7 @@ def cloud_init(rift_vnfd_id, vdu):
         logger.debug("cloud_init script provided inline %s", vdu.cloud_init)
         cloud_init_msg = vdu.cloud_init
     elif vdu.cloud_init_file is not None:
-       # Get cloud-init script contents from the file provided in the cloud_init_file param
+        # Get cloud-init script contents from the file provided in the cloud_init_file param
         logger.debug("cloud_init script provided in file %s", vdu.cloud_init_file)
         filename = vdu.cloud_init_file
         vnfd_package_store.refresh()
@@ -420,9 +402,9 @@ def config_file_init(rift_vnfd_id, vdu, cfg_file):
     stored_package = vnfd_package_store.get_package(rift_vnfd_id)
     cloud_init_extractor = rift.package.cloud_init.PackageCloudInitExtractor(logger)
     try:
-            cfg_file_msg = cloud_init_extractor.read_script(stored_package, filename)
+        cfg_file_msg = cloud_init_extractor.read_script(stored_package, filename)
     except rift.package.cloud_init.CloudInitExtractionError as e:
-            raise ValueError(e)
+        raise ValueError(e)
 
     logger.debug("Current config file msg is {}".format(cfg_file_msg))
     return cfg_file_msg
@@ -494,7 +476,7 @@ def rift2openmano_vnfd(rift_vnfd, rift_nsd):
             "VNFC": vdu.name,
             "local_iface_name": ext_if.name,
             "description": "%s iface on VDU %s" % (ext_if.name, vdu.name),
-            }
+        }
 
         vnf["external-connections"].append(connection)
 
@@ -505,7 +487,7 @@ def rift2openmano_vnfd(rift_vnfd, rift_nsd):
             "description": vld.description,
             "type": "bridge",
             "elements": [],
-            }
+        }
 
         # Add the specific VDU connection points
         for int_cp in vld.internal_connection_point:
@@ -513,7 +495,7 @@ def rift2openmano_vnfd(rift_vnfd, rift_nsd):
             connection["elements"].append({
                 "VNFC": vdu.name,
                 "local_iface_name": int_if.name,
-                })
+            })
         if "internal-connections" not in vnf:
             vnf["internal-connections"] = []
 
@@ -526,7 +508,7 @@ def rift2openmano_vnfd(rift_vnfd, rift_nsd):
             "name": vdu.name,
             "description": vdu.name,
             "bridge-ifaces": [],
-            }
+        }
 
         if vdu.vm_flavor.has_field("storage_gb") and vdu.vm_flavor.storage_gb:
             vnfc["disk"] = vdu.vm_flavor.storage_gb
@@ -545,9 +527,9 @@ def rift2openmano_vnfd(rift_vnfd, rift_nsd):
                 dedicated_int = True
         if vdu.guest_epa.has_field("numa_node_policy") or dedicated_int:
             vnfc["numas"] = [{
-                           "memory": max(int(vdu.vm_flavor.memory_mb/1024), 1),
-                           "interfaces":[],
-                           }]
+                "memory": max(int(vdu.vm_flavor.memory_mb/1024), 1),
+                "interfaces":[],
+            }]
             numa_node_policy = vdu.guest_epa.numa_node_policy
             if numa_node_policy.has_field("node"):
                 numa_node = numa_node_policy.node[0]
@@ -558,9 +540,9 @@ def rift2openmano_vnfd(rift_vnfd, rift_nsd):
                     if len(numa_node.paired_threads.paired_thread_ids) > 0:
                         vnfc["numas"][0]["paired-threads-id"] = []
                         for pair in numa_node.paired_threads.paired_thread_ids:
-                             vnfc["numas"][0]["paired-threads-id"].append(
-                                     [pair.thread_a, pair.thread_b]
-                                     )
+                            vnfc["numas"][0]["paired-threads-id"].append(
+                                [pair.thread_a, pair.thread_b]
+                            )
 
             else:
                 if vdu.vm_flavor.has_field("vcpu_count"):
@@ -595,7 +577,7 @@ def rift2openmano_vnfd(rift_vnfd, rift_nsd):
         if vdu.has_field("volumes"):
             vnfc["devices"] = []
             # Sort volumes as device-list is implictly ordered by Openmano
-            newvollist = sorted(vdu.volumes, key=lambda k: k.name) 
+            newvollist = sorted(vdu.volumes, key=lambda k: k.name)
             for iter_num, volume in enumerate(newvollist):
                 if iter_num == 0:
                     # Convert the first volume to vnfc.image
@@ -610,7 +592,7 @@ def rift2openmano_vnfd(rift_vnfd, rift_nsd):
                     device = {}
                     device["type"] = volume.device_type
                     device["image"] = volume.image
-                    vnfc["devices"].append(device)   
+                    vnfc["devices"].append(device)
 
         vnfc_boot_data_init = False
         if vdu.has_field("cloud_init") or vdu.has_field("cloud_init_file"):
@@ -632,14 +614,14 @@ def rift2openmano_vnfd(rift_vnfd, rift_nsd):
                     cfg_source = config_file_init(rift_vnfd.id, vdu, custom_config_file.source)
                     om_cfgfile_list.append({"dest":custom_config_file.dest, "content": cfg_source})
                 vnfc['boot-data']['config-files'] = om_cfgfile_list
+
 
         vnf["VNFC"].append(vnfc)
 
         for int_if in list(vdu.internal_interface) + list(vdu.external_interface):
             intf = {
                 "name": int_if.name,
-                }
+            }
             if int_if.virtual_interface.has_field("vpci"):
                 intf["vpci"] = int_if.virtual_interface.vpci
 
@@ -694,14 +676,14 @@ def parse_args(argv=sys.argv[1:]):
         '-o', '--outdir',
         default='-',
         help="Directory to output converted descriptors. Default is stdout",
-        )
+    )
 
     parser.add_argument(
         '-n', '--nsd-file-hdl',
         metavar="nsd_file",
         type=argparse.FileType('r'),
         help="Rift NSD Descriptor File",
-        )
+    )
 
     parser.add_argument(
         '-v', '--vnfd-file-hdls',
@@ -709,7 +691,7 @@ def parse_args(argv=sys.argv[1:]):
         action='append',
         type=argparse.FileType('r'),
         help="Rift VNFD Descriptor File",
-        )
+    )
 
     args = parser.parse_args(argv)
 
@@ -744,6 +726,7 @@ def write_yaml_to_file(name, outdir, desc_dict):
 def main(argv=sys.argv[1:]):
     args = parse_args(argv)
     nsd = None
+    rift_vnfd_id = 'test_vnfd'
     openmano_vnfr_ids = dict()
     vnf_dict = None
     if args.vnfd_file_hdls is not None:
@@ -766,4 +749,4 @@ def main(argv=sys.argv[1:]):
 
 if __name__ == "__main__":
     logging.basicConfig(level=logging.WARNING)
-    main()
+    main()
\ No newline at end of file
index 82a7f4e..6a19cb9 100644 (file)
@@ -8,6 +8,7 @@
 #
 #       http://www.apache.org/licenses/LICENSE-2.0
 #
+#test
 #   Unless required by applicable law or agreed to in writing, software
 #   distributed under the License is distributed on an "AS IS" BASIS,
 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -110,7 +111,7 @@ class VnfrConsoleOperdataDtsHandler(object):
                         None,
                         self._nsr._http_api.get_instance_vm_console_url,
                         self._nsr._nsr_uuid,
-                        self._vdur_id
+                        self._vdur_id,
                     )
 
                     self._log.debug("Got console response: %s for NSR ID %s vdur ID %s",
@@ -261,9 +262,9 @@ class OpenmanoNSRecordState(Enum):
 class OpenmanoNsr(object):
     TIMEOUT_SECS = 300
 
-    def __init__(self, dts, log, loop, publisher, cli_api, http_api, nsd_msg, nsr_config_msg,key_pairs,rift_vnfd_id=None ):
-        self._log = log
+    def __init__(self, dts, log, loop, publisher, cli_api, http_api, nsd_msg, nsr_config_msg,key_pairs, rift_vnfd_id=None):
         self._dts = dts
+        self._log = log
         self._loop = loop
         self._publisher = publisher
         self._cli_api = cli_api
@@ -271,6 +272,7 @@ class OpenmanoNsr(object):
 
         self._nsd_msg = nsd_msg
         self._nsr_config_msg = nsr_config_msg
+
         self._vlrs = []
         self._vnfrs = []
         self._nsrs = {}
@@ -279,7 +281,6 @@ class OpenmanoNsr(object):
 
         self._nsd_uuid = None
         self._nsr_uuid = None
-        self._nsd_msg = nsd_msg
 
         self._nsr_msg = None
 
@@ -293,10 +294,6 @@ class OpenmanoNsr(object):
     def nsd(self):
         return rift2openmano.RiftNSD(self._nsd_msg)
 
-    @property
-    def rift_vnfd_id(self):
-        return self._rift_vnfd_id
-
     @property
     def nsd_msg(self):
         return self._nsd_msg
@@ -305,6 +302,13 @@ class OpenmanoNsr(object):
     def nsr_config_msg(self):
         return self._nsr_config_msg
 
+    @property
+    def nsr_msg(self):
+        return self._nsr_msg
+
+    @property
+    def key_pairs(self):
+        return self._key_pairs
 
     @property
     def vnfds(self):
@@ -318,18 +322,6 @@ class OpenmanoNsr(object):
     def vnfrs(self):
         return self._vnfrs
 
-    @property
-    def key_pairs(self):
-        return self._key_pairs
-
-    @property
-    def nsr_msg(self):
-        return self._nsr_msg
-
-    @property
-    def vlrs(self):
-        return self._vlrs
-
     @property
     def openmano_nsd_yaml(self):
         self._log.debug("Converting nsd %s from rift to openmano", self.nsd.id)
@@ -337,14 +329,12 @@ class OpenmanoNsr(object):
         return yaml.safe_dump(openmano_nsd, default_flow_style=False)
 
     @property
-    def openmano_scaling_yaml(self):
-        self._log.debug("Creating Openmano Scaling Descriptor %s")
-        try:
-            openmano_vnfd_nsd = rift2openmano.rift2openmano_vnfd_nsd(self.nsd, self.vnfds, self.vnfr_ids, self._rift_vnfd_id)
-            return yaml.safe_dump(openmano_vnfd_nsd, default_flow_style=False)
-        except Exception as e:
-            self._log.exception("Scaling Descriptor Exception: %s", str(e))
+    def scaling_group_nsd_yaml(self):
+        self._log.debug("Creating Scaling Group Scenarion Descriptor for VNF %s", self._rift_vnfd_id)
+        openmano_vnfd_nsd = rift2openmano.rift2openmano_vnfd_nsd(self.nsd, self.vnfds, self.vnfr_ids, self._rift_vnfd_id)
+        return yaml.safe_dump(vnfd_nsd, default_flow_style=False)
 
+    @property
     def get_ssh_key_pairs(self):
         cloud_config = {}
         key_pairs = list()
@@ -389,16 +379,15 @@ class OpenmanoNsr(object):
 
     @property
     def openmano_instance_create_yaml(self):
-        self._log.debug("Creating instance-scenario-create input file for nsd %s with name %s", self.nsd.id, self._nsr_config_msg.name)
+        self._log.debug("Creating instance-scenario-create input file for nsd %s with name %s", self.nsd.id, self._nsr_config_msg.name, self._rift_vnfd_id)
         openmano_instance_create = {}
         openmano_instance_create["name"] = self._nsr_config_msg.name
         openmano_instance_create["description"] = self._nsr_config_msg.description
         openmano_instance_create["scenario"] = self._nsd_uuid
-        self._log.debug("DEBUG NSRID %s", self._nsd_uuid)
 
-        cloud_config = self.get_ssh_key_pairs()
-        if cloud_config:
-            openmano_instance_create["cloud-config"] = cloud_config
+        #cloud_config = self.get_ssh_key_pairs()
+        #if cloud_config:
+        #    openmano_instance_create["cloud-config"] = cloud_config
         if self._nsr_config_msg.has_field("om_datacenter"):
             openmano_instance_create["datacenter"] = self._nsr_config_msg.om_datacenter
         openmano_instance_create["vnfs"] = {}
@@ -452,16 +441,13 @@ class OpenmanoNsr(object):
         return yaml.safe_dump(openmano_instance_create, default_flow_style=False,width=1000)
 
     @property
-    def scaling_instance_create_yaml(self, scaleout=False):
-        self._log.debug("Creating instance-scenario-create input file for nsd %s with name %s", self.nsd.id, self._nsr_config_msg.name+"scal1")
+    def scaling_instance_create_yaml(self):
+        self._log.debug("Creating instance-scenario-create input file for nsd %s with name %s", self.nsd.id, self._nsr_config_msg.name)
         scaling_instance_create = {}
-        scaling_instance_create["name"] = self._nsr_config_msg.name + "__"+"scaling_group"
-        scaling_instance_create["description"] = self._nsr_config_msg.description
-        if scaleout:
-            scaling_instance_create["scenario"] = self._nsd_uuid + "__" +"scal"
-        else:
-            scaling_instance_create["scenario"] = self._nsd_uuid
-
+        scaling_instance_create["vnfs"] = {}
+        scaling_instance_create["name"] = self._nsr_config_msg.name+"scal1"
+        scaling_instance_create["description"] = "Scaling Group Instance Scenario File"
+        scaling_instance_create["scenario"] = self._rift_vnfd_id
 
         if self._nsr_config_msg.has_field("om_datacenter"):
             scaling_instance_create["datacenter"] = self._nsr_config_msg.om_datacenter
@@ -483,18 +469,8 @@ class OpenmanoNsr(object):
                     ip_profile = {}
                     if vld_msg.vim_network_name:
                         network["netmap-use"] = vld_msg.vim_network_name
-                    #else:
-                    #    network["netmap-create"] = vlr.name
-                    if vlr.om_datacenter_name:
-                        network["datacenter"] = vlr.om_datacenter_name
-                    elif vld_msg.has_field("om_datacenter"):
-                        network["datacenter"] = vld_msg.om_datacenter
-                    elif "datacenter" in scaling_instance_create:
-                        network["datacenter"] = openmano_instance_create["datacenter"]
-                    if network:
-                        scaling_instance_create["networks"][vld_msg.name]["sites"].append(network)
+        return yaml.safe_dump(scaling_instance_create, default_flow_style=False,width=1000)
 
-        return yaml.safe_dump(scaling_instance_create, default_flow_style=False, width=1000)
 
     @asyncio.coroutine
     def add_vlr(self, vlr):
@@ -585,17 +561,19 @@ class OpenmanoNsr(object):
 
     @asyncio.coroutine
     def scaling_scenario_create(self):
-        self._log.debug("Creating scaling openmano scenario")
-        self._nsd_uuid, _ = yield from self._loop.run_in_executor(
+        self._log.debug("Creating Openmano Scenario for the Scaling Group VNF")
+        self._vnfd_nsd_uuid, _ = yield from self._loop.run_in_executor(
             None,
             self._cli_api.ns_create,
-            self.openmano_scaling_yaml,
-
+            self.scaling_group_nsd_yaml,
+            self._rift_vnfd_id
         )
         fpath = dump_openmano_descriptor(
-            "{}_sgd".format(self._nsd_msg.name),
-            self.scaling_instance_create_yaml,
+            "{}_scaling_group_nsd".format(self._rift_vnfd_id),
+            self.scaling_group_nsd_yaml,
         )
+        self._log.debug("Dumped Scaling group scenario to '%s'", fpath)
+        self._created = True
 
     @asyncio.coroutine
     def instance_monitor_task(self):
@@ -796,7 +774,7 @@ class OpenmanoNsr(object):
         if self._nsd_uuid is None:
             raise ValueError("Cannot deploy an uncreated nsd")
 
-        self._log.debug("Deploying openmano instance scenario")
+        self._log.debug("Deploying openmano scenario")
 
         name_uuid_map = yield from self._loop.run_in_executor(
             None,
@@ -812,12 +790,13 @@ class OpenmanoNsr(object):
                 "{}_instance_sce_create".format(self._nsr_config_msg.name),
                 self.openmano_instance_create_yaml,
             )
-            self._log.debug("Dumped Openmano instance Scenario Cretae to: %s", fpath)
+            self._log.debug("Dumped Openmano NS Scenario Cretae to: %s", fpath)
 
             self._nsr_uuid = yield from self._loop.run_in_executor(
                 None,
                 self._cli_api.ns_instance_scenario_create,
-                self.openmano_instance_create_yaml)
+                self.scaling_instance_create_yaml)
+
 
         self._state = OpenmanoNSRecordState.INSTANTIATION_PENDING
 
@@ -826,28 +805,20 @@ class OpenmanoNsr(object):
         )
 
     @asyncio.coroutine
-    def deploy_scaling(self, nsr_msg, rift_vnfd_id):
-        self._log.debug("Deploying Scaling instance scenario")
+    def scaling_scenario_deploy(self, nsr_msg):
+        self._log.debug("Deploying Scaling scenario")
         self._nsr_msg = nsr_msg
         self._rift_vnfd_id = rift_vnfd_id
         fpath = dump_openmano_descriptor(
             "{}_scale_instance".format(self._nsr_config_msg.name),
             self.scaling_instance_create_yaml
-            )
-        self._nsr_uuid = yield from self._loop.run_in_executor(
-                None,
-                self._cli_api.ns_instance_scenario_create,
-                self.scaling_instance_create_yaml)
-
-        self._state = OpenmanoNSRecordState.INSTANTIATION_PENDING
+        )
+        self._state = OpenmanoNSRecordState.INIT
 
         self._monitor_task = asyncio.ensure_future(
             self.instance_monitor_task(), loop=self._loop
         )
 
-        self._state = OpenmanoNSRecordState.INIT
-
-
     @asyncio.coroutine
     def terminate(self):
 
@@ -914,6 +885,7 @@ class OpenmanoNsr(object):
 
 
 
+
 class OpenmanoNsPlugin(rwnsmplugin.NsmPluginBase):
     """
         RW Implentation of the NsmPluginBase
@@ -923,7 +895,6 @@ class OpenmanoNsPlugin(rwnsmplugin.NsmPluginBase):
         self._log = log
         self._loop = loop
         self._publisher = publisher
-
         self._cli_api = None
         self._http_api = None
         self._openmano_nsrs = {}
@@ -956,7 +927,7 @@ class OpenmanoNsPlugin(rwnsmplugin.NsmPluginBase):
                  OpenmanoNSRecordState.__members__.items() \
                  if member.value == state.value]
 
-    def create_nsr(self, nsr_config_msg, nsd_msg, key_pairs=None):
+    def create_nsr(self, nsr_config_msg, nsd_msg,  key_pairs=None):
         """
         Create Network service record
         """
@@ -980,6 +951,13 @@ class OpenmanoNsPlugin(rwnsmplugin.NsmPluginBase):
         yield from openmano_nsr.create()
         yield from openmano_nsr.deploy(nsr_msg)
 
+    @asyncio.coroutine
+    def deploy(self, nsr_msg):
+        self._log.debug("Received Scale out msg")
+        openmano_nsr = self._openmano_nsrs[nsr_msg.ns_instance_config_ref]
+        yield from openmano_nsr.scaling_scenario_create()
+        yield from openmano_nsr.scaling_scenario_deploy(nsr_msg)
+
     @asyncio.coroutine
     def instantiate_ns(self, nsr, xact):
         """
@@ -1004,31 +982,28 @@ class OpenmanoNsPlugin(rwnsmplugin.NsmPluginBase):
                 openmano_nsr.nsd_msg,
                 openmano_nsr.nsr_config_msg,
                 openmano_nsr.key_pairs,
-                #openmano_nsr.nsr_msg,
                 vnfr.vnfd.id
             )
-            for vlr in openmano_nsr.vlrs:
-                yield from openmano_vnf_nsr.add_vlr(vlr)
+            # Add new nsr to parent nsr
             try:
                 yield from openmano_nsr.add_nsr(openmano_vnf_nsr, vnfr)
             except Exception as e:
-                self.log.exception(str(e))
+                self.log.exception("Add VNFR Error ", str(e))
             try:
                 yield from openmano_vnf_nsr.add_vnfr(vnfr)
             except Exception as e:
-                self.log.exception(str(e))
+                self.log.exception("Scenario Create Error", str(e))
             try:
-                yield from openmano_vnf_nsr.scaling_scenario_create()
+                yield from openmano_vnf_nsr.create()
             except Exception as e:
-                self.log.exception(str(e))
+                self.log.exception("Starting instance scenario create ", str(e))
             try:
-                yield from openmano_vnf_nsr.deploy_scaling(openmano_vnf_nsr.nsr_msg, vnfr.id)
+                yield from openmano_vnf_nsr.deploy(openmano_vnf_nsr.nsr_msg)
             except Exception as e:
-                self.log.exception(str(e))
+                self.log.exception("Unable to deploy scaling scenario ", str(e))
         else:
             yield from openmano_nsr.add_vnfr(vnfr)
 
-        # Mark the VNFR as running
         # TODO: Create a task to monitor nsr/vnfr status
         vnfr_msg = vnfr.vnfr_msg.deep_copy()
         vnfr_msg.operational_status = "init"
@@ -1038,6 +1013,8 @@ class OpenmanoNsPlugin(rwnsmplugin.NsmPluginBase):
             yield from self._publisher.publish_vnfr(xact, vnfr_msg)
         self._log.debug("Creating a task to update uptime for vnfr: %s", vnfr.id)
         self._vnfr_uptime_tasks[vnfr.id] = self._loop.create_task(self.vnfr_uptime_update(vnfr))
+        with self._dts.transaction() as xact:
+            yield from openmano_vnf_nsr._publisher.publish_vnfr(xact, vnfr_msg)
 
     def vnfr_uptime_update(self, vnfr):
         try:
@@ -1098,4 +1075,4 @@ class OpenmanoNsPlugin(rwnsmplugin.NsmPluginBase):
         if openmano_nsr._state == OpenmanoNSRecordState.RUNNING:
             yield from openmano_nsr.delete_vlr(vlr)
         else:
-            yield from openmano_nsr.remove_vlr(vlr)
+            yield from openmano_nsr.remove_vlr(vlr)
\ No newline at end of file
index 2b6e617..77fa57c 100755 (executable)
@@ -115,21 +115,3 @@ class NsmPluginBase(object):
     def terminate_vl(self, vlr):
         """Terminate the Virtual Link Record"""
         pass
-
-    @abc.abstractmethod
-    @asyncio.coroutine
-    def create_scale_group_instance(self, group_name, vnfrs):
-        """Create Scale Group Instance"""
-        pass
-
-    @abc.abstractmethod
-    @asyncio.coroutine
-    def instantiate_instance(self, group_name, vnfrs):
-        """Create Instance"""
-        pass
-
-    @abc.abstractmethod
-    @asyncio.coroutine
-    def create_vnfs():
-        """Create VNF"""
-        pass
index 0198776..78a84e8 100755 (executable)
@@ -257,7 +257,7 @@ class VnffgRecord(object):
                        "vnffgd_id_ref": self._vnffgd_msg.id,
                        "vnffgd_name_ref": self._vnffgd_msg.name,
                        "sdn_account": self._sdn_account_name,
-                    }
+                       }
         vnffgr = NsrYang.YangData_Nsr_NsInstanceOpdata_Nsr_Vnffgr.from_dict(vnffgr_dict)
         for rsp in self._vnffgd_msg.rsp:
             vnffgr_rsp = vnffgr.rsp.add()
@@ -281,38 +281,38 @@ class VnffgRecord(object):
                 vnfr_cp_ref.vnfd_id_ref =rsp_cp_ref.vnfd_id_ref
                 vnfr_cp_ref.service_function_type = vnfd[0].service_function_type
                 for nsr_vnfr in self._nsr.vnfrs.values():
-                   if (nsr_vnfr.vnfd.id == vnfr_cp_ref.vnfd_id_ref and
-                      nsr_vnfr.member_vnf_index == vnfr_cp_ref.member_vnf_index_ref):
-                       vnfr_cp_ref.vnfr_id_ref = nsr_vnfr.id
-                       vnfr_cp_ref.vnfr_name_ref = nsr_vnfr.name
-                       vnfr_cp_ref.vnfr_connection_point_ref = rsp_cp_ref.vnfd_connection_point_ref
-
-                       vnfr = yield from self._nsr.fetch_vnfr(nsr_vnfr.xpath)
-                       self._log.debug(" Received VNFR is %s", vnfr)
-                       while vnfr.operational_status != 'running':
-                           self._log.info("Received vnf op status is %s; retrying",vnfr.operational_status)
-                           if vnfr.operational_status == 'failed':
-                               self._log.error("Fetching VNFR for  %s failed", vnfr.id)
-                               raise NsrInstantiationFailed("Failed NS %s instantiation due to VNFR %s failure" % (self.id, vnfr.id))
-                           yield from asyncio.sleep(2, loop=self._loop)
-                           vnfr = yield from self._nsr.fetch_vnfr(nsr_vnfr.xpath)
-                           self._log.debug("Received VNFR is %s", vnfr)
-
-                       vnfr_cp_ref.connection_point_params.mgmt_address =  vnfr.mgmt_interface.ip_address
-                       for cp in vnfr.connection_point:
-                           if cp.name == vnfr_cp_ref.vnfr_connection_point_ref:
-                               vnfr_cp_ref.connection_point_params.port_id = cp.connection_point_id
-                               vnfr_cp_ref.connection_point_params.name = self._nsr.name + '.' + cp.name
-                               for vdu in vnfr.vdur:
-                                   for ext_intf in vdu.external_interface:
-                                       if ext_intf.name == vnfr_cp_ref.vnfr_connection_point_ref:
-                                           vnfr_cp_ref.connection_point_params.vm_id =  vdu.vim_id
-                                           self._log.debug("VIM ID for CP %s in VNFR %s is %s",cp.name,nsr_vnfr.id,
+                    if (nsr_vnfr.vnfd.id == vnfr_cp_ref.vnfd_id_ref and
+                                nsr_vnfr.member_vnf_index == vnfr_cp_ref.member_vnf_index_ref):
+                        vnfr_cp_ref.vnfr_id_ref = nsr_vnfr.id
+                        vnfr_cp_ref.vnfr_name_ref = nsr_vnfr.name
+                        vnfr_cp_ref.vnfr_connection_point_ref = rsp_cp_ref.vnfd_connection_point_ref
+
+                        vnfr = yield from self._nsr.fetch_vnfr(nsr_vnfr.xpath)
+                        self._log.debug(" Received VNFR is %s", vnfr)
+                        while vnfr.operational_status != 'running':
+                            self._log.info("Received vnf op status is %s; retrying",vnfr.operational_status)
+                            if vnfr.operational_status == 'failed':
+                                self._log.error("Fetching VNFR for  %s failed", vnfr.id)
+                                raise NsrInstantiationFailed("Failed NS %s instantiation due to VNFR %s failure" % (self.id, vnfr.id))
+                            yield from asyncio.sleep(2, loop=self._loop)
+                            vnfr = yield from self._nsr.fetch_vnfr(nsr_vnfr.xpath)
+                            self._log.debug("Received VNFR is %s", vnfr)
+
+                        vnfr_cp_ref.connection_point_params.mgmt_address =  vnfr.mgmt_interface.ip_address
+                        for cp in vnfr.connection_point:
+                            if cp.name == vnfr_cp_ref.vnfr_connection_point_ref:
+                                vnfr_cp_ref.connection_point_params.port_id = cp.connection_point_id
+                                vnfr_cp_ref.connection_point_params.name = self._nsr.name + '.' + cp.name
+                                for vdu in vnfr.vdur:
+                                    for ext_intf in vdu.external_interface:
+                                        if ext_intf.name == vnfr_cp_ref.vnfr_connection_point_ref:
+                                            vnfr_cp_ref.connection_point_params.vm_id =  vdu.vim_id
+                                            self._log.debug("VIM ID for CP %s in VNFR %s is %s",cp.name,nsr_vnfr.id,
                                                             vnfr_cp_ref.connection_point_params.vm_id)
-                                           break
+                                            break
 
-                               vnfr_cp_ref.connection_point_params.address =  cp.ip_address
-                               vnfr_cp_ref.connection_point_params.port = VnffgRecord.SFF_DP_PORT
+                                vnfr_cp_ref.connection_point_params.address =  cp.ip_address
+                                vnfr_cp_ref.connection_point_params.port = VnffgRecord.SFF_DP_PORT
 
         for vnffgd_classifier in self._vnffgd_msg.classifier:
             _rsp =  [rsp for rsp in vnffgr.rsp if rsp.vnffgd_rsp_id_ref == vnffgd_classifier.rsp_id_ref]
@@ -329,37 +329,37 @@ class VnffgRecord(object):
             vnffgr_classifier.rsp_id_ref = rsp_id_ref
             vnffgr_classifier.rsp_name = rsp_name
             for nsr_vnfr in self._nsr.vnfrs.values():
-               if (nsr_vnfr.vnfd.id == vnffgd_classifier.vnfd_id_ref and
-                      nsr_vnfr.member_vnf_index == vnffgd_classifier.member_vnf_index_ref):
-                       vnffgr_classifier.vnfr_id_ref = nsr_vnfr.id
-                       vnffgr_classifier.vnfr_name_ref = nsr_vnfr.name
-                       vnffgr_classifier.vnfr_connection_point_ref = vnffgd_classifier.vnfd_connection_point_ref
-
-                       if nsr_vnfr.vnfd.service_function_chain == 'CLASSIFIER':
-                           vnffgr_classifier.sff_name = nsr_vnfr.name
-
-                       vnfr = yield from self._nsr.fetch_vnfr(nsr_vnfr.xpath)
-                       self._log.debug(" Received VNFR is %s", vnfr)
-                       while vnfr.operational_status != 'running':
-                           self._log.info("Received vnf op status is %s; retrying",vnfr.operational_status)
-                           if vnfr.operational_status == 'failed':
-                               self._log.error("Fetching VNFR for  %s failed", vnfr.id)
-                               raise NsrInstantiationFailed("Failed NS %s instantiation due to VNFR %s failure" % (self.id, vnfr.id))
-                           yield from asyncio.sleep(2, loop=self._loop)
-                           vnfr = yield from self._nsr.fetch_vnfr(nsr_vnfr.xpath)
-                           self._log.debug("Received VNFR is %s", vnfr)
-
-                       for cp in vnfr.connection_point:
-                           if cp.name == vnffgr_classifier.vnfr_connection_point_ref:
-                               vnffgr_classifier.port_id = cp.connection_point_id
-                               vnffgr_classifier.ip_address = cp.ip_address
-                               for vdu in vnfr.vdur:
-                                   for ext_intf in vdu.external_interface:
-                                       if ext_intf.name == vnffgr_classifier.vnfr_connection_point_ref:
-                                           vnffgr_classifier.vm_id =  vdu.vim_id
-                                           self._log.debug("VIM ID for CP %s in VNFR %s is %s",cp.name,nsr_vnfr.id,
-                                                            vnfr_cp_ref.connection_point_params.vm_id)
-                                           break
+                if (nsr_vnfr.vnfd.id == vnffgd_classifier.vnfd_id_ref and
+                            nsr_vnfr.member_vnf_index == vnffgd_classifier.member_vnf_index_ref):
+                    vnffgr_classifier.vnfr_id_ref = nsr_vnfr.id
+                    vnffgr_classifier.vnfr_name_ref = nsr_vnfr.name
+                    vnffgr_classifier.vnfr_connection_point_ref = vnffgd_classifier.vnfd_connection_point_ref
+
+                    if nsr_vnfr.vnfd.service_function_chain == 'CLASSIFIER':
+                        vnffgr_classifier.sff_name = nsr_vnfr.name
+
+                    vnfr = yield from self._nsr.fetch_vnfr(nsr_vnfr.xpath)
+                    self._log.debug(" Received VNFR is %s", vnfr)
+                    while vnfr.operational_status != 'running':
+                        self._log.info("Received vnf op status is %s; retrying",vnfr.operational_status)
+                        if vnfr.operational_status == 'failed':
+                            self._log.error("Fetching VNFR for  %s failed", vnfr.id)
+                            raise NsrInstantiationFailed("Failed NS %s instantiation due to VNFR %s failure" % (self.id, vnfr.id))
+                        yield from asyncio.sleep(2, loop=self._loop)
+                        vnfr = yield from self._nsr.fetch_vnfr(nsr_vnfr.xpath)
+                        self._log.debug("Received VNFR is %s", vnfr)
+
+                    for cp in vnfr.connection_point:
+                        if cp.name == vnffgr_classifier.vnfr_connection_point_ref:
+                            vnffgr_classifier.port_id = cp.connection_point_id
+                            vnffgr_classifier.ip_address = cp.ip_address
+                            for vdu in vnfr.vdur:
+                                for ext_intf in vdu.external_interface:
+                                    if ext_intf.name == vnffgr_classifier.vnfr_connection_point_ref:
+                                        vnffgr_classifier.vm_id =  vdu.vim_id
+                                        self._log.debug("VIM ID for CP %s in VNFR %s is %s",cp.name,nsr_vnfr.id,
+                                                        vnfr_cp_ref.connection_point_params.vm_id)
+                                        break
 
         self._log.info("VNFFGR msg to be sent is %s", vnffgr)
         return vnffgr
@@ -377,8 +377,8 @@ class VnffgRecord(object):
                 while vnfr.operational_status != 'running':
                     self._log.info("Received vnf op status is %s; retrying",vnfr.operational_status)
                     if vnfr.operational_status == 'failed':
-                       self._log.error("Fetching VNFR for  %s failed", vnfr.id)
-                       raise NsrInstantiationFailed("Failed NS %s instantiation due to VNFR %s failure" % (self.id, vnfr.id))
+                        self._log.error("Fetching VNFR for  %s failed", vnfr.id)
+                        raise NsrInstantiationFailed("Failed NS %s instantiation due to VNFR %s failure" % (self.id, vnfr.id))
                     yield from asyncio.sleep(2, loop=self._loop)
                     vnfr = yield from self._nsr.fetch_vnfr(nsr_vnfr.xpath)
                     self._log.debug("Received VNFR is %s", vnfr)
@@ -431,8 +431,8 @@ class VnffgRecord(object):
     def vnffgr_in_vnffgrm(self):
         """ Is there a VNFR record in VNFM """
         if (self._vnffgr_state == VnffgRecordState.ACTIVE or
-                self._vnffgr_state == VnffgRecordState.INSTANTIATION_PENDING or
-                self._vnffgr_state == VnffgRecordState.FAILED):
+                    self._vnffgr_state == VnffgRecordState.INSTANTIATION_PENDING or
+                    self._vnffgr_state == VnffgRecordState.FAILED):
             return True
 
         return False
@@ -469,21 +469,21 @@ class VirtualLinkRecord(object):
             VirtualLinkRecord
         """
         vlr_obj = VirtualLinkRecord(
-                      dts,
-                      log,
-                      loop,
-                      nsr_name,
-                      vld_msg,
-                      cloud_account_name,
-                      om_datacenter,
-                      ip_profile,
-                      nsr_id,
-                      )
+            dts,
+            log,
+            loop,
+            nsr_name,
+            vld_msg,
+            cloud_account_name,
+            om_datacenter,
+            ip_profile,
+            nsr_id,
+        )
 
         if restart_mode:
             res_iter = yield from dts.query_read(
-                              "D,/vlr:vlr-catalog/vlr:vlr",
-                              rwdts.XactFlag.MERGE)
+                "D,/vlr:vlr-catalog/vlr:vlr",
+                rwdts.XactFlag.MERGE)
 
             for fut in res_iter:
                 response = yield from fut
@@ -632,9 +632,9 @@ class VirtualLinkRecord(object):
         for conn in self.vld_msg.vnfd_connection_point_ref:
             for vnfr in vnfrs:
                 if (vnfr.vnfd.id == conn.vnfd_id_ref and
-                        vnfr.member_vnf_index == conn.member_vnf_index_ref and
-                        self.cloud_account_name == vnfr.cloud_account_name and
-                        self.om_datacenter_name == vnfr.om_datacenter_name):
+                            vnfr.member_vnf_index == conn.member_vnf_index_ref and
+                            self.cloud_account_name == vnfr.cloud_account_name and
+                            self.om_datacenter_name == vnfr.om_datacenter_name):
                     cp_entry = nsr_vlr.vnfr_connection_point_ref.add()
                     cp_entry.vnfr_id = vnfr.id
                     cp_entry.connection_point = conn.vnfd_connection_point_ref
@@ -678,9 +678,9 @@ class VirtualLinkRecord(object):
     def vlr_in_vns(self):
         """ Is there a VLR record in VNS """
         if (self._state == VlRecordState.ACTIVE or
-            self._state == VlRecordState.INSTANTIATION_PENDING or
-            self._state == VlRecordState.TERMINATE_PENDING or
-            self._state == VlRecordState.FAILED):
+                    self._state == VlRecordState.INSTANTIATION_PENDING or
+                    self._state == VlRecordState.TERMINATE_PENDING or
+                    self._state == VlRecordState.FAILED):
             return True
 
         return False
@@ -722,8 +722,8 @@ class VirtualNetworkFunctionRecord(object):
     @staticmethod
     @asyncio.coroutine
     def create_record(dts, log, loop, vnfd, const_vnfd_msg, nsd_id, nsr_name,
-                cloud_account_name, om_datacenter_name, nsr_id, group_name, group_instance_id,
-                placement_groups, restart_mode=False):
+                      cloud_account_name, om_datacenter_name, nsr_id, group_name, group_instance_id,
+                      placement_groups, restart_mode=False):
         """Creates a new VNFR object based on the given data.
 
         If restart mode is enabled, then we look for existing records in the
@@ -733,25 +733,25 @@ class VirtualNetworkFunctionRecord(object):
             VirtualNetworkFunctionRecord
         """
         vnfr_obj = VirtualNetworkFunctionRecord(
-                          dts,
-                          log,
-                          loop,
-                          vnfd,
-                          const_vnfd_msg,
-                          nsd_id,
-                          nsr_name,
-                          cloud_account_name,
-                          om_datacenter_name,
-                          nsr_id,
-                          group_name,
-                          group_instance_id,
-                          placement_groups,
-                          restart_mode=restart_mode)
+            dts,
+            log,
+            loop,
+            vnfd,
+            const_vnfd_msg,
+            nsd_id,
+            nsr_name,
+            cloud_account_name,
+            om_datacenter_name,
+            nsr_id,
+            group_name,
+            group_instance_id,
+            placement_groups,
+            restart_mode=restart_mode)
 
         if restart_mode:
             res_iter = yield from dts.query_read(
-                              "D,/vnfr:vnfr-catalog/vnfr:vnfr",
-                              rwdts.XactFlag.MERGE)
+                "D,/vnfr:vnfr-catalog/vnfr:vnfr",
+                rwdts.XactFlag.MERGE)
 
             for fut in res_iter:
                 response = yield from fut
@@ -931,34 +931,34 @@ class VirtualNetworkFunctionRecord(object):
 
     def configure(self):
         self.config_store.merge_vnfd_config(
-                    self._nsd_id,
-                    self._vnfd,
-                    self.member_vnf_index,
-                    )
+            self._nsd_id,
+            self._vnfd,
+            self.member_vnf_index,
+        )
 
     def create_vnfr_msg(self):
         """ VNFR message for this VNFR """
         vnfd_fields = [
-                "short_name",
-                "vendor",
-                "description",
-                "version",
-                "type_yang",
-                ]
+            "short_name",
+            "vendor",
+            "description",
+            "version",
+            "type_yang",
+        ]
         vnfd_copy_dict = {k: v for k, v in self._vnfd.as_dict().items() if k in vnfd_fields}
         vnfr_dict = {
-                "id": self.id,
-                "nsr_id_ref": self._nsr_id,
-                "name": self.name,
-                "cloud_account": self._cloud_account_name,
-                "om_datacenter": self._om_datacenter_name,
-                "config_status": self.config_status
-                }
+            "id": self.id,
+            "nsr_id_ref": self._nsr_id,
+            "name": self.name,
+            "cloud_account": self._cloud_account_name,
+            "om_datacenter": self._om_datacenter_name,
+            "config_status": self.config_status
+        }
         vnfr_dict.update(vnfd_copy_dict)
 
         vnfr = RwVnfrYang.YangData_Vnfr_VnfrCatalog_Vnfr.from_dict(vnfr_dict)
         vnfr.vnfd = VnfrYang.YangData_Vnfr_VnfrCatalog_Vnfr_Vnfd.from_dict(self.vnfd.as_dict(),
-                                                                          ignore_missing_keys=True)
+                                                                           ignore_missing_keys=True)
         vnfr.member_vnf_index_ref = self.member_vnf_index
         vnfr.vnf_configuration.from_dict(self._vnfd.vnf_configuration.as_dict())
 
@@ -980,10 +980,10 @@ class VirtualNetworkFunctionRecord(object):
         self._log.debug("Send an update to VNFM for VNFR {} with {}".
                         format(self.name, self.vnfr_msg))
         yield from self._dts.query_update(
-                self.xpath,
-                rwdts.XactFlag.TRACE,
-                self.vnfr_msg
-                )
+            self.xpath,
+            rwdts.XactFlag.TRACE,
+            self.vnfr_msg
+        )
 
     def get_config_status(self):
         """Return the config status as YANG ENUM"""
@@ -1030,7 +1030,7 @@ class VirtualNetworkFunctionRecord(object):
                     yield from self.update_vnfm()
                 except Exception as e:
                     self._log.error("Exception updating VNFM with new status {} of VNFR {}: {}".
-                                format(status, self.name, e))
+                                    format(status, self.name, e))
                     self._log.exception(e)
 
     def is_configured(self):
@@ -1059,9 +1059,9 @@ class VirtualNetworkFunctionRecord(object):
             for vlr in nsr.vlrs:
                 for vnfd_cp in vlr.vld_msg.vnfd_connection_point_ref:
                     if (vnfd_cp.vnfd_id_ref == self._vnfd.id and
-                            vnfd_cp.vnfd_connection_point_ref == conn.name and
-                            vnfd_cp.member_vnf_index_ref == self.member_vnf_index and
-                             vlr.cloud_account_name == self.cloud_account_name):
+                                vnfd_cp.vnfd_connection_point_ref == conn.name and
+                                vnfd_cp.member_vnf_index_ref == self.member_vnf_index and
+                                vlr.cloud_account_name == self.cloud_account_name):
                         self._log.debug("Found VLR for cp_name:%s and vnf-index:%d",
                                         conn.name, self.member_vnf_index)
                         return vlr
@@ -1073,13 +1073,13 @@ class VirtualNetworkFunctionRecord(object):
             cpr.name = conn_p.name
             cpr.type_yang = conn_p.type_yang
             if conn_p.has_field('port_security_enabled'):
-              cpr.port_security_enabled = conn_p.port_security_enabled
+                cpr.port_security_enabled = conn_p.port_security_enabled
 
             vlr_ref = find_vlr_for_cp(conn_p)
             if vlr_ref is None:
                 msg = "Failed to find VLR for cp = %s" % conn_p.name
                 self._log.debug("%s", msg)
-#                raise VirtualNetworkFunctionRecordError(msg)
+                #                raise VirtualNetworkFunctionRecordError(msg)
                 continue
 
             cpr.vlr_ref = vlr_ref.id
@@ -1127,8 +1127,8 @@ class VirtualNetworkFunctionRecord(object):
     def vnfr_in_vnfm(self):
         """ Is there a VNFR record in VNFM """
         if (self._state == VnfRecordState.ACTIVE or
-                self._state == VnfRecordState.INSTANTIATION_PENDING or
-                self._state == VnfRecordState.FAILED):
+                    self._state == VnfRecordState.INSTANTIATION_PENDING or
+                    self._state == VnfRecordState.FAILED):
             return True
 
         return False
@@ -1208,7 +1208,7 @@ class NetworkServiceStatus(object):
                             "FAILED": "failed",
                             "VL_INSTANTIATE": "vl_instantiate",
                             "VL_TERMINATE": "vl_terminate",
-        }
+                            }
         return state_to_str_map[self._state.name]
 
     @property
@@ -1405,8 +1405,8 @@ class NetworkServiceRecord(object):
 
     def __str__(self):
         return "NSR(name={}, nsd_id={}, cloud_account={})".format(
-                self.name, self.nsd_id, self.cloud_account_name
-                )
+            self.name, self.nsd_id, self.cloud_account_name
+        )
 
     def _get_vnfd(self, vnfd_id, config_xact):
         """  Fetch vnfd msg for the passed vnfd id """
@@ -1415,10 +1415,10 @@ class NetworkServiceRecord(object):
     def _get_vnfd_cloud_account(self, vnfd_member_index):
         """  Fetch Cloud Account for the passed vnfd id """
         if self._nsr_cfg_msg.vnf_cloud_account_map:
-           vim_accounts = [(vnf.cloud_account,vnf.om_datacenter)  for vnf in self._nsr_cfg_msg.vnf_cloud_account_map \
-                           if vnfd_member_index == vnf.member_vnf_index_ref]
-           if vim_accounts and vim_accounts[0]:
-               return vim_accounts[0]
+            vim_accounts = [(vnf.cloud_account,vnf.om_datacenter)  for vnf in self._nsr_cfg_msg.vnf_cloud_account_map \
+                            if vnfd_member_index == vnf.member_vnf_index_ref]
+            if vim_accounts and vim_accounts[0]:
+                return vim_accounts[0]
         return (self.cloud_account_name,self.om_datacenter_name)
 
     def _get_constituent_vnfd_msg(self, vnf_index):
@@ -1573,7 +1573,7 @@ class NetworkServiceRecord(object):
         tmp_file = None
         with tempfile.NamedTemporaryFile(delete=False) as tmp_file:
             tmp_file.write(yaml.dump(data, default_flow_style=True)
-                    .encode("UTF-8"))
+                           .encode("UTF-8"))
 
         self._log.debug("Creating a temp file: {} with input data: {}".
                         format(tmp_file.name, data))
@@ -1646,19 +1646,19 @@ class NetworkServiceRecord(object):
                 err_msg = None
                 if not rc:
                     err_msg = "Failed config for trigger {} using config script '{}'". \
-                              format(self.scaling_trigger_str(trigger),
-                                     config_primitive.user_defined_script)
+                        format(self.scaling_trigger_str(trigger),
+                               config_primitive.user_defined_script)
                 yield from update_config_status(success=rc, err_msg=err_msg)
                 return rc
             else:
                 err_msg = "Failed config for trigger {} as config script is not specified". \
-                          format(self.scaling_trigger_str(trigger))
+                    format(self.scaling_trigger_str(trigger))
                 yield from update_config_status(success=False, err_msg=err_msg)
                 raise NotImplementedError("Only script based config support for scale group for now: {}".
                                           format(group.name))
         else:
-            err_msg = "Failed config for trigger {} as config primitive is not specified".\
-                      format(self.scaling_trigger_str(trigger))
+            err_msg = "Failed config for trigger {} as config primitive is not specified". \
+                format(self.scaling_trigger_str(trigger))
             yield from update_config_status(success=False, err_msg=err_msg)
             self._log.error("Config primitive not specified for config action in scale group %s" %
                             (group.name))
@@ -1673,9 +1673,9 @@ class NetworkServiceRecord(object):
                             scaling_group_msg.name, self.id)
 
             group_record = scale_group.ScalingGroup(
-                    self._log,
-                    scaling_group_msg
-                    )
+                self._log,
+                scaling_group_msg
+            )
 
             self._scaling_groups[group_record.name] = group_record
 
@@ -1710,7 +1710,6 @@ class NetworkServiceRecord(object):
             yield from self.publish()
 
             self._log.debug("Instantiating %s VNFRS for %s", len(vnfrs), scale_instance)
-            yield from self.instantiate_vls()
             scale_instance.operational_status = "vnf_init_phase"
             yield from self.update_state()
 
@@ -1724,7 +1723,6 @@ class NetworkServiceRecord(object):
                 else:
                     yield from self.instantiate_vnfs(vnfrs, scaleout=True)
 
-
             except Exception as e:
                 self._log.exception("Failed to begin instantiatiation of vnfs for scale group {}: {}".
                                     format(group.name, e))
@@ -1804,7 +1802,7 @@ class NetworkServiceRecord(object):
                     if all([state == VnfRecordState.TERMINATED for state in instance_vnf_state_list]):
                         instance.operational_status = "terminated"
                         rc = yield from self.apply_scaling_group_config(NsdYang.ScalingTrigger.POST_SCALE_IN,
-                                                                         group, instance)
+                                                                        group, instance)
                         if rc:
                             self._log.debug("Scale in for group {} and instance {} succeeded".
                                             format(group.name, instance.instance_id))
@@ -1848,16 +1846,16 @@ class NetworkServiceRecord(object):
             VirtualLinkRecord
         """
         vlr = yield from VirtualLinkRecord.create_record(
-                self._dts,
-                self._log,
-                self._loop,
-                self.name,
-                vld,
-                cloud_account,
-                om_datacenter,
-                self.resolve_vld_ip_profile(self.nsd_msg, vld),
-                self.id,
-                restart_mode=self.restart_mode)
+            self._dts,
+            self._log,
+            self._loop,
+            self.name,
+            vld,
+            cloud_account,
+            om_datacenter,
+            self.resolve_vld_ip_profile(self.nsd_msg, vld),
+            self.id,
+            restart_mode=self.restart_mode)
 
         return vlr
 
@@ -1884,8 +1882,8 @@ class NetworkServiceRecord(object):
 
             for vnfc in vld.vnfd_connection_point_ref:
                 cloud_account = vnf_cloud_map.get(
-                        vnfc.member_vnf_index_ref,
-                        (self.cloud_account_name,self.om_datacenter_name))
+                    vnfc.member_vnf_index_ref,
+                    (self.cloud_account_name,self.om_datacenter_name))
 
                 cloud_account_list.append(cloud_account)
 
@@ -1951,7 +1949,7 @@ class NetworkServiceRecord(object):
 
         except Exception as e:
             err_msg = "Error instantiating VL for NSR {} and VLD {}: {}". \
-                      format(self.id, vld.id, e)
+                format(self.id, vld.id, e)
             self._log.error(err_msg)
             self._log.exception(e)
             vlr.state = VlRecordState.FAILED
@@ -1974,7 +1972,7 @@ class NetworkServiceRecord(object):
 
                 except Exception as e:
                     err_msg = "Error terminating VL for NSR {} and VLD {}: {}". \
-                              format(self.id, vld.id, e)
+                        format(self.id, vld.id, e)
                     self._log.error(err_msg)
                     self._log.exception(e)
                     vlr.state = VlRecordState.FAILED
@@ -2009,7 +2007,7 @@ class NetworkServiceRecord(object):
         for group in self.nsd_msg.placement_groups:
             for member_vnfd in group.member_vnfd:
                 if (member_vnfd.vnfd_id_ref == vnfd_msg.id) and \
-                   (member_vnfd.member_vnf_index_ref == const_vnfd.member_vnf_index):
+                        (member_vnfd.member_vnf_index_ref == const_vnfd.member_vnf_index):
                     group_info = self.resolve_placement_group_cloud_construct(group)
                     if group_info is None:
                         self._log.error("Could not resolve cloud-construct for placement group: %s", group.name)
@@ -2032,20 +2030,20 @@ class NetworkServiceRecord(object):
                        const_vnfd.member_vnf_index,
                        [ group.name for group in placement_groups])
         vnfr = yield from VirtualNetworkFunctionRecord.create_record(self._dts,
-                                            self._log,
-                                            self._loop,
-                                            vnfd_msg,
-                                            const_vnfd,
-                                            self.nsd_id,
-                                            self.name,
-                                            cloud_account_name,
-                                            om_datacenter_name,
-                                            self.id,
-                                            group_name,
-                                            group_instance_id,
-                                            placement_groups,
-                                            restart_mode=self.restart_mode,
-                                            )
+                                                                     self._log,
+                                                                     self._loop,
+                                                                     vnfd_msg,
+                                                                     const_vnfd,
+                                                                     self.nsd_id,
+                                                                     self.name,
+                                                                     cloud_account_name,
+                                                                     om_datacenter_name,
+                                                                     self.id,
+                                                                     group_name,
+                                                                     group_instance_id,
+                                                                     placement_groups,
+                                                                     restart_mode=self.restart_mode,
+                                                                     )
         if vnfr.id in self._vnfrs:
             err = "VNF with VNFR id %s already in vnf list" % (vnfr.id,)
             raise NetworkServiceRecordError(err)
@@ -2069,16 +2067,16 @@ class NetworkServiceRecord(object):
             end_value = param_pool.range.end_value
             if end_value < start_value:
                 raise NetworkServiceRecordError(
-                        "Parameter pool %s has invalid range (start: {}, end: {})".format(
-                            start_value, end_value
-                            )
-                        )
+                    "Parameter pool %s has invalid range (start: {}, end: {})".format(
+                        start_value, end_value
+                    )
+                )
 
             self._param_pools[param_pool.name] = config_value_pool.ParameterValuePool(
-                    self._log,
-                    param_pool.name,
-                    range(start_value, end_value)
-                    )
+                self._log,
+                param_pool.name,
+                range(start_value, end_value)
+            )
 
     @asyncio.coroutine
     def fetch_vnfr(self, vnfr_path):
@@ -2137,8 +2135,8 @@ class NetworkServiceRecord(object):
             for i in range(group.min_instance_count):
                 self._log.debug("Instantiating %s default scaling instance %s", group, i)
                 yield from self.create_scale_group_instance(
-                        group.name, i, config_xact, is_default=True
-                        )
+                    group.name, i, config_xact, is_default=True
+                )
 
             for group_msg in self._nsr_cfg_msg.scaling_group:
                 if group_msg.scaling_group_name_ref != group.name:
@@ -2147,8 +2145,8 @@ class NetworkServiceRecord(object):
                 for instance in group_msg.instance:
                     self._log.debug("Reloading %s scaling instance %s", group_msg, instance.id)
                     yield from self.create_scale_group_instance(
-                            group.name, instance.id, config_xact, is_default=False
-                            )
+                        group.name, instance.id, config_xact, is_default=False
+                    )
 
     def has_scaling_instances(self):
         """ Return boolean indicating if the network service has default scaling groups """
@@ -2192,7 +2190,7 @@ class NetworkServiceRecord(object):
         return(
             "D,/nsr:ns-instance-opdata" +
             "/nsr:nsr[nsr:ns-instance-config-ref = '{}']"
-            ).format(self.id)
+        ).format(self.id)
 
     @staticmethod
     def xpath_from_nsr(nsr):
@@ -2205,7 +2203,7 @@ class NetworkServiceRecord(object):
         """ Return NSD config xpath."""
         return(
             "C,/nsd:nsd-catalog/nsd:nsd[nsd:id = '{}']"
-            ).format(self.nsd_id)
+        ).format(self.nsd_id)
 
     @asyncio.coroutine
     def instantiate(self, config_xact):
@@ -2371,7 +2369,7 @@ class NetworkServiceRecord(object):
 
             if self._config_status == NsrYang.ConfigStates.FAILED:
                 self.record_event("config-failed", "NS configuration failed",
-                        evt_details=self._config_status_details)
+                                  evt_details=self._config_status_details)
 
             yield from self.publish()
 
@@ -2505,7 +2503,7 @@ class NetworkServiceRecord(object):
 
         for cfg_prim in self.nsd_msg.service_primitive:
             cfg_prim = NsrYang.YangData_Nsr_NsInstanceOpdata_Nsr_ServicePrimitive.from_dict(
-                    cfg_prim.as_dict())
+                cfg_prim.as_dict())
             nsr.service_primitive.append(cfg_prim)
 
         for init_cfg in self.nsd_msg.initial_config_primitive:
@@ -2604,7 +2602,7 @@ class NetworkServiceRecord(object):
                     break
                 else:
                     self._log.info("VNFFGR %s in NSR %s is still not active; current state is: %s",
-                                    vnffgr.id, self.id, vnffgr.state)
+                                   vnffgr.id, self.id, vnffgr.state)
                     new_state = curr_state
 
         # Update all the scaling group instance operational status to
@@ -2682,11 +2680,11 @@ class InputParameterSubstitution(object):
                     continue
 
                 self.log.debug(
-                        "input-parameter:{} = {}".format(
-                            param.xpath,
-                            param.value,
-                            )
-                        )
+                    "input-parameter:{} = {}".format(
+                        param.xpath,
+                        param.value,
+                    )
+                )
 
                 try:
                     xpath.setxattr(nsd, param.xpath, param.value)
@@ -2842,7 +2840,7 @@ class NsdDtsHandler(object):
         self._log.debug(
             "Registering for NSD config using xpath: %s",
             NsdDtsHandler.XPATH,
-            )
+        )
 
         acg_hdl = rift.tasklets.AppConfGroup.Handler(on_apply=on_apply)
         with self._dts.appconf_group_create(handler=acg_hdl) as acg:
@@ -2917,7 +2915,7 @@ class VnfdDtsHandler(object):
         self._log.debug(
             "Registering for VNFD config using xpath: %s",
             VnfdDtsHandler.XPATH,
-            )
+        )
         acg_hdl = rift.tasklets.AppConfGroup.Handler(on_apply=on_apply)
         with self._dts.appconf_group_create(handler=acg_hdl) as acg:
             # Need a list in scratch to store VNFDs to create/update later
@@ -2974,15 +2972,15 @@ class NsrRpcDtsHandler(object):
                 self._log.debug("Attemping NsmTasklet netconf connection.")
 
                 manager = yield from ncclient.asyncio_manager.asyncio_connect(
-                        loop=self._loop,
-                        host=NsrRpcDtsHandler.NETCONF_IP_ADDRESS,
-                        port=NsrRpcDtsHandler.NETCONF_PORT,
-                        username=NsrRpcDtsHandler.NETCONF_USER,
-                        password=NsrRpcDtsHandler.NETCONF_PW,
-                        allow_agent=False,
-                        look_for_keys=False,
-                        hostkey_verify=False,
-                        )
+                    loop=self._loop,
+                    host=NsrRpcDtsHandler.NETCONF_IP_ADDRESS,
+                    port=NsrRpcDtsHandler.NETCONF_PORT,
+                    username=NsrRpcDtsHandler.NETCONF_USER,
+                    password=NsrRpcDtsHandler.NETCONF_PW,
+                    allow_agent=False,
+                    look_for_keys=False,
+                    hostkey_verify=False,
+                )
 
                 return manager
 
@@ -2993,7 +2991,7 @@ class NsrRpcDtsHandler(object):
             yield from asyncio.sleep(5, loop=self._loop)
 
         raise NsrInstantiationFailed("Failed to connect to Launchpad within %s seconds" %
-                                      timeout_secs)
+                                     timeout_secs)
 
     def _apply_ns_instance_config(self,payload_dict):
         #self._log.debug("At apply NS instance config with payload %s",payload_dict)
@@ -3010,8 +3008,8 @@ class NsrRpcDtsHandler(object):
             assert action == rwdts.QueryAction.RPC
             rpc_ip = msg
             rpc_op = NsrYang.YangOutput_Nsr_StartNetworkService.from_dict({
-                    "nsr_id":str(uuid.uuid4())
-                })
+                "nsr_id":str(uuid.uuid4())
+            })
 
             if not ('name' in rpc_ip and  'nsd_ref' in rpc_ip and ('cloud_account' in rpc_ip or 'om_datacenter' in rpc_ip)):
                 self._log.error("Mandatory parameters name or nsd_ref or cloud account not found in start-network-service {}".format(rpc_ip))
@@ -3029,7 +3027,7 @@ class NsrRpcDtsHandler(object):
                 #    self._manager = yield from self._connect()
 
                 self._log.debug("Configuring ns-instance-config with name  %s nsd-ref: %s",
-                        rpc_ip.name, rpc_ip.nsd_ref)
+                                rpc_ip.name, rpc_ip.nsd_ref)
 
                 ns_instance_config_dict = {"id":rpc_op.nsr_id, "admin_status":"ENABLED"}
                 ns_instance_config_copy_dict = {k:v for k, v in rpc_ip.as_dict().items()
@@ -3047,7 +3045,7 @@ class NsrRpcDtsHandler(object):
                 #self._log.debug("Sending configure ns-instance-config xml to %s: %s",
                 #        netconf_xml, NsrRpcDtsHandler.NETCONF_IP_ADDRESS)
                 self._log.debug("Sending configure ns-instance-config json to %s: %s",
-                        self._nsr_config_url,ns_instance_config)
+                                self._nsr_config_url,ns_instance_config)
 
                 #response = yield from self._manager.edit_config(
                 #           target="running",
@@ -3057,7 +3055,7 @@ class NsrRpcDtsHandler(object):
                     None,
                     self._apply_ns_instance_config,
                     payload_dict
-                    )
+                )
                 response.raise_for_status()
                 self._log.debug("Received edit config response: %s", response.json())
 
@@ -3078,7 +3076,7 @@ class NsrRpcDtsHandler(object):
             self._ns_regh = group.register(xpath=NsrRpcDtsHandler.EXEC_NSR_CONF_XPATH,
                                            handler=hdl_ns,
                                            flags=rwdts.Flag.PUBLISHER,
-                                          )
+                                           )
 
 
 class NsrDtsHandler(object):
@@ -3251,7 +3249,7 @@ class NsrDtsHandler(object):
                     raise NetworkServiceRecordError(err)
 
                 self._log.debug("Creating NetworkServiceRecord %s  from nsr config  %s",
-                               msg.id, msg.as_dict())
+                                msg.id, msg.as_dict())
                 nsr = self.nsm.create_nsr(msg, key_pairs=key_pairs, restart_mode=restart_mode)
                 return nsr
 
@@ -3340,9 +3338,9 @@ class NsrDtsHandler(object):
             xpath = ks_path.to_xpath(RwNsrYang.get_schema())
             action = xact_info.query_action
             self._log.debug(
-                    "Got Nsr prepare callback (xact: %s) (action: %s) (info: %s), %s:%s)",
-                    xact, action, xact_info, xpath, msg
-                    )
+                "Got Nsr prepare callback (xact: %s) (action: %s) (info: %s), %s:%s)",
+                xact, action, xact_info, xpath, msg
+            )
 
             @asyncio.coroutine
             def delete_instantiation(ns_id):
@@ -3385,8 +3383,6 @@ class NsrDtsHandler(object):
                             raise NsrVlUpdateError("NS config NSD should have atleast 1 VLD defined")
 
                     if msg.has_field("scaling_group"):
-                        self._log.debug("ScaleMsg %s", msg)
-                        self._log.debug("NSSCALINGSTATE %s", nsr.state)
                         if nsr.state != NetworkServiceRecordState.RUNNING:
                             raise ScalingOperationError("Unable to perform scaling action when NS is not in running state")
 
@@ -3413,18 +3409,18 @@ class NsrDtsHandler(object):
         acg_hdl = rift.tasklets.AppConfGroup.Handler(on_apply=on_apply)
         with self._dts.appconf_group_create(handler=acg_hdl) as acg:
             self._nsr_regh = acg.register(xpath=NsrDtsHandler.NSR_XPATH,
-                                      flags=rwdts.Flag.SUBSCRIBER | rwdts.Flag.DELTA_READY | rwdts.Flag.CACHE,
-                                      on_prepare=on_prepare)
+                                          flags=rwdts.Flag.SUBSCRIBER | rwdts.Flag.DELTA_READY | rwdts.Flag.CACHE,
+                                          on_prepare=on_prepare)
 
             self._scale_regh = acg.register(
-                                      xpath=NsrDtsHandler.SCALE_INSTANCE_XPATH,
-                                      flags=rwdts.Flag.SUBSCRIBER | rwdts.Flag.DELTA_READY| rwdts.Flag.CACHE,
-                                      )
+                xpath=NsrDtsHandler.SCALE_INSTANCE_XPATH,
+                flags=rwdts.Flag.SUBSCRIBER | rwdts.Flag.DELTA_READY| rwdts.Flag.CACHE,
+            )
 
             self._key_pair_regh = acg.register(
-                                      xpath=NsrDtsHandler.KEY_PAIR_XPATH,
-                                      flags=rwdts.Flag.SUBSCRIBER | rwdts.Flag.DELTA_READY | rwdts.Flag.CACHE,
-                                       )
+                xpath=NsrDtsHandler.KEY_PAIR_XPATH,
+                flags=rwdts.Flag.SUBSCRIBER | rwdts.Flag.DELTA_READY | rwdts.Flag.CACHE,
+            )
 
 
 class NsrOpDataDtsHandler(object):
@@ -3527,7 +3523,7 @@ class VnfrDtsHandler(object):
             self._log.debug(
                 "Got vnfr on_prepare cb (xact_info: %s, action: %s): %s:%s",
                 xact_info, action, ks_path, msg
-                )
+            )
 
             schema = VnfrYang.YangData_Vnfr_VnfrCatalog_Vnfr.schema()
             path_entry = schema.keyspec_to_entry(ks_path)
@@ -3625,11 +3621,11 @@ class NsManager(object):
 
         self._ro_plugin_selector = ro_plugin_selector
         self._ncclient = rift.mano.ncclient.NcClient(
-              host="127.0.0.1",
-              port=2022,
-              username="admin",
-              password="admin",
-              loop=self._loop)
+            host="127.0.0.1",
+            port=2022,
+            username="admin",
+            password="admin",
+            loop=self._loop)
 
         self._nsrs = {}
         self._nsds = {}
@@ -3766,7 +3762,7 @@ class NsManager(object):
         ScalingGroup = NsrYang.YangData_Nsr_NsInstanceConfig_Nsr_ScalingGroup
 
         xpath = ('C,/nsr:ns-instance-config/nsr:nsr[nsr:id="{}"]').format(
-                          msg.nsr_id_ref)
+            msg.nsr_id_ref)
         instance = ScalingGroupInstance.from_dict({"id": msg.instance_id})
 
         @asyncio.coroutine
@@ -3810,18 +3806,18 @@ class NsManager(object):
         else:
             self._loop.create_task(scale_in())
 
-        # Opdata based calls, disabled for now!
-        # if action == ScalingRpcHandler.ACTION.SCALE_OUT:
-        #     self.scale_nsr_out(
-        #           msg.nsr_id_ref,
-        #           msg.scaling_group_name_ref,
-        #           msg.instance_id,
-        #           xact)
-        # else:
-        #     self.scale_nsr_in(
-        #           msg.nsr_id_ref,
-        #           msg.scaling_group_name_ref,
-        #           msg.instance_id)
+            # Opdata based calls, disabled for now!
+            # if action == ScalingRpcHandler.ACTION.SCALE_OUT:
+            #     self.scale_nsr_out(
+            #           msg.nsr_id_ref,
+            #           msg.scaling_group_name_ref,
+            #           msg.instance_id,
+            #           xact)
+            # else:
+            #     self.scale_nsr_in(
+            #           msg.nsr_id_ref,
+            #           msg.scaling_group_name_ref,
+            #           msg.instance_id)
 
     def nsr_update_cfg(self, nsr_id, msg):
         nsr = self._nsrs[nsr_id]
@@ -3847,7 +3843,6 @@ class NsManager(object):
 
     def create_nsr(self, nsr_msg, key_pairs=None,restart_mode=False):
         """ Create an NSR instance """
-        self._log.debug("NSRMSG %s", nsr_msg)
         if nsr_msg.id in self._nsrs:
             msg = "NSR id %s already exists" % nsr_msg.id
             self._log.error(msg)
@@ -3982,12 +3977,12 @@ class NsManager(object):
             raise NetworkServiceDescriptorError("NSD already exists-%s", nsd_msg.id)
 
         nsd = NetworkServiceDescriptor(
-                self._dts,
-                self._log,
-                self._loop,
-                nsd_msg,
-                self
-                )
+            self._dts,
+            self._log,
+            self._loop,
+            nsd_msg,
+            self
+        )
         self._nsds[nsd_msg.id] = nsd
 
         return nsd
@@ -4224,7 +4219,7 @@ class ScalingRpcHandler(mano_dts.DtsHandler):
                     self.callback(xact_info.xact, msg, self.ACTION.SCALE_IN)
 
                 rpc_op = NsrYang.YangOutput_Nsr_ExecScaleIn.from_dict({
-                      "instance_id": msg.instance_id})
+                    "instance_id": msg.instance_id})
 
                 xact_info.respond_xpath(
                     rwdts.XactRspCode.ACK,
@@ -4252,7 +4247,7 @@ class ScalingRpcHandler(mano_dts.DtsHandler):
                     self.callback(xact_info.xact, msg, self.ACTION.SCALE_OUT)
 
                 rpc_op = NsrYang.YangOutput_Nsr_ExecScaleOut.from_dict({
-                      "instance_id": msg.instance_id})
+                    "instance_id": msg.instance_id})
 
                 xact_info.respond_xpath(
                     rwdts.XactRspCode.ACK,
@@ -4262,23 +4257,23 @@ class ScalingRpcHandler(mano_dts.DtsHandler):
             except Exception as e:
                 self.log.exception(e)
                 xact_info.respond_xpath(
-                      rwdts.XactRspCode.NACK,
-                      self.__class__.SCALE_OUT_OUTPUT_XPATH)
+                    rwdts.XactRspCode.NACK,
+                    self.__class__.SCALE_OUT_OUTPUT_XPATH)
 
         scale_in_hdl = rift.tasklets.DTS.RegistrationHandler(
-              on_prepare=on_scale_in_prepare)
+            on_prepare=on_scale_in_prepare)
         scale_out_hdl = rift.tasklets.DTS.RegistrationHandler(
-              on_prepare=on_scale_out_prepare)
+            on_prepare=on_scale_out_prepare)
 
         with self.dts.group_create() as group:
             group.register(
-                  xpath=self.__class__.SCALE_IN_INPUT_XPATH,
-                  handler=scale_in_hdl,
-                  flags=rwdts.Flag.PUBLISHER)
+                xpath=self.__class__.SCALE_IN_INPUT_XPATH,
+                handler=scale_in_hdl,
+                flags=rwdts.Flag.PUBLISHER)
             group.register(
-                  xpath=self.__class__.SCALE_OUT_INPUT_XPATH,
-                  handler=scale_out_hdl,
-                  flags=rwdts.Flag.PUBLISHER)
+                xpath=self.__class__.SCALE_OUT_INPUT_XPATH,
+                handler=scale_out_hdl,
+                flags=rwdts.Flag.PUBLISHER)
 
 
 class NsmTasklet(rift.tasklets.Tasklet):
@@ -4352,28 +4347,28 @@ class NsmTasklet(rift.tasklets.Tasklet):
         self._vnfd_pub_handler = publisher.VnfdPublisher(use_ssl, ssl_cert, ssl_key, self.loop)
 
         self._records_publisher_proxy = NsmRecordsPublisherProxy(
-                self._dts,
-                self.log,
-                self.loop,
-                self._nsr_pub_handler,
-                self._vnfr_pub_handler,
-                self._vlr_pub_handler,
-                )
+            self._dts,
+            self.log,
+            self.loop,
+            self._nsr_pub_handler,
+            self._vnfr_pub_handler,
+            self._vlr_pub_handler,
+        )
 
         # Register the NSM to receive the nsm plugin
         # when cloud account is configured
         self._ro_plugin_selector = cloud.ROAccountPluginSelector(
-                self._dts,
-                self.log,
-                self.loop,
-                self._records_publisher_proxy,
-                )
+            self._dts,
+            self.log,
+            self.loop,
+            self._records_publisher_proxy,
+        )
         yield from self._ro_plugin_selector.register()
 
         self._cloud_account_handler = cloud.CloudAccountConfigSubscriber(
-                self._log,
-                self._dts,
-                self.log_hdl)
+            self._log,
+            self._dts,
+            self.log_hdl)
 
         yield from self._cloud_account_handler.register()
 
@@ -4381,17 +4376,17 @@ class NsmTasklet(rift.tasklets.Tasklet):
         yield from self._vnffgmgr.register()
 
         self._nsm = NsManager(
-                self._dts,
-                self.log,
-                self.loop,
-                self._nsr_pub_handler,
-                self._vnfr_pub_handler,
-                self._vlr_pub_handler,
-                self._ro_plugin_selector,
-                self._vnffgmgr,
-                self._vnfd_pub_handler,
-                self._cloud_account_handler
-                )
+            self._dts,
+            self.log,
+            self.loop,
+            self._nsr_pub_handler,
+            self._vnfr_pub_handler,
+            self._vlr_pub_handler,
+            self._ro_plugin_selector,
+            self._vnffgmgr,
+            self._vnfd_pub_handler,
+            self._cloud_account_handler
+        )
 
         yield from self._nsm.register()