override protected fcoTarget[] ProcessTargetList() { var targetList = new fcoTarget[VM.Length]; for (int i = 0; i < VM.Length; i++) { var fco = new fcoTarget(); if (VM[i].StartsWith("vm-")) { fco.keyType = fcoTypeSearch.VM_MOREF; } else if (RegexPattern.UUIDPATTERN.IsMatch(VM[i])) { fco.keyType = fcoTypeSearch.VM_UUID; } else { fco.keyType = fcoTypeSearch.VM_NAME; } fco.keyTypeSpecified = true; fco.key = VM[i]; targetList[i] = fco; } return(targetList); }
override protected fcoTarget[] ProcessTargetList() { var targetList = new fcoTarget[VApp.Length]; for (int i = 0; i < VApp.Length; i++) { var fco = new fcoTarget { keyType = fcoTypeSearch.VAPP_MOREF, keyTypeSpecified = true, key = (VApp[i] as VMware.VimAutomation.ViCore.Impl.V1.Inventory.VAppImpl).Id.Replace("VirtualApp-", "") }; targetList[i] = fco; } return(targetList); }
override protected fcoTarget[] ProcessTargetList() { var targetList = new fcoTarget[VM.Length]; for (int i = 0; i < VM.Length; i++) { var fco = new fcoTarget { keyType = fcoTypeSearch.VM_MOREF, keyTypeSpecified = true, key = (VM[i] as VMware.VimAutomation.ViCore.Impl.V1.VM.UniversalVirtualMachineImpl).Id.Replace("VirtualMachine-", "") }; targetList[i] = fco; } return(targetList); }
public static fcoTarget[] getFcoTargets(String fcoName) { String st = fcoName.Trim(); var res = new List <fcoTarget>(); String searchType = null; int index = 0; while (index < st.Length) { if (searchType == null) { if (st[index] == 'v') { if (st[index + 1] == 'm') { if (st[index + 2] == ':') { index += 3; searchType = "vm"; } } else if ((st[index + 1] == 'a') && (st[index + 2] == 'p') && (st[index + 3] == 'p') && (st[index + 4] == ':')) { index += 5; searchType = "vapp"; } else { ++index; } } else if ((st[index] == 'i') && (st[index + 1] == 'v') && (st[index + 2] == 'd') && (st[index + 3] == ':')) { index += 4; searchType = "ivd"; } else if ((st[index] == 't') && (st[index + 1] == 'a') && (st[index + 2] == 'g') && (st[index + 3] == ':')) { index += 4; searchType = "tag"; } else { throw new SapiException("fcoName :" + st + " is not valid"); } } else { var fcoValue = new StringBuilder(); char endFco = (st[index] == '"') ? '"' : ' '; if (endFco == '"') { ++index; } while (index < st.Length) { if ((st[index] != endFco)) { fcoValue.Append(st[index]); ++index; } else { ++index; break; } } fcoTypeSearch typeVm; String key = fcoValue.ToString(); switch (searchType) { case "ivd": if (UUIDPATTERN.IsMatch(key)) { typeVm = fcoTypeSearch.IVD_UUID; } else { typeVm = fcoTypeSearch.IVD_NAME; } break; case "vapp": if (key.StartsWith("resgroup-")) { typeVm = fcoTypeSearch.VAPP_MOREF; } else if (UUIDPATTERN.IsMatch(key)) { typeVm = fcoTypeSearch.VAPP_UUID; } else { typeVm = fcoTypeSearch.VAPP_NAME; } break; case "vm": if (UUIDPATTERN.IsMatch(key)) { typeVm = fcoTypeSearch.VM_UUID; } else if (IP4PATTERN.IsMatch(key)) { typeVm = fcoTypeSearch.VM_IP; } else if (key.StartsWith("vm-")) { typeVm = fcoTypeSearch.VM_MOREF; } else { typeVm = fcoTypeSearch.VM_NAME; } break; case "tag": typeVm = fcoTypeSearch.TAG; break; default: throw new SapiException("Unsupported type"); } var FcoTarget = new fcoTarget(); FcoTarget.key = key; FcoTarget.keyType = typeVm; FcoTarget.keyTypeSpecified = true; res.Add(FcoTarget); searchType = null; } } return(res.ToArray()); }