yang model revise: neutron-ports.yang 39/35839/9
authorIsaku Yamahata <isaku.yamahata@intel.com>
Fri, 4 Mar 2016 06:34:16 +0000 (22:34 -0800)
committerIsaku Yamahata <isaku.yamahata@intel.com>
Fri, 10 Jun 2016 09:13:59 +0000 (02:13 -0700)
This patch revises yang model for neutron ports
- type string -> yang:mac-address
- type string -> ip-prefix-or-address
- drop binding-profile which is part of neutron-portbinding.yang
- key for fixed-ips (should be both subnet-id and ip-address)
- eliminate deprecated methods in spi

Change-Id: Idcefd0ab82a9b39ab8b1cdfb7fed92100f65001a
Signed-off-by: Isaku Yamahata <isaku.yamahata@intel.com>
Signed-off-by: Ritu Sood <ritu.sood@intel.com>
model/src/main/yang/neutron-ports.yang
neutron-spi/src/main/java/org/opendaylight/neutron/spi/INeutronPortCRUD.java
neutron-spi/src/main/java/org/opendaylight/neutron/spi/NeutronPort.java
transcriber/src/main/java/org/opendaylight/neutron/transcriber/NeutronPortInterface.java

index 4f8a6536553abd81d9a7cbcc05f09ef6f161cd7b..429eca3e9194a4ca6c1b8614a90a92191317e4fd 100644 (file)
@@ -18,6 +18,7 @@ module neutron-ports {
     import ietf-inet-types { prefix "inet"; revision-date 2010-09-24; }
     import neutron-attrs { prefix "attrs"; }
     import neutron-constants { prefix "constants"; }
+    import neutron-types { prefix "types"; }
 
     organization "OpenDaylight Neutron Group";
 
@@ -40,10 +41,10 @@ module neutron-ports {
                         is already allowed to pass through the port";
             key "mac-address ip-address";
             leaf mac-address {
-                type string;
+                type yang:mac-address;
             }
             leaf ip-address {
-                type string;
+                type types:ip-prefix-or-address;
             }
         }
 
@@ -70,14 +71,10 @@ module neutron-ports {
             type string;
         }
         leaf mac-address {
-            type string;
+            type yang:mac-address;
         }
-        leaf binding-profile {
-            type string;
-        }
-
         list fixed-ips {
-            key subnet-id;
+            key "subnet-id ip-address";
             leaf subnet-id {
                 type yang:uuid;
             }
index 3be4db8679b87c9efd57e941be3f8855c17f8b05..57376a9da55062ec44826049677edfd8b66532c3 100644 (file)
@@ -81,30 +81,4 @@ public interface INeutronPortCRUD
      */
 
     boolean updatePort(String uuid, NeutronPort delta);
-
-    /**
-     * Applications call this interface method to see if a MAC address is in use
-     *
-     * @param macAddress
-     *            mac Address to be tested
-     * @return boolean on whether the macAddress is already associated with a
-     * port or not
-     *
-     * @deprecated - will be removed in Boron
-     */
-
-    boolean macInUse(String macAddress);
-
-    /**
-     * Applications call this interface method to retrieve the port associated with
-     * the gateway address of a subnet
-     *
-     * @param subnetUUID
-     *            identifier of the subnet
-     * @return OpenStackPorts object if the port exists and null if it does not
-     *
-     * @deprecated - will be removed in Boron
-     */
-
-    NeutronPort getGatewayPort(String subnetUUID);
 }
index 435af783a9e07fdd99c9aeb71a573f74734915a7..b027606eb4835bd7c7a23cc20605bfcb56238903 100644 (file)
@@ -84,16 +84,6 @@ public class NeutronPort extends NeutronObject implements Serializable, INeutron
     public NeutronPort() {
     }
 
-    @Deprecated
-    public String getPortUUID() {
-        return getID();
-    }
-
-    @Deprecated
-    public void setPortUUID(String uuid) {
-        setID(uuid);
-    }
-
     public String getNetworkUUID() {
         return networkUUID;
     }
@@ -246,6 +236,9 @@ public class NeutronPort extends NeutronObject implements Serializable, INeutron
             if ("id".equals(field)) {
                 ans.setID(this.getID());
             }
+            if ("tenant_id".equals(field)) {
+                ans.setTenantID(this.getTenantID());
+            }
             if ("network_id".equals(field)) {
                 ans.setNetworkUUID(this.getNetworkUUID());
             }
@@ -270,12 +263,27 @@ public class NeutronPort extends NeutronObject implements Serializable, INeutron
             if ("device_owner".equals(field)) {
                 ans.setDeviceOwner(this.getDeviceOwner());
             }
-            if ("tenant_id".equals(field)) {
-                ans.setTenantID(this.getTenantID());
-            }
             if ("security_groups".equals(field)) {
                 ans.setSecurityGroups(new ArrayList<NeutronSecurityGroup>(this.getSecurityGroups()));
             }
+            if ("allowed_address_pairs".equals(field)) {
+                ans.setAllowedAddressPairs(new ArrayList<NeutronPort_AllowedAddressPairs>(this.getAllowedAddressPairs()));
+            }
+            if ("binding:host_id".equals(field)) {
+                ans.setBindinghostID(this.getBindinghostID());
+            }
+            if ("binding:vnic_type".equals(field)) {
+                ans.setBindingvnicType(this.getBindingvnicType());
+            }
+            if ("binding:vif_type".equals(field)) {
+                ans.setBindingvifType(this.getBindingvifType());
+            }
+            if ("binding:vif_details".equals(field)) {
+                ans.setVIFDetail(new ArrayList<NeutronPort_VIFDetail>(this.getVIFDetail()));
+            }
+            if ("extra_dhcp_opts".equals(field)) {
+                ans.setExtraDHCPOptions(new ArrayList<NeutronPort_ExtraDHCPOption>(this.getExtraDHCPOptions()));
+            }
             if ("port_security_enabled".equals(field)) {
                 ans.setPortSecurityEnabled(this.getPortSecurityEnabled());
             }
@@ -301,7 +309,11 @@ public class NeutronPort extends NeutronObject implements Serializable, INeutron
                 + ", adminStateUp=" + adminStateUp + ", status=" + status + ", macAddress=" + macAddress
                 + ", fixedIPs=" + fixedIPs + ", deviceID=" + deviceID + ", deviceOwner=" + deviceOwner + ", tenantID="
                 + tenantID + ", securityGroups=" + securityGroups
+                + ", allowedAddressPairs" + allowedAddressPairs
                 + ", bindinghostID=" + bindinghostID + ", bindingvnicType=" + bindingvnicType
-                + ", bindingvnicType=" + bindingvnicType + ", portSecurityEnabled=" + portSecurityEnabled +"]";
+                + ", bindingvifType=" + bindingvifType
+                + ", vifDetails=" + vifDetails
+                + ", extraDHCPOptions=" + extraDHCPOptions
+                + ", portSecurityEnabled=" + portSecurityEnabled +"]";
     }
 }
