cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kous...@apache.org
Subject [1/3] CLOUDSTACK-702: Multiple ip ranges in different subnets.
Date Mon, 13 May 2013 11:38:55 GMT
Updated Branches:
  refs/heads/master 756a4179e -> 052c24c4d


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/052c24c4/server/test/com/cloud/configuration/ValidateIpRangeTest.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/configuration/ValidateIpRangeTest.java b/server/test/com/cloud/configuration/ValidateIpRangeTest.java
new file mode 100644
index 0000000..7681667
--- /dev/null
+++ b/server/test/com/cloud/configuration/ValidateIpRangeTest.java
@@ -0,0 +1,71 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.configuration;
+
+import com.cloud.dc.VlanVO;
+import com.cloud.network.Network;
+import com.cloud.network.NetworkModel;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.mockito.Mockito.when;
+
+public class ValidateIpRangeTest {
+    @Mock  NetworkModel   _networkModel;
+    @Mock  VlanVO   vlan;
+    @Mock Network network;
+    ConfigurationManagerImpl configurationMgr = new ConfigurationManagerImpl();
+    List<VlanVO> vlanVOList = new ArrayList<VlanVO>();
+
+    @Before
+    public void setup() {
+        MockitoAnnotations.initMocks(this);
+        configurationMgr._networkModel = _networkModel;
+        vlanVOList.add(vlan);
+        when(vlan.getVlanGateway()).thenReturn("10.147.33.1");
+        when(vlan.getVlanNetmask()).thenReturn("255.255.255.128");
+
+    }
+
+    @Test
+    public void SameSubnetTest() {
+        boolean sameSubnet=configurationMgr.validateIpRange("10.147.33.104", "10.147.33.105",
"10.147.33.1", "255.255.255.128", vlanVOList, true, false, null, null, null, null,network);
+        Assert.assertTrue(sameSubnet);
+    }
+
+    @Test
+    public void NewSubnetTest() {
+        boolean sameSubnet= configurationMgr.validateIpRange("10.147.33.140", "10.147.33.145",
"10.147.33.129", "255.255.255.191", vlanVOList, true, false, null, null, null, null,network);
+        Assert.assertTrue(!sameSubnet);
+    }
+
+    @Test
+    public void SuperSetTest() {
+        try {
+            configurationMgr.validateIpRange("10.147.33.140", "10.147.33.143", "10.147.33.140",
"255.255.255.191", vlanVOList, true, false, null, null, null, null,network);
+        } catch (Exception e) {
+            junit.framework.Assert.assertTrue(e.getMessage().contains("superset"));
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/052c24c4/server/test/com/cloud/network/MockNetworkManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/network/MockNetworkManagerImpl.java b/server/test/com/cloud/network/MockNetworkManagerImpl.java
index eb5fc25..2936fab 100755
--- a/server/test/com/cloud/network/MockNetworkManagerImpl.java
+++ b/server/test/com/cloud/network/MockNetworkManagerImpl.java
@@ -50,6 +50,7 @@ import com.cloud.network.addr.PublicIp;
 import com.cloud.network.dao.IPAddressVO;
 import com.cloud.network.dao.NetworkVO;
 import com.cloud.network.GuestVlan;
+import com.cloud.network.element.DhcpServiceProvider;
 import com.cloud.network.element.LoadBalancingServiceProvider;
 import com.cloud.network.element.StaticNatServiceProvider;
 import com.cloud.network.element.UserDataServiceProvider;
@@ -917,4 +918,14 @@ public class MockNetworkManagerImpl extends ManagerBase implements NetworkManage
         // TODO Auto-generated method stub
         return null;
     }
+
+    @Override
+    public DhcpServiceProvider getDhcpServiceProvider(Network network) {
+        return null;  //To change body of implemented methods use File | Settings | File
Templates.
+    }
+
+    @Override
+    public PublicIp assignPublicIpAddressFromVlans(long dcId, Long podId, Account owner,
VlanType type, List<Long> vlanDbIds, Long networkId, String requestedIp, boolean isSystem)
throws InsufficientAddressCapacityException {
+        return null;  //To change body of implemented methods use File | Settings | File
Templates.
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/052c24c4/server/test/com/cloud/vpc/MockConfigurationManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/vpc/MockConfigurationManagerImpl.java b/server/test/com/cloud/vpc/MockConfigurationManagerImpl.java
index 9058798..0f2972d 100755
--- a/server/test/com/cloud/vpc/MockConfigurationManagerImpl.java
+++ b/server/test/com/cloud/vpc/MockConfigurationManagerImpl.java
@@ -16,40 +16,6 @@
 // under the License.
 package com.cloud.vpc;
 
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.ejb.Local;
-import javax.inject.Inject;
-import javax.naming.ConfigurationException;
-import javax.naming.NamingException;
-
-import com.cloud.configuration.ConfigurationVO;
-import org.apache.cloudstack.api.command.admin.config.UpdateCfgCmd;
-import org.apache.cloudstack.api.command.admin.ldap.LDAPConfigCmd;
-import org.apache.cloudstack.api.command.admin.ldap.LDAPRemoveCmd;
-import org.apache.cloudstack.api.command.admin.network.CreateNetworkOfferingCmd;
-import org.apache.cloudstack.api.command.admin.network.DeleteNetworkOfferingCmd;
-import org.apache.cloudstack.api.command.admin.network.UpdateNetworkOfferingCmd;
-import org.apache.cloudstack.api.command.admin.offering.CreateDiskOfferingCmd;
-import org.apache.cloudstack.api.command.admin.offering.CreateServiceOfferingCmd;
-import org.apache.cloudstack.api.command.admin.offering.DeleteDiskOfferingCmd;
-import org.apache.cloudstack.api.command.admin.offering.DeleteServiceOfferingCmd;
-import org.apache.cloudstack.api.command.admin.offering.UpdateDiskOfferingCmd;
-import org.apache.cloudstack.api.command.admin.offering.UpdateServiceOfferingCmd;
-import org.apache.cloudstack.api.command.admin.pod.DeletePodCmd;
-import org.apache.cloudstack.api.command.admin.pod.UpdatePodCmd;
-import org.apache.cloudstack.api.command.admin.vlan.CreateVlanIpRangeCmd;
-import org.apache.cloudstack.api.command.admin.vlan.DedicatePublicIpRangeCmd;
-import org.apache.cloudstack.api.command.admin.vlan.DeleteVlanIpRangeCmd;
-import org.apache.cloudstack.api.command.admin.vlan.ReleasePublicIpRangeCmd;
-import org.apache.cloudstack.api.command.admin.zone.CreateZoneCmd;
-import org.apache.cloudstack.api.command.admin.zone.DeleteZoneCmd;
-import org.apache.cloudstack.api.command.admin.zone.UpdateZoneCmd;
-import org.apache.cloudstack.api.command.user.network.ListNetworkOfferingsCmd;
-import org.springframework.stereotype.Component;
-
 import com.cloud.configuration.Configuration;
 import com.cloud.configuration.ConfigurationManager;
 import com.cloud.configuration.ConfigurationService;
@@ -75,15 +41,44 @@ import com.cloud.offering.NetworkOffering;
 import com.cloud.offering.NetworkOffering.Availability;
 import com.cloud.offering.ServiceOffering;
 import com.cloud.offerings.NetworkOfferingVO;
-import com.cloud.offerings.dao.NetworkOfferingDao;
 import com.cloud.offerings.dao.NetworkOfferingDaoImpl;
 import com.cloud.org.Grouping.AllocationState;
 import com.cloud.service.ServiceOfferingVO;
 import com.cloud.storage.DiskOfferingVO;
 import com.cloud.user.Account;
-import com.cloud.utils.component.Manager;
 import com.cloud.utils.component.ManagerBase;
 import com.cloud.vm.VirtualMachine.Type;
+import org.apache.cloudstack.api.command.admin.config.UpdateCfgCmd;
+import org.apache.cloudstack.api.command.admin.ldap.LDAPConfigCmd;
+import org.apache.cloudstack.api.command.admin.ldap.LDAPRemoveCmd;
+import org.apache.cloudstack.api.command.admin.network.CreateNetworkOfferingCmd;
+import org.apache.cloudstack.api.command.admin.network.DeleteNetworkOfferingCmd;
+import org.apache.cloudstack.api.command.admin.network.UpdateNetworkOfferingCmd;
+import org.apache.cloudstack.api.command.admin.offering.CreateDiskOfferingCmd;
+import org.apache.cloudstack.api.command.admin.offering.CreateServiceOfferingCmd;
+import org.apache.cloudstack.api.command.admin.offering.DeleteDiskOfferingCmd;
+import org.apache.cloudstack.api.command.admin.offering.DeleteServiceOfferingCmd;
+import org.apache.cloudstack.api.command.admin.offering.UpdateDiskOfferingCmd;
+import org.apache.cloudstack.api.command.admin.offering.UpdateServiceOfferingCmd;
+import org.apache.cloudstack.api.command.admin.pod.DeletePodCmd;
+import org.apache.cloudstack.api.command.admin.pod.UpdatePodCmd;
+import org.apache.cloudstack.api.command.admin.vlan.CreateVlanIpRangeCmd;
+import org.apache.cloudstack.api.command.admin.vlan.DedicatePublicIpRangeCmd;
+import org.apache.cloudstack.api.command.admin.vlan.DeleteVlanIpRangeCmd;
+import org.apache.cloudstack.api.command.admin.vlan.ReleasePublicIpRangeCmd;
+import org.apache.cloudstack.api.command.admin.zone.CreateZoneCmd;
+import org.apache.cloudstack.api.command.admin.zone.DeleteZoneCmd;
+import org.apache.cloudstack.api.command.admin.zone.UpdateZoneCmd;
+import org.apache.cloudstack.api.command.user.network.ListNetworkOfferingsCmd;
+import org.springframework.stereotype.Component;
+
+import javax.ejb.Local;
+import javax.inject.Inject;
+import javax.naming.ConfigurationException;
+import javax.naming.NamingException;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
 
 @Component
 @Local(value = { ConfigurationManager.class, ConfigurationService.class })
@@ -629,11 +624,5 @@ public class MockConfigurationManagerImpl extends ManagerBase implements
Configu
 		return false;
 	}
 
-	@Override
-	public boolean releasePublicIpRange(long userId, long vlanDbId,
-			Account caller) {
-		// TODO Auto-generated method stub
-		return false;
-	}
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/052c24c4/server/test/com/cloud/vpc/MockNetworkManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/vpc/MockNetworkManagerImpl.java b/server/test/com/cloud/vpc/MockNetworkManagerImpl.java
index 84ae818..cb9fbb3 100644
--- a/server/test/com/cloud/vpc/MockNetworkManagerImpl.java
+++ b/server/test/com/cloud/vpc/MockNetworkManagerImpl.java
@@ -66,10 +66,7 @@ import com.cloud.network.dao.AccountGuestVlanMapVO;
 import com.cloud.network.dao.IPAddressVO;
 import com.cloud.network.dao.NetworkServiceMapDao;
 import com.cloud.network.dao.NetworkVO;
-import com.cloud.network.element.LoadBalancingServiceProvider;
-import com.cloud.network.element.NetworkElement;
-import com.cloud.network.element.StaticNatServiceProvider;
-import com.cloud.network.element.UserDataServiceProvider;
+import com.cloud.network.element.*;
 import com.cloud.network.guru.NetworkGuru;
 import com.cloud.network.rules.FirewallRule;
 import com.cloud.network.rules.FirewallRule.Purpose;
@@ -1429,13 +1426,6 @@ public class MockNetworkManagerImpl extends ManagerBase implements
NetworkManage
     }
 
 
-
-
-
-
-
-
-
     @Override
     public boolean removeVmSecondaryIpsOfNic(long nicId) {
         // TODO Auto-generated method stub
@@ -1443,14 +1433,21 @@ public class MockNetworkManagerImpl extends ManagerBase implements
NetworkManage
     }
 
 
-
-
-
     @Override
     public NicVO savePlaceholderNic(Network network, String ip4Address, Type vmType) {
         // TODO Auto-generated method stub
         return null;
     }
 
+    @Override
+    public DhcpServiceProvider getDhcpServiceProvider(Network network) {
+        return null;  //To change body of implemented methods use File | Settings | File
Templates.
+    }
+
+    @Override
+    public PublicIp assignPublicIpAddressFromVlans(long dcId, Long podId, Account owner,
VlanType type, List<Long> vlanDbIds, Long networkId, String requestedIp, boolean isSystem)
throws InsufficientAddressCapacityException {
+        return null;  //To change body of implemented methods use File | Settings | File
Templates.
+    }
+
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/052c24c4/server/test/com/cloud/vpc/MockVpcVirtualNetworkApplianceManager.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/vpc/MockVpcVirtualNetworkApplianceManager.java b/server/test/com/cloud/vpc/MockVpcVirtualNetworkApplianceManager.java
index 2886af4..0f12c43 100644
--- a/server/test/com/cloud/vpc/MockVpcVirtualNetworkApplianceManager.java
+++ b/server/test/com/cloud/vpc/MockVpcVirtualNetworkApplianceManager.java
@@ -212,6 +212,16 @@ VpcVirtualNetworkApplianceService {
         return false;
     }
 
+    @Override
+    public boolean configDhcpForSubnet(Network network, NicProfile nic, VirtualMachineProfile<UserVm>
uservm, DeployDestination dest, List<DomainRouterVO> routers) throws ResourceUnavailableException
{
+        return false;  //To change body of implemented methods use File | Settings | File
Templates.
+    }
+
+    @Override
+    public boolean removeDhcpSupportForSubnet(Network network, List<DomainRouterVO>
routers) throws ResourceUnavailableException {
+        return false;  //To change body of implemented methods use File | Settings | File
Templates.
+    }
+
     /* (non-Javadoc)
      * @see com.cloud.network.VirtualNetworkApplianceService#startRouter(long, boolean)
      */

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/052c24c4/server/test/org/apache/cloudstack/networkoffering/CreateNetworkOfferingTest.java
----------------------------------------------------------------------
diff --git a/server/test/org/apache/cloudstack/networkoffering/CreateNetworkOfferingTest.java
b/server/test/org/apache/cloudstack/networkoffering/CreateNetworkOfferingTest.java
index 92aa2a2..4a2c867 100644
--- a/server/test/org/apache/cloudstack/networkoffering/CreateNetworkOfferingTest.java
+++ b/server/test/org/apache/cloudstack/networkoffering/CreateNetworkOfferingTest.java
@@ -17,22 +17,6 @@
 
 package org.apache.cloudstack.networkoffering;
 
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import javax.inject.Inject;
-
-import junit.framework.TestCase;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mockito;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
 import com.cloud.configuration.ConfigurationManager;
 import com.cloud.configuration.ConfigurationVO;
 import com.cloud.configuration.dao.ConfigurationDao;
@@ -52,6 +36,19 @@ import com.cloud.user.AccountVO;
 import com.cloud.user.UserContext;
 import com.cloud.user.UserVO;
 import com.cloud.utils.component.ComponentContext;
+import junit.framework.TestCase;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mockito;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import javax.inject.Inject;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
 
 @RunWith(SpringJUnit4ClassRunner.class)
 @ContextConfiguration(locations="classpath:/createNetworkOffering.xml")

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/052c24c4/server/test/resources/createNetworkOffering.xml
----------------------------------------------------------------------
diff --git a/server/test/resources/createNetworkOffering.xml b/server/test/resources/createNetworkOffering.xml
index 90342c5..9d684ba 100644
--- a/server/test/resources/createNetworkOffering.xml
+++ b/server/test/resources/createNetworkOffering.xml
@@ -34,13 +34,14 @@
             <ref bean="transactionContextBuilder" />
             <ref bean="actionEventInterceptor" />
         </list>
-    </property>
-  </bean>
-
-    <bean id="ConfigurationManager" class="com.cloud.configuration.ConfigurationManagerImpl">
-        <property name="name" value="ConfigurationManager"/>
-    </bean>
-  
-    <bean class="org.apache.cloudstack.networkoffering.ChildTestConfiguration" />
-    
-</beans>
+    </property>
+  </bean>
+
+    <bean id="nicIpAliasDaoImpl" class="com.cloud.vm.dao.NicIpAliasDaoImpl" />
+    <bean id="ConfigurationManager" class="com.cloud.configuration.ConfigurationManagerImpl">
+        <property name="name" value="ConfigurationManager"/>
+    </bean>
+
+    <bean class="org.apache.cloudstack.networkoffering.ChildTestConfiguration" />
+
+</beans>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/052c24c4/setup/db/db/schema-410to420.sql
----------------------------------------------------------------------
diff --git a/setup/db/db/schema-410to420.sql b/setup/db/db/schema-410to420.sql
index 6e74537..77e86e1 100644
--- a/setup/db/db/schema-410to420.sql
+++ b/setup/db/db/schema-410to420.sql
@@ -1220,3 +1220,22 @@ INSERT INTO `cloud`.`network_acl_item` (id, uuid, acl_id, state, protocol,
creat
 INSERT INTO `cloud`.`network_acl` (id, uuid, vpc_id, description, name) values (2, UUID(),
0, "Default Network ACL Allow All", "default_allow");
 INSERT INTO `cloud`.`network_acl_item` (id, uuid, acl_id, state, protocol, created, traffic_type,
cidr, number, action) values (3, UUID(), 2, "Active", "all", now(), "Ingress", "0.0.0.0/0",
1, "Allow");
 INSERT INTO `cloud`.`network_acl_item` (id, uuid, acl_id, state, protocol, created, traffic_type,
cidr, number, action) values (4, UUID(), 2, "Active", "all", now(), "Egress", "0.0.0.0/0",
2, "Allow");
+
+CREATE  TABLE `cloud`.`nic_ip_alias` (
+  `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT ,
+  `uuid`  VARCHAR(40) NOT NULL ,
+  `nic_id` BIGINT(20) UNSIGNED NULL ,
+  `ip4_address` CHAR(40) NULL ,
+  `ip6_address` CHAR(40) NULL ,
+  `netmask` CHAR(40) NULL ,
+  `gateway` CHAR(40) NULL ,
+  `start_ip_of_subnet` CHAR(40),
+  `network_id` BIGINT(20) UNSIGNED NULL ,
+  `vmId` BIGINT(20) UNSIGNED NULL   ,
+  `alias_count` BIGINT(20) UNSIGNED NULL ,
+  `created` DATETIME NOT NULL ,
+  `account_id` BIGINT(20) UNSIGNED NOT NULL ,
+  `domain_id` BIGINT(20) UNSIGNED NOT NULL ,
+  `state`  char(32)  NOT NULL,
+  PRIMARY KEY (`id`) ,
+  UNIQUE INDEX `id_UNIQUE` (`id` ASC) );


Mime
View raw message