Search in sources :

Example 51 with Result

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.Result in project netvirt by opendaylight.

the class ConfigureL3VpnCommand method createL3VpnCLI.

private void createL3VpnCLI() throws InterruptedException, ExecutionException {
    if (vid == null) {
        session.getConsole().println("Please supply a valid VPN ID");
        session.getConsole().println(getHelp("create"));
        return;
    }
    if (rd == null) {
        session.getConsole().println("Please supply a valid RD");
        session.getConsole().println(getHelp("create"));
        return;
    }
    if (irt == null) {
        session.getConsole().println("Please supply a valid list of import RTs separated by {,}");
        session.getConsole().println(getHelp("create"));
        return;
    }
    if (ert == null) {
        session.getConsole().println("Please supply a valid list of export RTs separated by {,}");
        session.getConsole().println(getHelp("create"));
        return;
    }
    Uuid vuuid = new Uuid(vid);
    RpcResult<CreateL3VPNOutput> createL3VpnRpcResult = null;
    {
        ArrayList<String> rdList = new ArrayList<>(Arrays.asList(rd.split(",")));
        ArrayList<String> irtList = new ArrayList<>(Arrays.asList(irt.split(",")));
        ArrayList<String> ertList = new ArrayList<>(Arrays.asList(ert.split(",")));
        Uuid tuuid = null;
        if (tid != null) {
            tuuid = new Uuid(tid);
        }
        List<L3vpn> l3vpns = new ArrayList<>();
        L3vpn l3vpn = new L3vpnBuilder().setId(vuuid).setName(name).setRouteDistinguisher(rdList).setImportRT(irtList).setExportRT(ertList).setTenantId(tuuid).build();
        l3vpns.add(l3vpn);
        Future<RpcResult<CreateL3VPNOutput>> result = neutronvpnService.createL3VPN(new CreateL3VPNInputBuilder().setL3vpn(l3vpns).build());
        createL3VpnRpcResult = result.get();
        if (createL3VpnRpcResult.isSuccessful()) {
            session.getConsole().println("L3VPN created successfully");
            LOG.trace("createl3vpn: {}", result);
        } else {
            session.getConsole().println("Error populating createL3VPN : " + result.get().getErrors());
            session.getConsole().println(getHelp("create"));
        }
    }
    /**
     * passing a subnetId list alongwith create-l3-vpn CLI implicitly indicates that
     * association of network(s) to VPN is being intended.
     */
    if (createL3VpnRpcResult.isSuccessful()) {
        {
            List<Uuid> networkIdList = new ArrayList<>();
            if (sid != null) {
                for (String sidStr : sid.split(",")) {
                    Uuid subnetId = new Uuid(sidStr);
                    Uuid networkId = neutronVpnManager.getNetworkForSubnet(subnetId);
                    if (networkId != null) {
                        networkIdList.add(networkId);
                    } else {
                        session.getConsole().println("Could not find network for subnet " + subnetId.getValue() + ". Not proceeding with adding subnet to VPN");
                    }
                }
                if (!networkIdList.isEmpty()) {
                    Future<RpcResult<AssociateNetworksOutput>> result = neutronvpnService.associateNetworks(new AssociateNetworksInputBuilder().setVpnId(vuuid).setNetworkId(networkIdList).build());
                    RpcResult<AssociateNetworksOutput> associateNetworksRpcResult = result.get();
                    if (associateNetworksRpcResult.isSuccessful()) {
                        session.getConsole().println("Subnet(s) added to VPN successfully");
                        LOG.trace("associateNetworks: {}", result);
                    } else {
                        session.getConsole().println("Error while adding subnet(s) to VPN: " + result.get().getErrors());
                        session.getConsole().println(getHelp("create"));
                    }
                }
            }
        }
    }
}
Also used : CreateL3VPNOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.CreateL3VPNOutput) ArrayList(java.util.ArrayList) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) L3vpn(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.createl3vpn.input.L3vpn) AssociateNetworksInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.AssociateNetworksInputBuilder) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) AssociateNetworksOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.AssociateNetworksOutput) Future(java.util.concurrent.Future) ArrayList(java.util.ArrayList) List(java.util.List) L3vpnBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.createl3vpn.input.L3vpnBuilder) CreateL3VPNInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.CreateL3VPNInputBuilder)

Example 52 with Result

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.Result in project netvirt by opendaylight.

the class ConfigureL3VpnCommand method deleteL3VpnCLI.

private void deleteL3VpnCLI() throws InterruptedException, ExecutionException {
    if (vid == null) {
        session.getConsole().println("Please supply a valid VPN ID");
        session.getConsole().println(getHelp("delete"));
        return;
    }
    Uuid vpnId = new Uuid(vid);
    // disassociation of network(s) (removal of subnet(s)) from VPN to be followed by deletion of VPN
    RpcResult<DissociateNetworksOutput> dissociateNetworksRpcResult = null;
    List<Uuid> networkIdList = null;
    networkIdList = neutronVpnManager.getNetworksForVpn(vpnId);
    if (networkIdList != null && !networkIdList.isEmpty()) {
        Future<RpcResult<DissociateNetworksOutput>> result = neutronvpnService.dissociateNetworks(new DissociateNetworksInputBuilder().setVpnId(vpnId).setNetworkId(networkIdList).build());
        dissociateNetworksRpcResult = result.get();
        if (dissociateNetworksRpcResult.isSuccessful()) {
            session.getConsole().println("Subnet(s) removed from VPN successfully");
            LOG.trace("dissociateNetworks: {}", result);
        } else {
            session.getConsole().println("Error while removing subnet(s) from VPN: " + result.get().getErrors());
            session.getConsole().println(getHelp("delete"));
        }
    }
    if (networkIdList == null || networkIdList.isEmpty() || dissociateNetworksRpcResult.isSuccessful()) {
        List<Uuid> vpnIdList = new ArrayList<>();
        vpnIdList.add(vpnId);
        Future<RpcResult<DeleteL3VPNOutput>> result = neutronvpnService.deleteL3VPN(new DeleteL3VPNInputBuilder().setId(vpnIdList).build());
        RpcResult<DeleteL3VPNOutput> rpcResult = result.get();
        if (rpcResult.isSuccessful()) {
            session.getConsole().println("L3VPN deleted successfully");
            LOG.trace("deletel3vpn: {}", result);
        } else {
            session.getConsole().println("Error populating deleteL3VPN : " + result.get().getErrors());
            session.getConsole().println(getHelp("delete"));
        }
    } else {
        session.getConsole().println("Not proceeding with deletion of L3VPN since error(s) encountered " + "in removing subnet(s) from VPN");
    }
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) DissociateNetworksOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.DissociateNetworksOutput) DeleteL3VPNOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.DeleteL3VPNOutput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) ArrayList(java.util.ArrayList) DeleteL3VPNInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.DeleteL3VPNInputBuilder) DissociateNetworksInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.DissociateNetworksInputBuilder)

Example 53 with Result

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.Result in project bgpcep by opendaylight.

the class EthSegRParserTest method parser2Test.

@Test
public void parser2Test() {
    final EsRouteCase expected = new EsRouteCaseBuilder().setEsRoute(new EsRouteBuilder().setEsi(LAN_AUT_GEN_CASE).setOrigRouteIp(IPV6).build()).build();
    assertArrayEquals(RESULT2, ByteArray.getAllBytes(this.parser.serializeEvpn(expected, Unpooled.wrappedBuffer(ROUDE_DISTIN))));
    final EvpnChoice result = this.parser.parseEvpn(Unpooled.wrappedBuffer(VALUE2));
    assertEquals(expected, result);
    final DataContainerNodeBuilder<YangInstanceIdentifier.NodeIdentifier, ChoiceNode> choice = Builders.choiceBuilder();
    choice.withNodeIdentifier(EthSegRParser.ES_ROUTE_NID);
    final ContainerNode arbitraryC = createContBuilder(EthSegRParser.ES_ROUTE_NID).addChild(LanParserTest.createLanChoice()).addChild(createValueBuilder(IPV6_MODEL, ORI_NID).build()).build();
    final EvpnChoice modelResult = this.parser.serializeEvpnModel(arbitraryC);
    assertEquals(expected, modelResult);
    final EvpnChoice keyResult = this.parser.createRouteKey(arbitraryC);
    assertEquals(expected, keyResult);
}
Also used : EsRouteCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.evpn.evpn.choice.EsRouteCase) EsRouteBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.es.route.EsRouteBuilder) ChoiceNode(org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode) EvpnChoice(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.evpn.EvpnChoice) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) EsRouteCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.evpn.evpn.choice.EsRouteCaseBuilder) LanParserTest(org.opendaylight.protocol.bgp.evpn.impl.esi.types.LanParserTest) Test(org.junit.Test)

