From d39026171050a077a0ef935ae37c83c12ae9314d Mon Sep 17 00:00:00 2001 From: Alena Prokharchyk Date: Mon, 4 Jun 2012 09:29:48 -0700 Subject: [PATCH 1/8] CS-15197: correct default value for service_offering.nw_rate Reviewed-by: Will Chan Conflicts: setup/db/db/schema-302to303.sql --- setup/db/db/schema-302to303.sql | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/setup/db/db/schema-302to303.sql b/setup/db/db/schema-302to303.sql index 4aeb85f5a9b..32f68e6f582 100755 --- a/setup/db/db/schema-302to303.sql +++ b/setup/db/db/schema-302to303.sql @@ -172,3 +172,7 @@ CREATE TABLE `cloud`.`port_profile` ( `port_binding` varchar(20), PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +DELETE FROM `cloud`.`storage_pool_host_ref` WHERE pool_id IN (SELECT id FROM storage_pool WHERE removed IS NOT NULL); + +ALTER TABLE `cloud`.`service_offering` MODIFY `nw_rate` smallint(5) unsigned DEFAULT '200' COMMENT 'network rate throttle mbits/s'; From 7092532ae89643fb2ec928ac27df713d58a6b71f Mon Sep 17 00:00:00 2001 From: Alena Prokharchyk Date: Mon, 4 Jun 2012 18:39:10 -0700 Subject: [PATCH 2/8] CS-15220: fixed db upgrade for networks using external devices Reviewed-by: Sheng Yang Conflicts: server/test/com/cloud/network/MockNetworkManagerImpl.java Conflicts: server/src/com/cloud/upgrade/dao/Upgrade2214to30.java --- .../cloud/upgrade/dao/Upgrade2214to30.java | 185 +++++++++++++++--- .../cloud/network/MockNetworkManagerImpl.java | 17 +- .../AdvanceZone223To224UpgradeTest.java | 8 +- .../vm/MockVirtualMachineManagerImpl.java | 18 ++ 4 files changed, 191 insertions(+), 37 deletions(-) diff --git a/server/src/com/cloud/upgrade/dao/Upgrade2214to30.java b/server/src/com/cloud/upgrade/dao/Upgrade2214to30.java index a4e5b6fd153..37d8c554da8 100755 --- a/server/src/com/cloud/upgrade/dao/Upgrade2214to30.java +++ b/server/src/com/cloud/upgrade/dao/Upgrade2214to30.java @@ -22,6 +22,7 @@ import java.sql.Types; import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.UUID; import org.apache.log4j.Logger; @@ -29,7 +30,6 @@ import org.apache.log4j.Logger; import com.cloud.offering.NetworkOffering; import com.cloud.utils.crypt.DBEncryptionUtil; import com.cloud.utils.crypt.EncryptionSecretKeyChecker; -import com.cloud.utils.db.Transaction; import com.cloud.utils.exception.CloudRuntimeException; import com.cloud.utils.script.Script; @@ -82,8 +82,10 @@ public class Upgrade2214to30 implements DbUpgrade { updateReduntantRouters(conn); // update networks that have to switch from Shared to Isolated network offerings switchAccountSpecificNetworksToIsolated(conn); + // update networks to external network offerings if needed + String externalOfferingName = fixNetworksWithExternalDevices(conn); // create service/provider map for network offerings - createNetworkOfferingServices(conn); + createNetworkOfferingServices(conn, externalOfferingName); // create service/provider map for networks createNetworkServices(conn); //migrate user concentrated deployment planner choice to new global setting @@ -854,67 +856,97 @@ public class Upgrade2214to30 implements DbUpgrade { } } - private void createNetworkOfferingServices(Connection conn) { + private void createNetworkOfferingServices(Connection conn, String externalOfferingName) { PreparedStatement pstmt = null; ResultSet rs = null; try { pstmt = conn - .prepareStatement("select id, dns_service, gateway_service, firewall_service, lb_service, userdata_service, vpn_service, dhcp_service, unique_name from `cloud`.`network_offerings` where traffic_type='Guest'"); + .prepareStatement("select id, dns_service, gateway_service, firewall_service, lb_service, userdata_service," + + " vpn_service, dhcp_service, unique_name from `cloud`.`network_offerings` where traffic_type='Guest'"); rs = pstmt.executeQuery(); while (rs.next()) { + boolean sharedSourceNat = false; + boolean dedicatedLb = true; long id = rs.getLong(1); String uniqueName = rs.getString(9); - ArrayList services = new ArrayList(); + Map services = new HashMap(); if (rs.getLong(2) != 0) { - services.add("Dns"); + services.put("Dns", "VirtualRouter"); } if (rs.getLong(3) != 0) { - services.add("Gateway"); + if (externalOfferingName != null && uniqueName.equalsIgnoreCase(externalOfferingName)) { + services.put("Gateway", "JuniperSRX"); + } else { + services.put("Gateway", "VirtualRouter"); + } } if (rs.getLong(4) != 0) { - services.add("Firewall"); + if (externalOfferingName != null && uniqueName.equalsIgnoreCase(externalOfferingName)) { + services.put("Firewall", "JuniperSRX"); + } else { + services.put("Firewall", "VirtualRouter"); + } } if (rs.getLong(5) != 0) { - services.add("Lb"); + if (externalOfferingName != null && uniqueName.equalsIgnoreCase(externalOfferingName)) { + services.put("Lb", "F5BigIp"); + dedicatedLb = false; + } else { + services.put("Lb", "VirtualRouter"); + } } if (rs.getLong(6) != 0) { - services.add("UserData"); + services.put("UserData", "VirtualRouter"); } if (rs.getLong(7) != 0) { - services.add("Vpn"); + if (externalOfferingName == null || !uniqueName.equalsIgnoreCase(externalOfferingName)) { + services.put("Vpn", "VirtualRouter"); + } } if (rs.getLong(8) != 0) { - services.add("Dhcp"); + services.put("Dhcp", "VirtualRouter"); } if (uniqueName.equalsIgnoreCase(NetworkOffering.DefaultSharedNetworkOfferingWithSGService.toString())) { - services.add("SecurityGroup"); + services.put("SecurityGroup", "SecurityGroupProvider"); } - if (uniqueName.equals(NetworkOffering.DefaultIsolatedNetworkOfferingWithSourceNatService.toString())) { - services.add("SourceNat"); - services.add("PortForwarding"); - services.add("StaticNat"); + if (uniqueName.equals(NetworkOffering.DefaultIsolatedNetworkOfferingWithSourceNatService.toString()) || uniqueName.equalsIgnoreCase(externalOfferingName)) { + if (externalOfferingName != null && uniqueName.equalsIgnoreCase(externalOfferingName)) { + services.put("SourceNat", "JuniperSRX"); + services.put("PortForwarding", "JuniperSRX"); + services.put("StaticNat", "JuniperSRX"); + sharedSourceNat = true; + } else { + services.put("SourceNat", "VirtualRouter"); + services.put("PortForwarding", "VirtualRouter"); + services.put("StaticNat", "VirtualRouter"); + } } - for (String service : services) { - pstmt = conn.prepareStatement("INSERT INTO `cloud`.`ntwk_offering_service_map` (`network_offering_id`, `service`, `provider`, `created`) values (?,?,?, now())"); + for (String service : services.keySet()) { + pstmt = conn.prepareStatement("INSERT INTO `cloud`.`ntwk_offering_service_map` (`network_offering_id`," + + " `service`, `provider`, `created`) values (?,?,?, now())"); pstmt.setLong(1, id); pstmt.setString(2, service); - if (service.equalsIgnoreCase("SecurityGroup")) { - pstmt.setString(3, "SecurityGroupProvider"); - } else { - pstmt.setString(3, "VirtualRouter"); - } + pstmt.setString(3, services.get(service)); pstmt.executeUpdate(); } + + //update shared source nat and dedicated lb + pstmt = conn.prepareStatement("UPDATE `cloud`.`network_offerings` set shared_source_nat_service=?, dedicated_lb_service=? where id=?"); + pstmt.setBoolean(1, sharedSourceNat); + pstmt.setBoolean(2, dedicatedLb); + pstmt.setLong(3, id); + pstmt.executeUpdate(); + } } catch (SQLException e) { throw new CloudRuntimeException("Unable to create service/provider map for network offerings", e); @@ -1175,7 +1207,7 @@ public class Upgrade2214to30 implements DbUpgrade { return ; } - // get all networks that need to be updated to the redundant network offerings + // get all networks that need to be updated to the isolated network offering pstmt = conn .prepareStatement("select id, network_offering_id from `cloud`.`networks` where switch_to_isolated=1"); rs = pstmt.executeQuery(); @@ -1310,4 +1342,107 @@ public class Upgrade2214to30 implements DbUpgrade { } } } + + protected String fixNetworksWithExternalDevices(Connection conn) { + PreparedStatement pstmt = null; + ResultSet rs = null; + ResultSet rs1 = null; + + //Get zones to upgrade + List zoneIds = new ArrayList(); + try { + pstmt = conn.prepareStatement("select id from `cloud`.`data_center` where lb_provider='F5BigIp' or firewall_provider='JuniperSRX' or gateway_provider='JuniperSRX'"); + rs = pstmt.executeQuery(); + while (rs.next()) { + zoneIds.add(rs.getLong(1)); + } + } catch (SQLException e) { + throw new CloudRuntimeException("Unable to switch networks to the new network offering", e); + } + + + String uniqueName = null; + HashMap newNetworkOfferingMap = new HashMap(); + + for (Long zoneId : zoneIds) { + try { + // Find the correct network offering + pstmt = conn + .prepareStatement("select id, network_offering_id from `cloud`.`networks` where guest_type='Virtual' and data_center_id=?"); + pstmt.setLong(1, zoneId); + rs = pstmt.executeQuery(); + pstmt = conn.prepareStatement("select count(*) from `cloud`.`network_offerings`"); + rs1 = pstmt.executeQuery(); + long ntwkOffCount = 0; + while (rs1.next()) { + ntwkOffCount = rs1.getLong(1); + } + + pstmt = conn.prepareStatement("CREATE TEMPORARY TABLE `cloud`.`network_offerings2` ENGINE=MEMORY SELECT * FROM `cloud`.`network_offerings` WHERE id=1"); + pstmt.executeUpdate(); + + + while (rs.next()) { + long networkId = rs.getLong(1); + long networkOfferingId = rs.getLong(2); + s_logger.debug("Updating network offering for the network id=" + networkId + " as it has switch_to_isolated=1"); + Long newNetworkOfferingId = null; + if (!newNetworkOfferingMap.containsKey(networkOfferingId)) { + uniqueName = "Isolated with external providers"; + // clone the record to + pstmt = conn.prepareStatement("INSERT INTO `cloud`.`network_offerings2` SELECT * FROM `cloud`.`network_offerings` WHERE id=?"); + pstmt.setLong(1, networkOfferingId); + pstmt.executeUpdate(); + + //set the new unique name + pstmt = conn.prepareStatement("UPDATE `cloud`.`network_offerings2` SET id=?, unique_name=?, name=? WHERE id=?"); + ntwkOffCount = ntwkOffCount + 1; + newNetworkOfferingId = ntwkOffCount; + pstmt.setLong(1, newNetworkOfferingId); + pstmt.setString(2, uniqueName); + pstmt.setString(3, uniqueName); + pstmt.setLong(4, networkOfferingId); + pstmt.executeUpdate(); + + pstmt = conn.prepareStatement("INSERT INTO `cloud`.`network_offerings` SELECT * from " + + "`cloud`.`network_offerings2` WHERE id=" + newNetworkOfferingId); + pstmt.executeUpdate(); + + pstmt = conn.prepareStatement("UPDATE `cloud`.`networks` SET network_offering_id=? where id=?"); + pstmt.setLong(1, newNetworkOfferingId); + pstmt.setLong(2, networkId); + pstmt.executeUpdate(); + + newNetworkOfferingMap.put(networkOfferingId, ntwkOffCount); + } else { + pstmt = conn.prepareStatement("UPDATE `cloud`.`networks` SET network_offering_id=? where id=?"); + newNetworkOfferingId = newNetworkOfferingMap.get(networkOfferingId); + pstmt.setLong(1, newNetworkOfferingId); + pstmt.setLong(2, networkId); + pstmt.executeUpdate(); + } + + s_logger.debug("Successfully updated network id=" + networkId + " with new network offering id " + newNetworkOfferingId); + } + + } catch (SQLException e) { + throw new CloudRuntimeException("Unable to switch networks to the new network offering", e); + } finally { + try { + pstmt = conn.prepareStatement("DROP TABLE `cloud`.`network_offerings2`"); + pstmt.executeUpdate(); + if (rs != null) { + rs.close(); + } + + if (pstmt != null) { + pstmt.close(); + } + } catch (SQLException e) { + } + } + } + + return uniqueName; + } } diff --git a/server/test/com/cloud/network/MockNetworkManagerImpl.java b/server/test/com/cloud/network/MockNetworkManagerImpl.java index f7380fe0aa0..323e85df475 100755 --- a/server/test/com/cloud/network/MockNetworkManagerImpl.java +++ b/server/test/com/cloud/network/MockNetworkManagerImpl.java @@ -767,14 +767,6 @@ public class MockNetworkManagerImpl implements NetworkManager, Manager, NetworkS } - @Override - public IpAddress allocateIP(long networkId, Account ipOwner, - boolean isSystem) throws ResourceAllocationException, - InsufficientAddressCapacityException, ConcurrentOperationException { - // TODO Auto-generated method stub - return null; - } - @Override public PublicIp assignPublicIpAddress(long dcId, Long podId, Account owner, VlanType type, Long networkId, String requestedIp, boolean isSystem) @@ -881,4 +873,13 @@ public class MockNetworkManagerImpl implements NetworkManager, Manager, NetworkS // TODO Auto-generated method stub return null; } + + /* (non-Javadoc) + * @see com.cloud.network.NetworkService#allocateIP(long, com.cloud.user.Account) + */ + @Override + public IpAddress allocateIP(long networkId, Account ipOwner) throws ResourceAllocationException, InsufficientAddressCapacityException, ConcurrentOperationException { + // TODO Auto-generated method stub + return null; + } } diff --git a/server/test/com/cloud/upgrade/AdvanceZone223To224UpgradeTest.java b/server/test/com/cloud/upgrade/AdvanceZone223To224UpgradeTest.java index 5ddb19079c4..ce47449ef0f 100644 --- a/server/test/com/cloud/upgrade/AdvanceZone223To224UpgradeTest.java +++ b/server/test/com/cloud/upgrade/AdvanceZone223To224UpgradeTest.java @@ -40,8 +40,8 @@ public class AdvanceZone223To224UpgradeTest extends TestCase { } public void test217to22Upgrade() throws SQLException { - s_logger.debug("Finding sample data from 2.2.8"); -// DbTestUtils.executeScript("PreviousDatabaseSchema/2.2.8/dave-sample.sql", false, true); + s_logger.debug("Finding sample data from 2.2.14"); +// DbTestUtils.executeScript("PreviousDatabaseSchema/2.2.14/dave-sample.sql", false, true); Connection conn; PreparedStatement pstmt; @@ -50,9 +50,9 @@ public class AdvanceZone223To224UpgradeTest extends TestCase { DatabaseUpgradeChecker checker = ComponentLocator.inject(DatabaseUpgradeChecker.class); String version = dao.getCurrentVersion(); - assert version.equals("2.2.8") : "Version returned is not 2.2.8 but " + version; + assert version.equals("2.2.14") : "Version returned is not 2.2.14 but " + version; - checker.upgrade("2.2.8", "2.2.12"); + checker.upgrade("2.2.14", "3.0.3"); } } diff --git a/server/test/com/cloud/vm/MockVirtualMachineManagerImpl.java b/server/test/com/cloud/vm/MockVirtualMachineManagerImpl.java index ea4950ba2b0..5a65a6d13f9 100755 --- a/server/test/com/cloud/vm/MockVirtualMachineManagerImpl.java +++ b/server/test/com/cloud/vm/MockVirtualMachineManagerImpl.java @@ -217,4 +217,22 @@ public class MockVirtualMachineManagerImpl implements VirtualMachineManager { return null; } + /* (non-Javadoc) + * @see com.cloud.vm.VirtualMachineManager#checkIfCanUpgrade(com.cloud.vm.VirtualMachine, long) + */ + @Override + public void checkIfCanUpgrade(VirtualMachine vmInstance, long newServiceOfferingId) { + // TODO Auto-generated method stub + + } + + /* (non-Javadoc) + * @see com.cloud.vm.VirtualMachineManager#upgradeVmDb(long, long) + */ + @Override + public boolean upgradeVmDb(long vmId, long serviceOfferingId) { + // TODO Auto-generated method stub + return false; + } + } From d8d4232a7b83c6d50aed34d44541a3bdadb599c2 Mon Sep 17 00:00:00 2001 From: Kelven Yang Date: Fri, 25 May 2012 10:18:26 -0700 Subject: [PATCH 3/8] bug : CS-15080 - check traffic label at host discovery stage also --- .../hypervisor/vmware/VmwareManagerImpl.java | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/server/src/com/cloud/hypervisor/vmware/VmwareManagerImpl.java b/server/src/com/cloud/hypervisor/vmware/VmwareManagerImpl.java index 705b46fcec1..746b582dc6d 100755 --- a/server/src/com/cloud/hypervisor/vmware/VmwareManagerImpl.java +++ b/server/src/com/cloud/hypervisor/vmware/VmwareManagerImpl.java @@ -376,11 +376,9 @@ public class VmwareManagerImpl implements VmwareManager, VmwareStorageMount, Lis mor = serviceContext.getHostMorByPath(hostInventoryPath); String privateTrafficLabel = null; - if (_nexusVSwitchActive) { - privateTrafficLabel = serviceContext.getStockObject("privateTrafficLabel"); - if (privateTrafficLabel == null) { - privateTrafficLabel = _privateNetworkVSwitchName; - } + privateTrafficLabel = serviceContext.getStockObject("privateTrafficLabel"); + if (privateTrafficLabel == null) { + privateTrafficLabel = _privateNetworkVSwitchName; } if(mor != null) { @@ -401,12 +399,11 @@ public class VmwareManagerImpl implements VmwareManager, VmwareStorageMount, Lis } // prepare at least one network on the vswitch to enable OVF importing - String managementPortGroupName = getManagementPortGroupByHost(hostMo); - assert(managementPortGroupName != null); - HostPortGroupSpec spec = hostMo.getPortGroupSpec(managementPortGroupName); String vlanId = null; - if(spec.getVlanId() != 0) { - vlanId = String.valueOf(spec.getVlanId()); + if(privateTrafficLabel != null) { + String[] tokens = privateTrafficLabel.split(","); + if(tokens.length == 2) + vlanId = tokens[1]; } if(!_nexusVSwitchActive) { From 9298e5d25d430b80d9a14b437193ae9802bf363a Mon Sep 17 00:00:00 2001 From: Kelven Yang Date: Fri, 25 May 2012 10:51:39 -0700 Subject: [PATCH 4/8] bug 15080: check traffic type in host discovery stage - cluster level checks --- .../hypervisor/vmware/VmwareManagerImpl.java | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/server/src/com/cloud/hypervisor/vmware/VmwareManagerImpl.java b/server/src/com/cloud/hypervisor/vmware/VmwareManagerImpl.java index 746b582dc6d..90a040b2eb1 100755 --- a/server/src/com/cloud/hypervisor/vmware/VmwareManagerImpl.java +++ b/server/src/com/cloud/hypervisor/vmware/VmwareManagerImpl.java @@ -374,7 +374,6 @@ public class VmwareManagerImpl implements VmwareManager, VmwareStorageMount, Lis ManagedObjectReference mor = null; if (serviceContext != null) mor = serviceContext.getHostMorByPath(hostInventoryPath); - String privateTrafficLabel = null; privateTrafficLabel = serviceContext.getStockObject("privateTrafficLabel"); if (privateTrafficLabel == null) { @@ -393,6 +392,7 @@ public class VmwareManagerImpl implements VmwareManager, VmwareStorageMount, Lis HostFirewallSystemMO firewallMo = hostMo.getHostFirewallSystemMO(); if(firewallMo != null) { if(hostMo.getHostType() == VmwareHostType.ESX) { + firewallMo.enableRuleset("vncServer"); firewallMo.refreshFirewall(); } @@ -436,14 +436,14 @@ public class VmwareManagerImpl implements VmwareManager, VmwareStorageMount, Lis } } - String managementPortGroupName = getManagementPortGroupByHost(hostMo); - assert(managementPortGroupName != null); - - HostPortGroupSpec spec = hostMo.getPortGroupSpec(managementPortGroupName); String vlanId = null; - if(spec.getVlanId() != 0) { - vlanId = String.valueOf(spec.getVlanId()); + if(privateTrafficLabel != null) { + String[] tokens = privateTrafficLabel.split(","); + if(tokens.length == 2) + vlanId = tokens[1]; } + + s_logger.info("Calling prepareNetwork : " + hostMo.getContext().toString()); // prepare at least one network on the vswitch to enable OVF importing if(!_nexusVSwitchActive) { @@ -467,12 +467,11 @@ public class VmwareManagerImpl implements VmwareManager, VmwareStorageMount, Lis } } - String managementPortGroupName = getManagementPortGroupByHost(hostMo); - assert(managementPortGroupName != null); - HostPortGroupSpec spec = hostMo.getPortGroupSpec(managementPortGroupName); String vlanId = null; - if(spec.getVlanId() != 0) { - vlanId = String.valueOf(spec.getVlanId()); + if(privateTrafficLabel != null) { + String[] tokens = privateTrafficLabel.split(","); + if(tokens.length == 2) + vlanId = tokens[1]; } // prepare at least one network on the vswitch to enable OVF importing From 874544fd64419724835250eb75778980a51b6a0f Mon Sep 17 00:00:00 2001 From: Kelven Yang Date: Wed, 30 May 2012 10:35:52 -0700 Subject: [PATCH 5/8] bug CS-15119: check previously named datastore before we mount new one to support backwards compatibility Reviewed-by:Anthony --- .../cloud/hypervisor/vmware/resource/VmwareResource.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/core/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java b/core/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java index 73e1754645b..f882046585c 100755 --- a/core/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java +++ b/core/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java @@ -2341,8 +2341,11 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa throw new Exception("Unsupported storage pool type " + pool.getType()); } - ManagedObjectReference morDatastore = hyperHost.mountDatastore(pool.getType() == StoragePoolType.VMFS, pool.getHost(), - pool.getPort(), pool.getPath(), pool.getUuid().replace("-", "")); + ManagedObjectReference morDatastore = null; + morDatastore = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, pool.getUuid()); + if(morDatastore == null) + morDatastore = hyperHost.mountDatastore(pool.getType() == StoragePoolType.VMFS, pool.getHost(), + pool.getPort(), pool.getPath(), pool.getUuid().replace("-", "")); assert (morDatastore != null); DatastoreSummary summary = new DatastoreMO(getServiceContext(), morDatastore).getSummary(); From 8b6936bde6dc783ad7a31e227fa555e4e2984159 Mon Sep 17 00:00:00 2001 From: Kelven Yang Date: Thu, 31 May 2012 11:32:04 -0700 Subject: [PATCH 6/8] CS-15080: VMware control network is CloudStack management network, correct the way to send down a correct traffic label to VMware resource Reviewed-by: Anthony --- .../hypervisor/vmware/resource/VmwareResource.java | 1 - server/src/com/cloud/network/NetworkManagerImpl.java | 10 +++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/core/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java b/core/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java index f882046585c..f4771b8fc2a 100755 --- a/core/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java +++ b/core/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java @@ -230,7 +230,6 @@ import com.vmware.vim25.VirtualMachineGuestOsIdentifier; import com.vmware.vim25.VirtualMachinePowerState; import com.vmware.vim25.VirtualMachineRuntimeInfo; import com.vmware.vim25.VirtualSCSISharing; -import com.xensource.xenapi.VLAN; public class VmwareResource implements StoragePoolResource, ServerResource, VmwareHostService { private static final Logger s_logger = Logger.getLogger(VmwareResource.class); diff --git a/server/src/com/cloud/network/NetworkManagerImpl.java b/server/src/com/cloud/network/NetworkManagerImpl.java index a4121beaa1e..7c11f3411bc 100755 --- a/server/src/com/cloud/network/NetworkManagerImpl.java +++ b/server/src/com/cloud/network/NetworkManagerImpl.java @@ -6060,12 +6060,16 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag @Override public String getNetworkTag(HypervisorType hType, Network network) { // no network tag for control traffic type - if (network.getTrafficType() == TrafficType.Control) { + TrafficType effectiveTrafficType = network.getTrafficType(); + if(hType == HypervisorType.VMware && effectiveTrafficType == TrafficType.Control) + effectiveTrafficType = TrafficType.Management; + + if (effectiveTrafficType == TrafficType.Control) { return null; } Long physicalNetworkId = null; - if (network.getTrafficType() != TrafficType.Guest) { + if (effectiveTrafficType != TrafficType.Guest) { physicalNetworkId = getNonGuestNetworkPhysicalNetworkId(network); } else { NetworkOffering offering = _configMgr.getNetworkOffering(network.getNetworkOfferingId()); @@ -6078,7 +6082,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag return null; } - return _pNTrafficTypeDao.getNetworkTag(physicalNetworkId, network.getTrafficType(), hType); + return _pNTrafficTypeDao.getNetworkTag(physicalNetworkId, effectiveTrafficType, hType); } protected Long getNonGuestNetworkPhysicalNetworkId(Network network) { From d0bdab98ae80605a25e69da5d30d68add66d3e60 Mon Sep 17 00:00:00 2001 From: Kelven Yang Date: Fri, 1 Jun 2012 10:33:14 -0700 Subject: [PATCH 7/8] bug CS-15191: remove a sanity check that prevent us from getting traffic lable under VMware Reviewed-by: anthony --- server/src/com/cloud/network/NetworkManagerImpl.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/server/src/com/cloud/network/NetworkManagerImpl.java b/server/src/com/cloud/network/NetworkManagerImpl.java index 7c11f3411bc..60c98b86d96 100755 --- a/server/src/com/cloud/network/NetworkManagerImpl.java +++ b/server/src/com/cloud/network/NetworkManagerImpl.java @@ -6087,10 +6087,14 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag protected Long getNonGuestNetworkPhysicalNetworkId(Network network) { // no physical network for control traffic type + + // have to remove this sanity check as VMware control network is management network + // we need to retrieve traffic label information through physical network +/* if (network.getTrafficType() == TrafficType.Control) { return null; } - +*/ Long physicalNetworkId = network.getPhysicalNetworkId(); if (physicalNetworkId == null) { From ef4f0c695a778aac493e8469b4813f4b63e4d18c Mon Sep 17 00:00:00 2001 From: Kelven Yang Date: Fri, 1 Jun 2012 11:36:16 -0700 Subject: [PATCH 8/8] bug CS-15179: ensure route before connecting Reviewed-by: anthony --- .../src/com/cloud/consoleproxy/ConsoleProxyVncClient.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/console-proxy/src/com/cloud/consoleproxy/ConsoleProxyVncClient.java b/console-proxy/src/com/cloud/consoleproxy/ConsoleProxyVncClient.java index 729302559dd..0feb5f68dbb 100644 --- a/console-proxy/src/com/cloud/consoleproxy/ConsoleProxyVncClient.java +++ b/console-proxy/src/com/cloud/consoleproxy/ConsoleProxyVncClient.java @@ -70,6 +70,8 @@ public class ConsoleProxyVncClient extends ConsoleProxyClientBase { if(tunnelUrl != null && !tunnelUrl.isEmpty() && tunnelSession != null && !tunnelSession.isEmpty()) { URI uri = new URI(tunnelUrl); s_logger.info("Connect to VNC server via tunnel. url: " + tunnelUrl + ", session: " + tunnelSession); + + ConsoleProxy.ensureRoute(uri.getHost()); client.connectTo( uri.getHost(), uri.getPort(), uri.getPath() + "?" + uri.getQuery(), @@ -77,6 +79,7 @@ public class ConsoleProxyVncClient extends ConsoleProxyClientBase { getClientHostPassword()); } else { s_logger.info("Connect to VNC server directly. host: " + getClientHostAddress() + ", port: " + getClientHostPort()); + ConsoleProxy.ensureRoute(getClientHostAddress()); client.connectTo(getClientHostAddress(), getClientHostPort(), getClientHostPassword()); } } catch (UnknownHostException e) {