Skip to content
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

Floating IPs provisioning UI #12097

Merged
merged 9 commits into from
Dec 21, 2016
Merged

Floating IPs provisioning UI #12097

merged 9 commits into from
Dec 21, 2016

Conversation

gildub
Copy link
Contributor

@gildub gildub commented Oct 21, 2016

Adds controller actions using task queue
Adds new and edit views

https://bugzilla.redhat.com/show_bug.cgi?id=1394277

@tzumainn
Copy link
Contributor

@miq-bot add_label euwe/yes

@miq-bot
Copy link
Member

miq-bot commented Nov 1, 2016

<pr_mergeability_checker />This pull request is not mergeable. Please rebase and repush.

@gildub gildub closed this Nov 2, 2016
@gildub gildub reopened this Nov 2, 2016
@gildub gildub closed this Nov 7, 2016
@gildub gildub reopened this Nov 7, 2016
@gildub
Copy link
Contributor Author

gildub commented Nov 7, 2016

@martinpovolny, @himdel, @dclarizio, can you please review?

@himdel
Copy link
Contributor

himdel commented Nov 7, 2016

@gildub Can you please update the PR description with instructions where to find this functionality and a screenshot?

Not seeing anything wrong in the code, except for a few find_by_id which should be find or find_by.

@tzumainn
Copy link
Contributor

tzumainn commented Nov 7, 2016

screenshot from 2016-11-07 10 57 18
screenshot from 2016-11-07 10 57 23

@tzumainn
Copy link
Contributor

tzumainn commented Nov 7, 2016

Accessed through the left navigation - Networks > Floating IPs

@tzumainn
Copy link
Contributor

tzumainn commented Nov 7, 2016

@himdel added the info, let me know if it helps! I've tested this functionality successfully, so I think we're only really looking for code sanity.


floating_ips_to_delete = []
floating_ips.each do |s|
floating_ip = FloatingIp.find_by_id(s)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be find(s)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

def floating_ip_form_fields
assert_privileges("floating_ip_edit")
# TODO: find_by_id_filtered fails
# floating_ip = find_by_id_filtered(FloatingIp, params[:id])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any idea why it fails? Sounds like a security problem without it..

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You say fixed, but I still see the commented out code here..

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw seems like this is working fine in SecurityGroups so maybe it would now here too..?

@himdel
Copy link
Contributor

himdel commented Nov 10, 2016

Floating IP Address (optional)

So.. I'm a bit concerned about the address field being optional. In particular, @mansam has done changes to the UI in #12446 that depend on every floating ip having an address.

So how is this supposed to work? Is that a valid expectation, do the addresses get filled out during the task or something like that, or do we need that field to be required? (Sorry, I know nothing..)

@himdel
Copy link
Contributor

himdel commented Nov 10, 2016

Another thing, trying to save a new floating IP, I get an error that just says "Floating IP creation failed: Task start failed: ID [10000000088263]".

That's ..very unhelpful :) (What I'm seeing in the log is..., so we do have an actual error message we could show..)

[----] E, [2016-11-10T13:33:41.336507 #14977:2b0527c090d4] ERROR -- : excon.error     #<Excon::Error::Unauthorized: Expected([200, 204]) <=> Actual(401 Unauthorized)
excon.error.response
  :body          => "{\"error\": {\"message\": \"The request you have made requires authentication.\", \"code\": 401, \"title\": \"Unauthorized\"}}"
  :cookies       => [
  ]

@gildub
Copy link
Contributor Author

gildub commented Nov 17, 2016

@himdel,

A floating IP address from the pool would be automatically assigned unless provided.

I fixed the task error.

options[:ems_id] = params[:ems_id] if params[:ems_id] && params[:ems_id] != 'new'
options[:floating_ip_address] = params[:floating_ip_address] if params[:floating_ip_address]
options[:cloud_network_id] = params[:cloud_network_id] if params[:cloud_network_id]
options[:cloud_tenant_id] = params[:cloud_tenant_id] if params[:cloud_tenant_id]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be something like:

options[:cloud_tenant] = find_by_id_filtered(CloudTenant, params[:cloud_tenant_id]) if params[:cloud_tenant_id]

Because the model expects options to include :cloud_tenant, and not :cloud_tenant_id (I'm currently fixing this in other places)

@@ -14,4 +14,260 @@ def self.display_methods
end

menu_section :net

def button
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you cleanup this method a bit?

Please, make it a simple case statement and make sure that all the code is needed. E.g. you are setting the @refresh_div variable and then testing it. Is there some code between the statements that might change that value?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@martinpovolny,

All the network UI and others (cloud_tenant, cloud_volumes) use the exact same approach.
So I'm keen to make a refactor on all of them using a consistent approach.

That said, I don't see the point of a case for replacing a if/elsif.
No idea about the @refresh_div, I haven't digged into it, what's for? What's the issue here?
Thanks

@himdel
Copy link
Contributor

himdel commented Nov 28, 2016

So.. another problem, similar to #12101 (comment)

  1. Go to /cloud_tenant/show/10000000000011?display=floating_ips (assuming such a tenant exists) - Compute > Clouds > Tenants - click a tenant detail, click on floating ips in the summary detail.
    OR
    Go to /network_port/show/10000000000389?display=floating_ips (same) - Networks > Network Ports - click on a port detail, click on floating ips in the summary detail.
    (you can find these places by searching for floating_ips in the display_methods methods in each controller)

  2. pick any ip (checkbox)

  3. do any of the new toolbar actions

  4. No route matches {:action=>"layouts/flash_msg", :controller=>"network_port", :id=>nil} [network_port/button] (or similar)

@gildub
Copy link
Contributor Author

gildub commented Nov 30, 2016

@himdel,

I can see that issue.
I believe this is respectively a cloud tenant and a network_port controller issues because other controllers accessing the same page are responsible for it, isn't ?
That said I'm looking into it.

@gildub
Copy link
Contributor Author

gildub commented Nov 30, 2016

@himdel,

Ok, so from the UI endpoint, why when selecting the floating IP (whether from the cloud tenant or network port entry) we don't end up in the floating IP controller?

A "normal" work flow would be:
After the user selects the floating IP, having saved where the user is coming from to be able to go back if needed later, then the floating ip controller manages any changes, ultimately the user chooses to go back or go somewhere else.

But obviously we are on a different road, where a controller (such as cloud tenant or network port, from the example above) is managing the views it's not designed for. Unless there is some logic in those button I'm missing. If that the case could you please direct me to the related documentation or at least some good practice example.

Thanks

@gildub
Copy link
Contributor Author

gildub commented Nov 30, 2016

@dclarizio, any pointers please?

@himdel
Copy link
Contributor

himdel commented Nov 30, 2016

@gildub exactly, the solution is essentially to handle the button action in both places, redirecting to the right controller from the other one. Or sharing the code.

For example, for the edit action, just redirecting to the right URL is usually enough (except you may need something like javascript_redirect previous_breadcrumb_url when the form is saved and done (or cancelled)) so that you get back to the right place again.

As @martinpovolny said, we're currently in the process of refactoring this so .. it has to work .. but doesn't have to be perfect right now :).

@gildub
Copy link
Contributor Author

gildub commented Dec 1, 2016

@himdel,

It seems like this is an on-going discussion and the shared controller approach might not be the one to take.

@martinpovolny also suggested to minimize the impact by not having some button appear on the cross controller. Do you have details about how to do that?

@himdel
Copy link
Contributor

himdel commented Dec 1, 2016

also suggested to minimize the impact by not having some button appear on the cross controller. Do you have details about how to do that?

Can't make them not appear in one controller but yes in another. But what you can do is not add the button to the list toolbar but only to the detail toolbar. So they would not be present in either of the lists, but only in the detail screen.

And that is easy because those are separate toolbars (one is in plural, the other not) .. so you just not add it to the other one :).

