def __init__(self, name, instance_count=1):
self.vnfd_catalog = None
self.vnfd = None
+ self.mano_ut = False
+ self.use_ns_init_conf = False
+ self.use_vca_conf = False
+ self.use_charm = False
self.instance_count = instance_count
self._placement_groups = []
+ self.use_vnf_init_conf = False
super(VirtualNetworkFunction, self).__init__(name)
def add_placement_group(self, group):
with open(script_file, "w") as f:
f.write("{}".format(cfg))
+ # Copy the vnf_init_config script
+ if self.use_vnf_init_conf and ('ping' in self.name):
+ script_name = 'ping_set_rate.py'
+
+ src_path = os.path.dirname(os.path.abspath(os.path.realpath(__file__)))
+ script_src = os.path.join(src_path, script_name)
+ if not os.path.exists(script_src):
+ src_path = os.path.join(os.environ['RIFT_ROOT'],
+ 'modules/core/mano/examples/ping_pong_ns/rift/mano/examples')
+ script_src = os.path.join(src_path, script_name)
+
+ dest_path = os.path.join(outdir, self.name, 'scripts')
+ os.makedirs(dest_path, exist_ok=True)
+
+ shutil.copy2(script_src, dest_path)
+
+ def add_scripts(self, outdir):
+ if not self.use_charm:
+ self.add_cloud_init(outdir)
+
+ if self.use_vca_conf and not self.use_charm:
+ self.add_vca_scripts(outdir)
+
+ def add_vca_scripts(self, outdir):
+ dest_path = os.path.join(outdir, self.name, 'scripts')
+ try:
+ os.makedirs(dest_path)
+ except OSError:
+ if not os.path.isdir(dest_path):
+ raise
+
+ if 'pong_' in self.name:
+ scripts = ['pong_setup.py', 'pong_start_stop.py']
+ else:
+ scripts = ['ping_setup.py', 'ping_rate.py', 'ping_start_stop.py']
+
+ for script_name in scripts:
+ src_path = os.path.dirname(os.path.abspath(
+ os.path.realpath(__file__)))
+ script_src = os.path.join(src_path, script_name)
+ if not os.path.exists(script_src):
+ src_path = os.path.join(os.environ['RIFT_ROOT'],
+ 'modules/core/mano/examples/'
+ 'ping_pong_ns/rift/mano/examples')
+ script_src = os.path.join(src_path, script_name)
+
+ shutil.copy2(script_src, dest_path)
+
+
class NetworkService(ManoDescriptor):
def __init__(self, name):
super(NetworkService, self).__init__(name)
{"name": "number", "data_type": "STRING", "mandatory": True},
]
})
- vnf_config.service_primitive.append(config)
+ vnf_config.config_primitive.append(config)
- def default_config(self, const_vnfd, vnfd, mano_ut, use_ns_init_conf):
+ def default_config(self, const_vnfd, vnfd, mano_ut,
+ use_ns_init_conf,
+ use_vnf_init_conf):
vnf_config = vnfd.vnfd.vnf_configuration
vnf_config.config_attributes.config_priority = 0
def compose(self, vnfd_list, cpgroup_list, mano_ut,
use_ns_init_conf=True,
- use_vnf_init_conf=True,):
++ use_vnf_init_conf=True,
+ use_vca_conf=False):
if mano_ut:
# Disable NS initial config primitive
constituent_vnfd.start_by_default = False
constituent_vnfd.vnfd_id_ref = vnfd.descriptor.vnfd[0].id
- self.default_config(constituent_vnfd, vnfd, mano_ut,
- use_ns_init_conf, use_vnf_init_conf)
+ if use_vca_conf is False:
+ self.default_config(constituent_vnfd, vnfd, mano_ut,
- use_ns_init_conf)
++ use_ns_init_conf, use_vnf_init_conf)
member_vnf_index += 1
# Enable config primitives if either mano_ut or
ex_pong_userdata=None,
use_placement_group=True,
use_ns_init_conf=True,
+ use_vnf_init_conf=True,
+ use_vca_conf=True,
+ use_charm=False,
):
# List of connection point groups
# Each connection point group refers to a virtual link
cpgroup_list,
mano_ut,
use_ns_init_conf=use_ns_init_conf,
- use_vnf_init_conf=use_vnf_init_conf,)
++ use_vnf_init_conf=use_vnf_init_conf,
+ use_vca_conf=use_vca_conf,
+ )
if write_to_file:
ping.write_to_file(out_dir, ping_fmt if ping_fmt is not None else fmt)
"The value should be hidden by the UI.
Only applies to parameters with default values.";
type boolean;
+ default false;
+ }
+
+ leaf out {
+ description "If this is an output of the primitive execution";
+ type boolean;
+ default false;
}
- leaf parameter-type {
- description "Type of this parameter, whether this in IN or OUT";
- type enumeration {
- enum OUT;
- enum IN;
- }
- default "IN";
- }
- leaf parameter-path {
- description "A Leafref to the parameter path with the attribute selection.
- At present only attribute ip-address() is supported.
- For example, to get the ip address of VNF connection point
- the xpath would look something along the following lines,
- /vnfd-catalog/vnfd[id='x']/connection-point[name='cp']/ip-address()";
- type string;
- }
}
list initial-config-primitive {
rwpb:msg-new InitialConfigPrimitive;
description
- "Initial set of configuration primitives.";
+ "Initial set of configuration primitives.";
key "seq";
- uses initial-config;
+ leaf seq {
+ description
+ "Sequence number for the configuration primitive.";
+ type uint64;
+ }
+
+ choice primtive-type {
+ case primtive-definition {
+ leaf name {
+ description
+ "Name of the configuration primitive.";
+ type string;
+ }
+
+ uses primitive-parameter-value;
++
++ leaf user-defined-script {
++ description
++ "A user defined script.";
++ type string;
++ }
+ }
+
+ case primitive-ref {
+ leaf config-primitive-ref {
+ description
+ "Reference to a config primitive name.
+ NOTE: The config primitive referred should have
+ all the input paramaters predefined either
+ with default values or dependency references.";
+ type leafref {
+ path "../../config-primitive/name";
+ }
+ }
+ }
+ }
}
leaf config-template {