public void SetRoleInstanceCountProcess() { Func <XElement, bool> func = null; this.GetCurrentDeployment(); if (this.currentDeployment != null) { using (OperationContextScope operationContextScope = new OperationContextScope((IContextChannel)base.Channel)) { try { XNamespace xNamespace = "http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration"; XDocument xDocument = XDocument.Parse(ServiceManagementHelper.DecodeFromBase64String(this.currentDeployment.Configuration)); IEnumerable <XElement> xElements = xDocument.Root.Elements(xNamespace + "Role"); if (func == null) { func = (XElement p) => string.Compare(p.Attribute("name").Value, this.RoleName, true) == 0; } XElement xElement = xElements.Where <XElement>(func).SingleOrDefault <XElement>(); if (xElement != null) { xElement.Element(xNamespace + "Instances").SetAttributeValue("count", this.Count); } using (OperationContextScope operationContextScope1 = new OperationContextScope((IContextChannel)base.Channel)) { ChangeConfigurationInput changeConfigurationInput = new ChangeConfigurationInput(); changeConfigurationInput.Configuration = ServiceManagementHelper.EncodeToBase64String(xDocument.ToString()); ChangeConfigurationInput changeConfigurationInput1 = changeConfigurationInput; CmdletExtensions.WriteVerboseOutputForObject(this, xDocument); base.RetryCall((string s) => base.Channel.ChangeConfigurationBySlot(s, this.ServiceName, this.Slot, changeConfigurationInput1)); Operation operation = base.WaitForOperation(base.CommandRuntime.ToString()); ManagementOperationContext managementOperationContext = new ManagementOperationContext(); managementOperationContext.set_OperationDescription(base.CommandRuntime.ToString()); managementOperationContext.set_OperationId(operation.OperationTrackingId); managementOperationContext.set_OperationStatus(operation.Status); ManagementOperationContext managementOperationContext1 = managementOperationContext; base.WriteObject(managementOperationContext1, true); } } catch (EndpointNotFoundException endpointNotFoundException1) { EndpointNotFoundException endpointNotFoundException = endpointNotFoundException1; this.WriteErrorDetails(endpointNotFoundException); } catch (CommunicationException communicationException1) { CommunicationException communicationException = communicationException1; this.WriteErrorDetails(communicationException); } } return; } else { return; } }
internal static void LogObject(OperatingSystem operatingSystem) { if (operatingSystem == null) { return; } Console.WriteLine("Operating System Version:{0}", operatingSystem.Version); 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); }
public DeploymentInfoContext(Microsoft.Samples.WindowsAzure.ServiceManagement.Deployment innerDeployment) { this.innerDeployment = innerDeployment; if (this.innerDeployment.RoleInstanceList != null) { this.RoleInstanceList = new List <RoleInstance>(); foreach (var roleInstance in this.innerDeployment.RoleInstanceList) { this.RoleInstanceList.Add(new RoleInstance(roleInstance)); } } if (!string.IsNullOrEmpty(this.innerDeployment.Configuration)) { string xmlString = ServiceManagementHelper.DecodeFromBase64String(this.innerDeployment.Configuration); // Ensure that the readers are properly disposed StringReader stringReader = null; try { stringReader = new StringReader(xmlString); using (var reader = XmlReader.Create(stringReader)) { stringReader = null; XDocument doc = XDocument.Load(reader); this.OSVersion = doc.Root.Attribute("osVersion") != null? doc.Root.Attribute("osVersion").Value: string.Empty; this.RolesConfiguration = new Dictionary <string, RoleConfiguration>(); var roles = doc.Root.Descendants(this.ns + "Role"); foreach (var role in roles) { this.RolesConfiguration.Add(role.Attribute("name").Value, new RoleConfiguration(role)); } } } finally { if (stringReader != null) { stringReader.Dispose(); } } } }
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)); } }
internal static void LogObject(OperatingSystemFamilyList operatingSystemFamilyList) { if (operatingSystemFamilyList == null) { return; } Console.WriteLine("OperatingSystemFamilyList contains {0} item(s).", operatingSystemFamilyList.Count); foreach (var item in operatingSystemFamilyList) { Console.WriteLine("OperatingSystemFamily Name:{0}", item.Name); Console.WriteLine("OperatingSystemFamily Label:{0}", ServiceManagementHelper.DecodeFromBase64String(item.Label)); Console.WriteLine("Operating Systems in this family:"); LogObject(item.OperatingSystems); } }
internal static void LogObject(AffinityGroup affinityGroup) { if (affinityGroup == null) return; Console.WriteLine("AffinityGroup Name:{0}", affinityGroup.Name); if (!string.IsNullOrEmpty(affinityGroup.Label)) { Console.WriteLine("AffinityGroup Label:{0}", ServiceManagementHelper.DecodeFromBase64String(affinityGroup.Label)); } Console.WriteLine("AffinityGroup Description:{0}", affinityGroup.Description); Console.WriteLine("AffinityGroup Location:{0}", affinityGroup.Location); LogObject(affinityGroup.HostedServices); LogObject(affinityGroup.StorageServices); }
internal static void LogObject(Deployment deployment) { if (deployment == null) return; Console.WriteLine("Name:{0}", deployment.Name); Console.WriteLine("Label:{0}", ServiceManagementHelper.DecodeFromBase64String(deployment.Label)); Console.WriteLine("Url:{0}", deployment.Url.ToString()); Console.WriteLine("Status:{0}", deployment.Status); Console.WriteLine("DeploymentSlot:{0}", deployment.DeploymentSlot); Console.WriteLine("PrivateID:{0}", deployment.PrivateID); Console.WriteLine("UpgradeDomainCount:{0}", deployment.UpgradeDomainCount); LogObject(deployment.RoleList); LogObject(deployment.RoleInstanceList); LogObject(deployment.UpgradeStatus); }
internal static void LogObject(HostedServiceProperties hostedServiceProperties) { if (hostedServiceProperties == null) return; Console.WriteLine("HostedService Label:{0}", ServiceManagementHelper.DecodeFromBase64String(hostedServiceProperties.Label)); Console.WriteLine("HostedService Description:{0}", hostedServiceProperties.Description); if (!string.IsNullOrEmpty(hostedServiceProperties.AffinityGroup)) { Console.WriteLine("HostedService AffinityGroupName:{0}", hostedServiceProperties.AffinityGroup); } if (!string.IsNullOrEmpty(hostedServiceProperties.Location)) { Console.WriteLine("HostedService Location:{0}", hostedServiceProperties.Location); } }
protected override void ProcessRecord() { try { Func <AffinityGroup, AffinityGroupContext> func = null; base.ProcessRecord(); Operation operation = null; IEnumerable <AffinityGroup> affinityGroupProcess = this.GetAffinityGroupProcess(out operation); if (affinityGroupProcess != null) { IEnumerable <AffinityGroup> affinityGroups = affinityGroupProcess; if (func == null) { func = (AffinityGroup affinityGroup) => { string str; IEnumerable <AffinityGroupContext.Service> services; IEnumerable <AffinityGroupContext.Service> services1; AffinityGroupContext affinityGroupContext = new AffinityGroupContext(); affinityGroupContext.set_OperationId(operation.OperationTrackingId); affinityGroupContext.set_OperationDescription(this.CommandRuntime.ToString()); affinityGroupContext.set_OperationStatus(operation.Status); affinityGroupContext.Name = affinityGroup.Name; AffinityGroupContext affinityGroupContext1 = affinityGroupContext; if (string.IsNullOrEmpty(affinityGroup.Label)) { str = null; } else { str = ServiceManagementHelper.DecodeFromBase64String(affinityGroup.Label); } affinityGroupContext1.Label = str; affinityGroupContext.Description = affinityGroup.Description; affinityGroupContext.Location = affinityGroup.Location; AffinityGroupContext affinityGroupContext2 = affinityGroupContext; if (affinityGroup.HostedServices != null) { HostedServiceList hostedServices = affinityGroup.HostedServices; services = hostedServices.Select <HostedService, AffinityGroupContext.Service>((HostedService p) => { AffinityGroupContext.Service service = new AffinityGroupContext.Service(); service.Url = p.Url; service.ServiceName = p.ServiceName; return(service); }); } else { services = new AffinityGroupContext.Service[0]; } affinityGroupContext2.HostedServices = services; AffinityGroupContext affinityGroupContext3 = affinityGroupContext; if (affinityGroup.StorageServices != null) { StorageServiceList storageServices = affinityGroup.StorageServices; services1 = storageServices.Select <StorageService, AffinityGroupContext.Service>((StorageService p) => { AffinityGroupContext.Service service = new AffinityGroupContext.Service(); service.Url = p.Url; service.ServiceName = p.ServiceName; return(service); }); } else { services1 = new AffinityGroupContext.Service[0]; } affinityGroupContext3.StorageServices = services1; return(affinityGroupContext); } ; } IEnumerable <AffinityGroupContext> affinityGroupContexts = affinityGroups.Select <AffinityGroup, AffinityGroupContext>(func); base.WriteObject(affinityGroupContexts, true); } } catch (Exception exception1) { Exception exception = exception1; base.WriteError(new ErrorRecord(exception, string.Empty, ErrorCategory.CloseError, null)); } }
public DeploymentInfoContext(Deployment deployment) { XDocument xDocument; string empty; string str; string value; this.ns = "http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration"; this.Slot = deployment.DeploymentSlot; this.Name = deployment.Name; this.DeploymentName = deployment.Name; this.Url = deployment.Url; this.Status = deployment.Status; this.DeploymentId = deployment.PrivateID; this.VNetName = deployment.VirtualNetworkName; this.SdkVersion = deployment.SdkVersion; this.DnsSettings = deployment.Dns; bool?rollbackAllowed = deployment.RollbackAllowed; if (rollbackAllowed.HasValue) { this.RollbackAllowed = deployment.RollbackAllowed; } if (deployment.UpgradeStatus != null) { this.CurrentUpgradeDomain = deployment.UpgradeStatus.CurrentUpgradeDomain; this.CurrentUpgradeDomainState = deployment.UpgradeStatus.CurrentUpgradeDomainState; this.UpgradeType = deployment.UpgradeStatus.UpgradeType; } DeploymentInfoContext deploymentInfoContext = this; if (string.IsNullOrEmpty(deployment.Configuration)) { empty = string.Empty; } else { empty = ServiceManagementHelper.DecodeFromBase64String(deployment.Configuration); } deploymentInfoContext.Configuration = empty; DeploymentInfoContext deploymentInfoContext1 = this; if (string.IsNullOrEmpty(deployment.Label)) { str = string.Empty; } else { str = ServiceManagementHelper.DecodeFromBase64String(deployment.Label); } deploymentInfoContext1.Label = str; if (deployment.RoleInstanceList != null) { this.RoleInstanceList = new List <RoleInstance>(); foreach (RoleInstance roleInstanceList in deployment.RoleInstanceList) { this.RoleInstanceList.Add(roleInstanceList); } } if (!string.IsNullOrEmpty(deployment.Configuration)) { string configuration = this.Configuration; using (StringReader stringReader = new StringReader(configuration)) { XmlReader xmlReader = XmlReader.Create(stringReader); xDocument = XDocument.Load(xmlReader); } DeploymentInfoContext deploymentInfoContext2 = this; if (xDocument.Root.Attribute("osVersion") != null) { value = xDocument.Root.Attribute("osVersion").Value; } else { value = string.Empty; } deploymentInfoContext2.OSVersion = value; this.RolesConfiguration = new Dictionary <string, RoleConfiguration>(); IEnumerable <XElement> xElements = xDocument.Root.Descendants(this.ns + "Role"); foreach (XElement xElement in xElements) { this.RolesConfiguration.Add(xElement.Attribute("name").Value, new RoleConfiguration(xElement)); } } }
public IEnumerable<StorageServicePropertiesOperationContext> GetStorageServicesProcess() { IEnumerable<StorageServicePropertiesOperationContext> storageServicePropertiesOperationContexts; Func<string, StorageServiceList> func = null; Func<StorageServicePropertiesOperationContext, bool> func1 = null; IEnumerable<StorageServicePropertiesOperationContext> storageServicePropertiesOperationContexts1 = null; using (OperationContextScope operationContextScope = new OperationContextScope((IContextChannel)base.Channel)) { try { Func<StorageService, StorageServicePropertiesOperationContext> func2 = null; Func<StorageService, StorageServicePropertiesOperationContext> func3 = null; GetAzureStorageAccountCommand getAzureStorageAccountCommand = this; if (func == null) { func = (string s) => base.Channel.ListStorageServices(s); } StorageServiceList storageServiceList = ((CmdletBase<IServiceManagement>)getAzureStorageAccountCommand).RetryCall<StorageServiceList>(func); Operation operation = base.WaitForOperation(base.CommandRuntime.ToString()); if (storageServiceList != null) { if (!string.IsNullOrEmpty(this.StorageAccountName)) { StorageServiceList storageServiceList1 = storageServiceList; if (func3 == null) { func3 = (StorageService service) => { string empty; StorageServicePropertiesOperationContext storageServicePropertiesOperationContext = new StorageServicePropertiesOperationContext(); storageServicePropertiesOperationContext.StorageAccountName = service.ServiceName; storageServicePropertiesOperationContext.set_OperationId(this.operation.OperationTrackingId); storageServicePropertiesOperationContext.set_OperationDescription(this.CommandRuntime.ToString()); storageServicePropertiesOperationContext.set_OperationStatus(this.operation.Status); storageServicePropertiesOperationContext.AffinityGroup = service.StorageServiceProperties.AffinityGroup; storageServicePropertiesOperationContext.StorageAccountDescription = service.StorageServiceProperties.Description; StorageServicePropertiesOperationContext storageServicePropertiesOperationContext1 = storageServicePropertiesOperationContext; if (service.StorageServiceProperties.Label != null) { empty = ServiceManagementHelper.DecodeFromBase64String(service.StorageServiceProperties.Label); } else { empty = string.Empty; } storageServicePropertiesOperationContext1.Label = empty; storageServicePropertiesOperationContext.Location = service.StorageServiceProperties.Location; storageServicePropertiesOperationContext.Endpoints = service.StorageServiceProperties.Endpoints; storageServicePropertiesOperationContext.StorageAccountStatus = service.StorageServiceProperties.Status; storageServicePropertiesOperationContext.GeoReplicationEnabled = service.StorageServiceProperties.GeoReplicationEnabled; storageServicePropertiesOperationContext.GeoPrimaryLocation = service.StorageServiceProperties.GeoPrimaryRegion; storageServicePropertiesOperationContext.GeoSecondaryLocation = service.StorageServiceProperties.StatusOfSecondary; storageServicePropertiesOperationContext.StatusOfPrimary = service.StorageServiceProperties.StatusOfPrimary; storageServicePropertiesOperationContext.StatusOfSecondary = service.StorageServiceProperties.StatusOfSecondary; return storageServicePropertiesOperationContext; } ; } IEnumerable<StorageServicePropertiesOperationContext> storageServicePropertiesOperationContexts2 = storageServiceList1.Select<StorageService, StorageServicePropertiesOperationContext>(func3); if (func1 == null) { func1 = (StorageServicePropertiesOperationContext s) => s.StorageAccountName.Equals(this.StorageAccountName, StringComparison.InvariantCultureIgnoreCase); } storageServicePropertiesOperationContexts1 = storageServicePropertiesOperationContexts2.Where<StorageServicePropertiesOperationContext>(func1); } else { StorageServiceList storageServiceList2 = storageServiceList; if (func2 == null) { func2 = (StorageService service) => { string empty; StorageServicePropertiesOperationContext storageServicePropertiesOperationContext = new StorageServicePropertiesOperationContext(); storageServicePropertiesOperationContext.StorageAccountName = service.ServiceName; storageServicePropertiesOperationContext.OperationId = operation.OperationTrackingId; storageServicePropertiesOperationContext.OperationDescription = this.CommandRuntime.ToString(); storageServicePropertiesOperationContext.OperationStatus = operation.Status; storageServicePropertiesOperationContext.AffinityGroup = service.StorageServiceProperties.AffinityGroup; storageServicePropertiesOperationContext.StorageAccountDescription = service.StorageServiceProperties.Description; StorageServicePropertiesOperationContext storageServicePropertiesOperationContext1 = storageServicePropertiesOperationContext; if (service.StorageServiceProperties.Label != null) { empty = ServiceManagementHelper.DecodeFromBase64String(service.StorageServiceProperties.Label); } else { empty = string.Empty; } storageServicePropertiesOperationContext1.Label = empty; storageServicePropertiesOperationContext.Location = service.StorageServiceProperties.Location; storageServicePropertiesOperationContext.Endpoints = service.StorageServiceProperties.Endpoints; storageServicePropertiesOperationContext.StorageAccountStatus = service.StorageServiceProperties.Status; storageServicePropertiesOperationContext.GeoReplicationEnabled = service.StorageServiceProperties.GeoReplicationEnabled; storageServicePropertiesOperationContext.GeoPrimaryLocation = service.StorageServiceProperties.GeoPrimaryRegion; storageServicePropertiesOperationContext.GeoSecondaryLocation = service.StorageServiceProperties.StatusOfSecondary; storageServicePropertiesOperationContext.StatusOfPrimary = service.StorageServiceProperties.StatusOfPrimary; storageServicePropertiesOperationContext.StatusOfSecondary = service.StorageServiceProperties.StatusOfSecondary; return storageServicePropertiesOperationContext; } ; } storageServicePropertiesOperationContexts1 = storageServiceList2.Select<StorageService, StorageServicePropertiesOperationContext>(func2); } } } catch (CommunicationException communicationException1) { CommunicationException communicationException = communicationException1; if (communicationException as EndpointNotFoundException == null || base.IsVerbose()) { this.WriteErrorDetails(communicationException); } else { storageServicePropertiesOperationContexts = null; return storageServicePropertiesOperationContexts; } } return storageServicePropertiesOperationContexts1; } return storageServicePropertiesOperationContexts; }
protected override void ProcessRecord() { try { Func <HostedService, HostedServiceDetailedContext> func = null; base.ProcessRecord(); Operation operation = null; IEnumerable <HostedService> hostedServiceProcess = this.GetHostedServiceProcess(out operation); if (hostedServiceProcess != null) { IEnumerable <HostedService> hostedServices = hostedServiceProcess; if (func == null) { func = (HostedService service) => { string serviceName; string empty; string str; string serviceName1; if (this.ServiceName == null) { HostedServiceDetailedContext hostedServiceDetailedContext = new HostedServiceDetailedContext(); HostedServiceDetailedContext hostedServiceDetailedContext1 = hostedServiceDetailedContext; if (service.ServiceName != null) { serviceName = service.ServiceName; } else { serviceName = this.ServiceName; } hostedServiceDetailedContext1.ServiceName = serviceName; hostedServiceDetailedContext.Url = service.Url; HostedServiceDetailedContext hostedServiceDetailedContext2 = hostedServiceDetailedContext; if (string.IsNullOrEmpty(service.HostedServiceProperties.Label)) { empty = string.Empty; } else { empty = ServiceManagementHelper.DecodeFromBase64String(service.HostedServiceProperties.Label); } hostedServiceDetailedContext2.Label = empty; hostedServiceDetailedContext.Description = service.HostedServiceProperties.Description; hostedServiceDetailedContext.Location = service.HostedServiceProperties.Location; hostedServiceDetailedContext.Status = service.HostedServiceProperties.Status; hostedServiceDetailedContext.DateCreated = service.HostedServiceProperties.DateCreated; hostedServiceDetailedContext.DateModified = service.HostedServiceProperties.DateLastModified; hostedServiceDetailedContext.AffinityGroup = service.HostedServiceProperties.AffinityGroup; hostedServiceDetailedContext.set_OperationId(operation.OperationTrackingId); hostedServiceDetailedContext.set_OperationDescription(this.CommandRuntime.ToString()); hostedServiceDetailedContext.set_OperationStatus(operation.Status); return(hostedServiceDetailedContext); } else { if (string.IsNullOrEmpty(service.HostedServiceProperties.Label)) { str = string.Empty; } else { str = ServiceManagementHelper.DecodeFromBase64String(service.HostedServiceProperties.Label); } string str1 = str; HostedServiceDetailedContext url = new HostedServiceDetailedContext(); HostedServiceDetailedContext hostedServiceDetailedContext3 = url; if (service.ServiceName != null) { serviceName1 = service.ServiceName; } else { serviceName1 = this.ServiceName; } hostedServiceDetailedContext3.ServiceName = serviceName1; url.Url = service.Url; url.Label = str1; url.Description = service.HostedServiceProperties.Description; url.AffinityGroup = service.HostedServiceProperties.AffinityGroup; url.Location = service.HostedServiceProperties.Location; url.Status = service.HostedServiceProperties.Status; url.DateCreated = service.HostedServiceProperties.DateCreated; url.DateModified = service.HostedServiceProperties.DateLastModified; url.set_OperationId(operation.OperationTrackingId); url.set_OperationDescription(this.CommandRuntime.ToString()); url.set_OperationStatus(operation.Status); return(url); } } ; } IEnumerable <HostedServiceDetailedContext> hostedServiceDetailedContexts = hostedServices.Select <HostedService, HostedServiceDetailedContext>(func); base.WriteObject(hostedServiceDetailedContexts, true); } } catch (Exception exception1) { Exception exception = exception1; base.WriteError(new ErrorRecord(exception, string.Empty, ErrorCategory.CloseError, null)); } }