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

Adds request_retirement start #380

Merged
merged 1 commit into from
May 21, 2018
Merged

Conversation

d-m-u
Copy link
Contributor

@d-m-u d-m-u commented May 10, 2018

The New And Improved #375.

WIP cause needs specs that pass

New retire as a request uses new make_retire_request this api change is necessary because we must continue to have retire_now for backward compatibility reasons.

https://github.com/ManageIQ/manageiq/blob/master/app/models/mixins/retirement_mixin.rb#L13 is new, we're calling make_request for retirement as well. make_require_request is available for both Vm and Service and OrchStack classes and is immediate (replaces old retire_now except it doesn't replace it, we're not taking the retire_now out for those who still use it). The identifier in miq_product_features isn't changing. Everything should be similar to retire_now, it's just bimodal now.

@d-m-u d-m-u changed the title Adds request_retirement start [WIP] Adds request_retirement start May 10, 2018
@miq-bot miq-bot added the wip label May 10, 2018
@d-m-u
Copy link
Contributor Author

d-m-u commented May 14, 2018

@abellotti can you give me 👀 on this please?

msg << " immediately as a request."
api_log_info(msg)
klass.make_retire_request(resource.id)
resource
Copy link
Member

Choose a reason for hiding this comment

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

I thought the request_retire needs to return the request and not the resource

raise BadRequestError, "Must specify an id for retiring a #{type} resource"
end
else
raise ForbiddenError, "User lacking correct permissions to retire a #{type} as a request."
Copy link
Member

Choose a reason for hiding this comment

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

maybe update this to mention that the user is lacking permission to approve a request ? (miq_request_approval above)

if id
msg = "Retiring #{type} id #{id}"
resource = resource_search(id, type, klass)
msg << " immediately as a request."
Copy link
Member

Choose a reason for hiding this comment

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

maybe just form the whole msg on line 68, no need for the append here.

@d-m-u d-m-u force-pushed the request_retirement branch 2 times, most recently from 756eeef to ca6da80 Compare May 15, 2018 13:33
@@ -2811,6 +2811,8 @@
:identifier: service_edit
- :name: retire
:identifier: service_retire
- :name: request_retire
:identifier: service_retire
Copy link
Member

Choose a reason for hiding this comment

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

we'd also need the request_retire actions on the individual resource and not just at the collection level (bulk) for both services and vms. Thanks.

@d-m-u d-m-u force-pushed the request_retirement branch 7 times, most recently from a87be56 to ed311e9 Compare May 16, 2018 21:40
@d-m-u d-m-u changed the title [WIP] Adds request_retirement start Adds request_retirement start May 16, 2018
@d-m-u
Copy link
Contributor Author

d-m-u commented May 16, 2018

@miq-bot add_label enhancement

@miq-bot miq-bot removed the wip label May 16, 2018
@d-m-u
Copy link
Contributor Author

d-m-u commented May 16, 2018

@miq-bot add_label retirement
@miq-bot add_label i_have_no_clue_what_labels_are_even_in_this_repo

@miq-bot
Copy link
Member

miq-bot commented May 16, 2018

@d-m-u Cannot apply the following label because they are not recognized: retirement

@miq-bot
Copy link
Member

miq-bot commented May 16, 2018

@d-m-u Cannot apply the following label because they are not recognized: i_have_no_clue_what_labels_are_even_in_this_repo

@d-m-u
Copy link
Contributor Author

d-m-u commented May 17, 2018

@abellotti bump

@abellotti abellotti self-assigned this May 18, 2018
Copy link
Member

@abellotti abellotti left a comment

Choose a reason for hiding this comment

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

Thanks @d-m-u for the update, minor changes needed but looking good. Thanks.

),
a_hash_including(
"message" => a_string_matching(/VM Retire - Request Created/),
"href" => a_string_matching(/\/api\/requests\//),
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 update those to use a_string_matching(api_requests_url)

raise BadRequestError, "Must specify an id for retiring a #{type} resource"
end
else
raise ForbiddenError, "User lacking correct permissions to approve a #{type} retire as a request."
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 add a test for this bad path, i.e. authorize user with service_retire and not miq_request_approval ?

it "supports multiple service retirement in future" do
api_basic_authorize collection_action_identifier(:services, :retire)

ret_date = format_retirement_date(Time.zone.now + 2.days)
Copy link
Member

Choose a reason for hiding this comment

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

I take it these updates were for rubocop ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup!

@d-m-u d-m-u force-pushed the request_retirement branch 3 times, most recently from d005775 to ed3a0f6 Compare May 21, 2018 13:13
@miq-bot
Copy link
Member

miq-bot commented May 21, 2018

Checked commit d-m-u@1e63ed2 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
3 files checked, 0 offenses detected
Everything looks fine. 🏆

@abellotti
Copy link
Member

Thanks @d-m-u for the API Enhancement. LGTM !! 👍 Will merge when 🍏

@abellotti abellotti added this to the Sprint 86 Ending May 21, 2018 milestone May 21, 2018
@abellotti abellotti merged commit 6c3908f into ManageIQ:master May 21, 2018
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.

3 participants