Return-Path: X-Original-To: apmail-incubator-cloudstack-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-cloudstack-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 86378EEDD for ; Fri, 1 Feb 2013 23:27:43 +0000 (UTC) Received: (qmail 69777 invoked by uid 500); 1 Feb 2013 23:27:33 -0000 Delivered-To: apmail-incubator-cloudstack-commits-archive@incubator.apache.org Received: (qmail 69127 invoked by uid 500); 1 Feb 2013 23:27:32 -0000 Mailing-List: contact cloudstack-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: cloudstack-dev@incubator.apache.org Delivered-To: mailing list cloudstack-commits@incubator.apache.org Received: (qmail 68475 invoked by uid 99); 1 Feb 2013 23:27:31 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 01 Feb 2013 23:27:31 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 52A2082913D; Fri, 1 Feb 2013 23:27:31 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: kelveny@apache.org To: cloudstack-commits@incubator.apache.org X-Mailer: ASF-Git Admin Mailer Subject: [37/50] [abbrv] Sync javelin with master up to 894cb8f7d9fc8b5561754a9fa541fef8f235148a Message-Id: <20130201232731.52A2082913D@tyr.zones.apache.org> Date: Fri, 1 Feb 2013 23:27:31 +0000 (UTC) http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7bd8bec6/server/src/com/cloud/configuration/ConfigurationManagerImpl.java ---------------------------------------------------------------------- diff --cc server/src/com/cloud/configuration/ConfigurationManagerImpl.java index 7925ff8,c8acf3b..5c30e9a --- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java +++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java @@@ -2276,11 -2278,23 +2276,23 @@@ public class ConfigurationManagerImpl e @DB public Vlan createVlanAndPublicIpRange(long zoneId, long networkId, long physicalNetworkId, boolean forVirtualNetwork, Long podId, String startIP, String endIP, String vlanGateway, String vlanNetmask, - String vlanId, Account vlanOwner) { + String vlanId, Account vlanOwner, String startIPv6, String endIPv6, String vlanIp6Gateway, String vlanIp6Cidr) { + Network network = _networkModel.getNetwork(networkId); - + + boolean ipv4 = false, ipv6 = false; - + - Network network = _networkModel.getNetwork(networkId); + if (startIP != null) { + ipv4 = true; + } + + if (startIPv6 != null) { + ipv6 = true; + } + + if (!ipv4 && !ipv6) { + throw new InvalidParameterValueException("Please specify IPv4 or IPv6 address."); + } - + //Validate the zone DataCenterVO zone = _zoneDao.findById(zoneId); if (zone == null) { @@@ -2345,91 -2359,134 +2357,134 @@@ throw new InvalidParameterValueException("Vlan owner can be defined only in the zone of type " + NetworkType.Advanced); } + if (ipv4) { - // Make sure the gateway is valid - if (!NetUtils.isValidIp(vlanGateway)) { - throw new InvalidParameterValueException("Please specify a valid gateway"); - } + // Make sure the gateway is valid + if (!NetUtils.isValidIp(vlanGateway)) { + throw new InvalidParameterValueException("Please specify a valid gateway"); + } - // Make sure the netmask is valid - if (!NetUtils.isValidIp(vlanNetmask)) { - throw new InvalidParameterValueException("Please specify a valid netmask"); - } + // Make sure the netmask is valid + if (!NetUtils.isValidIp(vlanNetmask)) { + throw new InvalidParameterValueException("Please specify a valid netmask"); } - ++ } + + if (ipv6) { + if (!NetUtils.isValidIpv6(vlanIp6Gateway)) { + throw new InvalidParameterValueException("Please specify a valid IPv6 gateway"); + } + if (!NetUtils.isValidIp6Cidr(vlanIp6Cidr)) { + throw new InvalidParameterValueException("Please specify a valid IPv6 CIDR"); + } + } + + if (ipv4) { - String newVlanSubnet = NetUtils.getSubNet(vlanGateway, vlanNetmask); - - // Check if the new VLAN's subnet conflicts with the guest network in - // the specified zone (guestCidr is null for basic zone) - String guestNetworkCidr = zone.getGuestNetworkCidr(); - if (guestNetworkCidr != null) { - String[] cidrPair = guestNetworkCidr.split("\\/"); - String guestIpNetwork = NetUtils.getIpRangeStartIpFromCidr(cidrPair[0], Long.parseLong(cidrPair[1])); - long guestCidrSize = Long.parseLong(cidrPair[1]); - long vlanCidrSize = NetUtils.getCidrSize(vlanNetmask); - - long cidrSizeToUse = -1; - if (vlanCidrSize < guestCidrSize) { - cidrSizeToUse = vlanCidrSize; - } else { - cidrSizeToUse = guestCidrSize; - } + String newVlanSubnet = NetUtils.getSubNet(vlanGateway, vlanNetmask); - String guestSubnet = NetUtils.getCidrSubNet(guestIpNetwork, cidrSizeToUse); + // Check if the new VLAN's subnet conflicts with the guest network in + // the specified zone (guestCidr is null for basic zone) + String guestNetworkCidr = zone.getGuestNetworkCidr(); + if (guestNetworkCidr != null) { + String[] cidrPair = guestNetworkCidr.split("\\/"); + String guestIpNetwork = NetUtils.getIpRangeStartIpFromCidr(cidrPair[0], Long.parseLong(cidrPair[1])); + long guestCidrSize = Long.parseLong(cidrPair[1]); + long vlanCidrSize = NetUtils.getCidrSize(vlanNetmask); - if (newVlanSubnet.equals(guestSubnet)) { - throw new InvalidParameterValueException("The new IP range you have specified has the same subnet as the guest network in zone: " + zone.getName() - + ". Please specify a different gateway/netmask."); - } - } + long cidrSizeToUse = -1; + if (vlanCidrSize < guestCidrSize) { + cidrSizeToUse = vlanCidrSize; + } else { + cidrSizeToUse = guestCidrSize; + } - // Check if there are any errors with the IP range - checkPublicIpRangeErrors(zoneId, vlanId, vlanGateway, vlanNetmask, startIP, endIP); - - // Throw an exception if any of the following is true: - // 1. Another VLAN in the same zone has a different tag but the same - // subnet as the new VLAN. Make an exception for the - // case when both vlans are Direct. - // 2. Another VLAN in the same zone that has the same tag and subnet as - // the new VLAN has IPs that overlap with the IPs - // being added - // 3. Another VLAN in the same zone that has the same tag and subnet as - // the new VLAN has a different gateway than the - // new VLAN - // 4. If VLAN is untagged and Virtual, and there is existing UNTAGGED - // vlan with different subnet - List vlans = _vlanDao.listByZone(zone.getId()); - for (VlanVO vlan : vlans) { - String otherVlanGateway = vlan.getVlanGateway(); + String guestSubnet = NetUtils.getCidrSubNet(guestIpNetwork, cidrSizeToUse); + + if (newVlanSubnet.equals(guestSubnet)) { + throw new InvalidParameterValueException("The new IP range you have specified has the same subnet as the guest network in zone: " + zone.getName() + + ". Please specify a different gateway/netmask."); + } + } + + // Check if there are any errors with the IP range + checkPublicIpRangeErrors(zoneId, vlanId, vlanGateway, vlanNetmask, startIP, endIP); + + // Throw an exception if any of the following is true: + // 1. Another VLAN in the same zone has a different tag but the same + // subnet as the new VLAN. Make an exception for the + // case when both vlans are Direct. + // 2. Another VLAN in the same zone that has the same tag and subnet as + // the new VLAN has IPs that overlap with the IPs + // being added + // 3. Another VLAN in the same zone that has the same tag and subnet as + // the new VLAN has a different gateway than the + // new VLAN + // 4. If VLAN is untagged and Virtual, and there is existing UNTAGGED + // vlan with different subnet + List vlans = _vlanDao.listByZone(zone.getId()); + for (VlanVO vlan : vlans) { + String otherVlanGateway = vlan.getVlanGateway(); + // Continue if it's not IPv4 + if (otherVlanGateway == null) { + continue; + } - String otherVlanSubnet = NetUtils.getSubNet(vlan.getVlanGateway(), vlan.getVlanNetmask()); - String[] otherVlanIpRange = vlan.getIpRange().split("\\-"); - String otherVlanStartIP = otherVlanIpRange[0]; - String otherVlanEndIP = null; - if (otherVlanIpRange.length > 1) { - otherVlanEndIP = otherVlanIpRange[1]; - } + String otherVlanSubnet = NetUtils.getSubNet(vlan.getVlanGateway(), vlan.getVlanNetmask()); + String[] otherVlanIpRange = vlan.getIpRange().split("\\-"); + String otherVlanStartIP = otherVlanIpRange[0]; + String otherVlanEndIP = null; + if (otherVlanIpRange.length > 1) { + otherVlanEndIP = otherVlanIpRange[1]; + } - if (forVirtualNetwork && !vlanId.equals(vlan.getVlanTag()) && newVlanSubnet.equals(otherVlanSubnet) && !allowIpRangeOverlap(vlan, forVirtualNetwork, networkId)) { - throw new InvalidParameterValueException("The IP range with tag: " + vlan.getVlanTag() + " in zone " + zone.getName() - + " has the same subnet. Please specify a different gateway/netmask."); - } + if (forVirtualNetwork && !vlanId.equals(vlan.getVlanTag()) && newVlanSubnet.equals(otherVlanSubnet) && !allowIpRangeOverlap(vlan, forVirtualNetwork, networkId)) { + throw new InvalidParameterValueException("The IP range with tag: " + vlan.getVlanTag() + " in zone " + zone.getName() + + " has the same subnet. Please specify a different gateway/netmask."); + } - boolean vlansUntaggedAndVirtual = (vlanId.equals(Vlan.UNTAGGED) && vlanId.equals(vlan.getVlanTag()) && forVirtualNetwork && vlan.getVlanType() == VlanType.VirtualNetwork); + boolean vlansUntaggedAndVirtual = (vlanId.equals(Vlan.UNTAGGED) && vlanId.equals(vlan.getVlanTag()) && forVirtualNetwork && vlan.getVlanType() == VlanType.VirtualNetwork); - if (vlansUntaggedAndVirtual && !newVlanSubnet.equals(otherVlanSubnet)) { - throw new InvalidParameterValueException("The Untagged ip range with different subnet already exists in zone " + zone.getId()); - } + if (vlansUntaggedAndVirtual && !newVlanSubnet.equals(otherVlanSubnet)) { + throw new InvalidParameterValueException("The Untagged ip range with different subnet already exists in zone " + zone.getId()); + } - if (vlanId.equals(vlan.getVlanTag()) && newVlanSubnet.equals(otherVlanSubnet)) { - if (NetUtils.ipRangesOverlap(startIP, endIP, otherVlanStartIP, otherVlanEndIP)) { - throw new InvalidParameterValueException("The IP range with tag: " + vlan.getVlanTag() - + " already has IPs that overlap with the new range. Please specify a different start IP/end IP."); - } + if (vlanId.equals(vlan.getVlanTag()) && newVlanSubnet.equals(otherVlanSubnet)) { + if (NetUtils.ipRangesOverlap(startIP, endIP, otherVlanStartIP, otherVlanEndIP)) { + throw new InvalidParameterValueException("The IP range with tag: " + vlan.getVlanTag() + + " already has IPs that overlap with the new range. Please specify a different start IP/end IP."); + } - if (!vlanGateway.equals(otherVlanGateway)) { - throw new InvalidParameterValueException("The IP range with tag: " + vlan.getVlanTag() + " has already been added with gateway " + otherVlanGateway - + ". Please specify a different tag."); - } - } - } + if (!vlanGateway.equals(otherVlanGateway)) { + throw new InvalidParameterValueException("The IP range with tag: " + vlan.getVlanTag() + " has already been added with gateway " + otherVlanGateway + + ". Please specify a different tag."); + } + } + } + } + + String ipv6Range = null; + if (ipv6) { + ipv6Range = startIPv6; + if (endIPv6 != null) { + ipv6Range += "-" + endIPv6; + } + + List vlans = _vlanDao.listByZone(zone.getId()); + for (VlanVO vlan : vlans) { + if (vlan.getIp6Gateway() == null) { + continue; + } + if (vlanId.equals(vlan.getVlanTag())) { + if (NetUtils.isIp6RangeOverlap(ipv6Range, vlan.getIp6Range())) { + throw new InvalidParameterValueException("The IPv6 range with tag: " + vlan.getVlanTag() + + " already has IPs that overlap with the new range. Please specify a different start IP/end IP."); + } + + if (!vlanIp6Gateway.equals(vlan.getIp6Gateway())) { + throw new InvalidParameterValueException("The IP range with tag: " + vlan.getVlanTag() + " has already been added with gateway " + vlan.getIp6Gateway() + + ". Please specify a different tag."); + } + } + } + } // Check if a guest VLAN is using the same tag if (_zoneDao.findVnet(zoneId, physicalNetworkId, vlanId).size() > 0) { @@@ -2450,11 -2507,15 +2505,15 @@@ } } - String ipRange = startIP; + String ipRange = null; + + if (ipv4) { + ipRange = startIP; - if (endIP != null) { - ipRange += "-" + endIP; - } + if (endIP != null) { + ipRange += "-" + endIP; } - ++ } + // Everything was fine, so persist the VLAN Transaction txn = Transaction.currentTxn(); txn.start(); @@@ -2463,8 -2524,11 +2522,11 @@@ s_logger.debug("Saving vlan range " + vlan); vlan = _vlanDao.persist(vlan); + // IPv6 use a used ip map, is different from ipv4, no need to save public ip range + if (ipv4) { - if (!savePublicIPRange(startIP, endIP, zoneId, vlan.getId(), networkId, physicalNetworkId)) { + if (!savePublicIPRange(startIP, endIP, zoneId, vlan.getId(), networkId, physicalNetworkId)) { - throw new CloudRuntimeException("Failed to save IP range. Please contact Cloud Support."); + throw new CloudRuntimeException("Failed to save IPv4 range. Please contact Cloud Support."); + } } if (vlanOwner != null) { http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7bd8bec6/server/src/com/cloud/network/Ipv6AddressManagerImpl.java ---------------------------------------------------------------------- diff --cc server/src/com/cloud/network/Ipv6AddressManagerImpl.java index 0000000,6666596..0122772 mode 000000,100644..100644 --- a/server/src/com/cloud/network/Ipv6AddressManagerImpl.java +++ b/server/src/com/cloud/network/Ipv6AddressManagerImpl.java @@@ -1,0 -1,132 +1,109 @@@ + // 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.network; + + import java.util.Map; + + import javax.ejb.Local; ++import javax.inject.Inject; + import javax.naming.ConfigurationException; + + import org.apache.log4j.Logger; + + import com.cloud.dc.DataCenterVO; + import com.cloud.dc.Vlan; + import com.cloud.dc.dao.DataCenterDao; + import com.cloud.dc.dao.VlanDao; + import com.cloud.exception.InsufficientAddressCapacityException; + import com.cloud.network.dao.UserIpv6AddressDao; + import com.cloud.user.Account; -import com.cloud.utils.component.Inject; ++import com.cloud.utils.component.ManagerBase; + import com.cloud.utils.exception.CloudRuntimeException; + import com.cloud.utils.net.NetUtils; + + @Local(value = { Ipv6AddressManager.class } ) -public class Ipv6AddressManagerImpl implements Ipv6AddressManager { ++public class Ipv6AddressManagerImpl extends ManagerBase implements Ipv6AddressManager { + public static final Logger s_logger = Logger.getLogger(Ipv6AddressManagerImpl.class.getName()); + - String _name = null; - + @Inject + DataCenterDao _dcDao; + @Inject + VlanDao _vlanDao; + @Inject + NetworkModel _networkModel; + @Inject + UserIpv6AddressDao _ipv6Dao; + + @Override - public boolean configure(String name, Map params) - throws ConfigurationException { - _name = name; - return true; - } - - @Override - public boolean start() { - return true; - } - - @Override - public boolean stop() { - return true; - } - - @Override - public String getName() { - return _name; - } - - @Override + public UserIpv6Address assignDirectIp6Address(long dcId, Account owner, Long networkId, String requestedIp6) + throws InsufficientAddressCapacityException { + Vlan vlan = _networkModel.getVlanForNetwork(networkId); + if (vlan == null) { + s_logger.debug("Cannot find related vlan or too many vlan attached to network " + networkId); + return null; + } + String ip = null; + if (requestedIp6 == null) { + int count = 0; + while (ip == null || count >= 10) { + ip = NetUtils.getIp6FromRange(vlan.getIp6Range()); + //Check for duplicate IP + if (_ipv6Dao.findByNetworkIdAndIp(networkId, ip) == null) { + break; + } else { + ip = null; + } + count ++; + } + if (ip == null) { + throw new CloudRuntimeException("Fail to get unique ipv6 address after 10 times trying!"); + } + } else { + if (!NetUtils.isIp6InRange(requestedIp6, vlan.getIp6Range())) { + throw new CloudRuntimeException("Requested IPv6 is not in the predefined range!"); + } + ip = requestedIp6; + if (_ipv6Dao.findByNetworkIdAndIp(networkId, ip) != null) { + throw new CloudRuntimeException("The requested IP is already taken!"); + } + } + DataCenterVO dc = _dcDao.findById(dcId); + Long mac = dc.getMacAddress(); + Long nextMac = mac + 1; + dc.setMacAddress(nextMac); + _dcDao.update(dc.getId(), dc); + + String macAddress = NetUtils.long2Mac(NetUtils.createSequenceBasedMacAddress(mac)); + UserIpv6AddressVO ipVO = new UserIpv6AddressVO(ip, dcId, macAddress, vlan.getId()); + ipVO.setPhysicalNetworkId(vlan.getPhysicalNetworkId()); + ipVO.setSourceNetworkId(vlan.getNetworkId()); + ipVO.setState(UserIpv6Address.State.Allocated); + ipVO.setDomainId(owner.getDomainId()); + ipVO.setAccountId(owner.getAccountId()); + _ipv6Dao.persist(ipVO); + return ipVO; + } + + @Override + public void revokeDirectIpv6Address(long networkId, String ip6Address) { + UserIpv6AddressVO ip = _ipv6Dao.findByNetworkIdAndIp(networkId, ip6Address); + if (ip != null) { + _ipv6Dao.remove(ip.getId()); + } + } + } http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7bd8bec6/server/src/com/cloud/network/NetworkManager.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7bd8bec6/server/src/com/cloud/network/NetworkManagerImpl.java ---------------------------------------------------------------------- diff --cc server/src/com/cloud/network/NetworkManagerImpl.java index 0235bf1,67568da..643f1a4 --- a/server/src/com/cloud/network/NetworkManagerImpl.java +++ b/server/src/com/cloud/network/NetworkManagerImpl.java @@@ -119,7 -112,7 +119,8 @@@ import com.cloud.network.dao.PhysicalNe import com.cloud.network.dao.PhysicalNetworkServiceProviderDao; import com.cloud.network.dao.PhysicalNetworkTrafficTypeDao; import com.cloud.network.dao.PhysicalNetworkTrafficTypeVO; +import com.cloud.network.dao.PhysicalNetworkVO; + import com.cloud.network.dao.UserIpv6AddressDao; import com.cloud.network.element.DhcpServiceProvider; import com.cloud.network.element.IpDeployer; import com.cloud.network.element.LoadBalancingServiceProvider; @@@ -1313,10 -1317,8 +1318,8 @@@ public class NetworkManagerImpl extend vo.setDefaultNic(profile.isDefaultNic()); - if (profile.getIp4Address() != null) { - vo.setIp4Address(profile.getIp4Address()); + vo.setIp4Address(profile.getIp4Address()); - vo.setAddressFormat(AddressFormat.Ip4); - } + vo.setAddressFormat(profile.getFormat()); if (profile.getMacAddress() != null) { vo.setMacAddress(profile.getMacAddress()); @@@ -1967,11 -1986,11 +1987,11 @@@ throw new InvalidParameterValueException("StartIp/endIp/gateway/netmask can't be specified for zone of type " + NetworkType.Basic); } - // Check if cidr is RFC1918 compliant if the network is Guest Isolated + // Check if cidr is RFC1918 compliant if the network is Guest Isolated for IPv4 if (cidr != null && ntwkOff.getGuestType() == Network.GuestType.Isolated && ntwkOff.getTrafficType() == TrafficType.Guest) { - if (!NetUtils.validateGuestCidr(cidr)) { - throw new InvalidParameterValueException("Virtual Guest Cidr " + cidr + " is not RFC1918 compliant"); - } + if (!NetUtils.validateGuestCidr(cidr)) { + throw new InvalidParameterValueException("Virtual Guest Cidr " + cidr + " is not RFC1918 compliant"); + } } Transaction txn = Transaction.currentTxn(); @@@ -1998,7 -2017,21 +2018,21 @@@ } } } - + + if (ip6Cidr != null && ip6Gateway != null) { + userNetwork.setIp6Cidr(ip6Cidr); + userNetwork.setIp6Gateway(ip6Gateway); + if (vlanId != null) { + userNetwork.setBroadcastUri(URI.create("vlan://" + vlanId)); + userNetwork.setBroadcastDomainType(BroadcastDomainType.Vlan); + if (!vlanId.equalsIgnoreCase(Vlan.UNTAGGED)) { + userNetwork.setBroadcastDomainType(BroadcastDomainType.Vlan); + } else { + userNetwork.setBroadcastDomainType(BroadcastDomainType.Native); + } + } + } + List networks = setupNetwork(owner, ntwkOff, userNetwork, plan, name, displayText, true, domainId, aclType, subdomainAccess, vpcId); @@@ -2566,12 -2599,12 +2600,12 @@@ throw new InvalidParameterValueException("Unable to find physical network with id: "+physicalNetworkId + " and tag: " +requiredOfferings.get(0).getTags()); } - s_logger.debug("Creating network for account " + owner + " from the network offering id=" + - requiredOfferings.get(0).getId() + " as a part of createVlanIpRange process"); + s_logger.debug("Creating network for account " + owner + " from the network offering id=" + + requiredOfferings.get(0).getId() + " as a part of createVlanIpRange process"); guestNetwork = createGuestNetwork(requiredOfferings.get(0).getId(), owner.getAccountName() + "-network" - , owner.getAccountName() + "-network", null, null, null, null, owner, null, physicalNetwork, + , owner.getAccountName() + "-network", null, null, null, null, owner, null, physicalNetwork, zoneId, ACLType.Account, - null, null); + null, null, null, null); if (guestNetwork == null) { s_logger.warn("Failed to create default Virtual network for the account " + accountId + "in zone " + zoneId); throw new CloudRuntimeException("Failed to create a Guest Isolated Networks with SourceNAT " + @@@ -3347,28 -3380,56 +3381,56 @@@ return success; } - @Override - public void allocateDirectIp(NicProfile nic, DataCenter dc, VirtualMachineProfile vm, Network network, String requestedIp) throws InsufficientVirtualNetworkCapcityException, + public void allocateDirectIp(NicProfile nic, DataCenter dc, VirtualMachineProfile vm, Network network, + String requestedIpv4, String requestedIpv6) throws InsufficientVirtualNetworkCapcityException, - InsufficientAddressCapacityException { + InsufficientAddressCapacityException { + boolean ipv4 = false, ipv6 = false; + if (network.getGateway() != null) { - if (nic.getIp4Address() == null) { + if (nic.getIp4Address() == null) { - PublicIp ip = assignPublicIpAddress(dc.getId(), null, vm.getOwner(), VlanType.DirectAttached, network.getId(), requestedIp, false); + ipv4 = true; + PublicIp ip = assignPublicIpAddress(dc.getId(), null, vm.getOwner(), VlanType.DirectAttached, network.getId(), requestedIpv4, false); - nic.setIp4Address(ip.getAddress().toString()); - nic.setGateway(ip.getGateway()); - nic.setNetmask(ip.getNetmask()); - nic.setIsolationUri(IsolationType.Vlan.toUri(ip.getVlanTag())); - nic.setBroadcastType(BroadcastDomainType.Vlan); - nic.setBroadcastUri(BroadcastDomainType.Vlan.toUri(ip.getVlanTag())); - nic.setFormat(AddressFormat.Ip4); - nic.setReservationId(String.valueOf(ip.getVlanTag())); - nic.setMacAddress(ip.getMacAddress()); - } + nic.setIp4Address(ip.getAddress().toString()); + nic.setGateway(ip.getGateway()); + nic.setNetmask(ip.getNetmask()); + nic.setIsolationUri(IsolationType.Vlan.toUri(ip.getVlanTag())); + nic.setBroadcastType(BroadcastDomainType.Vlan); + nic.setBroadcastUri(BroadcastDomainType.Vlan.toUri(ip.getVlanTag())); + nic.setFormat(AddressFormat.Ip4); + nic.setReservationId(String.valueOf(ip.getVlanTag())); + nic.setMacAddress(ip.getMacAddress()); + } + } + + if (network.getIp6Gateway() != null) { + if (nic.getIp6Address() == null) { + ipv6 = true; + UserIpv6Address ip = _ipv6Mgr.assignDirectIp6Address(dc.getId(), vm.getOwner(), network.getId(), requestedIpv6); + Vlan vlan = _networkModel.getVlanForNetwork(network.getId()); + if (vlan == null) { + s_logger.debug("Cannot find related vlan or too many vlan attached to network " + network.getId()); + return; + } + nic.setIp6Address(ip.getAddress().toString()); + nic.setIp6Gateway(vlan.getIp6Gateway()); + nic.setIp6Cidr(vlan.getIp6Cidr()); + if (ipv4) { + nic.setFormat(AddressFormat.DualStack); + } else { + nic.setIsolationUri(IsolationType.Vlan.toUri(vlan.getVlanTag())); + nic.setBroadcastType(BroadcastDomainType.Vlan); + nic.setBroadcastUri(BroadcastDomainType.Vlan.toUri(vlan.getVlanTag())); + nic.setFormat(AddressFormat.Ip6); + nic.setReservationId(String.valueOf(vlan.getVlanTag())); + nic.setMacAddress(ip.getMacAddress()); + } + } + } nic.setDns1(dc.getDns1()); nic.setDns2(dc.getDns2()); } - - @Override + @Override public boolean setupDns(Network network, Provider provider) { boolean dnsProvided = _networkModel.isProviderSupportServiceInNetwork(network.getId(), Service.Dns, provider ); boolean dhcpProvided =_networkModel.isProviderSupportServiceInNetwork(network.getId(), Service.Dhcp, http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7bd8bec6/server/src/com/cloud/network/NetworkModelImpl.java ---------------------------------------------------------------------- diff --cc server/src/com/cloud/network/NetworkModelImpl.java index 7aba59f,a74b589..ff97911 --- a/server/src/com/cloud/network/NetworkModelImpl.java +++ b/server/src/com/cloud/network/NetworkModelImpl.java @@@ -71,7 -66,7 +72,8 @@@ import com.cloud.network.dao.PhysicalNe import com.cloud.network.dao.PhysicalNetworkServiceProviderVO; import com.cloud.network.dao.PhysicalNetworkTrafficTypeDao; import com.cloud.network.dao.PhysicalNetworkTrafficTypeVO; +import com.cloud.network.dao.PhysicalNetworkVO; + import com.cloud.network.dao.UserIpv6AddressDao; import com.cloud.network.element.NetworkElement; import com.cloud.network.element.UserDataServiceProvider; import com.cloud.network.rules.FirewallRule.Purpose; @@@ -516,7 -513,15 +519,15 @@@ public class NetworkModelImpl extends M } boolean hasFreeIps = true; if (network.getGuestType() == GuestType.Shared) { + if (network.getGateway() != null) { - hasFreeIps = _ipAddressDao.countFreeIPsInNetwork(network.getId()) > 0; + hasFreeIps = _ipAddressDao.countFreeIPsInNetwork(network.getId()) > 0; + } + if (!hasFreeIps) { + return false; + } + if (network.getIp6Gateway() != null) { + hasFreeIps = isIP6AddressAvailable(network); + } } else { hasFreeIps = (getAvailableIps(network, null)).size() > 0; } @@@ -524,9 -529,27 +535,27 @@@ return hasFreeIps; } + @Override + public Vlan getVlanForNetwork(long networkId) { + List vlans = _vlanDao.listVlansByNetworkId(networkId); + if (vlans == null || vlans.size() > 1) { + s_logger.debug("Cannot find related vlan or too many vlan attached to network " + networkId); + return null; + } + return vlans.get(0); + } - + + private boolean isIP6AddressAvailable(Network network) { + if (network.getIp6Gateway() == null) { + return false; + } + Vlan vlan = getVlanForNetwork(network.getId()); + long existedCount = _ipv6Dao.countExistedIpsInNetwork(network.getId()); + long rangeCount = NetUtils.countIp6InRange(vlan.getIp6Range()); + return (existedCount < rangeCount); + } - @Override + @Override public Map> getNetworkCapabilities(long networkId) { Map> networkCapabilities = new HashMap>(); http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7bd8bec6/server/src/com/cloud/network/NetworkServiceImpl.java ---------------------------------------------------------------------- diff --cc server/src/com/cloud/network/NetworkServiceImpl.java index 9020281,4467727..f0282ab --- a/server/src/com/cloud/network/NetworkServiceImpl.java +++ b/server/src/com/cloud/network/NetworkServiceImpl.java @@@ -727,37 -735,90 +731,90 @@@ public class NetworkServiceImpl extend UserContext.current().setAccountId(owner.getAccountId()); - // VALIDATE IP INFO + boolean ipv4 = false, ipv6 = false; + if (startIP != null) { + ipv4 = true; + } + if (startIPv6 != null) { + ipv6 = true; + } + + String cidr = null; + if (ipv4) { - // if end ip is not specified, default it to startIp - if (startIP != null) { - if (!NetUtils.isValidIp(startIP)) { - throw new InvalidParameterValueException("Invalid format for the startIp parameter"); - } - if (endIP == null) { - endIP = startIP; - } else if (!NetUtils.isValidIp(endIP)) { - throw new InvalidParameterValueException("Invalid format for the endIp parameter"); - } - } + // if end ip is not specified, default it to startIp + if (startIP != null) { + if (!NetUtils.isValidIp(startIP)) { + throw new InvalidParameterValueException("Invalid format for the startIp parameter"); + } + if (endIP == null) { + endIP = startIP; + } else if (!NetUtils.isValidIp(endIP)) { + throw new InvalidParameterValueException("Invalid format for the endIp parameter"); + } + } - if (startIP != null && endIP != null) { - if (!(gateway != null && netmask != null)) { - throw new InvalidParameterValueException("gateway and netmask should be defined when startIP/endIP are passed in"); - } - } + if (startIP != null && endIP != null) { + if (!(gateway != null && netmask != null)) { + throw new InvalidParameterValueException("gateway and netmask should be defined when startIP/endIP are passed in"); + } + } - String cidr = null; - if (gateway != null && netmask != null) { - if (!NetUtils.isValidIp(gateway)) { - throw new InvalidParameterValueException("Invalid gateway"); - } - if (!NetUtils.isValidNetmask(netmask)) { - throw new InvalidParameterValueException("Invalid netmask"); - } + if (gateway != null && netmask != null) { + if (!NetUtils.isValidIp(gateway)) { + throw new InvalidParameterValueException("Invalid gateway"); + } + if (!NetUtils.isValidNetmask(netmask)) { + throw new InvalidParameterValueException("Invalid netmask"); + } - cidr = NetUtils.ipAndNetMaskToCidr(gateway, netmask); - } + cidr = NetUtils.ipAndNetMaskToCidr(gateway, netmask); + } + } + + if (ipv6) { + if (!NetUtils.isValidIpv6(startIPv6)) { + throw new InvalidParameterValueException("Invalid format for the startIPv6 parameter"); + } + if (endIPv6 == null) { + endIPv6 = startIPv6; + } else if (!NetUtils.isValidIpv6(endIPv6)) { + throw new InvalidParameterValueException("Invalid format for the endIPv6 parameter"); + } + + if (!(ip6Gateway != null && ip6Cidr != null)) { + throw new InvalidParameterValueException("ip6Gateway and ip6Cidr should be defined when startIPv6/endIPv6 are passed in"); + } + + if (!NetUtils.isValidIpv6(ip6Gateway)) { + throw new InvalidParameterValueException("Invalid ip6Gateway"); + } + if (!NetUtils.isValidIp6Cidr(ip6Cidr)) { + throw new InvalidParameterValueException("Invalid ip6cidr"); + } + if (!NetUtils.isIp6InRange(startIPv6, ip6Cidr)) { + throw new InvalidParameterValueException("startIPv6 is not in ip6cidr indicated network range!"); + } + if (!NetUtils.isIp6InRange(endIPv6, ip6Cidr)) { + throw new InvalidParameterValueException("endIPv6 is not in ip6cidr indicated network range!"); + } + if (!NetUtils.isIp6InRange(ip6Gateway, ip6Cidr)) { + throw new InvalidParameterValueException("ip6Gateway is not in ip6cidr indicated network range!"); + } + + int cidrSize = NetUtils.getIp6CidrSize(ip6Cidr); + // Ipv6 cidr limit should be at least /64 + if (cidrSize < 64) { + throw new InvalidParameterValueException("The cidr size of IPv6 network must be no less than 64 bits!"); + } + } + + if (ipv6) { + if (zone.getNetworkType() != NetworkType.Advanced || ntwkOff.getGuestType() != Network.GuestType.Shared) { + throw new InvalidParameterValueException("Can only support create IPv6 network with advance shared network!"); + } + } + // Regular user can create Guest Isolated Source Nat enabled network only if (caller.getType() == Account.ACCOUNT_TYPE_NORMAL && (ntwkOff.getTrafficType() != TrafficType.Guest || ntwkOff.getGuestType() != Network.GuestType.Isolated @@@ -771,19 -832,25 +828,25 @@@ if (caller.getType() == Account.ACCOUNT_TYPE_NORMAL && (ntwkOff.getSpecifyVlan() || vlanId != null)) { throw new InvalidParameterValueException("Regular user is not allowed to specify vlanId"); } - + + if (ipv4) { - // For non-root admins check cidr limit - if it's allowed by global config value - if (caller.getType() != Account.ACCOUNT_TYPE_ADMIN && cidr != null) { + // For non-root admins check cidr limit - if it's allowed by global config value + if (caller.getType() != Account.ACCOUNT_TYPE_ADMIN && cidr != null) { - String[] cidrPair = cidr.split("\\/"); - int cidrSize = Integer.valueOf(cidrPair[1]); + String[] cidrPair = cidr.split("\\/"); + int cidrSize = Integer.valueOf(cidrPair[1]); - if (cidrSize < _cidrLimit) { - throw new InvalidParameterValueException("Cidr size can't be less than " + _cidrLimit); - } - } + if (cidrSize < _cidrLimit) { + throw new InvalidParameterValueException("Cidr size can't be less than " + _cidrLimit); + } + } + } Collection ntwkProviders = _networkMgr.finalizeServicesAndProvidersForNetwork(ntwkOff, physicalNetworkId).values(); + if (ipv6 && providersConfiguredForExternalNetworking(ntwkProviders)) { + throw new InvalidParameterValueException("Cannot support IPv6 on network offering with external devices!"); + } + if (cidr != null && providersConfiguredForExternalNetworking(ntwkProviders)) { if (ntwkOff.getGuestType() == GuestType.Shared && (zone.getNetworkType() == NetworkType.Advanced) && isSharedNetworkOfferingWithServices(networkOfferingId)) { @@@ -800,9 -866,16 +862,16 @@@ // 2) GuestType is Isolated, but SourceNat service is disabled boolean createVlan = (startIP != null && endIP != null && zone.getNetworkType() == NetworkType.Advanced && ((ntwkOff.getGuestType() == Network.GuestType.Shared) - || (ntwkOff.getGuestType() == GuestType.Isolated && - !areServicesSupportedByNetworkOffering(ntwkOff.getId(), Service.SourceNat)))); - + || (ntwkOff.getGuestType() == GuestType.Isolated && + !areServicesSupportedByNetworkOffering(ntwkOff.getId(), Service.SourceNat)))); + + if (!createVlan) { + // Only support advance shared network in IPv6, which means createVlan is a must + if (ipv6) { + createVlan = true; + } + } + // Can add vlan range only to the network which allows it if (createVlan && !ntwkOff.getSpecifyIpRanges()) { InvalidParameterValueException ex = new InvalidParameterValueException("Network offering with specified id doesn't support adding multiple ip ranges"); http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7bd8bec6/server/src/com/cloud/network/addr/PublicIp.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7bd8bec6/server/src/com/cloud/network/dao/NetworkVO.java ---------------------------------------------------------------------- diff --cc server/src/com/cloud/network/dao/NetworkVO.java index b89cb65,0000000..5ecb22f mode 100644,000000..100644 --- a/server/src/com/cloud/network/dao/NetworkVO.java +++ b/server/src/com/cloud/network/dao/NetworkVO.java @@@ -1,499 -1,0 +1,523 @@@ +// 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.network.dao; + +import java.net.URI; +import java.util.Date; +import java.util.UUID; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.EnumType; +import javax.persistence.Enumerated; +import javax.persistence.Id; +import javax.persistence.Table; +import javax.persistence.TableGenerator; +import javax.persistence.Transient; + +import org.apache.cloudstack.acl.ControlledEntity; + +import com.cloud.network.Network; +import com.cloud.network.Networks; +import com.cloud.network.Network.GuestType; +import com.cloud.network.Network.State; +import com.cloud.network.Networks.BroadcastDomainType; +import com.cloud.network.Networks.Mode; +import com.cloud.network.Networks.TrafficType; +import com.cloud.utils.NumbersUtil; +import com.cloud.utils.db.GenericDao; +import com.cloud.utils.net.NetUtils; + +/** + * NetworkConfigurationVO contains information about a specific network. + * + */ +@Entity +@Table(name="networks") +public class NetworkVO implements Network { + @Id + @TableGenerator(name="networks_sq", table="sequence", pkColumnName="name", valueColumnName="value", pkColumnValue="networks_seq", allocationSize=1) + @Column(name="id") + long id; + + @Column(name="mode") + @Enumerated(value=EnumType.STRING) + Mode mode; + + @Column(name="broadcast_domain_type") + @Enumerated(value=EnumType.STRING) + BroadcastDomainType broadcastDomainType; + + @Column(name="traffic_type") + @Enumerated(value=EnumType.STRING) + TrafficType trafficType; + + @Column(name="name") + String name; + + @Column(name="display_text") + String displayText;; + + @Column(name="broadcast_uri") + URI broadcastUri; + + @Column(name="gateway") + String gateway; + + @Column(name="cidr") + String cidr; + + @Column(name="network_offering_id") + long networkOfferingId; + + @Column(name="vpc_id") + Long vpcId; + + @Column(name="physical_network_id") + Long physicalNetworkId; + + @Column(name="data_center_id") + long dataCenterId; + + @Column(name="related") + long related; + + @Column(name="guru_name") + String guruName; + + @Column(name="state") + @Enumerated(value=EnumType.STRING) + State state; + + @Column(name="dns1") + String dns1; + + @Column(name="domain_id") + long domainId; + + @Column(name="account_id") + long accountId; + + @Column(name="set_fields") + long setFields; + + @TableGenerator(name="mac_address_seq", table="op_networks", pkColumnName="id", valueColumnName="mac_address_seq", allocationSize=1) + @Transient + long macAddress = 1; + + @Column(name="guru_data", length=1024) + String guruData; + + @Column(name="dns2") + String dns2; + + @Column(name="network_domain") + String networkDomain; + + @Column(name=GenericDao.REMOVED_COLUMN) + Date removed; + + @Column(name=GenericDao.CREATED_COLUMN) + Date created; + + @Column(name="reservation_id") + String reservationId; + + @Column(name="uuid") + String uuid; + + @Column(name="guest_type") + @Enumerated(value=EnumType.STRING) + Network.GuestType guestType; + + @Column(name="acl_type") + @Enumerated(value=EnumType.STRING) + ControlledEntity.ACLType aclType; + + @Column(name="restart_required") + boolean restartRequired = false; + + @Column(name="specify_ip_ranges") + boolean specifyIpRanges = false; + ++ @Column(name="ip6_gateway") ++ String ip6Gateway; ++ ++ @Column(name="ip6_cidr") ++ String ip6Cidr; ++ + public NetworkVO() { + this.uuid = UUID.randomUUID().toString(); + } + + /** + * Constructor to be used for the adapters because it only initializes what's needed. + * @param trafficType + * @param mode + * @param broadcastDomainType + * @param networkOfferingId + * @param state TODO + * @param dataCenterId + * @param physicalNetworkId TODO + */ + public NetworkVO(TrafficType trafficType, Mode mode, BroadcastDomainType broadcastDomainType, long networkOfferingId, + State state, long dataCenterId, Long physicalNetworkId) { + this.trafficType = trafficType; + this.mode = mode; + this.broadcastDomainType = broadcastDomainType; + this.networkOfferingId = networkOfferingId; + this.dataCenterId = dataCenterId; + this.physicalNetworkId = physicalNetworkId; + if (state == null) { + state = State.Allocated; + } else { + this.state = state; + } + this.id = -1; + this.uuid = UUID.randomUUID().toString(); + } + + public NetworkVO(long id, Network that, long offeringId, String guruName, long domainId, long accountId, + long related, String name, String displayText, String networkDomain, GuestType guestType, long dcId, + Long physicalNetworkId, ACLType aclType, boolean specifyIpRanges, Long vpcId) { + this(id, that.getTrafficType(), that.getMode(), that.getBroadcastDomainType(), offeringId, domainId, accountId, + related, name, displayText, networkDomain, guestType, dcId, physicalNetworkId, aclType, specifyIpRanges, vpcId); + this.gateway = that.getGateway(); + this.cidr = that.getCidr(); + this.broadcastUri = that.getBroadcastUri(); + this.broadcastDomainType = that.getBroadcastDomainType(); + this.guruName = guruName; + this.state = that.getState(); + if (state == null) { + state = State.Allocated; + } + this.uuid = UUID.randomUUID().toString(); ++ this.ip6Gateway = that.getIp6Gateway(); ++ this.ip6Cidr = that.getIp6Cidr(); + } + + /** + * Constructor for the actual DAO object. + * @param trafficType + * @param mode + * @param broadcastDomainType + * @param networkOfferingId + * @param domainId + * @param accountId + * @param name + * @param displayText + * @param networkDomain + * @param guestType TODO + * @param aclType TODO + * @param specifyIpRanges TODO + * @param vpcId TODO + * @param dataCenterId + */ + public NetworkVO(long id, TrafficType trafficType, Mode mode, BroadcastDomainType broadcastDomainType, + long networkOfferingId, long domainId, long accountId, long related, String name, String displayText, + String networkDomain, GuestType guestType, long dcId, Long physicalNetworkId, ACLType aclType, boolean specifyIpRanges, Long vpcId) { + this(trafficType, mode, broadcastDomainType, networkOfferingId, State.Allocated, dcId, physicalNetworkId); + this.domainId = domainId; + this.accountId = accountId; + this.related = related; + this.id = id; + this.name = name; + this.displayText = displayText; + this.aclType = aclType; + this.networkDomain = networkDomain; + this.uuid = UUID.randomUUID().toString(); + this.guestType = guestType; + this.specifyIpRanges = specifyIpRanges; + this.vpcId = vpcId; + } + + @Override + public String getReservationId() { + return reservationId; + } + + public void setReservationId(String reservationId) { + this.reservationId = reservationId; + } + + @Override + public State getState() { + return state; + } + + public void setState(State state) { + this.state = state; + } + + @Override + public long getRelated() { + return related; + } + + @Override + public long getId() { + return id; + } + + @Override + public Mode getMode() { + return mode; + } + + @Override + public long getAccountId() { + return accountId; + } + + @Override + public long getDomainId() { + return domainId; + } + + @Override + public long getNetworkOfferingId() { + return networkOfferingId; + } + + public void setNetworkOfferingId(long networkOfferingId) { + this.networkOfferingId = networkOfferingId; + } + + public void setMode(Mode mode) { + this.mode = mode; + } + + @Override + public BroadcastDomainType getBroadcastDomainType() { + return broadcastDomainType; + } + + public String getGuruData() { + return guruData; + } + + public void setGuruData(String guruData) { + this.guruData = guruData; + } + + public String getGuruName() { + return guruName; + } + + public void setGuruName(String guruName) { + this.guruName = guruName; + } + + public void setBroadcastDomainType(BroadcastDomainType broadcastDomainType) { + this.broadcastDomainType = broadcastDomainType; + } + + @Override + public String getNetworkDomain() { + return networkDomain; + } + + public void setNetworkDomain(String networkDomain) { + this.networkDomain = networkDomain; + } + + @Override + public TrafficType getTrafficType() { + return trafficType; + } + + public void setTrafficType(TrafficType trafficType) { + this.trafficType = trafficType; + } + + @Override + public String getGateway() { + return gateway; + } + + public void setGateway(String gateway) { + this.gateway = gateway; + } + + @Override + public String getCidr() { + return cidr; + } + + public void setCidr(String cidr) { + this.cidr = cidr; + } + + @Override + public URI getBroadcastUri() { + return broadcastUri; + } + + public void setBroadcastUri(URI broadcastUri) { + this.broadcastUri = broadcastUri; + } + + @Override + public int hashCode() { + return NumbersUtil.hash(id); + } + + @Override + public Long getPhysicalNetworkId() { + return physicalNetworkId; + } + + @Override + public void setPhysicalNetworkId(Long physicalNetworkId) { + this.physicalNetworkId = physicalNetworkId; + } + + @Override + public long getDataCenterId() { + return dataCenterId; + } + + public String getDns1() { + return dns1; + } + + public void setDns1(String dns) { + this.dns1 = dns; + } + + public String getDns2() { + return dns2; + } + + public void setDns2(String dns) { + this.dns2 = dns; + } + + @Override + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Override + public String getDisplayText() { + return displayText; + } + + public void setDisplayText(String displayText) { + this.displayText = displayText; + } + + public Date getRemoved() { + return removed; + } + + public void setRemoved(Date removed) { + this.removed = removed; + } + + public Date getCreated() { + return created; + } + + public void setCreated(Date created) { + this.created = created; + } + + @Override + public Network.GuestType getGuestType() { + return guestType; + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof NetworkVO)) { + return false; + } + NetworkVO that = (NetworkVO)obj; + if (this.trafficType != that.trafficType) { + return false; + } + + if ((this.cidr == null && that.cidr != null) || (this.cidr != null && that.cidr == null)) { + return false; + } + + if (this.cidr == null && that.cidr == null) { + return true; + } + + return NetUtils.isNetworkAWithinNetworkB(this.cidr, that.cidr); + } + + @Override + public String toString() { + StringBuilder buf = new StringBuilder("Ntwk["); + buf.append(id).append("|").append(trafficType).append("|").append(networkOfferingId).append("]"); + return buf.toString(); + } + + public String getUuid() { + return this.uuid; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + public ControlledEntity.ACLType getAclType() { + return aclType; + } + + public void setRestartRequired(boolean restartRequired) { + this.restartRequired = restartRequired; + } + + @Override + public boolean isRestartRequired() { + return restartRequired; + } + + @Override + public boolean getSpecifyIpRanges() { + return specifyIpRanges; + } + + @Override + public Long getVpcId() { + return vpcId; + } ++ ++ public String getIp6Cidr() { ++ return ip6Cidr; ++ } ++ ++ public void setIp6Cidr(String ip6Cidr) { ++ this.ip6Cidr = ip6Cidr; ++ } ++ ++ public String getIp6Gateway() { ++ return ip6Gateway; ++ } ++ ++ public void setIp6Gateway(String ip6Gateway) { ++ this.ip6Gateway = ip6Gateway; ++ } +} http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7bd8bec6/server/src/com/cloud/network/dao/UserIpv6AddressDaoImpl.java ---------------------------------------------------------------------- diff --cc server/src/com/cloud/network/dao/UserIpv6AddressDaoImpl.java index 0000000,6989c40..14935c3 mode 000000,100644..100644 --- a/server/src/com/cloud/network/dao/UserIpv6AddressDaoImpl.java +++ b/server/src/com/cloud/network/dao/UserIpv6AddressDaoImpl.java @@@ -1,0 -1,96 +1,98 @@@ + package com.cloud.network.dao; + + import java.util.List; + import java.util.Map; + + import javax.ejb.Local; + import javax.naming.ConfigurationException; + + import org.apache.log4j.Logger; ++import org.springframework.stereotype.Component; + + import com.cloud.network.Network; + import com.cloud.network.UserIpv6AddressVO; + import com.cloud.utils.Pair; + import com.cloud.utils.db.Filter; + import com.cloud.utils.db.GenericDaoBase; + import com.cloud.utils.db.GenericSearchBuilder; + import com.cloud.utils.db.SearchBuilder; + import com.cloud.utils.db.SearchCriteria; + import com.cloud.utils.db.SearchCriteria.Func; + import com.cloud.utils.db.SearchCriteria.Op; + import com.cloud.utils.db.SearchCriteria2; + ++@Component + @Local(value=UserIpv6AddressDao.class) + public class UserIpv6AddressDaoImpl extends GenericDaoBase implements UserIpv6AddressDao { + private static final Logger s_logger = Logger.getLogger(IPAddressDaoImpl.class); + + protected final SearchBuilder AllFieldsSearch; + protected GenericSearchBuilder CountFreePublicIps; + + public UserIpv6AddressDaoImpl() { + AllFieldsSearch = createSearchBuilder(); + AllFieldsSearch.and("id", AllFieldsSearch.entity().getId(), Op.EQ); + AllFieldsSearch.and("dataCenterId", AllFieldsSearch.entity().getDataCenterId(), Op.EQ); + AllFieldsSearch.and("ipAddress", AllFieldsSearch.entity().getAddress(), Op.EQ); + AllFieldsSearch.and("vlan", AllFieldsSearch.entity().getVlanId(), Op.EQ); + AllFieldsSearch.and("accountId", AllFieldsSearch.entity().getAccountId(), Op.EQ); + AllFieldsSearch.and("network", AllFieldsSearch.entity().getNetworkId(), Op.EQ); + AllFieldsSearch.and("physicalNetworkId", AllFieldsSearch.entity().getPhysicalNetworkId(), Op.EQ); + AllFieldsSearch.done(); + + CountFreePublicIps = createSearchBuilder(Long.class); + CountFreePublicIps.select(null, Func.COUNT, null); + CountFreePublicIps.and("networkId", CountFreePublicIps.entity().getSourceNetworkId(), SearchCriteria.Op.EQ); + CountFreePublicIps.done(); + } + + @Override + public List listByAccount(long accountId) { + SearchCriteria sc = AllFieldsSearch.create(); + sc.setParameters("accountId", accountId); + return listBy(sc); + } + + @Override + public List listByVlanId(long vlanId) { + SearchCriteria sc = AllFieldsSearch.create(); + sc.setParameters("vlan", vlanId); + return listBy(sc); + } + + @Override + public List listByDcId(long dcId) { + SearchCriteria sc = AllFieldsSearch.create(); + sc.setParameters("dataCenterId", dcId); + return listBy(sc); + } + + @Override + public List listByNetwork(long networkId) { + SearchCriteria sc = AllFieldsSearch.create(); + sc.setParameters("network", networkId); + return listBy(sc); + } + + @Override + public UserIpv6AddressVO findByNetworkIdAndIp(long networkId, String ipAddress) { + SearchCriteria sc = AllFieldsSearch.create(); + sc.setParameters("networkId", networkId); + sc.setParameters("ipAddress", ipAddress); + return findOneBy(sc); + } + + @Override + public List listByPhysicalNetworkId(long physicalNetworkId) { + SearchCriteria sc = AllFieldsSearch.create(); + sc.setParameters("physicalNetworkId", physicalNetworkId); + return listBy(sc); + } + + @Override + public long countExistedIpsInNetwork(long networkId) { + SearchCriteria sc = CountFreePublicIps.create(); + sc.setParameters("networkId", networkId); + return customSearch(sc, null).get(0); + } + } http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7bd8bec6/server/src/com/cloud/network/element/VirtualRouterElement.java ---------------------------------------------------------------------- diff --cc server/src/com/cloud/network/element/VirtualRouterElement.java index e065255,b224537..500d0b6 --- a/server/src/com/cloud/network/element/VirtualRouterElement.java +++ b/server/src/com/cloud/network/element/VirtualRouterElement.java @@@ -841,7 -841,12 +841,12 @@@ public class VirtualRouterElement exten if (vm.getType() != VirtualMachine.Type.User) { return false; } - + + if (network.getIp6Gateway() != null) { + s_logger.info("Skip password and userdata service setup for IPv6 VM"); + return true; + } + @SuppressWarnings("unchecked") VirtualMachineProfile uservm = (VirtualMachineProfile) vm; http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7bd8bec6/server/src/com/cloud/network/guru/DirectNetworkGuru.java ---------------------------------------------------------------------- diff --cc server/src/com/cloud/network/guru/DirectNetworkGuru.java index 4be7491,0d5425f..7ea988f --- a/server/src/com/cloud/network/guru/DirectNetworkGuru.java +++ b/server/src/com/cloud/network/guru/DirectNetworkGuru.java @@@ -31,6 -30,8 +31,7 @@@ import com.cloud.exception.ConcurrentOp import com.cloud.exception.InsufficientAddressCapacityException; import com.cloud.exception.InsufficientVirtualNetworkCapcityException; import com.cloud.exception.InvalidParameterValueException; -import com.cloud.network.IPAddressVO; + import com.cloud.network.Ipv6AddressManager; import com.cloud.network.Network; import com.cloud.network.Network.GuestType; import com.cloud.network.Network.Service; @@@ -41,9 -42,10 +42,11 @@@ import com.cloud.network.NetworkProfile import com.cloud.network.Networks.BroadcastDomainType; import com.cloud.network.Networks.Mode; import com.cloud.network.Networks.TrafficType; + import com.cloud.network.UserIpv6AddressVO; import com.cloud.network.dao.IPAddressDao; +import com.cloud.network.dao.IPAddressVO; +import com.cloud.network.dao.NetworkVO; + import com.cloud.network.dao.UserIpv6AddressDao; import com.cloud.offering.NetworkOffering; import com.cloud.offerings.dao.NetworkOfferingDao; import com.cloud.user.Account; @@@ -202,14 -221,20 +221,20 @@@ public class DirectNetworkGuru extends s_logger.debug("Deallocate network: networkId: " + nic.getNetworkId() + ", ip: " + nic.getIp4Address()); } + if (nic.getIp4Address() != null) { - IPAddressVO ip = _ipAddressDao.findByIpAndSourceNetworkId(nic.getNetworkId(), nic.getIp4Address()); - if (ip != null) { - Transaction txn = Transaction.currentTxn(); - txn.start(); - _networkMgr.markIpAsUnavailable(ip.getId()); - _ipAddressDao.unassignIpAddress(ip.getId()); - txn.commit(); - } + IPAddressVO ip = _ipAddressDao.findByIpAndSourceNetworkId(nic.getNetworkId(), nic.getIp4Address()); + if (ip != null) { + Transaction txn = Transaction.currentTxn(); + txn.start(); + _networkMgr.markIpAsUnavailable(ip.getId()); + _ipAddressDao.unassignIpAddress(ip.getId()); + txn.commit(); + } + } + + if (nic.getIp6Address() != null) { + _ipv6Mgr.revokeDirectIpv6Address(nic.getNetworkId(), nic.getIp6Address()); + } nic.deallocate(); } http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7bd8bec6/server/src/com/cloud/network/guru/DirectPodBasedNetworkGuru.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7bd8bec6/server/src/com/cloud/network/guru/ExternalGuestNetworkGuru.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7bd8bec6/server/src/com/cloud/network/guru/GuestNetworkGuru.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7bd8bec6/server/src/com/cloud/network/guru/PodBasedNetworkGuru.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7bd8bec6/server/src/com/cloud/network/guru/PublicNetworkGuru.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7bd8bec6/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java ---------------------------------------------------------------------- diff --cc server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java index a787079,dee418b..1abca51 --- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java +++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java @@@ -1924,11 -1908,25 +1924,25 @@@ public class VirtualNetworkApplianceMan String defaultDns2 = null; for (NicProfile nic : profile.getNics()) { int deviceId = nic.getDeviceId(); + boolean ipv4 = false, ipv6 = false; + if (nic.getIp4Address() != null) { + ipv4 = true; - buf.append(" eth").append(deviceId).append("ip=").append(nic.getIp4Address()); - buf.append(" eth").append(deviceId).append("mask=").append(nic.getNetmask()); + buf.append(" eth").append(deviceId).append("ip=").append(nic.getIp4Address()); + buf.append(" eth").append(deviceId).append("mask=").append(nic.getNetmask()); + } + if (nic.getIp6Address() != null) { + ipv6 = true; + buf.append(" eth").append(deviceId).append("ip6=").append(nic.getIp6Address()); + buf.append(" eth").append(deviceId).append("ip6prelen=").append(NetUtils.getIp6CidrSize(nic.getIp6Cidr())); + } if (nic.isDefaultNic()) { + if (ipv4) { - buf.append(" gateway=").append(nic.getGateway()); + buf.append(" gateway=").append(nic.getGateway()); + } + if (ipv6) { + buf.append(" ip6gateway=").append(nic.getIp6Gateway()); + } defaultDns1 = nic.getDns1(); defaultDns2 = nic.getDns2(); } @@@ -3068,11 -3066,11 +3082,11 @@@ } private void createDhcpEntryCommand(VirtualRouter router, UserVm vm, NicVO nic, Commands cmds) { - DhcpEntryCommand dhcpCommand = new DhcpEntryCommand(nic.getMacAddress(), nic.getIp4Address(), vm.getHostName()); + DhcpEntryCommand dhcpCommand = new DhcpEntryCommand(nic.getMacAddress(), nic.getIp4Address(), vm.getHostName(), nic.getIp6Address()); - DataCenterVO dcVo = _dcDao.findById(router.getDataCenterIdToDeployIn()); + DataCenterVO dcVo = _dcDao.findById(router.getDataCenterId()); String gatewayIp = findGatewayIp(vm.getId()); boolean needGateway = true; - if (!gatewayIp.equals(nic.getGateway())) { + if (gatewayIp != null && !gatewayIp.equals(nic.getGateway())) { needGateway = false; GuestOSVO guestOS = _guestOSDao.findById(vm.getGuestOSId()); // Do set dhcp:router option for non-default nic on certain OS(including Windows), and leave other OS unset. http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7bd8bec6/server/src/com/cloud/network/vpc/VpcManagerImpl.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7bd8bec6/server/src/com/cloud/user/AccountManagerImpl.java ---------------------------------------------------------------------- diff --cc server/src/com/cloud/user/AccountManagerImpl.java index eceeb84,f116cad..5512d3f --- a/server/src/com/cloud/user/AccountManagerImpl.java +++ b/server/src/com/cloud/user/AccountManagerImpl.java @@@ -139,11 -140,11 +139,11 @@@ import com.cloud.vm.dao.InstanceGroupDa import com.cloud.vm.dao.UserVmDao; import com.cloud.vm.dao.VMInstanceDao; +@Component @Local(value = { AccountManager.class, AccountService.class }) - public class AccountManagerImpl extends ManagerBase implements AccountManager, AccountService { -public class AccountManagerImpl implements AccountManager, Manager { ++public class AccountManagerImpl extends ManagerBase implements AccountManager, Manager { public static final Logger s_logger = Logger.getLogger(AccountManagerImpl.class); - private String _name; @Inject private AccountDao _accountDao; @Inject http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7bd8bec6/server/src/com/cloud/vm/UserVmManagerImpl.java ---------------------------------------------------------------------- diff --cc server/src/com/cloud/vm/UserVmManagerImpl.java index dd60da7,655d6c8..ad358eb --- a/server/src/com/cloud/vm/UserVmManagerImpl.java +++ b/server/src/com/cloud/vm/UserVmManagerImpl.java @@@ -133,22 -63,12 +133,24 @@@ import com.cloud.host.HostVO import com.cloud.host.dao.HostDao; import com.cloud.hypervisor.Hypervisor.HypervisorType; import com.cloud.hypervisor.dao.HypervisorCapabilitiesDao; +import com.cloud.network.Network; + import com.cloud.network.*; + import com.cloud.network.Network.IpAddresses; import com.cloud.network.Network.Provider; import com.cloud.network.Network.Service; +import com.cloud.network.NetworkManager; +import com.cloud.network.NetworkModel; import com.cloud.network.Networks.TrafficType; -import com.cloud.network.dao.*; +import com.cloud.network.PhysicalNetwork; +import com.cloud.network.dao.FirewallRulesDao; +import com.cloud.network.dao.IPAddressDao; +import com.cloud.network.dao.IPAddressVO; +import com.cloud.network.dao.LoadBalancerVMMapDao; +import com.cloud.network.dao.LoadBalancerVMMapVO; +import com.cloud.network.dao.NetworkDao; +import com.cloud.network.dao.NetworkServiceMapDao; +import com.cloud.network.dao.NetworkVO; +import com.cloud.network.dao.PhysicalNetworkDao; import com.cloud.network.element.UserDataServiceProvider; import com.cloud.network.lb.LoadBalancingRulesManager; import com.cloud.network.rules.FirewallManager; @@@ -2874,16 -2384,10 +2867,10 @@@ public class UserVmManagerImpl extends } @Override - public UserVm createAdvancedSecurityGroupVirtualMachine(DataCenter zone, - ServiceOffering serviceOffering, VirtualMachineTemplate template, - List networkIdList, List securityGroupIdList, - Account owner, String hostName, String displayName, - Long diskOfferingId, Long diskSize, String group, - HypervisorType hypervisor, String userData, String sshKeyPair, - Map requestedIps, String defaultIp, String keyboard) - throws InsufficientCapacityException, ConcurrentOperationException, - ResourceUnavailableException, StorageUnavailableException, + public UserVm createAdvancedSecurityGroupVirtualMachine(DataCenter zone, ServiceOffering serviceOffering, VirtualMachineTemplate template, List networkIdList, + List securityGroupIdList, Account owner, String hostName, String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor, String userData, + String sshKeyPair, Map requestedIps, IpAddresses defaultIps, String keyboard) throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException, - ResourceAllocationException { + ResourceAllocationException { Account caller = UserContext.current().getCaller(); List networkList = new ArrayList(); @@@ -3051,29 -2520,17 +3029,20 @@@ if (virtualNetworks.isEmpty()) { long physicalNetworkId = _networkModel.findPhysicalNetworkId(zone.getId(), requiredOfferings.get(0).getTags(), requiredOfferings.get(0).getTrafficType()); // Validate physical network - PhysicalNetwork physicalNetwork = _physicalNetworkDao.findById(physicalNetworkId); + PhysicalNetwork physicalNetwork = _physicalNetworkDao + .findById(physicalNetworkId); if (physicalNetwork == null) { - throw new InvalidParameterValueException( - "Unable to find physical network with id: " - + physicalNetworkId + " and tag: " - + requiredOfferings.get(0).getTags()); + throw new InvalidParameterValueException("Unable to find physical network with id: "+physicalNetworkId + " and tag: " +requiredOfferings.get(0).getTags()); } - s_logger.debug("Creating network for account " + owner - + " from the network offering id=" - + requiredOfferings.get(0).getId() - + " as a part of deployVM process"); - Network newNetwork = _networkMgr.createGuestNetwork( - requiredOfferings.get(0).getId(), - owner.getAccountName() + "-network", - owner.getAccountName() + "-network", null, null, - null, null, owner, null, physicalNetwork, - zone.getId(), ACLType.Account, null, null); + s_logger.debug("Creating network for account " + owner + " from the network offering id=" +requiredOfferings.get(0).getId() + " as a part of deployVM process"); + Network newNetwork = _networkMgr.createGuestNetwork(requiredOfferings.get(0).getId(), + owner.getAccountName() + "-network", owner.getAccountName() + "-network", null, null, + null, null, owner, null, physicalNetwork, zone.getId(), ACLType.Account, null, null, null, null); defaultNetwork = _networkDao.findById(newNetwork.getId()); } else if (virtualNetworks.size() > 1) { - throw new InvalidParameterValueException("More than 1 default Isolated networks are found for account " + owner + "; please specify networkIds"); + throw new InvalidParameterValueException( + "More than 1 default Isolated networks are found for account " + + owner + "; please specify networkIds"); } else { defaultNetwork = _networkDao.findById(virtualNetworks.get(0).getId()); } @@@ -3159,13 -2587,10 +3117,13 @@@ long accountId = owner.getId(); - assert !(requestedIps != null && defaultNetworkIp != null) : "requestedIp list and defaultNetworkIp should never be specified together"; + assert !(requestedIps != null && (defaultIps.getIp4Address() != null || defaultIps.getIp6Address() != null)) : "requestedIp list and defaultNetworkIp should never be specified together"; - if (Grouping.AllocationState.Disabled == zone.getAllocationState() && !_accountMgr.isRootAdmin(caller.getType())) { - throw new PermissionDeniedException("Cannot perform this operation, Zone is currently disabled: " + zone.getId()); + if (Grouping.AllocationState.Disabled == zone.getAllocationState() + && !_accountMgr.isRootAdmin(caller.getType())) { + throw new PermissionDeniedException( + "Cannot perform this operation, Zone is currently disabled: " + + zone.getId()); } if (zone.getDomainId() != null) { @@@ -3265,17 -2708,21 +3223,23 @@@ boolean vpcNetwork = false; for (NetworkVO network : networkList) { if (network.getDataCenterId() != zone.getId()) { - throw new InvalidParameterValueException("Network id=" + network.getId() + " doesn't belong to zone " + zone.getId()); + throw new InvalidParameterValueException("Network id=" + + network.getId() + " doesn't belong to zone " + + zone.getId()); } - String requestedIp = null; + IpAddresses requestedIpPair = null; if (requestedIps != null && !requestedIps.isEmpty()) { - requestedIp = requestedIps.get(network.getId()); + requestedIpPair = requestedIps.get(network.getId()); } - + - NicProfile profile = new NicProfile(requestedIp); + if (requestedIpPair == null) { + requestedIpPair = new IpAddresses(null, null); + } else { + checkRequestedIpAddresses(requestedIpPair.getIp4Address(), requestedIpPair.getIp6Address()); + } + + NicProfile profile = new NicProfile(requestedIpPair.getIp4Address(), requestedIpPair.getIp6Address()); if (defaultNetworkNumber == 0) { defaultNetworkNumber++; @@@ -3460,7 -2866,20 +3425,20 @@@ return vm; } + private void checkRequestedIpAddresses(String ip4, String ip6) throws InvalidParameterValueException { + if (ip4 != null) { + if (!NetUtils.isValidIp(ip4)) { + throw new InvalidParameterValueException("Invalid specified IPv4 address " + ip4); + } + } + if (ip6 != null) { + if (!NetUtils.isValidIpv6(ip6)) { + throw new InvalidParameterValueException("Invalid specified IPv6 address " + ip6); + } + } + } + - private void validateUserData(String userData) { + private void validateUserData(String userData) { byte[] decodedUserData = null; if (userData != null) { if (!Base64.isBase64(userData)) { @@@ -4690,16 -3904,14 +4668,16 @@@ throw new InvalidParameterValueException("Unable to find physical network with id: "+physicalNetworkId + " and tag: " +requiredOfferings.get(0).getTags()); } s_logger.debug("Creating network for account " + newAccount + " from the network offering id=" + - requiredOfferings.get(0).getId() + " as a part of deployVM process"); + requiredOfferings.get(0).getId() + " as a part of deployVM process"); Network newNetwork = _networkMgr.createGuestNetwork(requiredOfferings.get(0).getId(), newAccount.getAccountName() + "-network", newAccount.getAccountName() + "-network", null, null, - null, null, newAccount, null, physicalNetwork, zone.getId(), ACLType.Account, null, null); + null, null, newAccount, null, physicalNetwork, zone.getId(), ACLType.Account, null, null, null, null); defaultNetwork = _networkDao.findById(newNetwork.getId()); } else if (virtualNetworks.size() > 1) { - throw new InvalidParameterValueException("More than 1 default Isolated networks are found " + - "for account " + newAccount + "; please specify networkIds"); + throw new InvalidParameterValueException( + "More than 1 default Isolated networks are found " + + "for account " + newAccount + + "; please specify networkIds"); } else { defaultNetwork = _networkDao.findById(virtualNetworks.get(0).getId()); } http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7bd8bec6/server/test/com/cloud/network/MockNetworkManagerImpl.java ---------------------------------------------------------------------- diff --cc server/test/com/cloud/network/MockNetworkManagerImpl.java index fbd3e27,af0b03f..4a24f9a --- a/server/test/com/cloud/network/MockNetworkManagerImpl.java +++ b/server/test/com/cloud/network/MockNetworkManagerImpl.java @@@ -666,10 -661,10 +666,10 @@@ public class MockNetworkManagerImpl ext */ @Override public void allocateDirectIp(NicProfile nic, DataCenter dc, VirtualMachineProfile vm, - Network network, String requestedIp) throws InsufficientVirtualNetworkCapcityException, + Network network, String requestedIpv4, String requestedIpv6) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException { // TODO Auto-generated method stub - + } /* (non-Javadoc) http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7bd8bec6/server/test/com/cloud/network/MockNetworkModelImpl.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7bd8bec6/server/test/com/cloud/user/MockAccountManagerImpl.java ---------------------------------------------------------------------- diff --cc server/test/com/cloud/user/MockAccountManagerImpl.java index e5a7ada,135ae9a..1893d67 --- a/server/test/com/cloud/user/MockAccountManagerImpl.java +++ b/server/test/com/cloud/user/MockAccountManagerImpl.java @@@ -45,9 -44,8 +45,9 @@@ import com.cloud.utils.db.SearchBuilder import com.cloud.utils.db.SearchCriteria; +@Component @Local(value = { AccountManager.class, AccountService.class }) - public class MockAccountManagerImpl extends ManagerBase implements AccountManager, AccountService { -public class MockAccountManagerImpl implements Manager, AccountManager { ++public class MockAccountManagerImpl extends ManagerBase implements Manager, AccountManager { @Override http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7bd8bec6/server/test/com/cloud/vm/MockUserVmManagerImpl.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7bd8bec6/server/test/com/cloud/vpc/MockConfigurationManagerImpl.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7bd8bec6/server/test/com/cloud/vpc/MockNetworkManagerImpl.java ---------------------------------------------------------------------- diff --cc server/test/com/cloud/vpc/MockNetworkManagerImpl.java index 7c8226a,5d9c436..534df1c --- a/server/test/com/cloud/vpc/MockNetworkManagerImpl.java +++ b/server/test/com/cloud/vpc/MockNetworkManagerImpl.java @@@ -56,10 -56,9 +56,11 @@@ import com.cloud.network.PhysicalNetwor import com.cloud.network.PhysicalNetworkServiceProvider; import com.cloud.network.PhysicalNetworkTrafficType; import com.cloud.network.PublicIpAddress; + import com.cloud.network.UserIpv6Address; import com.cloud.network.addr.PublicIp; +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; @@@ -849,8 -847,8 +850,8 @@@ public class MockNetworkManagerImpl ext @Override public Network createGuestNetwork(long networkOfferingId, String name, String displayText, String gateway, String cidr, String vlanId, String networkDomain, Account owner, Long domainId, - PhysicalNetwork physicalNetwork, long zoneId, ACLType aclType, Boolean subdomainAccess, Long vpcId) + PhysicalNetwork physicalNetwork, long zoneId, ACLType aclType, Boolean subdomainAccess, Long vpcId, String gatewayv6, String cidrv6) - throws ConcurrentOperationException, InsufficientCapacityException, ResourceAllocationException { + throws ConcurrentOperationException, InsufficientCapacityException, ResourceAllocationException { // TODO Auto-generated method stub return null; }