mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
CLOUDSTACK-6106 Agent side changes for VPC on Hyper-V
This commit is contained in:
parent
1b4325d2c8
commit
4523f5d8de
@ -992,6 +992,7 @@ namespace HypervResource
|
|||||||
using (log4net.NDC.Push(Guid.NewGuid().ToString()))
|
using (log4net.NDC.Push(Guid.NewGuid().ToString()))
|
||||||
{
|
{
|
||||||
logger.Info(CloudStackTypes.PlugNicCommand + cmd.ToString());
|
logger.Info(CloudStackTypes.PlugNicCommand + cmd.ToString());
|
||||||
|
|
||||||
object ansContent = new
|
object ansContent = new
|
||||||
{
|
{
|
||||||
result = true,
|
result = true,
|
||||||
@ -1299,8 +1300,15 @@ namespace HypervResource
|
|||||||
String vmName = cmd.vmName;
|
String vmName = cmd.vmName;
|
||||||
uint vlan = (uint)cmd.vlan;
|
uint vlan = (uint)cmd.vlan;
|
||||||
string macAddress = cmd.macAddress;
|
string macAddress = cmd.macAddress;
|
||||||
|
uint pos = cmd.index;
|
||||||
|
if (macAddress != null)
|
||||||
|
{
|
||||||
wmiCallsV2.ModifyVmVLan(vmName, vlan, macAddress);
|
wmiCallsV2.ModifyVmVLan(vmName, vlan, macAddress);
|
||||||
|
}
|
||||||
|
else if (pos > 1)
|
||||||
|
{
|
||||||
|
wmiCallsV2.ModifyVmVLan(vmName, vlan, pos);
|
||||||
|
}
|
||||||
result = true;
|
result = true;
|
||||||
|
|
||||||
object ansContent = new
|
object ansContent = new
|
||||||
|
|||||||
@ -70,5 +70,6 @@ namespace HypervResource
|
|||||||
void SetState(ComputerSystem vm, ushort requiredState);
|
void SetState(ComputerSystem vm, ushort requiredState);
|
||||||
Dictionary<String, VmState> GetVmSync(String privateIpAddress);
|
Dictionary<String, VmState> GetVmSync(String privateIpAddress);
|
||||||
void ModifyVmVLan(string vmName, uint vlanid, string mac);
|
void ModifyVmVLan(string vmName, uint vlanid, string mac);
|
||||||
|
void ModifyVmVLan(string vmName, uint vlanid, uint pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -229,6 +229,7 @@ namespace HypervResource
|
|||||||
string errMsg = vmName;
|
string errMsg = vmName;
|
||||||
var diskDrives = vmInfo.disks;
|
var diskDrives = vmInfo.disks;
|
||||||
var bootArgs = vmInfo.bootArgs;
|
var bootArgs = vmInfo.bootArgs;
|
||||||
|
string defaultvlan = "4094";
|
||||||
|
|
||||||
// assert
|
// assert
|
||||||
errMsg = vmName + ": missing disk information, array empty or missing, agent expects *at least* one disk for a VM";
|
errMsg = vmName + ": missing disk information, array empty or missing, agent expects *at least* one disk for a VM";
|
||||||
@ -391,6 +392,8 @@ namespace HypervResource
|
|||||||
string vlan = null;
|
string vlan = null;
|
||||||
string isolationUri = nic.isolationUri;
|
string isolationUri = nic.isolationUri;
|
||||||
string broadcastUri = nic.broadcastUri;
|
string broadcastUri = nic.broadcastUri;
|
||||||
|
string nicIp = nic.ip;
|
||||||
|
string nicNetmask = nic.netmask;
|
||||||
if ( (broadcastUri != null ) || (isolationUri != null && isolationUri.StartsWith("vlan://")))
|
if ( (broadcastUri != null ) || (isolationUri != null && isolationUri.StartsWith("vlan://")))
|
||||||
{
|
{
|
||||||
if (broadcastUri != null && broadcastUri.StartsWith("storage"))
|
if (broadcastUri != null && broadcastUri.StartsWith("storage"))
|
||||||
@ -415,6 +418,10 @@ namespace HypervResource
|
|||||||
throw ex;
|
throw ex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(nicIp.Equals("0.0.0.0") && nicNetmask.Equals("255.255.255.255") ) {
|
||||||
|
// this is the extra nic added to VR.
|
||||||
|
vlan = defaultvlan;
|
||||||
|
}
|
||||||
|
|
||||||
if (nicCount == 2)
|
if (nicCount == 2)
|
||||||
{
|
{
|
||||||
@ -914,7 +921,6 @@ namespace HypervResource
|
|||||||
return new ResourceAllocationSettingData((ManagementBaseObject)defaultDiskDriveSettings.LateBoundObject.Clone());
|
return new ResourceAllocationSettingData((ManagementBaseObject)defaultDiskDriveSettings.LateBoundObject.Clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Modify the systemvm nic's VLAN id
|
// Modify the systemvm nic's VLAN id
|
||||||
public void ModifyVmVLan(string vmName, uint vlanid, String mac)
|
public void ModifyVmVLan(string vmName, uint vlanid, String mac)
|
||||||
{
|
{
|
||||||
@ -945,6 +951,24 @@ namespace HypervResource
|
|||||||
vlanSettings.LateBoundObject.GetText(TextFormat.CimDtd20)});
|
vlanSettings.LateBoundObject.GetText(TextFormat.CimDtd20)});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Modify the systemvm nic's VLAN id
|
||||||
|
public void ModifyVmVLan(string vmName, uint vlanid, uint pos)
|
||||||
|
{
|
||||||
|
ComputerSystem vm = GetComputerSystem(vmName);
|
||||||
|
SyntheticEthernetPortSettingData[] nicSettingsViaVm = GetEthernetPortSettings(vm);
|
||||||
|
// Obtain controller for Hyper-V virtualisation subsystem
|
||||||
|
VirtualSystemManagementService vmMgmtSvc = GetVirtualisationSystemManagementService();
|
||||||
|
|
||||||
|
EthernetPortAllocationSettingData[] ethernetConnections = GetEthernetConnections(vm);
|
||||||
|
EthernetSwitchPortVlanSettingData vlanSettings = GetVlanSettings(ethernetConnections[pos]);
|
||||||
|
|
||||||
|
//Assign configuration to new NIC
|
||||||
|
vlanSettings.LateBoundObject["AccessVlanId"] = vlanid;
|
||||||
|
vlanSettings.LateBoundObject["OperationMode"] = 1;
|
||||||
|
ModifyFeatureVmResources(vmMgmtSvc, vm, new String[] {
|
||||||
|
vlanSettings.LateBoundObject.GetText(TextFormat.CimDtd20)});
|
||||||
|
}
|
||||||
|
|
||||||
public void AttachIso(string displayName, string iso)
|
public void AttachIso(string displayName, string iso)
|
||||||
{
|
{
|
||||||
logger.DebugFormat("Got request to attach iso {0} to vm {1}", iso, displayName);
|
logger.DebugFormat("Got request to attach iso {0} to vm {1}", iso, displayName);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user