wsp-10329 Adding hyper-v replica to HyperV Provider. Server Part 6.
This commit is contained in:
parent
e8495ac0c6
commit
3a8e9e8355
7 changed files with 37 additions and 86 deletions
|
@ -109,7 +109,7 @@ namespace WebsitePanel.Providers.Virtualization
|
|||
void TestReplicationServer(string vmId, string replicaServer, string localThumbprint);
|
||||
void StartInitialReplication(string vmId);
|
||||
VmReplication GetReplication(string vmId);
|
||||
bool DisableVmReplication(string vmId, string replicaServer);
|
||||
void DisableVmReplication(string vmId);
|
||||
ReplicationDetailInfo GetReplicationInfo(string vmId);
|
||||
void PauseReplication(string vmId);
|
||||
void ResumeReplication(string vmId);
|
||||
|
|
|
@ -14,6 +14,7 @@ namespace WebsitePanel.Providers.Virtualization
|
|||
FailedOver,
|
||||
NotApplicable,
|
||||
ReadyForInitialReplication,
|
||||
InitialReplicationInProgress,
|
||||
Replicating,
|
||||
Resynchronizing,
|
||||
ResynchronizeSuspended,
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
public string Thumbprint { get; set; }
|
||||
|
||||
[Persistent]
|
||||
public string VhdToReplicate { get; set; }
|
||||
public string[] VhdToReplicate { get; set; }
|
||||
|
||||
[Persistent]
|
||||
public ReplicaFrequency ReplicaFrequency { get; set; }
|
||||
|
|
|
@ -74,6 +74,7 @@ namespace WebsitePanel.Providers.Virtualization
|
|||
{
|
||||
Command cmd = new Command("Stop-VM");
|
||||
|
||||
cmd.Parameters.Add("Name", vmName);
|
||||
if (force) cmd.Parameters.Add("Force");
|
||||
if (!string.IsNullOrEmpty(server)) cmd.Parameters.Add("ComputerName", server);
|
||||
//if (!string.IsNullOrEmpty(reason)) cmd.Parameters.Add("Reason", reason);
|
||||
|
|
|
@ -102,7 +102,7 @@ namespace WebsitePanel.Providers.Virtualization
|
|||
|
||||
public ReplicaMode ReplicaMode
|
||||
{
|
||||
get { return (ReplicaMode) ProviderSettings.GetInt("ReplicaMode"); }
|
||||
get { return (ReplicaMode) Enum.Parse(typeof(ReplicaMode) , ProviderSettings["ReplicaMode"]); }
|
||||
}
|
||||
protected string ReplicaServerPath
|
||||
{
|
||||
|
@ -780,10 +780,10 @@ namespace WebsitePanel.Providers.Virtualization
|
|||
Command cmd = new Command("Get-VMSwitch");
|
||||
|
||||
// Not needed as the PowerShellManager adds the computer name
|
||||
//if (!string.IsNullOrEmpty(computerName)) cmd.Parameters.Add("ComputerName", computerName);
|
||||
if (!string.IsNullOrEmpty(computerName)) cmd.Parameters.Add("ComputerName", computerName);
|
||||
if (!string.IsNullOrEmpty(type)) cmd.Parameters.Add("SwitchType", type);
|
||||
|
||||
Collection<PSObject> result = PowerShell.Execute(cmd, true, true);
|
||||
Collection<PSObject> result = PowerShell.Execute(cmd, false, true);
|
||||
|
||||
foreach (PSObject current in result)
|
||||
{
|
||||
|
@ -2037,19 +2037,18 @@ namespace WebsitePanel.Providers.Virtualization
|
|||
|
||||
var excludes = vm.Disks
|
||||
.Select(d => d.Path)
|
||||
.Where(p => !p.Equals(replication.VhdToReplicate, StringComparison.OrdinalIgnoreCase))
|
||||
.Where(p => replication.VhdToReplicate.All(vp => !p.Equals(vp, StringComparison.OrdinalIgnoreCase)))
|
||||
.ToArray();
|
||||
if (excludes.Any())
|
||||
cmd.Parameters.Add("ExcludedVhdPath", excludes);
|
||||
|
||||
// recovery points
|
||||
cmd.Parameters.Add("RecoveryHistory", replication.AdditionalRecoveryPoints);
|
||||
if (replication.AdditionalRecoveryPoints > 0)
|
||||
{
|
||||
if (replication.AdditionalRecoveryPoints > 24)
|
||||
throw new Exception("AdditionalRecoveryPoints can not be greater than 24");
|
||||
|
||||
cmd.Parameters.Add("RecoveryHistory", replication.AdditionalRecoveryPoints);
|
||||
|
||||
if (replication.VSSSnapshotFrequencyHour > 0)
|
||||
{
|
||||
if (replication.VSSSnapshotFrequencyHour > 12)
|
||||
|
@ -2059,10 +2058,7 @@ namespace WebsitePanel.Providers.Virtualization
|
|||
}
|
||||
}
|
||||
|
||||
PowerShell.Execute(cmd, true);
|
||||
|
||||
// Initial Replication
|
||||
StartInitialReplication(vmId);
|
||||
PowerShell.Execute(cmd, true, true);
|
||||
}
|
||||
|
||||
public void SetVmReplication(string vmId, string replicaServer, VmReplication replication)
|
||||
|
@ -2080,21 +2076,13 @@ namespace WebsitePanel.Providers.Virtualization
|
|||
cmd.Parameters.Add("CertificateThumbprint", replication.Thumbprint);
|
||||
cmd.Parameters.Add("ReplicationFrequencySec", (int)replication.ReplicaFrequency);
|
||||
|
||||
var excludes = vm.Disks
|
||||
.Select(d => d.Path)
|
||||
.Where(p => !p.Equals(replication.VhdToReplicate, StringComparison.OrdinalIgnoreCase))
|
||||
.ToArray();
|
||||
if (excludes.Any())
|
||||
cmd.Parameters.Add("ExcludedVhdPath", excludes);
|
||||
|
||||
// recovery points
|
||||
cmd.Parameters.Add("RecoveryHistory", replication.AdditionalRecoveryPoints);
|
||||
if (replication.AdditionalRecoveryPoints > 0)
|
||||
{
|
||||
if (replication.AdditionalRecoveryPoints > 24)
|
||||
throw new Exception("AdditionalRecoveryPoints can not be greater than 24");
|
||||
|
||||
cmd.Parameters.Add("RecoveryHistory", replication.AdditionalRecoveryPoints);
|
||||
|
||||
if (replication.VSSSnapshotFrequencyHour > 0)
|
||||
{
|
||||
if (replication.VSSSnapshotFrequencyHour > 12)
|
||||
|
@ -2102,6 +2090,10 @@ namespace WebsitePanel.Providers.Virtualization
|
|||
|
||||
cmd.Parameters.Add("VSSSnapshotFrequencyHour", replication.VSSSnapshotFrequencyHour);
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd.Parameters.Add("DisableVSSSnapshotReplication");
|
||||
}
|
||||
}
|
||||
|
||||
PowerShell.Execute(cmd, true);
|
||||
|
@ -2163,36 +2155,21 @@ namespace WebsitePanel.Providers.Virtualization
|
|||
excludes.Add(item.Path.ToString());
|
||||
replica.VhdToReplicate = vm.Disks
|
||||
.Select(d => d.Path)
|
||||
.FirstOrDefault(p => excludes.All(ep => !p.Equals(ep, StringComparison.OrdinalIgnoreCase)));
|
||||
.Where(p => excludes.All(ep => !p.Equals(ep, StringComparison.OrdinalIgnoreCase)))
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
return replica;
|
||||
}
|
||||
|
||||
public bool DisableVmReplication(string vmId, string replicaServer)
|
||||
public void DisableVmReplication(string vmId)
|
||||
{
|
||||
if (ReplicaMode != ReplicaMode.ReplicationEnabled)
|
||||
if (ReplicaMode == ReplicaMode.None)
|
||||
throw new Exception("Server does not allow replication by settings");
|
||||
|
||||
var vm = GetVirtualMachine(vmId);
|
||||
|
||||
ReplicaHelper.RemoveVmReplication(PowerShell, vm.Name, ServerNameSettings);
|
||||
|
||||
// move it to EnterpriseServer?
|
||||
// If we have access - delete garbage from replica server
|
||||
try
|
||||
{
|
||||
ReplicaHelper.RemoveVmReplication(PowerShell, vm.Name, replicaServer);
|
||||
// Delete replica vm
|
||||
VirtualMachineHelper.Stop(PowerShell, vm.Name, true, replicaServer);
|
||||
VirtualMachineHelper.Delete(PowerShell, vm.Name, replicaServer);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -2212,13 +2189,13 @@ namespace WebsitePanel.Providers.Virtualization
|
|||
if (result != null && result.Count > 0)
|
||||
{
|
||||
replica = new ReplicationDetailInfo();
|
||||
replica.AverageLatency = result[0].GetProperty<TimeSpan>("AverageReplicationLatency");
|
||||
replica.AverageLatency = result[0].GetProperty<TimeSpan?>("AverageReplicationLatency") ?? new TimeSpan();
|
||||
replica.AverageSize = result[0].GetMb("AverageReplicationSize");
|
||||
replica.Errors = result[0].GetInt("ReplicationErrors");
|
||||
replica.FromTime = result[0].GetProperty<DateTime>("MonitoringStartTime");
|
||||
replica.Health = result[0].GetEnum<ReplicationHealth>("ReplicationHealth");
|
||||
replica.HealthDetails = result[0].GetString("ReplicationHealthDetails");
|
||||
replica.LastSynhronizedAt = result[0].GetProperty<DateTime>("LastReplicationTime");
|
||||
replica.HealthDetails = string.Join(". ", result[0].GetProperty<string[]>("ReplicationHealthDetails"));
|
||||
replica.LastSynhronizedAt = result[0].GetProperty<DateTime?>("LastReplicationTime") ?? new DateTime();
|
||||
replica.MaximumSize = result[0].GetMb("MaximumReplicationSize");
|
||||
replica.Mode = result[0].GetEnum<VmReplicationMode>("ReplicationMode");
|
||||
replica.PendingSize = result[0].GetMb("PendingReplicationSize");
|
||||
|
|
|
@ -2749,45 +2749,40 @@ namespace WebsitePanel.Providers.Virtualization2012 {
|
|||
/// <remarks/>
|
||||
[System.Web.Services.Protocols.SoapHeaderAttribute("ServiceProviderSettingsSoapHeaderValue")]
|
||||
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/DisableVmReplication", RequestNamespace="http://smbsaas/websitepanel/server/", ResponseNamespace="http://smbsaas/websitepanel/server/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
|
||||
public bool DisableVmReplication(string vmId, string replicaServer) {
|
||||
object[] results = this.Invoke("DisableVmReplication", new object[] {
|
||||
vmId,
|
||||
replicaServer});
|
||||
return ((bool)(results[0]));
|
||||
public void DisableVmReplication(string vmId) {
|
||||
this.Invoke("DisableVmReplication", new object[] {
|
||||
vmId});
|
||||
}
|
||||
|
||||
/// <remarks/>
|
||||
public System.IAsyncResult BeginDisableVmReplication(string vmId, string replicaServer, System.AsyncCallback callback, object asyncState) {
|
||||
public System.IAsyncResult BeginDisableVmReplication(string vmId, System.AsyncCallback callback, object asyncState) {
|
||||
return this.BeginInvoke("DisableVmReplication", new object[] {
|
||||
vmId,
|
||||
replicaServer}, callback, asyncState);
|
||||
vmId}, callback, asyncState);
|
||||
}
|
||||
|
||||
/// <remarks/>
|
||||
public bool EndDisableVmReplication(System.IAsyncResult asyncResult) {
|
||||
object[] results = this.EndInvoke(asyncResult);
|
||||
return ((bool)(results[0]));
|
||||
public void EndDisableVmReplication(System.IAsyncResult asyncResult) {
|
||||
this.EndInvoke(asyncResult);
|
||||
}
|
||||
|
||||
/// <remarks/>
|
||||
public void DisableVmReplicationAsync(string vmId, string replicaServer) {
|
||||
this.DisableVmReplicationAsync(vmId, replicaServer, null);
|
||||
public void DisableVmReplicationAsync(string vmId) {
|
||||
this.DisableVmReplicationAsync(vmId, null);
|
||||
}
|
||||
|
||||
/// <remarks/>
|
||||
public void DisableVmReplicationAsync(string vmId, string replicaServer, object userState) {
|
||||
public void DisableVmReplicationAsync(string vmId, object userState) {
|
||||
if ((this.DisableVmReplicationOperationCompleted == null)) {
|
||||
this.DisableVmReplicationOperationCompleted = new System.Threading.SendOrPostCallback(this.OnDisableVmReplicationOperationCompleted);
|
||||
}
|
||||
this.InvokeAsync("DisableVmReplication", new object[] {
|
||||
vmId,
|
||||
replicaServer}, this.DisableVmReplicationOperationCompleted, userState);
|
||||
vmId}, this.DisableVmReplicationOperationCompleted, userState);
|
||||
}
|
||||
|
||||
private void OnDisableVmReplicationOperationCompleted(object arg) {
|
||||
if ((this.DisableVmReplicationCompleted != null)) {
|
||||
System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
|
||||
this.DisableVmReplicationCompleted(this, new DisableVmReplicationCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
|
||||
this.DisableVmReplicationCompleted(this, new System.ComponentModel.AsyncCompletedEventArgs(invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4179,29 +4174,7 @@ namespace WebsitePanel.Providers.Virtualization2012 {
|
|||
|
||||
/// <remarks/>
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")]
|
||||
public delegate void DisableVmReplicationCompletedEventHandler(object sender, DisableVmReplicationCompletedEventArgs e);
|
||||
|
||||
/// <remarks/>
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")]
|
||||
[System.Diagnostics.DebuggerStepThroughAttribute()]
|
||||
[System.ComponentModel.DesignerCategoryAttribute("code")]
|
||||
public partial class DisableVmReplicationCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
|
||||
|
||||
private object[] results;
|
||||
|
||||
internal DisableVmReplicationCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) :
|
||||
base(exception, cancelled, userState) {
|
||||
this.results = results;
|
||||
}
|
||||
|
||||
/// <remarks/>
|
||||
public bool Result {
|
||||
get {
|
||||
this.RaiseExceptionIfNecessary();
|
||||
return ((bool)(this.results[0]));
|
||||
}
|
||||
}
|
||||
}
|
||||
public delegate void DisableVmReplicationCompletedEventHandler(object sender, System.ComponentModel.AsyncCompletedEventArgs e);
|
||||
|
||||
/// <remarks/>
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")]
|
||||
|
|
|
@ -1023,14 +1023,13 @@ namespace WebsitePanel.Server
|
|||
}
|
||||
|
||||
[WebMethod, SoapHeader("settings")]
|
||||
public bool DisableVmReplication(string vmId, string replicaServer)
|
||||
public void DisableVmReplication(string vmId)
|
||||
{
|
||||
try
|
||||
{
|
||||
Log.WriteStart("'{0}' DisableVmReplication", ProviderSettings.ProviderName);
|
||||
var result = VirtualizationProvider.DisableVmReplication(vmId, replicaServer);
|
||||
VirtualizationProvider.DisableVmReplication(vmId);
|
||||
Log.WriteEnd("'{0}' DisableVmReplication", ProviderSettings.ProviderName);
|
||||
return result;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue