import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
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.ports.rev150712.port.attributes.FixedIps;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIpsBuilder;
.setDeviceOwner("compute:nova")
.setDeviceId("12345678-1234-1234-1234-123456789012")
.setUuid(uuid)
- .setMacAddress("00:00:01:02:03:04")
+ .setMacAddress(new MacAddress("00:00:01:02:03:04"))
.setFixedIps(ips)
.build());
}
assertNotNull("Could not find ineutronSecurityRuleCRUD Service", ineutronSecurityRuleCRUD);
NeutronSecurityGroup neutronSG = new NeutronSecurityGroup();
- neutronSG.setSecurityGroupDescription("testig defaultSG-IT");
neutronSG.setSecurityGroupName("DefaultSG");
- neutronSG.setSecurityGroupUUID("d3329053-bae5-4bf4-a2d1-7330f11ba5db");
+ neutronSG.setID("d3329053-bae5-4bf4-a2d1-7330f11ba5db");
neutronSG.setTenantID(tenantId);
List<NeutronSecurityRule> nsrs = new ArrayList<>();
nsrIN.setSecurityRuleGroupID("d3329053-bae5-4bf4-a2d1-7330f11ba5db");
nsrIN.setSecurityRuleProtocol("TCP");
nsrIN.setSecurityRuleRemoteIpPrefix("10.0.0.0/24");
- nsrIN.setSecurityRuleUUID("823faaf7-175d-4f01-a271-0bf56fb1e7e6");
+ nsrIN.setID("823faaf7-175d-4f01-a271-0bf56fb1e7e6");
nsrIN.setTenantID(tenantId);
NeutronSecurityRule nsrEG = new NeutronSecurityRule();
nsrEG.setSecurityRuleGroupID("d3329053-bae5-4bf4-a2d1-7330f11ba5db");
nsrEG.setSecurityRuleProtocol("TCP");
nsrEG.setSecurityRuleRemoteIpPrefix("10.0.0.0/24");
- nsrEG.setSecurityRuleUUID("823faaf7-175d-4f01-a271-0bf56fb1e7e1");
+ nsrEG.setID("823faaf7-175d-4f01-a271-0bf56fb1e7e1");
nsrEG.setTenantID(tenantId);
nsrs.add(nsrIN);
nsrs.add(nsrEG);
- neutronSG.setSecurityRules(nsrs);
ineutronSecurityRuleCRUD.addNeutronSecurityRule(nsrIN);
ineutronSecurityRuleCRUD.addNeutronSecurityRule(nsrEG);
ineutronSecurityGroupCRUD.add(neutronSG);
import org.opendaylight.netvirt.openstack.netvirt.translator.NeutronSecurityGroup;
import org.opendaylight.netvirt.openstack.netvirt.translator.NeutronSecurityRule;
import org.opendaylight.netvirt.openstack.netvirt.translator.Neutron_IPs;
+import org.opendaylight.netvirt.openstack.netvirt.translator.crud.INeutronSecurityRuleCRUD;
import org.opendaylight.netvirt.utils.mdsal.openflow.ActionUtils;
import org.opendaylight.netvirt.utils.mdsal.openflow.FlowUtils;
import org.opendaylight.netvirt.utils.mdsal.openflow.InstructionUtils;
import java.net.Inet6Address;
import java.net.InetAddress;
import java.net.UnknownHostException;
+import java.util.ArrayList;
import java.util.List;
import java.util.Map;
private static final Logger LOG = LoggerFactory.getLogger(EgressAclService.class);
private volatile SecurityServicesManager securityServicesManager;
private volatile SecurityGroupCacheManger securityGroupCacheManger;
+ private volatile INeutronSecurityRuleCRUD neutronSecurityRule;
private static final int DHCP_SOURCE_PORT = 67;
private static final int DHCP_DESTINATION_PORT = 68;
private static final int DHCPV6_SOURCE_PORT = 547;
NeutronSecurityGroup securityGroup, String portUuid, boolean write) {
LOG.trace("programPortSecurityGroup: neutronSecurityGroup: {} ", securityGroup);
- if (securityGroup == null || securityGroup.getSecurityRules() == null) {
+ if (securityGroup == null || getSecurityRulesforGroup(securityGroup) == null) {
return;
}
- List<NeutronSecurityRule> portSecurityList = securityGroup.getSecurityRules();
+ List<NeutronSecurityRule> portSecurityList = getSecurityRulesforGroup(securityGroup);
/* Iterate over the Port Security Rules in the Port Security Group bound to the port*/
for (NeutronSecurityRule portSecurityRule : portSecurityList) {
}
}
+ private List<NeutronSecurityRule> getSecurityRulesforGroup(NeutronSecurityGroup securityGroup) {
+ List<NeutronSecurityRule> securityRules = new ArrayList<>();
+ List<NeutronSecurityRule> rules = neutronSecurityRule.getAllNeutronSecurityRules();
+ for (NeutronSecurityRule securityRule : rules) {
+ if (securityGroup.getID().equals(securityRule.getSecurityRuleGroupID())) {
+ securityRules.add(securityRule);
+ }
+ }
+ return securityRules;
+ }
@Override
public void setDependencies(BundleContext bundleContext, ServiceReference serviceReference) {
(SecurityServicesManager) ServiceHelper.getGlobalInstance(SecurityServicesManager.class, this);
securityGroupCacheManger =
(SecurityGroupCacheManger) ServiceHelper.getGlobalInstance(SecurityGroupCacheManger.class, this);
+ neutronSecurityRule = (INeutronSecurityRuleCRUD) ServiceHelper.getGlobalInstance(INeutronSecurityRuleCRUD.class, this);
}
@Override
import org.opendaylight.netvirt.openstack.netvirt.translator.NeutronSecurityGroup;
import org.opendaylight.netvirt.openstack.netvirt.translator.NeutronSecurityRule;
import org.opendaylight.netvirt.openstack.netvirt.translator.Neutron_IPs;
+import org.opendaylight.netvirt.openstack.netvirt.translator.crud.INeutronSecurityRuleCRUD;
import org.opendaylight.netvirt.utils.mdsal.openflow.ActionUtils;
import org.opendaylight.netvirt.utils.mdsal.openflow.FlowUtils;
import org.opendaylight.netvirt.utils.mdsal.openflow.InstructionUtils;
import java.net.Inet6Address;
import java.net.InetAddress;
import java.net.UnknownHostException;
+import java.util.ArrayList;
import java.util.List;
import java.util.Map;
private static final Logger LOG = LoggerFactory.getLogger(IngressAclService.class);
private volatile SecurityServicesManager securityServicesManager;
private volatile SecurityGroupCacheManger securityGroupCacheManger;
+ private volatile INeutronSecurityRuleCRUD neutronSecurityRule;
private static final int PORT_RANGE_MIN = 1;
private static final int PORT_RANGE_MAX = 65535;
String portUuid, boolean write) {
LOG.trace("programPortSecurityGroup neutronSecurityGroup: {} ", securityGroup);
- if (securityGroup == null || securityGroup.getSecurityRules() == null) {
+ if (securityGroup == null || getSecurityRulesforGroup(securityGroup) == null) {
return;
}
- List<NeutronSecurityRule> portSecurityList = securityGroup.getSecurityRules();
+ List<NeutronSecurityRule> portSecurityList = getSecurityRulesforGroup(securityGroup);
/* Iterate over the Port Security Rules in the Port Security Group bound to the port*/
for (NeutronSecurityRule portSecurityRule : portSecurityList) {
}
}
+ private List<NeutronSecurityRule> getSecurityRulesforGroup(NeutronSecurityGroup securityGroup) {
+ List<NeutronSecurityRule> securityRules = new ArrayList<>();
+ List<NeutronSecurityRule> rules = neutronSecurityRule.getAllNeutronSecurityRules();
+ for (NeutronSecurityRule securityRule : rules) {
+ if (securityGroup.getID().equals(securityRule.getSecurityRuleGroupID())) {
+ securityRules.add(securityRule);
+ }
+ }
+ return securityRules;
+ }
+
@Override
public void setDependencies(BundleContext bundleContext, ServiceReference serviceReference) {
super.setDependencies(bundleContext.getServiceReference(IngressAclProvider.class.getName()), this);
(SecurityServicesManager) ServiceHelper.getGlobalInstance(SecurityServicesManager.class, this);
securityGroupCacheManger =
(SecurityGroupCacheManger) ServiceHelper.getGlobalInstance(SecurityGroupCacheManger.class, this);
+ neutronSecurityRule = (INeutronSecurityRuleCRUD) ServiceHelper.getGlobalInstance(INeutronSecurityRuleCRUD.class, this);
}
@Override
import org.opendaylight.netvirt.openstack.netvirt.api.SecurityGroupCacheManger;
import org.opendaylight.netvirt.openstack.netvirt.api.SecurityServicesManager;
import org.opendaylight.netvirt.openstack.netvirt.providers.openflow13.PipelineOrchestrator;
+import org.opendaylight.netvirt.openstack.netvirt.translator.crud.INeutronSecurityRuleCRUD;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder;
@Mock private NeutronSecurityRule portSecurityRule;
@Mock private NeutronSecurityGroup securityGroupIpv6;
@Mock private NeutronSecurityRule portSecurityIpv6Rule;
+ @Mock private INeutronSecurityRuleCRUD neutronSecurityRuleCache;
@Mock private SecurityServicesManager securityServices;
@Mock private SecurityGroupCacheManger securityGroupCacheManger;
List<NeutronSecurityRule> portSecurityIpv6List = new ArrayList<>();
portSecurityIpv6List.add(portSecurityIpv6Rule);
- when(securityGroupIpv6.getSecurityRules()).thenReturn(portSecurityIpv6List);
+ when(neutronSecurityRuleCache.getAllNeutronSecurityRules()).thenReturn(portSecurityIpv6List);
neutron_ipv6_dest_1 = new Neutron_IPs();
neutron_ipv6_dest_1.setIpAddress(IPV6_DEST_IP_1);
neutron_ipv6_dest_2.setIpAddress(IPV6_DEST_IP_2);
neutronDestIpList.add(neutron_ipv6_dest_2);
- when(securityGroup.getSecurityRules()).thenReturn(portSecurityList);
+ when(neutronSecurityRuleCache.getAllNeutronSecurityRules()).thenReturn(portSecurityList);
when(securityServices.getVmListForSecurityGroup(PORT_UUID, SECURITY_GROUP_UUID)).thenReturn(neutronDestIpList);
NetvirtProvidersProvider netvirtProvider = mock(NetvirtProvidersProvider.class);
portSecurityList.add(portSecurityRule4);
NeutronSecurityGroup localSecurityGroup = mock(NeutronSecurityGroup.class);
- when(localSecurityGroup.getSecurityRules()).thenReturn(portSecurityList);
+ when(neutronSecurityRuleCache.getAllNeutronSecurityRules()).thenReturn(portSecurityList);
egressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT,
localSecurityGroup, PORT_UUID, true);
import org.opendaylight.netvirt.openstack.netvirt.translator.NeutronSecurityRule;
import org.opendaylight.netvirt.openstack.netvirt.translator.Neutron_IPs;
import org.opendaylight.netvirt.openstack.netvirt.api.SecurityGroupCacheManger;
+import org.opendaylight.netvirt.openstack.netvirt.translator.crud.INeutronSecurityRuleCRUD;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder;
@Mock private NeutronSecurityRule portSecurityIpv6Rule;
@Mock private SecurityServicesManager securityServices;
@Mock private SecurityGroupCacheManger securityGroupCacheManger;
+ @Mock private INeutronSecurityRuleCRUD neutronSecurityRuleCache;
private List<Neutron_IPs> neutronSrcIpList = new ArrayList<>();
private List<Neutron_IPs> neutronDestIpList = new ArrayList<>();
List<NeutronSecurityRule> portSecurityIpv6List = new ArrayList<>();
portSecurityIpv6List.add(portSecurityIpv6Rule);
- when(securityGroupIpv6.getSecurityRules()).thenReturn(portSecurityIpv6List);
+ when(neutronSecurityRuleCache.getAllNeutronSecurityRules()).thenReturn(portSecurityIpv6List);
neutron_ipv6_dest_1 = new Neutron_IPs();
neutron_ipv6_dest_1.setIpAddress(IPV6_DEST_IP_1);
neutron_ipv6_dest_2.setIpAddress(IPV6_DEST_IP_2);
neutronDestIpList.add(neutron_ipv6_dest_2);
- when(securityGroup.getSecurityRules()).thenReturn(portSecurityList);
+ when(neutronSecurityRuleCache.getAllNeutronSecurityRules()).thenReturn(portSecurityList);
when(securityServices.getVmListForSecurityGroup
(PORT_UUID, SECURITY_GROUP_UUID)).thenReturn(neutronDestIpList);
NetvirtProvidersProvider netvirtProvider = mock(NetvirtProvidersProvider.class);
portSecurityList.add(portSecurityRule4);
NeutronSecurityGroup localSecurityGroup = mock(NeutronSecurityGroup.class);
- when(localSecurityGroup.getSecurityRules()).thenReturn(portSecurityList);
+ when(neutronSecurityRuleCache.getAllNeutronSecurityRules()).thenReturn(portSecurityList);
ingressAclServiceSpy.programPortSecurityGroup(
Long.valueOf(1554), "2", MAC_ADDRESS, 124, localSecurityGroup, PORT_UUID, false);
<Embed-Transitive>true</Embed-Transitive>
<Export-Package>
org.opendaylight.netvirt.openstack.netvirt.translator,
+ org.opendaylight.netvirt.openstack.netvirt.translator.crud,
org.opendaylight.netvirt.openstack.netvirt.api,
org.opendaylight.netvirt.openstack.netvirt
</Export-Package>
port.getDeviceOwner().equals(OWNER_ROUTER_INTERFACE)) {
LOG.debug("L3 Cache Population : Router interface {} found.",port);
networkIdToRouterMacCache.put(port.getNetworkId().getValue()
- , port.getMacAddress());
+ , port.getMacAddress().getValue());
networkIdToRouterIpListCache.put(port.getNetworkId().getValue(),
NeutronIAwareUtil.convertMDSalIpToNeutronIp(port.getFixedIps()));
import org.opendaylight.netvirt.openstack.netvirt.translator.NeutronSecurityGroup;
import org.opendaylight.netvirt.openstack.netvirt.translator.NeutronSecurityRule;
import org.opendaylight.netvirt.openstack.netvirt.translator.Neutron_IPs;
+import org.opendaylight.netvirt.openstack.netvirt.translator.crud.INeutronSecurityRuleCRUD;
+import org.opendaylight.netvirt.utils.neutron.utils.NeutronUtils;
import org.opendaylight.netvirt.utils.servicehelper.ServiceHelper;
import org.osgi.framework.ServiceReference;
import org.slf4j.Logger;
private volatile SecurityServicesManager securityServicesManager;
private volatile INeutronPortCRUD neutronPortCache;
private volatile NeutronL3Adapter neutronL3Adapter;
+ private volatile INeutronSecurityRuleCRUD neutronSecurityRule;
@Override
public void portAdded(String securityGroupUuid, String portUuid) {
List<NeutronSecurityRule> remoteSecurityRules = new ArrayList<>();
List<NeutronSecurityGroup> securityGroups = port.getSecurityGroups();
for (NeutronSecurityGroup securityGroup : securityGroups) {
- List<NeutronSecurityRule> securityRules = securityGroup.getSecurityRules();
+ List<NeutronSecurityRule> securityRules = getSecurityRulesforGroup(securityGroup);
for (NeutronSecurityRule securityRule : securityRules) {
if (securityGroupUuid.equals(securityRule.getSecurityRemoteGroupID())) {
remoteSecurityRules.add(securityRule);
List<NeutronSecurityGroup> securityGroupList = port.getSecurityGroups();
if ( null != securityGroupList) {
for (NeutronSecurityGroup securityGroup : securityGroupList) {
- List<NeutronSecurityRule> securityRuleList = securityGroup.getSecurityRules();
+ List<NeutronSecurityRule> securityRuleList = getSecurityRulesforGroup(securityGroup);
if ( null != securityRuleList) {
for (NeutronSecurityRule securityRule : securityRuleList) {
if (null != securityRule.getSecurityRemoteGroupID()) {
}
}
+ private List<NeutronSecurityRule> getSecurityRulesforGroup(NeutronSecurityGroup securityGroup) {
+ List<NeutronSecurityRule> securityRules = new ArrayList<>();
+ List<NeutronSecurityRule> rules = neutronSecurityRule.getAllNeutronSecurityRules();
+ for (NeutronSecurityRule securityRule : rules) {
+ if (securityGroup.getID().equals(securityRule.getSecurityRuleGroupID())) {
+ securityRules.add(securityRule);
+ }
+ }
+ return securityRules;
+ }
+
@Override
public void setDependencies(ServiceReference serviceReference) {
neutronL3Adapter =
securityServicesManager =
(SecurityServicesManager) ServiceHelper.getGlobalInstance(SecurityServicesManager.class, this);
neutronPortCache = (INeutronPortCRUD) ServiceHelper.getGlobalInstance(INeutronPortCRUD.class, this);
+ neutronSecurityRule = (INeutronSecurityRuleCRUD) ServiceHelper.getGlobalInstance(INeutronSecurityRuleCRUD.class, this);
init();
}
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
//@XmlElement (name = "binding:vif_details")
@XmlElement (namespace = "binding", name = "vif_details")
- List<NeutronPort_VIFDetail> vifDetails;
+ Map<String, String> vifDetails;
@XmlElement (name = "extra_dhcp_opts")
List<NeutronPort_ExtraDHCPOption> extraDHCPOptions;
public Boolean getAdminStateUp() { return adminStateUp; }
public void setAdminStateUp(Boolean newValue) {
- adminStateUp = newValue;
+ adminStateUp = newValue;
}
public String getStatus() {
this.extraDHCPOptions = extraDHCPOptions;
}
- public List<NeutronPort_VIFDetail> getVIFDetail() {
+ public Map<String, String> getVIFDetails() {
return vifDetails;
}
- public void setVIFDetail(List<NeutronPort_VIFDetail> vifDetails) {
+ public void setVIFDetails(Map<String, String> vifDetails) {
this.vifDetails = vifDetails;
}
public String getBindinghostID() {
- return bindinghostID;
+ return bindinghostID;
}
public void setBindinghostID(String bindinghostID) {
- this.bindinghostID = bindinghostID;
+ this.bindinghostID = bindinghostID;
}
public String getBindingvnicType() {
@XmlElement (name = "routes")
List<Routes> routes;
- /* Holds a map of OpenStackRouterInterfaces by subnet UUID
- * used for internal mapping to DOVE
- */
- Map<String, NeutronRouter_Interface> interfaces;
-
- public NeutronRouter() {
- interfaces = new HashMap<>();
- }
-
public String getID() { return routerUUID; }
public void setID(String id) { this.routerUUID = id; }
return ans;
}
- public void setInterfaces(Map<String, NeutronRouter_Interface> input) {
- interfaces = input;
- }
-
- public Map<String, NeutronRouter_Interface> getInterfaces() {
- return interfaces;
- }
-
- public void addInterface(String s, NeutronRouter_Interface i) {
- interfaces.put(s, i);
- }
-
- public void removeInterface(String s) {
- interfaces.remove(s);
- }
-
public void initDefaults() {
adminStateUp = true;
}
", distributed=" + distributed +
", gw_port_id=" + gatewayPortId +
", routes=" + routes +
- ", interfaces=" + interfaces +
"]";
}
-
}
* name String name of the security group.
* description String name of the security group.
* tenant_id uuid-str Owner of security rule..
- * security_group_rules List<NeutronSecurityRule> nested RO in the sec group.
*/
@XmlRootElement
@XmlElement(name = "tenant_id")
String securityGroupTenantID;
- @XmlElement(name = "security_group_rules")
- List<NeutronSecurityRule> neutronSecurityRule;
-
public NeutronSecurityGroup() {
- neutronSecurityRule = new ArrayList<>();
-
}
public String getID() {
this.securityGroupTenantID = securityGroupTenantID;
}
- // Rules In Group
- public List<NeutronSecurityRule> getSecurityRules() {
- return neutronSecurityRule;
- }
-
- public void setSecurityRules(List<NeutronSecurityRule> neutronSecurityRule) {
- this.neutronSecurityRule = neutronSecurityRule;
- }
-
public NeutronSecurityGroup extractFields(List<String> fields) {
NeutronSecurityGroup ans = new NeutronSecurityGroup ();
for (String s : fields) {
case "tenant_id":
ans.setSecurityGroupTenantID(this.getSecurityGroupTenantID());
break;
- case "security_group_rules":
- ans.setSecurityRules(this.getSecurityRules());
- break;
}
}
return ans;
", securityGroupName='" + securityGroupName + '\'' +
", securityGroupDescription='" + securityGroupDescription + '\'' +
", securityGroupTenantID='" + securityGroupTenantID + '\'' +
- ", securityRules=" + neutronSecurityRule + "]";
+ "]";
}
public void initDefaults() {
protected Loadbalancer toMd(NeutronLoadBalancer loadBalancer) {
LoadbalancerBuilder loadBalancersBuilder = new LoadbalancerBuilder();
loadBalancersBuilder.setAdminStateUp(loadBalancer.getLoadBalancerAdminStateUp());
- if (loadBalancer.getLoadBalancerDescription() != null) {
- loadBalancersBuilder.setDescr(loadBalancer.getLoadBalancerDescription());
- }
if (loadBalancer.getLoadBalancerName() != null) {
loadBalancersBuilder.setName(loadBalancer.getLoadBalancerName());
}
protected Pool toMd(NeutronLoadBalancerPool pool) {
PoolBuilder poolBuilder = new PoolBuilder();
poolBuilder.setAdminStateUp(pool.getLoadBalancerPoolAdminIsStateIsUp());
- if (pool.getLoadBalancerPoolDescription() != null) {
- poolBuilder.setDescr(pool.getLoadBalancerPoolDescription());
- }
if (pool.getNeutronLoadBalancerPoolHealthMonitorID() != null) {
poolBuilder.setHealthmonitorId(toUuid(pool.getNeutronLoadBalancerPoolHealthMonitorID()));
}
package org.opendaylight.netvirt.openstack.netvirt.translator.crud.impl;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
import org.opendaylight.netvirt.openstack.netvirt.translator.NeutronSecurityGroup;
import org.opendaylight.netvirt.openstack.netvirt.translator.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.PortBindingExtension;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.binding.rev150712.PortBindingExtensionBuilder;
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;
PortBindingExtension binding = port.getAugmentation(PortBindingExtension.class);
result.setBindinghostID(binding.getHostId());
if (binding.getVifDetails() != null) {
- List<NeutronPort_VIFDetail> details = new ArrayList<>();
- for (VifDetails vifDetail : binding.getVifDetails()) {
- NeutronPort_VIFDetail detail = new NeutronPort_VIFDetail();
- detail.setPortFilter(vifDetail.isPortFilter());
- detail.setOvsHybridPlug(vifDetail.isOvsHybridPlug());
- details.add(detail);
+ final Map<String, String> details = new HashMap<String, String>(binding.getVifDetails().size());
+ for (final VifDetails vifDetail : binding.getVifDetails()) {
+ details.put(vifDetail.getDetailsKey(), vifDetail.getValue());
}
- result.setVIFDetail(details);
+ result.setVIFDetails(details);
}
result.setBindingvifType(binding.getVifType());
result.setBindingvnicType(binding.getVnicType());
List<NeutronPort_AllowedAddressPairs> pairs = new ArrayList<>();
for (AllowedAddressPairs mdPair : port.getAllowedAddressPairs()) {
NeutronPort_AllowedAddressPairs pair = new NeutronPort_AllowedAddressPairs();
- pair.setIpAddress(mdPair.getIpAddress());
- pair.setMacAddress(mdPair.getMacAddress());
+ pair.setIpAddress(String.valueOf(mdPair.getIpAddress().getValue()));
+ pair.setMacAddress(mdPair.getMacAddress().getValue());
pairs.add(pair);
}
result.setAllowedAddressPairs(pairs);
}
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) {
if (neutronPort.getBindinghostID() != null) {
bindingBuilder.setHostId(neutronPort.getBindinghostID());
}
- if (neutronPort.getVIFDetail() != null) {
- List<VifDetails> listVifDetail = new ArrayList<>();
- for (NeutronPort_VIFDetail detail: neutronPort.getVIFDetail()) {
- VifDetailsBuilder vifDetailsBuilder = new VifDetailsBuilder();
- if (detail.getPortFilter() != null) {
- vifDetailsBuilder.setPortFilter(detail.getPortFilter());
+ if (neutronPort.getVIFDetails() != null) {
+ final Map<String, String> vifDetails = neutronPort.getVIFDetails();
+ final List<VifDetails> listVifDetail = new ArrayList<VifDetails>(vifDetails.size());
+ for (final Map.Entry<String, String> vifDetail : vifDetails.entrySet()) {
+ final VifDetailsBuilder vifDetailsBuilder = new VifDetailsBuilder();
+ if (vifDetail.getKey() != null) {
+ vifDetailsBuilder.setDetailsKey(vifDetail.getKey());
}
- if (detail.getOvsHybridPlug() != null) {
- vifDetailsBuilder.setOvsHybridPlug(detail.getOvsHybridPlug());
+ if (vifDetail.getValue() != null) {
+ vifDetailsBuilder.setValue(vifDetail.getValue());
}
listVifDetail.add(vifDetailsBuilder.build());
}
List<AllowedAddressPairs> listAllowedAddressPairs = new ArrayList<>();
for (NeutronPort_AllowedAddressPairs allowedAddressPairs : neutronPort.getAllowedAddressPairs()) {
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);
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());
import java.util.Set;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
-import org.opendaylight.netvirt.openstack.netvirt.translator.NeutronRouter_Interface;
import org.opendaylight.netvirt.openstack.netvirt.translator.crud.INeutronRouterCRUD;
import org.opendaylight.netvirt.openstack.netvirt.translator.NeutronRouter;
import org.opendaylight.netvirt.openstack.netvirt.translator.NeutronRouter_NetworkReference;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.RouterBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.router.ExternalGatewayInfo;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.router.ExternalGatewayInfoBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.router.Interfaces;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.router.external_gateway_info.ExternalFixedIps;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.router.external_gateway_info.ExternalFixedIpsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron;
@Override
public boolean routerInUse(String routerUUID) {
- if (!routerExists(routerUUID)) {
- return true;
- }
- NeutronRouter target = getRouter(routerUUID);
- return (target.getInterfaces().size() > 0);
+ return !routerExists(routerUUID);
}
@Override
}
routerBuilder.setExternalGatewayInfo(externalGatewayInfo);
}
- if (router.getInterfaces() != null) {
- Map<String, NeutronRouter_Interface> mapInterfaces = new HashMap<>();
- List<Interfaces> interfaces = new ArrayList<>();
- for (Entry<String, NeutronRouter_Interface> entry : mapInterfaces.entrySet()) {
- interfaces.add((Interfaces) entry.getValue());
- }
- routerBuilder.setInterfaces(interfaces);
- }
if (router.getID() != null) {
routerBuilder.setUuid(toUuid(router.getID()));
} else {
result.setExternalGatewayInfo(extGwInfo);
}
- if (router.getInterfaces() != null) {
- Map<String, NeutronRouter_Interface> interfaces = new HashMap<>();
- for (Interfaces mdInterface : router.getInterfaces()) {
- NeutronRouter_Interface pojoInterface = new NeutronRouter_Interface();
- String id = String.valueOf(mdInterface.getUuid().getValue());
- pojoInterface.setID(id);
- pojoInterface.setTenantID(String.valueOf(mdInterface.getTenantId().getValue()));
- pojoInterface.setSubnetUUID(String.valueOf(mdInterface.getSubnetId().getValue()));
- pojoInterface.setPortUUID(String.valueOf(mdInterface.getPortId().getValue()));
- interfaces.put(id, pojoInterface);
- }
- result.setInterfaces(interfaces);
- }
return result;
}
if (group.getName() != null) {
answer.setSecurityGroupName(group.getName());
}
- if (group.getDescription() != null) {
- answer.setSecurityGroupDescription(group.getDescription());
- }
if (group.getTenantId() != null) {
answer.setSecurityGroupTenantID(group.getTenantId().getValue().replace("-",""));
}
-
- // Bug 4550
- // https://bugs.opendaylight.org/show_bug.cgi?id=4550
- // Now SecurityGroup::securityGroupRule isn't updated.
- // always rebuid it from security group rules
- NeutronCRUDInterfaces interfaces = new NeutronCRUDInterfaces()
- .fetchINeutronSecurityRuleCRUD(this);
- INeutronSecurityRuleCRUD srCrud = interfaces.getSecurityRuleInterface();
-
- List<NeutronSecurityRule> rules = new ArrayList<>();
- String sgId = group.getUuid().getValue();
- for (NeutronSecurityRule rule: srCrud.getAllNeutronSecurityRules()) {
- if (rule.getSecurityRuleGroupID().equals(sgId)) {
- rules.add(rule);
- }
- }
- answer.setSecurityRules(rules);
-
if (group.getUuid() != null) {
answer.setID(group.getUuid().getValue());
}
if (securityGroup.getSecurityGroupName() != null) {
securityGroupBuilder.setName(securityGroup.getSecurityGroupName());
}
- if (securityGroup.getSecurityGroupDescription() != null) {
- securityGroupBuilder.setDescription(securityGroup.getSecurityGroupDescription());
- }
if (securityGroup.getSecurityGroupTenantID() != null) {
securityGroupBuilder.setTenantId(toUuid(securityGroup.getSecurityGroupTenantID()));
}
-
- // don't update security group rule, always empty list
- // Bug 4550
- // https://bugs.opendaylight.org/show_bug.cgi?id=4550
- securityGroupBuilder.setSecurityRules(new ArrayList<>());
-
if (securityGroup.getID() != null) {
securityGroupBuilder.setUuid(toUuid(securityGroup.getID()));
} else {
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.ProtocolIcmpV6;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.ProtocolTcp;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.ProtocolUdp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.NeutronUtils;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.secgroups.rev150712.SecurityRuleAttributes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.secgroups.rev150712.security.rules.attributes.SecurityRules;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.secgroups.rev150712.security.rules.attributes.security.rules.SecurityRule;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.secgroups.rev150712.security.rules.attributes.security.rules.SecurityRuleBuilder;
super(providerContext);
}
- private void updateSecGroupRuleInSecurityGroup(NeutronSecurityRule input) {
- NeutronCRUDInterfaces interfaces = new NeutronCRUDInterfaces()
- .fetchINeutronSecurityGroupCRUD(this);
- INeutronSecurityGroupCRUD sgCrud = interfaces.getSecurityGroupInterface();
- NeutronSecurityGroup sg = sgCrud.getNeutronSecurityGroup(input.getSecurityRuleGroupID());
- if(sg != null && sg.getSecurityRules() != null) {
- for(NeutronSecurityRule sgr :sg.getSecurityRules()) {
- if(sgr != null && sgr.getID() != null && sgr.getID().equals(input.getID())) {
- int index = sg.getSecurityRules().indexOf(sgr);
- sg.getSecurityRules().set(index, input);
- }
- }
- }
- if (sg != null) {
- sg.getSecurityRules().add(input);
- }
- }
-
- private void removeSecGroupRuleFromSecurityGroup(NeutronSecurityRule input) {
- NeutronCRUDInterfaces interfaces = new NeutronCRUDInterfaces()
- .fetchINeutronSecurityGroupCRUD(this);
- INeutronSecurityGroupCRUD sgCrud = interfaces.getSecurityGroupInterface();
- NeutronSecurityGroup sg = sgCrud.getNeutronSecurityGroup(input.getSecurityRuleGroupID());
- if(sg != null && sg.getSecurityRules() != null) {
- List<NeutronSecurityRule> toRemove = new ArrayList<>();
- for(NeutronSecurityRule sgr :sg.getSecurityRules()) {
- if(sgr.getID() != null && sgr.getID().equals(input.getID())) {
- toRemove.add(sgr);
- }
- }
- sg.getSecurityRules().removeAll(toRemove);
- }
- }
-
@Override
public boolean neutronSecurityRuleExists(String uuid) {
SecurityRule rule = readMd(createInstanceIdentifier(toMd(uuid)));
if (neutronSecurityRuleExists(input.getID())) {
return false;
}
- updateSecGroupRuleInSecurityGroup(input);
addMd(input);
return true;
}
if (!neutronSecurityRuleExists(uuid)) {
return false;
}
- removeSecGroupRuleFromSecurityGroup(getNeutronSecurityRule(uuid));
removeMd(toMd(uuid));
return true;
}
if (!neutronSecurityRuleExists(uuid)) {
return false;
}
- updateSecGroupRuleInSecurityGroup(delta);
updateMd(delta);
return true;
}
rule.getRemoteIpPrefix().getIpv4Prefix().getValue():rule.getRemoteIpPrefix().getIpv6Prefix().getValue());
}
if (rule.getProtocol() != null) {
- answer.setSecurityRuleProtocol(PROTOCOL_MAP.get(rule.getProtocol()));
+ SecurityRuleAttributes.Protocol protocol = rule.getProtocol();
+ if (protocol.getUint8() != null) {
+ // uint8
+ answer.setSecurityRuleProtocol(protocol.getUint8().toString());
+ } else {
+ // symbolic protocol name
+ answer.setSecurityRuleProtocol(NeutronUtils.ProtocolMapper.getName(protocol.getIdentityref()));
+ }
}
if (rule.getEthertype() != null) {
answer.setSecurityRuleEthertype(ETHERTYPE_MAP.get(rule.getEthertype()));
if (rule.getPortRangeMax() != null) {
answer.setSecurityRulePortMax(rule.getPortRangeMax());
}
- if (rule.getId() != null) {
- answer.setID(rule.getId().getValue());
+ if (rule.getUuid() != null) {
+ answer.setID(rule.getUuid().getValue());
}
return answer;
}
securityRuleBuilder.setRemoteIpPrefix(new IpPrefix(securityRule.getSecurityRuleRemoteIpPrefix().toCharArray()));
}
if (securityRule.getSecurityRuleProtocol() != null) {
- ImmutableBiMap<String, Class<? extends ProtocolBase>> mapper =
- PROTOCOL_MAP.inverse();
- securityRuleBuilder.setProtocol(mapper.get(securityRule.getSecurityRuleProtocol()));
+ String protocolString = securityRule.getSecurityRuleProtocol();
+ SecurityRuleAttributes.Protocol protocol = new SecurityRuleAttributes.Protocol(protocolString.toCharArray());
+ securityRuleBuilder.setProtocol(protocol);
}
if (securityRule.getSecurityRuleEthertype() != null) {
ImmutableBiMap<String, Class<? extends EthertypeBase>> mapper =
securityRuleBuilder.setPortRangeMax(securityRule.getSecurityRulePortMax());
}
if (securityRule.getID() != null) {
- securityRuleBuilder.setId(toUuid(securityRule.getID()));
+ securityRuleBuilder.setUuid(toUuid(securityRule.getID()));
} else {
LOGGER.warn("Attempting to write neutron securityRule without UUID");
}
@Override
protected SecurityRule toMd(String uuid) {
SecurityRuleBuilder securityRuleBuilder = new SecurityRuleBuilder();
- securityRuleBuilder.setId(toUuid(uuid));
+ securityRuleBuilder.setUuid(toUuid(uuid));
return securityRuleBuilder.build();
}
import org.opendaylight.netvirt.openstack.netvirt.translator.crud.INeutronSubnetCRUD;
import org.opendaylight.netvirt.openstack.netvirt.translator.crud.NeutronCRUDInterfaces;
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.inet.types.rev100924.IpPrefix;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.Dhcpv6Base;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.Dhcpv6Off;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.Dhcpv6Slaac;
result.setTenantID(String.valueOf(subnet.getTenantId().getValue()).replace("-",""));
result.setNetworkUUID(subnet.getNetworkId().getValue());
result.setIpVersion(IPV_MAP.get(subnet.getIpVersion()));
- result.setCidr(subnet.getCidr());
+ result.setCidr(String.valueOf(subnet.getCidr().getValue()));
result.setIpV6RaMode(DHCPV6_MAP.get(subnet.getIpv6RaMode()));
result.setIpV6AddressMode(DHCPV6_MAP.get(subnet.getIpv6AddressMode()));
result.setEnableDHCP(subnet.isEnableDhcp());
List<NeutronSubnetIPAllocationPool> allocationPools = new ArrayList<>();
for (AllocationPools allocationPool : subnet.getAllocationPools()) {
NeutronSubnetIPAllocationPool pool = new NeutronSubnetIPAllocationPool();
- pool.setPoolStart(allocationPool.getStart());
- pool.setPoolEnd(allocationPool.getEnd());
+ pool.setPoolStart(String.valueOf(allocationPool.getStart().getValue()));
+ pool.setPoolEnd(String.valueOf(allocationPool.getEnd().getValue()));
allocationPools.add(pool);
}
result.setAllocationPools(allocationPools);
.getIpVersion()));
}
if (subnet.getCidr() != null) {
- subnetBuilder.setCidr(subnet.getCidr());
+ IpPrefix ipPrefix = new IpPrefix(subnet.getCidr().toCharArray());
+ subnetBuilder.setCidr(ipPrefix);
}
if (subnet.getGatewayIP() != null) {
IpAddress ipAddress = new IpAddress(subnet.getGatewayIP()
for (NeutronSubnetIPAllocationPool allocationPool : subnet
.getAllocationPools()) {
AllocationPoolsBuilder builder = new AllocationPoolsBuilder();
- builder.setStart(allocationPool.getPoolStart());
- builder.setEnd(allocationPool.getPoolEnd());
+ builder.setStart(new IpAddress(allocationPool.getPoolStart().toCharArray()));
+ builder.setEnd(new IpAddress(allocationPool.getPoolEnd().toCharArray()));
AllocationPools temp = builder.build();
allocationPools.add(temp);
}
if (pool.getName() != null) {
result.setLoadBalancerPoolName(pool.getName());
}
- if (pool.getDescr() != null) {
- result.setLoadBalancerPoolDescription(pool.getDescr());
- }
if (pool.getProtocol() != null) {
result.setLoadBalancerPoolProtocol(PROTOCOL_MAP.get(pool.getProtocol()));
}
List<NeutronPort_AllowedAddressPairs> pairs = new ArrayList<>();
for (AllowedAddressPairs mdPair : port.getAllowedAddressPairs()) {
NeutronPort_AllowedAddressPairs pair = new NeutronPort_AllowedAddressPairs();
- pair.setIpAddress(mdPair.getIpAddress());
- pair.setMacAddress(mdPair.getMacAddress());
+ pair.setIpAddress(String.valueOf(mdPair.getIpAddress().getValue()));
+ pair.setMacAddress(mdPair.getMacAddress().getValue());
pairs.add(pair);
}
result.setAllowedAddressPairs(pairs);
}
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) {
PortBindingExtension binding = port.getAugmentation(PortBindingExtension.class);
result.setBindinghostID(binding.getHostId());
if (binding.getVifDetails() != null) {
- List<NeutronPort_VIFDetail> details = new ArrayList<>();
- for (VifDetails vifDetail : binding.getVifDetails()) {
- NeutronPort_VIFDetail detail = new NeutronPort_VIFDetail();
- detail.setPortFilter(vifDetail.isPortFilter());
- detail.setOvsHybridPlug(vifDetail.isOvsHybridPlug());
- details.add(detail);
+ final Map<String, String> details = new HashMap<String, String>(binding.getVifDetails().size());
+ for (final VifDetails vifDetail : binding.getVifDetails()) {
+ details.put(vifDetail.getDetailsKey(), vifDetail.getValue());
}
- result.setVIFDetail(details);
+ result.setVIFDetails(details);
}
result.setBindingvifType(binding.getVifType());
result.setBindingvnicType(binding.getVnicType());
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.netvirt.openstack.netvirt.translator.NeutronRouter;
-import org.opendaylight.netvirt.openstack.netvirt.translator.NeutronRouter_Interface;
import org.opendaylight.netvirt.openstack.netvirt.translator.NeutronRouter_NetworkReference;
import org.opendaylight.netvirt.openstack.netvirt.translator.Neutron_IPs;
import org.opendaylight.netvirt.openstack.netvirt.translator.iaware.INeutronRouterAware;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.l3.attributes.Routes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.Routers;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.Router;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.router.Interfaces;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.router.external_gateway_info.ExternalFixedIps;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
result.setExternalGatewayInfo(extGwInfo);
}
- if (router.getInterfaces() != null) {
- Map<String, NeutronRouter_Interface> interfaces = new HashMap<>();
- for (Interfaces mdInterface : router.getInterfaces()) {
- NeutronRouter_Interface pojoInterface = new NeutronRouter_Interface();
- String id = String.valueOf(mdInterface.getUuid().getValue());
- pojoInterface.setID(id);
- if (mdInterface.getTenantId() != null) {
- pojoInterface.setTenantID(String.valueOf(mdInterface.getTenantId().getValue()));
- }
- pojoInterface.setSubnetUUID(String.valueOf(mdInterface.getSubnetId().getValue()));
- pojoInterface.setPortUUID(String.valueOf(mdInterface.getPortId().getValue()));
- interfaces.put(id, pojoInterface);
- }
- result.setInterfaces(interfaces);
- }
return result;
}
if (group.getName() != null) {
answer.setSecurityGroupName(group.getName());
}
- if (group.getDescription() != null) {
- answer.setSecurityGroupDescription(group.getDescription());
- }
if (group.getTenantId() != null) {
answer.setSecurityGroupTenantID(group.getTenantId().getValue()
.replace("-", ""));
}
- if (group.getSecurityRules() != null) {
- NeutronCRUDInterfaces interfaces = new NeutronCRUDInterfaces()
- .fetchINeutronSecurityRuleCRUD(this);
- INeutronSecurityRuleCRUD srCrud = interfaces
- .getSecurityRuleInterface();
-
- List<NeutronSecurityRule> rules = new ArrayList<>();
- for (Uuid uuid : group.getSecurityRules()) {
- rules.add(srCrud.getNeutronSecurityRule(uuid.getValue()));
- }
- answer.setSecurityRules(rules);
- }
if (group.getUuid() != null) {
answer.setID(group.getUuid().getValue());
}
if (rule.getPortRangeMax() != null) {
answer.setSecurityRulePortMax(rule.getPortRangeMax());
}
- if (rule.getId() != null) {
- answer.setID(rule.getId().getValue());
+ if (rule.getUuid() != null) {
+ answer.setID(rule.getUuid().getValue());
}
return answer;
}
}
result.setNetworkUUID(subnet.getNetworkId().getValue());
result.setIpVersion(IPV_MAP.get(subnet.getIpVersion()));
- result.setCidr(subnet.getCidr());
+ result.setCidr(String.valueOf(subnet.getCidr().getValue()));
if (subnet.getGatewayIp() != null) {
result.setGatewayIP(String.valueOf(subnet.getGatewayIp().getValue()));
}
List<NeutronSubnetIPAllocationPool> allocationPools = new ArrayList<>();
for (AllocationPools allocationPool : subnet.getAllocationPools()) {
NeutronSubnetIPAllocationPool pool = new NeutronSubnetIPAllocationPool();
- pool.setPoolStart(allocationPool.getStart());
- pool.setPoolEnd(allocationPool.getEnd());
+ pool.setPoolStart(String.valueOf(allocationPool.getStart().getValue()));
+ pool.setPoolEnd(String.valueOf(allocationPool.getEnd().getValue()));
allocationPools.add(pool);
}
result.setAllocationPools(allocationPools);
import org.opendaylight.netvirt.openstack.netvirt.translator.Neutron_IPs;
import org.opendaylight.netvirt.openstack.netvirt.translator.crud.INeutronPortCRUD;
import org.opendaylight.netvirt.openstack.netvirt.translator.crud.INeutronSecurityGroupCRUD;
+import org.opendaylight.netvirt.openstack.netvirt.translator.crud.INeutronSecurityRuleCRUD;
/**
* Unit test fort {@link SecurityGroupCacheManagerImpl}
@InjectMocks private SecurityGroupCacheManagerImpl securityGroupCacheManagerImpl;
@Mock private INeutronPortCRUD neutronPortCache;
@Mock private INeutronSecurityGroupCRUD securityGroupCache;
+ @Mock private INeutronSecurityRuleCRUD neutronSecurityRuleCache;
@Mock NeutronPort neutronPort_Vm1;
@Mock NeutronPort neutronPort_Vm2;
@Mock NeutronPort neutronPort_Vm3;
securityGroups_Vm_2.add(neutronSecurityGroup_2);
List<NeutronSecurityGroup> securityGroups_Vm_3 = new ArrayList<>();
securityGroups_Vm_3.add(neutronSecurityGroup_3);
- List<NeutronSecurityRule> securityRule_1 = new ArrayList<>();
- securityRule_1.add(neutronSecurityRule_1);
- List<NeutronSecurityRule> securityRule_2 = new ArrayList<>();
- securityRule_2.add(neutronSecurityRule_2);
- List<NeutronSecurityRule> securityRule_3 = new ArrayList<>();
- securityRule_3.add(neutronSecurityRule_3);
+ List<NeutronSecurityRule> securityRule = new ArrayList<>();
+ securityRule.add(neutronSecurityRule_1);
+ securityRule.add(neutronSecurityRule_2);
+ securityRule.add(neutronSecurityRule_3);
neutron_IPs_1.add(neutron_ip_1);
neutron_IPs_2.add(neutron_ip_2);
when(neutronPort_Vm3.getSecurityGroups()).thenReturn(securityGroups_Vm_3);
when(neutronPort_Vm4.getSecurityGroups()).thenReturn(securityGroups_Vm_1);
when(neutronPort_Vm5.getSecurityGroups()).thenReturn(securityGroups_Vm_3);
- when(neutronSecurityGroup_1.getSecurityRules()).thenReturn(securityRule_1);
- when(neutronSecurityGroup_2.getSecurityRules()).thenReturn(securityRule_2);
- when(neutronSecurityGroup_3.getSecurityRules()).thenReturn(securityRule_3);
+ when(neutronSecurityRuleCache.getAllNeutronSecurityRules()).thenReturn(securityRule);
when(neutronSecurityGroup_1.getSecurityGroupUUID()).thenReturn(SECURITY_GROUP_ID_1);
when(neutronSecurityGroup_2.getSecurityGroupUUID()).thenReturn(SECURITY_GROUP_ID_2);
when(neutronSecurityGroup_3.getSecurityGroupUUID()).thenReturn(SECURITY_GROUP_ID_3);
+ when(neutronSecurityGroup_1.getID()).thenReturn(SECURITY_GROUP_ID_1);
+ when(neutronSecurityGroup_2.getID()).thenReturn(SECURITY_GROUP_ID_2);
+ when(neutronSecurityGroup_3.getID()).thenReturn(SECURITY_GROUP_ID_3);
+ when(neutronSecurityRule_1.getSecurityRuleGroupID()).thenReturn(SECURITY_GROUP_ID_1);
+ when(neutronSecurityRule_2.getSecurityRuleGroupID()).thenReturn(SECURITY_GROUP_ID_2);
+ when(neutronSecurityRule_3.getSecurityRuleGroupID()).thenReturn(SECURITY_GROUP_ID_3);
when(neutronSecurityRule_1.getSecurityRemoteGroupID()).thenReturn(SECURITY_GROUP_ID_1);
when(neutronSecurityRule_3.getSecurityRemoteGroupID()).thenReturn(SECURITY_GROUP_ID_2);
when(neutronPort_Vm1.getFixedIPs()).thenReturn(neutron_IPs_1);
import org.opendaylight.netvirt.openstack.netvirt.translator.NeutronSubnet;
import org.opendaylight.netvirt.openstack.netvirt.translator.Neutron_IPs;
import org.opendaylight.netvirt.openstack.netvirt.translator.crud.INeutronPortCRUD;
+import org.opendaylight.netvirt.openstack.netvirt.translator.crud.INeutronSecurityRuleCRUD;
import org.opendaylight.netvirt.openstack.netvirt.translator.crud.INeutronSubnetCRUD;
import org.opendaylight.netvirt.utils.servicehelper.ServiceHelper;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105
@Mock private INeutronSubnetCRUD subNetCache;
@Mock private Southbound southbound;
@Mock private ConfigurationService configurationService;
+ @Mock private INeutronSecurityRuleCRUD neutronSecurityRuleCache;
@Mock NeutronNetwork neutronNetwork;
@Mock NeutronPort neutronPort_Vm1;
@Mock NeutronPort neutronPort_Vm2;
securityGroups_2.add(neutronSecurityGroup_2);
List<NeutronSecurityGroup> securityGroups_3 = new ArrayList<>();
securityGroups_3.add(neutronSecurityGroup_3);
- List<NeutronSecurityRule> securityRule_1 = new ArrayList<>();
- securityRule_1.add(neutronSecurityRule_1);
- List<NeutronSecurityRule> securityRule_2 = new ArrayList<>();
- securityRule_1.add(neutronSecurityRule_2);
- List<NeutronSecurityRule> securityRule_3 = new ArrayList<>();
- securityRule_1.add(neutronSecurityRule_3);
+ List<NeutronSecurityRule> securityRule = new ArrayList<>();
+ securityRule.add(neutronSecurityRule_1);
+ securityRule.add(neutronSecurityRule_2);
+ securityRule.add(neutronSecurityRule_3);
neutron_IPs_1.add(neutron_ip_1);
neutron_IPs_2.add(neutron_ip_2);
when(neutronPort_Vm1.getSecurityGroups()).thenReturn(securityGroups_1);
when(neutronPort_Vm2.getSecurityGroups()).thenReturn(securityGroups_2);
when(neutronPort_Vm3.getSecurityGroups()).thenReturn(securityGroups_3);
- when(neutronSecurityGroup_1.getSecurityRules()).thenReturn(securityRule_1);
- when(neutronSecurityGroup_2.getSecurityRules()).thenReturn(securityRule_2);
- when(neutronSecurityGroup_3.getSecurityRules()).thenReturn(securityRule_3);
+ when(neutronSecurityRuleCache.getAllNeutronSecurityRules()).thenReturn(securityRule);
when(neutronSecurityGroup_1.getSecurityGroupUUID()).thenReturn(SECURITY_GROUP_ID_1);
when(neutronSecurityGroup_2.getSecurityGroupUUID()).thenReturn(SECURITY_GROUP_ID_2);
when(neutronSecurityGroup_3.getSecurityGroupUUID()).thenReturn(SECURITY_GROUP_ID_3);
+ when(neutronSecurityGroup_1.getID()).thenReturn(SECURITY_GROUP_ID_1);
+ when(neutronSecurityGroup_2.getID()).thenReturn(SECURITY_GROUP_ID_2);
+ when(neutronSecurityGroup_3.getID()).thenReturn(SECURITY_GROUP_ID_3);
+ when(neutronSecurityRule_1.getSecurityRuleGroupID()).thenReturn(SECURITY_GROUP_ID_1);
+ when(neutronSecurityRule_2.getSecurityRuleGroupID()).thenReturn(SECURITY_GROUP_ID_2);
+ when(neutronSecurityRule_3.getSecurityRuleGroupID()).thenReturn(SECURITY_GROUP_ID_3);
when(neutronPort_Vm1.getDeviceOwner()).thenReturn(DEVICE_OWNER_VM);
when(neutronPort_Vm2.getDeviceOwner()).thenReturn(DEVICE_OWNER_VM);
when(neutronPort_Vm3.getDeviceOwner()).thenReturn(DEVICE_OWNER_VM);
public NeutronSecurityRule buildNeutronSecurityRule(String direction, String ethertype, String protocol,
String ipPrefix, Integer portMin, Integer portMax) {
NeutronSecurityRule rule = new NeutronSecurityRule();
- rule.setSecurityRuleUUID(UUID.randomUUID().toString());
+ rule.setID(UUID.randomUUID().toString());
rule.setSecurityRemoteGroupID(null);
rule.setSecurityRuleDirection(direction);
rule.setSecurityRuleEthertype(ethertype);
String id = UUID.randomUUID().toString();
NeutronSecurityGroup sg = new NeutronSecurityGroup();
sg.setSecurityGroupName("SG-" + id);
- sg.setSecurityGroupUUID(id);
+ sg.setID(id);
sg.setTenantID(tenantId);
List<NeutronSecurityRule> ruleList = new ArrayList<>(rules.length);
ruleCRUD.addNeutronSecurityRule(rule);
}
- sg.setSecurityRules(ruleList);
groupCRUD.add(sg);
return sg;
public void removeNeutronSecurityGroupAndRules(NeutronSecurityGroup sg) {
INeutronSecurityGroupCRUD groupCRUD =
(INeutronSecurityGroupCRUD) ServiceHelper.getGlobalInstance(INeutronSecurityGroupCRUD.class, this);
+
+ groupCRUD.removeNeutronSecurityGroup(sg.getID());
+ }
+
+ /**
+ * Get the NeutronSecurityRule and its associated NeutronSecurityGroup
+ * @param sg NeutronSecurityGroup to to get the rules for
+ * @return List of NeutronSecurityRule
+ */
+ public List<NeutronSecurityRule> getNeutronSecurityGroupRules(NeutronSecurityGroup sg) {
INeutronSecurityRuleCRUD ruleCRUD =
(INeutronSecurityRuleCRUD) ServiceHelper.getGlobalInstance(INeutronSecurityRuleCRUD.class, this);
- for (NeutronSecurityRule rule : sg.getSecurityRules()) {
- ruleCRUD.removeNeutronSecurityRule(rule.getSecurityRuleUUID());
+ List<NeutronSecurityRule> rules = new ArrayList<>();
+ List<NeutronSecurityRule> securityRules = ruleCRUD.getAllNeutronSecurityRules();
+ for (NeutronSecurityRule securityRule : securityRules) {
+ if (sg.getID().equals(securityRule.getSecurityRuleGroupID())) {
+ rules.add(securityRule);
+ }
}
- groupCRUD.removeNeutronSecurityGroup(sg.getID());
+ return rules;
}
}
if(NeutronUtils.isPortVnicTypeNormal(port)) {
continue;
}
- String macAddress = port.getMacAddress();
+ String macAddress = port.getMacAddress().getValue();
Uuid networkId = port.getNetworkId();
String segmentationId = DhcpServiceUtils.getSegmentationId(networkId, broker);
if (segmentationId == null) {
Port port = dhcpManager.getNeutronPort(interfaceName);
if (port!=null) {
logger.trace("Port found in neutron. Interface Name {}, port {}", interfaceName, port);
- return port.getMacAddress();
+ return port.getMacAddress().getValue();
}
return null;
}
}
private String getMacAddress(Port port) {
- String macAddress = port.getMacAddress();
+ String macAddress = port.getMacAddress().getValue();
return macAddress;
}
}
List<IpAddress> dnsServers = nSubnet.getDnsNameservers();
dhcpInfo = new DhcpInfo();
dhcpInfo.setClientIp(clientIp).setServerIp(serverIp)
- .setCidr(nSubnet.getCidr()).setHostRoutes(nSubnet.getHostRoutes())
+ .setCidr(String.valueOf(nSubnet.getCidr().getValue())).setHostRoutes(nSubnet.getHostRoutes())
.setDnsServersIpAddrs(dnsServers).setGatewayIp(serverIp);
}
return dhcpInfo;
logger.warn("Trunk port {} not available for sub-port", parentRefName);
return null;
}
- return trunkPort.get().getMacAddress();
+ return trunkPort.get().getMacAddress().getValue();
}
-}
\ No newline at end of file
+}
<type>xml</type>
<scope>runtime</scope>
</dependency>
- <dependency>
- <groupId>org.opendaylight.neutron</groupId>
- <artifactId>dummyprovider</artifactId>
- <version>${neutron.version}</version>
- </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>vpnmanager-impl</artifactId>
</feature>
<feature name='odl-netvirt-vpnservice-core' version='${project.version}' description='OpenDaylight :: vpnservice :: core'>
<feature version="${neutron.version}">odl-neutron-service</feature>
- <bundle>mvn:org.opendaylight.neutron/dummyprovider/{{VERSION}}</bundle>
<feature version="${project.version}">odl-netvirt-vpnservice-impl-ui</feature>
</feature>
<feature name='odl-netvirt-vpnservice-openstack' version='${project.version}' description='OpenDaylight :: vpnservice :: openstack'>
<feature version="${neutron.version}">odl-neutron-service</feature>
- <bundle>mvn:org.opendaylight.neutron/dummyprovider/{{VERSION}}</bundle>
<feature version="${project.version}">odl-netvirt-vpnservice-impl-rest</feature>
</feature>
</features>
private final DataBroker broker;
private NeutronvpnManager nvpnManager;
private NeutronvpnNatManager nvpnNatManager;
- private NeutronvpnUtils neutronvpnUtils;
public NeutronNetworkChangeListener(final DataBroker db, NeutronvpnManager nVpnMgr, NeutronvpnNatManager
- nVpnNatMgr, NeutronvpnUtils nVpnUtils) {
+ nVpnNatMgr) {
super(Network.class);
broker = db;
nvpnManager = nVpnMgr;
nvpnNatManager = nVpnNatMgr;
- neutronvpnUtils = nVpnUtils;
registerListener(db);
}
createElanInstance(input);
if (input.getAugmentation(NetworkL3Extension.class).isExternal()) {
nvpnNatManager.addExternalNetwork(input);
- neutronvpnUtils.addToNetworkCache(input);
+ NeutronvpnUtils.addToNetworkCache(input);
}
}
deleteElanInstance(input.getUuid().getValue());
if (input.getAugmentation(NetworkL3Extension.class).isExternal()) {
nvpnNatManager.removeExternalNetwork(input);
- neutronvpnUtils.removeFromNetworkCache(input);
+ NeutronvpnUtils.removeFromNetworkCache(input);
}
}
private LockManagerService lockManager;
private NotificationPublishService notificationPublishService;
private NotificationService notificationService;
- private NeutronvpnUtils neutronvpnUtils;
public NeutronPortChangeListener(final DataBroker db, NeutronvpnManager nVpnMgr,NeutronvpnNatManager nVpnNatMgr,
- NotificationPublishService notiPublishService, NotificationService notiService,
- NeutronvpnUtils nVpnUtils) {
+ NotificationPublishService notiPublishService, NotificationService notiService) {
super(Port.class);
broker = db;
nvpnManager = nVpnMgr;
nvpnNatManager = nVpnNatMgr;
notificationPublishService = notiPublishService;
notificationService = notiService;
- neutronvpnUtils = nVpnUtils;
registerListener(db);
}
}
}
handleNeutronPortCreated(input);
- neutronvpnUtils.addToPortCache(input);
+ NeutronvpnUtils.addToPortCache(input);
}
}
}
handleNeutronPortDeleted(input);
- neutronvpnUtils.removeFromPortCache(input);
-
+ NeutronvpnUtils.removeFromPortCache(input);
}
@Override
}
}
handleNeutronPortUpdated(original, update);
- neutronvpnUtils.addToPortCache(update);
+ NeutronvpnUtils.addToPortCache(update);
}
}
private void createElanInterface(Port port, String name) {
String elanInstanceName = port.getNetworkId().getValue();
List<PhysAddress> physAddresses = new ArrayList<>();
- physAddresses.add(new PhysAddress(port.getMacAddress()));
+ physAddresses.add(new PhysAddress(port.getMacAddress().getValue()));
InstanceIdentifier<ElanInterface> id = InstanceIdentifier.builder(ElanInterfaces.class).child(ElanInterface
.class, new ElanInterfaceKey(name)).build();
private final DataBroker broker;
private NeutronvpnManager nvpnManager;
private NeutronvpnNatManager nvpnNatManager;
- private NeutronvpnUtils neutronvpnUtils;
public NeutronRouterChangeListener(final DataBroker db, NeutronvpnManager nVpnMgr, NeutronvpnNatManager
- nVpnNatMgr, NeutronvpnUtils nVpnUtils) {
+ nVpnNatMgr) {
super(Router.class);
broker = db;
nvpnManager = nVpnMgr;
nvpnNatManager = nVpnNatMgr;
- neutronvpnUtils = nVpnUtils;
registerListener(db);
}
}
// Create internal VPN
nvpnManager.createL3Vpn(input.getUuid(), null, null, null, null, null, input.getUuid(), null);
- neutronvpnUtils.addToRouterCache(input);
+ NeutronvpnUtils.addToRouterCache(input);
}
@Override
//will be removed from VPN by invocations from NeutronPortChangeListener
List<Uuid> routerSubnetIds = new ArrayList<>();
nvpnManager.handleNeutronRouterDeleted(routerId, routerSubnetIds);
- neutronvpnUtils.removeFromRouterCache(input);
+ NeutronvpnUtils.removeFromRouterCache(input);
// Handle router deletion for the NAT service
if (input.getExternalGatewayInfo() != null) {
Uuid extNetId = input.getExternalGatewayInfo().getExternalNetworkId();
private ListenerRegistration<DataChangeListener> listenerRegistration;
private final DataBroker broker;
private NeutronvpnManager nvpnManager;
- private NeutronvpnUtils neutronvpnUtils;
- public NeutronSubnetChangeListener(final DataBroker db, NeutronvpnManager nVpnMgr, NeutronvpnUtils nVpnUtils) {
+ public NeutronSubnetChangeListener(final DataBroker db, NeutronvpnManager nVpnMgr) {
super(Subnet.class);
broker = db;
nvpnManager = nVpnMgr;
- neutronvpnUtils = nVpnUtils;
registerListener(db);
}
input.getName(), network);
return;
}
- handleNeutronSubnetCreated(input.getUuid(), input.getCidr(), networkId, input.getTenantId());
- neutronvpnUtils.addToSubnetCache(input);
+ handleNeutronSubnetCreated(input.getUuid(), String.valueOf(input.getCidr().getValue()), input.getNetworkId(), input.getTenantId());
+ NeutronvpnUtils.addToSubnetCache(input);
}
@Override
return;
}
handleNeutronSubnetDeleted(input.getUuid(), networkId, null);
- neutronvpnUtils.removeFromSubnetCache(input);
+ NeutronvpnUtils.removeFromSubnetCache(input);
}
@Override
return;
}
handleNeutronSubnetUpdated(update.getUuid(), networkId, update.getTenantId());
- neutronvpnUtils.addToSubnetCache(update);
+ NeutronvpnUtils.addToSubnetCache(update);
}
private void handleNeutronSubnetCreated(Uuid subnetId, String subnetIp, Uuid networkId, Uuid tenantId) {
IMdsalApiManager mdsalUtil;
private NotificationPublishService notificationPublishService;
private NotificationService notificationService;
- private NeutronvpnUtils neutronvpnUtils;
Boolean isExternalVpn;
/**
* @param mdsalManager - MDSAL Util API access
*/
public NeutronvpnManager(final DataBroker db, IMdsalApiManager mdsalManager,NotificationPublishService notiPublishService,
- NotificationService notiService, NeutronvpnNatManager vpnNatMgr, NeutronvpnUtils
- nVpnUtils) {
+ NotificationService notiService, NeutronvpnNatManager vpnNatMgr) {
broker = db;
mdsalUtil = mdsalManager;
nvpnNatManager = vpnNatMgr;
notificationPublishService = notiPublishService;
notificationService = notiService;
- neutronvpnUtils = nVpnUtils;
}
public void setLockManager(LockManagerService lockManager) {
StringBuilder IpPrefixBuild = new StringBuilder(ip.getIpAddress().getIpv4Address().getValue());
String IpPrefix = IpPrefixBuild.append("/32").toString();
Adjacency vmAdj = new AdjacencyBuilder().setKey(new AdjacencyKey(IpPrefix)).setIpAddress(IpPrefix)
- .setMacAddress(port.getMacAddress()).build();
+ .setMacAddress(port.getMacAddress().getValue()).build();
adjList.add(vmAdj);
// create extra route adjacency
if (rtr != null && rtr.getRoutes() != null) {
private static final Logger LOG = LoggerFactory.getLogger(NeutronvpnProvider.class);
private NeutronvpnManager nvManager;
private NeutronvpnNatManager nvNatManager;
- private NeutronvpnUtils nVpnUtils;
private IMdsalApiManager mdsalManager;
private LockManagerService lockManager;
private NeutronBgpvpnChangeListener bgpvpnListener;
final DataBroker dbx = session.getSALService(DataBroker.class);
nvNatManager = new NeutronvpnNatManager(dbx, mdsalManager);
nvManager = new NeutronvpnManager(dbx, mdsalManager,notificationPublishService,notificationService,
- nvNatManager, nVpnUtils);
+ nvNatManager);
final BindingAwareBroker.RpcRegistration<NeutronvpnService> rpcRegistration =
getRpcProviderRegistry().addRpcImplementation(NeutronvpnService.class, nvManager);
bgpvpnListener = new NeutronBgpvpnChangeListener(dbx, nvManager);
- networkListener = new NeutronNetworkChangeListener(dbx, nvManager, nvNatManager, nVpnUtils);
- subnetListener = new NeutronSubnetChangeListener(dbx, nvManager, nVpnUtils);
- routerListener = new NeutronRouterChangeListener(dbx, nvManager, nvNatManager, nVpnUtils);
+ networkListener = new NeutronNetworkChangeListener(dbx, nvManager, nvNatManager);
+ subnetListener = new NeutronSubnetChangeListener(dbx, nvManager);
+ routerListener = new NeutronRouterChangeListener(dbx, nvManager, nvNatManager);
portListener = new NeutronPortChangeListener(dbx, nvManager, nvNatManager,
- notificationPublishService,notificationService, nVpnUtils);
+ notificationPublishService,notificationService);
portListener.setLockManager(lockManager);
portListener.setLockManager(lockManager);
floatingIpMapListener = new NeutronFloatingToFixedIpMappingChangeListener(dbx);
@Override
public Subnet getNeutronSubnet(Uuid subnetId) {
- return nVpnUtils.getNeutronSubnet(broker, subnetId);
+ return NeutronvpnUtils.getNeutronSubnet(broker, subnetId);
}
@Override
public static ConcurrentHashMap<Uuid, Port> portMap = new ConcurrentHashMap<Uuid, Port>();
public static ConcurrentHashMap<Uuid, Subnet> subnetMap = new ConcurrentHashMap<Uuid, Subnet>();
+ private NeutronvpnUtils() {
+ throw new UnsupportedOperationException("Utility class should not be instantiated");
+ }
+
protected static Subnetmap getSubnetmap(DataBroker broker, Uuid subnetId) {
InstanceIdentifier id = buildSubnetMapIdentifier(subnetId);
Optional<Subnetmap> sn = read(broker, LogicalDatastoreType.CONFIGURATION, id);
.class).child(Subnet.class, subnetkey);
Optional<Subnet> subnet = read(broker, LogicalDatastoreType.CONFIGURATION,subnetidentifier);
if (subnet.isPresent()) {
- cidr = subnet.get().getCidr();
+ cidr = String.valueOf(subnet.get().getCidr().getValue());
// Extract the prefix length from cidr
String[] parts = cidr.split("/");
if ((parts.length == 2)) {
import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
import org.opendaylight.controller.md.sal.binding.api.NotificationService;
+import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
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.inet.types.rev100924.Ipv4Address;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address;
+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.networks.rev150712.networks.attributes.networks.Network;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIpsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import com.google.common.base.Optional;
import com.google.common.util.concurrent.Futures;
@RunWith(MockitoJUnitRunner.class)
ListenerRegistration<DataChangeListener> dataChangeListenerRegistration;
@Mock
WriteTransaction mockWriteTx;
+ @Mock
+ ReadOnlyTransaction mockReadTx;
+ @Mock
+ Network mockNetwork;
@Before
public void setUp() {
thenReturn(dataChangeListenerRegistration);
doReturn(mockWriteTx).when(dataBroker).newWriteOnlyTransaction();
doReturn(Futures.immediateCheckedFuture(null)).when(mockWriteTx).submit();
+ doReturn(mockReadTx).when(dataBroker).newReadOnlyTransaction();
+ when(mockReadTx.read(any(LogicalDatastoreType.class), any(InstanceIdentifier.class))).
+ thenReturn(Futures.immediateCheckedFuture(Optional.of(mockNetwork)));
neutronPortChangeListener = new NeutronPortChangeListener(dataBroker, nVpnMgr, nVpnNatMgr, notiPublishService, notiService);
}
PortBuilder pb = new PortBuilder();
pb.setUuid(new Uuid("12345678-1234-1234-1234-123456789012"));
pb.setNetworkId(new Uuid("12345678-1234-1234-1234-123456789012"));
- pb.setMacAddress("AA:BB:CC:DD:EE:FF");
+ 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);
PortBuilder pb = new PortBuilder();
pb.setUuid(new Uuid("12345678-1234-1234-1234-123456789012"));
pb.setNetworkId(new Uuid("12345678-1234-1234-1234-123456789012"));
- pb.setMacAddress("AA:BB:CC:DD:EE:FF");
+ 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);
PortBuilder pb = new PortBuilder();
pb.setUuid(new Uuid("12345678-1234-1234-1234-123456789012"));
pb.setNetworkId(new Uuid("12345678-1234-1234-1234-123456789012"));
- pb.setMacAddress("AA:BB:CC:DD:EE:FF");
+ pb.setMacAddress(new MacAddress("AA:BB:CC:DD:EE:FF"));
List<FixedIps> fixedIps = new ArrayList<FixedIps>();
pb.setFixedIps(fixedIps);
Port port = pb.build();