CLOUDSTACK-6106 Agent side changes for VPC on Hyper-V

This commit is contained in:
Rajesh Battala 2014-03-12 07:45:50 +05:30
parent 1b4325d2c8
commit 4523f5d8de
3 changed files with 37 additions and 4 deletions

View File

@ -992,6 +992,7 @@ namespace HypervResource
using (log4net.NDC.Push(Guid.NewGuid().ToString()))
{
logger.Info(CloudStackTypes.PlugNicCommand + cmd.ToString());
object ansContent = new
{
result = true,
@ -1299,9 +1300,16 @@ namespace HypervResource
String vmName = cmd.vmName;
uint vlan = (uint)cmd.vlan;
string macAddress = cmd.macAddress;
wmiCallsV2.ModifyVmVLan(vmName, vlan, macAddress);
result = true;
uint pos = cmd.index;
if (macAddress != null)
{
wmiCallsV2.ModifyVmVLan(vmName, vlan, macAddress);
}
else if (pos > 1)
{
wmiCallsV2.ModifyVmVLan(vmName, vlan, pos);
}
result = true;
object ansContent = new
{

View File

@ -70,5 +70,6 @@ namespace HypervResource
void SetState(ComputerSystem vm, ushort requiredState);
Dictionary<String, VmState> GetVmSync(String privateIpAddress);
void ModifyVmVLan(string vmName, uint vlanid, string mac);
void ModifyVmVLan(string vmName, uint vlanid, uint pos);
}
}

View File

@ -229,6 +229,7 @@ namespace HypervResource
string errMsg = vmName;
var diskDrives = vmInfo.disks;
var bootArgs = vmInfo.bootArgs;
string defaultvlan = "4094";
// assert
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 isolationUri = nic.isolationUri;
string broadcastUri = nic.broadcastUri;
string nicIp = nic.ip;
string nicNetmask = nic.netmask;
if ( (broadcastUri != null ) || (isolationUri != null && isolationUri.StartsWith("vlan://")))
{
if (broadcastUri != null && broadcastUri.StartsWith("storage"))
@ -415,6 +418,10 @@ namespace HypervResource
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)
{
@ -913,7 +920,6 @@ namespace HypervResource
ResourceAllocationSettingData defaultDiskDriveSettings = defaultDiskDriveSettingsObjs.OfType<ResourceAllocationSettingData>().First();
return new ResourceAllocationSettingData((ManagementBaseObject)defaultDiskDriveSettings.LateBoundObject.Clone());
}
// Modify the systemvm nic's VLAN id
public void ModifyVmVLan(string vmName, uint vlanid, String mac)
@ -945,6 +951,24 @@ namespace HypervResource
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)
{
logger.DebugFormat("Got request to attach iso {0} to vm {1}", iso, displayName);