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

Add basic CentralAdmin support to the API #472

Merged
merged 6 commits into from
Oct 3, 2018

Conversation

bdunne
Copy link
Member

@bdunne bdunne commented Sep 19, 2018

@bdunne
Copy link
Member Author

bdunne commented Sep 19, 2018

I think I'm going to refactor the tests to reduce duplication, but I wanted to open this to see if anyone had any major concerns.

@bdunne
Copy link
Member Author

bdunne commented Sep 19, 2018

@gtanzillo @jrafanie This wound up being a much cleaner implementation than the others we discussed, and it's easily extendable in the future.

@@ -152,6 +159,7 @@ def scan_resource(type, id = nil, _data = nil)
result
end
end
central_admin :scan_resource, :scan
Copy link
Member

Choose a reason for hiding this comment

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

There are a few of these in here that I don't think we support from the main app.

Doing a quick look for api_relay in the core source I can only find shutdown_guest, reboot_guest, reset, start, stop, and suspend. We should keep the actions we support consistent between the UI and API.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, they were simple, so I added them.

Copy link
Member Author

Choose a reason for hiding this comment

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

Also, I'd like to add all future central admin features through the api and maybe even deprecate the central admin support in the models.

Copy link
Member

Choose a reason for hiding this comment

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

I wouldn't introduce new behavior just to make it complete. We can add the new ones later when they're needed.

Copy link
Member

Choose a reason for hiding this comment

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

I still think we should leave out the extra methods here until they are also supported through the classic UI. If this PR is meant to solve a particular BZ we should limit the scope that issue rather than also adding new features.

Copy link
Member Author

Choose a reason for hiding this comment

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

Since enabling them all is so easy, I figured I would just do it proactively rather than waiting for another high severity customer case saying Action X doesn't work.

Copy link
Member

Choose a reason for hiding this comment

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

Right, but as I understand it this was because of missing operations in the API vs the classic UI. If you really do want to add the new ones, then please create an additional PR to add the same operations in core for consistency.

Copy link
Member

Choose a reason for hiding this comment

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

I can see the value in separating the bugfix from the enhancement part of this PR. 👍

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay, I removed the things we don't central admin in the UI. I'll open a followup PR to add those.

end
end
end
end
Copy link
Member

Choose a reason for hiding this comment

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

enddddddd

@jrafanie
Copy link
Member

Wow, and this works? Looks good. My only concern is what @carbonin brought up above

@bdunne
Copy link
Member Author

bdunne commented Sep 21, 2018

Wow, and this works?

For better or worse, it does the same thing that the central admin through the classic-ui does. So, the actions get passed down properly, but the response returned to the user is garbage.

Valid action:

$ api -l https://global_region post /api/vms/2
{
  "action" : "stop"
}

{
  "error": {
    "kind": "internal_server_error",
    "message": "undefined method `keys' for nil:NilClass",
    "klass": "NoMethodError"
  }
}

$ api -l https://remote_region post /api/vms/2
{
  "action" : "stop"
}

{
  "success": true,
  "message": "VM id:2 name:'Apache_PHP_rh_summit_002' stopping",
  "task_id": "4",
  "task_href": "https://remote_region/api/tasks/4",
  "href": "https://remote_region/api/vms/2"
}

Invalid action:

$ api -l https://global_region post /api/vms/3
{
  "action" : "start"
}

{
  "error": {
    "kind": "internal_server_error",
    "message": "The VM is retired",
    "klass": "InterRegionApiMethodRelay::InterRegionApiMethodRelayError"
  }
}

$ api -l https://remote_region post /api/vms/3
{
  "action" : "start"
}

{
  "success": false,
  "message": "The VM is retired",
  "href": "https://remote_region/api/vms/3"
}

I'm investigating what needs to be done to make the response useful.

@jrafanie
Copy link
Member

I'm investigating what needs to be done to make the response useful.

Interesting edge cases you're testing. It's a great idea to try vms in various states.

@bdunne bdunne force-pushed the central_admin branch 2 times, most recently from 621ced9 to 9e11519 Compare October 2, 2018 11:12
@bdunne
Copy link
Member Author

bdunne commented Oct 2, 2018

Okay, @carbonin @jrafanie @gtanzillo @abellotti This is ready to go. I got the success and failure responses working properly and all of the hrefs pointing to the correct server.

@miq-bot
Copy link
Member

miq-bot commented Oct 2, 2018

Checked commits bdunne/manageiq-api@5d11ea8~...504eda4 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
6 files checked, 0 offenses detected
Everything looks fine. 🏆

Copy link
Member

@jrafanie jrafanie left a comment

Choose a reason for hiding this comment

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

LGTM, I can't merge here.

@bdunne and I want to create a new label and call it bughancement with the color of the existing two labels added together.

@bdunne
Copy link
Member Author

bdunne commented Oct 2, 2018

@bdunne and I want to create a new label and call it bughancement with the color of the existing two labels added together.

🤣

Copy link
Member

@gtanzillo gtanzillo left a comment

Choose a reason for hiding this comment

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

Looks awesome! 👍

@gtanzillo gtanzillo self-assigned this Oct 2, 2018
@gtanzillo gtanzillo added this to the Sprint 96 Ending Oct 8, 2018 milestone Oct 3, 2018
@gtanzillo gtanzillo merged commit 4dbf6b0 into ManageIQ:master Oct 3, 2018
@bdunne bdunne deleted the central_admin branch October 3, 2018 13:49
@simaishi
Copy link
Contributor

simaishi commented Oct 5, 2018

@bdunne hammer/yes and gaprindashvili/yes ?

@bdunne
Copy link
Member Author

bdunne commented Oct 5, 2018

@simaishi I think so. Also related are: ManageIQ/manageiq#17987 and ManageIQ/manageiq#18036

simaishi pushed a commit that referenced this pull request Oct 8, 2018
Add basic CentralAdmin support to the API

(cherry picked from commit 4dbf6b0)

https://bugzilla.redhat.com/show_bug.cgi?id=1628658
@simaishi
Copy link
Contributor

simaishi commented Oct 8, 2018

Hammer backport details:

$ git log -1
commit 60cb7c906f7ec9724e5ac56f76e2558bfae1fd0b
Author: Gregg Tanzillo <gtanzill@redhat.com>
Date:   Wed Oct 3 08:56:43 2018 -0400

    Merge pull request #472 from bdunne/central_admin
    
    Add basic CentralAdmin support to the API
    
    (cherry picked from commit 4dbf6b0bbb3cc10be69d6259c069e385ee7bc10c)
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1628658

@simaishi
Copy link
Contributor

Gaprindashvili backport details:

$ git log -1
commit 96b8096ee80d56ac45faee5fe73328443a4ff085
Author: Gregg Tanzillo <gtanzill@redhat.com>
Date:   Wed Oct 3 08:56:43 2018 -0400

    Merge pull request #472 from bdunne/central_admin
    
    Add basic CentralAdmin support to the API
    
    (cherry picked from commit 4dbf6b0bbb3cc10be69d6259c069e385ee7bc10c)
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1635764

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.

6 participants