You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by re...@apache.org on 2016/01/18 12:13:45 UTC

[10/11] git commit: updated refs/heads/master to c9922ea

Merge release branch 4.7 to master

* 4.7:
  CLOUDSTACK-9154 - Sets the pub interface down when all guest nets are gone
  CLOUDSTACK-9187 - Makes code ready for more something like ethXXXX, if we ever get that far
  CLOUDSTACK-9188 -  Reads network GC interval and wait from configDao
  CLOUDSTACK-9187 - Fixes interface allocation to VRRP instances
  CLOUDSTACK-9187 - Adds test to cover multiple nics and nic removal
  CLOUDSTACK-9154 - Adds test to cover nics state after GC
  CLOUDSTACK-9154 - Returns the guest iterface that is marked as added

 Conflicts:
	engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/addb2645
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/addb2645
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/addb2645

Branch: refs/heads/master
Commit: addb26455ac73f5da3d07b8764980b1e012721c3
Parents: 262be75 ff89587
Author: Daan Hoogland <da...@onecht.net>
Authored: Sun Jan 17 20:04:11 2016 +0100
Committer: Daan Hoogland <da...@onecht.net>
Committed: Sun Jan 17 20:04:11 2016 +0100

----------------------------------------------------------------------
 .../orchestration/NetworkOrchestrator.java      | 962 ++++++++++---------
 .../debian/config/opt/cloud/bin/cs/CsAddress.py |  21 +-
 .../config/opt/cloud/bin/cs/CsRedundant.py      |  70 +-
 test/integration/smoke/test_vpc_redundant.py    | 134 ++-
 4 files changed, 646 insertions(+), 541 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/addb2645/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java
----------------------------------------------------------------------
diff --cc engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java
index fa6cd82,5f442b3..2cf1635
--- a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java
+++ b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java
@@@ -168,8 -167,8 +168,9 @@@ import com.cloud.user.Account
  import com.cloud.user.ResourceLimitService;
  import com.cloud.user.User;
  import com.cloud.user.dao.AccountDao;
+ import com.cloud.utils.NumbersUtil;
  import com.cloud.utils.Pair;
 +import com.cloud.utils.UuidUtils;
  import com.cloud.utils.component.AdapterBase;
  import com.cloud.utils.component.ManagerBase;
  import com.cloud.utils.concurrency.NamedThreadFactory;
@@@ -672,14 -674,8 +676,14 @@@ public class NetworkOrchestrator extend
                                  vpcId, offering.getRedundantRouter());
                          vo.setDisplayNetwork(isDisplayNetworkEnabled == null ? true : isDisplayNetworkEnabled);
                          vo.setStrechedL2Network(offering.getSupportsStrechedL2());
-                         NetworkVO networkPersisted = _networksDao.persist(vo, vo.getGuestType() == Network.GuestType.Isolated,
 -                        networks.add(_networksDao.persist(vo, vo.getGuestType() == Network.GuestType.Isolated,
 -                                finalizeServicesAndProvidersForNetwork(offering, plan.getPhysicalNetworkId())));
++                        final NetworkVO networkPersisted = _networksDao.persist(vo, vo.getGuestType() == Network.GuestType.Isolated,
 +                                finalizeServicesAndProvidersForNetwork(offering, plan.getPhysicalNetworkId()));
 +                        networks.add(networkPersisted);
 +
 +                        if (predefined instanceof NetworkVO && guru instanceof NetworkGuruAdditionalFunctions){
-                             NetworkGuruAdditionalFunctions functions = (NetworkGuruAdditionalFunctions) guru;
++                            final NetworkGuruAdditionalFunctions functions = (NetworkGuruAdditionalFunctions) guru;
 +                            functions.finalizeNetworkDesign(networkPersisted.getId(), ((NetworkVO)predefined).getVlanIdAsUUID());
 +                        }
  
                          if (domainId != null && aclType == ACLType.Domain) {
                              _networksDao.addDomainToNetwork(id, domainId, subdomainAccess == null ? true : subdomainAccess);
@@@ -1025,12 -1021,9 +1029,12 @@@
              _networksDao.update(network.getId(), network);
              implemented.set(guru, network);
              return implemented;
-         } catch (NoTransitionException e) {
+         } catch (final NoTransitionException e) {
              s_logger.error(e.getMessage());
              return null;
-         } catch (CloudRuntimeException e) {
++        } catch (final CloudRuntimeException e) {
 +            s_logger.error("Caught exception: " + e.getMessage());
 +            return null;
          } finally {
              if (implemented.first() == null) {
                  s_logger.debug("Cleaning up because we're unable to implement the network " + network);
@@@ -1484,10 -1477,10 +1488,10 @@@
                      //Nic details are not available in DB
                      //Create nic profile for migration
                      s_logger.debug("Creating nic profile for migration. BroadcastUri: "+broadcastUri.toString()+" NetworkId: "+ntwkId+" Vm: "+vm.getId());
-                     NetworkVO network = _networksDao.findById(ntwkId);
-                     Integer networkRate = _networkModel.getNetworkRate(network.getId(), vm.getId());
-                     NetworkGuru guru = AdapterBase.getAdapterByName(networkGurus, network.getGuruName());
-                     NicProfile profile = new NicProfile();
+                     final NetworkVO network = _networksDao.findById(ntwkId);
 -                    final Integer networkRate = _networkModel.getNetworkRate(network.getId(), vm.getId());
++                    _networkModel.getNetworkRate(network.getId(), vm.getId());
+                     final NetworkGuru guru = AdapterBase.getAdapterByName(networkGurus, network.getGuruName());
+                     final NicProfile profile = new NicProfile();
                      profile.setDeviceId(255); //dummyId
                      profile.setIPv4Address(userIp.getAddress().toString());
                      profile.setIPv4Netmask(publicIp.getNetmask());
@@@ -1922,35 -1915,33 +1926,35 @@@
                  throw new InvalidParameterValueException("The VLAN tag " + vlanId + " is already being used for dynamic vlan allocation for the guest network in zone "
                          + zone.getName());
              }
 -            final String uri = BroadcastDomainType.fromString(vlanId).toString();
 -            // For Isolated networks, don't allow to create network with vlan that already exists in the zone
 -            if (ntwkOff.getGuestType() == GuestType.Isolated) {
 -                if (_networksDao.countByZoneAndUri(zoneId, uri) > 0) {
 -                    throw new InvalidParameterValueException("Network with vlan " + vlanId + " already exists in zone " + zoneId);
 -                } else {
 -                    final List<DataCenterVnetVO> dcVnets = _datacenterVnetDao.findVnet(zoneId, vlanId.toString());
 -                    //for the network that is created as part of private gateway,
 -                    //the vnet is not coming from the data center vnet table, so the list can be empty
 -                    if (!dcVnets.isEmpty()) {
 -                        final DataCenterVnetVO dcVnet = dcVnets.get(0);
 -                        // Fail network creation if specified vlan is dedicated to a different account
 -                        if (dcVnet.getAccountGuestVlanMapId() != null) {
 -                            final Long accountGuestVlanMapId = dcVnet.getAccountGuestVlanMapId();
 -                            final AccountGuestVlanMapVO map = _accountGuestVlanMapDao.findById(accountGuestVlanMapId);
 -                            if (map.getAccountId() != owner.getAccountId()) {
 -                                throw new InvalidParameterValueException("Vlan " + vlanId + " is dedicated to a different account");
 -                            }
 -                            // Fail network creation if owner has a dedicated range of vlans but the specified vlan belongs to the system pool
 -                        } else {
 -                            final List<AccountGuestVlanMapVO> maps = _accountGuestVlanMapDao.listAccountGuestVlanMapsByAccount(owner.getAccountId());
 -                            if (maps != null && !maps.isEmpty()) {
 -                                final int vnetsAllocatedToAccount = _datacenterVnetDao.countVnetsAllocatedToAccount(zoneId, owner.getAccountId());
 -                                final int vnetsDedicatedToAccount = _datacenterVnetDao.countVnetsDedicatedToAccount(zoneId, owner.getAccountId());
 -                                if (vnetsAllocatedToAccount < vnetsDedicatedToAccount) {
 -                                    throw new InvalidParameterValueException("Specified vlan " + vlanId + " doesn't belong" + " to the vlan range dedicated to the owner "
 -                                            + owner.getAccountName());
 +            if (! UuidUtils.validateUUID(vlanId)){
-                 String uri = BroadcastDomainType.fromString(vlanId).toString();
++                final String uri = BroadcastDomainType.fromString(vlanId).toString();
 +                // For Isolated networks, don't allow to create network with vlan that already exists in the zone
 +                if (ntwkOff.getGuestType() == GuestType.Isolated) {
 +                    if (_networksDao.countByZoneAndUri(zoneId, uri) > 0) {
 +                        throw new InvalidParameterValueException("Network with vlan " + vlanId + " already exists in zone " + zoneId);
 +                    } else {
-                         List<DataCenterVnetVO> dcVnets = _datacenterVnetDao.findVnet(zoneId, vlanId.toString());
++                        final List<DataCenterVnetVO> dcVnets = _datacenterVnetDao.findVnet(zoneId, vlanId.toString());
 +                        //for the network that is created as part of private gateway,
 +                        //the vnet is not coming from the data center vnet table, so the list can be empty
 +                        if (!dcVnets.isEmpty()) {
-                             DataCenterVnetVO dcVnet = dcVnets.get(0);
++                            final DataCenterVnetVO dcVnet = dcVnets.get(0);
 +                            // Fail network creation if specified vlan is dedicated to a different account
 +                            if (dcVnet.getAccountGuestVlanMapId() != null) {
-                                 Long accountGuestVlanMapId = dcVnet.getAccountGuestVlanMapId();
-                                 AccountGuestVlanMapVO map = _accountGuestVlanMapDao.findById(accountGuestVlanMapId);
++                                final Long accountGuestVlanMapId = dcVnet.getAccountGuestVlanMapId();
++                                final AccountGuestVlanMapVO map = _accountGuestVlanMapDao.findById(accountGuestVlanMapId);
 +                                if (map.getAccountId() != owner.getAccountId()) {
 +                                    throw new InvalidParameterValueException("Vlan " + vlanId + " is dedicated to a different account");
 +                                }
 +                                // Fail network creation if owner has a dedicated range of vlans but the specified vlan belongs to the system pool
 +                            } else {
-                                 List<AccountGuestVlanMapVO> maps = _accountGuestVlanMapDao.listAccountGuestVlanMapsByAccount(owner.getAccountId());
++                                final List<AccountGuestVlanMapVO> maps = _accountGuestVlanMapDao.listAccountGuestVlanMapsByAccount(owner.getAccountId());
 +                                if (maps != null && !maps.isEmpty()) {
-                                     int vnetsAllocatedToAccount = _datacenterVnetDao.countVnetsAllocatedToAccount(zoneId, owner.getAccountId());
-                                     int vnetsDedicatedToAccount = _datacenterVnetDao.countVnetsDedicatedToAccount(zoneId, owner.getAccountId());
++                                    final int vnetsAllocatedToAccount = _datacenterVnetDao.countVnetsAllocatedToAccount(zoneId, owner.getAccountId());
++                                    final int vnetsDedicatedToAccount = _datacenterVnetDao.countVnetsDedicatedToAccount(zoneId, owner.getAccountId());
 +                                    if (vnetsAllocatedToAccount < vnetsDedicatedToAccount) {
 +                                        throw new InvalidParameterValueException("Specified vlan " + vlanId + " doesn't belong" + " to the vlan range dedicated to the owner "
 +                                                + owner.getAccountName());
 +                                    }
                                  }
                              }
                          }
@@@ -2667,27 -2656,6 +2676,27 @@@
          } else {
              result = _nicDao.listByVmIdAndNicIdAndNtwkId(vmId, nicId, networkId);
          }
 +
-         for (NicVO nic : result) {
++        for (final NicVO nic : result) {
 +            if (_networkModel.isProviderForNetwork(Provider.NiciraNvp, nic.getNetworkId())) {
 +                //For NSX Based networks, add nsxlogicalswitch, nsxlogicalswitchport to each result
 +                s_logger.info("Listing NSX logical switch and logical switch por for each nic");
-                 NetworkVO network = _networksDao.findById(nic.getNetworkId());
-                 NetworkGuru guru = AdapterBase.getAdapterByName(networkGurus, network.getGuruName());
-                 NetworkGuruAdditionalFunctions guruFunctions = (NetworkGuruAdditionalFunctions) guru;
++                final NetworkVO network = _networksDao.findById(nic.getNetworkId());
++                final NetworkGuru guru = AdapterBase.getAdapterByName(networkGurus, network.getGuruName());
++                final NetworkGuruAdditionalFunctions guruFunctions = (NetworkGuruAdditionalFunctions) guru;
 +
-                 Map<String, ? extends Object> nsxParams = guruFunctions.listAdditionalNicParams(nic.getUuid());
++                final Map<String, ? extends Object> nsxParams = guruFunctions.listAdditionalNicParams(nic.getUuid());
 +                if (nsxParams != null){
-                     String lswitchUuuid = (nsxParams.containsKey(NetworkGuruAdditionalFunctions.NSX_LSWITCH_UUID))
++                    final String lswitchUuuid = nsxParams.containsKey(NetworkGuruAdditionalFunctions.NSX_LSWITCH_UUID)
 +                            ? (String) nsxParams.get(NetworkGuruAdditionalFunctions.NSX_LSWITCH_UUID) : null;
-                     String lswitchPortUuuid = (nsxParams.containsKey(NetworkGuruAdditionalFunctions.NSX_LSWITCHPORT_UUID))
++                    final String lswitchPortUuuid = nsxParams.containsKey(NetworkGuruAdditionalFunctions.NSX_LSWITCHPORT_UUID)
 +                            ? (String) nsxParams.get(NetworkGuruAdditionalFunctions.NSX_LSWITCHPORT_UUID) : null;
 +                    nic.setNsxLogicalSwitchUuid(lswitchUuuid);
 +                    nic.setNsxLogicalSwitchPortUuid(lswitchPortUuuid);
 +                }
 +            }
 +        }
 +
          return result;
      }