-
Notifications
You must be signed in to change notification settings - Fork 42
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
Inventory FloatingIps #97
Conversation
923af51
to
8aa708f
Compare
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.
Generally fine, just few minor comments.
Consider marking it WIP if the schema change should be merged before this one.
@@ -37,6 +37,10 @@ def network_routers | |||
@network_routers_map.values.compact | |||
end | |||
|
|||
def floating_ips | |||
[] # TODO(miha-plesko): implement targeted refresh for floating ips |
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.
Please create issues for this so that we don't forget on them. I see another TODO above.
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.
collector.floating_ips.each do |ip| | ||
persister.floating_ips.find_or_build(ip['ID']).assign_attributes( | ||
:address => ip['address'], | ||
:network_router => persister.network_routers.lazy_find(ip['parentID']), |
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.
Can you explain this bit? Why both network_router
and cloud_tenant
use the same data from the floating IP?
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.
So ip['parentID]
contains ems_ref of corresponding NetworkRouter. Knowing this, you can read the two lines like this:
L73: Assign this FloatingIp to corresponding NetworkRouter - just do lazy lookup by ems_ref.
L74: Assign this FloatingIp to corresponding CloudTenant - but since the JSON we got from API does not contain CloudTenant's ems_ref, we do lazy lookup to get NetworkRouter and copy cloud_tenant from it.
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.
Oh, I missed the fact that you query the network router for its cloud_tenant
in the next line. Thanks!
@@ -32,6 +32,13 @@ def append_headers(key, value) | |||
@headers[key] = value | |||
end | |||
|
|||
def clear_headers |
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.
May I suggest to use a different method name? init_headers
, reset_headers
or something similar. I had a comment asking why are you clearing the headers here. After I saw this, I understand that you are basically resetting them.
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.
Good point, thanks. In fact I decided to open a separate PR to fix the vsd client itself so that this one can focus on FloatingIp inventoring only.
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.
Thanks @gberginc
@@ -37,6 +37,10 @@ def network_routers | |||
@network_routers_map.values.compact | |||
end | |||
|
|||
def floating_ips | |||
[] # TODO(miha-plesko): implement targeted refresh for floating ips |
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.
collector.floating_ips.each do |ip| | ||
persister.floating_ips.find_or_build(ip['ID']).assign_attributes( | ||
:address => ip['address'], | ||
:network_router => persister.network_routers.lazy_find(ip['parentID']), |
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.
So ip['parentID]
contains ems_ref of corresponding NetworkRouter. Knowing this, you can read the two lines like this:
L73: Assign this FloatingIp to corresponding NetworkRouter - just do lazy lookup by ems_ref.
L74: Assign this FloatingIp to corresponding CloudTenant - but since the JSON we got from API does not contain CloudTenant's ems_ref, we do lazy lookup to get NetworkRouter and copy cloud_tenant from it.
@@ -32,6 +32,13 @@ def append_headers(key, value) | |||
@headers[key] = value | |||
end | |||
|
|||
def clear_headers |
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.
Good point, thanks. In fact I decided to open a separate PR to fix the vsd client itself so that this one can focus on FloatingIp inventoring only.
This pull request is not mergeable. Please rebase and repush. |
4f77b00
to
4d0d682
Compare
@Ladas I've updated the code to leverage CloudNetwork when relating FloatingIp to NetworkRouter. HOWEVER there are two issues with such approach: a) on Nuage GUI you can allocate floating IP from external network to a router (which can then allocate it to vPort beneath it). With our model here this is not possible: FloatingIp is connected to external network but MIQ is not aware of what router is it allocated to. So I think we still need to add that additional field to FloatingIp model. b) on Nuage GUI you can allocate floating IPs from different external networks to the same router. With our model, this is not possible, you can only assign a single one. We can have a call tomorrow so that I show you how it looks like on Nuage GUI. Would be great to push this through this week so that we can then model also NetworkPorts and be done with inventory upgrade. |
@miha-plesko b) so in Nuage, do you do some explicit connection of a Router and External network? Sounds like the connection is done only by allocation the floating IP to router (meaning you can pick from any external network?). So might be enough that the floating_ip has info from what network and router it comes from. |
Yes @Ladas you're correct about the b) - there is no explicit connection between the router and external netrwork, only FloatingIp itself is aware of what external network did it come from. I'm going to update this PR to match following behavior:
Then I think we're good. |
563d73b
to
f2d98cf
Compare
There you go @Ladas, I've updated the PR and I think relations between routers, floating ips and external natworks are now in great shape. Looking forward to your review. Will need to wait shema update before we merge. |
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.
Looks great 👍
With this commit we inventory both FloatingIp and CloudNetwork where the FloatingIp originates from. FloatingIps are directly related to NetworkRouter while NetworkRouter has no direct relation to CloudNetwork (but is connected via FloatingIps). RFE BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1574922 Signed-off-by: Miha Pleško <miha.plesko@xlab.si>
f2d98cf
to
963e139
Compare
Checked commit miha-plesko@963e139 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0 app/models/manageiq/providers/nuage/inventory/parser/network_manager.rb
app/models/manageiq/providers/nuage/network_manager/vsd_client.rb
|
@Ladas I've commented out the line where we bind FloatingIp to NetworkRouter and put TODO there so that we can, should you agree, merge this PR today. Once the schema PR will get merged I'll uncomment them. Would this work for you? |
@miha-plesko sounds good 👍 |
With this commit we inventory FloatingIps together with CloudNetworks where IPs originate from. loatingIps are related to NetworkRouter through CloudNetwork.
RFE BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1574922
Depends on: ManageIQ/manageiq-schema#217