public DeploymentInfoContext(DeploymentGetResponse deployment) { this.Slot = deployment.DeploymentSlot.ToString(); this.Name = deployment.Name; this.DeploymentName = deployment.Name; this.Url = deployment.Uri; this.Status = deployment.Status.ToString(); this.DeploymentId = deployment.PrivateId; this.VNetName = deployment.VirtualNetworkName; this.SdkVersion = deployment.SdkVersion; this.CreatedTime = deployment.CreatedTime; this.LastModifiedTime = deployment.LastModifiedTime; this.Locked = deployment.Locked; // IP Related this.ReservedIPName = deployment.ReservedIPName; this.VirtualIPs = deployment.VirtualIPAddresses == null ? null : new PVM.VirtualIPList( deployment.VirtualIPAddresses.Select(a => new PVM.VirtualIP { Address = a.Address, IsDnsProgrammed = a.IsDnsProgrammed, Name = a.Name })); // DNS if (deployment.DnsSettings != null) { this.DnsSettings = new Microsoft.WindowsAzure.Commands.ServiceManagement.Model.DnsSettings { DnsServers = new Microsoft.WindowsAzure.Commands.ServiceManagement.Model.DnsServerList() }; foreach (var dns in deployment.DnsSettings.DnsServers) { var newDns = new Microsoft.WindowsAzure.Commands.ServiceManagement.Model.DnsServer { Name = dns.Name, Address = dns.Address.ToString() }; this.DnsSettings.DnsServers.Add(newDns); } } this.RollbackAllowed = deployment.RollbackAllowed; if (deployment.UpgradeStatus != null) { this.CurrentUpgradeDomain = deployment.UpgradeStatus.CurrentUpgradeDomain; this.CurrentUpgradeDomainState = deployment.UpgradeStatus.CurrentUpgradeDomainState.ToString(); this.UpgradeType = deployment.UpgradeStatus.UpgradeType.ToString(); } this.Configuration = string.IsNullOrEmpty(deployment.Configuration) ? string.Empty : deployment.Configuration; this.Label = string.IsNullOrEmpty(deployment.Label) ? string.Empty : deployment.Label; this.RoleInstanceList = deployment.RoleInstances; if (!string.IsNullOrEmpty(deployment.Configuration)) { string xmlString = this.Configuration; XDocument doc; using (var stringReader = new StringReader(xmlString)) { XmlReader reader = XmlReader.Create(stringReader); 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)); } } // ILB if (deployment.LoadBalancers != null) { this.LoadBalancers = new PVM.LoadBalancerList( from b in deployment.LoadBalancers select new PVM.LoadBalancer { Name = b.Name, FrontEndIpConfiguration = b.FrontendIPConfiguration == null ? null : new PVM.IpConfiguration { StaticVirtualNetworkIPAddress = b.FrontendIPConfiguration.StaticVirtualNetworkIPAddress, SubnetName = b.FrontendIPConfiguration.SubnetName, Type = string.Equals( b.FrontendIPConfiguration.Type, PVM.LoadBalancerType.Private.ToString(), StringComparison.OrdinalIgnoreCase) ? PVM.LoadBalancerType.Private : PVM.LoadBalancerType.Unknown } }); this.InternalLoadBalancerName = this.LoadBalancers == null || !this.LoadBalancers.Any() ? null : this.LoadBalancers.First().Name; } }
public DeploymentInfoContext(DeploymentGetResponse deployment) { this.Slot = deployment.DeploymentSlot.ToString(); this.Name = deployment.Name; this.DeploymentName = deployment.Name; this.Url = deployment.Uri; this.Status = deployment.Status.ToString(); this.DeploymentId = deployment.PrivateId; this.VNetName = deployment.VirtualNetworkName; this.SdkVersion = deployment.SdkVersion; this.CreatedTime = deployment.CreatedTime; this.LastModifiedTime = deployment.LastModifiedTime; this.Locked = deployment.Locked; // IP Related this.ReservedIPName = deployment.ReservedIPName; this.VirtualIPs = deployment.VirtualIPAddresses == null ? null : new PVM.VirtualIPList( deployment.VirtualIPAddresses.Select(a => new PVM.VirtualIP { Address = a.Address, IsDnsProgrammed = a.IsDnsProgrammed, Name = a.Name })); // DNS if (deployment.DnsSettings != null) { this.DnsSettings = new Microsoft.WindowsAzure.Commands.ServiceManagement.Model.DnsSettings { DnsServers = new Microsoft.WindowsAzure.Commands.ServiceManagement.Model.DnsServerList() }; foreach (var dns in deployment.DnsSettings.DnsServers) { var newDns = new Microsoft.WindowsAzure.Commands.ServiceManagement.Model.DnsServer { Name = dns.Name, Address = dns.Address.ToString() }; this.DnsSettings.DnsServers.Add(newDns); } } this.RollbackAllowed = deployment.RollbackAllowed; if (deployment.UpgradeStatus != null) { this.CurrentUpgradeDomain = deployment.UpgradeStatus.CurrentUpgradeDomain; this.CurrentUpgradeDomainState = deployment.UpgradeStatus.CurrentUpgradeDomainState.ToString(); this.UpgradeType = deployment.UpgradeStatus.UpgradeType.ToString(); } this.Configuration = string.IsNullOrEmpty(deployment.Configuration) ? string.Empty : deployment.Configuration; this.Label = string.IsNullOrEmpty(deployment.Label) ? string.Empty : deployment.Label; this.RoleInstanceList = deployment.RoleInstances; if (!string.IsNullOrEmpty(deployment.Configuration)) { string xmlString = this.Configuration; XDocument doc; using (var stringReader = new StringReader(xmlString)) { XmlReader reader = XmlReader.Create(stringReader); 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)); } } // ILB if (deployment.LoadBalancers != null) { this.LoadBalancers = new PVM.LoadBalancerList( from b in deployment.LoadBalancers select new PVM.LoadBalancer { Name = b.Name, FrontEndIpConfiguration = b.FrontendIPConfiguration == null ? null : new PVM.IpConfiguration { StaticVirtualNetworkIPAddress = b.FrontendIPConfiguration.StaticVirtualNetworkIPAddress, SubnetName = b.FrontendIPConfiguration.SubnetName, Type = string.Equals( b.FrontendIPConfiguration.Type, PVM.LoadBalancerType.Private.ToString(), StringComparison.OrdinalIgnoreCase) ? PVM.LoadBalancerType.Private : PVM.LoadBalancerType.Unknown } }); this.InternalLoadBalancerName = this.LoadBalancers == null || !this.LoadBalancers.Any() ? null : this.LoadBalancers.First().Name; } }