manageiq-api
manageiq-api copied to clipboard
[WIP] API for VM Infra Reconfigure field form
Related PR https://github.com/ManageIQ/manageiq/pull/22980
API for VM Infra Reconfigure field form
Before - /vm_infra/reconfigure_form_fields/new,2983,4671
After
Get request for multiple ids GET /api/vm_infras/4671,2983
{
"objectIds": [
4671,
4672
],
"memory": "8",
"memory_type": "GB",
"socket_count": "2",
"cores_per_socket_count": "1",
"disks": [
{
"hdFilename": "7a0eaa34-df13-401f-b01a-1d19bb82329f",
"hdType": "thin",
"hdMode": "persistent",
"hdSize": "40",
"hdUnit": "GB",
"add_remove": "",
"cb_bootable": true,
"vm": [
{
"href": "http://localhost:3000/api/vm_infras/4671",
"id": "4671",
"vendor": "redhat",
"format": null,
"version": null,
"name": "2_vcr_liberty_keystone_v3",
"description": null,
"location": "20a02fe8-9586-4b01-b153-175b0257d1de.ovf",
"config_xml": null,
"autostart": null,
"host_id": null,
"last_sync_on": null,
"created_on": "2019-04-30T14:07:45Z",
"updated_on": "2020-01-14T15:11:22Z",
"storage_id": "29",
"guid": "8796fa1e-67bd-474c-b730-884f1cf7069a",
"ems_id": "56",
"last_scan_on": null,
"last_scan_attempt_on": null,
"uid_ems": "20a02fe8-9586-4b01-b153-175b0257d1de",
"retires_on": null,
"retired": null,
"boot_time": "2018-10-05T12:39:57Z",
"tools_status": null,
"standby_action": null,
"power_state": "off",
"state_changed_on": "2020-01-14T15:11:22Z",
"previous_state": "up",
"connection_state": "connected",
"last_perf_capture_on": null,
"registered": null,
"busy": null,
"smart": null,
"memory_reserve": 8192,
"memory_reserve_expand": null,
"memory_limit": 32768,
"memory_shares": null,
"memory_shares_level": null,
"cpu_reserve": null,
"cpu_reserve_expand": null,
"cpu_limit": null,
"cpu_shares": null,
"cpu_shares_level": null,
"cpu_affinity": null,
"ems_created_on": null,
"template": false,
"evm_owner_id": null,
"miq_group_id": "1",
"linked_clone": null,
"fault_tolerance": null,
"type": "ManageIQ::Providers::Redhat::InfraManager::Vm",
"ems_ref": "/api/vms/20a02fe8-9586-4b01-b153-175b0257d1de",
"ems_cluster_id": "10",
"retirement_warn": null,
"retirement_last_warn": null,
"vnc_port": null,
"flavor_id": null,
"availability_zone_id": null,
"cloud": false,
"retirement_state": null,
"cloud_network_id": null,
"cloud_subnet_id": null,
"cloud_tenant_id": null,
"raw_power_state": "down",
"publicly_available": null,
"orchestration_stack_id": null,
"retirement_requester": null,
"tenant_id": "1",
"resource_group_id": null,
"deprecated": null,
"storage_profile_id": null,
"cpu_hot_add_enabled": null,
"cpu_hot_remove_enabled": null,
"memory_hot_add_enabled": null,
"memory_hot_add_limit": null,
"memory_hot_add_increment": null,
"hostname": null,
"ems_ref_type": null,
"restart_needed": false,
"ancestry": "4678/4672",
"placement_group_id": null
},
{
"href": "http://localhost:3000/api/vm_infras/4672",
"id": "4672",
"vendor": "redhat",
"format": null,
"version": null,
"name": "3_vcr_kilo",
"description": null,
"location": "7404871d-ef18-4aee-86a4-6c9e1807867b.ovf",
"config_xml": null,
"autostart": null,
"host_id": null,
"last_sync_on": null,
"created_on": "2019-04-30T14:07:45Z",
"updated_on": "2020-01-14T15:11:22Z",
"storage_id": "29",
"guid": "8dfe73ad-8e67-4292-aeb1-840a4cb8a521",
"ems_id": "56",
"last_scan_on": null,
"last_scan_attempt_on": null,
"uid_ems": "7404871d-ef18-4aee-86a4-6c9e1807867b",
"retires_on": null,
"retired": null,
"boot_time": "2018-10-05T12:39:54Z",
"tools_status": null,
"standby_action": null,
"power_state": "off",
"state_changed_on": "2020-01-14T15:11:22Z",
"previous_state": "up",
"connection_state": "connected",
"last_perf_capture_on": null,
"registered": null,
"busy": null,
"smart": null,
"memory_reserve": 8192,
"memory_reserve_expand": null,
"memory_limit": 32768,
"memory_shares": null,
"memory_shares_level": null,
"cpu_reserve": null,
"cpu_reserve_expand": null,
"cpu_limit": null,
"cpu_shares": null,
"cpu_shares_level": null,
"cpu_affinity": null,
"ems_created_on": null,
"template": false,
"evm_owner_id": null,
"miq_group_id": "1",
"linked_clone": null,
"fault_tolerance": null,
"type": "ManageIQ::Providers::Redhat::InfraManager::Vm",
"ems_ref": "/api/vms/7404871d-ef18-4aee-86a4-6c9e1807867b",
"ems_cluster_id": "10",
"retirement_warn": null,
"retirement_last_warn": null,
"vnc_port": null,
"flavor_id": null,
"availability_zone_id": null,
"cloud": false,
"retirement_state": null,
"cloud_network_id": null,
"cloud_subnet_id": null,
"cloud_tenant_id": null,
"raw_power_state": "down",
"publicly_available": null,
"orchestration_stack_id": null,
"retirement_requester": null,
"tenant_id": "1",
"resource_group_id": null,
"deprecated": null,
"storage_profile_id": null,
"cpu_hot_add_enabled": null,
"cpu_hot_remove_enabled": null,
"memory_hot_add_enabled": null,
"memory_hot_add_limit": null,
"memory_hot_add_increment": null,
"hostname": null,
"ems_ref_type": null,
"restart_needed": false,
"ancestry": "4678",
"placement_group_id": null
}
]
}
],
"network_adapters": [],
"cdroms": [],
"vm_vendor": "redhat",
"vm_type": "ManageIQ::Providers::Redhat::InfraManager::Vm",
"orchestration_stack_id": null,
"disk_default_type": "thin",
"cb_memory": false,
"cb_cpu": false
}
Get request for single id GET /api/vm_infras/4671
{
"objectIds": [
4671
],
"memory": "8",
"memory_type": "GB",
"socket_count": "2",
"cores_per_socket_count": "1",
"disks": [
{
"hdFilename": "7a0eaa34-df13-401f-b01a-1d19bb82329f",
"hdType": "thin",
"hdMode": "persistent",
"hdSize": "40",
"hdUnit": "GB",
"add_remove": "",
"cb_bootable": true,
"vm": [
{
"href": "http://localhost:3000/api/vm_infras/4671",
"id": "4671",
"vendor": "redhat",
"format": null,
"version": null,
"name": "2_vcr_liberty_keystone_v3",
"description": null,
"location": "20a02fe8-9586-4b01-b153-175b0257d1de.ovf",
"config_xml": null,
"autostart": null,
"host_id": null,
"last_sync_on": null,
"created_on": "2019-04-30T14:07:45Z",
"updated_on": "2020-01-14T15:11:22Z",
"storage_id": "29",
"guid": "8796fa1e-67bd-474c-b730-884f1cf7069a",
"ems_id": "56",
"last_scan_on": null,
"last_scan_attempt_on": null,
"uid_ems": "20a02fe8-9586-4b01-b153-175b0257d1de",
"retires_on": null,
"retired": null,
"boot_time": "2018-10-05T12:39:57Z",
"tools_status": null,
"standby_action": null,
"power_state": "off",
"state_changed_on": "2020-01-14T15:11:22Z",
"previous_state": "up",
"connection_state": "connected",
"last_perf_capture_on": null,
"registered": null,
"busy": null,
"smart": null,
"memory_reserve": 8192,
"memory_reserve_expand": null,
"memory_limit": 32768,
"memory_shares": null,
"memory_shares_level": null,
"cpu_reserve": null,
"cpu_reserve_expand": null,
"cpu_limit": null,
"cpu_shares": null,
"cpu_shares_level": null,
"cpu_affinity": null,
"ems_created_on": null,
"template": false,
"evm_owner_id": null,
"miq_group_id": "1",
"linked_clone": null,
"fault_tolerance": null,
"type": "ManageIQ::Providers::Redhat::InfraManager::Vm",
"ems_ref": "/api/vms/20a02fe8-9586-4b01-b153-175b0257d1de",
"ems_cluster_id": "10",
"retirement_warn": null,
"retirement_last_warn": null,
"vnc_port": null,
"flavor_id": null,
"availability_zone_id": null,
"cloud": false,
"retirement_state": null,
"cloud_network_id": null,
"cloud_subnet_id": null,
"cloud_tenant_id": null,
"raw_power_state": "down",
"publicly_available": null,
"orchestration_stack_id": null,
"retirement_requester": null,
"tenant_id": "1",
"resource_group_id": null,
"deprecated": null,
"storage_profile_id": null,
"cpu_hot_add_enabled": null,
"cpu_hot_remove_enabled": null,
"memory_hot_add_enabled": null,
"memory_hot_add_limit": null,
"memory_hot_add_increment": null,
"hostname": null,
"ems_ref_type": null,
"restart_needed": false,
"ancestry": "4678/4672",
"placement_group_id": null
}
]
}
],
"network_adapters": [
{
"name": "nic1",
"vlan": "ovirtmgmt",
"mac": "00:1a:4a:fc:68:0e",
"add_remove": ""
}
],
"cdroms": [],
"vm_vendor": "redhat",
"vm_type": "ManageIQ::Providers::Redhat::InfraManager::Vm",
"orchestration_stack_id": null,
"disk_default_type": "thin",
"cb_memory": false,
"cb_cpu": false
}
Todo: API response
(out of band) update:
Going to move these to vms_controller.rb#reconfigure
suggestion: (was out of band)
putting here so it doesn't get lost
# @param type Vm
def reconfigure_resource(type, id, data = nil)
api_resource(type, id, "Reconfigure") do |vm|
options = {}
if data[:disk_add]
ensure_supports(type, vm, :reconfigure_disk)
end
request = VmReconfigureRequest.make_request(@request_id, options, current_user)
{}
end
end
@jaisejose1123 could you push a more recent version of this? I'm curious where it currently stands
I marked as wip. please remove the WIP when you are ready for review. (or ping me and I can remove the WIP)
Implemented VM infrastructures inside the VM controller.
Implemented VM infrastructures inside the VM controller.
Api screen short for multiple id's
Backend result while calling this above api
Api screen short for multiple id's
Backend result while calling this above api
When calling a single ID instead of multiple IDs, it should provide additional data. Consequently, we implemented APIs with different actions.
The below image will show the result while calling single id in manager-ui-classic
but while calling multiple id's it shows only limited data
app/controllers/api/base_controller/generic.rb
- [ ] :exclamation: - Line 255, Col 4 - Layout/TrailingEmptyLines - Final newline missing.
app/controllers/api/vms_controller.rb
- [ ] :warning: - Line 106, Col 9 - Layout/EndAlignment -
end
at 106, 8 is not aligned withunless
at 103, 6. - [ ] :warning: - Line 69, Col 9 - Layout/EndAlignment -
end
at 69, 8 is not aligned withunless
at 66, 6. - [ ] :warning: - Line 71, Col 9 - Lint/UselessAssignment - Useless assignment to variable -
new_row
. - [ ] :exclamation: - Line 102, Col 1 - Layout/TrailingWhitespace - Trailing whitespace detected.
- [ ] :exclamation: - Line 104, Col 7 - Layout/IndentationWidth - Use 2 (not 4) spaces for indentation.
- [ ] :exclamation: - Line 107, Col 9 - Layout/IndentationConsistency - Inconsistent indentation detected.
- [ ] :exclamation: - Line 109, Col 45 - Layout/SpaceAfterComma - Space missing after comma.
- [ ] :exclamation: - Line 109, Col 9 - Layout/IndentationConsistency - Inconsistent indentation detected.
- [ ] :exclamation: - Line 110, Col 1 - Layout/TrailingWhitespace - Trailing whitespace detected.
- [ ] :exclamation: - Line 111, Col 9 - Layout/IndentationConsistency - Inconsistent indentation detected.
- [ ] :exclamation: - Line 116, Col 9 - Layout/IndentationConsistency - Inconsistent indentation detected.
- [ ] :exclamation: - Line 117, Col 11 - Layout/EmptyLineAfterGuardClause - Add empty line after guard clause.
- [ ] :exclamation: - Line 120, Col 25 - Layout/HashAlignment - Align the keys and values of a hash literal if they span more than one line.
- [ ] :exclamation: - Line 121, Col 25 - Layout/HashAlignment - Align the keys and values of a hash literal if they span more than one line.
- [ ] :exclamation: - Line 122, Col 25 - Layout/HashAlignment - Align the keys and values of a hash literal if they span more than one line.
- [ ] :exclamation: - Line 123, Col 25 - Layout/HashAlignment - Align the keys and values of a hash literal if they span more than one line.
- [ ] :exclamation: - Line 124, Col 25 - Layout/HashAlignment - Align the keys and values of a hash literal if they span more than one line.
- [ ] :exclamation: - Line 125, Col 25 - Layout/HashAlignment - Align the keys and values of a hash literal if they span more than one line.
- [ ] :exclamation: - Line 127, Col 1 - Layout/EmptyLinesAroundBlockBody - Extra empty line detected at block body end.
- [ ] :exclamation: - Line 127, Col 1 - Layout/EmptyLines - Extra blank line detected.
- [ ] :exclamation: - Line 129, Col 1 - Layout/TrailingWhitespace - Trailing whitespace detected.
- [ ] :exclamation: - Line 130, Col 9 - Layout/IndentationConsistency - Inconsistent indentation detected.
- [ ] :exclamation: - Line 137, Col 9 - Layout/IndentationConsistency - Inconsistent indentation detected.
- [ ] :exclamation: - Line 57, Col 1 - Layout/TrailingWhitespace - Trailing whitespace detected.
- [ ] :exclamation: - Line 59, Col 1 - Layout/TrailingWhitespace - Trailing whitespace detected.
- [ ] :exclamation: - Line 61, Col 9 - Layout/HashAlignment - Align the keys and values of a hash literal if they span more than one line.
- [ ] :exclamation: - Line 62, Col 9 - Layout/HashAlignment - Align the keys and values of a hash literal if they span more than one line.
- [ ] :exclamation: - Line 63, Col 9 - Layout/HashAlignment - Align the keys and values of a hash literal if they span more than one line.
- [ ] :exclamation: - Line 65, Col 1 - Layout/TrailingWhitespace - Trailing whitespace detected.
- [ ] :exclamation: - Line 67, Col 7 - Layout/IndentationWidth - Use 2 (not 4) spaces for indentation.
- [ ] :exclamation: - Line 70, Col 9 - Layout/IndentationConsistency - Inconsistent indentation detected.
- [ ] :exclamation: - Line 71, Col 45 - Layout/SpaceAfterComma - Space missing after comma.
- [ ] :exclamation: - Line 71, Col 9 - Layout/IndentationConsistency - Inconsistent indentation detected.
- [ ] :exclamation: - Line 72, Col 1 - Layout/TrailingWhitespace - Trailing whitespace detected.
- [ ] :exclamation: - Line 73, Col 9 - Layout/IndentationConsistency - Inconsistent indentation detected.
- [ ] :exclamation: - Line 80, Col 9 - Layout/IndentationConsistency - Inconsistent indentation detected.
- [ ] :exclamation: - Line 83, Col 35 - Layout/SpaceAfterComma - Space missing after comma.
spec/requests/authentications_spec.rb
- [ ] :exclamation: - Line 492, Col 4 - Layout/TrailingWhitespace - Trailing whitespace detected.
- [ ] :exclamation: - Line 492, Col 5 - Layout/TrailingEmptyLines - Final newline missing.
I assume at some point this will create a VmReconfigureRequest
right?
Hey @jaisejose1123 ,
I had a short discussion with @kbrock and below is the outcome.
- Explained the conversion of
http.get
and useAPI.get
- Discussed about the method in reconfigure.rb/def get_reconfig_info
- talked about
attibutes=supports_reconfigure_cdrome/network_Adapters
- @kbrock to talk with @Fryguy about the
supports
column. - @jeffibm to checkout this branch and get the new response, reformat the response similar to the output from
get_reconfig_info
method.
@jaisejose1123 , could you please update the PR.
By utilizing the following GET API, we can gather the VM resources for the reconfigure field form for single id Api http://localhost:3000/api/vms/4671?attributes=name,num_cpu,cpu_cores_per_socket,mem_cpu,vendor,type,host.name,hardware.guest_devices,lans,hardware.disks,hardware.cdroms
Response
by this we can collect all the related information like lans,disks,network_adapters,hardware etc...
For multiple IDs, we can retrieve the data using bulk querying
post Apihttp://localhost:3000/api/vms?attributes=name,num_cpu,cpu_cores_per_socket,mem_cpu,vendor,type,host.name,hardware.guest_devices,lans,hardware.disks,hardware.cdroms
by passing json { "action" : "query", "resources" : [ { "id" : 2983 }, { "id" : 4671 } ] }
Response includes all the related information like lans,disks,network_adapters,hardware etc...
Most of this data should be retrieved using the standard GET
api.
Much of the data has a little manipulation but is pretty standard https://github.com/ManageIQ/manageiq-ui-classic/blob/master/app/controllers/mixins/actions/vm_actions/reconfigure.rb#L233
We do run into problems when accessing vm.supports?(:reconfigure_network_adapters)
.
It looks like some of this has been
http://localhost:3000/api/vms?expand=resources&attributes=name,num_cpu,cpu_cores_per_socket,mem_cpu,vendor,type,host.name,hardware.guest_devices,lans,hardware.disks,hardware.cdroms&filter[]=id=[2983,4671]
Updated the multiple id's api to Get request
Resopnse
This pull request has been automatically marked as stale because it has not been updated for at least 3 months.
If these changes are still valid, please remove the stale
label, make any changes requested by reviewers (if any), and ensure that this issue is being looked at by the assigned/reviewer(s).