[bug 581] Fix parameter checking if no data-type
[osm/N2VC.git] / n2vc / vnf.py
index e03cca9..1c79aed 100644 (file)
@@ -429,23 +429,14 @@ class N2VC:
         ########################################################
         to = ""
         if machine_spec.keys():
-            if all(k in machine_spec for k in ['hostname', 'username']):
-                # Get the path to the previously generated ssh private key.
-                # Machines we're manually provisioned must have N2VC's public
-                # key injected, so if we don't have a keypair, raise an error.
-                private_key_path = ""
-
-                # Enlist the existing machine in Juju
-                machine = await self.model.add_machine(
-                    spec='ssh:{}@{}:{}'.format(
-                        specs['host'],
-                        specs['user'],
-                        private_key_path,
-                    )
-                )
-                # Set the machine id that the deploy below will use.
+            if all(k in machine_spec for k in ['host', 'user']):
+                # Enlist an existing machine as a Juju unit
+                machine = await model.add_machine(spec='ssh:{}@{}:{}'.format(
+                    machine_spec['user'],
+                    machine_spec['host'],
+                    self.GetPrivateKeyPath(),
+                ))
                 to = machine.id
-            pass
 
         #######################################
         # Get the initial charm configuration #
@@ -494,11 +485,12 @@ class N2VC:
         # #######################################
         # # Execute initial config primitive(s) #
         # #######################################
-        await self.ExecuteInitialPrimitives(
+        uuids = await self.ExecuteInitialPrimitives(
             model_name,
             application_name,
             params,
         )
+        return uuids
 
         # primitives = {}
         #
@@ -895,6 +887,10 @@ class N2VC:
             param = str(parameter['name'])
             value = None
 
+            # If there's no value, use the default-value (if set)
+            if parameter['value'] is None and 'default-value' in parameter:
+                value = parameter['default-value']
+
             # Typecast parameter value, if present
             if 'data-type' in parameter:
                 paramtype = str(parameter['data-type']).lower()
@@ -905,6 +901,9 @@ class N2VC:
                     value = bool(parameter['value'])
                 else:
                     value = str(parameter['value'])
+            else:
+                # If there's no data-type, assume the value is a string
+                value = str(parameter['value'])
 
             if parameter['value'] == "<rw_mgmt_ip>":
                 params[param] = str(values[parameter['value']])
@@ -926,7 +925,6 @@ class N2VC:
 
         return config
 
-    @staticmethod
     def FormatApplicationName(self, *args):
         """
         Generate a Juju-compatible Application name
@@ -942,7 +940,6 @@ class N2VC:
 
             FormatApplicationName("ping_pong_ns", "ping_vnf", "a")
         """
-
         appname = ""
         for c in "-".join(list(args)):
             if c.isdigit():