shared controller approach might not be the one to take.

Just to be sure, I was not proposing a shared controller, I was proposing exactly the opposite - redirecting those actions from the bad controller to the right one. (Similar to https://github.com/ManageIQ/manageiq/pull/12551/files#diff-68512128862e16616d93240055cb3a7dR77)

@gildub
Copy link
Contributor Author

gildub commented Dec 19, 2016

@himdel,

The name of a floating ip is the floating address.
The edit (and delete) buttons were not showing up any more because the filter was wrong, I've fixed it.

@himdel
Copy link
Contributor

himdel commented Dec 19, 2016

@gildub thanks!, going to re-review right now :)

The name of a floating ip is the floating address.

Yeaah, possibly only in the openstack land..
float

But I'm not blocking the PR for that, I guess that will change once you can edit other providers' floating ips too..

@himdel
Copy link
Contributor

himdel commented Dec 19, 2016

So, @gildub I think this one is ready to get merged 👍

But.. I'm seeing you marked a few Fixnum->Integers as fixed but haven't actually fixed them .. so I'm guessing you may have forgotten to push a commit here?

@miq-bot
Copy link
Member

miq-bot commented Dec 19, 2016

<pr_mergeability_checker />This pull request is not mergeable. Please rebase and repush.

@gildub
Copy link
Contributor Author

gildub commented Dec 20, 2016

@himdel,

Sorry, yes the Fixnum -> Integer commit slipped out, I've restored it and rebased.

@himdel
Copy link
Contributor

himdel commented Dec 20, 2016

Sorry, yes the Fixnum -> Integer commit slipped out, I've restored it and rebased.

@gildub yeah, happens, thanks :) .. Just one more thing, can you please look at https://github.com/ManageIQ/manageiq/pull/12097/files#r93028604 (line 146 looks like it should be used instead of line 147).

But if not for some reason, at least remove the commented out code please :).

@gildub
Copy link
Contributor Author

gildub commented Dec 21, 2016

@himdel,

But if not for some reason, at least remove the commented out code please :).

sorry I forgot about that one, it's fixed, using find_by_id_filtered and without any comments ;)

@miq-bot
Copy link
Member

miq-bot commented Dec 21, 2016

Checked commits https://github.com/gildub/manageiq/compare/41341833bf86da410f33ee171aa0fbabbfa73ebf~...26cac2f757d3ca96aacacc3a220815c531c176e9 with ruby 2.2.5, rubocop 0.37.2, and haml-lint 0.16.1
8 files checked, 14 offenses detected

app/controllers/floating_ip_controller.rb

@himdel
Copy link
Contributor

himdel commented Dec 21, 2016

@gildub Thanks, LGTM, the spec failures are probably all unrelated, I'll try to restart the tests once master is OK, and get this in before the UI split..

@himdel himdel closed this Dec 21, 2016
@himdel himdel reopened this Dec 21, 2016
@himdel himdel merged commit 57b0a61 into ManageIQ:master Dec 21, 2016
@himdel himdel added this to the Sprint 51 Ending Jan 2, 2017 milestone Dec 21, 2016
simaishi pushed a commit that referenced this pull request Jan 13, 2017
@simaishi
Copy link
Contributor

Euwe backport details:

$ git log -1
commit fc719649568c5b0fadc90479c88f00625decb886
Author: Martin Hradil <himdel@seznam.cz>
Date:   Wed Dec 21 14:56:01 2016 +0000

    Merge pull request #12097 from gildub/network-provisioning-floating-ips-ui
    
    Floating IPs provisioning UI
    (cherry picked from commit 57b0a61fa1d9529582056123b68c47d7707a26ca)
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1410588

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants