@click.option('--ssh_keys',
default=None,
help='comma separated list of keys to inject to vnfs')
-@click.option('--vim_network_prefix',
+@click.option('--config',
default=None,
- help='vim network name prefix')
+ help='ns specific yaml configuration')
@click.pass_context
def ns_create(ctx,
nsd_name,
vim_account,
admin_status,
ssh_keys,
- vim_network_prefix):
+ config):
try:
ctx.obj.ns.create(
nsd_name,
ns_name,
- vim_network_prefix=vim_network_prefix,
+ config=config,
ssh_keys=ssh_keys,
account=vim_account)
except ClientException as inst:
from osmclient.common.exceptions import ClientException
from osmclient.common.exceptions import NotFound
import uuid
+import yaml
class Ns(object):
ns_name,
resp))
- def create(self, nsd_name, nsr_name, account, vim_network_prefix=None,
+ def create(self, nsd_name, nsr_name, account, config=None,
ssh_keys=None, description='default description',
admin_status='ENABLED'):
postdata = {}
nsr['ssh-authorized-key'] = ssh_keys_format
- if vim_network_prefix is not None:
- for index, vld in enumerate(nsr['nsd']['vld']):
- network_name = vld['name']
- nsr['nsd']['vld'][index]['vim-network-name'] = '{}-{}'.format(
- vim_network_prefix, network_name)
+ if config:
+ ns_config = yaml.load(config)
+
+ if ns_config and 'vim-network-name' in ns_config:
+ for network in ns_config['vim-network-name']:
+ # now find this network
+ vld_name = network['name']
+ vim_vld_name = network['vim-network-name']
+
+ for index, vld in enumerate(nsr['nsd']['vld']):
+ if vld['name'] == vld_name:
+ nsr['nsd']['vld'][index]['vim-network-name'] = network['vim-network-name']
postdata['nsr'].append(nsr)