You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ra...@apache.org on 2013/10/11 13:58:54 UTC
git commit: updated refs/heads/hyperv to c15a295
Updated Branches:
refs/heads/hyperv 16422cbc0 -> c15a295e9
Modified hyperv agent code, to deploy VR with Boot Args, boot args passed to VR using KVP Exchange Component.
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/c15a295e
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/c15a295e
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/c15a295e
Branch: refs/heads/hyperv
Commit: c15a295e91bf4335a111d6fabe793a54ab45fe0d
Parents: 16422cb
Author: Rajesh Battala <ra...@citrix.com>
Authored: Fri Oct 11 17:26:15 2013 +0530
Committer: Rajesh Battala <ra...@citrix.com>
Committed: Fri Oct 11 17:26:15 2013 +0530
----------------------------------------------------------------------
.../ServerResource/HypervResource/WmiCalls.cs | 88 ++++++++++++++++----
1 file changed, 73 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c15a295e/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/WmiCalls.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/WmiCalls.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/WmiCalls.cs
index 9b00c82..0fbb00b 100644
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/WmiCalls.cs
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/WmiCalls.cs
@@ -167,6 +167,7 @@ namespace HypervResource
int memSize = vmInfo.maxRam / 1048576;
string errMsg = vmName;
var diskDrives = vmInfo.disks;
+ var bootArgs = vmInfo.bootArgs;
// assert
errMsg = vmName + ": missing disk information, array empty or missing, agent expects *at least* one disk for a VM";
@@ -283,34 +284,91 @@ namespace HypervResource
AddDiskDriveToVm(newVm, vhdFile, ideCtrllr, driveResourceType);
}
- // add nics
- foreach (var nic in nicInfo)
+ // Add the Nics to the VM in the deviceId order.
+ for (int i = 0; i <= 2; i++)
{
- string mac = nic.mac;
- string vlan = null;
- string isolationUri = nic.isolationUri;
- if (isolationUri != null && isolationUri.StartsWith("vlan://") && !isolationUri.Equals("vlan://untagged"))
+ foreach (var nic in nicInfo)
{
- vlan = isolationUri.Substring("vlan://".Length);
- int tmp;
- if (!int.TryParse(vlan, out tmp))
+
+ int nicid = nic.deviceId;
+ string mac = nic.mac;
+ string vlan = null;
+ string isolationUri = nic.isolationUri;
+ if (isolationUri != null && isolationUri.StartsWith("vlan://") && !isolationUri.Equals("vlan://untagged"))
{
- // TODO: double check exception type
- errMsg = string.Format("Invalid VLAN value {0} for on vm {1} for nic uuid {2}", isolationUri, vmName, nic.uuid);
- var ex = new WmiException(errMsg);
- logger.Error(errMsg, ex);
- throw ex;
+ vlan = isolationUri.Substring("vlan://".Length);
+ int tmp;
+ if (!int.TryParse(vlan, out tmp))
+ {
+ // TODO: double check exception type
+ errMsg = string.Format("Invalid VLAN value {0} for on vm {1} for nic uuid {2}", isolationUri, vmName, nic.uuid);
+ var ex = new WmiException(errMsg);
+ logger.Error(errMsg, ex);
+ throw ex;
+ }
+ }
+
+ if (nicid == i)
+ {
+ CreateNICforVm(newVm, mac, vlan);
+ break;
}
}
- CreateNICforVm(newVm, mac, vlan);
+ }
+
+ // pass the boot args for the VM using KVP component.
+ // We need to pass the boot args to system vm's to get them configured with cloudstack configuration.
+ // Add new user data
+ var vm = WmiCallsV2.GetComputerSystem(vmName);
+ if (bootArgs != null)
+ {
+
+ String bootargs = bootArgs;
+ WmiCallsV2.AddUserData(vm, bootargs);
+
+
+ // Get existing KVP
+ //var vmSettings = WmiCallsV2.GetVmSettings(vm);
+ //var kvpInfo = WmiCallsV2.GetKvpSettings(vmSettings);
+ //logger.DebugFormat("Boot Args presisted on the VM are ", kvpInfo);
+ //WmiCallsV2.AddUserData(vm, bootargs);
+
+ // Verify key added to subsystem
+ //kvpInfo = WmiCallsV2.GetKvpSettings(vmSettings);
+
+ // HostExchangesItems are embedded objects in the sense that the object value is stored and not a reference to the object.
+ //kvpProps = kvpInfo.HostExchangeItems;
+
+ }
+ // call patch systemvm iso only for systemvms
+ if (vmName.StartsWith("r-"))
+ {
+ patchSystemVmIso(vmName);
}
logger.DebugFormat("Starting VM {0}", vmName);
SetState(newVm, RequiredState.Enabled);
+
+ // we need to reboot to get the hv kvp daemon get started vr gets configured.
+ if (vmName.StartsWith("r-"))
+ {
+ System.Threading.Thread.Sleep(8000);
+ SetState(newVm, RequiredState.Reboot);
+ }
logger.InfoFormat("Started VM {0}", vmName);
return newVm;
}
+ /// this method is to add a dvd drive and attach the systemvm iso.
+ ///
+
+ public static void patchSystemVmIso(String vmName)
+ {
+ ComputerSystem vmObject = WmiCalls.GetComputerSystem(vmName);
+ AddDiskDriveToVm(vmObject, "", "1", IDE_ISO_DRIVE);
+ WmiCalls.AttachIso(vmName, "c:\\systemvm.iso");
+ }
+
/// <summary>
/// Create a disk and attach it to the vm
/// </summary>