mirror of https://github.com/apache/cloudstack.git
Creating vservice node and associating it with port profile in nexus for guest VMs
This commit is contained in:
parent
387545caff
commit
2ce7cdc756
|
|
@ -49,7 +49,9 @@ import com.cloud.hypervisor.HypervisorGuru;
|
|||
import com.cloud.hypervisor.HypervisorGuruBase;
|
||||
import com.cloud.hypervisor.vmware.manager.VmwareManager;
|
||||
import com.cloud.hypervisor.vmware.mo.VirtualEthernetCardType;
|
||||
import com.cloud.network.Network.Provider;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.dao.NetworkDao;
|
||||
import com.cloud.network.dao.NetworkVO;
|
||||
|
|
@ -140,13 +142,23 @@ public class VMwareGuru extends HypervisorGuruBase implements HypervisorGuru {
|
|||
}
|
||||
details.put(VmDetailConstants.ROOK_DISK_CONTROLLER, _vmwareMgr.getRootDiskController());
|
||||
}
|
||||
|
||||
|
||||
List<NicProfile> nicProfiles = vm.getNics();
|
||||
|
||||
for(NicProfile nicProfile : nicProfiles) {
|
||||
if(nicProfile.getTrafficType() == TrafficType.Guest) {
|
||||
if(_networkMgr.isProviderSupportServiceInNetwork(nicProfile.getNetworkId(), Service.Firewall, Provider.CiscoVnmc)) {
|
||||
details.put("ConfigureVServiceInNexus", Boolean.TRUE.toString());
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
to.setDetails(details);
|
||||
|
||||
if(vm.getVirtualMachine() instanceof DomainRouterVO) {
|
||||
List<NicProfile> nicProfiles = vm.getNics();
|
||||
NicProfile publicNicProfile = null;
|
||||
|
||||
NicProfile publicNicProfile = null;
|
||||
for(NicProfile nicProfile : nicProfiles) {
|
||||
if(nicProfile.getTrafficType() == TrafficType.Public) {
|
||||
publicNicProfile = nicProfile;
|
||||
|
|
|
|||
|
|
@ -200,6 +200,7 @@ import com.cloud.network.HAProxyConfigurator;
|
|||
import com.cloud.network.LoadBalancerConfigurator;
|
||||
import com.cloud.network.Networks;
|
||||
import com.cloud.network.Networks.BroadcastDomainType;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.rules.FirewallRule;
|
||||
import com.cloud.resource.ServerResource;
|
||||
import com.cloud.serializer.GsonHelper;
|
||||
|
|
@ -1318,7 +1319,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||
|
||||
NicTO nicTo = cmd.getNic();
|
||||
VirtualDevice nic;
|
||||
Pair<ManagedObjectReference, String> networkInfo = prepareNetworkFromNicInfo(vmMo.getRunningHost(), nicTo);
|
||||
Pair<ManagedObjectReference, String> networkInfo = prepareNetworkFromNicInfo(vmMo.getRunningHost(), nicTo, false);
|
||||
if (mgr.getNexusVSwitchGlobalParameter()) {
|
||||
String dvSwitchUuid;
|
||||
ManagedObjectReference dcMor = hyperHost.getHyperHostDatacenter();
|
||||
|
|
@ -1556,7 +1557,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||
vmMo.getRunningHost(), vlanId, null, null, this._ops_timeout, true);
|
||||
} else {
|
||||
networkInfo = HypervisorHostHelper.prepareNetwork(this._publicNetworkVSwitchName, "cloud.public",
|
||||
vmMo.getRunningHost(), vlanId, null, null, this._ops_timeout);
|
||||
vmMo.getRunningHost(), vlanId, false, null, null, this._ops_timeout);
|
||||
}
|
||||
|
||||
int nicIndex = allocPublicNicIndex(vmMo);
|
||||
|
|
@ -2264,7 +2265,8 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||
for (NicTO nicTo : sortNicsByDeviceId(nics)) {
|
||||
s_logger.info("Prepare NIC device based on NicTO: " + _gson.toJson(nicTo));
|
||||
|
||||
Pair<ManagedObjectReference, String> networkInfo = prepareNetworkFromNicInfo(vmMo.getRunningHost(), nicTo);
|
||||
boolean configureVServiceInNexus = (nicTo.getType() == TrafficType.Guest) && (vmSpec.getDetails().containsKey("ConfigureVServiceInNexus"));
|
||||
Pair<ManagedObjectReference, String> networkInfo = prepareNetworkFromNicInfo(vmMo.getRunningHost(), nicTo, configureVServiceInNexus);
|
||||
if (mgr.getNexusVSwitchGlobalParameter()) {
|
||||
String dvSwitchUuid;
|
||||
ManagedObjectReference dcMor = hyperHost.getHyperHostDatacenter();
|
||||
|
|
@ -2463,22 +2465,21 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||
return defaultVlan;
|
||||
}
|
||||
|
||||
private Pair<ManagedObjectReference, String> prepareNetworkFromNicInfo(HostMO hostMo, NicTO nicTo) throws Exception {
|
||||
private Pair<ManagedObjectReference, String> prepareNetworkFromNicInfo(HostMO hostMo, NicTO nicTo, boolean configureVServiceInNexus) throws Exception {
|
||||
|
||||
Pair<String, String> switchName = getTargetSwitch(nicTo);
|
||||
Pair<String, String> switchName = getTargetSwitch(nicTo);
|
||||
String namePrefix = getNetworkNamePrefix(nicTo);
|
||||
Pair<ManagedObjectReference, String> networkInfo = null;
|
||||
|
||||
s_logger.info("Prepare network on vSwitch: " + switchName + " with name prefix: " + namePrefix);
|
||||
|
||||
if(!_nexusVSwitch) {
|
||||
networkInfo = HypervisorHostHelper.prepareNetwork(switchName.first(), namePrefix, hostMo, getVlanInfo(nicTo, switchName.second()),
|
||||
nicTo.getNetworkRateMbps(), nicTo.getNetworkRateMulticastMbps(), _ops_timeout,
|
||||
if (!_nexusVSwitch) {
|
||||
networkInfo = HypervisorHostHelper.prepareNetwork(switchName.first(), namePrefix, hostMo, getVlanInfo(nicTo, switchName.second()),
|
||||
nicTo.getNetworkRateMbps(), nicTo.getNetworkRateMulticastMbps(), _ops_timeout,
|
||||
!namePrefix.startsWith("cloud.private"));
|
||||
}
|
||||
else {
|
||||
networkInfo = HypervisorHostHelper.prepareNetwork(switchName.first(), namePrefix, hostMo, getVlanInfo(nicTo, switchName.second()),
|
||||
nicTo.getNetworkRateMbps(), nicTo.getNetworkRateMulticastMbps(), _ops_timeout);
|
||||
} else {
|
||||
networkInfo = HypervisorHostHelper.prepareNetwork(switchName.first(), namePrefix, hostMo, getVlanInfo(nicTo, switchName.second()),
|
||||
configureVServiceInNexus, nicTo.getNetworkRateMbps(), nicTo.getNetworkRateMulticastMbps(), _ops_timeout);
|
||||
}
|
||||
|
||||
return networkInfo;
|
||||
|
|
@ -2966,7 +2967,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||
NicTO[] nics = vm.getNics();
|
||||
for (NicTO nic : nics) {
|
||||
// prepare network on the host
|
||||
prepareNetworkFromNicInfo(new HostMO(getServiceContext(), _morHyperHost), nic);
|
||||
prepareNetworkFromNicInfo(new HostMO(getServiceContext(), _morHyperHost), nic, false);
|
||||
}
|
||||
|
||||
String secStoreUrl = mgr.getSecondaryStorageStoreUrl(Long.parseLong(_dcId));
|
||||
|
|
|
|||
|
|
@ -158,7 +158,7 @@ public class HypervisorHostHelper {
|
|||
}
|
||||
|
||||
public static void createPortProfile(VmwareContext context, String ethPortProfileName, String networkName,
|
||||
Integer vlanId, Integer networkRateMbps, long peakBandwidth, long burstSize) throws Exception {
|
||||
Integer vlanId, Integer networkRateMbps, long peakBandwidth, long burstSize, boolean configureVServiceInNexus) throws Exception {
|
||||
Map<String, String> vsmCredentials = getValidatedVsmCredentials(context);
|
||||
String vsmIp = vsmCredentials.get("vsmip");
|
||||
String vsmUserName = vsmCredentials.get("vsmusername");
|
||||
|
|
@ -229,7 +229,15 @@ public class HypervisorHostHelper {
|
|||
netconfClient.addPortProfile(networkName, PortProfileType.vethernet, BindingType.portbindingstatic, SwitchPortMode.access, 0);
|
||||
} else {
|
||||
s_logger.info("Adding port profile configured over VLAN : " + vlanId.toString());
|
||||
netconfClient.addPortProfile(networkName, PortProfileType.vethernet, BindingType.portbindingstatic, SwitchPortMode.access, vlanId.intValue());
|
||||
if (!configureVServiceInNexus) {
|
||||
netconfClient.addPortProfile(networkName, PortProfileType.vethernet, BindingType.portbindingstatic, SwitchPortMode.access, vlanId.intValue());
|
||||
} else {
|
||||
String tenant = "vlan-" + vlanId.intValue();
|
||||
String vdc = "root/" + tenant + "/VDC-" + tenant;
|
||||
String esp = "ESP-" + tenant;
|
||||
netconfClient.addVServiceNode(vlanId.toString(), "10.1.1.1");
|
||||
netconfClient.addPortProfile(networkName, PortProfileType.vethernet, BindingType.portbindingstatic, SwitchPortMode.access, vlanId.intValue(), vdc, esp);
|
||||
}
|
||||
}
|
||||
} catch (CloudRuntimeException e) {
|
||||
msg = "Failed to add vEthernet port profile " + networkName + "." + ". Exception: " + e.toString();
|
||||
|
|
@ -394,7 +402,7 @@ public class HypervisorHostHelper {
|
|||
*/
|
||||
|
||||
public static Pair<ManagedObjectReference, String> prepareNetwork(String ethPortProfileName, String namePrefix,
|
||||
HostMO hostMo, String vlanId, Integer networkRateMbps, Integer networkRateMulticastMbps, long timeOutMs)
|
||||
HostMO hostMo, String vlanId, boolean configureVServiceInNexus, Integer networkRateMbps, Integer networkRateMulticastMbps, long timeOutMs)
|
||||
throws Exception {
|
||||
ManagedObjectReference morNetwork = null;
|
||||
VmwareContext context = hostMo.getContext();
|
||||
|
|
@ -459,7 +467,7 @@ public class HypervisorHostHelper {
|
|||
boolean bWaitPortGroupReady = false;
|
||||
if (!dataCenterMo.hasDvPortGroup(networkName)) {
|
||||
s_logger.info("Port profile " + networkName + " not found.");
|
||||
createPortProfile(context, ethPortProfileName, networkName, vid, networkRateMbps, peakBandwidth, burstSize);
|
||||
createPortProfile(context, ethPortProfileName, networkName, vid, networkRateMbps, peakBandwidth, burstSize, configureVServiceInNexus);
|
||||
bWaitPortGroupReady = true;
|
||||
} else {
|
||||
s_logger.info("Port profile " + networkName + " found.");
|
||||
|
|
|
|||
Loading…
Reference in New Issue