wsp-10329 Adding hyper-v replica to HyperV Provider. Server Part 4.

This commit is contained in:
Alexander Trofimov 2015-04-16 13:58:12 -04:00
parent 5af4c5a932
commit cceebc9f24
4 changed files with 108 additions and 4 deletions

View file

@ -1962,13 +1962,13 @@ namespace WebsitePanel.Providers.Virtualization
public List<CertificateInfo> 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<PSObject> result = PowerShell.Execute(cmd, true);
Collection<PSObject> 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<PSObject> result = PowerShell.Execute(cmd, true);
return result != null && result.Count > 0;
}
public void EnableVmReplication(string vmId, string replicaServer, VmReplication replication)
{
if (ReplicaMode != ReplicaMode.ReplicationEnabled)