Search in sources :

Example 16 with FixedIps

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps in project netvirt by opendaylight.

the class NeutronPortChangeListenerTest method addPort__Ipv4FixedIps.

@Test
public void addPort__Ipv4FixedIps() throws Exception {
    PortBuilder pb = new PortBuilder();
    pb.setUuid(new Uuid("12345678-1234-1234-1234-123456789012"));
    pb.setNetworkId(new Uuid("12345678-1234-1234-1234-123456789012"));
    pb.setMacAddress(new MacAddress("AA:BB:CC:DD:EE:FF"));
    IpAddress ipv4 = new IpAddress(new Ipv4Address("2.2.2.2"));
    FixedIpsBuilder fib = new FixedIpsBuilder();
    fib.setIpAddress(ipv4);
    List<FixedIps> fixedIps = new ArrayList<>();
    fixedIps.add(fib.build());
    pb.setFixedIps(fixedIps);
    Port port = pb.build();
    neutronPortChangeListener.add(InstanceIdentifier.create(Port.class), port);
}
Also used : FixedIpsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIpsBuilder) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) PortBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.PortBuilder) Port(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port) ArrayList(java.util.ArrayList) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) FixedIps(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address) Test(org.junit.Test)

Example 17 with FixedIps

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps in project netvirt by opendaylight.

the class NeutronPortChangeListenerTest method addPort__Ipv6FixedIps.

@Test
public void addPort__Ipv6FixedIps() throws Exception {
    PortBuilder pb = new PortBuilder();
    pb.setUuid(new Uuid("12345678-1234-1234-1234-123456789012"));
    pb.setNetworkId(new Uuid("12345678-1234-1234-1234-123456789012"));
    pb.setMacAddress(new MacAddress("AA:BB:CC:DD:EE:FF"));
    IpAddress ipv6 = new IpAddress(new Ipv6Address("1::1"));
    FixedIpsBuilder fib = new FixedIpsBuilder();
    fib.setIpAddress(ipv6);
    List<FixedIps> fixedIps = new ArrayList<>();
    fixedIps.add(fib.build());
    pb.setFixedIps(fixedIps);
    Port port = pb.build();
    neutronPortChangeListener.add(InstanceIdentifier.create(Port.class), port);
}
Also used : FixedIpsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIpsBuilder) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) PortBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.PortBuilder) Port(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port) ArrayList(java.util.ArrayList) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) FixedIps(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) Ipv6Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address) Test(org.junit.Test)

Example 18 with FixedIps

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps in project lispflowmapping by opendaylight.

the class PortDataProcessorTest method createTest.

/**
 * Tests {@link PortDataProcessor#create} method.
 */
@Test
public void createTest() throws ExecutionException, InterruptedException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
    portDataProcessor.create(portMock);
    List<FixedIps> fixedIps = portMock.getFixedIps();
    for (FixedIps ip : fixedIps) {
        Mockito.verify(hostInformationManager).addHostRelatedInfo(HOST_ID_1, getEid(portDataProcessor, portMock, ip));
    }
}
Also used : FixedIps(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps) Test(org.junit.Test)

Example 19 with FixedIps

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps in project lispflowmapping by opendaylight.

the class PortDataProcessor method update.

@Override
public void update(Port port) {
    final String hostId = port.getAugmentation(PortBindingExtension.class).getHostId();
    if (hostId == null) {
        LOG.error("Updating port to lisp mapping service failed. Port does not have a HostID. Port: {}", port.toString());
        return;
    }
    List<FixedIps> fixedIPs = port.getFixedIps();
    if (fixedIPs != null && fixedIPs.size() > 0) {
        Eid eidAddress;
        for (FixedIps ip : fixedIPs) {
            eidAddress = getEid(port, ip);
            PortData portData = new PortData(port.getUuid().getValue(), eidAddress);
            hostInformationManager.addHostRelatedInfo(hostId, portData);
        }
    }
    LOG.info("Neutron Port updated: Port name: " + port.getName() + " Port Fixed IP: " + (port.getFixedIps() != null ? port.getFixedIps().get(0) : "No Fixed IP assigned"));
    LOG.debug("Neutron Port Updated : " + port.toString());
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) PortData(org.opendaylight.lispflowmapping.neutron.mappingmanager.PortData) FixedIps(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps) PortBindingExtension(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.binding.rev150712.PortBindingExtension)

Example 20 with FixedIps

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps in project lispflowmapping by opendaylight.

the class PortDataProcessor method delete.

@Override
public void delete(Port port) {
    // TODO if port ips existed in MapServer, delete them. Else, log error.
    LOG.info("Neutron Port Deleted: Port name: " + port.getName() + " Port Fixed IP: " + (port.getFixedIps() != null ? port.getFixedIps().get(0) : "No Fixed IP assigned"));
    LOG.debug("Neutron Port Deleted : " + port.toString());
    List<FixedIps> fixedIPs = port.getFixedIps();
    if (fixedIPs != null && fixedIPs.size() > 0) {
        Eid eidAddress;
        for (FixedIps ip : fixedIPs) {
            // TODO Add check/support for IPv6.
            // Get subnet for this port, based on v4 or v6 decide address
            // iana code.
            eidAddress = LispAddressUtil.asIpv4PrefixEid(ip.getIpAddress().getIpv4Address().getValue() + "/32");
            lispNeutronService.getMappingDbService().removeMapping(LispUtil.buildRemoveMappingInput(eidAddress));
            LOG.info("Neutron Port mapping deleted from lisp: " + " Port Fixed IP: " + ip + "Port host IP: ");
        }
    }
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) FixedIps(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps)

Aggregations

FixedIps (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps)27 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)20 ArrayList (java.util.ArrayList)17 Port (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port)11 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)7 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)6 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)6 Subnetmap (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap)6 HashSet (java.util.HashSet)5 LearntVpnVipToPort (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.learnt.vpn.vip.to.port.data.LearntVpnVipToPort)5 BigInteger (java.math.BigInteger)4 Test (org.junit.Test)4 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)4 Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)4 ExecutionException (java.util.concurrent.ExecutionException)3 IpVersionChoice (org.opendaylight.netvirt.neutronvpn.api.enums.IpVersionChoice)3 PortBindingExtension (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.binding.rev150712.PortBindingExtension)3 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)2 Collections (java.util.Collections)2 List (java.util.List)2