topological_inventory-core 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (194) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +202 -0
  3. data/README.md +36 -0
  4. data/Rakefile +47 -0
  5. data/app/assets/config/topological_inventory_manifest.js +2 -0
  6. data/app/assets/javascripts/topological_inventory/application.js +13 -0
  7. data/app/assets/stylesheets/topological_inventory/application.css +15 -0
  8. data/app/controllers/topological_inventory/application_controller.rb +5 -0
  9. data/app/helpers/topological_inventory/application_helper.rb +4 -0
  10. data/app/jobs/topological_inventory/application_job.rb +4 -0
  11. data/app/mailers/topological_inventory/application_mailer.rb +6 -0
  12. data/app/models/application_record.rb +15 -0
  13. data/app/models/availability.rb +3 -0
  14. data/app/models/cluster.rb +14 -0
  15. data/app/models/cluster_tag.rb +7 -0
  16. data/app/models/concerns/act_as_taggable_on.rb +75 -0
  17. data/app/models/concerns/archived_concern.rb +16 -0
  18. data/app/models/container.rb +12 -0
  19. data/app/models/container_group.rb +16 -0
  20. data/app/models/container_group_tag.rb +7 -0
  21. data/app/models/container_image.rb +14 -0
  22. data/app/models/container_image_tag.rb +7 -0
  23. data/app/models/container_node.rb +14 -0
  24. data/app/models/container_node_tag.rb +7 -0
  25. data/app/models/container_project.rb +15 -0
  26. data/app/models/container_project_tag.rb +7 -0
  27. data/app/models/container_resource_quota.rb +14 -0
  28. data/app/models/container_template.rb +13 -0
  29. data/app/models/container_template_tag.rb +7 -0
  30. data/app/models/datastore.rb +15 -0
  31. data/app/models/datastore_mount.rb +6 -0
  32. data/app/models/datastore_tag.rb +7 -0
  33. data/app/models/flavor.rb +14 -0
  34. data/app/models/host.rb +20 -0
  35. data/app/models/host_tag.rb +7 -0
  36. data/app/models/ipaddress.rb +18 -0
  37. data/app/models/ipaddress_tag.rb +7 -0
  38. data/app/models/network.rb +18 -0
  39. data/app/models/network_adapter.rb +19 -0
  40. data/app/models/network_adapter_tag.rb +7 -0
  41. data/app/models/network_tag.rb +7 -0
  42. data/app/models/orchestration_stack.rb +24 -0
  43. data/app/models/refresh_state.rb +7 -0
  44. data/app/models/refresh_state_part.rb +63 -0
  45. data/app/models/reservation.rb +15 -0
  46. data/app/models/reservation_tag.rb +7 -0
  47. data/app/models/security_group.rb +19 -0
  48. data/app/models/security_group_tag.rb +7 -0
  49. data/app/models/service_credential.rb +13 -0
  50. data/app/models/service_credential_type.rb +13 -0
  51. data/app/models/service_instance.rb +23 -0
  52. data/app/models/service_instance_node.rb +17 -0
  53. data/app/models/service_instance_node_service_credential.rb +8 -0
  54. data/app/models/service_instance_service_credential.rb +8 -0
  55. data/app/models/service_inventory.rb +18 -0
  56. data/app/models/service_inventory_tag.rb +7 -0
  57. data/app/models/service_offering.rb +25 -0
  58. data/app/models/service_offering_icon.rb +9 -0
  59. data/app/models/service_offering_node.rb +17 -0
  60. data/app/models/service_offering_node_service_credential.rb +8 -0
  61. data/app/models/service_offering_service_credential.rb +8 -0
  62. data/app/models/service_offering_tag.rb +7 -0
  63. data/app/models/service_plan.rb +16 -0
  64. data/app/models/source.rb +82 -0
  65. data/app/models/source_region.rb +24 -0
  66. data/app/models/subnet.rb +21 -0
  67. data/app/models/subnet_tag.rb +7 -0
  68. data/app/models/subscription.rb +25 -0
  69. data/app/models/tag.rb +67 -0
  70. data/app/models/task.rb +8 -0
  71. data/app/models/tenant.rb +47 -0
  72. data/app/models/vm.rb +27 -0
  73. data/app/models/vm_security_group.rb +8 -0
  74. data/app/models/vm_tag.rb +7 -0
  75. data/app/models/volume.rb +18 -0
  76. data/app/models/volume_attachment.rb +8 -0
  77. data/app/models/volume_type.rb +13 -0
  78. data/app/views/layouts/topological_inventory/application.html.erb +14 -0
  79. data/config/database.dev.yml +22 -0
  80. data/db/migrate/20180919170553_add_sources_and_endpoints.rb +19 -0
  81. data/db/migrate/20180927171624_add_container_models.rb +36 -0
  82. data/db/migrate/20180927205317_add_service_catalog_models.rb +38 -0
  83. data/db/migrate/20180928122710_add_authentications.rb +13 -0
  84. data/db/migrate/20180928130326_add_default_to_endpoints.rb +5 -0
  85. data/db/migrate/20181002195506_update_endpoints_uri_parts.rb +10 -0
  86. data/db/migrate/20181005182645_add_tenant_and_tenant_id_to_all_tables.rb +20 -0
  87. data/db/migrate/20181011164429_add_container_nodes.rb +18 -0
  88. data/db/migrate/20181011172858_add_source_created_and_deleted_at_timestamps.rb +19 -0
  89. data/db/migrate/20181015150921_add_missing_name_to_container_template.rb +5 -0
  90. data/db/migrate/20181016141948_add_json_spec_to_parameters_sets.rb +6 -0
  91. data/db/migrate/20181018082155_add_archived_on_timestamp_to_all_models.rb +19 -0
  92. data/db/migrate/20181018141423_rename_service_parameters_sets_to_service_plans.rb +6 -0
  93. data/db/migrate/20181018235055_add_foreign_keys_to_all_models.rb +37 -0
  94. data/db/migrate/20181023094055_add_not_null_constraints_to_all_models.rb +43 -0
  95. data/db/migrate/20181023102858_add_timestamps_for_parallel_saving.rb +27 -0
  96. data/db/migrate/20181023213355_add_tags_and_taggings.rb +28 -0
  97. data/db/migrate/20181023215716_change_column_defaults.rb +5 -0
  98. data/db/migrate/20181024163850_add_source_type.rb +13 -0
  99. data/db/migrate/20181026182144_add_tasks_table.rb +13 -0
  100. data/db/migrate/20181102141329_add_ssl_options_to_endpoints.rb +6 -0
  101. data/db/migrate/20181102145252_add_regions_and_subscriptions.rb +31 -0
  102. data/db/migrate/20181107211649_add_containers.rb +24 -0
  103. data/db/migrate/20181108113645_add_tenant_id_to_regions_and_subscriptions.rb +6 -0
  104. data/db/migrate/20181109170334_add_not_null_constraints_to_source_type.rb +7 -0
  105. data/db/migrate/20181113145803_add_indexes_on_name_column_to_node_and_namespace.rb +6 -0
  106. data/db/migrate/20181113182615_add_vms_table.rb +32 -0
  107. data/db/migrate/20181113190507_add_orchestration_stacks.rb +26 -0
  108. data/db/migrate/20181114094606_add_last_seen_at_to_all_tables.rb +36 -0
  109. data/db/migrate/20181114115416_add_refresh_states_and_refresh_state_parts.rb +26 -0
  110. data/db/migrate/20181119173228_add_lives_on_to_container_nodes.rb +5 -0
  111. data/db/migrate/20181127191451_add_container_images.rb +28 -0
  112. data/db/migrate/20181128101451_add_flavors.rb +25 -0
  113. data/db/migrate/20181128141221_add_json_schema_to_source_types.rb +5 -0
  114. data/db/migrate/20181129150215_rename_archived_on.rb +18 -0
  115. data/db/migrate/20181130111723_add_volumes.rb +57 -0
  116. data/db/migrate/20181205142648_add_unique_constraint_to_source_uid.rb +6 -0
  117. data/db/migrate/20181210164829_add_hardware_attributes_to_flavors.rb +8 -0
  118. data/db/migrate/20190102161242_remove_tags_and_taggings.rb +33 -0
  119. data/db/migrate/20190102161442_add_taggings_for_all_taggable_tables.rb +86 -0
  120. data/db/migrate/20190104213045_rename_authentication_userid_to_username.rb +5 -0
  121. data/db/migrate/20190111083026_change_sources_source_type_to_not_null.rb +5 -0
  122. data/db/migrate/20190111163026_change_sources_name_to_not_null.rb +5 -0
  123. data/db/migrate/20190116164905_add_extra_metadata_and_tags_for_service_offerings.rb +21 -0
  124. data/db/migrate/20190118110059_add_service_offering_icons.rb +16 -0
  125. data/db/migrate/20190122131958_add_missing_foreign_key_constraint_to_tasks.rb +5 -0
  126. data/db/migrate/20190122133424_index_foreign_keys_in_authentications.rb +5 -0
  127. data/db/migrate/20190122133425_index_foreign_keys_in_container_groups.rb +5 -0
  128. data/db/migrate/20190122133426_index_foreign_keys_in_container_projects.rb +5 -0
  129. data/db/migrate/20190122133427_index_foreign_keys_in_container_templates.rb +5 -0
  130. data/db/migrate/20190122133428_index_foreign_keys_in_endpoints.rb +5 -0
  131. data/db/migrate/20190122133429_index_foreign_keys_in_service_instances.rb +5 -0
  132. data/db/migrate/20190122133430_index_foreign_keys_in_service_offerings.rb +5 -0
  133. data/db/migrate/20190122133431_index_foreign_keys_in_service_plans.rb +5 -0
  134. data/db/migrate/20190122133432_index_foreign_keys_in_sources.rb +5 -0
  135. data/db/migrate/20190122153645_remove_extraneous_indexes.rb +17 -0
  136. data/db/migrate/20190124140942_add_missing_indexes_for_last_seen_at.rb +8 -0
  137. data/db/migrate/20190124154742_add_missing_not_null_constraints_to_source_ref.rb +21 -0
  138. data/db/migrate/20190205174227_add_version_to_sources.rb +5 -0
  139. data/db/migrate/20190208143909_add_availabilities_table.rb +15 -0
  140. data/db/migrate/20190213155142_add_resource_version_to_service_plans.rb +5 -0
  141. data/db/migrate/20190218180413_move_tag_value_to_tags.rb +40 -0
  142. data/db/migrate/20190218203848_remove_extra_columns_from_tagging_join_tables.rb +33 -0
  143. data/db/migrate/20190222171042_add_mac_addresses_and_host_inventory_id_to_vms.rb +8 -0
  144. data/db/migrate/20190228103842_add_unique_indexes_to_tag_mapping_tables.rb +21 -0
  145. data/db/migrate/20190308144237_add_application_types.rb +9 -0
  146. data/db/migrate/20190308145549_add_applications.rb +10 -0
  147. data/db/migrate/20190313191654_add_application_type_display_name.rb +5 -0
  148. data/db/migrate/20190314123842_add_containers_resource_quotas_table.rb +30 -0
  149. data/db/migrate/20190314133842_add_columns_for_containers_capacity_planning_analytics.rb +13 -0
  150. data/db/migrate/20190314153151_extract_sources_to_new_service.rb +84 -0
  151. data/db/migrate/20190322122542_add_external_url_to_service_instances.rb +5 -0
  152. data/db/migrate/20190325115642_external_tenant_must_be_unique_and_not_null.rb +6 -0
  153. data/db/migrate/20190401134142_add_last_seen_at_to_all_ingress_exposed_tables.rb +36 -0
  154. data/db/migrate/20190514164916_add_clusters.rb +39 -0
  155. data/db/migrate/20190514165841_add_hosts.rb +45 -0
  156. data/db/migrate/20190522170940_add_datastores.rb +38 -0
  157. data/db/migrate/20190522172440_add_datastore_mounts.rb +17 -0
  158. data/db/migrate/20190724194551_add_network_adapters.rb +39 -0
  159. data/db/migrate/20190729194551_change_network_adapters.rb +27 -0
  160. data/db/migrate/20190729214242_add_ipaddresses_subnets_and_networks.rb +186 -0
  161. data/db/migrate/20190806112121_add_missing_relation_to_subscription_region_and_stack.rb +14 -0
  162. data/db/migrate/20190807102142_add_missing_relation_to_subscription_and_region_to_network_adapter.rb +6 -0
  163. data/db/migrate/20190807183701_add_source_collector_status.rb +5 -0
  164. data/db/migrate/20190815194221_add_reservations_table.rb +43 -0
  165. data/db/migrate/20190926144242_add_service_inventories_table.rb +39 -0
  166. data/db/migrate/20190930112142_add_service_offering_and_instance_nodes_tables.rb +67 -0
  167. data/db/migrate/20190930162142_add_inventory_relation_to_service_offerings_and_instances.rb +6 -0
  168. data/db/migrate/20191002132112_add_root_service_instance_to_service_instances.rb +6 -0
  169. data/db/migrate/20191108135108_add_service_credential_tables.rb +33 -0
  170. data/db/migrate/20191118181501_add_host_to_vm.rb +5 -0
  171. data/db/migrate/20200122181811_add_tenant_to_join_tables.rb +134 -0
  172. data/db/migrate/20200213135429_remove_service_credential_references.rb +8 -0
  173. data/db/migrate/20200213150314_create_service_credential_types.rb +30 -0
  174. data/db/migrate/20200213173958_add_service_credential_type_to_service_credentials.rb +5 -0
  175. data/db/migrate/20200214183108_create_join_table_service_offering_service_credentials.rb +18 -0
  176. data/db/migrate/20200214183117_create_join_table_service_instance_service_credentials.rb +19 -0
  177. data/db/migrate/20200218182928_create_join_table_service_offering_node_service_credentials.rb +18 -0
  178. data/db/migrate/20200218183046_create_join_table_service_instance_node_service_credentials.rb +18 -0
  179. data/db/migrate/20200313124806_remove_extraneous_index_from_service_credential_join_tables.rb +15 -0
  180. data/db/migrate/20200313141215_add_refresh_state_part_to_persisted_models.rb +66 -0
  181. data/db/migrate/20200317082640_add_tracking_timestamps_to_refresh_state.rb +6 -0
  182. data/db/schema.rb +1594 -0
  183. data/db/seeds.rb +0 -0
  184. data/lib/tasks/topological_inventory_tasks.rake +4 -0
  185. data/lib/topological_inventory-core.rb +7 -0
  186. data/lib/topological_inventory/core/ar_helper.rb +50 -0
  187. data/lib/topological_inventory/core/engine.rb +17 -0
  188. data/lib/topological_inventory/core/logging.rb +19 -0
  189. data/lib/topological_inventory/core/seed_loader.rb +9 -0
  190. data/lib/topological_inventory/core/version.rb +5 -0
  191. data/lib/topological_inventory/schema.rb +6 -0
  192. data/lib/topological_inventory/schema/base.rb +26 -0
  193. data/lib/topological_inventory/schema/default.rb +187 -0
  194. metadata +389 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 63b1ec93fd5f7ebb021670fe8184db0945eed00385bafd718d3587aa25a171a7
