예제 #1
0
    def _generate_nsd(self, vnfds, path):
        """Write a nsd to the specified path. """

        model = gi.repository.RwYang.Model.create_libncx()
        model.load_schema_ypbc(rwnsd.get_schema())

        nsd = rwnsd.NetworkServiceDescriptor()
        colony = self._sysinfo.find_by_class(rift.vcs.Colony)
        if colony is None:
            logger.error("Colony not found, could not generate NSD")
            return

        if not isinstance(colony, rift.vcs.NSD):
            ns = rift.vcs.NSD(
                collection=colony,
                name=colony.name,
            )
        else:
            ns = colony

        nsd.name = ns.nsd_name
        nsd.nsd_id = ns.id
        nsd.provider = ns.provider
        nsd.version = ns.version

        # Add all vnf id's to the nsd
        for vnfd in vnfds:
            nsd.constituent_vnfs.add().vnf_id = vnfd.vnfd_id

        # Create a mapping of link name (port_group) to a list
        # of all VNFD Connection points connected to that link
        link_points = collections.defaultdict(list)
        for vnfd in vnfds:
            for conn_point in vnfd.connection_points:
                link_name = conn_point.id.split("_")[2]
                link_points[link_name].append(conn_point.id)

        # Add a virtual link descriptor for each link name and
        # add all the vnf connections points to it.
        vld_id_gen = itertools.count(1)
        for link_name in link_points:
            vld = nsd.vlds.add()
            vld.id = next(vld_id_gen)
            vld.type_yang = "ELAN"
            for vnf_cp_id in link_points[link_name]:
                vld.connection_points.add().id = vnf_cp_id

        with open(path, 'w') as fp:
            fp.write(nsd.to_xml_v2(model))

        logger.info('Wrote NSD XML file %s: %s', path, nsd)
예제 #2
0
파일: demo.py 프로젝트: RIFTIO/RIFT.ware
    def _generate_nsd(self, vnfds, path):
        """Write a nsd to the specified path. """

        model = gi.repository.RwYang.Model.create_libncx()
        model.load_schema_ypbc(rwnsd.get_schema())

        nsd = rwnsd.NetworkServiceDescriptor()
        colony = self._sysinfo.find_by_class(rift.vcs.Colony)
        if colony is None:
            logger.error("Colony not found, could not generate NSD")
            return

        if not isinstance(colony, rift.vcs.NSD):
            ns = rift.vcs.NSD(
                    collection=colony,
                    name=colony.name,
                    )
        else:
            ns = colony

        nsd.name = ns.nsd_name
        nsd.nsd_id = ns.id
        nsd.provider = ns.provider
        nsd.version = ns.version

        # Add all vnf id's to the nsd
        for vnfd in vnfds:
            nsd.constituent_vnfs.add().vnf_id = vnfd.vnfd_id

        # Create a mapping of link name (port_group) to a list
        # of all VNFD Connection points connected to that link
        link_points = collections.defaultdict(list)
        for vnfd in vnfds:
            for conn_point in vnfd.connection_points:
                link_name = conn_point.id.split("_")[2]
                link_points[link_name].append(conn_point.id)

        # Add a virtual link descriptor for each link name and
        # add all the vnf connections points to it.
        vld_id_gen = itertools.count(1)
        for link_name in link_points:
            vld = nsd.vlds.add()
            vld.id = next(vld_id_gen)
            vld.type_yang = "ELAN"
            for vnf_cp_id in link_points[link_name]:
                vld.connection_points.add().id = vnf_cp_id

        with open(path, 'w') as fp:
            fp.write(nsd.to_xml_v2(model))

        logger.info('Wrote NSD XML file %s: %s', path, nsd)
예제 #3
0
import rift.vcs
import sys

import gi
gi.require_version('RwYang', '1.0')

# TODO (Philip): Relook at this code

from gi.repository import (NsdYang, VldYang, VnfdYang, RwYang)

logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger(__name__)

model = RwYang.Model.create_libyang()
model.load_schema_ypbc(VldYang.get_schema())
model.load_schema_ypbc(NsdYang.get_schema())
model.load_schema_ypbc(VnfdYang.get_schema())


def configure_vld(proxy, vld_xml_hdl):
    vld_xml = vld_xml_hdl.read()
    logger.debug("Attempting to deserialize XML into VLD protobuf: %s",
                 vld_xml)
    vld = VldYang.YangData_RwProject_Project_VldCatalog_Vld()
    vld.from_xml_v2(model, vld_xml)

    logger.debug("Sending VLD to netconf: %s", vld)
    proxy.merge_config(vld.to_xml_v2(model))


def configure_vnfd(proxy, vnfd_xml_hdl):
예제 #4
0
#

import argparse
import logging
import rift.auto.proxy
import rift.vcs
import sys

from gi.repository import NsdYang, VldYang, VnfdYang, RwYang

logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger(__name__)

model = RwYang.Model.create_libncx()
model.load_schema_ypbc(VldYang.get_schema())
model.load_schema_ypbc(NsdYang.get_schema())
model.load_schema_ypbc(VnfdYang.get_schema())


def configure_vld(proxy, vld_xml_hdl):
    vld_xml = vld_xml_hdl.read()
    logger.debug("Attempting to deserialize XML into VLD protobuf: %s", vld_xml)
    vld = VldYang.YangData_Vld_VldCatalog_Vld()
    vld.from_xml_v2(model, vld_xml)

    logger.debug("Sending VLD to netconf: %s", vld)
    proxy.merge_config(vld.to_xml_v2(model))


def configure_vnfd(proxy, vnfd_xml_hdl):
    vnfd_xml = vnfd_xml_hdl.read()