X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FN2VC.git;a=blobdiff_plain;f=n2vc%2Fvnf.py;h=1c79aed6544af489e8f561d6a3b81df65c6b5944;hp=4427c9b37e792583a4790590a590f767cb8ba44b;hb=bf79352ca652b228c5c216564cc512b635e3c5e4;hpb=cf253202ee98f285720c18d5c7bae382ea900934 diff --git a/n2vc/vnf.py b/n2vc/vnf.py index 4427c9b..1c79aed 100644 --- a/n2vc/vnf.py +++ b/n2vc/vnf.py @@ -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 # @@ -894,11 +885,15 @@ class N2VC: params = {} for parameter in parameters: 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() - value = None if paramtype == "integer": value = int(parameter['value']) @@ -906,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'] == "": params[param] = str(values[parameter['value']])