ManageIQ / manageiq-ui-classic

Classic UI of ManageIQ
Apache License 2.0
50 stars 358 forks source link

Form conversion: Control/Simulation #6932

Open himdel opened 4 years ago

himdel commented 4 years ago

Convert form to use DDF/React and API - parent issue https://github.com/ManageIQ/manageiq-ui-classic/issues/6825

Location: Control/Simulation

current type: Ruby API state: Need info

PM Input: 1 - Low Comments: Completely unstyled

imported status: NOT ASSIGNED

skateman commented 4 years ago

https://github.com/ManageIQ/manageiq-api/issues/936

jrafanie commented 2 years ago

POST http://localhost:3000/api/vms

BODY

{
    "action": "simulate_policy",
    "resources": [
        {
            "id": 4680,
            "event": "login_failed"
        }
    ]
}

RESPONSE

{
    "results": [
        {
            "success": true,
            "message": "Vm id:4680 name: 'ag_destroy_test' simulating policy on event login_failed",
            "task_id": "435978",
            "task_href": "http://localhost:3000/api/tasks/435978",
            "href": "http://localhost:3000/api/vms/4680"
        }
    ]
}
jrafanie commented 2 years ago

Using the task_id above, check task_results:

GET http://localhost:3000/api/tasks/435978?attributes=task_results

RESPONSE

{
    "href": "http://localhost:3000/api/tasks/435978",
    "id": "435978",
    "name": "VmOrTemplate - Resultant Set of Policy, Event: [Login failed]",
    "state": "Finished",
    "status": "Ok",
    "message": "Task completed successfully",
    "results": null,
    "miq_server_id": "17",
    "identifier": null,
    "started_on": "2021-11-08T22:34:46Z",
    "zone": null,
    "task_results": [
        {
            "href": "http://localhost:3000/api/tasks/4680",
            "id": "4680",
            "name": "ag_destroy_test",
            "result": "allow"
            ^^^^^^^^^^^^^^^^
...
jrafanie commented 2 years ago

This requires you add a policy => condition, such as vm name includes "test", add a policy with vm and instance scope, use the created condition, assign an event such as login failed and generate log message for action. Put this policy into a policy profile, create one if you don't have one. Then, go to vm and instances and select several vms with names with some that meet the condition and some that don't. Then go to policy -> manage policies and add your policy profile.

Then, go to policy -> simulation and try to get the event for the specific vms to "allow" or "deny" the policy. Once that works to allow the proper one and deny the expected denial, you can try doing this in the API.

jrafanie commented 2 years ago

Note, opened a PR to fix a bug I found when testing this: https://github.com/ManageIQ/manageiq/pull/21549

miq-bot commented 1 year ago

This issue has been automatically marked as stale because it has not been updated for at least 3 months.

If you can still reproduce this issue on the current release or on master, please reply with all of the information you have about it in order to keep the issue open.

Thank you for all your contributions! More information about the ManageIQ triage process can be found in the triage process documentation.