Search in sources :

Example 21 with Object

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object in project netvirt by opendaylight.

the class ElanGet method doExecute.

@Override
protected Object doExecute() {
    LOG.debug("Executing Get ElanInstance command for elanName: {}", elanName);
    if (elanName != null) {
        ElanInstance elanInstance = elanProvider.getElanInstance(elanName);
        if (elanInstance == null) {
            session.getConsole().println("No Elan Instance present with name:" + elanName);
        } else {
            session.getConsole().println(getElanHeaderOutput());
            session.getConsole().println(String.format(ElanCLIUtils.ELAN_INTERFACE_CLI_FORMAT, elanInstance.getElanInstanceName(), elanInstance.getMacTimeout(), elanInstance.getElanTag(), elanInstance.getDescription()));
        }
    } else {
        List<ElanInstance> elanInstanceList = elanProvider.getElanInstances();
        if (elanInstanceList != null && !elanInstanceList.isEmpty()) {
            session.getConsole().println(getElanHeaderOutput());
            for (ElanInstance elanInstance : elanInstanceList) {
                session.getConsole().println(String.format(ElanCLIUtils.ELAN_INTERFACE_CLI_FORMAT, elanInstance.getElanInstanceName(), elanInstance.getMacTimeout(), elanInstance.getElanTag(), elanInstance.getDescription()));
            }
        } else {
            session.getConsole().println("No Elan Instances are present");
        }
    }
    return null;
}
Also used : ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance)

Example 22 with Object

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object in project netvirt by opendaylight.

the class ElanInterfaceGet method doExecute.

@Override
protected Object doExecute() {
    LOG.debug("Executing Get ElanInterface command for the corresponding Elan Instance for {}", elanName);
    if (elanName != null) {
        ElanInstance elanInstance = elanProvider.getElanInstance(elanName);
        List<String> elanInterfaces = elanProvider.getElanInterfaces(elanName);
        if (elanInterfaces == null) {
            session.getConsole().println("No Elan Interfaces present for ELan Instance:" + elanName);
            return null;
        }
        session.getConsole().println(getElanInterfaceHeaderOutput());
        displayInterfaces(elanInstance, elanInterfaces);
    } else {
        List<ElanInstance> elanInstances = elanProvider.getElanInstances();
        if (!elanInstances.isEmpty()) {
            session.getConsole().println(getElanInterfaceHeaderOutput());
            for (ElanInstance elanInstance : elanInstances) {
                List<String> elanInterfaces = elanProvider.getElanInterfaces(elanInstance.getElanInstanceName());
                displayInterfaces(elanInstance, elanInterfaces);
                session.getConsole().println("\n");
            }
        }
    }
    return null;
}
Also used : ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance)

Example 23 with Object

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object in project netvirt by opendaylight.

the class ElanMacTableGet method doExecute.

@Override
protected Object doExecute() {
    LOG.debug("Executing elan mac table get command for {}", elanName);
    Collection<MacEntry> macTables = elanProvider.getElanMacTable(elanName);
    if (!macTables.isEmpty()) {
        SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yy:HH:mm:ss");
        session.getConsole().println(getMacTableHeaderOutput());
        session.getConsole().println(elanName);
        for (MacEntry mac : macTables) {
            boolean isStatic = mac.isIsStaticAddress();
            session.getConsole().println(String.format(ElanCLIUtils.MAC_TABLE_CLI_FORMAT, "", mac.getInterface(), mac.getMacAddress().getValue(), ""));
            session.getConsole().println(String.format(ElanCLIUtils.MAC_TABLE_CLI_FORMAT, "", isStatic, "", isStatic ? "-" : formatter.format(new Date(mac.getControllerLearnedForwardingEntryTimestamp().longValue()))));
        }
    }
    return null;
}
Also used : MacEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntry) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Example 24 with Object

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object in project netvirt by opendaylight.

the class NeutronvpnNatManager method handleSnatSettingChangeForRouter.

private void handleSnatSettingChangeForRouter(Router update) {
    Uuid routerId = update.getUuid();
    InstanceIdentifier<Routers> routersIdentifier = NeutronvpnUtils.buildExtRoutersIdentifier(routerId);
    try {
        Optional<Routers> optionalRouters = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, routersIdentifier);
        LOG.trace("Updating Internal subnets for Routers node: {}", routerId.getValue());
        RoutersBuilder builder = null;
        if (optionalRouters.isPresent()) {
            builder = new RoutersBuilder(optionalRouters.get());
        } else {
            LOG.trace("No Routers element found for router name {}", routerId.getValue());
            return;
        }
        builder.setEnableSnat(update.getExternalGatewayInfo().isEnableSnat());
        Routers routerss = builder.build();
        // Add Routers object to the ExtRouters list
        LOG.trace("Updating extrouters for snat change {}", routerss);
        SingleTransactionDataBroker.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, routersIdentifier, routerss);
        LOG.trace("Updated successfully Routers to CONFIG Datastore");
    } catch (TransactionCommitFailedException | ReadFailedException ex) {
        LOG.error("Updation of snat for extrouters failed for router {}", routerId.getValue(), ex);
    }
}
Also used : TransactionCommitFailedException(org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException) ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) RoutersBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.RoutersBuilder) Routers(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.Routers)

