Ejemplo n.º 1
0
        public void Populate(
            IEnumerable <Instance> instances,
            Func <InstanceLocator, bool> isConnected)
        {
            this.Nodes.Clear();

            var zoneIds = instances.Select(i => InventoryNode.ShortIdFromUrl(i.Zone)).ToHashSet();

            foreach (var zoneId in zoneIds)
            {
                var zoneNode = new ZoneNode(zoneId, this);

                var instancesInZone = instances
                                      .Where(i => InventoryNode.ShortIdFromUrl(i.Zone) == zoneId)
                                      .Where(i => i.Disks != null && i.Disks.Any())
                                      .OrderBy(i => i.Name);

                foreach (var instance in instancesInZone)
                {
                    var instanceNode = new VmInstanceNode(instance, zoneNode);
                    instanceNode.IsConnected = isConnected(
                        new InstanceLocator(this.ProjectId, zoneId, instance.Name));

                    zoneNode.Nodes.Add(instanceNode);
                }

                this.Nodes.Add(zoneNode);
                zoneNode.Expand();
            }

            Expand();
        }
Ejemplo n.º 2
0
        public void Populate(
            IEnumerable <Instance> allInstances,
            Func <InstanceLocator, bool> isConnected)
        {
            this.Nodes.Clear();

            // Narrow the list down to Windows instances - there is no point
            // of adding Linux instanes to the list of servers.
            var instances = allInstances.Where(i => ComputeEngineAdapter.IsWindowsInstance(i));
            var zoneIds   = instances.Select(i => InventoryNode.ShortIdFromUrl(i.Zone)).ToHashSet();

            foreach (var zoneId in zoneIds)
            {
                var zoneNode = new ZoneNode(zoneId, this);

                var instancesInZone = instances
                                      .Where(i => InventoryNode.ShortIdFromUrl(i.Zone) == zoneId)
                                      .OrderBy(i => i.Name);

                foreach (var instance in instancesInZone)
                {
                    var instanceNode = new VmInstanceNode(instance, zoneNode);
                    instanceNode.IsConnected = isConnected(
                        new InstanceLocator(this.ProjectId, zoneId, instance.Name));

                    zoneNode.Nodes.Add(instanceNode);
                }

                this.Nodes.Add(zoneNode);
                zoneNode.Expand();
            }

            Expand();
        }