Search in sources :

Example 1 with PortBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.PortBuilder in project netvirt by opendaylight.

the class NeutronUtils method writePortStatus.

private static boolean writePortStatus(String uuid, String portStatus, DataBroker dataBroker, boolean create) {
    Uuid uuidObj = new Uuid(uuid);
    PortBuilder portBuilder = new PortBuilder();
    portBuilder.setUuid(uuidObj);
    portBuilder.setStatus(portStatus);
    InstanceIdentifier iid = InstanceIdentifier.create(Neutron.class).child(Ports.class).child(Port.class, new PortKey(uuidObj));
    SingleTransactionDataBroker tx = new SingleTransactionDataBroker(dataBroker);
    try {
        if (create) {
            tx.syncWrite(LogicalDatastoreType.OPERATIONAL, iid, portBuilder.build());
        } else {
            tx.syncUpdate(LogicalDatastoreType.OPERATIONAL, iid, portBuilder.build());
        }
    } catch (TransactionCommitFailedException e) {
        LOG.error("writePortStatus: failed neutron port status write. isCreate: {}", create, e);
        return false;
    }
    return true;
}
Also used : 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) PortBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.PortBuilder) PortKey(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.PortKey) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) Ports(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.Ports) SingleTransactionDataBroker(org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker)

Example 2 with PortBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.PortBuilder 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 3 with PortBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.PortBuilder 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 4 with PortBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.PortBuilder in project openflowplugin by opendaylight.

the class MatchResponseConvertor2Test method testLayer4MatchSctp.

/**
 * Test {@link MatchResponseConvertor#convert(MatchEntriesGrouping, VersionDatapathIdConvertorData)}.
 */
@Test
public void testLayer4MatchSctp() {
    final MatchBuilder builder = new MatchBuilder();
    builder.setType(OxmMatchType.class);
    final List<MatchEntry> entries = new ArrayList<>();
    MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();
    entriesBuilder.setOxmClass(OpenflowBasicClass.class);
    entriesBuilder.setOxmMatchField(SctpSrc.class);
    entriesBuilder.setHasMask(false);
    final SctpSrcCaseBuilder sctpSrcCaseBuilder = new SctpSrcCaseBuilder();
    final SctpSrcBuilder portBuilder = new SctpSrcBuilder();
    portBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber(13));
    sctpSrcCaseBuilder.setSctpSrc(portBuilder.build());
    entriesBuilder.setMatchEntryValue(sctpSrcCaseBuilder.build());
    entries.add(entriesBuilder.build());
    entriesBuilder = new MatchEntryBuilder();
    entriesBuilder.setOxmClass(OpenflowBasicClass.class);
    entriesBuilder.setOxmMatchField(SctpDst.class);
    entriesBuilder.setHasMask(false);
    final SctpDstCaseBuilder sctpDstCaseBuilder = new SctpDstCaseBuilder();
    final SctpDstBuilder sctpDstBuilder = new SctpDstBuilder();
    sctpDstBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber(14));
    sctpDstCaseBuilder.setSctpDst(sctpDstBuilder.build());
    entriesBuilder.setMatchEntryValue(sctpDstCaseBuilder.build());
    entries.add(entriesBuilder.build());
    builder.setMatchEntry(entries);
    final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);
    datapathIdConvertorData.setDatapathId(new BigInteger("42"));
    final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder salMatchBuilder = convert(builder.build(), datapathIdConvertorData);
    final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatchBuilder.build();
    final SctpMatch udpMatch = (SctpMatch) builtMatch.getLayer4Match();
    Assert.assertEquals("Wrong sctp src port", 13, udpMatch.getSctpSourcePort().getValue().intValue());
    Assert.assertEquals("Wrong sctp dst port", 14, udpMatch.getSctpDestinationPort().getValue().intValue());
}
Also used : MatchEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry) VersionDatapathIdConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData) SctpDstBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.sctp.dst._case.SctpDstBuilder) ArrayList(java.util.ArrayList) SctpDstCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.SctpDstCaseBuilder) MatchEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder) SctpSrcBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.sctp.src._case.SctpSrcBuilder) SctpMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.SctpMatch) SctpSrcCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.SctpSrcCaseBuilder) BigInteger(java.math.BigInteger) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder) Test(org.junit.Test)

Example 5 with PortBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.PortBuilder in project openflowplugin by opendaylight.

the class SalPortServiceImplTest method dummyUpdatePortInput.

private UpdatePortInput dummyUpdatePortInput() {
    org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.PortBuilder concretePortBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.PortBuilder();
    concretePortBuilder.setConfiguration(new PortConfig(true, true, true, true));
    concretePortBuilder.setAdvertisedFeatures(new PortFeatures(true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true));
    concretePortBuilder.setPortNumber(new PortNumberUni(DUMMY_PORT_NUMBER));
    concretePortBuilder.setHardwareAddress(new MacAddress(DUMMY_MAC_ADDRESS));
    List<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.Port> ports = Lists.newArrayList(concretePortBuilder.build());
    Port port = new PortBuilder().setPort(ports).build();
    UpdatedPort updatePort = new UpdatedPortBuilder().setPort(port).build();
    return new UpdatePortInputBuilder().setUpdatedPort(updatePort).build();
}
Also used : PortNumberUni(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortNumberUni) UpdatedPort(org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.port.update.UpdatedPort) Port(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.Port) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) UpdatedPort(org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.port.update.UpdatedPort) PortBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.PortBuilder) UpdatedPortBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.port.update.UpdatedPortBuilder) PortFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortFeatures) UpdatePortInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.UpdatePortInputBuilder) UpdatedPortBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.port.update.UpdatedPortBuilder) PortConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortConfig)

Aggregations

Test (org.junit.Test)9 ArrayList (java.util.ArrayList)6 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)6 MatchEntryBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder)6 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)4 PortBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.PortBuilder)4 PortNumber (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber)4 BigInteger (java.math.BigInteger)3 VersionDatapathIdConvertorData (org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)3 PortNumberUni (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortNumberUni)3 PortBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.PortBuilder)3 FixedIps (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps)3 Port (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port)3 MatchEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry)3 MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder)3 MultipartRequestPortStatsCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortStatsCaseBuilder)3 MultipartRequestPortStatsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.port.stats._case.MultipartRequestPortStatsBuilder)3 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)2 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)2 SctpMatch (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.SctpMatch)2