public hypervisor_vmware_FreeNAS(hypSpec_vmware spec, NASParams nasParams, clientExecutionMethod newExecMethod = clientExecutionMethod.vmwaretools) : base(spec, newExecMethod) { nas = FreeNasGroup.getOrMake(nasParams.IP, nasParams.username, nasParams.password); }
public static void restoreSnapshot <T>(hypervisorWithSpec <T> hyp, FreeNASWithCaching nas, cancellableDateTime deadline) { hypSpec_withWindbgKernel _spec = hyp.getBaseConnectionSpec(); // Find the device snapshot, so we can get information about it needed to get the ISCSI volume snapshotObjects shotObjects = getSnapshotObjectsFromNAS(nas, _spec.snapshotFullName); // Here we power the server down, tell the iSCSI server to use the right image, and power it back up again. hyp.powerOff(); // Now we can get started. We must remove the 'target to extent' mapping, then the extent. Then we can safely roll back // the ZFS snapshot, and then re-add the extent and mapping. We use a finally block so that it is less likely we will // leave the NAS object in an inconsistent state. // Note that removing the target will also remove any 'target to extent' mapping, so we don't need to do that explicitly. // FreeNAS will take care of it for us. nas.deleteISCSIExtent(shotObjects.extent); nas.waitUntilISCSIConfigFlushed(); try { // Roll back the snapshot. Use a retry, since FreeNAS is complaining the dataset is in use occasionally. int retries = 100; while (true) { try { nas.rollbackSnapshot(shotObjects.shotToRestore); break; } catch (Exception) { if (retries-- == 0) { throw; } deadline.doCancellableSleep(TimeSpan.FromSeconds(6)); // 6 sec * 100 retries = ten minutes } } } finally { // Re-add the extent and target-to-extent mapping. Use the same target ID as the old target-to-extent used, and // the new extent's ID. iscsiExtent newExtent = nas.addISCSIExtent(shotObjects.extent); nas.addISCSITargetToExtent(shotObjects.tgtToExtent.iscsi_target, newExtent); nas.waitUntilISCSIConfigFlushed(); } }
public hypervisor_iLo(hypSpec_iLo spec, clientExecutionMethod newExecMethod = clientExecutionMethod.smbWithPSExec) { _spec = spec; lock (_ilos) { if (!_ilos.ContainsKey(spec.iLoHostname)) { _ilos.Add(spec.iLoHostname, new refCount <hypervisor_iLo_HTTP>(new hypervisor_iLo_HTTP(spec.iLoHostname, spec.iLoUsername, spec.iLoPassword))); } else { _ilos[spec.iLoHostname].addRef(); } } if (_spec.iscsiserverIP != null && _spec.iscsiServerUsername != null && _spec.iscsiServerPassword != null) { theNas = FreeNasGroup.getOrMake(_spec.iscsiserverIP, _spec.iscsiServerUsername, _spec.iscsiServerPassword); } if (newExecMethod == clientExecutionMethod.smbWithPSExec) { _executor = new SMBExecutorWithPSExec(spec.kernelDebugIPOrHostname, spec.hostUsername, spec.hostPassword); } else if (newExecMethod == clientExecutionMethod.smbWithWMI) { _executor = new SMBExecutor(spec.kernelDebugIPOrHostname, spec.hostUsername, spec.hostPassword); } else if (newExecMethod == clientExecutionMethod.vmwaretools) { throw new NotSupportedException(); } else if (newExecMethod == clientExecutionMethod.SSHToBASH) { _executor = new SSHExecutor(spec.kernelDebugIPOrHostname, spec.hostUsername, spec.hostPassword); } }
public hypervisor_vmware_FreeNAS(hypSpec_vmware spec, string freeNasip, string freeNasUsername, string freeNasPassword, clientExecutionMethod newExecMethod = clientExecutionMethod.vmwaretools) : base(spec, newExecMethod) { nas = FreeNasGroup.getOrMake(freeNasip, freeNasUsername, freeNasPassword); }