4
+ data.tar.gz: 37df3df19aa75c724464eb04b2639d07caa8078543435c9edee5e5fc3dc0aa24
5
+ SHA512:
6
+ metadata.gz: 9bc2bd484466880aed1fc578bc5dc1f6b1578e288d430e386a089f505caa51d7585ba668dfcee0d4db5f04f58ec58bad2502db460f258ca2b6127284f05a08c0
7
+ data.tar.gz: aa83f7119b8b1e2570c965a01fed2abda0d1218b14a0cba6b5f6b66ef97e8cfff6c1161902da72e6ee28aba2a8d66740bea61c0a3fb66f3494ae099401786e73
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,36 @@
1
+ # TopologicalInventory
2
+
3
+ [![Build Status](https://travis-ci.org/RedHatInsights/topological_inventory-core.svg)](https://travis-ci.org/RedHatInsights/topological_inventory-core)
4
+ [![Maintainability](https://api.codeclimate.com/v1/badges/34f9bd9412e35c1a36fd/maintainability)](https://codeclimate.com/github/RedHatInsights/topological_inventory-core/maintainability)
5
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/34f9bd9412e35c1a36fd/test_coverage)](https://codeclimate.com/github/RedHatInsights/topological_inventory-core/test_coverage)
6
+ [![Security](https://hakiri.io/github/RedHatInsights/topological_inventory-core/master.svg)](https://hakiri.io/github/RedHatInsights/topological_inventory-core/master)
7
+
8
+ ## Usage
9
+
10
+ How to use my plugin.
11
+
12
+ ## Installation
13
+
14
+ Add this line to your application's Gemfile:
15
+
16
+ ```ruby
17
+ gem 'topological_inventory'
18
+ ```
19
+
20
+ And then execute:
21
+ ```bash
22
+ $ bundle
23
+ ```
24
+
25
+ Or install it yourself as:
26
+ ```bash
27
+ $ gem install topological_inventory
28
+ ```
29
+
30
+ ## Contributing
31
+
32
+ Contribution directions go here.
33
+
34
+ ## License
35
+
36
+ This project is available as open source under the terms of the [Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0).
@@ -0,0 +1,47 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'TopologicalInventory'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.md')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ load 'rails/tasks/statistics.rake'
18
+
19
+ require 'bundler/gem_tasks'
20
+ require "rspec/core/rake_task"
21
+
22
+ require "active_record"
23
+ require "yaml"
24
+
25
+ load "active_record/railties/databases.rake"
26
+
27
+ namespace :db do
28
+ task :environment do
29
+ require "topological_inventory/core/ar_helper"
30
+ TopologicalInventory::Core::ArHelper.load_environment!
31
+ end
32
+ Rake::Task["db:load_config"].enhance(["db:environment"])
33
+ end
34
+
35
+ # Spec related rake tasks
36
+ RSpec::Core::RakeTask.new(:spec)
37
+
38
+ namespace :spec do
39
+ task :initialize do
40
+ ENV["RAILS_ENV"] ||= "test"
41
+ end
42
+
43
+ desc "Setup the database for running tests"
44
+ task :setup => [:initialize, "db:test:prepare"]
45
+ end
46
+
47
+ task default: :spec
@@ -0,0 +1,2 @@
1
+ //= link_directory ../javascripts/topological_inventory .js
2
+ //= link_directory ../stylesheets/topological_inventory .css
@@ -0,0 +1,13 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file. JavaScript code in this file should be added after the last require_* statement.
9
+ //
10
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10
+ * files in this directory. Styles in this file should be added after the last require_* statement.
11
+ * It is generally better to create a new file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,5 @@
1
+ module TopologicalInventory
2
+ class ApplicationController < ActionController::Base
3
+ protect_from_forgery with: :exception
4
+ end
5
+ end
@@ -0,0 +1,4 @@
1
+ module TopologicalInventory
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module TopologicalInventory
2
+ class ApplicationJob < ActiveJob::Base
3
+ end
4
+ end
@@ -0,0 +1,6 @@
1
+ module TopologicalInventory
2
+ class ApplicationMailer < ActionMailer::Base
3
+ default from: 'from@example.com'
4
+ layout 'mailer'
5
+ end
6
+ end
@@ -0,0 +1,15 @@
1
+ class ApplicationRecord < ActiveRecord::Base
2
+ require 'acts_as_tenant'
3
+
4
+ self.abstract_class = true
5
+
6
+ def as_json(options = {})
7
+ options[:except] ||= []
8
+ super
9
+ end
10
+
11
+ require 'act_as_taggable_on'
12
+ ActiveSupport.on_load(:active_record) do
13
+ extend ActAsTaggableOn
14
+ end
15
+ end
@@ -0,0 +1,3 @@
1
+ class Availability < ApplicationRecord
2
+ belongs_to :resource, :polymorphic => true
3
+ end
@@ -0,0 +1,14 @@
1
+ require "archived_concern"
2
+
3
+ class Cluster < ApplicationRecord
4
+ include ArchivedConcern
5
+
6
+ belongs_to :tenant
7
+ belongs_to :source
8
+ belongs_to :refresh_state_part, :optional => true
9
+
10
+ has_many :hosts
11
+
12
+ acts_as_tenant(:tenant)
13
+ acts_as_taggable_on
14
+ end
@@ -0,0 +1,7 @@
1
+ class ClusterTag < ApplicationRecord
2
+ belongs_to :cluster
3
+ belongs_to :tag
4
+ belongs_to :tenant
5
+ belongs_to :refresh_state_part, :optional => true
6
+ acts_as_tenant(:tenant)
7
+ end
@@ -0,0 +1,75 @@
1
+ module ActAsTaggableOn
2
+ def acts_as_taggable_on
3
+ class_eval do
4
+ def self.tagging_relation_name
5
+ "#{name.underscore}_tags".to_sym
6
+ end
7
+
8
+ has_many tagging_relation_name
9
+ has_many :tags, :through => tagging_relation_name
10
+
11
+ def self.taggable?
12
+ true
13
+ end
14
+
15
+ def taggings
16
+ # TODO: legacy v0.0 API dependency, remove when v0.0 is removed
17
+ public_send(:tags).map do |tag|
18
+ {
19
+ :tag_id => tag.id.to_s,
20
+ :name => tag.name,
21
+ :value => tag.value,
22
+ }
23
+ end
24
+ end
25
+
26
+ def tag_list
27
+ tags.pluck(:name)
28
+ end
29
+
30
+ def tag_add(tag_list, options = {})
31
+ Tag.transaction do
32
+ model_tag_class.transaction do
33
+ Array(tag_list).each do |tag_name|
34
+ next if tagged_with?(tag_name, options)
35
+ tag_params = {:name => tag_name, :tenant_id => tenant.id}
36
+ tag_params.merge!(options)
37
+ tag = Tag.find_or_create_by(tag_params)
38
+ tagging_params = {self.class.name.underscore.to_sym => self, :tag_id => tag.id}
39
+ public_send(self.class.tagging_relation_name).create(tagging_params)
40
+ end
41
+ end
42
+ end
43
+ end
44
+
45
+ def tagged_with?(tag_name, options = {})
46
+ options[:value] ||= ""
47
+ options[:namespace] ||= ""
48
+ model_tag_class.joins(:tag)
49
+ .exists?(:tags => {:name => tag_name, :namespace => options[:namespace], :value => options[:value]}, self.class.name.underscore.to_sym => self)
50
+ end
51
+
52
+ def tag_remove(tag_list, options = {})
53
+ options[:value] ||= ""
54
+ options[:namespace] ||= ""
55
+ Tag.joins(self.class.tagging_relation_name)
56
+ .where(:name => Array(tag_list), :namespace => options[:namespace], :value => options[:value], self.class.tagging_relation_name => {self.class.name.underscore.to_sym => self})
57
+ .destroy_all
58
+ end
59
+
60
+ def model_tag_class
61
+ self.class.tagging_relation_name.to_s.classify.constantize
62
+ end
63
+ end
64
+
65
+ tenant_klass = ActsAsTenant.tenant_klass
66
+ join_klass = tagging_relation_name.to_s.singularize.classify.safe_constantize
67
+ join_klass.before_validation(:on => :create) { |i| i.send("#{tenant_klass}=", i.tag.send(tenant_klass)) }
68
+ end
69
+
70
+ def tagged_with(tag_name, options = {})
71
+ options[:value] ||= ""
72
+ options[:namespace] ||= ""
73
+ joins(tagging_relation_name => :tag).where(:tags => {:name => tag_name, :namespace => options[:namespace], :value => options[:value]})
74
+ end
75
+ end