diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Base/Virtualization/IVirtualizationServer2012.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Base/Virtualization/IVirtualizationServer2012.cs index f234ef0d..e792d49d 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.Base/Virtualization/IVirtualizationServer2012.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.Base/Virtualization/IVirtualizationServer2012.cs @@ -99,9 +99,11 @@ namespace WebsitePanel.Providers.Virtualization // Configuration int GetProcessorCoresNumber(); + // Replication List GetCertificates(string remoteServer); void SetReplicaServer(string remoteServer, string thumbprint, string storagePath); void UnsetReplicaServer(string remoteServer); + bool IsReplicaServer(string remoteServer); void EnableVmReplication(string vmId, string replicaServer, VmReplication replication); void SetVmReplication(string vmId, string replicaServer, VmReplication replication); void TestReplicationServer(string vmId, string replicaServer, string localThumbprint); diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Virtualization.HyperV-2012R2/HyperV2012R2.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Virtualization.HyperV-2012R2/HyperV2012R2.cs index c65b5c90..e1becaaf 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.Virtualization.HyperV-2012R2/HyperV2012R2.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.Virtualization.HyperV-2012R2/HyperV2012R2.cs @@ -1962,13 +1962,13 @@ namespace WebsitePanel.Providers.Virtualization public List GetCertificates(string remoteServer) { // we cant get certificates from remote server - if (string.IsNullOrEmpty(remoteServer)) + if (!string.IsNullOrEmpty(remoteServer)) return null; Command cmd = new Command("Get-ChildItem"); cmd.Parameters.Add("Path", @"cert:\LocalMachine\My"); - Collection result = PowerShell.Execute(cmd, true); + Collection result = PowerShell.Execute(cmd, false); return result .Select( @@ -1985,9 +1985,7 @@ namespace WebsitePanel.Providers.Virtualization { // we cant enable firewall rules on remote server if (!string.IsNullOrEmpty(remoteServer)) - { ReplicaHelper.SetFirewallRule(PowerShell, true); - } ReplicaHelper.SetReplicaServer(PowerShell, true, remoteServer, thumbprint, storagePath); } @@ -1997,6 +1995,20 @@ namespace WebsitePanel.Providers.Virtualization ReplicaHelper.SetReplicaServer(PowerShell, false, remoteServer, null, null); } + public bool IsReplicaServer(string remoteServer) + { + Command cmd = new Command("Get-VMReplicationServer"); + + if (!string.IsNullOrEmpty(remoteServer)) + { + cmd.Parameters.Add("ComputerName", remoteServer); + } + + Collection result = PowerShell.Execute(cmd, true); + + return result != null && result.Count > 0; + } + public void EnableVmReplication(string vmId, string replicaServer, VmReplication replication) { if (ReplicaMode != ReplicaMode.ReplicationEnabled) diff --git a/WebsitePanel/Sources/WebsitePanel.Server.Client/VirtualizationServerProxy2012.cs b/WebsitePanel/Sources/WebsitePanel.Server.Client/VirtualizationServerProxy2012.cs index 60bdae20..05f71105 100644 --- a/WebsitePanel/Sources/WebsitePanel.Server.Client/VirtualizationServerProxy2012.cs +++ b/WebsitePanel/Sources/WebsitePanel.Server.Client/VirtualizationServerProxy2012.cs @@ -133,6 +133,8 @@ namespace WebsitePanel.Providers.Virtualization2012 { private System.Threading.SendOrPostCallback UnsetReplicaServerOperationCompleted; + private System.Threading.SendOrPostCallback IsReplicaServerOperationCompleted; + private System.Threading.SendOrPostCallback EnableVmReplicationOperationCompleted; private System.Threading.SendOrPostCallback SetVmReplicationOperationCompleted; @@ -306,6 +308,9 @@ namespace WebsitePanel.Providers.Virtualization2012 { /// public event UnsetReplicaServerCompletedEventHandler UnsetReplicaServerCompleted; + /// + public event IsReplicaServerCompletedEventHandler IsReplicaServerCompleted; + /// public event EnableVmReplicationCompletedEventHandler EnableVmReplicationCompleted; @@ -2479,6 +2484,48 @@ namespace WebsitePanel.Providers.Virtualization2012 { } } + /// + [System.Web.Services.Protocols.SoapHeaderAttribute("ServiceProviderSettingsSoapHeaderValue")] + [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/IsReplicaServer", 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 IsReplicaServer(string remoteServer) { + object[] results = this.Invoke("IsReplicaServer", new object[] { + remoteServer}); + return ((bool)(results[0])); + } + + /// + public System.IAsyncResult BeginIsReplicaServer(string remoteServer, System.AsyncCallback callback, object asyncState) { + return this.BeginInvoke("IsReplicaServer", new object[] { + remoteServer}, callback, asyncState); + } + + /// + public bool EndIsReplicaServer(System.IAsyncResult asyncResult) { + object[] results = this.EndInvoke(asyncResult); + return ((bool)(results[0])); + } + + /// + public void IsReplicaServerAsync(string remoteServer) { + this.IsReplicaServerAsync(remoteServer, null); + } + + /// + public void IsReplicaServerAsync(string remoteServer, object userState) { + if ((this.IsReplicaServerOperationCompleted == null)) { + this.IsReplicaServerOperationCompleted = new System.Threading.SendOrPostCallback(this.OnIsReplicaServerOperationCompleted); + } + this.InvokeAsync("IsReplicaServer", new object[] { + remoteServer}, this.IsReplicaServerOperationCompleted, userState); + } + + private void OnIsReplicaServerOperationCompleted(object arg) { + if ((this.IsReplicaServerCompleted != null)) { + System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); + this.IsReplicaServerCompleted(this, new IsReplicaServerCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); + } + } + /// [System.Web.Services.Protocols.SoapHeaderAttribute("ServiceProviderSettingsSoapHeaderValue")] [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/EnableVmReplication", RequestNamespace="http://smbsaas/websitepanel/server/", ResponseNamespace="http://smbsaas/websitepanel/server/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] @@ -4062,6 +4109,32 @@ namespace WebsitePanel.Providers.Virtualization2012 { [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")] public delegate void UnsetReplicaServerCompletedEventHandler(object sender, System.ComponentModel.AsyncCompletedEventArgs e); + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")] + public delegate void IsReplicaServerCompletedEventHandler(object sender, IsReplicaServerCompletedEventArgs e); + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + public partial class IsReplicaServerCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { + + private object[] results; + + internal IsReplicaServerCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : + base(exception, cancelled, userState) { + this.results = results; + } + + /// + public bool Result { + get { + this.RaiseExceptionIfNecessary(); + return ((bool)(this.results[0])); + } + } + } + /// [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")] public delegate void EnableVmReplicationCompletedEventHandler(object sender, System.ComponentModel.AsyncCompletedEventArgs e); diff --git a/WebsitePanel/Sources/WebsitePanel.Server/VirtualizationServer2012.asmx.cs b/WebsitePanel/Sources/WebsitePanel.Server/VirtualizationServer2012.asmx.cs index c8c990a6..1d49cfa3 100644 --- a/WebsitePanel/Sources/WebsitePanel.Server/VirtualizationServer2012.asmx.cs +++ b/WebsitePanel/Sources/WebsitePanel.Server/VirtualizationServer2012.asmx.cs @@ -924,6 +924,23 @@ namespace WebsitePanel.Server } } + [WebMethod, SoapHeader("settings")] + public bool IsReplicaServer(string remoteServer) + { + try + { + Log.WriteStart("'{0}' IsReplicaServer", ProviderSettings.ProviderName); + var result = VirtualizationProvider.IsReplicaServer(remoteServer); + Log.WriteEnd("'{0}' IsReplicaServer", ProviderSettings.ProviderName); + return result; + } + catch (Exception ex) + { + Log.WriteError(String.Format("'{0}' IsReplicaServer", ProviderSettings.ProviderName), ex); + throw; + } + } + [WebMethod, SoapHeader("settings")] public void EnableVmReplication(string vmId, string replicaServer, VmReplication replication) {