Example 54 with Result

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.Result in project bgpcep by opendaylight.

the class IncMultEthTagRParserTest method parserTest.

@Test
public void parserTest() {
    final IncMultiEthernetTagResCase expected = IncMultEthTagRParserTest.createIncMultiCase();
    assertArrayEquals(RESULT, ByteArray.getAllBytes(this.parser.serializeEvpn(expected, Unpooled.wrappedBuffer(ROUDE_DISTIN))));
    final EvpnChoice result = this.parser.parseEvpn(Unpooled.wrappedBuffer(VALUE));
    assertEquals(expected, result);
    final DataContainerNodeBuilder<NodeIdentifier, ChoiceNode> choice = Builders.choiceBuilder();
    choice.withNodeIdentifier(IncMultEthTagRParser.INC_MULT_ROUTE_NID);
    final ContainerNode incMult = createContBuilder(IncMultEthTagRParser.INC_MULT_ROUTE_NID).addChild(createEti()).addChild(createValueBuilder(IP_MODEL, ORI_NID).build()).build();
    final EvpnChoice modelResult = this.parser.serializeEvpnModel(incMult);
    assertEquals(expected, modelResult);
    final EvpnChoice keyResult = this.parser.createRouteKey(incMult);
    assertEquals(expected, keyResult);
}
Also used : IncMultiEthernetTagResCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.evpn.evpn.choice.IncMultiEthernetTagResCase) NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) ChoiceNode(org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode) EvpnChoice(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.evpn.EvpnChoice) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) Test(org.junit.Test)

Example 55 with Result

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.Result in project bgpcep by opendaylight.

the class MACIpAdvRParserTest method parserCase2Test.

@Test
public void parserCase2Test() {
    final MacIpAdvRouteCase expected = new MacIpAdvRouteCaseBuilder().setMacIpAdvRoute(new MacIpAdvRouteBuilder().setEsi(LAN_AUT_GEN_CASE).setEthernetTagId(ETI).setMacAddress(MAC).setIpAddress(IPV6).setMplsLabel1(MPLS_LABEL).build()).build();
    assertArrayEquals(RESULT2, ByteArray.getAllBytes(this.parser.serializeEvpn(expected, Unpooled.wrappedBuffer(ROUDE_DISTIN))));
    final EvpnChoice result = this.parser.parseEvpn(Unpooled.wrappedBuffer(VALUE2));
    assertEquals(expected, result);
    final DataContainerNodeBuilder<NodeIdentifier, ChoiceNode> choice = Builders.choiceBuilder();
    choice.withNodeIdentifier(MACIpAdvRParser.MAC_IP_ADV_ROUTE_NID);
    final ContainerNode macIp = createContBuilder(MACIpAdvRParser.MAC_IP_ADV_ROUTE_NID).addChild(LanParserTest.createLanChoice()).addChild(createEti()).addChild(createValueBuilder(MAC_MODEL, MAC_NID).build()).addChild(createValueBuilder(IPV6_MODEL, IP_NID).build()).addChild(createValueBuilder(MPLS_LABEL_MODEL, MPLS1_NID).build()).build();
    final EvpnChoice modelResult = this.parser.serializeEvpnModel(macIp);
    assertEquals(expected, modelResult);
}
Also used : MacIpAdvRouteCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.evpn.evpn.choice.MacIpAdvRouteCaseBuilder) MacIpAdvRouteBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.mac.ip.adv.route.MacIpAdvRouteBuilder) MacIpAdvRouteCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.evpn.evpn.choice.MacIpAdvRouteCase) NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) ChoiceNode(org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode) EvpnChoice(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.evpn.EvpnChoice) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) LanParserTest(org.opendaylight.protocol.bgp.evpn.impl.esi.types.LanParserTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)348 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)174 ByteBuf (io.netty.buffer.ByteBuf)97 ArrayList (java.util.ArrayList)94 ExecutionException (java.util.concurrent.ExecutionException)92 AttributesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.AttributesBuilder)46 ObjectHeaderImpl (org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl)40 RouteAttributeContainer (org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry.RouteAttributeContainer)33 Statement (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.Statement)33 List (java.util.List)31 BigInteger (java.math.BigInteger)29 Collections (java.util.Collections)26 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)24 Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)24 Nonnull (javax.annotation.Nonnull)23 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)23 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)23 AllocateIdInput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInput)22 AllocateIdInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInputBuilder)22 RpcError (org.opendaylight.yangtools.yang.common.RpcError)22