Example 25 with Object

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object in project netvirt by opendaylight.

the class NeutronvpnNatManager method addExternalNetworkToRouter.

private void addExternalNetworkToRouter(Router update) {
    Uuid routerId = update.getUuid();
    Uuid extNetId = update.getExternalGatewayInfo().getExternalNetworkId();
    List<ExternalFixedIps> externalFixedIps = update.getExternalGatewayInfo().getExternalFixedIps();
    try {
        Network input = neutronvpnUtils.getNeutronNetwork(extNetId);
        ProviderTypes providerNwType = NeutronvpnUtils.getProviderNetworkType(input);
        if (providerNwType == null) {
            LOG.error("Unable to get Network Provider Type for network {}", input.getUuid().getValue());
            return;
        }
        // Add this router to the ExtRouters list
        addExternalRouter(update);
        // Update External Subnets for this router
        updateExternalSubnetsForRouter(routerId, extNetId, externalFixedIps);
        // Create and add Networks object for this External Network to the ExternalNetworks list
        InstanceIdentifier<Networks> netsIdentifier = InstanceIdentifier.builder(ExternalNetworks.class).child(Networks.class, new NetworksKey(extNetId)).build();
        Optional<Networks> optionalNets = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, netsIdentifier);
        if (!optionalNets.isPresent()) {
            LOG.error("External Network {} not present in the NVPN datamodel", extNetId.getValue());
            return;
        }
        NetworksBuilder builder = new NetworksBuilder(optionalNets.get());
        List<Uuid> rtrList = builder.getRouterIds();
        if (rtrList == null) {
            rtrList = new ArrayList<>();
        }
        rtrList.add(routerId);
        builder.setRouterIds(rtrList);
        if (NeutronvpnUtils.isFlatOrVlanNetwork(input)) {
            builder.setVpnid(extNetId);
        }
        Networks networkss = builder.build();
        // Add Networks object to the ExternalNetworks list
        LOG.trace("Updating externalnetworks {}", networkss);
        SingleTransactionDataBroker.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, netsIdentifier, networkss);
        LOG.trace("Updated externalnetworks successfully to CONFIG Datastore");
        // get vpn external form this network external to setup vpnInternet for ipv6
        Uuid vpnExternal = neutronvpnUtils.getVpnForNetwork(extNetId);
        if (vpnExternal == null) {
            LOG.debug("addExternalNetworkToRouter : no vpnExternal for Network {}", extNetId);
        }
        LOG.debug("addExternalNetworkToRouter : the vpnExternal {}", vpnExternal);
        // get subnetmap associate to the router, any subnetmap "external" could be existing
        List<Subnetmap> snList = neutronvpnUtils.getNeutronRouterSubnetMaps(routerId);
        LOG.debug("addExternalNetworkToRouter : the vpnExternal {} subnetmap to be set with vpnInternet {}", vpnExternal, snList);
        for (Subnetmap sn : snList) {
            if (sn.getInternetVpnId() == null) {
                continue;
            }
            IpVersionChoice ipVers = neutronvpnUtils.getIpVersionFromString(sn.getSubnetIp());
            if (ipVers == IpVersionChoice.IPV6) {
                LOG.debug("addExternalNetworkToRouter : setup vpnInternet IPv6 for vpnExternal {} subnetmap {}", vpnExternal, sn);
                nvpnManager.updateVpnInternetForSubnet(sn, vpnExternal, true);
            }
        }
    } catch (TransactionCommitFailedException | ReadFailedException ex) {
        LOG.error("Creation of externalnetworks failed for {}", extNetId.getValue(), ex);
    }
}
Also used : Networks(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.external.networks.Networks) ExternalNetworks(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ExternalNetworks) ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) ProviderTypes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ProviderTypes) Subnetmap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap) ExternalFixedIps(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.router.external_gateway_info.ExternalFixedIps) NetworksKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.external.networks.NetworksKey) TransactionCommitFailedException(org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) Network(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.networks.Network) NetworksBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.external.networks.NetworksBuilder) IpVersionChoice(org.opendaylight.netvirt.neutronvpn.api.enums.IpVersionChoice)

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)72 Test (org.junit.Test)60 ArrayList (java.util.ArrayList)46 Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)29 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)28 Attributes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes)25 Object (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object)23 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)18 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)17 PCEPDeserializerException (org.opendaylight.protocol.pcep.spi.PCEPDeserializerException)16 VendorInformationObject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.objects.VendorInformationObject)15 BigInteger (java.math.BigInteger)14 Preconditions (com.google.common.base.Preconditions)13 HashMap (java.util.HashMap)13 ObjectHeaderImpl (org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl)13 List (java.util.List)12 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)10 UnknownObject (org.opendaylight.protocol.pcep.spi.UnknownObject)10 BitArray (org.opendaylight.protocol.util.BitArray)9 Flowspec (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.Flowspec)9