RENCI-NRIG / ndllib

NDL Imperative and declarative conversion library
0 stars 0 forks source link

NDLLib incorrectly creates stitchports #1

Closed ibaldin closed 8 years ago

ibaldin commented 8 years ago

Since modifications made by Yufeng to embedding code to accommodate multiple stitchports in a single request, the stitchports should be defined differently from what NDLlib is currently doing. Fan is trying to use NDLlib.

ibaldin commented 8 years ago

The previous way of declaring a stitchport was like this (class is indicated in parentheses):

Device(StitchingDomain) hasInterface StitchportURL(Interface) StitchportURL(Interface) label VLANTag(Label) NodeOrLink(...) hasInterface StitchportURL(Interface)

The new way is like this

Device(StitchingDomain) hasInterface SomeUniqueID(Interface) [SomeUniqueId in flukes is formed by appending VLAN tag to the Stitchport URL, but doesn't have to be] SomeUniqueId(Interface) label VLANTag(Label) StitchportURL(Interface) ethernet:Tagged-Ethernet SomeUniqueId(Interface) [ this is an adaptation property] NodeOrLink(....) hasInterface SomeUniqueId(Interface)

Here are examples from a correct request:

Stitchport:

  <rdf:Description rdf:about="http://geni-orca.renci.org/owl/75ad7d8a-4623-49fc-a084-4bd42311aeab#sp">
    <topology:hasInterface rdf:resource="http://geni-orca.renci.org/owl/ion.rdf#AL2S/SDSC/Cisco/6509/TenGigabitEthernet/1/1/3700"/>
    <topology:hasGUID>b6cfa51d-73a2-477e-b685-b14c9914d83e</topology:hasGUID>
    <request-schema:inDomain rdf:resource="http://geni-orca.renci.org/owl/orca.rdf#Stitching/Domain"/>
    <rdf:type rdf:resource="http://geni-orca.renci.org/owl/topology.owl#Device"/>
  </rdf:Description>

SomeUniqueID:

  <rdf:Description rdf:about="http://geni-orca.renci.org/owl/ion.rdf#AL2S/SDSC/Cisco/6509/TenGigabitEthernet/1/1/3700">
    <layer:label rdf:resource="http://geni-orca.renci.org/owl/75ad7d8a-4623-49fc-a084-4bd42311aeab#Label-3700"/>
    <rdf:type rdf:resource="http://geni-orca.renci.org/owl/topology.owl#Interface"/>
  </rdf:Description>

Adaptation:

  <rdf:Description rdf:about="http://geni-orca.renci.org/owl/ion.rdf#AL2S/SDSC/Cisco/6509/TenGigabitEthernet/1/1">
    <ethernet:Tagged-Ethernet rdf:resource="http://geni-orca.renci.org/owl/ion.rdf#AL2S/SDSC/Cisco/6509/TenGigabitEthernet/1/1/3700"/>
    <rdf:type rdf:resource="http://geni-orca.renci.org/owl/topology.owl#Interface"/>
  </rdf:Description>

The other side (in this case it's a network object):

  <rdf:Description rdf:about="http://geni-orca.renci.org/owl/75ad7d8a-4623-49fc-a084-4bd42311aeab#net">
    <topology:hasInterface rdf:resource="http://geni-orca.renci.org/owl/ion.rdf#AL2S/SDSC/Cisco/6509/TenGigabitEthernet/1/1/3700"/>
    <topology:hasInterface rdf:resource="http://geni-orca.renci.org/owl/75ad7d8a-4623-49fc-a084-4bd42311aeab#net-node"/>
    <layer:atLayer rdf:resource="http://geni-orca.renci.org/owl/ethernet.owl#EthernetNetworkElement"/>
    <topology:hasGUID>42361682-11b6-44c3-bd9e-3de8d87a0919</topology:hasGUID>
    <rdf:type rdf:resource="http://geni-orca.renci.org/owl/topology.owl#BroadcastConnection"/>
  </rdf:Description>
ibaldin commented 8 years ago

Here is a code example:

        if (n instanceof OrcaStitchPort) {
            OrcaStitchPort sp = (OrcaStitchPort)n;
            if ((sp.getPort() == null) || (sp.getPort().length() == 0) || 
                    (sp.getLabel() == null) || (sp.getLabel().length() == 0))
                throw new NdlException("URL and label must be specified in StitchPort");
            //intI = ngen.declareExistingInterface(sp.getPort());
            intI = ngen.declareExistingInterface(generateStitchPortInterfaceUrl(sp));
            ngen.addLabelToIndividual(intI, sp.getLabel());
            // declare adaptation
            Individual intM = ngen.declareExistingInterface(sp.getPort());
            ngen.addEthernetAdaptation(intM, intI);
            }
...
        // add to link
        ngen.addInterfaceToIndividual(intI, edgeI);

        // add to previously added node
        Individual nodeI = getOrDeclareIndividual(n);
        if (nodeI == null)
            throw new NdlException("Unable to find or create individual in the model for node " + n + " of type " + n.getResourceType());

        ngen.addInterfaceToIndividual(intI, nodeI);

where

    static String generateStitchPortInterfaceUrl(OrcaStitchPort osp) throws NdlException {
        if ((osp.getPort() == null) || (osp.getLabel() == null))
            throw new NdlException("Stitchport " + osp + " does not specify URL or label");

        if (osp.getPort().endsWith("/"))
            return osp.getPort() + osp.getLabel();
        else
            return osp.getPort() + "/" + osp.getLabel();
    }
ibaldin commented 8 years ago

I can probably consolidate this a little bit and make a single call for NdlGenerator to create a stitchport interface that will save a couple of calls above.

shuang5 commented 8 years ago

Is Fan using Paul’s original branch or the property-graph branch? -shu On Nov 2, 2015, at 9:33 AM, Ilya Baldin notifications@github.com<mailto:notifications@github.com> wrote:

Since modifications made by Yufeng to embedding code to accommodate multiple stitchports in a single request, the stitchports should be defined differently from what NDLlib is currently doing. Fan is trying to use NDLlib.

— Reply to this email directly or view it on GitHubhttps://github.com/RENCI-NRIG/ndllib/issues/1.

ibaldin commented 8 years ago

Original, I think.

-ilya

Ilya Baldin Director, Networking Research and Infrastructure RENCI/UNC Chapel Hill http://www.renci.org

On Nov 2, 2015, at 10:43 AM, shuang5 notifications@github.com<mailto:notifications@github.com> wrote:

Is Fan using Paul’s original branch or the property-graph branch? -shu On Nov 2, 2015, at 9:33 AM, Ilya Baldin notifications@github.com<mailto:notifications@github.commailto:notifications@github.com> wrote:

Since modifications made by Yufeng to embedding code to accommodate multiple stitchports in a single request, the stitchports should be defined differently from what NDLlib is currently doing. Fan is trying to use NDLlib.

— Reply to this email directly or view it on GitHubhttps://github.com/RENCI-NRIG/ndllib/issues/1.

— Reply to this email directly or view it on GitHubhttps://github.com/RENCI-NRIG/ndllib/issues/1#issuecomment-153057471.

ibaldin commented 8 years ago

OK, I modified NDL commons (based on modify branch of Orca) so that above can now be done like this:

        if (n instanceof OrcaStitchPort) {
            OrcaStitchPort sp = (OrcaStitchPort)n;
            if ((sp.getPort() == null) || (sp.getPort().length() == 0) || 
                    (sp.getLabel() == null) || (sp.getLabel().length() == 0))
                throw new NdlException("URL and label must be specified in StitchPort");
            intI = ngen.declareStitchportInterface(sp.getPort(), sp.getLabel());
        } else 
            intI = ngen.declareInterface(e.getName()+"-"+n.getName());
        // add to link
        ngen.addInterfaceToIndividual(intI, edgeI);

        // add to previously added node
        Individual nodeI = getOrDeclareIndividual(n);

        if (nodeI == null)
            throw new NdlException("Unable to find or create individual in the model for node " + n + " of type " + n.getResourceType());

        ngen.addInterfaceToIndividual(intI, nodeI);

i.e. just call NdlGenerator.declareStitchportInterface(URL, Label)

ibaldin commented 8 years ago

Also new Flukes is deployed with this new code. NDLLib should be able to do the same thing now.

NDL Commons is on orca5 modify branch and also deployed into Nexus

ibaldin commented 8 years ago

Build a new version from master using e6ccfdf34d201bece74f0697bdbb77629878c73c, should work

ibaldin commented 8 years ago

Fan reported the fix works.