예제 #1
0
        //
        // Calls for zertoFailover
        //
        public static JToken FailoverTest(string vpgName, string vmName)
        {
            ZertoZvm.Parameters.Clear();
            try
            {
                if (vpgName.Length > 0)
                {
                    ZertoZvm.Parameters.Add("vpgName", vpgName);
                }
                if (vmName.Length > 0)
                {
                    ZertoZvm.Parameters.Add("vmName", vmName);
                }

                JArray vms           = (JArray)(ZertoZvmApi.GetResult("/v1/vms", ZertoZvm.Parameters));
                var    vpgId         = vms.SelectToken("[0].VpgIdentifier");
                var    checkpointId  = ZertoZvmApi.GetResult("/v1/vpgs/" + vpgId + "/checkpoints/stats", ZertoZvm.Parameters).SelectToken("Latest.CheckpointIdentifier");
                JArray VmIdentifiers = new JArray();
                foreach (var vm in vms)
                {
                    VmIdentifiers.Add(vm.SelectToken("VmIdentifier"));
                }
                JToken request = new JObject(
                    new JProperty("CheckpointIdentifier", checkpointId),
                    new JProperty("VmIdentifiers", VmIdentifiers));

                var result = JToken.Parse(ZertoZvmApi.PostRequest("/v1/vpgs/" + vpgId + "/FailoverTest", request));
                return(result);
            }
            catch (Exception e)
            {
                return(JToken.Parse(e.ToString()));
            }
        }
예제 #2
0
 public static string GetVms(string TargetSiteIdentifier, bool cloud = false)
 {
     ZertoZvm.Parameters.Clear();
     try
     {
         return(ZertoZvmApi.GetResult("/v1/virtualizationsites/" + TargetSiteIdentifier + "/vms", ZertoZvm.Parameters, cloud).ToString());
     }
     catch (Exception e)
     {
         return(e.ToString());
     }
 }
예제 #3
0
 public static string GetOrgVdcStorageProfiles(string TargetSiteIdentifier, string OrgVdcIdentifier, bool cloud = false)
 {
     ZertoZvm.Parameters.Clear();
     try
     {
         return(ZertoZvmApi.GetResult("/v1/virtualizationsites/" + TargetSiteIdentifier + "/orgvdcs/" + OrgVdcIdentifier + "/storageprofiles", ZertoZvm.Parameters, cloud).ToString());
     }
     catch (Exception e)
     {
         return(e.ToString());
     }
 }
예제 #4
0
 public static string GetServiceProfiles(bool cloud = false)
 {
     ZertoZvm.Parameters.Clear();
     try
     {
         return(ZertoZvmApi.GetResult("/v1/serviceprofiles", ZertoZvm.Parameters, cloud).ToString());
     }
     catch (Exception e)
     {
         return(e.ToString());
     }
 }
예제 #5
0
 public static string GetSites(bool cloud = false)
 {
     ZertoZvm.Parameters.Clear();
     try
     {
         return(ZertoZvmApi.GetResult("/v1/virtualizationsites", ZertoZvm.Parameters, cloud).ToString());
     }
     catch (Exception e)
     {
         return(e.ToString());
     }
 }
예제 #6
0
 public static string GetLocalSiteIdentifier(bool cloud = false)
 {
     ZertoZvm.Parameters.Clear();
     try
     {
         return(ZertoZvmApi.GetResult("/v1/localsite", ZertoZvm.Parameters, cloud).SelectToken("SiteIdentifier").ToString());
     }
     catch (Exception e)
     {
         return(e.ToString());
     }
 }
예제 #7
0
 public static string CommitVpgSettingsObject(string VpgSettingsIdentifier, bool cloud = false)
 {
     ZertoZvm.Parameters.Clear();
     try
     {
         return(ZertoZvmApi.PostRequest("/v1/vpgSettings/" + VpgSettingsIdentifier + "/commit", "", cloud));
     }
     catch (Exception e)
     {
         return(e.ToString());
     }
 }
예제 #8
0
 public static string GetVpgSettingsObject(string VpgSettingsIdentifier, bool cloud = false)
 {
     ZertoZvm.Parameters.Clear();
     try
     {
         return(ZertoZvmApi.GetResult("/v1/vpgSettings/" + VpgSettingsIdentifier, ZertoZvm.Parameters, cloud).ToString());;
     }
     catch (Exception e)
     {
         return(e.ToString());
     }
 }
예제 #9
0
 public static string GetVpgSettingsIdentifier(JToken body, bool cloud = false)
 {
     ZertoZvm.Parameters.Clear();
     try
     {
         return(ZertoZvmApi.PostRequest("/v1/vpgSettings", body, cloud));
     }
     catch (Exception e)
     {
         return(e.ToString());
     }
 }
예제 #10
0
 public static int TaskStatus(string taskId)
 {
     ZertoZvm.Parameters.Clear();
     try
     {
         var taskStatus = Convert.ToInt32(ZertoZvmApi.GetResult("/v1/tasks/" + taskId, ZertoZvm.Parameters).SelectToken("Status.State"));
         return(taskStatus);
     }
     catch
     {
         return(-1);
     }
 }
예제 #11
0
 public static JToken FailoverRollback(string vpgName)
 {
     try
     {
         var vpgId  = GetVpgId(vpgName);
         var result = JToken.Parse(ZertoZvmApi.PostRequest("/v1/vpgs/" + vpgId + "/FailoverRollback", ""));
         return(result);
     }
     catch (Exception e)
     {
         return(JToken.Parse(e.ToString()));
     }
 }
예제 #12
0
 public static string GetVpgId(string vpgName, bool cloud = false)
 {
     ZertoZvm.Parameters.Clear();
     try
     {
         if (vpgName.Length > 0)
         {
             ZertoZvm.Parameters.Add("name", vpgName);
         }
         return(ZertoZvmApi.GetResult("/v1/vpgs", ZertoZvm.Parameters, cloud).SelectToken("[0].VpgIdentifier").ToString());
     }
     catch (Exception e)
     {
         return(e.ToString());
     }
 }
예제 #13
0
        public static JToken FailoverCommit(string vpgName)
        {
            try
            {
                var vpgId = GetVpgId(vpgName);

                JToken request = new JObject(
                    new JProperty("IsReverseProtection", false));

                var result = JToken.Parse(ZertoZvmApi.PostRequest("/v1/vpgs/" + vpgId + "/FailoverCommit", ""));
                return(result);
            }
            catch (Exception e)
            {
                return(JToken.Parse(e.ToString()));
            }
        }
예제 #14
0
 public static bool TaskComplete(string taskId)
 {
     ZertoZvm.Parameters.Clear();
     try
     {
         var taskStatus = Convert.ToInt32(ZertoZvmApi.GetResult("/v1/tasks/" + taskId, ZertoZvm.Parameters).SelectToken("Status.State"));
         if (taskStatus == 4 || taskStatus == 5 || taskStatus == 6)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch
     {
         return(true);                //returns true if an error occurs to avoid any processes waiting for the task to finish
     }
 }