mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Modified cloud-early-config to configure, when the VR boots up in HyperV Environment
Implemented commands that are required for VR to bootup and Vm deployment to work Modified hyperv agent code, to deploy VR with Boot Args, boot args passed to VR using KVP Exchange Component. Fix for VR to boot up and get configured with boot args, Fixed issue in VolumeOrchestrator Implemented SetFirewallRulesCommand in HyperV Resource Implemented VR network commands to provide the necessary services from VR Fixed hyperv localstorage path encode url issue. encode is converting space to '+'
This commit is contained in:
parent
f9f196a46a
commit
989c6e6914
@ -1222,8 +1222,11 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati
|
||||
public void updateVolumeDiskChain(long volumeId, String path, String chainInfo) {
|
||||
VolumeVO vol = _volsDao.findById(volumeId);
|
||||
boolean needUpdate = false;
|
||||
// Volume path is not getting updated in the DB, need to find reason and fix the issue.
|
||||
if (vol.getPath() == null)
|
||||
return;
|
||||
if(!vol.getPath().equalsIgnoreCase(path))
|
||||
needUpdate = true;
|
||||
needUpdate = true;
|
||||
|
||||
if(chainInfo != null && (vol.getChainInfo() == null || !chainInfo.equalsIgnoreCase(vol.getChainInfo())))
|
||||
needUpdate = true;
|
||||
|
||||
@ -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,93 @@ 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(90000);
|
||||
SetState(newVm, RequiredState.Reboot);
|
||||
// wait for the second boot and then return with suces
|
||||
System.Threading.Thread.Sleep(50000);
|
||||
}
|
||||
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>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -186,6 +186,7 @@ public class CloudStackPrimaryDataStoreLifeCycleImpl implements PrimaryDataStore
|
||||
Object localStorage = dsInfos.get("localStorage");
|
||||
if (localStorage != null) {
|
||||
hostPath = hostPath.replaceFirst("/", "");
|
||||
hostPath = hostPath.replace("+"," ");
|
||||
}
|
||||
String userInfo = uri.getUserInfo();
|
||||
int port = uri.getPort();
|
||||
|
||||
@ -130,12 +130,11 @@ get_boot_params() {
|
||||
vmware)
|
||||
vmtoolsd --cmd 'machine.id.get' > /var/cache/cloud/cmdline
|
||||
;;
|
||||
virtualpc)
|
||||
# Hyper-V is recognized as virtualpc hypervisor type. Boot args are passed in the NTFS data-disk
|
||||
mkdir -p $EXTRA_MOUNT
|
||||
mount -t ntfs /dev/sdb1 $EXTRA_MOUNT
|
||||
cp -f $EXTRA_MOUNT/cmdline /var/cache/cloud/cmdline
|
||||
umount $EXTRA_MOUNT
|
||||
virtualpc|hyperv)
|
||||
# Hyper-V is recognized as virtualpc hypervisor type. Boot args are passed using KVP Daemon
|
||||
#waiting for the hv_kvp_daemon to start up
|
||||
#sleep 30 need to fix the race condition of hv_kvp_daemon and cloud-early-config
|
||||
cp -f /var/opt/hyperv/.kvp_pool_0 /var/cache/cloud/cmdline
|
||||
;;
|
||||
esac
|
||||
|
||||
@ -157,6 +156,10 @@ patch() {
|
||||
cdrom_dev=/dev/cdrom
|
||||
elif [ -e /dev/cdrom1 ]; then
|
||||
cdrom_dev=/dev/cdrom1
|
||||
elif [ -e /dev/cdrom2 ]; then
|
||||
cdrom_dev=/dev/cdrom2
|
||||
elif [ -e /dev/cdrom3 ]; then
|
||||
cdrom_dev=/dev/cdrom3
|
||||
fi
|
||||
[ -f /var/cache/cloud/authorized_keys ] && privkey=/var/cache/cloud/authorized_keys
|
||||
|
||||
@ -718,7 +721,7 @@ setup_dnsmasq() {
|
||||
[ $ETH0_IP ] && echo "dhcp-option=6,$NS" >> /etc/dnsmasq.conf
|
||||
[ $ETH0_IP6 ] && echo "dhcp-option=option6:dns-server,$NS6" >> /etc/dnsmasq.conf
|
||||
#adding the name data-server to the /etc/hosts for allowing the access to user-data service and ssh-key reset in every subnet.
|
||||
//removing the existing entires to avoid duplicates on restarts.
|
||||
#removing the existing entires to avoid duplicates on restarts.
|
||||
sed -i '/data-server/d' /etc/hosts
|
||||
if [ -n "$ETH0_IP" ]
|
||||
then
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user