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(); }
private static bool IsRunningOperatingSystem( Instance instance, OperatingSystems operatingSystems) { switch (operatingSystems) { case OperatingSystems.Windows: return(ComputeEngineAdapter.IsWindowsInstance(instance)); case OperatingSystems.Linux: return(!ComputeEngineAdapter.IsWindowsInstance(instance)); default: return(true); } }