index 5a3f0e3a55774110e40a43b5fd6a7f8f107f4d93..09e9e80e4352da812c730f916a74b0fde160ab6e 100644 (file)
@@ -24,6 +24,7 @@ import org.opendaylight.neutron.spi.NeutronPort_VIFDetail;
 import org.opendaylight.neutron.spi.NeutronSecurityGroup;
 import org.opendaylight.neutron.spi.Neutron_IPs;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.binding.rev150712.binding.attributes.VifDetails;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.binding.rev150712.binding.attributes.VifDetailsBuilder;
@@ -44,6 +45,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.por
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.portsecurity.rev150712.PortSecurityExtension;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.portsecurity.rev150712.PortSecurityExtensionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.types.rev160517.IpPrefixOrAddress;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceRegistration;
@@ -103,18 +105,6 @@ public class NeutronPortInterface extends AbstractNeutronInterface<Port, Ports,
         return update(uuid, delta);
     }
 
-    // @deprecated, will be removed in Boron
-    @Override
-    public boolean macInUse(String macAddress) {
-        return false;
-    }
-
-    // @deprecated, will be removed in Boron
-    @Override
-    public NeutronPort getGatewayPort(String subnetUUID) {
-        return null;
-    }
-
     @Override
     protected InstanceIdentifier<Port> createInstanceIdentifier(Port port) {
         return InstanceIdentifier.create(Neutron.class)
@@ -159,8 +149,8 @@ public class NeutronPortInterface extends AbstractNeutronInterface<Port, Ports,
             final List<NeutronPort_AllowedAddressPairs> pairs = new ArrayList<NeutronPort_AllowedAddressPairs>();
             for (final AllowedAddressPairs mdPair : port.getAllowedAddressPairs()) {
                 final NeutronPort_AllowedAddressPairs pair = new NeutronPort_AllowedAddressPairs();
-                pair.setIpAddress(mdPair.getIpAddress());
-                pair.setMacAddress(mdPair.getMacAddress());
+                pair.setIpAddress(mdPair.getIpAddress().getValue().toString());
+                pair.setMacAddress(mdPair.getMacAddress().getValue());
                 pairs.add(pair);
             }
             result.setAllowedAddressPairs(pairs);
@@ -188,7 +178,7 @@ public class NeutronPortInterface extends AbstractNeutronInterface<Port, Ports,
             }
             result.setFixedIPs(ips);
         }
-        result.setMacAddress(port.getMacAddress());
+        result.setMacAddress(port.getMacAddress().getValue());
         result.setName(port.getName());
         result.setNetworkUUID(String.valueOf(port.getNetworkId().getValue()));
         if (port.getSecurityGroups() != null) {
@@ -253,8 +243,8 @@ public class NeutronPortInterface extends AbstractNeutronInterface<Port, Ports,
             final List<AllowedAddressPairs> listAllowedAddressPairs = new ArrayList<AllowedAddressPairs>();
             for (final NeutronPort_AllowedAddressPairs allowedAddressPairs : neutronPort.getAllowedAddressPairs()) {
                     final AllowedAddressPairsBuilder allowedAddressPairsBuilder = new AllowedAddressPairsBuilder();
-                    allowedAddressPairsBuilder.setIpAddress(allowedAddressPairs.getIpAddress());
-                    allowedAddressPairsBuilder.setMacAddress(allowedAddressPairs.getMacAddress());
+                    allowedAddressPairsBuilder.setIpAddress(new IpPrefixOrAddress(allowedAddressPairs.getIpAddress().toCharArray()));
+                    allowedAddressPairsBuilder.setMacAddress(new MacAddress(allowedAddressPairs.getMacAddress()));
                     listAllowedAddressPairs.add(allowedAddressPairsBuilder.build());
             }
             portBuilder.setAllowedAddressPairs(listAllowedAddressPairs);
@@ -292,7 +282,7 @@ public class NeutronPortInterface extends AbstractNeutronInterface<Port, Ports,
             portBuilder.setFixedIps(listNeutronIPs);
         }
         if (neutronPort.getMacAddress() != null) {
-            portBuilder.setMacAddress(neutronPort.getMacAddress());
+            portBuilder.setMacAddress(new MacAddress(neutronPort.getMacAddress()));
         }
         if (neutronPort.getName() != null) {
         portBuilder.setName(neutronPort.getName());