protected override void PerformOperation(IServiceManagement channel) { Console.WriteLine("Listing OperatingSystems"); OperatingSystemList operatingSystems = channel.ListOperatingSystems(SubscriptionId); Utility.LogObject(operatingSystems); }
public OperatingSystemList GetOSVersionsProcess(out Operation operation) { Func <string, OperatingSystemList> func = null; OperatingSystemList operatingSystemList = null; operation = null; using (OperationContextScope operationContextScope = new OperationContextScope((IContextChannel)base.Channel)) { try { GetAzureOSVersionCommand getAzureOSVersionCommand = this; if (func == null) { func = (string s) => base.Channel.ListOperatingSystems(s); } operatingSystemList = ((CmdletBase <IServiceManagement>)getAzureOSVersionCommand).RetryCall <OperatingSystemList>(func); operation = base.WaitForOperation(base.CommandRuntime.ToString()); } catch (CommunicationException communicationException1) { CommunicationException communicationException = communicationException1; this.WriteErrorDetails(communicationException); } } return(operatingSystemList); }
/// <summary> /// Connect to an Azure subscription and obtain a list of operating systems. /// </summary> protected override void AzureExecute() { try { OperatingSystemList operatingSystems = this.RetryCall(s => this.Channel.ListOperatingSystems(s)); this.OperatingSystems.Set(this.ActivityContext, operatingSystems); } catch (EndpointNotFoundException ex) { this.LogBuildMessage(ex.Message); this.OperatingSystems.Set(this.ActivityContext, null); } }
internal static void LogObject(OperatingSystemList operatingSystemList) { if (operatingSystemList == null) { return; } Console.WriteLine("OperatingSystemList contains {0} item(s).", operatingSystemList.Count); foreach (var item in operatingSystemList) { LogObject(item); } }
protected override void ProcessRecord() { try { base.ProcessRecord(); Operation operation = null; OperatingSystemList oSVersionsProcess = this.GetOSVersionsProcess(out operation); IEnumerable <OSVersionsContext> oSVersionsContexts = oSVersionsProcess.Select <OperatingSystem, OSVersionsContext>((OperatingSystem os) => { string str; string str1; OSVersionsContext oSVersionsContext = new OSVersionsContext(); oSVersionsContext.set_OperationId(operation.OperationTrackingId); oSVersionsContext.set_OperationDescription(this.CommandRuntime.ToString()); oSVersionsContext.set_OperationStatus(operation.Status); oSVersionsContext.Family = os.Family; OSVersionsContext oSVersionsContext1 = oSVersionsContext; if (string.IsNullOrEmpty(os.FamilyLabel)) { str = null; } else { str = ServiceManagementHelper.DecodeFromBase64String(os.FamilyLabel); } oSVersionsContext1.FamilyLabel = str; oSVersionsContext.IsActive = os.IsActive; oSVersionsContext.IsDefault = os.IsDefault; oSVersionsContext.Version = os.Version; OSVersionsContext oSVersionsContext2 = oSVersionsContext; if (string.IsNullOrEmpty(os.Label)) { str1 = null; } else { str1 = ServiceManagementHelper.DecodeFromBase64String(os.Label); } oSVersionsContext2.Label = str1; return(oSVersionsContext); } ); base.WriteObject(oSVersionsContexts, true); } catch (Exception exception1) { Exception exception = exception1; base.WriteError(new ErrorRecord(exception, string.Empty, ErrorCategory.CloseError, null)); } }
Console.WriteLine("Operating System Label:{0}", ServiceManagementHelper.DecodeFromBase64String(operatingSystem.Label)); Console.WriteLine("Operating System IsDefault:{0}", operatingSystem.IsDefault); Console.WriteLine("Operating System IsActive:{0}", operatingSystem.IsActive); Console.WriteLine("Operating System Family:{0}", operatingSystem.Family); Console.WriteLine("Operating System FamilyLabel:{0}", operatingSystem.FamilyLabel); } internal static string GetSettings(string settingsFile) { string settings = null; try {