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

OpenStack set default api version #5297

Conversation

Ladas
Copy link
Contributor

@Ladas Ladas commented Nov 5, 2015

For providers without api version, we take default v2. Otherwise
UI shows blank field that is not an option

Partial fix BZ
https://bugzilla.redhat.com/show_bug.cgi?id=1278036

For providers without api version, we take default v2. Otherwise
UI shows blank field that is not an option

Partial fix BZ
https://bugzilla.redhat.com/show_bug.cgi?id=1278036
@Ladas
Copy link
Contributor Author

Ladas commented Nov 5, 2015

before:
image

after:
image

@miq-bot
Copy link
Member

miq-bot commented Nov 5, 2015

Checked commit Ladas@2ae4909 with ruby 1.9.3, rubocop 0.34.2, and haml-lint 0.13.0
1 file checked, 0 offenses detected
Everything looks good. 👍

@@ -160,7 +160,7 @@ def ems_cloud_form_fields
:provider_id => @ems.provider_id ? @ems.provider_id : "",
:hostname => @ems.hostname,
:api_port => @ems.port,
:api_version => @ems.api_version,
:api_version => @ems.api_version ? @ems.api_version : "v2",
Copy link
Member

Choose a reason for hiding this comment

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

Should this default just be in the model instead? I prefer not putting logic in the UI. You can probably leverage default_value_for :api_version, "v2" on the models, and then this Just Works ™️

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think UI code would need to change quite a bit. Now for the new Manager, they don't have here the correct class, just regular CloudManager. So I cannot put the default value to the correct class, which is the Openstack::CloudManager.

Although with the angular form, I think it is not supported to have default value per provider, since it doesn't do any requests when changing the provider type, the logic is in JS

So not sure, should I put the default value on ManageIQ::Providers::CloudManager? It doesn't belong there, it doesn't belong here, hard choice. :-)

Copy link
Member

Choose a reason for hiding this comment

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

Why don't they have the right class? That seems wrong in and of itself.

Copy link
Member

Choose a reason for hiding this comment

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

Although with the angular form, I think it is not supported to have default value per provider, since it doesn't do any requests when changing the provider type, the logic is in JS

Ugh that's horrible...that means all the business logic for new objects (ANY new object) has to be in Angular as well? cc @matthewd @chessbyte @blomquisg

Copy link
Contributor Author

Choose a reason for hiding this comment

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

From my testing the angular changes form just according to provider type string, which you change by changing the selectbox of provider type, which is not ideal, cause I wanted to use the 'supports_..' methods we have on models. Maybe it's work in progress?

They don't have the right class since first request doesn't have the provider type set and then the logic is in JS.

Copy link
Member

Choose a reason for hiding this comment

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

So I'm a little confused...This code in question is in the Rails side and you have the @ems, so not sure where angular fits in. If you use default_value_for in the model for api_version, then this code should work as it was.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Fryguy right, but for new provider, it's just EmsCloud, cause you don't know the type yet. So first thing you do is pick the type in selectbox, but it doesn't shoot request back to this code. I think it was like this in the non angular version?

So should I define the default value on EmsCloud (meaning ManageIQ::Providers::CloudManager) class?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, that just feels wrong. I think if you pick the dropdown, then after that it should do a EmsThatSubclass.new.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Fryguy Yeah I agree, it should go back to this code when switching ems type, doesn't make sense to do the businesses logic in JS, for infra it will actually have to, since we have e.g. different selectboxes values for different EMS (unless we will preload all data for all EMSes. which again seems wrong).

Though that is currently above my angular skills :-D So will this suffice as a bacportable fix? While UI team should do later refactoring of the angular form?

Copy link
Member

Choose a reason for hiding this comment

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

This is starting to sound like a larger change than this PR needs right now. Right?

I think we can merge what @Ladas has here, and then separately figure out if we're going off the, uh, rails with some of the form designs.

blomquisg added a commit that referenced this pull request Nov 12, 2015
…_in_cloud_form

OpenStack set default api version
@blomquisg blomquisg merged commit cd8befa into ManageIQ:master Nov 12, 2015
@blomquisg blomquisg added this to the Sprint 32 Ending Nov 16, 2015 milestone Nov 12, 2015
blomquisg added a commit that referenced this pull request Nov 17, 2015
…_in_cloud_form

OpenStack set default api version
blomquisg pushed a commit to blomquisg/manageiq that referenced this pull request Nov 23, 2015
Bz1278036

Missing API version select box in cloud provider

Clean cherry pick of:
ManageIQ#5277
ManageIQ#5297

Fixed BZ:
https://bugzilla.redhat.com/show_bug.cgi?id=1278036

See merge request !428
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.

None yet

4 participants