internal override void Parse()
        {
            IEnumerable <XElement> rootElements = Document.Element(GetSchema() + RootElement)
                                                  .Elements(GetSchema() + "Deployments");

            if (rootElements == null)
            {
                return;
            }

            rootElements = rootElements.Elements(GetSchema() + "Deployment");
            foreach (XElement deployment in rootElements)
            {
                var objDeployment = new Deployment()
                {
                    Name = deployment.Element(GetSchema() + "Name").Value,
                    Slot = (DeploymentSlot)Enum.Parse(typeof(DeploymentSlot), deployment.Element(GetSchema() + "DeploymentSlot").Value)
                };
                if (deployment.Elements(GetSchema() + "RoleInstanceList") != null)
                {
                    var instanceListCount =
                        deployment.Elements(GetSchema() + "RoleInstanceList").Descendants().Count(a => a.Name == GetSchema() + "RoleInstance");
                    objDeployment.TotalRoleInstanceCount = instanceListCount;
                }
                CommandResponse.Add(objDeployment);
            }
        }
        internal override void Parse()
        {
            IEnumerable <XElement> rootElements = Document.Element(GetSchema() + "Locations")
                                                  .Elements(GetSchema() + "Location");

            foreach (XElement hostedService in rootElements)
            {
                var service = new LocationInformation
                {
                    Name        = (string)hostedService.Element(GetSchema() + "Name"),
                    DisplayName = (string)hostedService.Element(GetSchema() + "DisplayName"),
                    VirtualMachineRolesSizes = new List <VmSize>(),
                    WebWorkerRolesSizes      = new List <VmSize>()
                };
                foreach (var element in hostedService.Element(GetSchema() + "AvailableServices").Elements(GetSchema() + "AvailableService"))
                {
                    service.AvailableServices |=
                        (AvailableServices)Enum.Parse(typeof(AvailableServices), element.Value);
                }
                foreach (var element in hostedService.Element(GetSchema() + "ComputeCapabilities").Element(GetSchema() + "WebWorkerRoleSizes")
                         .Elements(GetSchema() + "RoleSize"))
                {
                    service.WebWorkerRolesSizes.Add((VmSize)Enum.Parse(typeof(VmSize), element.Value));
                }
                foreach (var element in hostedService.Element(GetSchema() + "ComputeCapabilities").Element(GetSchema() + "VirtualMachinesRoleSizes")
                         .Elements(GetSchema() + "RoleSize"))
                {
                    service.VirtualMachineRolesSizes.Add((VmSize)Enum.Parse(typeof(VmSize), element.Value));
                }
                CommandResponse.Add(service);
            }
        }
        internal override void Parse()
        {
            IEnumerable <XElement> rootElements = Document.Element(GetSchema() + "Disks")
                                                  .Elements(GetSchema() + "Disk");

            foreach (XElement disk in rootElements)
            {
                var virtualDisk = new VirtualDisk();
                // get the affinity group if it exists
                if (disk.Element(GetSchema() + "AffinityGroup") != null)
                {
                    virtualDisk.AffinityGroup = disk.Element(GetSchema() + "AffinityGroup").Value;
                }
                // get the Location if it exists
                if (disk.Element(GetSchema() + "Location") != null)
                {
                    virtualDisk.Location = disk.Element(GetSchema() + "Location").Value;
                }
                // get the OS if it exists
                if (disk.Element(GetSchema() + "OS") != null)
                {
                    virtualDisk.OS = disk.Element(GetSchema() + "OS").Value;
                }
                // get the medialink if it exists
                if (disk.Element(GetSchema() + "MediaLink") != null)
                {
                    virtualDisk.MediaLink = disk.Element(GetSchema() + "MediaLink").Value;
                }
                // get the name if it exists
                if (disk.Element(GetSchema() + "Name") != null)
                {
                    virtualDisk.Name = disk.Element(GetSchema() + "Name").Value;
                }
                // get the sourceimagename if it exists
                if (disk.Element(GetSchema() + "SourceImageName") != null)
                {
                    virtualDisk.SourceImageName = disk.Element(GetSchema() + "SourceImageName").Value;
                }
                // get the sourceimagename if it exists
                if (disk.Element(GetSchema() + "LogicalSizeInGB") != null)
                {
                    virtualDisk.LogicalSizeInGB = int.Parse(disk.Element(GetSchema() + "LogicalSizeInGB").Value);
                }
                // check if this is attached to a vm
                if (disk.Element(GetSchema() + "AttachedTo") != null)
                {
                    virtualDisk.VM = new AttachedVM()
                    {
                        CloudServiceName =
                            disk.Element(GetSchema() + "AttachedTo").Element(GetSchema() + "HostedServiceName").Value,
                        DeploymentName = disk.Element(GetSchema() + "AttachedTo").Element(GetSchema() + "DeploymentName").Value,
                        RoleName       = disk.Element(GetSchema() + "AttachedTo").Element(GetSchema() + "RoleName").Value
                    };
                }

                CommandResponse.Add(virtualDisk);
            }
        }
        /*
         * <FirewallRules xmlns="http://schemas.microsoft.com/sqlazure/2010/12/">
         *    <FirewallRule>
         *      <Name>Test_Firewall_Rule</Name>
         *      <StartIpAddress>10.20.30.0</StartIpAddress>
         *      <EndIpAddress>10.20.30.100</EndIpAddress>
         *    </FirewallRule>
         *  </FirewallRules>
         */
        internal override void Parse()
        {
            IEnumerable <XElement> rootElements = Document.Element(GetSchema() + RootElement)
                                                  .Elements(GetSchema() + "FirewallRule");

            rootElements.ToList().ForEach(rule => CommandResponse.Add(
                                              new SqlFirewallRule()
            {
                RuleName      = (string)rule.Element(GetSchema() + "Name"),
                IpAddressHigh = (string)rule.Element(GetSchema() + "StartIpAddress"),
                IpAddressLow  = (string)rule.Element(GetSchema() + "EndIpAddress")
            }));
        }
        /// <summary>
        /// Pulls back all of the details about the mobile services table
        /// </summary>
        internal override void Parse()
        {
            IEnumerable <XElement> rootElements = Document.Element(GetSchema() + RootElement).Elements(GetSchema() + "Table");

            foreach (var service in rootElements.Select(mobileService => new MobileServiceTable()
            {
                TableName = mobileService.Element(GetSchema() + "Name").Value,
                SizeInBytes = int.Parse(mobileService.Element(GetSchema() + "Metrics").Element(GetSchema() + "SizeBytes").Value),
                NumberOfIndexes = int.Parse(mobileService.Element(GetSchema() + "Metrics").Element(GetSchema() + "IndexCount").Value),
                NumberOfRecords = int.Parse(mobileService.Element(GetSchema() + "Metrics").Element(GetSchema() + "RecordCount").Value)
            }))
            {
                CommandResponse.Add(service);
            }
        }
Example #6
0
        internal override void Parse()
        {
            IEnumerable <XElement> rootElements = Document.Element(GetSchema() + "StorageServices")
                                                  .Elements(GetSchema() + "StorageService");

            foreach (XElement hostedService in rootElements)
            {
                var service = new StorageAccount
                {
                    Name = (string)hostedService.Element(GetSchema() + "ServiceName"),
                    Url  = (string)hostedService.Element(GetSchema() + "Url")
                };
                CommandResponse.Add(service);
            }
        }
Example #7
0
        internal override void Parse()
        {
            IEnumerable <XElement> rootElements = Document.Element(GetSchema() + "Locations")
                                                  .Elements(GetSchema() + "Location");

            foreach (XElement hostedService in rootElements)
            {
                var service = new LocationInformation
                {
                    Name        = (string)hostedService.Element(GetSchema() + "Name"),
                    DisplayName = (string)hostedService.Element(GetSchema() + "DisplayName")
                };
                CommandResponse.Add(service);
            }
        }
        internal override void Parse()
        {
            IEnumerable <XElement> rootElements = Document.Element(GetSchema() + RootElement)
                                                  .Elements(GetSchema() + "Deployments");

            if (rootElements == null)
            {
                return;
            }

            rootElements = rootElements.Elements(GetSchema() + "Deployment");
            foreach (XElement deployment in rootElements)
            {
                var objDeployment = new Deployment()
                {
                    Name = deployment.Element(GetSchema() + "Name").Value,
                    Slot = (DeploymentSlot)Enum.Parse(typeof(DeploymentSlot), deployment.Element(GetSchema() + "DeploymentSlot").Value),
                };
                if (deployment.Elements(GetSchema() + "RoleInstanceList") != null)
                {
                    var instanceListCount =
                        deployment.Elements(GetSchema() + "RoleInstanceList").Descendants().Count(a => a.Name == GetSchema() + "RoleInstance");
                    objDeployment.TotalRoleInstanceCount = instanceListCount;
                    var instanceList = deployment.Elements(GetSchema() + "RoleInstanceList")
                                       .Elements(GetSchema() + "RoleInstance")
                                       .Select(xElement => new RoleInstance()
                    {
                        Name      = (string)xElement.Element(GetSchema() + "InstanceName"),
                        IpAddress = (string)xElement.Element(GetSchema() + "IpAddress"),
                        Size      = (VmSize)Enum.Parse(typeof(VmSize), (string)xElement.Element(GetSchema() + "InstanceSize")),
                        Status    = (RoleInstanceStatus)Enum.Parse(typeof(RoleInstanceStatus), (string)xElement.Element(GetSchema() + "InstanceStatus")),
                        //VirtualIpAddress = (string)xElement.Element(GetSchema() + "InstanceEndpoints").Elements(GetSchema() + "InstanceEndpoint").First()
                        //                .Element(GetSchema() + "Vip")
                    }).ToList();
                    objDeployment.RoleInstances = instanceList;
                }
                CommandResponse.Add(objDeployment);
            }
        }
        internal override void Parse()
        {
            IEnumerable <XElement> rootElements = Document.Element(GetSchema() + RootElement)
                                                  .Elements(GetSchema() + "HostedService");

            foreach (XElement hostedService in rootElements)
            {
                var service = new CloudService
                {
                    Name        = (string)hostedService.Element(GetSchema() + "ServiceName"),
                    Url         = (string)hostedService.Element(GetSchema() + "Url"),
                    Created     = DateTime.Parse(hostedService.Element(GetSchema() + "HostedServiceProperties").Element(GetSchema() + "DateCreated").Value),
                    Modified    = DateTime.Parse(hostedService.Element(GetSchema() + "HostedServiceProperties").Element(GetSchema() + "DateLastModified").Value),
                    Status      = (CloudServiceStatus)Enum.Parse(typeof(CloudServiceStatus), hostedService.Element(GetSchema() + "HostedServiceProperties").Element(GetSchema() + "Status").Value),
                    Deployments = new List <Deployment>()
                };
                // if the cloud service has an affinity group then the location will not be returned
                service.LocationOrAffinityGroup = (string)hostedService.Element(GetSchema() + "HostedServiceProperties").Element(GetSchema() + "Location")
                                                  ?? (string)hostedService.Element(GetSchema() + "HostedServiceProperties").Element(GetSchema() + "AffinityGroup");

                CommandResponse.Add(service);
            }
        }
Example #10
0
        internal override void Parse()
        {
            IEnumerable <XElement> rootElements = Document.Element(GetSchema() + "StorageServices")
                                                  .Elements(GetSchema() + "StorageService");

            foreach (XElement hostedService in rootElements)
            {
                var service = new StorageAccount
                {
                    Name     = (string)hostedService.Element(GetSchema() + "ServiceName"),
                    Url      = (string)hostedService.Element(GetSchema() + "Url"),
                    Location = (string)hostedService.Element(GetSchema() + "StorageServiceProperties")
                               .Element(GetSchema() + "Location")
                };
                // this can happen if there is an affinity group - then there is no location -
                // we get a primary geolocation though
                if (service.Location == null)
                {
                    service.Location = (string)hostedService.Element(GetSchema() + "StorageServiceProperties")
                                       .Element(GetSchema() + "GeoPrimaryRegion");
                }
                CommandResponse.Add(service);
            }
        }
Example #11
0
        internal override void Parse()
        {
            /*
             * <Images xmlns="http://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
             *    <OSImage>
             *      <AffinityGroup>name-of-the-affinity-group</AffinityGroup>
             *      <Category>category-of-the-image</Category>
             *      <Label>image-description</Label>
             *      <Location>geo-location-of-the-stored-image</Location>
             *      <LogicalSizeInGB>size-of-the-image</LogicalSizeInGB>
             *      <MediaLink>url-of-the-containing-blob</MediaLink>
             *      <Name>image-name</Name>
             *      <OS>operating-system-of-the-image</OS>
             *      <Eula>image-eula</Eula>
             *      <Description>image-description</Description>
             *      <ImageFamily>image-family</ImageFamily>
             *      <ShowInGui>true|false</ShowInGui>
             *      <PublishedDate>published-date</PublishedDate>
             *      <IsPremium>true|false</IsPremium>
             *      <PrivacyUri>uri-of-privacy-policy</PrivacyUri>
             *      <RecommendedVMSize>size-of-the-virtual-machine</RecommendedVMSize>
             *      <PublisherName>publisher-identifier</PublisherName>
             *      <PricingDetailLink>pricing-details</PricingDetailLink>
             *      <SmallIconUri>uri-of-icon</SmallIconUri>
             *      <Language>language-of-image</Language>
             *    </OSImage>
             *    …
             *  </Images>*/
            IEnumerable <XElement> rootElements = Document.Element(GetSchema() + "Images")
                                                  .Elements(GetSchema() + "OSImage");

            foreach (XElement osDetail in rootElements)
            {
                //if (osDetail.Element(GetSchema() + "MediaLink") == null)
                //{
                //    continue;
                //}

                //if (osDetail.Element(GetSchema() + "MediaLink").Value == String.Empty)
                //{
                //    continue;
                //}

                if (osDetail.Element(GetSchema() + "ImageFamily") != null)
                {
                    if (osDetail.Element(GetSchema() + "ImageFamily").Value.Contains("RightScale"))
                    {
                        continue;
                    }
                }
                var imageProperties = new ImageProperties();
                // get the affinity group if it exists
                if (osDetail.Element(GetSchema() + "Description") != null)
                {
                    imageProperties.Description = osDetail.Element(GetSchema() + "Description").Value;
                }
                if (osDetail.Element(GetSchema() + "Name") != null)
                {
                    imageProperties.Name = osDetail.Element(GetSchema() + "Name").Value;
                }
                if (osDetail.Element(GetSchema() + "Label") != null)
                {
                    imageProperties.Label = osDetail.Element(GetSchema() + "Label").Value;
                }
                if (osDetail.Element(GetSchema() + "Eula") != null)
                {
                    imageProperties.Eula = osDetail.Element(GetSchema() + "Eula").Value;
                }
                if (osDetail.Element(GetSchema() + "ImageFamily") != null)
                {
                    imageProperties.ImageFamily = osDetail.Element(GetSchema() + "ImageFamily").Value;
                }
                if (osDetail.Element(GetSchema() + "IsPremium") != null)
                {
                    imageProperties.IsPremium = bool.Parse(osDetail.Element(GetSchema() + "IsPremium").Value);
                }
                if (osDetail.Element(GetSchema() + "ShowInGui") != null)
                {
                    imageProperties.ShowInGui = bool.Parse(osDetail.Element(GetSchema() + "ShowInGui").Value);
                }
                if (osDetail.Element(GetSchema() + "MediaLink") != null)
                {
                    imageProperties.MediaLink = osDetail.Element(GetSchema() + "MediaLink").Value;
                }
                if (osDetail.Element(GetSchema() + "OS") != null)
                {
                    imageProperties.OperatingSystem = (PlatformType)Enum.Parse(typeof(PlatformType), osDetail.Element(GetSchema() + "OS").Value);
                }
                if (osDetail.Element(GetSchema() + "PublishedDate") != null)
                {
                    imageProperties.PublishedDate = DateTime.Parse(osDetail.Element(GetSchema() + "PublishedDate").Value);
                }

                CommandResponse.Add(imageProperties);
            }
        }
Example #12
0
        internal override void Parse()
        {
            /*
             * <VirtualNetworkSites xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/windowsazure">
             * <VirtualNetworkSite>
             * <Name>name-of-virtual-network-site</Name>
             * <Label>label-of-virtual-network-site</Label>
             * <Id>identifier-of-virtual-network-site</Id>
             * <AffinityGroup>name-of-affinity-group</AffinityGroup>
             * <Location>location-of-virtual-network-site</Location>
             * <State>state-of-virtual-network-site</State>
             * <AddressSpace>
             * <AddressPrefixes>
             * <AddressPrefix>CIDR-identifier</AddressPrefix>
             * </AddressPrefixes>
             * </AddressSpace>
             * <Subnets>
             * <Subnet>
             * <Name>subnet-name</Name>
             * <AddressPrefix>CIDR-identifier</AddressPrefix>
             * </Subnet>
             * </Subnets>
             * <DnsServers>
             * <DnsServer>
             * <Name>primary-DNS-name</Name>
             * <Address>IPV4-address-of-the-DNS-server</Address>
             * </DnsServer>
             * <Gateway>
             * <Profile>gateway-profile-size</Profile>
             * <Sites>
             * <LocalNetworkSite>
             * <Name>local-site-name</Name>
             * <AddressSpace>
             * <AddressPrefixes>
             * <AddressPrefix>CIDR-identifier</AddressPrefix>
             * </AddressPrefixes>
             * </AddressSpace>
             * <VpnGatewayAddress>IPV4-address-of-the-vpn-gateway</VpnGatewayAddress>
             * <Connections>
             * <Connection>
             * <Type>connection-type</Type>
             * </Connection>
             * </Connections>
             * </LocalNetworkSite>
             * </Sites>
             * <VPNClientAddressPool>
             * <AddressPrefixes>
             * <AddressPrefix>CIDR-identifier</AddressPrefix>
             * </AddressPrefixes>
             * </VPNClientAddressPool>
             * </Gateway>
             * </VirtualNetworkSite>
             * </VirtualNetworkSites>*/
            IEnumerable <XElement> rootElements = Document.Element(GetSchema() + "VirtualNetworkSites")
                                                  .Elements(GetSchema() + "VirtualNetworkSite");

            foreach (XElement virtualSite in rootElements)
            {
                var site = new VirtualNetworkSite();
                // get the affinity group if it exists
                if (virtualSite.Element(GetSchema() + "Name") != null)
                {
                    site.Name = virtualSite.Element(GetSchema() + "Name").Value;
                }
                if (virtualSite.Element(GetSchema() + "Label") != null)
                {
                    site.Label = virtualSite.Element(GetSchema() + "Label").Value;
                }
                if (virtualSite.Element(GetSchema() + "Id") != null)
                {
                    site.Location = virtualSite.Element(GetSchema() + "Id").Value;
                }
                if (virtualSite.Element(GetSchema() + "Location") != null)
                {
                    site.Location = virtualSite.Element(GetSchema() + "Location").Value;
                }
                if (virtualSite.Element(GetSchema() + "State") != null)
                {
                    site.State = virtualSite.Element(GetSchema() + "State").Value;
                }
                site.Subnets = new List <Subnet>();
                if (virtualSite.Element(GetSchema() + "Subnets") != null)
                {
                    foreach (var subNet in virtualSite.Element(GetSchema() + "Subnets").Elements(GetSchema() + "Subnet").Select(subnet => new Subnet()
                    {
                        Name = (string)subnet.Element(GetSchema() + "Name"),
                        CidrAddressRange = (string)subnet.Element(GetSchema() + "AddressPrefix")
                    }))
                    {
                        site.Subnets.Add(subNet);
                    }
                }

                site.AddressSpaces = new List <AddressSpace>();
                if (virtualSite.Element(GetSchema() + "AddressSpace") != null)
                {
                    foreach (
                        var space in
                        virtualSite.Element(GetSchema() + "AddressSpace")
                        .Element(GetSchema() + "AddressPrefixes")
                        .Elements(GetSchema() + "AddressPrefix")
                        .Select(space => new AddressSpace()
                    {
                        CidrAddressRange = space.Value
                    }))
                    {
                        site.AddressSpaces.Add(space);
                    }
                }

                CommandResponse.Add(site);
            }
        }