Skip to content

Instantly share code, notes, and snippets.

@Fryguy
Created October 27, 2015 17:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Fryguy/be705248227bcbf592b4 to your computer and use it in GitHub Desktop.
Save Fryguy/be705248227bcbf592b4 to your computer and use it in GitHub Desktop.
Loading development environment (Rails 4.2.4)
[1] pry(main)> e = ExtManagementSystem.first; nil
ExtManagementSystem Load (0.8ms) SELECT "ext_management_systems".* FROM "ext_management_systems" ORDER BY "ext_management_systems"."id" ASC LIMIT 1
ExtManagementSystem Inst Including Associations (314.9ms - 1rows)
=> nil
[2] pry(main)> d = e.descendants_arranged; nil
(0.6ms) SELECT COUNT(*) FROM "relationships" WHERE "relationships"."resource_id" = $1 AND "relationships"."resource_type" = $2 AND "relationships"."relationship" = $3 [["resource_id", 1000000000002], ["resource_type", "ExtManagementSystem"], ["relationship", "ems_metadata"]]
Relationship Load (0.3ms) SELECT "relationships".* FROM "relationships" WHERE "relationships"."resource_id" = $1 AND "relationships"."resource_type" = $2 AND "relationships"."relationship" = $3 ORDER BY "relationships"."id" ASC LIMIT 1 [["resource_id", 1000000000002], ["resource_type", "ExtManagementSystem"], ["relationship", "ems_metadata"]]
Relationship Inst Including Associations (3.9ms - 1rows)
Relationship Load (237.5ms) SELECT "relationships".* FROM "relationships" WHERE ("relationships"."ancestry" ILIKE '1000000000146/%' OR "relationships"."ancestry" = '1000000000146') ORDER BY (case when relationships.ancestry is null then 0 else 1 end), relationships.ancestry
Relationship Inst Including Associations (78.1ms - 6144rows)
EmsFolder Load (0.4ms) SELECT "ems_folders".* FROM "ems_folders" WHERE "ems_folders"."id" IN (1000000000001, 1000000000004, 1000000000003, 1000000000002)
EmsFolder Inst Including Associations (4.5ms - 4rows)
VmOrTemplate Load (23.7ms) SELECT "vms".* FROM "vms" WHERE "vms"."id" IN (1000000002977, 1000000002976, 1000000002975, 1000000002974, 1000000002973, 1000000002972, 1000000002971, 1000000002970, 1000000002969, 1000000002968, 1000000002967, 1000000002966, 1000000002965, 1000000002964, 1000000002963, 1000000002962, 1000000002961, 1000000002960, 1000000002959, ...)
VmOrTemplate Inst Including Associations (265.8ms - 3000rows)
EmsCluster Load (0.5ms) SELECT "ems_clusters".* FROM "ems_clusters" WHERE "ems_clusters"."id" IN (1000000000004, 1000000000012, 1000000000013, 1000000000005, 1000000000014, 1000000000015, 1000000000001, 1000000000006, 1000000000016, 1000000000017, 1000000000007, 1000000000018, 1000000000019, 1000000000002, 1000000000008, 1000000000020, 1000000000009, ...)
EmsCluster Inst Including Associations (7.6ms - 20rows)
ResourcePool Load (1.0ms) SELECT "resource_pools".* FROM "resource_pools" WHERE "resource_pools"."id" IN (1000000000022, 1000000000023, 1000000000024, 1000000000025, 1000000000026, 1000000000027, 1000000000068, 1000000000069, 1000000000070, 1000000000072, 1000000000073, 1000000000074, 1000000000075, 1000000000076, 1000000000077, 1000000000078, 1000000000079, ...)
ResourcePool Inst Including Associations (7.9ms - 120rows)
=> nil
[3] pry(main)> Relationship.puts_arranged_resources(d)
- EmsFolder 1000000000001: Datacenters
- EmsFolder 1000000000004: VC0DC0
- EmsFolder 1000000000002: host
- EmsCluster 1000000000016: VC0DC0_C0
- ResourcePool 1000000000095: Default for Cluster / Deployment Role VC0DC0_C0
- ResourcePool 1000000000101: VC0DC0_C0_RP0
- ManageIQ::Providers::Vmware::InfraManager::Vm 1000000002495: VC0DC0_C0_RP0_VM0
- ManageIQ::Providers::Vmware::InfraManager::Vm 1000000002506: VC0DC0_C0_RP0_VM1
...
- ResourcePool 1000000000113: VC0DC0_C0_RP1
- ManageIQ::Providers::Vmware::InfraManager::Vm 1000000002800: VC0DC0_C0_RP1_VM0
- ManageIQ::Providers::Vmware::InfraManager::Vm 1000000002811: VC0DC0_C0_RP1_VM1
...
- EmsCluster 1000000000007: VC0DC0_C1
- ResourcePool 1000000000041: Default for Cluster / Deployment Role VC0DC0_C1
- ResourcePool 1000000000047: VC0DC0_C1_RP0
- ManageIQ::Providers::Vmware::InfraManager::Vm 1000000001145: VC0DC0_C1_RP0_VM0
- ManageIQ::Providers::Vmware::InfraManager::Vm 1000000001156: VC0DC0_C1_RP0_VM1
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment