-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gather AWS labels and create CustomAttributes #162
Conversation
@bronaghs Interesting, I was not aware of this model, nor how it was used for labelling. This could obviate my approach completely. But, a few things: Do labels hook into company policy at all the way tags and categories potentially do? I was told by @blomquisg that these should definitely hook into policy. Also, should we try to create a two-way relationship by setting |
60a5986
to
c4606c8
Compare
@djberg96 - Create resource_id and resource_type are already columns in the custom_attributes table. |
@bronaghs right, but you can't go the other way, e.g. |
@djberg96 - I have not been told that is a requirement |
@bronaghs Two things in the /app/models/custom_attribute.rb file I want to check on: https://github.com/ManageIQ/manageiq/blob/master/app/models/custom_attribute.rb
However, this doesn't appear to be enforced in any way on the model itself, though it is checked at https://github.com/ManageIQ/manageiq/blob/master/app/controllers/api/providers_controller.rb#L94 The other thing that jumped out at me was this method:
This is used at https://github.com/ManageIQ/manageiq/blob/master/app/controllers/api/subcollections/custom_attributes.rb#L52-L65. So, is this perhaps already reflected within the UI somehow? Since we're dealing with a tag on the provider side, should we set the source to "VC"? |
As a test, I tried creating a custom attribute, and then set the source to VC, as well as the resource_type and resource_id. This is the result within the UI: Obviously this isn't VCenter, but we could change that text. The resource_id we could set in post-processing. @abellotti I noticed that you added this method. Is there any reason we couldn't/shouldn't try to leverage this? |
@djberg96 I don't see why not, the code would need to be pulled out first, it's currently only for the Api, so maybe moving the logic as an api service (lib/services/api/) that you can instantiate and use on your side. /cc @imtayadeway |
@djberg96 @abellotti +1 on extracting services, but I don't know about putting it in lib/services/api if it's to be shared not only outside the API, but with another repo. Part of the |
@djberg96 - Im afraid I don't understand your point with your previous 2 comments. There is a source set to "amazon" in the custom attribute and the section is "labels". What are you looking to see changed? |
@bronaghs I guess it doesn't matter since we're not going to rely on that. |
@blomquisg - review please and thank you. |
thanks for the heads up @gberginc, I will add this to the new inventory code too. |
@Ladas after this is merged, can you look at porting this over to the graph refresher for AWS? |
fdbab23
to
abd6db7
Compare
7a8bed4
to
2c950a7
Compare
@Ladas - Please review the porting of this PR to the new refresh Inventory code. CustomAttributes are being saved in the DB for VMs and Images, |
@bronaghs commented the ManageIQ/manageiq#14281, a correct relation in :through will fix it :-) |
@@ -403,6 +403,7 @@ def assert_specific_vm_powered_on | |||
v.with_relationship_type("genealogy") do | |||
expect(v.parent).to eq(@template) | |||
end | |||
expect(v.custom_attributes.find_by(:name => "Name").value).to eq("EmsRefreshSpec-PoweredOn-Basic3") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would be nice if we could add 1 more tag to the testing data, but that can be done as follow up in the future, since it will require new VCRs
@@ -116,6 +125,13 @@ def get_instance_hardware(instance, flavor) | |||
end | |||
end | |||
|
|||
def get_instance_labels(instance, tags) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems like 1 method get_vm_or_template_labels should be enough
and just pass the 2 lazy_finds as args
52b0f27
to
770417a
Compare
770417a
to
f9123d8
Compare
Checked commits bronaghs/manageiq-providers-amazon@8ff07ca~...f9123d8 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0 |
looks great 👍 |
Note that LabelTagMapping also currently applies tags at a low DB level, does not hook into policy the way "normal" tagging does! |
Hm, so there is a policy 'something has been tagged' ? Yeah calling policy as a part of the refresh would be definitely bad, we could check if this could be a post refresh action? |
This PR parses AWS Tags which are saved in the database as custom attributes.
Currently AWS only supports tagging VMs and Images.
This PR takes care of the parsing and depends on the model and post processing logic getting merged first:
ManageIQ/manageiq#14202 (Status: merged)
A UI PR will be made separately to display the custom attributes in the Labels table of the VMs and Images.
Steps to test:
https://www.pivotaltracker.com/story/show/139414085