From 87408c9c8d10dceece01d5f28cf0708eb3010ee3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Bosdonnat?= Date: Tue, 17 Sep 2024 16:42:43 +0200 Subject: [PATCH] Remove the virtualization code. --- .../com/redhat/rhn/GlobalInstanceHolder.java | 7 +- .../common/security/acl/test/AccessTest.java | 7 +- .../rhn/domain/action/ActionFactory.java | 80 - .../domain/action/Action_legacyUser.hbm.xml | 261 +- .../domain/action/test/ActionFactoryTest.java | 23 - .../BaseVirtualizationGuestAction.java | 51 - .../BaseVirtualizationNetworkAction.java | 43 - .../BaseVirtualizationPoolAction.java | 44 - .../BaseVirtualizationVolumeAction.java | 42 - .../VirtualizationCreateGuestAction.java | 92 - .../VirtualizationDeleteGuestAction.java | 22 - .../VirtualizationDestroyGuestAction.java | 22 - .../VirtualizationGuestPackageInstall.java | 26 - .../VirtualizationHostPackageInstall.java | 26 - .../VirtualizationMigrateGuestAction.java | 54 - .../VirtualizationNetworkCreateAction.java | 72 - ...irtualizationNetworkStateChangeAction.java | 36 - .../VirtualizationPoolCreateAction.java | 201 -- .../VirtualizationPoolCreateActionSource.java | 52 - .../VirtualizationPoolDeleteAction.java | 40 - .../VirtualizationPoolRefreshAction.java | 22 - .../VirtualizationPoolStartAction.java | 23 - .../VirtualizationPoolStopAction.java | 23 - .../VirtualizationRebootGuestAction.java | 37 - .../VirtualizationResumeGuestAction.java | 22 - .../VirtualizationSchedulePollerAction.java | 26 - .../VirtualizationSetMemoryGuestAction.java | 40 - .../VirtualizationSetVcpusGuestAction.java | 40 - .../VirtualizationShutdownGuestAction.java | 37 - .../VirtualizationStartGuestAction.java | 22 - .../VirtualizationSuspendGuestAction.java | 22 - .../test/VirtualizationActionsTest.java | 257 -- ...tualizationPoolCreateActionSourceTest.java | 65 - .../test/BaseEntitlementTestCase.java | 7 +- .../ContainerBuildHostEntitlementTest.java | 7 +- .../test/OSImageBuildHostEntitlementTest.java | 7 +- .../test/PeripheralServerEntitlementTest.java | 7 +- .../test/VirtualizationEntitlementTest.java | 7 +- .../image/test/ImageInfoFactoryTest.java | 7 +- .../domain/server/test/ServerFactoryTest.java | 7 +- .../rhn/domain/server/test/ServerTest.java | 8 +- .../test/VirtualInstanceFactoryTest.java | 7 +- .../SystemEntitlementsSetupActionTest.java | 7 +- .../SystemEntitlementsSubmitActionTest.java | 7 +- .../images/ScheduleImageDeploymentAction.java | 111 - .../sdc/test/SystemDetailsEditActionTest.java | 7 +- .../sdc/test/SystemOverviewActionTest.java | 7 +- .../ProvisionVirtualizationWizardAction.java | 370 -- ...ovisionVirtualizationWizardActionTest.java | 238 -- .../test/AdminConfigurationHandlerTest.java | 7 +- .../ansible/test/AnsibleHandlerTest.java | 7 +- .../test/ChannelSoftwareHandlerTest.java | 7 +- .../image/test/ImageInfoHandlerTest.java | 7 +- .../frontend/xmlrpc/system/SystemHandler.java | 175 - .../system/test/SystemHandlerPtfTest.java | 7 +- .../xmlrpc/system/test/SystemHandlerTest.java | 98 +- .../rhn/manager/action/ActionManager.java | 41 - .../action/test/ActionManagerTest.java | 7 +- .../action/test/MinionActionManagerTest.java | 7 +- .../org/test/MigrationManagerTest.java | 7 +- .../rhn/manager/system/SystemManager.java | 7 +- .../system/VirtualInstanceManager.java | 6 - .../system/entitling/SystemEntitler.java | 23 +- .../system/entitling/SystemUnentitler.java | 13 +- .../test/SystemEntitlementManagerTest.java | 7 +- .../system/test/AnsibleManagerTest.java | 7 +- .../system/test/SystemManagerTest.java | 7 +- .../test/PaygComputeDimensionsTaskTest.java | 7 +- .../matcher/test/MatcherJsonIOTest.java | 12 +- .../com/suse/manager/reactor/SaltReactor.java | 48 +- .../AbstractLibvirtEngineMessage.java | 133 - .../LibvirtEngineDomainLifecycleMessage.java | 57 - ...irtEngineDomainLifecycleMessageAction.java | 202 -- .../messaging/LibvirtEngineDomainMessage.java | 87 - .../LibvirtEngineNetworkLifecycleMessage.java | 56 - .../LibvirtEngineNetworkMessage.java | 77 - .../LibvirtEngineNetworkMessageAction.java | 31 - .../LibvirtEnginePoolLifecycleMessage.java | 56 - .../messaging/LibvirtEnginePoolMessage.java | 81 - .../LibvirtEnginePoolMessageAction.java | 31 - .../LibvirtEnginePoolRefreshMessage.java | 45 - .../RegisterMinionEventMessageAction.java | 7 +- .../test/JobReturnEventMessageActionTest.java | 7 +- ...ngineDomainLifecycleMessageActionTest.java | 304 -- .../src/com/suse/manager/utils/SaltUtils.java | 12 - .../manager/virtualization/DhcpHostDef.java | 97 - .../suse/manager/virtualization/DnsDef.java | 118 - .../virtualization/DnsForwarderDef.java | 68 - .../manager/virtualization/DnsHostDef.java | 67 - .../manager/virtualization/DnsSrvDef.java | 152 - .../manager/virtualization/DnsTxtDef.java | 65 - .../DomainCapabilitiesJson.java | 70 - .../virtualization/GuestCreateDetails.java | 120 - .../virtualization/GuestDefinition.java | 330 -- .../manager/virtualization/GuestDiskDef.java | 237 -- .../virtualization/GuestGraphicsDef.java | 69 - .../virtualization/GuestInterfaceDef.java | 98 - .../manager/virtualization/GuestOsDef.java | 138 - .../manager/virtualization/GuestVcpuDef.java | 85 - .../virtualization/HostCapabilitiesJson.java | 120 - .../suse/manager/virtualization/HostInfo.java | 58 - .../suse/manager/virtualization/IpDef.java | 207 -- .../suse/manager/virtualization/NatDef.java | 71 - .../virtualization/NetworkDefinition.java | 450 --- .../virtualization/PoolCapabilitiesJson.java | 222 -- .../virtualization/PoolDefinition.java | 155 - .../manager/virtualization/PoolSource.java | 194 -- .../virtualization/PoolSourceAdapter.java | 253 -- .../PoolSourceAuthentication.java | 148 - .../virtualization/PoolSourceDevice.java | 101 - .../manager/virtualization/PoolTarget.java | 121 - .../suse/manager/virtualization/Range.java | 81 - .../virtualization/VirtManagerSalt.java | 337 -- .../virtualization/VirtStatesHelper.java | 76 - .../virtualization/VirtualPortDef.java | 181 - .../VirtualizationActionHelper.java | 371 -- .../suse/manager/virtualization/VlanDef.java | 72 - .../virtualization/VmInfoDiskJson.java | 104 - .../manager/virtualization/VmInfoJson.java | 40 - .../test/NetworkDefinitionTest.java | 231 -- .../test/PoolDefinitionTest.java | 246 -- .../virtualization/test/TestVirtManager.java | 115 - .../test/VirtManagerSaltTest.java | 102 - .../virtualization/test/virt.features.json | 5 - .../virtualization/test/virt.vm_info.all.json | 108 - .../src/com/suse/manager/webui/Router.java | 17 - .../test/SystemsControllerTest.java | 25 +- .../AbstractVirtualizationController.java | 180 - .../VirtualGuestsController.java | 821 ----- .../virtualization/VirtualNetsController.java | 357 -- .../VirtualPoolsController.java | 457 --- .../gson/VirtualGuestMigrateActionJson.java | 51 - .../gson/VirtualGuestSetterActionJson.java | 38 - .../gson/VirtualGuestsBaseActionJson.java | 57 - .../gson/VirtualGuestsUpdateActionJson.java | 435 --- .../gson/VirtualNetworkBaseActionJson.java | 40 - .../gson/VirtualNetworkCreateActionJson.java | 38 - .../gson/VirtualNetworkInfoJson.java | 132 - .../gson/VirtualPoolBaseActionJson.java | 42 - .../gson/VirtualPoolCreateActionJson.java | 104 - .../gson/VirtualPoolDeleteActionJson.java | 38 - .../gson/VirtualStoragePoolInfoJson.java | 228 -- .../gson/VirtualStorageVolumeInfoJson.java | 109 - .../gson/VirtualVolumeBaseActionJson.java | 56 - .../test/VirtualGuestsControllerTest.java | 473 --- .../test/VirtualNetsControllerTest.java | 314 -- .../test/VirtualPoolsControllerTest.java | 320 -- .../test/virt.guest.allcaps.json | 837 ----- .../virtualization/test/virt.net.info.json | 18 - .../test/virt.node_devices.json | 3064 ----------------- .../virtualization/test/virt.pool.caps.json | 248 -- .../virtualization/test/virt.pool.info.json | 24 - .../virtualization/test/virt.volume.info.json | 22 - .../test/virt_utils.vm.info.json | 6 - .../test/virt_utils.vm_definition.json | 66 - .../services/SaltServerActionService.java | 575 ---- .../webui/services/iface/VirtManager.java | 171 - ...nionVirtualizationPillarGeneratorTest.java | 83 - .../test/SaltServerActionServiceTest.java | 80 +- .../virtualization/guests/console.jade | 22 - .../virtualization/guests/create.jade | 32 - .../templates/virtualization/guests/edit.jade | 28 - .../templates/virtualization/guests/show.jade | 22 - .../templates/virtualization/nets/create.jade | 21 - .../templates/virtualization/nets/edit.jade | 21 - .../templates/virtualization/nets/show.jade | 20 - .../virtualization/pools/create.jade | 20 - .../templates/virtualization/pools/edit.jade | 21 - .../templates/virtualization/pools/show.jade | 19 - .../webui/websocket/VirtNotifications.java | 379 -- .../json/VirtNotificationMessage.java | 53 - .../SCCSystemRegistrationManagerTest.java | 30 +- .../code/webapp/WEB-INF/nav/system_detail.xml | 9 - .../virtualization/images/deployment.jsp | 101 - .../virtualization/provision/first.jsp | 83 - .../virtualization/provision/second.jsp | 3 - .../virtualization/virtualguests_confirm.jsp | 92 - java/code/webapp/WEB-INF/struts-config.xml | 31 - java/spacewalk-java.changes.cbosdo.no-virt | 1 + .../spacewalk/common/data/rhnActionType.sql | 20 - .../data/rhnVirtualInstanceEventType.sql | 24 - .../common/tables/rhnActionVirtCreate.sql | 32 - .../common/tables/rhnActionVirtDelete.sql | 38 - .../common/tables/rhnActionVirtDestroy.sql | 38 - .../common/tables/rhnActionVirtMigrate.sql | 28 - .../tables/rhnActionVirtNetworkCreate.sql | 30 - .../rhnActionVirtNetworkStateChange.sql | 30 - .../common/tables/rhnActionVirtPoolCreate.sql | 42 - .../common/tables/rhnActionVirtPoolDelete.sql | 33 - .../tables/rhnActionVirtPoolRefresh.sql | 30 - .../common/tables/rhnActionVirtPoolStart.sql | 29 - .../common/tables/rhnActionVirtPoolStop.sql | 29 - .../common/tables/rhnActionVirtReboot.sql | 42 - .../common/tables/rhnActionVirtRefresh.sql | 37 - .../common/tables/rhnActionVirtResume.sql | 38 - .../tables/rhnActionVirtSchedulePoller.sql | 42 - .../common/tables/rhnActionVirtSetMemory.sql | 39 - .../common/tables/rhnActionVirtShutdown.sql | 42 - .../common/tables/rhnActionVirtStart.sql | 35 - .../common/tables/rhnActionVirtSuspend.sql | 38 - .../common/tables/rhnActionVirtVcpu.sql | 39 - .../common/tables/rhnActionVirtVolDelete.sql | 29 - .../tables/rhnVirtualInstanceEventLog.sql | 58 - .../tables/rhnVirtualInstanceEventType.sql | 33 - schema/spacewalk/common/tables/tables.deps | 2 - .../postgres/procs/delete_server.sql | 10 - .../postgres/triggers/rhnActionVirtDelete.sql | 14 - .../triggers/rhnActionVirtDestroy.sql | 15 - .../postgres/triggers/rhnActionVirtReboot.sql | 15 - .../triggers/rhnActionVirtRefresh.sql | 15 - .../postgres/triggers/rhnActionVirtResume.sql | 15 - .../triggers/rhnActionVirtSchedulePoller.sql | 14 - .../triggers/rhnActionVirtSetMemory.sql | 15 - .../triggers/rhnActionVirtShutdown.sql | 15 - .../postgres/triggers/rhnActionVirtStart.sql | 15 - .../triggers/rhnActionVirtSuspend.sql | 15 - .../postgres/triggers/rhnActionVirtVcpu.sql | 14 - .../003-virt-removal.sql | 36 + spacewalk/admin/Makefile.admin | 2 +- spacewalk/admin/mgr-websockify.service | 10 - spacewalk/admin/spacewalk-admin.spec | 2 - spacewalk/admin/spacewalk.target | 1 - spacewalk/admin/uyuni-check-database.service | 2 +- .../etc/httpd/conf.d/zz-spacewalk-www.conf | 2 - .../modules/engines/mgr_events.py | 10 - .../salt/virt/cluster-vm-primitive.conf | 10 - .../susemanager-sls/salt/virt/create-vm.sls | 170 - .../susemanager-sls/salt/virt/deleted.sls | 21 - .../salt/virt/engine-events.sls | 22 - .../salt/virt/guest-migrate.sls | 2 - .../salt/virt/network-create.sls | 19 - .../salt/virt/network-statechange.sls | 24 - .../susemanager-sls/salt/virt/pool-create.sls | 112 - .../salt/virt/pool-deleted.sls | 4 - .../salt/virt/pool-refreshed.sls | 4 - .../salt/virt/pool-statechange.sls | 4 - .../susemanager-sls/salt/virt/reset.sls | 9 - .../susemanager-sls/salt/virt/resumed.sls | 4 - .../susemanager-sls/salt/virt/setmem.sls | 6 - .../susemanager-sls/salt/virt/setvcpus.sls | 6 - .../susemanager-sls/salt/virt/statechange.sls | 21 - .../susemanager-sls/salt/virt/suspended.sls | 4 - .../susemanager-sls/salt/virt/update-vm.sls | 74 - .../salt/virt/volume-deleted.sls | 10 - .../susemanager-sls/src/grains/virt.py | 72 - .../susemanager-sls/src/states/virt_utils.py | 244 -- .../src/tests/data/virt_state-test.initcache | 32 - .../src/tests/test_grains_virt.py | 82 - .../src/tests/test_module_virt_utils.py | 310 -- .../src/tests/test_state_virt_utils.py | 242 -- .../susemanager-sls.changes.cbosdo.no-virt | 1 + testsuite/documentation/cucumber-steps.md | 90 - testsuite/documentation/guidelines.md | 1 - testsuite/documentation/optional.md | 39 - testsuite/features/core/allcli_sanity.feature | 7 - .../init_clients/min_virthost.feature | 74 - .../reposync/srv_create_activationkey.feature | 1 - .../features/secondary/minkvm_guests.feature | 447 --- .../secondary/srv_rename_hostname.feature | 22 - .../step_definitions/command_steps.rb | 2 +- .../features/step_definitions/salt_steps.rb | 4 - .../features/step_definitions/vm_steps.rb | 401 --- testsuite/features/support/constants.rb | 1 - testsuite/features/support/env.rb | 4 - .../features/support/remote_nodes_env.rb | 1 - .../run_sets/secondary_parallelizable.yml | 2 - web/html/src/manager/index.ts | 2 - .../src/manager/virtualization/ActionApi.tsx | 74 - .../virtualization/HypervisorCheck.tsx | 32 - .../src/manager/virtualization/ListTab.tsx | 287 -- .../virtualization/SimpleActionApi.tsx | 34 - .../virtualization/guests/GuestProperties.tsx | 340 -- .../guests/console/MessagePopUp.tsx | 70 - .../guests/console/guests-console-types.ts | 11 - .../guests/console/guests-console.module.css | 39 - .../console/guests-console.renderer.tsx | 31 - .../guests/console/guests-console.tsx | 374 -- .../guests/console/spice-client.ts | 118 - .../guests/console/vnc-client.ts | 67 - .../guests/create/guests-create.renderer.tsx | 28 - .../guests/create/guests-create.tsx | 105 - .../guests/edit/guests-edit.renderer.tsx | 28 - .../guests/edit/guests-edit.tsx | 131 - .../guests/list/MigrateDialog.tsx | 73 - .../guests/list/guests-list.renderer.tsx | 27 - .../guests/list/guests-list.tsx | 262 -- .../guests/properties/GuestDiskFields.tsx | 84 - .../guests/properties/GuestDiskFileFields.tsx | 45 - .../properties/GuestDiskVolumeFields.tsx | 124 - .../guests/properties/GuestDisksPanel.tsx | 101 - .../guests/properties/disk-utils.ts | 74 - .../guests/properties/guest-nics-panel.tsx | 122 - .../properties/guest-properties-form.tsx | 131 - .../guest-properties-traditional.tsx | 79 - .../guests/properties/templates.ts | 3 - .../guests/virtualization-domains-caps-api.ts | 63 - .../virtualization-guest-definition-api.ts | 58 - web/html/src/manager/virtualization/index.ts | 12 - .../src/manager/virtualization/list.utils.ts | 37 - .../nets/create/nets-create.renderer.tsx | 21 - .../nets/create/nets-create.tsx | 44 - .../nets/edit/nets-edit.renderer.tsx | 28 - .../virtualization/nets/edit/nets-edit.tsx | 55 - .../nets/list/nets-list.renderer.tsx | 18 - .../virtualization/nets/list/nets-list.tsx | 134 - .../nets/network-properties.test.tsx | 712 ---- .../nets/network-properties.tsx | 472 --- .../nets/properties/DnsConfig.tsx | 256 -- .../nets/properties/Interface.tsx | 32 - .../nets/properties/IpConfig.tsx | 155 - .../nets/properties/NetworkAddress.tsx | 110 - .../nets/properties/VirtualPortFields.tsx | 76 - .../virtualization/nets/properties/Vlans.tsx | 76 - .../nets/properties/fields-data.ts | 58 - .../nets/properties/utils.test.ts | 55 - .../virtualization/nets/properties/utils.ts | 15 - .../virtualization-network-definition-api.tsx | 49 - .../nets/virtualization-network-devs-api.ts | 41 - .../pools/create/pools-create.renderer.tsx | 21 - .../pools/create/pools-create.tsx | 42 - .../pools/edit/pools-edit.renderer.tsx | 28 - .../virtualization/pools/edit/pools-edit.tsx | 53 - .../pools/list/pools-list.renderer.tsx | 17 - .../virtualization/pools/list/pools-list.tsx | 413 --- .../virtualization/pools/pool-properties.tsx | 591 ---- .../pools/properties/fields-data.test.ts | 67 - .../pools/properties/fields-data.ts | 237 -- .../virtualization-pool-definition-api.tsx | 49 - .../pools/virtualization-pools-action-api.tsx | 51 - .../virtualization-pools-capabilities-api.ts | 41 - .../virtualization/useVirtNotification.ts | 106 - .../virtualization-list-refresh-api.ts | 33 - .../src/vendors/npm.licenses.structured.js | 2 +- web/html/src/vendors/npm.licenses.txt | 109 - web/spacewalk-web.changes.cbosdo.no-virt | 1 + web/spacewalk-web.spec | 4 +- 336 files changed, 123 insertions(+), 31692 deletions(-) delete mode 100644 java/code/src/com/redhat/rhn/domain/action/virtualization/BaseVirtualizationGuestAction.java delete mode 100644 java/code/src/com/redhat/rhn/domain/action/virtualization/BaseVirtualizationNetworkAction.java delete mode 100644 java/code/src/com/redhat/rhn/domain/action/virtualization/BaseVirtualizationPoolAction.java delete mode 100644 java/code/src/com/redhat/rhn/domain/action/virtualization/BaseVirtualizationVolumeAction.java delete mode 100644 java/code/src/com/redhat/rhn/domain/action/virtualization/VirtualizationCreateGuestAction.java delete mode 100644 java/code/src/com/redhat/rhn/domain/action/virtualization/VirtualizationDeleteGuestAction.java delete mode 100644 java/code/src/com/redhat/rhn/domain/action/virtualization/VirtualizationDestroyGuestAction.java delete mode 100644 java/code/src/com/redhat/rhn/domain/action/virtualization/VirtualizationGuestPackageInstall.java delete mode 100644 java/code/src/com/redhat/rhn/domain/action/virtualization/VirtualizationHostPackageInstall.java delete mode 100644 java/code/src/com/redhat/rhn/domain/action/virtualization/VirtualizationMigrateGuestAction.java delete mode 100644 java/code/src/com/redhat/rhn/domain/action/virtualization/VirtualizationNetworkCreateAction.java delete mode 100644 java/code/src/com/redhat/rhn/domain/action/virtualization/VirtualizationNetworkStateChangeAction.java delete mode 100644 java/code/src/com/redhat/rhn/domain/action/virtualization/VirtualizationPoolCreateAction.java delete mode 100644 java/code/src/com/redhat/rhn/domain/action/virtualization/VirtualizationPoolCreateActionSource.java delete mode 100644 java/code/src/com/redhat/rhn/domain/action/virtualization/VirtualizationPoolDeleteAction.java delete mode 100644 java/code/src/com/redhat/rhn/domain/action/virtualization/VirtualizationPoolRefreshAction.java delete mode 100644 java/code/src/com/redhat/rhn/domain/action/virtualization/VirtualizationPoolStartAction.java delete mode 100644 java/code/src/com/redhat/rhn/domain/action/virtualization/VirtualizationPoolStopAction.java delete mode 100644 java/code/src/com/redhat/rhn/domain/action/virtualization/VirtualizationRebootGuestAction.java delete mode 100644 java/code/src/com/redhat/rhn/domain/action/virtualization/VirtualizationResumeGuestAction.java delete mode 100644 java/code/src/com/redhat/rhn/domain/action/virtualization/VirtualizationSchedulePollerAction.java delete mode 100644 java/code/src/com/redhat/rhn/domain/action/virtualization/VirtualizationSetMemoryGuestAction.java delete mode 100644 java/code/src/com/redhat/rhn/domain/action/virtualization/VirtualizationSetVcpusGuestAction.java delete mode 100644 java/code/src/com/redhat/rhn/domain/action/virtualization/VirtualizationShutdownGuestAction.java delete mode 100644 java/code/src/com/redhat/rhn/domain/action/virtualization/VirtualizationStartGuestAction.java delete mode 100644 java/code/src/com/redhat/rhn/domain/action/virtualization/VirtualizationSuspendGuestAction.java delete mode 100644 java/code/src/com/redhat/rhn/domain/action/virtualization/test/VirtualizationActionsTest.java delete mode 100644 java/code/src/com/redhat/rhn/domain/action/virtualization/test/VirtualizationPoolCreateActionSourceTest.java delete mode 100644 java/code/src/com/redhat/rhn/frontend/action/systems/images/ScheduleImageDeploymentAction.java delete mode 100644 java/code/src/com/redhat/rhn/frontend/action/systems/virtualization/ProvisionVirtualizationWizardAction.java delete mode 100644 java/code/src/com/redhat/rhn/frontend/action/systems/virtualization/test/ProvisionVirtualizationWizardActionTest.java delete mode 100644 java/code/src/com/suse/manager/reactor/messaging/AbstractLibvirtEngineMessage.java delete mode 100644 java/code/src/com/suse/manager/reactor/messaging/LibvirtEngineDomainLifecycleMessage.java delete mode 100644 java/code/src/com/suse/manager/reactor/messaging/LibvirtEngineDomainLifecycleMessageAction.java delete mode 100644 java/code/src/com/suse/manager/reactor/messaging/LibvirtEngineDomainMessage.java delete mode 100644 java/code/src/com/suse/manager/reactor/messaging/LibvirtEngineNetworkLifecycleMessage.java delete mode 100644 java/code/src/com/suse/manager/reactor/messaging/LibvirtEngineNetworkMessage.java delete mode 100644 java/code/src/com/suse/manager/reactor/messaging/LibvirtEngineNetworkMessageAction.java delete mode 100644 java/code/src/com/suse/manager/reactor/messaging/LibvirtEnginePoolLifecycleMessage.java delete mode 100644 java/code/src/com/suse/manager/reactor/messaging/LibvirtEnginePoolMessage.java delete mode 100644 java/code/src/com/suse/manager/reactor/messaging/LibvirtEnginePoolMessageAction.java delete mode 100644 java/code/src/com/suse/manager/reactor/messaging/LibvirtEnginePoolRefreshMessage.java delete mode 100644 java/code/src/com/suse/manager/reactor/messaging/test/LibvirtEngineDomainLifecycleMessageActionTest.java delete mode 100644 java/code/src/com/suse/manager/virtualization/DhcpHostDef.java delete mode 100644 java/code/src/com/suse/manager/virtualization/DnsDef.java delete mode 100644 java/code/src/com/suse/manager/virtualization/DnsForwarderDef.java delete mode 100644 java/code/src/com/suse/manager/virtualization/DnsHostDef.java delete mode 100644 java/code/src/com/suse/manager/virtualization/DnsSrvDef.java delete mode 100644 java/code/src/com/suse/manager/virtualization/DnsTxtDef.java delete mode 100644 java/code/src/com/suse/manager/virtualization/DomainCapabilitiesJson.java delete mode 100644 java/code/src/com/suse/manager/virtualization/GuestCreateDetails.java delete mode 100644 java/code/src/com/suse/manager/virtualization/GuestDefinition.java delete mode 100644 java/code/src/com/suse/manager/virtualization/GuestDiskDef.java delete mode 100644 java/code/src/com/suse/manager/virtualization/GuestGraphicsDef.java delete mode 100644 java/code/src/com/suse/manager/virtualization/GuestInterfaceDef.java delete mode 100644 java/code/src/com/suse/manager/virtualization/GuestOsDef.java delete mode 100644 java/code/src/com/suse/manager/virtualization/GuestVcpuDef.java delete mode 100644 java/code/src/com/suse/manager/virtualization/HostCapabilitiesJson.java delete mode 100644 java/code/src/com/suse/manager/virtualization/HostInfo.java delete mode 100644 java/code/src/com/suse/manager/virtualization/IpDef.java delete mode 100644 java/code/src/com/suse/manager/virtualization/NatDef.java delete mode 100644 java/code/src/com/suse/manager/virtualization/NetworkDefinition.java delete mode 100644 java/code/src/com/suse/manager/virtualization/PoolCapabilitiesJson.java delete mode 100644 java/code/src/com/suse/manager/virtualization/PoolDefinition.java delete mode 100644 java/code/src/com/suse/manager/virtualization/PoolSource.java delete mode 100644 java/code/src/com/suse/manager/virtualization/PoolSourceAdapter.java delete mode 100644 java/code/src/com/suse/manager/virtualization/PoolSourceAuthentication.java delete mode 100644 java/code/src/com/suse/manager/virtualization/PoolSourceDevice.java delete mode 100644 java/code/src/com/suse/manager/virtualization/PoolTarget.java delete mode 100644 java/code/src/com/suse/manager/virtualization/Range.java delete mode 100644 java/code/src/com/suse/manager/virtualization/VirtManagerSalt.java delete mode 100644 java/code/src/com/suse/manager/virtualization/VirtStatesHelper.java delete mode 100644 java/code/src/com/suse/manager/virtualization/VirtualPortDef.java delete mode 100644 java/code/src/com/suse/manager/virtualization/VirtualizationActionHelper.java delete mode 100644 java/code/src/com/suse/manager/virtualization/VlanDef.java delete mode 100644 java/code/src/com/suse/manager/virtualization/VmInfoDiskJson.java delete mode 100644 java/code/src/com/suse/manager/virtualization/VmInfoJson.java delete mode 100644 java/code/src/com/suse/manager/virtualization/test/NetworkDefinitionTest.java delete mode 100644 java/code/src/com/suse/manager/virtualization/test/PoolDefinitionTest.java delete mode 100644 java/code/src/com/suse/manager/virtualization/test/TestVirtManager.java delete mode 100644 java/code/src/com/suse/manager/virtualization/test/VirtManagerSaltTest.java delete mode 100644 java/code/src/com/suse/manager/virtualization/test/virt.features.json delete mode 100644 java/code/src/com/suse/manager/virtualization/test/virt.vm_info.all.json delete mode 100644 java/code/src/com/suse/manager/webui/controllers/virtualization/AbstractVirtualizationController.java delete mode 100644 java/code/src/com/suse/manager/webui/controllers/virtualization/VirtualGuestsController.java delete mode 100644 java/code/src/com/suse/manager/webui/controllers/virtualization/VirtualNetsController.java delete mode 100644 java/code/src/com/suse/manager/webui/controllers/virtualization/VirtualPoolsController.java delete mode 100644 java/code/src/com/suse/manager/webui/controllers/virtualization/gson/VirtualGuestMigrateActionJson.java delete mode 100644 java/code/src/com/suse/manager/webui/controllers/virtualization/gson/VirtualGuestSetterActionJson.java delete mode 100644 java/code/src/com/suse/manager/webui/controllers/virtualization/gson/VirtualGuestsBaseActionJson.java delete mode 100644 java/code/src/com/suse/manager/webui/controllers/virtualization/gson/VirtualGuestsUpdateActionJson.java delete mode 100644 java/code/src/com/suse/manager/webui/controllers/virtualization/gson/VirtualNetworkBaseActionJson.java delete mode 100644 java/code/src/com/suse/manager/webui/controllers/virtualization/gson/VirtualNetworkCreateActionJson.java delete mode 100644 java/code/src/com/suse/manager/webui/controllers/virtualization/gson/VirtualNetworkInfoJson.java delete mode 100644 java/code/src/com/suse/manager/webui/controllers/virtualization/gson/VirtualPoolBaseActionJson.java delete mode 100644 java/code/src/com/suse/manager/webui/controllers/virtualization/gson/VirtualPoolCreateActionJson.java delete mode 100644 java/code/src/com/suse/manager/webui/controllers/virtualization/gson/VirtualPoolDeleteActionJson.java delete mode 100644 java/code/src/com/suse/manager/webui/controllers/virtualization/gson/VirtualStoragePoolInfoJson.java delete mode 100644 java/code/src/com/suse/manager/webui/controllers/virtualization/gson/VirtualStorageVolumeInfoJson.java delete mode 100644 java/code/src/com/suse/manager/webui/controllers/virtualization/gson/VirtualVolumeBaseActionJson.java delete mode 100644 java/code/src/com/suse/manager/webui/controllers/virtualization/test/VirtualGuestsControllerTest.java delete mode 100644 java/code/src/com/suse/manager/webui/controllers/virtualization/test/VirtualNetsControllerTest.java delete mode 100644 java/code/src/com/suse/manager/webui/controllers/virtualization/test/VirtualPoolsControllerTest.java delete mode 100644 java/code/src/com/suse/manager/webui/controllers/virtualization/test/virt.guest.allcaps.json delete mode 100644 java/code/src/com/suse/manager/webui/controllers/virtualization/test/virt.net.info.json delete mode 100644 java/code/src/com/suse/manager/webui/controllers/virtualization/test/virt.node_devices.json delete mode 100644 java/code/src/com/suse/manager/webui/controllers/virtualization/test/virt.pool.caps.json delete mode 100644 java/code/src/com/suse/manager/webui/controllers/virtualization/test/virt.pool.info.json delete mode 100644 java/code/src/com/suse/manager/webui/controllers/virtualization/test/virt.volume.info.json delete mode 100644 java/code/src/com/suse/manager/webui/controllers/virtualization/test/virt_utils.vm.info.json delete mode 100644 java/code/src/com/suse/manager/webui/controllers/virtualization/test/virt_utils.vm_definition.json delete mode 100644 java/code/src/com/suse/manager/webui/services/iface/VirtManager.java delete mode 100644 java/code/src/com/suse/manager/webui/services/pillar/test/MinionVirtualizationPillarGeneratorTest.java delete mode 100644 java/code/src/com/suse/manager/webui/templates/virtualization/guests/console.jade delete mode 100644 java/code/src/com/suse/manager/webui/templates/virtualization/guests/create.jade delete mode 100644 java/code/src/com/suse/manager/webui/templates/virtualization/guests/edit.jade delete mode 100644 java/code/src/com/suse/manager/webui/templates/virtualization/guests/show.jade delete mode 100644 java/code/src/com/suse/manager/webui/templates/virtualization/nets/create.jade delete mode 100644 java/code/src/com/suse/manager/webui/templates/virtualization/nets/edit.jade delete mode 100644 java/code/src/com/suse/manager/webui/templates/virtualization/nets/show.jade delete mode 100644 java/code/src/com/suse/manager/webui/templates/virtualization/pools/create.jade delete mode 100644 java/code/src/com/suse/manager/webui/templates/virtualization/pools/edit.jade delete mode 100644 java/code/src/com/suse/manager/webui/templates/virtualization/pools/show.jade delete mode 100644 java/code/src/com/suse/manager/webui/websocket/VirtNotifications.java delete mode 100644 java/code/src/com/suse/manager/webui/websocket/json/VirtNotificationMessage.java delete mode 100644 java/code/webapp/WEB-INF/pages/systems/details/virtualization/images/deployment.jsp delete mode 100644 java/code/webapp/WEB-INF/pages/systems/details/virtualization/provision/first.jsp delete mode 100644 java/code/webapp/WEB-INF/pages/systems/details/virtualization/provision/second.jsp delete mode 100644 java/code/webapp/WEB-INF/pages/systems/details/virtualization/virtualguests_confirm.jsp create mode 100644 java/spacewalk-java.changes.cbosdo.no-virt delete mode 100644 schema/spacewalk/common/data/rhnVirtualInstanceEventType.sql delete mode 100644 schema/spacewalk/common/tables/rhnActionVirtCreate.sql delete mode 100644 schema/spacewalk/common/tables/rhnActionVirtDelete.sql delete mode 100644 schema/spacewalk/common/tables/rhnActionVirtDestroy.sql delete mode 100644 schema/spacewalk/common/tables/rhnActionVirtMigrate.sql delete mode 100644 schema/spacewalk/common/tables/rhnActionVirtNetworkCreate.sql delete mode 100644 schema/spacewalk/common/tables/rhnActionVirtNetworkStateChange.sql delete mode 100644 schema/spacewalk/common/tables/rhnActionVirtPoolCreate.sql delete mode 100644 schema/spacewalk/common/tables/rhnActionVirtPoolDelete.sql delete mode 100644 schema/spacewalk/common/tables/rhnActionVirtPoolRefresh.sql delete mode 100644 schema/spacewalk/common/tables/rhnActionVirtPoolStart.sql delete mode 100644 schema/spacewalk/common/tables/rhnActionVirtPoolStop.sql delete mode 100644 schema/spacewalk/common/tables/rhnActionVirtReboot.sql delete mode 100644 schema/spacewalk/common/tables/rhnActionVirtRefresh.sql delete mode 100644 schema/spacewalk/common/tables/rhnActionVirtResume.sql delete mode 100644 schema/spacewalk/common/tables/rhnActionVirtSchedulePoller.sql delete mode 100644 schema/spacewalk/common/tables/rhnActionVirtSetMemory.sql delete mode 100644 schema/spacewalk/common/tables/rhnActionVirtShutdown.sql delete mode 100644 schema/spacewalk/common/tables/rhnActionVirtStart.sql delete mode 100644 schema/spacewalk/common/tables/rhnActionVirtSuspend.sql delete mode 100644 schema/spacewalk/common/tables/rhnActionVirtVcpu.sql delete mode 100644 schema/spacewalk/common/tables/rhnActionVirtVolDelete.sql delete mode 100644 schema/spacewalk/common/tables/rhnVirtualInstanceEventLog.sql delete mode 100644 schema/spacewalk/common/tables/rhnVirtualInstanceEventType.sql delete mode 100644 schema/spacewalk/postgres/triggers/rhnActionVirtDelete.sql delete mode 100644 schema/spacewalk/postgres/triggers/rhnActionVirtDestroy.sql delete mode 100644 schema/spacewalk/postgres/triggers/rhnActionVirtReboot.sql delete mode 100644 schema/spacewalk/postgres/triggers/rhnActionVirtRefresh.sql delete mode 100644 schema/spacewalk/postgres/triggers/rhnActionVirtResume.sql delete mode 100644 schema/spacewalk/postgres/triggers/rhnActionVirtSchedulePoller.sql delete mode 100644 schema/spacewalk/postgres/triggers/rhnActionVirtSetMemory.sql delete mode 100644 schema/spacewalk/postgres/triggers/rhnActionVirtShutdown.sql delete mode 100644 schema/spacewalk/postgres/triggers/rhnActionVirtStart.sql delete mode 100644 schema/spacewalk/postgres/triggers/rhnActionVirtSuspend.sql delete mode 100644 schema/spacewalk/postgres/triggers/rhnActionVirtVcpu.sql create mode 100644 schema/spacewalk/upgrade/susemanager-schema-5.1.0-to-susemanager-schema-5.1.1/003-virt-removal.sql delete mode 100644 spacewalk/admin/mgr-websockify.service delete mode 100644 susemanager-utils/susemanager-sls/salt/virt/cluster-vm-primitive.conf delete mode 100644 susemanager-utils/susemanager-sls/salt/virt/create-vm.sls delete mode 100644 susemanager-utils/susemanager-sls/salt/virt/deleted.sls delete mode 100644 susemanager-utils/susemanager-sls/salt/virt/engine-events.sls delete mode 100644 susemanager-utils/susemanager-sls/salt/virt/guest-migrate.sls delete mode 100644 susemanager-utils/susemanager-sls/salt/virt/network-create.sls delete mode 100644 susemanager-utils/susemanager-sls/salt/virt/network-statechange.sls delete mode 100644 susemanager-utils/susemanager-sls/salt/virt/pool-create.sls delete mode 100644 susemanager-utils/susemanager-sls/salt/virt/pool-deleted.sls delete mode 100644 susemanager-utils/susemanager-sls/salt/virt/pool-refreshed.sls delete mode 100644 susemanager-utils/susemanager-sls/salt/virt/pool-statechange.sls delete mode 100644 susemanager-utils/susemanager-sls/salt/virt/reset.sls delete mode 100644 susemanager-utils/susemanager-sls/salt/virt/resumed.sls delete mode 100644 susemanager-utils/susemanager-sls/salt/virt/setmem.sls delete mode 100644 susemanager-utils/susemanager-sls/salt/virt/setvcpus.sls delete mode 100644 susemanager-utils/susemanager-sls/salt/virt/statechange.sls delete mode 100644 susemanager-utils/susemanager-sls/salt/virt/suspended.sls delete mode 100644 susemanager-utils/susemanager-sls/salt/virt/update-vm.sls delete mode 100644 susemanager-utils/susemanager-sls/salt/virt/volume-deleted.sls delete mode 100644 susemanager-utils/susemanager-sls/src/grains/virt.py delete mode 100644 susemanager-utils/susemanager-sls/src/states/virt_utils.py delete mode 100644 susemanager-utils/susemanager-sls/src/tests/data/virt_state-test.initcache delete mode 100644 susemanager-utils/susemanager-sls/src/tests/test_grains_virt.py delete mode 100644 susemanager-utils/susemanager-sls/src/tests/test_module_virt_utils.py delete mode 100644 susemanager-utils/susemanager-sls/src/tests/test_state_virt_utils.py create mode 100644 susemanager-utils/susemanager-sls/susemanager-sls.changes.cbosdo.no-virt delete mode 100644 testsuite/features/init_clients/min_virthost.feature delete mode 100644 testsuite/features/secondary/minkvm_guests.feature delete mode 100644 testsuite/features/step_definitions/vm_steps.rb delete mode 100644 web/html/src/manager/virtualization/ActionApi.tsx delete mode 100644 web/html/src/manager/virtualization/HypervisorCheck.tsx delete mode 100644 web/html/src/manager/virtualization/ListTab.tsx delete mode 100644 web/html/src/manager/virtualization/SimpleActionApi.tsx delete mode 100644 web/html/src/manager/virtualization/guests/GuestProperties.tsx delete mode 100644 web/html/src/manager/virtualization/guests/console/MessagePopUp.tsx delete mode 100644 web/html/src/manager/virtualization/guests/console/guests-console-types.ts delete mode 100644 web/html/src/manager/virtualization/guests/console/guests-console.module.css delete mode 100644 web/html/src/manager/virtualization/guests/console/guests-console.renderer.tsx delete mode 100644 web/html/src/manager/virtualization/guests/console/guests-console.tsx delete mode 100644 web/html/src/manager/virtualization/guests/console/spice-client.ts delete mode 100644 web/html/src/manager/virtualization/guests/console/vnc-client.ts delete mode 100644 web/html/src/manager/virtualization/guests/create/guests-create.renderer.tsx delete mode 100644 web/html/src/manager/virtualization/guests/create/guests-create.tsx delete mode 100644 web/html/src/manager/virtualization/guests/edit/guests-edit.renderer.tsx delete mode 100644 web/html/src/manager/virtualization/guests/edit/guests-edit.tsx delete mode 100644 web/html/src/manager/virtualization/guests/list/MigrateDialog.tsx delete mode 100644 web/html/src/manager/virtualization/guests/list/guests-list.renderer.tsx delete mode 100644 web/html/src/manager/virtualization/guests/list/guests-list.tsx delete mode 100644 web/html/src/manager/virtualization/guests/properties/GuestDiskFields.tsx delete mode 100644 web/html/src/manager/virtualization/guests/properties/GuestDiskFileFields.tsx delete mode 100644 web/html/src/manager/virtualization/guests/properties/GuestDiskVolumeFields.tsx delete mode 100644 web/html/src/manager/virtualization/guests/properties/GuestDisksPanel.tsx delete mode 100644 web/html/src/manager/virtualization/guests/properties/disk-utils.ts delete mode 100644 web/html/src/manager/virtualization/guests/properties/guest-nics-panel.tsx delete mode 100644 web/html/src/manager/virtualization/guests/properties/guest-properties-form.tsx delete mode 100644 web/html/src/manager/virtualization/guests/properties/guest-properties-traditional.tsx delete mode 100644 web/html/src/manager/virtualization/guests/properties/templates.ts delete mode 100644 web/html/src/manager/virtualization/guests/virtualization-domains-caps-api.ts delete mode 100644 web/html/src/manager/virtualization/guests/virtualization-guest-definition-api.ts delete mode 100644 web/html/src/manager/virtualization/index.ts delete mode 100644 web/html/src/manager/virtualization/list.utils.ts delete mode 100644 web/html/src/manager/virtualization/nets/create/nets-create.renderer.tsx delete mode 100644 web/html/src/manager/virtualization/nets/create/nets-create.tsx delete mode 100644 web/html/src/manager/virtualization/nets/edit/nets-edit.renderer.tsx delete mode 100644 web/html/src/manager/virtualization/nets/edit/nets-edit.tsx delete mode 100644 web/html/src/manager/virtualization/nets/list/nets-list.renderer.tsx delete mode 100644 web/html/src/manager/virtualization/nets/list/nets-list.tsx delete mode 100644 web/html/src/manager/virtualization/nets/network-properties.test.tsx delete mode 100644 web/html/src/manager/virtualization/nets/network-properties.tsx delete mode 100644 web/html/src/manager/virtualization/nets/properties/DnsConfig.tsx delete mode 100644 web/html/src/manager/virtualization/nets/properties/Interface.tsx delete mode 100644 web/html/src/manager/virtualization/nets/properties/IpConfig.tsx delete mode 100644 web/html/src/manager/virtualization/nets/properties/NetworkAddress.tsx delete mode 100644 web/html/src/manager/virtualization/nets/properties/VirtualPortFields.tsx delete mode 100644 web/html/src/manager/virtualization/nets/properties/Vlans.tsx delete mode 100644 web/html/src/manager/virtualization/nets/properties/fields-data.ts delete mode 100644 web/html/src/manager/virtualization/nets/properties/utils.test.ts delete mode 100644 web/html/src/manager/virtualization/nets/properties/utils.ts delete mode 100644 web/html/src/manager/virtualization/nets/virtualization-network-definition-api.tsx delete mode 100644 web/html/src/manager/virtualization/nets/virtualization-network-devs-api.ts delete mode 100644 web/html/src/manager/virtualization/pools/create/pools-create.renderer.tsx delete mode 100644 web/html/src/manager/virtualization/pools/create/pools-create.tsx delete mode 100644 web/html/src/manager/virtualization/pools/edit/pools-edit.renderer.tsx delete mode 100644 web/html/src/manager/virtualization/pools/edit/pools-edit.tsx delete mode 100644 web/html/src/manager/virtualization/pools/list/pools-list.renderer.tsx delete mode 100644 web/html/src/manager/virtualization/pools/list/pools-list.tsx delete mode 100644 web/html/src/manager/virtualization/pools/pool-properties.tsx delete mode 100644 web/html/src/manager/virtualization/pools/properties/fields-data.test.ts delete mode 100644 web/html/src/manager/virtualization/pools/properties/fields-data.ts delete mode 100644 web/html/src/manager/virtualization/pools/virtualization-pool-definition-api.tsx delete mode 100644 web/html/src/manager/virtualization/pools/virtualization-pools-action-api.tsx delete mode 100644 web/html/src/manager/virtualization/pools/virtualization-pools-capabilities-api.ts delete mode 100644 web/html/src/manager/virtualization/useVirtNotification.ts delete mode 100644 web/html/src/manager/virtualization/virtualization-list-refresh-api.ts create mode 100644 web/spacewalk-web.changes.cbosdo.no-virt diff --git a/java/code/src/com/redhat/rhn/GlobalInstanceHolder.java b/java/code/src/com/redhat/rhn/GlobalInstanceHolder.java index 5668a18adb79..df780044e7a8 100644 --- a/java/code/src/com/redhat/rhn/GlobalInstanceHolder.java +++ b/java/code/src/com/redhat/rhn/GlobalInstanceHolder.java @@ -33,7 +33,6 @@ import com.suse.manager.kubernetes.KubernetesManager; import com.suse.manager.utils.SaltKeyUtils; import com.suse.manager.utils.SaltUtils; -import com.suse.manager.virtualization.VirtManagerSalt; import com.suse.manager.webui.controllers.bootstrap.RegularMinionBootstrapper; import com.suse.manager.webui.controllers.bootstrap.SSHMinionBootstrapper; import com.suse.manager.webui.menu.MenuTree; @@ -42,7 +41,6 @@ import com.suse.manager.webui.services.iface.MonitoringManager; import com.suse.manager.webui.services.iface.SaltApi; import com.suse.manager.webui.services.iface.SystemQuery; -import com.suse.manager.webui.services.iface.VirtManager; import com.suse.manager.webui.services.impl.SaltService; import com.suse.manager.webui.utils.MinionActionUtils; import com.suse.manager.webui.utils.UserPreferenceUtils; @@ -79,15 +77,14 @@ private GlobalInstanceHolder() { public static final RenderUtils RENDER_UTILS = new RenderUtils(ACL_FACTORY); public static final MinionActionUtils MINION_ACTION_UTILS = new MinionActionUtils(SALT_API, SALT_UTILS); public static final KubernetesManager KUBERNETES_MANAGER = new KubernetesManager(SALT_API); - public static final VirtManager VIRT_MANAGER = new VirtManagerSalt(SALT_API); public static final RegularMinionBootstrapper REGULAR_MINION_BOOTSTRAPPER = new RegularMinionBootstrapper(SYSTEM_QUERY, SALT_API, PAYG_MANAGER, ATTESTATION_MANAGER); public static final SSHMinionBootstrapper SSH_MINION_BOOTSTRAPPER = new SSHMinionBootstrapper(SYSTEM_QUERY, SALT_API, PAYG_MANAGER, ATTESTATION_MANAGER); public static final MonitoringManager MONITORING_MANAGER = new FormulaMonitoringManager(SALT_API); public static final SystemEntitlementManager SYSTEM_ENTITLEMENT_MANAGER = new SystemEntitlementManager( - new SystemUnentitler(VIRT_MANAGER, MONITORING_MANAGER, SERVER_GROUP_MANAGER), - new SystemEntitler(SALT_API, VIRT_MANAGER, MONITORING_MANAGER, + new SystemUnentitler(MONITORING_MANAGER, SERVER_GROUP_MANAGER), + new SystemEntitler(SALT_API, MONITORING_MANAGER, SERVER_GROUP_MANAGER) ); public static final SystemManager SYSTEM_MANAGER = new SystemManager(ServerFactory.SINGLETON, diff --git a/java/code/src/com/redhat/rhn/common/security/acl/test/AccessTest.java b/java/code/src/com/redhat/rhn/common/security/acl/test/AccessTest.java index a6167a3598ab..98f622c5276a 100644 --- a/java/code/src/com/redhat/rhn/common/security/acl/test/AccessTest.java +++ b/java/code/src/com/redhat/rhn/common/security/acl/test/AccessTest.java @@ -45,10 +45,8 @@ import com.redhat.rhn.testing.TestUtils; import com.redhat.rhn.testing.UserTestUtils; -import com.suse.manager.virtualization.VirtManagerSalt; import com.suse.manager.webui.services.iface.MonitoringManager; import com.suse.manager.webui.services.iface.SaltApi; -import com.suse.manager.webui.services.iface.VirtManager; import com.suse.manager.webui.services.test.TestSaltApi; import org.junit.jupiter.api.BeforeEach; @@ -69,11 +67,10 @@ public class AccessTest extends BaseTestCaseWithUser { private Acl acl; private final SaltApi saltApi = new TestSaltApi(); private final ServerGroupManager serverGroupManager = new ServerGroupManager(saltApi); - private final VirtManager virtManager = new VirtManagerSalt(saltApi); private final MonitoringManager monitoringManager = new FormulaMonitoringManager(saltApi); private final SystemEntitlementManager systemEntitlementManager = new SystemEntitlementManager( - new SystemUnentitler(virtManager, monitoringManager, serverGroupManager), - new SystemEntitler(saltApi, virtManager, monitoringManager, serverGroupManager) + new SystemUnentitler(monitoringManager, serverGroupManager), + new SystemEntitler(saltApi, monitoringManager, serverGroupManager) ); @Override diff --git a/java/code/src/com/redhat/rhn/domain/action/ActionFactory.java b/java/code/src/com/redhat/rhn/domain/action/ActionFactory.java index 2e173986d807..9f760a81bd15 100644 --- a/java/code/src/com/redhat/rhn/domain/action/ActionFactory.java +++ b/java/code/src/com/redhat/rhn/domain/action/ActionFactory.java @@ -52,26 +52,6 @@ import com.redhat.rhn.domain.action.script.ScriptActionDetails; import com.redhat.rhn.domain.action.script.ScriptRunAction; import com.redhat.rhn.domain.action.server.ServerAction; -import com.redhat.rhn.domain.action.virtualization.BaseVirtualizationVolumeAction; -import com.redhat.rhn.domain.action.virtualization.VirtualizationCreateGuestAction; -import com.redhat.rhn.domain.action.virtualization.VirtualizationDeleteGuestAction; -import com.redhat.rhn.domain.action.virtualization.VirtualizationDestroyGuestAction; -import com.redhat.rhn.domain.action.virtualization.VirtualizationMigrateGuestAction; -import com.redhat.rhn.domain.action.virtualization.VirtualizationNetworkCreateAction; -import com.redhat.rhn.domain.action.virtualization.VirtualizationNetworkStateChangeAction; -import com.redhat.rhn.domain.action.virtualization.VirtualizationPoolCreateAction; -import com.redhat.rhn.domain.action.virtualization.VirtualizationPoolDeleteAction; -import com.redhat.rhn.domain.action.virtualization.VirtualizationPoolRefreshAction; -import com.redhat.rhn.domain.action.virtualization.VirtualizationPoolStartAction; -import com.redhat.rhn.domain.action.virtualization.VirtualizationPoolStopAction; -import com.redhat.rhn.domain.action.virtualization.VirtualizationRebootGuestAction; -import com.redhat.rhn.domain.action.virtualization.VirtualizationResumeGuestAction; -import com.redhat.rhn.domain.action.virtualization.VirtualizationSchedulePollerAction; -import com.redhat.rhn.domain.action.virtualization.VirtualizationSetMemoryGuestAction; -import com.redhat.rhn.domain.action.virtualization.VirtualizationSetVcpusGuestAction; -import com.redhat.rhn.domain.action.virtualization.VirtualizationShutdownGuestAction; -import com.redhat.rhn.domain.action.virtualization.VirtualizationStartGuestAction; -import com.redhat.rhn.domain.action.virtualization.VirtualizationSuspendGuestAction; import com.redhat.rhn.domain.config.ConfigRevision; import com.redhat.rhn.domain.rhnpackage.PackageEvr; import com.redhat.rhn.domain.rhnpackage.PackageEvrFactory; @@ -419,72 +399,12 @@ else if (typeIn.equals(TYPE_KICKSTART_INITIATE_GUEST)) { else if (typeIn.equals(TYPE_DAEMON_CONFIG)) { retval = new DaemonConfigAction(); } - else if (typeIn.equals(TYPE_VIRTUALIZATION_SHUTDOWN)) { - retval = new VirtualizationShutdownGuestAction(); - } - else if (typeIn.equals(TYPE_VIRTUALIZATION_START)) { - retval = new VirtualizationStartGuestAction(); - } - else if (typeIn.equals(TYPE_VIRTUALIZATION_SUSPEND)) { - retval = new VirtualizationSuspendGuestAction(); - } - else if (typeIn.equals(TYPE_VIRTUALIZATION_RESUME)) { - retval = new VirtualizationResumeGuestAction(); - } - else if (typeIn.equals(TYPE_VIRTUALIZATION_REBOOT)) { - retval = new VirtualizationRebootGuestAction(); - } - else if (typeIn.equals(TYPE_VIRTUALIZATION_DESTROY)) { - retval = new VirtualizationDestroyGuestAction(); - } - else if (typeIn.equals(TYPE_VIRTUALIZATION_DELETE)) { - retval = new VirtualizationDeleteGuestAction(); - } - else if (typeIn.equals(TYPE_VIRTUALIZATION_SET_MEMORY)) { - retval = new VirtualizationSetMemoryGuestAction(); - } - else if (typeIn.equals(TYPE_VIRTUALIZATION_SET_VCPUS)) { - retval = new VirtualizationSetVcpusGuestAction(); - } - else if (typeIn.equals(TYPE_VIRTUALIZATION_GUEST_MIGRATE)) { - retval = new VirtualizationMigrateGuestAction(); - } - else if (typeIn.equals(TYPE_VIRTUALIZATION_SCHEDULE_POLLER)) { - retval = new VirtualizationSchedulePollerAction(); - } else if (typeIn.equals(TYPE_VIRTIZATION_HOST_SUBSCRIBE_TO_TOOLS_CHANNEL)) { retval = new KickstartHostToolsChannelSubscriptionAction(); } else if (typeIn.equals(TYPE_VIRTUALIZATION_GUEST_SUBSCRIBE_TO_TOOLS_CHANNEL)) { retval = new KickstartGuestToolsChannelSubscriptionAction(); } - else if (typeIn.equals(TYPE_VIRTUALIZATION_CREATE)) { - retval = new VirtualizationCreateGuestAction(); - } - else if (typeIn.equals(TYPE_VIRTUALIZATION_POOL_REFRESH)) { - retval = new VirtualizationPoolRefreshAction(); - } - else if (typeIn.equals(TYPE_VIRTUALIZATION_POOL_START)) { - retval = new VirtualizationPoolStartAction(); - } - else if (typeIn.equals(TYPE_VIRTUALIZATION_POOL_STOP)) { - retval = new VirtualizationPoolStopAction(); - } - else if (typeIn.equals(TYPE_VIRTUALIZATION_POOL_DELETE)) { - retval = new VirtualizationPoolDeleteAction(); - } - else if (typeIn.equals(TYPE_VIRTUALIZATION_POOL_CREATE)) { - retval = new VirtualizationPoolCreateAction(); - } - else if (typeIn.equals(TYPE_VIRTUALIZATION_VOLUME_DELETE)) { - retval = new BaseVirtualizationVolumeAction(); - } - else if (typeIn.equals(TYPE_VIRTUALIZATION_NETWORK_STATE_CHANGE)) { - retval = new VirtualizationNetworkStateChangeAction(); - } - else if (typeIn.equals(TYPE_VIRTUALIZATION_NETWORK_CREATE)) { - retval = new VirtualizationNetworkCreateAction(); - } else if (typeIn.equals(TYPE_SCAP_XCCDF_EVAL)) { retval = new ScapAction(); } diff --git a/java/code/src/com/redhat/rhn/domain/action/Action_legacyUser.hbm.xml b/java/code/src/com/redhat/rhn/domain/action/Action_legacyUser.hbm.xml index dab9696b70bc..f34e6e0779ba 100644 --- a/java/code/src/com/redhat/rhn/domain/action/Action_legacyUser.hbm.xml +++ b/java/code/src/com/redhat/rhn/domain/action/Action_legacyUser.hbm.xml @@ -253,89 +253,6 @@ PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -348,83 +265,6 @@ PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" discriminator-value="51" lazy="true"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - () { }.getType()); - } - - @Override - public String getWebSocketActionId() { - return String.format("new-%s", getId()); - } -} diff --git a/java/code/src/com/redhat/rhn/domain/action/virtualization/VirtualizationNetworkStateChangeAction.java b/java/code/src/com/redhat/rhn/domain/action/virtualization/VirtualizationNetworkStateChangeAction.java deleted file mode 100644 index b6c2f7b5648e..000000000000 --- a/java/code/src/com/redhat/rhn/domain/action/virtualization/VirtualizationNetworkStateChangeAction.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2020 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.redhat.rhn.domain.action.virtualization; - -/** - * Represents the virtual network actions like start, stop and delete - */ -public class VirtualizationNetworkStateChangeAction extends BaseVirtualizationNetworkAction { - private String state; - - /** - * @return the state to change the networks to - */ - public String getState() { - return state; - } - - /** - * @param stateIn the state to change the networks to - */ - public void setState(String stateIn) { - state = stateIn; - } -} diff --git a/java/code/src/com/redhat/rhn/domain/action/virtualization/VirtualizationPoolCreateAction.java b/java/code/src/com/redhat/rhn/domain/action/virtualization/VirtualizationPoolCreateAction.java deleted file mode 100644 index f0425506fde9..000000000000 --- a/java/code/src/com/redhat/rhn/domain/action/virtualization/VirtualizationPoolCreateAction.java +++ /dev/null @@ -1,201 +0,0 @@ -/* - * Copyright (c) 2020 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.redhat.rhn.domain.action.virtualization; - -/** - * Represents a virtual storage creation action. - */ -public class VirtualizationPoolCreateAction extends BaseVirtualizationPoolAction { - - private String uuid; - private String type; - private String target; - private boolean autostart = false; - - // Permissions properties - private String mode; - private String owner; - private String group; - private String seclabel; - - private VirtualizationPoolCreateActionSource source; - - - /** - * @return Returns the uuid. - */ - public String getUuid() { - return uuid; - } - - - /** - * @param uuidIn The uuid to set. - */ - public void setUuid(String uuidIn) { - uuid = uuidIn; - } - - /** - * @return Returns the pool type. - */ - public String getType() { - return type; - } - - /** - * @param typeIn The pool type to set. - */ - public void setType(String typeIn) { - type = typeIn; - } - - /** - * @return Returns the target. - */ - public String getTarget() { - return target; - } - - /** - * @param targetIn The target to set. - */ - public void setTarget(String targetIn) { - target = targetIn; - } - - /** - * @return Returns whether to autostart the pool. - */ - public boolean isAutostart() { - return autostart; - } - - /** - * @param autostartIn True if the pool needs to be automatically started. - */ - public void setAutostart(boolean autostartIn) { - autostart = autostartIn; - } - - /** - * @return Returns the permission mode. - */ - public String getMode() { - return mode; - } - - /** - * @param modeIn The permission mode to set. - */ - public void setMode(String modeIn) { - mode = modeIn; - } - - /** - * @return Returns the owner user. - */ - public String getOwner() { - return owner; - } - - /** - * @param ownerIn The owner user to set. - */ - public void setOwner(String ownerIn) { - owner = ownerIn; - } - - - /** - * @return Returns the group. - */ - public String getGroup() { - return group; - } - - /** - * @param groupIn The group to set. - */ - public void setGroup(String groupIn) { - group = groupIn; - } - - /** - * @return Returns the SE Linux label. - */ - public String getSeclabel() { - return seclabel; - } - - /** - * @param seclabelIn The SE Linux label to set. - */ - public void setSeclabel(String seclabelIn) { - seclabel = seclabelIn; - } - - /** - * @return Returns the source. - */ - public VirtualizationPoolCreateActionSource getSource() { - return source; - } - - /** - * @return the source serialized into a String. - * - * This function should only be used by hibernate. - */ - public String getSourceAsString() { - String string = null; - if (source != null) { - string = source.toString(); - } - return string; - } - - /** - * @param sourceIn The source to set. - */ - public void setSource(VirtualizationPoolCreateActionSource sourceIn) { - source = sourceIn; - } - - /** - * Set the source from its Serialized value. - * - * @param sourceString serialized value. - * - * This function should only be used by hibernate. - */ - public void setSourceAsString(String sourceString) { - if (sourceString != null) { - source = VirtualizationPoolCreateActionSource.parse(sourceString); - } - else { - source = null; - } - } - - @Override - public String getWebSocketActionId() { - String id = super.getWebSocketActionId(); - if (getUuid() == null) { - id = String.format("new-%s", getId()); - } - return id; - } -} diff --git a/java/code/src/com/redhat/rhn/domain/action/virtualization/VirtualizationPoolCreateActionSource.java b/java/code/src/com/redhat/rhn/domain/action/virtualization/VirtualizationPoolCreateActionSource.java deleted file mode 100644 index a43f3a59b7f8..000000000000 --- a/java/code/src/com/redhat/rhn/domain/action/virtualization/VirtualizationPoolCreateActionSource.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2020 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.redhat.rhn.domain.action.virtualization; - -import com.suse.manager.reactor.utils.OptionalTypeAdapterFactory; -import com.suse.manager.virtualization.PoolSource; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.reflect.TypeToken; - -/** - * Represents the virtual storage source parameters for the storage pool creation action. - * Note that to save database fields this is stored as a json string in the database. - */ -public class VirtualizationPoolCreateActionSource extends PoolSource { - - private static final Gson GSON = new GsonBuilder() - .registerTypeAdapterFactory(new OptionalTypeAdapterFactory()) - .create(); - - /** - * Create from a serialized string. - * - * @param json the serialized string as output by toString() - * @return the parsed object - */ - public static VirtualizationPoolCreateActionSource parse(String json) { - return GSON.fromJson(json, new TypeToken() { }.getType()); - } - - /** - * Serializes into a json string - * {@inheritDoc} - */ - @Override - public String toString() { - return GSON.toJson(this); - } -} diff --git a/java/code/src/com/redhat/rhn/domain/action/virtualization/VirtualizationPoolDeleteAction.java b/java/code/src/com/redhat/rhn/domain/action/virtualization/VirtualizationPoolDeleteAction.java deleted file mode 100644 index e81ecda45699..000000000000 --- a/java/code/src/com/redhat/rhn/domain/action/virtualization/VirtualizationPoolDeleteAction.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2020 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.redhat.rhn.domain.action.virtualization; - -/** - * Represents a virtual storage removal action. - */ -public class VirtualizationPoolDeleteAction extends BaseVirtualizationPoolAction { - - private boolean purge = false; - - /** - * Set whether the delete operation needs to also delete the data. - * - * @param purgeIn true to delete the pool and volumes, false otherwise - */ - public void setPurge(boolean purgeIn) { - purge = purgeIn; - } - - /** - * @return whether the delete operation needs to also delete the data. - * Defaults to false. - */ - public boolean isPurge() { - return purge; - } -} diff --git a/java/code/src/com/redhat/rhn/domain/action/virtualization/VirtualizationPoolRefreshAction.java b/java/code/src/com/redhat/rhn/domain/action/virtualization/VirtualizationPoolRefreshAction.java deleted file mode 100644 index bebd48118b59..000000000000 --- a/java/code/src/com/redhat/rhn/domain/action/virtualization/VirtualizationPoolRefreshAction.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (c) 2020 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.redhat.rhn.domain.action.virtualization; - -/** - * Represents a virtual storage refresh action. - */ -public class VirtualizationPoolRefreshAction extends BaseVirtualizationPoolAction { - -} diff --git a/java/code/src/com/redhat/rhn/domain/action/virtualization/VirtualizationPoolStartAction.java b/java/code/src/com/redhat/rhn/domain/action/virtualization/VirtualizationPoolStartAction.java deleted file mode 100644 index 2be1a30414fe..000000000000 --- a/java/code/src/com/redhat/rhn/domain/action/virtualization/VirtualizationPoolStartAction.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (c) 2020 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.redhat.rhn.domain.action.virtualization; - - -/** - * Represents a virtual storage start action. - */ -public class VirtualizationPoolStartAction extends BaseVirtualizationPoolAction { - -} diff --git a/java/code/src/com/redhat/rhn/domain/action/virtualization/VirtualizationPoolStopAction.java b/java/code/src/com/redhat/rhn/domain/action/virtualization/VirtualizationPoolStopAction.java deleted file mode 100644 index 8204db6e2f5d..000000000000 --- a/java/code/src/com/redhat/rhn/domain/action/virtualization/VirtualizationPoolStopAction.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (c) 2020 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.redhat.rhn.domain.action.virtualization; - - -/** - * Represents a virtual storage stop action. - */ -public class VirtualizationPoolStopAction extends BaseVirtualizationPoolAction { - -} diff --git a/java/code/src/com/redhat/rhn/domain/action/virtualization/VirtualizationRebootGuestAction.java b/java/code/src/com/redhat/rhn/domain/action/virtualization/VirtualizationRebootGuestAction.java deleted file mode 100644 index 03a9ad018132..000000000000 --- a/java/code/src/com/redhat/rhn/domain/action/virtualization/VirtualizationRebootGuestAction.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2009--2010 Red Hat, Inc. - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.redhat.rhn.domain.action.virtualization; - -/** - * Class representing TYPE_VIRTUALIZATION_REBOOT - */ -public class VirtualizationRebootGuestAction extends BaseVirtualizationGuestAction { - - private boolean force = false; - - /** - * @return Returns whether to force off rather than cleanly shutting down. - */ - public boolean isForce() { - return force; - } - - /** - * @param forceIn whether to force off rather than cleanly shutting down. - */ - public void setForce(boolean forceIn) { - force = forceIn; - } -} diff --git a/java/code/src/com/redhat/rhn/domain/action/virtualization/VirtualizationResumeGuestAction.java b/java/code/src/com/redhat/rhn/domain/action/virtualization/VirtualizationResumeGuestAction.java deleted file mode 100644 index 4328ada7f834..000000000000 --- a/java/code/src/com/redhat/rhn/domain/action/virtualization/VirtualizationResumeGuestAction.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (c) 2009--2010 Red Hat, Inc. - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.redhat.rhn.domain.action.virtualization; - -/** - * Class representing TYPE_VIRTUALIZATION_RESUME - */ -public class VirtualizationResumeGuestAction extends BaseVirtualizationGuestAction { - -} diff --git a/java/code/src/com/redhat/rhn/domain/action/virtualization/VirtualizationSchedulePollerAction.java b/java/code/src/com/redhat/rhn/domain/action/virtualization/VirtualizationSchedulePollerAction.java deleted file mode 100644 index 8ba59439e650..000000000000 --- a/java/code/src/com/redhat/rhn/domain/action/virtualization/VirtualizationSchedulePollerAction.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2009--2010 Red Hat, Inc. - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.redhat.rhn.domain.action.virtualization; - -import com.redhat.rhn.domain.action.Action; - -/** - * VirtualizationSchedulePollerAction - Class representing - * TYPE_VIRTUALIZATION_SCHEDULE_POLLER - * - */ -public class VirtualizationSchedulePollerAction extends Action { - -} diff --git a/java/code/src/com/redhat/rhn/domain/action/virtualization/VirtualizationSetMemoryGuestAction.java b/java/code/src/com/redhat/rhn/domain/action/virtualization/VirtualizationSetMemoryGuestAction.java deleted file mode 100644 index 44ec45f2acd3..000000000000 --- a/java/code/src/com/redhat/rhn/domain/action/virtualization/VirtualizationSetMemoryGuestAction.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2009--2010 Red Hat, Inc. - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.redhat.rhn.domain.action.virtualization; - -/** - * Class representing TYPE_VIRTUALIZATION_SET_MEMORY. - * Make sure the 'memory' field is in kilobytes. - */ -public class VirtualizationSetMemoryGuestAction extends BaseVirtualizationGuestAction { - - private Integer memory; - - /** - * Set the memory to be appied to the guest. This is KILOBYTES - * @param memoryIn New setting for guest memory. - */ - public void setMemory(Integer memoryIn) { - memory = memoryIn; - } - - /** - * Guest the guest memory. KILOBYTES - * @return The guest memory setting. - */ - public Integer getMemory() { - return memory; - } -} diff --git a/java/code/src/com/redhat/rhn/domain/action/virtualization/VirtualizationSetVcpusGuestAction.java b/java/code/src/com/redhat/rhn/domain/action/virtualization/VirtualizationSetVcpusGuestAction.java deleted file mode 100644 index 0a21d3546a1a..000000000000 --- a/java/code/src/com/redhat/rhn/domain/action/virtualization/VirtualizationSetVcpusGuestAction.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2009--2010 Red Hat, Inc. - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.redhat.rhn.domain.action.virtualization; - -/** - * Class representing TYPE_VIRTUALIZATION_SET_VCPUS - */ -public class VirtualizationSetVcpusGuestAction extends BaseVirtualizationGuestAction { - - private Integer vcpu; - - /** - * Set the vcpus to be appied to the guest. - * @param vcpuIn New setting for guest vcpus. - */ - public void setVcpu(Integer vcpuIn) { - vcpu = vcpuIn; - } - - /** - * Guest the guest vcpus. - * @return The guest vcpu setting. - */ - public Integer getVcpu() { - return vcpu; - } -} - diff --git a/java/code/src/com/redhat/rhn/domain/action/virtualization/VirtualizationShutdownGuestAction.java b/java/code/src/com/redhat/rhn/domain/action/virtualization/VirtualizationShutdownGuestAction.java deleted file mode 100644 index 293140622b95..000000000000 --- a/java/code/src/com/redhat/rhn/domain/action/virtualization/VirtualizationShutdownGuestAction.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2009--2010 Red Hat, Inc. - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.redhat.rhn.domain.action.virtualization; - -/** - * Class representing TYPE_VIRTUALIZATION_SHUTDOWN - */ -public class VirtualizationShutdownGuestAction extends BaseVirtualizationGuestAction { - - private boolean force = false; - - /** - * @return Returns whether to force off rather than cleanly shutting down. - */ - public boolean isForce() { - return force; - } - - /** - * @param forceIn whether to force off rather than cleanly shutting down. - */ - public void setForce(boolean forceIn) { - force = forceIn; - } -} diff --git a/java/code/src/com/redhat/rhn/domain/action/virtualization/VirtualizationStartGuestAction.java b/java/code/src/com/redhat/rhn/domain/action/virtualization/VirtualizationStartGuestAction.java deleted file mode 100644 index b43b57ae4b52..000000000000 --- a/java/code/src/com/redhat/rhn/domain/action/virtualization/VirtualizationStartGuestAction.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (c) 2009--2010 Red Hat, Inc. - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.redhat.rhn.domain.action.virtualization; - -/** - * Class representing TYPE_VIRTUALIZATION_SHUTDOWN - */ -public class VirtualizationStartGuestAction extends BaseVirtualizationGuestAction { - -} diff --git a/java/code/src/com/redhat/rhn/domain/action/virtualization/VirtualizationSuspendGuestAction.java b/java/code/src/com/redhat/rhn/domain/action/virtualization/VirtualizationSuspendGuestAction.java deleted file mode 100644 index a0b8bf27e91a..000000000000 --- a/java/code/src/com/redhat/rhn/domain/action/virtualization/VirtualizationSuspendGuestAction.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (c) 2009--2010 Red Hat, Inc. - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.redhat.rhn.domain.action.virtualization; - -/** - * Class representing TYPE_VIRTUALIZATION_SUSPEND - */ -public class VirtualizationSuspendGuestAction extends BaseVirtualizationGuestAction { - -} diff --git a/java/code/src/com/redhat/rhn/domain/action/virtualization/test/VirtualizationActionsTest.java b/java/code/src/com/redhat/rhn/domain/action/virtualization/test/VirtualizationActionsTest.java deleted file mode 100644 index e424bb7879eb..000000000000 --- a/java/code/src/com/redhat/rhn/domain/action/virtualization/test/VirtualizationActionsTest.java +++ /dev/null @@ -1,257 +0,0 @@ -/* - * Copyright (c) 2009--2010 Red Hat, Inc. - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.redhat.rhn.domain.action.virtualization.test; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import com.redhat.rhn.domain.action.Action; -import com.redhat.rhn.domain.action.ActionFactory; -import com.redhat.rhn.domain.action.ActionType; -import com.redhat.rhn.domain.action.test.ActionFactoryTest; -import com.redhat.rhn.domain.action.virtualization.BaseVirtualizationGuestAction; -import com.redhat.rhn.domain.action.virtualization.VirtualizationCreateGuestAction; -import com.redhat.rhn.domain.action.virtualization.VirtualizationDeleteGuestAction; -import com.redhat.rhn.domain.action.virtualization.VirtualizationGuestPackageInstall; -import com.redhat.rhn.domain.action.virtualization.VirtualizationHostPackageInstall; -import com.redhat.rhn.domain.action.virtualization.VirtualizationPoolCreateAction; -import com.redhat.rhn.domain.action.virtualization.VirtualizationPoolCreateActionSource; -import com.redhat.rhn.domain.action.virtualization.VirtualizationRebootGuestAction; -import com.redhat.rhn.domain.action.virtualization.VirtualizationResumeGuestAction; -import com.redhat.rhn.domain.action.virtualization.VirtualizationSetMemoryGuestAction; -import com.redhat.rhn.domain.action.virtualization.VirtualizationSetVcpusGuestAction; -import com.redhat.rhn.domain.action.virtualization.VirtualizationShutdownGuestAction; -import com.redhat.rhn.domain.action.virtualization.VirtualizationStartGuestAction; -import com.redhat.rhn.domain.action.virtualization.VirtualizationSuspendGuestAction; -import com.redhat.rhn.frontend.context.Context; -import com.redhat.rhn.testing.BaseTestCaseWithUser; - -import com.suse.manager.virtualization.GuestCreateDetails; -import com.suse.manager.virtualization.PoolSourceAuthentication; -import com.suse.manager.virtualization.PoolSourceDevice; -import com.suse.manager.webui.controllers.virtualization.gson.VirtualGuestsUpdateActionJson; - -import org.junit.jupiter.api.Test; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map.Entry; -import java.util.TimeZone; -import java.util.stream.Collectors; - -public class VirtualizationActionsTest extends BaseTestCaseWithUser { - - @Test - public void testPackageInstall() throws Exception { - Action a1 = ActionFactoryTest.createAction(user, - ActionFactory.TYPE_VIRTUALIZATION_GUEST_PACKAGE_INSTALL); - - flushAndEvict(a1); - Long id = a1.getId(); - Action a = ActionFactory.lookupById(id); - - assertNotNull(a); - assertTrue(a instanceof VirtualizationGuestPackageInstall); - - Action a2 = ActionFactoryTest.createAction(user, - ActionFactory.TYPE_VIRTUALIZATION_HOST_PACKAGE_INSTALL); - flushAndEvict(a2); - id = a2.getId(); - - a = ActionFactory.lookupById(id); - assertNotNull(a); - assertTrue(a instanceof VirtualizationHostPackageInstall); - - } - - @Test - public void testDomainLifecycleActions() throws Exception { - HashMap> types = new HashMap<>(); - types.put(ActionFactory.TYPE_VIRTUALIZATION_DELETE, VirtualizationDeleteGuestAction.class); - types.put(ActionFactory.TYPE_VIRTUALIZATION_REBOOT, VirtualizationRebootGuestAction.class); - types.put(ActionFactory.TYPE_VIRTUALIZATION_RESUME, VirtualizationResumeGuestAction.class); - types.put(ActionFactory.TYPE_VIRTUALIZATION_SHUTDOWN, VirtualizationShutdownGuestAction.class); - types.put(ActionFactory.TYPE_VIRTUALIZATION_START, VirtualizationStartGuestAction.class); - types.put(ActionFactory.TYPE_VIRTUALIZATION_SUSPEND, VirtualizationSuspendGuestAction.class); - - for (Entry> entry : types.entrySet()) { - Action a = ActionFactoryTest.createAction(user, entry.getKey()); - flushAndEvict(a); - - Action a1 = ActionFactory.lookupById(a.getId()); - assertNotNull(a1); - - assertTrue(entry.getValue().isInstance(a1)); - } - } - - @Test - public void testDomainForceoff() throws Exception { - Action a = ActionFactoryTest.createAction(user, ActionFactory.TYPE_VIRTUALIZATION_SHUTDOWN); - VirtualizationShutdownGuestAction va = (VirtualizationShutdownGuestAction)a; - va.setForce(true); - flushAndEvict(va); - - Action a1 = ActionFactory.lookupById(a.getId()); - assertNotNull(a1); - - assertTrue(a1 instanceof VirtualizationShutdownGuestAction); - VirtualizationShutdownGuestAction rebootAction = (VirtualizationShutdownGuestAction)a1; - assertTrue(rebootAction.isForce()); - } - - @Test - public void testDomainReset() throws Exception { - Action a = ActionFactoryTest.createAction(user, ActionFactory.TYPE_VIRTUALIZATION_REBOOT); - VirtualizationRebootGuestAction va = (VirtualizationRebootGuestAction)a; - va.setForce(true); - flushAndEvict(va); - - Action a1 = ActionFactory.lookupById(a.getId()); - assertNotNull(a1); - - assertTrue(a1 instanceof VirtualizationRebootGuestAction); - VirtualizationRebootGuestAction rebootAction = (VirtualizationRebootGuestAction)a1; - assertTrue(rebootAction.isForce()); - } - - @Test - public void testSetMemory() throws Exception { - Action a = ActionFactoryTest.createAction(user, ActionFactory.TYPE_VIRTUALIZATION_SET_MEMORY); - flushAndEvict(a); - - Action a1 = ActionFactory.lookupById(a.getId()); - assertNotNull(a1); - - VirtualizationSetMemoryGuestAction va = (VirtualizationSetMemoryGuestAction)a1; - assertEquals(Integer.valueOf(1234), va.getMemory()); - } - - @Test - public void testSetVcpus() throws Exception { - Action a = ActionFactoryTest.createAction(user, ActionFactory.TYPE_VIRTUALIZATION_SET_VCPUS); - flushAndEvict(a); - - Action a1 = ActionFactory.lookupById(a.getId()); - assertNotNull(a1); - - VirtualizationSetVcpusGuestAction va = (VirtualizationSetVcpusGuestAction)a1; - assertEquals(Integer.valueOf(12), va.getVcpu()); - } - - /** - * Test that virtualization creation actions are properly persisted and looked up - * - * @throws Exception something bad happened - */ - @Test - public void testCreateLookup() throws Exception { - Context.getCurrentContext().setTimezone(TimeZone.getDefault()); - - VirtualizationCreateGuestAction a1 = (VirtualizationCreateGuestAction)ActionFactoryTest - .createAction(user, ActionFactory.TYPE_VIRTUALIZATION_CREATE); - a1.setDetails(new GuestCreateDetails()); - a1.getDetails().setType("kvm"); - a1.getDetails().setName("guest0"); - a1.getDetails().setArch("x86_64"); - a1.getDetails().setMemory(1024L); - a1.getDetails().setVcpu(2L); - a1.getDetails().setOsType("hvm"); - a1.getDetails().setKernelOptions("kernelopts"); - a1.getDetails().setCobblerSystem("cobbler:system:id"); - a1.getDetails().setKickstartHost("https://cobbler.host.local"); - - List disks = new ArrayList<>(); - VirtualGuestsUpdateActionJson.DiskData disk0 = a1.getDetails().new DiskData(); - disk0.setTemplate("templateimage.qcow2"); - disk0.setBus("virtio"); - disk0.setPool("default"); - disks.add(disk0); - a1.getDetails().setDisks(disks); - - List nets = Arrays.asList("net0", "net1"); - a1.getDetails().setInterfaces( - nets.stream().map(net -> { - VirtualGuestsUpdateActionJson.InterfaceData detail = a1.getDetails().new InterfaceData(); - detail.setSource(net); - return detail; - }).collect(Collectors.toList())); - - flushAndEvict(a1); - - Action a = ActionFactory.lookupById(a1.getId()); - - assertNotNull(a); - assertTrue(a instanceof VirtualizationCreateGuestAction); - VirtualizationCreateGuestAction actual = (VirtualizationCreateGuestAction)a; - assertEquals("kvm", actual.getDetails().getType()); - assertEquals("guest0", actual.getDetails().getName()); - assertEquals("x86_64", actual.getDetails().getArch()); - assertEquals(Long.valueOf(1024), actual.getDetails().getMemory()); - assertEquals(Long.valueOf(2), actual.getDetails().getVcpu()); - assertEquals("hvm", actual.getDetails().getOsType()); - assertEquals("kernelopts", actual.getDetails().getKernelOptions()); - assertEquals("cobbler:system:id", actual.getDetails().getCobblerSystem()); - assertEquals("https://cobbler.host.local", actual.getDetails().getKickstartHost()); - - assertEquals(1, actual.getDetails().getDisks().size()); - assertEquals("templateimage.qcow2", actual.getDetails().getDisks().get(0).getTemplate()); - assertEquals("virtio", actual.getDetails().getDisks().get(0).getBus()); - assertEquals("default", actual.getDetails().getDisks().get(0).getPool()); - assertEquals(2, actual.getDetails().getInterfaces().size()); - assertEquals("net0", actual.getDetails().getInterfaces().get(0).getSource()); - assertEquals("net1", actual.getDetails().getInterfaces().get(1).getSource()); - } - - @Test - public void testPoolCreate() throws Exception { - VirtualizationPoolCreateAction a1 = (VirtualizationPoolCreateAction)ActionFactoryTest - .createAction(user, ActionFactory.TYPE_VIRTUALIZATION_POOL_CREATE); - a1.setName("pool0"); - a1.setType("iscsi"); - a1.setTarget("/dev/disk/by-path"); - VirtualizationPoolCreateActionSource src = new VirtualizationPoolCreateActionSource(); - src.setAuth(new PoolSourceAuthentication("myuser", "mysecret")); - src.setHosts(Arrays.asList("iscsi.example.com")); - src.setDevices(Arrays.asList(new PoolSourceDevice("iqn.2013-06.com.example:iscsi-pool"))); - a1.setSource(src); - a1.setMode("0744"); - a1.setOwner("107"); - a1.setGroup("108"); - a1.setSeclabel("virt_image_t"); - - flushAndEvict(a1); - - Action a = ActionFactory.lookupById(a1.getId()); - - assertNotNull(a); - assertTrue(a instanceof VirtualizationPoolCreateAction); - VirtualizationPoolCreateAction actual = (VirtualizationPoolCreateAction)a; - assertEquals("pool0", actual.getName()); - assertEquals("iscsi", actual.getType()); - assertEquals("/dev/disk/by-path", actual.getTarget()); - assertEquals("0744", actual.getMode()); - assertEquals("107", actual.getOwner()); - assertEquals("108", actual.getGroup()); - assertEquals("virt_image_t", actual.getSeclabel()); - assertEquals("myuser", actual.getSource().getAuth().getUsername()); - assertEquals("mysecret", actual.getSource().getAuth().getPassword()); - assertEquals("iscsi.example.com", actual.getSource().getHosts().get(0)); - assertEquals("iqn.2013-06.com.example:iscsi-pool", actual.getSource().getDevices().get(0).getPath()); - } -} diff --git a/java/code/src/com/redhat/rhn/domain/action/virtualization/test/VirtualizationPoolCreateActionSourceTest.java b/java/code/src/com/redhat/rhn/domain/action/virtualization/test/VirtualizationPoolCreateActionSourceTest.java deleted file mode 100644 index 7721eca2de46..000000000000 --- a/java/code/src/com/redhat/rhn/domain/action/virtualization/test/VirtualizationPoolCreateActionSourceTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2020--2021 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.redhat.rhn.domain.action.virtualization.test; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -import com.redhat.rhn.domain.action.virtualization.VirtualizationPoolCreateActionSource; - -import com.suse.manager.virtualization.PoolSourceDevice; - -import org.junit.jupiter.api.Test; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Optional; - -public class VirtualizationPoolCreateActionSourceTest { - - @Test - public void testNfsDir() { - VirtualizationPoolCreateActionSource src = new VirtualizationPoolCreateActionSource(); - src.setDir("/var/lib/libvirt/images"); - src.setFormat("nfs"); - src.setHosts(Arrays.asList("localhost")); - - String serialized = src.toString(); - assertEquals( - "{\"dir\":\"/var/lib/libvirt/images\"," + - "\"hosts\":[\"localhost\"]," + - "\"format\":\"nfs\"" + - "}", serialized); - - VirtualizationPoolCreateActionSource src2 = VirtualizationPoolCreateActionSource.parse(serialized); - assertEquals(src.getDir(), src2.getDir()); - assertEquals(src.getFormat(), src2.getFormat()); - assertEquals("localhost", src2.getHosts().get(0)); - } - - @Test - public void testDevice() { - VirtualizationPoolCreateActionSource src = new VirtualizationPoolCreateActionSource(); - List devices = new ArrayList<>(); - devices.add(new PoolSourceDevice("/dev/mapper/dev0")); - devices.add(new PoolSourceDevice("/dev/mapper/dev1", Optional.of(true))); - src.setDevices(devices); - - String serialized = src.toString(); - assertEquals("{\"devices\":[" + - "{\"path\":\"/dev/mapper/dev0\"}," + - "{\"path\":\"/dev/mapper/dev1\",\"separator\":true}]}", serialized); - } -} diff --git a/java/code/src/com/redhat/rhn/domain/entitlement/test/BaseEntitlementTestCase.java b/java/code/src/com/redhat/rhn/domain/entitlement/test/BaseEntitlementTestCase.java index 64b3cb69a3ea..61e1762f4327 100644 --- a/java/code/src/com/redhat/rhn/domain/entitlement/test/BaseEntitlementTestCase.java +++ b/java/code/src/com/redhat/rhn/domain/entitlement/test/BaseEntitlementTestCase.java @@ -29,11 +29,9 @@ import com.redhat.rhn.testing.BaseTestCaseWithUser; import com.redhat.rhn.testing.ServerTestUtils; -import com.suse.manager.virtualization.VirtManagerSalt; import com.suse.manager.webui.services.iface.MonitoringManager; import com.suse.manager.webui.services.iface.SaltApi; import com.suse.manager.webui.services.iface.SystemQuery; -import com.suse.manager.webui.services.iface.VirtManager; import com.suse.manager.webui.services.test.TestSaltApi; import com.suse.manager.webui.services.test.TestSystemQuery; @@ -50,11 +48,10 @@ public abstract class BaseEntitlementTestCase extends BaseTestCaseWithUser { private final SystemQuery systemQuery = new TestSystemQuery(); private final SaltApi saltApi = new TestSaltApi(); private final ServerGroupManager serverGroupManager = new ServerGroupManager(saltApi); - private final VirtManager virtManager = new VirtManagerSalt(saltApi); private final MonitoringManager monitoringManager = new FormulaMonitoringManager(saltApi); private final SystemEntitlementManager systemEntitlementManager = new SystemEntitlementManager( - new SystemUnentitler(virtManager, monitoringManager, serverGroupManager), - new SystemEntitler(saltApi, virtManager, monitoringManager, serverGroupManager) + new SystemUnentitler(monitoringManager, serverGroupManager), + new SystemEntitler(saltApi, monitoringManager, serverGroupManager) ); @Override diff --git a/java/code/src/com/redhat/rhn/domain/entitlement/test/ContainerBuildHostEntitlementTest.java b/java/code/src/com/redhat/rhn/domain/entitlement/test/ContainerBuildHostEntitlementTest.java index 25afec026a8a..040bb3c1a291 100644 --- a/java/code/src/com/redhat/rhn/domain/entitlement/test/ContainerBuildHostEntitlementTest.java +++ b/java/code/src/com/redhat/rhn/domain/entitlement/test/ContainerBuildHostEntitlementTest.java @@ -30,10 +30,8 @@ import com.redhat.rhn.testing.ServerTestUtils; import com.suse.manager.reactor.utils.ValueMap; -import com.suse.manager.virtualization.VirtManagerSalt; import com.suse.manager.webui.services.iface.MonitoringManager; import com.suse.manager.webui.services.iface.SaltApi; -import com.suse.manager.webui.services.iface.VirtManager; import com.suse.manager.webui.services.test.TestSaltApi; import org.junit.jupiter.api.Test; @@ -45,11 +43,10 @@ public class ContainerBuildHostEntitlementTest extends BaseEntitlementTestCase { private final SaltApi saltApi = new TestSaltApi(); private final ServerGroupManager serverGroupManager = new ServerGroupManager(saltApi); - private final VirtManager virtManager = new VirtManagerSalt(saltApi); private final MonitoringManager monitoringManager = new FormulaMonitoringManager(saltApi); private final SystemEntitlementManager systemEntitlementManager = new SystemEntitlementManager( - new SystemUnentitler(virtManager, monitoringManager, serverGroupManager), - new SystemEntitler(saltApi, virtManager, monitoringManager, serverGroupManager) + new SystemUnentitler(monitoringManager, serverGroupManager), + new SystemEntitler(saltApi, monitoringManager, serverGroupManager) ); @Override diff --git a/java/code/src/com/redhat/rhn/domain/entitlement/test/OSImageBuildHostEntitlementTest.java b/java/code/src/com/redhat/rhn/domain/entitlement/test/OSImageBuildHostEntitlementTest.java index 9fc76729ad15..edd82898f9d2 100644 --- a/java/code/src/com/redhat/rhn/domain/entitlement/test/OSImageBuildHostEntitlementTest.java +++ b/java/code/src/com/redhat/rhn/domain/entitlement/test/OSImageBuildHostEntitlementTest.java @@ -30,11 +30,9 @@ import com.redhat.rhn.manager.system.entitling.SystemUnentitler; import com.redhat.rhn.testing.ServerTestUtils; -import com.suse.manager.virtualization.VirtManagerSalt; import com.suse.manager.webui.services.iface.MonitoringManager; import com.suse.manager.webui.services.iface.SaltApi; import com.suse.manager.webui.services.iface.SystemQuery; -import com.suse.manager.webui.services.iface.VirtManager; import com.suse.manager.webui.services.test.TestSaltApi; import com.suse.manager.webui.services.test.TestSystemQuery; @@ -46,11 +44,10 @@ public class OSImageBuildHostEntitlementTest extends BaseEntitlementTestCase { private final SystemQuery systemQuery = new TestSystemQuery(); private final SaltApi saltApi = new TestSaltApi(); private final ServerGroupManager serverGroupManager = new ServerGroupManager(saltApi); - private final VirtManager virtManager = new VirtManagerSalt(saltApi); private final MonitoringManager monitoringManager = new FormulaMonitoringManager(saltApi); private final SystemEntitlementManager systemEntitlementManager = new SystemEntitlementManager( - new SystemUnentitler(virtManager, monitoringManager, serverGroupManager), - new SystemEntitler(saltApi, virtManager, monitoringManager, serverGroupManager) + new SystemUnentitler(monitoringManager, serverGroupManager), + new SystemEntitler(saltApi, monitoringManager, serverGroupManager) ); @Override diff --git a/java/code/src/com/redhat/rhn/domain/entitlement/test/PeripheralServerEntitlementTest.java b/java/code/src/com/redhat/rhn/domain/entitlement/test/PeripheralServerEntitlementTest.java index c8d2c59d46ad..edba36a8dfba 100644 --- a/java/code/src/com/redhat/rhn/domain/entitlement/test/PeripheralServerEntitlementTest.java +++ b/java/code/src/com/redhat/rhn/domain/entitlement/test/PeripheralServerEntitlementTest.java @@ -31,11 +31,9 @@ import com.redhat.rhn.testing.ServerTestUtils; import com.redhat.rhn.testing.TestUtils; -import com.suse.manager.virtualization.VirtManagerSalt; import com.suse.manager.webui.services.iface.MonitoringManager; import com.suse.manager.webui.services.iface.SaltApi; import com.suse.manager.webui.services.iface.SystemQuery; -import com.suse.manager.webui.services.iface.VirtManager; import com.suse.manager.webui.services.test.TestSaltApi; import com.suse.manager.webui.services.test.TestSystemQuery; @@ -48,11 +46,10 @@ public class PeripheralServerEntitlementTest extends BaseEntitlementTestCase { private final SystemQuery systemQuery = new TestSystemQuery(); private final SaltApi saltApi = new TestSaltApi(); private final ServerGroupManager serverGroupManager = new ServerGroupManager(saltApi); - private final VirtManager virtManager = new VirtManagerSalt(saltApi); private final MonitoringManager monitoringManager = new FormulaMonitoringManager(saltApi); private final SystemEntitlementManager systemEntitlementManager = new SystemEntitlementManager( - new SystemUnentitler(virtManager, monitoringManager, serverGroupManager), - new SystemEntitler(saltApi, virtManager, monitoringManager, serverGroupManager) + new SystemUnentitler(monitoringManager, serverGroupManager), + new SystemEntitler(saltApi, monitoringManager, serverGroupManager) ); @Override diff --git a/java/code/src/com/redhat/rhn/domain/entitlement/test/VirtualizationEntitlementTest.java b/java/code/src/com/redhat/rhn/domain/entitlement/test/VirtualizationEntitlementTest.java index 115bc3f4d548..db1b3817a276 100644 --- a/java/code/src/com/redhat/rhn/domain/entitlement/test/VirtualizationEntitlementTest.java +++ b/java/code/src/com/redhat/rhn/domain/entitlement/test/VirtualizationEntitlementTest.java @@ -30,11 +30,9 @@ import com.redhat.rhn.testing.ServerTestUtils; import com.suse.manager.reactor.utils.ValueMap; -import com.suse.manager.virtualization.VirtManagerSalt; import com.suse.manager.webui.services.iface.MonitoringManager; import com.suse.manager.webui.services.iface.SaltApi; import com.suse.manager.webui.services.iface.SystemQuery; -import com.suse.manager.webui.services.iface.VirtManager; import com.suse.manager.webui.services.test.TestSaltApi; import com.suse.manager.webui.services.test.TestSystemQuery; @@ -48,11 +46,10 @@ public class VirtualizationEntitlementTest extends BaseEntitlementTestCase { private final SystemQuery systemQuery = new TestSystemQuery(); private final SaltApi saltApi = new TestSaltApi(); private final ServerGroupManager serverGroupManager = new ServerGroupManager(saltApi); - private final VirtManager virtManager = new VirtManagerSalt(saltApi); private final MonitoringManager monitoringManager = new FormulaMonitoringManager(saltApi); private final SystemEntitlementManager systemEntitlementManager = new SystemEntitlementManager( - new SystemUnentitler(virtManager, monitoringManager, serverGroupManager), - new SystemEntitler(saltApi, virtManager, monitoringManager, serverGroupManager) + new SystemUnentitler(monitoringManager, serverGroupManager), + new SystemEntitler(saltApi, monitoringManager, serverGroupManager) ); @Override diff --git a/java/code/src/com/redhat/rhn/domain/image/test/ImageInfoFactoryTest.java b/java/code/src/com/redhat/rhn/domain/image/test/ImageInfoFactoryTest.java index ee28ee6bfe6c..783f63e22fb8 100644 --- a/java/code/src/com/redhat/rhn/domain/image/test/ImageInfoFactoryTest.java +++ b/java/code/src/com/redhat/rhn/domain/image/test/ImageInfoFactoryTest.java @@ -66,11 +66,9 @@ import com.redhat.rhn.testing.TestUtils; import com.redhat.rhn.testing.UserTestUtils; -import com.suse.manager.virtualization.VirtManagerSalt; import com.suse.manager.webui.services.iface.MonitoringManager; import com.suse.manager.webui.services.iface.SaltApi; import com.suse.manager.webui.services.iface.SystemQuery; -import com.suse.manager.webui.services.iface.VirtManager; import com.suse.manager.webui.services.test.TestSaltApi; import com.suse.manager.webui.services.test.TestSystemQuery; import com.suse.manager.webui.utils.salt.custom.ImageChecksum; @@ -108,11 +106,10 @@ public class ImageInfoFactoryTest extends BaseTestCaseWithUser { private final SystemQuery systemQuery = new TestSystemQuery(); private final SaltApi saltApi = new TestSaltApi(); private final ServerGroupManager serverGroupManager = new ServerGroupManager(saltApi); - private final VirtManager virtManager = new VirtManagerSalt(saltApi); private final MonitoringManager monitoringManager = new FormulaMonitoringManager(saltApi); private final SystemEntitlementManager systemEntitlementManager = new SystemEntitlementManager( - new SystemUnentitler(virtManager, monitoringManager, serverGroupManager), - new SystemEntitler(saltApi, virtManager, monitoringManager, serverGroupManager) + new SystemUnentitler(monitoringManager, serverGroupManager), + new SystemEntitler(saltApi, monitoringManager, serverGroupManager) ); @Override diff --git a/java/code/src/com/redhat/rhn/domain/server/test/ServerFactoryTest.java b/java/code/src/com/redhat/rhn/domain/server/test/ServerFactoryTest.java index beaf3544d653..980044fa75f1 100644 --- a/java/code/src/com/redhat/rhn/domain/server/test/ServerFactoryTest.java +++ b/java/code/src/com/redhat/rhn/domain/server/test/ServerFactoryTest.java @@ -107,12 +107,10 @@ import com.suse.manager.model.maintenance.MaintenanceSchedule; import com.suse.manager.utils.SaltKeyUtils; import com.suse.manager.utils.SaltUtils; -import com.suse.manager.virtualization.VirtManagerSalt; import com.suse.manager.webui.services.SaltServerActionService; import com.suse.manager.webui.services.iface.MonitoringManager; import com.suse.manager.webui.services.iface.SaltApi; import com.suse.manager.webui.services.iface.SystemQuery; -import com.suse.manager.webui.services.iface.VirtManager; import com.suse.manager.webui.services.test.TestSaltApi; import com.suse.manager.webui.services.test.TestSystemQuery; import com.suse.salt.netapi.calls.LocalCall; @@ -155,11 +153,10 @@ public class ServerFactoryTest extends BaseTestCaseWithUser { SALT_UTILS, SALT_KEY_UTILS ); - private static final VirtManager VIRT_MANAGER = new VirtManagerSalt(SALT_API); private static final MonitoringManager MONITORING_MANAGER = new FormulaMonitoringManager(SALT_API); private static final SystemEntitlementManager SYSTEM_ENTITLEMENT_MANAGER = new SystemEntitlementManager( - new SystemUnentitler(VIRT_MANAGER, MONITORING_MANAGER, SERVER_GROUP_MANAGER), - new SystemEntitler(SALT_API, VIRT_MANAGER, MONITORING_MANAGER, SERVER_GROUP_MANAGER) + new SystemUnentitler(MONITORING_MANAGER, SERVER_GROUP_MANAGER), + new SystemEntitler(SALT_API, MONITORING_MANAGER, SERVER_GROUP_MANAGER) ); @Override diff --git a/java/code/src/com/redhat/rhn/domain/server/test/ServerTest.java b/java/code/src/com/redhat/rhn/domain/server/test/ServerTest.java index 6bcacfbc8c5e..0326f6223b8b 100644 --- a/java/code/src/com/redhat/rhn/domain/server/test/ServerTest.java +++ b/java/code/src/com/redhat/rhn/domain/server/test/ServerTest.java @@ -50,10 +50,8 @@ import com.redhat.rhn.testing.TestUtils; import com.redhat.rhn.testing.UserTestUtils; -import com.suse.manager.virtualization.VirtManagerSalt; import com.suse.manager.webui.services.iface.MonitoringManager; import com.suse.manager.webui.services.iface.SaltApi; -import com.suse.manager.webui.services.iface.VirtManager; import com.suse.manager.webui.services.test.TestSaltApi; import org.junit.jupiter.api.Test; @@ -71,13 +69,11 @@ public class ServerTest extends BaseTestCaseWithUser { private final SaltApi saltApi = new TestSaltApi(); private final ServerGroupManager serverGroupManager = new ServerGroupManager(saltApi); - private final VirtManager virtManager = new VirtManagerSalt(saltApi); private final MonitoringManager monitoringManager = new FormulaMonitoringManager(saltApi); private final SystemUnentitler systemUnentitler = new SystemUnentitler( - virtManager, monitoringManager, serverGroupManager); + monitoringManager, serverGroupManager); private final SystemEntitlementManager systemEntitlementManager = new SystemEntitlementManager( - systemUnentitler, - new SystemEntitler(saltApi, virtManager, monitoringManager, serverGroupManager) + systemUnentitler, new SystemEntitler(saltApi, monitoringManager, serverGroupManager) ); @Test diff --git a/java/code/src/com/redhat/rhn/domain/server/test/VirtualInstanceFactoryTest.java b/java/code/src/com/redhat/rhn/domain/server/test/VirtualInstanceFactoryTest.java index 0a495363ae87..f04f0c1b0746 100644 --- a/java/code/src/com/redhat/rhn/domain/server/test/VirtualInstanceFactoryTest.java +++ b/java/code/src/com/redhat/rhn/domain/server/test/VirtualInstanceFactoryTest.java @@ -35,10 +35,8 @@ import com.redhat.rhn.testing.TestUtils; import com.redhat.rhn.testing.UserTestUtils; -import com.suse.manager.virtualization.test.TestVirtManager; import com.suse.manager.webui.services.iface.MonitoringManager; import com.suse.manager.webui.services.iface.SaltApi; -import com.suse.manager.webui.services.iface.VirtManager; import com.suse.manager.webui.services.test.TestSaltApi; import org.apache.commons.collections.CollectionUtils; @@ -70,11 +68,10 @@ public void setUp() { builder = new GuestBuilder(user); SaltApi saltApi = new TestSaltApi(); ServerGroupManager serverGroupManager = new ServerGroupManager(saltApi); - VirtManager virtManager = new TestVirtManager(); MonitoringManager monitoringManager = new FormulaMonitoringManager(saltApi); systemEntitlementManager = new SystemEntitlementManager( - new SystemUnentitler(virtManager, monitoringManager, serverGroupManager), - new SystemEntitler(saltApi, virtManager, monitoringManager, serverGroupManager) + new SystemUnentitler(monitoringManager, serverGroupManager), + new SystemEntitler(saltApi, monitoringManager, serverGroupManager) ); } diff --git a/java/code/src/com/redhat/rhn/frontend/action/systems/entitlements/test/SystemEntitlementsSetupActionTest.java b/java/code/src/com/redhat/rhn/frontend/action/systems/entitlements/test/SystemEntitlementsSetupActionTest.java index c1f66dca045e..02d16ba22f56 100644 --- a/java/code/src/com/redhat/rhn/frontend/action/systems/entitlements/test/SystemEntitlementsSetupActionTest.java +++ b/java/code/src/com/redhat/rhn/frontend/action/systems/entitlements/test/SystemEntitlementsSetupActionTest.java @@ -46,9 +46,7 @@ import com.redhat.rhn.testing.ServerTestUtils; import com.redhat.rhn.testing.UserTestUtils; -import com.suse.manager.virtualization.VirtManagerSalt; import com.suse.manager.webui.services.iface.MonitoringManager; -import com.suse.manager.webui.services.iface.VirtManager; import com.suse.manager.webui.services.impl.SaltSSHService; import com.suse.manager.webui.services.impl.SaltService; import com.suse.salt.netapi.datatypes.target.MinionList; @@ -81,11 +79,10 @@ public void setUp() throws Exception { context.setImposteriser(ByteBuddyClassImposteriser.INSTANCE); saltServiceMock = context.mock(SaltService.class); ServerGroupManager serverGroupManager = new ServerGroupManager(saltServiceMock); - VirtManager virtManager = new VirtManagerSalt(saltServiceMock); MonitoringManager monitoringManager = new FormulaMonitoringManager(saltServiceMock); systemEntitlementManager = new SystemEntitlementManager( - new SystemUnentitler(virtManager, monitoringManager, serverGroupManager), - new SystemEntitler(saltServiceMock, virtManager, monitoringManager, serverGroupManager) + new SystemUnentitler(monitoringManager, serverGroupManager), + new SystemEntitler(saltServiceMock, monitoringManager, serverGroupManager) ); context.checking(new Expectations() {{ allowing(saltServiceMock).refreshPillar(with(any(MinionList.class))); diff --git a/java/code/src/com/redhat/rhn/frontend/action/systems/entitlements/test/SystemEntitlementsSubmitActionTest.java b/java/code/src/com/redhat/rhn/frontend/action/systems/entitlements/test/SystemEntitlementsSubmitActionTest.java index fdc0b8c84004..fdb4f9b0fb06 100644 --- a/java/code/src/com/redhat/rhn/frontend/action/systems/entitlements/test/SystemEntitlementsSubmitActionTest.java +++ b/java/code/src/com/redhat/rhn/frontend/action/systems/entitlements/test/SystemEntitlementsSubmitActionTest.java @@ -39,11 +39,9 @@ import com.redhat.rhn.testing.RhnPostMockStrutsTestCase; import com.redhat.rhn.testing.ServerTestUtils; -import com.suse.manager.virtualization.VirtManagerSalt; import com.suse.manager.webui.services.iface.MonitoringManager; import com.suse.manager.webui.services.iface.SaltApi; import com.suse.manager.webui.services.iface.SystemQuery; -import com.suse.manager.webui.services.iface.VirtManager; import com.suse.manager.webui.services.test.TestSaltApi; import com.suse.manager.webui.services.test.TestSystemQuery; @@ -64,11 +62,10 @@ public class SystemEntitlementsSubmitActionTest extends RhnPostMockStrutsTestCas private final SystemQuery systemQuery = new TestSystemQuery(); private final SaltApi saltApi = new TestSaltApi(); private final ServerGroupManager serverGroupManager = new ServerGroupManager(saltApi); - private final VirtManager virtManager = new VirtManagerSalt(saltApi); private final MonitoringManager monitoringManager = new FormulaMonitoringManager(saltApi); private final SystemEntitlementManager systemEntitlementManager = new SystemEntitlementManager( - new SystemUnentitler(virtManager, monitoringManager, serverGroupManager), - new SystemEntitler(saltApi, virtManager, monitoringManager, serverGroupManager) + new SystemUnentitler(monitoringManager, serverGroupManager), + new SystemEntitler(saltApi, monitoringManager, serverGroupManager) ); diff --git a/java/code/src/com/redhat/rhn/frontend/action/systems/images/ScheduleImageDeploymentAction.java b/java/code/src/com/redhat/rhn/frontend/action/systems/images/ScheduleImageDeploymentAction.java deleted file mode 100644 index a4531460e0cc..000000000000 --- a/java/code/src/com/redhat/rhn/frontend/action/systems/images/ScheduleImageDeploymentAction.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (c) 2012 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.redhat.rhn.frontend.action.systems.images; - -import com.redhat.rhn.domain.action.Action; -import com.redhat.rhn.domain.image.ProxyConfig; -import com.redhat.rhn.domain.server.Server; -import com.redhat.rhn.domain.user.User; -import com.redhat.rhn.frontend.struts.RequestContext; -import com.redhat.rhn.frontend.struts.RhnAction; -import com.redhat.rhn.frontend.struts.RhnHelper; -import com.redhat.rhn.manager.action.ActionManager; -import com.redhat.rhn.manager.system.SystemManager; - -import org.apache.commons.lang3.StringUtils; -import org.apache.struts.action.ActionForm; -import org.apache.struts.action.ActionForward; -import org.apache.struts.action.ActionMapping; -import org.apache.struts.action.DynaActionForm; - -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -/** - * This action will schedule image deployment for an image given by URL. - */ -public class ScheduleImageDeploymentAction extends RhnAction { - - private static final String SUCCESS_KEY = "images.message.success.scheduled"; - - /** {@inheritDoc} */ - @Override - public ActionForward execute(ActionMapping actionMapping, - ActionForm actionForm, HttpServletRequest request, - HttpServletResponse response) { - - // Get the current user - RequestContext ctx = new RequestContext(request); - User user = ctx.getCurrentUser(); - - // Put the server object to the request (for system header) - Long sid = Long.valueOf(request.getParameter(RequestContext.SID)); - Server server = SystemManager.lookupByIdAndUser(sid, user); - request.setAttribute("system", server); - - ActionForward forward; - if (request.getParameter(RequestContext.DISPATCH) != null) { - // Read the form parameters - DynaActionForm form = (DynaActionForm) actionForm; - Long vcpus = (Long) form.get("vcpus"); - Long memkb = (Long) form.get("mem_mb") * 1024; - String bridge = form.getString("bridge"); - String proxyServer = form.getString("proxy_server"); - String proxyUser = form.getString("proxy_user"); - String proxyPass = form.getString("proxy_pass"); - - // Set up the proxy configuration - ProxyConfig proxy = null; - if (StringUtils.isNotEmpty(proxyServer)) { - proxy = new ProxyConfig(proxyServer, proxyUser, proxyPass); - } - - // Put defaults for deployment parameters - if (vcpus <= 0) { - vcpus = 1L; - } - if (memkb <= 0) { - memkb = 524288L; - } - - // Create the action and store it - String imageUrl = form.getString("image_url"); - - if (StringUtils.isEmpty(imageUrl)) { - createErrorMessage(request, "images.jsp.error.noimage", null); - forward = actionMapping.findForward(RhnHelper.DEFAULT_FORWARD); - } - else { - Action action = ActionManager.createDeployImageAction(user, imageUrl, - vcpus, memkb, bridge, proxy); - ActionManager.addServerToAction(sid, action); - ActionManager.storeAction(action); - createSuccessMessage(request, SUCCESS_KEY, imageUrl); - - // Forward the sid as a request parameter - Map forwardParams = makeParamMap(request); - forwardParams.put(RequestContext.SID, sid); - forward = getStrutsDelegate().forwardParams( - actionMapping.findForward("submitted"), forwardParams); - } - } - else { - forward = actionMapping.findForward(RhnHelper.DEFAULT_FORWARD); - } - return forward; - } -} diff --git a/java/code/src/com/redhat/rhn/frontend/action/systems/sdc/test/SystemDetailsEditActionTest.java b/java/code/src/com/redhat/rhn/frontend/action/systems/sdc/test/SystemDetailsEditActionTest.java index 6119ec3083ff..1d6ef2c9a6f2 100644 --- a/java/code/src/com/redhat/rhn/frontend/action/systems/sdc/test/SystemDetailsEditActionTest.java +++ b/java/code/src/com/redhat/rhn/frontend/action/systems/sdc/test/SystemDetailsEditActionTest.java @@ -39,11 +39,9 @@ import com.redhat.rhn.testing.TestUtils; import com.redhat.rhn.testing.UserTestUtils; -import com.suse.manager.virtualization.VirtManagerSalt; import com.suse.manager.webui.services.iface.MonitoringManager; import com.suse.manager.webui.services.iface.SaltApi; import com.suse.manager.webui.services.iface.SystemQuery; -import com.suse.manager.webui.services.iface.VirtManager; import com.suse.manager.webui.services.test.TestSaltApi; import com.suse.manager.webui.services.test.TestSystemQuery; @@ -65,11 +63,10 @@ public class SystemDetailsEditActionTest extends RhnPostMockStrutsTestCase { private final SystemQuery systemQuery = new TestSystemQuery(); private final SaltApi saltApi = new TestSaltApi(); private final ServerGroupManager serverGroupManager = new ServerGroupManager(saltApi); - private final VirtManager virtManager = new VirtManagerSalt(saltApi); private final MonitoringManager monitoringManager = new FormulaMonitoringManager(saltApi); private final SystemEntitlementManager systemEntitlementManager = new SystemEntitlementManager( - new SystemUnentitler(virtManager, monitoringManager, serverGroupManager), - new SystemEntitler(saltApi, virtManager, monitoringManager, serverGroupManager) + new SystemUnentitler(monitoringManager, serverGroupManager), + new SystemEntitler(saltApi, monitoringManager, serverGroupManager) ); /** diff --git a/java/code/src/com/redhat/rhn/frontend/action/systems/sdc/test/SystemOverviewActionTest.java b/java/code/src/com/redhat/rhn/frontend/action/systems/sdc/test/SystemOverviewActionTest.java index d485f0c56866..340abe7f0cef 100644 --- a/java/code/src/com/redhat/rhn/frontend/action/systems/sdc/test/SystemOverviewActionTest.java +++ b/java/code/src/com/redhat/rhn/frontend/action/systems/sdc/test/SystemOverviewActionTest.java @@ -41,10 +41,8 @@ import com.redhat.rhn.testing.RhnMockStrutsTestCase; import com.redhat.rhn.testing.TestUtils; -import com.suse.manager.virtualization.VirtManagerSalt; import com.suse.manager.webui.services.iface.MonitoringManager; import com.suse.manager.webui.services.iface.SaltApi; -import com.suse.manager.webui.services.iface.VirtManager; import com.suse.manager.webui.services.test.TestSaltApi; import org.junit.jupiter.api.BeforeEach; @@ -62,11 +60,10 @@ public class SystemOverviewActionTest extends RhnMockStrutsTestCase { protected Server s; private final SaltApi saltApi = new TestSaltApi(); private final ServerGroupManager serverGroupManager = new ServerGroupManager(saltApi); - private final VirtManager virtManager = new VirtManagerSalt(saltApi); private final MonitoringManager monitoringManager = new FormulaMonitoringManager(saltApi); private final SystemEntitlementManager systemEntitlementManager = new SystemEntitlementManager( - new SystemUnentitler(virtManager, monitoringManager, serverGroupManager), - new SystemEntitler(saltApi, virtManager, monitoringManager, serverGroupManager) + new SystemUnentitler(monitoringManager, serverGroupManager), + new SystemEntitler(saltApi, monitoringManager, serverGroupManager) ); /** diff --git a/java/code/src/com/redhat/rhn/frontend/action/systems/virtualization/ProvisionVirtualizationWizardAction.java b/java/code/src/com/redhat/rhn/frontend/action/systems/virtualization/ProvisionVirtualizationWizardAction.java deleted file mode 100644 index ede873cf57f7..000000000000 --- a/java/code/src/com/redhat/rhn/frontend/action/systems/virtualization/ProvisionVirtualizationWizardAction.java +++ /dev/null @@ -1,370 +0,0 @@ -/* - * Copyright (c) 2009--2014 Red Hat, Inc. - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.redhat.rhn.frontend.action.systems.virtualization; - -import com.redhat.rhn.common.localization.LocalizationService; -import com.redhat.rhn.common.util.DatePicker; -import com.redhat.rhn.common.validator.ValidatorError; -import com.redhat.rhn.domain.kickstart.KickstartData; -import com.redhat.rhn.domain.kickstart.KickstartFactory; -import com.redhat.rhn.domain.server.Server; -import com.redhat.rhn.domain.user.User; -import com.redhat.rhn.frontend.action.kickstart.KickstartHelper; -import com.redhat.rhn.frontend.action.kickstart.ScheduleKickstartWizardAction; -import com.redhat.rhn.frontend.struts.RequestContext; -import com.redhat.rhn.frontend.struts.RhnValidationHelper; -import com.redhat.rhn.frontend.struts.wizard.WizardStep; -import com.redhat.rhn.manager.kickstart.KickstartScheduleCommand; -import com.redhat.rhn.manager.kickstart.ProvisionVirtualInstanceCommand; -import com.redhat.rhn.manager.kickstart.cobbler.CobblerXMLRPCHelper; -import com.redhat.rhn.manager.system.SystemManager; - -import org.apache.commons.lang3.StringUtils; -import org.apache.struts.action.ActionErrors; -import org.apache.struts.action.ActionForward; -import org.apache.struts.action.ActionMapping; -import org.apache.struts.action.ActionMessage; -import org.apache.struts.action.ActionMessages; -import org.apache.struts.action.DynaActionForm; -import org.cobbler.Profile; - -import java.util.Date; -import java.util.HashMap; -import java.util.Map; -import java.util.regex.Pattern; - -import javax.servlet.http.HttpServletResponse; -/** - * ProvisionVirtualizationWizardAction extends ScheduleKickstartWizardAction - */ -public class ProvisionVirtualizationWizardAction extends ScheduleKickstartWizardAction { - - public static final String MEMORY_ALLOCATION = "memoryAllocation"; - public static final String VIRTUAL_CPUS = "virtualCpus"; - public static final String VIRTUAL_BRIDGE = "virtBridge"; - public static final String VIRTUAL_FILE_PATH = "diskPath"; - public static final String LOCAL_STORAGE_GB = "localStorageGigabytes"; - public static final String MAC_ADDRESS = "macAddress"; - public static final String PROFILE = "cobbler_profile"; - - public static final String GUEST_NAME = "guestName"; - - /** - * {@inheritDoc} - */ - @Override - public ActionForward runFirst(ActionMapping mapping, DynaActionForm form, - RequestContext ctx, HttpServletResponse response, - WizardStep step) throws Exception { - Long sid = (Long) form.get(RequestContext.SID); - User user = ctx.getCurrentUser(); - Server system = SystemManager.lookupByIdAndUser(sid, user); - - if (StringUtils.isEmpty(form.getString(MEMORY_ALLOCATION))) { - form.set(MEMORY_ALLOCATION, ""); - } - - if (StringUtils.isEmpty(form.getString(VIRTUAL_CPUS))) { - form.set(VIRTUAL_CPUS, ""); - } - - if (StringUtils.isEmpty(form.getString(LOCAL_STORAGE_GB))) { - form.set(LOCAL_STORAGE_GB, ""); - } - - if (StringUtils.isEmpty(form.getString(MAC_ADDRESS))) { - form.set(MAC_ADDRESS, ""); - } - - return super.runFirst(mapping, form, ctx, response, step); - } - - /** - * {@inheritDoc} - */ - @Override - public ActionForward runSecond(ActionMapping mapping, DynaActionForm form, - RequestContext ctx, HttpServletResponse response, - WizardStep step) throws Exception { - if (!validateFirstSelections(form, ctx)) { - return runFirst(mapping, form, ctx, response, step); - } - ActionErrors errors = validateInput(form); - if (!errors.isEmpty()) { - addErrors(ctx.getRequest(), errors); - //saveMessages(ctx.getRequest(), errors); - return runFirst(mapping, form, ctx, response, step); - } - ActionForward forward = super.runSecond(mapping, form, ctx, response, step); - - Profile pf = getCobblerProfile(ctx); - KickstartData ksdata = ctx.lookupAndBindKickstartData(); - if (StringUtils.isEmpty(form.getString(VIRTUAL_FILE_PATH))) { - form.set(VIRTUAL_FILE_PATH, ProvisionVirtualInstanceCommand. - makeDefaultVirtPath(form.getString(GUEST_NAME), - ksdata.getKickstartDefaults().getVirtualizationType())); - } - if (StringUtils.isEmpty(form.getString(MEMORY_ALLOCATION))) { - form.set(MEMORY_ALLOCATION, String.valueOf(pf.getVirtRam())); - } - - if (StringUtils.isEmpty(form.getString(VIRTUAL_CPUS))) { - form.set(VIRTUAL_CPUS, String.valueOf(pf.getVirtCpus())); - } - - if (StringUtils.isEmpty(form.getString(LOCAL_STORAGE_GB))) { - form.set(LOCAL_STORAGE_GB, String.valueOf(pf.getVirtFileSize())); - } - - if (StringUtils.isEmpty(form.getString(VIRTUAL_BRIDGE))) { - form.set(VIRTUAL_BRIDGE, String.valueOf(pf.getVirtBridge())); - } - - if (StringUtils.isEmpty(form.getString(TARGET_PROFILE_TYPE))) { - form.set(TARGET_PROFILE_TYPE, - KickstartScheduleCommand.TARGET_PROFILE_TYPE_NONE); - } - return forward; - } - - /** - * {@inheritDoc} - */ - @Override - public ActionForward runThird(ActionMapping mapping, DynaActionForm form, - RequestContext ctx, HttpServletResponse response, - WizardStep step) throws Exception { - if (!validateFirstSelections(form, ctx)) { - return runFirst(mapping, form, ctx, response, step); - } - - ActionErrors errors = validateInput(form); - if (!errors.isEmpty()) { - addErrors(ctx.getRequest(), errors); - //saveMessages(ctx.getRequest(), errors); - return runFirst(mapping, form, ctx, response, step); - } - - String scheduleAsap = form.getString("scheduleAsap"); - Date scheduleTime = null; - if (scheduleAsap != null && scheduleAsap.equals("false")) { - scheduleTime = getStrutsDelegate().readScheduleDate(form, "date", - DatePicker.YEAR_RANGE_POSITIVE); - } - else { - scheduleTime = new Date(); - } - KickstartHelper helper = new KickstartHelper(ctx.getRequest()); - - ProvisionVirtualInstanceCommand cmd = getScheduleCommand(form, - ctx, scheduleTime, helper.getKickstartHost()); - - cmd.setKernelOptions(form.getString(KERNEL_PARAMS)); - - cmd.setProfileType(form.getString("targetProfileType")); - cmd.setServerProfileId((Long) form.get("targetServerProfile")); - cmd.setProfileId((Long) form.get("targetProfile")); - - cmd.setGuestName(form.getString(GUEST_NAME)); - - - //If the virt options are overridden use them, otherwise use - // The profile's values - if (!StringUtils.isEmpty(form.getString(MEMORY_ALLOCATION))) { - cmd.setMemoryAllocation(Long.valueOf(form.getString(MEMORY_ALLOCATION))); - } - else { - cmd.setMemoryAllocation((long) this.getCobblerProfile(ctx).getVirtRam().get()); - } - - if (!StringUtils.isEmpty(form.getString(VIRTUAL_CPUS))) { - cmd.setVirtualCpus(Long.valueOf(form.getString(VIRTUAL_CPUS))); - } - else { - cmd.setVirtualCpus((long) this.getCobblerProfile(ctx).getVirtCpus().get()); - } - - if (!StringUtils.isEmpty(form.getString(LOCAL_STORAGE_GB))) { - cmd.setLocalStorageSize(Long.valueOf(form.getString(LOCAL_STORAGE_GB))); - } - else { - cmd.setLocalStorageSize(this.getCobblerProfile(ctx).getVirtFileSize().get().longValue()); - } - - if (!StringUtils.isEmpty(form.getString(VIRTUAL_BRIDGE))) { - cmd.setVirtBridge(form.getString(VIRTUAL_BRIDGE)); - } - else { - cmd.setVirtBridge(this.getCobblerProfile(ctx).getVirtBridge().get()); - } - if (!StringUtils.isEmpty(form.getString(MAC_ADDRESS))) { - String macAddress = form.getString(MAC_ADDRESS); - macAddress = macAddress.replace(":", ""); - macAddress = macAddress.toLowerCase(); - macAddress = macAddress.substring(0, 2) + ":" + - macAddress.substring(2, 4) + ":" + - macAddress.substring(4, 6) + ":" + - macAddress.substring(6, 8) + ":" + - macAddress.substring(8, 10) + ":" + - macAddress.substring(10); - cmd.setMacAddress(macAddress); - } - cmd.setFilePath(form.getString(VIRTUAL_FILE_PATH)); - storeProxyInfo(form, ctx, cmd); - // Store the new KickstartSession to the DB. - ValidatorError ve = cmd.store(); - if (ve != null) { - errors = RhnValidationHelper.validatorErrorToActionErrors(ve); - if (!errors.isEmpty()) { - getStrutsDelegate().saveMessages(ctx.getRequest(), errors); - return runFirst(mapping, form, ctx, response, step); - } - } - - createSuccessMessage(ctx.getRequest(), "kickstart.schedule.success", - LocalizationService.getInstance().formatDate(scheduleTime)); - Map params = new HashMap<>(); - params.put(RequestContext.SID, form.get(RequestContext.SID)); - - return getStrutsDelegate().forwardParams(mapping.findForward("success"), params); - } - @Override - protected KickstartScheduleCommand getKickstartScheduleCommand(Long sid, - User currentUser) { - return new ProvisionVirtualInstanceCommand(sid, currentUser); - } - - - private ActionErrors validateInput(DynaActionForm form) { - ActionErrors errors = new ActionErrors(); - String name = form.getString(GUEST_NAME); - - if (name.length() < ProvisionVirtualInstanceCommand.MIN_NAME_SIZE) { - errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage( - "frontend.actions.systems.virt.invalidguestnamelength", - (ProvisionVirtualInstanceCommand.MIN_NAME_SIZE))); - } - - Pattern pattern = Pattern.compile( - ProvisionVirtualInstanceCommand.GUEST_NAME_REGEXP, - Pattern.CASE_INSENSITIVE); - if (!pattern.matcher(name).matches()) { - errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage( - "frontend.actions.systems.virt.invalidregexp")); - } - - if (!StringUtils.isEmpty(form.getString(MEMORY_ALLOCATION))) { - try { - Long memory = Long.parseLong(form.getString(MEMORY_ALLOCATION)); - if (memory <= 0) { - throw new NumberFormatException(); - } - } - catch (NumberFormatException e) { - errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage( - "frontend.actions.systems.virt.invalidmemvalue")); - } - } - - if (!StringUtils.isEmpty(form.getString(VIRTUAL_CPUS))) { - try { - Long cpus = Long.parseLong(form.getString(VIRTUAL_CPUS)); - if (cpus <= 0 || cpus > ProvisionVirtualInstanceCommand.MAX_CPU) { - throw new NumberFormatException(); - } - } - catch (NumberFormatException e) { - errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage( - "frontend.actions.systems.virt.invalidcpuvalue", - (ProvisionVirtualInstanceCommand.MAX_CPU + 1))); - } - } - - if (!StringUtils.isEmpty(form.getString(LOCAL_STORAGE_GB))) { - try { - Long storage = Long.parseLong(form.getString(LOCAL_STORAGE_GB)); - if (storage <= 0) { - throw new NumberFormatException(); - } - } - catch (NumberFormatException e) { - errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage( - "frontend.actions.systems.virt.invalidstoragevalue")); - form.set(LOCAL_STORAGE_GB, ""); - } - } - - if (!StringUtils.isEmpty(form.getString(MAC_ADDRESS))) { - try { - String macAddress = form.getString(MAC_ADDRESS); - macAddress = macAddress.replace(":", ""); - if (macAddress.length() != 12 || - !macAddress.matches("^[0-9a-fA-F]+$")) { - throw new NumberFormatException(); - } - } - catch (NumberFormatException e) { - errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage( - "frontend.actions.systems.virt.invalidmacaddressvalue")); - form.set(MAC_ADDRESS, ""); - } - } - - return errors; - } - - /** - * Get the cobbler profile - * @param context the request context - * @return the cobbler profile - */ - private Profile getCobblerProfile(RequestContext context) { - if (context.getRequest().getAttribute(PROFILE) == null) { - String cobblerId = (String) context.getRequest().getAttribute( - RequestContext.COBBLER_ID); - User user = context.getCurrentUser(); - Profile cobblerProfile = Profile.lookupById( - CobblerXMLRPCHelper.getConnection(user), cobblerId); - context.getRequest().setAttribute(PROFILE, cobblerProfile); - } - return (Profile) context.getRequest().getAttribute(PROFILE); - } - - @Override - protected ProvisionVirtualInstanceCommand getScheduleCommand(DynaActionForm form, - RequestContext ctx, Date scheduleTime, String host) { - Profile cobblerProfile = getCobblerProfile(ctx); - User user = ctx.getCurrentUser(); - ProvisionVirtualInstanceCommand cmd; - KickstartData data = KickstartFactory. - lookupKickstartDataByCobblerIdAndOrg(user.getOrg(), cobblerProfile.getId()); - - if (data != null) { - cmd = - new ProvisionVirtualInstanceCommand( - (Long) form.get(RequestContext.SID), - data, - ctx.getCurrentUser(), - scheduleTime, - host); - } - else { - cmd = ProvisionVirtualInstanceCommand.createCobblerScheduleCommand((Long) - form.get(RequestContext.SID), cobblerProfile.getName(), - user, scheduleTime, host); - } - return cmd; - } -} diff --git a/java/code/src/com/redhat/rhn/frontend/action/systems/virtualization/test/ProvisionVirtualizationWizardActionTest.java b/java/code/src/com/redhat/rhn/frontend/action/systems/virtualization/test/ProvisionVirtualizationWizardActionTest.java deleted file mode 100644 index 615928bf6135..000000000000 --- a/java/code/src/com/redhat/rhn/frontend/action/systems/virtualization/test/ProvisionVirtualizationWizardActionTest.java +++ /dev/null @@ -1,238 +0,0 @@ -/* - * Copyright (c) 2009--2014 Red Hat, Inc. - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.redhat.rhn.frontend.action.systems.virtualization.test; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; - -import com.redhat.rhn.common.conf.ConfigDefaults; -import com.redhat.rhn.common.db.datasource.Row; -import com.redhat.rhn.domain.channel.Channel; -import com.redhat.rhn.domain.channel.test.ChannelFactoryTest; -import com.redhat.rhn.domain.kickstart.KickstartData; -import com.redhat.rhn.domain.kickstart.KickstartFactory; -import com.redhat.rhn.domain.kickstart.KickstartSession; -import com.redhat.rhn.domain.kickstart.test.KickstartDataTest; -import com.redhat.rhn.domain.role.RoleFactory; -import com.redhat.rhn.domain.server.EntitlementServerGroup; -import com.redhat.rhn.domain.server.Server; -import com.redhat.rhn.domain.server.ServerConstants; -import com.redhat.rhn.domain.server.ServerFactory; -import com.redhat.rhn.domain.server.test.ServerFactoryTest; -import com.redhat.rhn.domain.token.ActivationKey; -import com.redhat.rhn.domain.token.ActivationKeyFactory; -import com.redhat.rhn.domain.token.Token; -import com.redhat.rhn.domain.token.TokenFactory; -import com.redhat.rhn.frontend.action.kickstart.ScheduleKickstartWizardAction; -import com.redhat.rhn.frontend.action.kickstart.test.ScheduleKickstartWizardTest; -import com.redhat.rhn.frontend.action.systems.virtualization.ProvisionVirtualizationWizardAction; -import com.redhat.rhn.frontend.dto.ProfileDto; -import com.redhat.rhn.frontend.struts.RequestContext; -import com.redhat.rhn.manager.formula.FormulaMonitoringManager; -import com.redhat.rhn.manager.kickstart.KickstartScheduleCommand; -import com.redhat.rhn.manager.profile.test.ProfileManagerTest; -import com.redhat.rhn.manager.rhnpackage.test.PackageManagerTest; -import com.redhat.rhn.manager.system.ServerGroupManager; -import com.redhat.rhn.manager.system.entitling.SystemEntitlementManager; -import com.redhat.rhn.manager.system.entitling.SystemEntitler; -import com.redhat.rhn.manager.system.entitling.SystemUnentitler; -import com.redhat.rhn.testing.RhnMockStrutsTestCase; -import com.redhat.rhn.testing.ServerGroupTestUtils; -import com.redhat.rhn.testing.TestUtils; - -import com.suse.manager.virtualization.VirtManagerSalt; -import com.suse.manager.webui.services.iface.MonitoringManager; -import com.suse.manager.webui.services.iface.SaltApi; -import com.suse.manager.webui.services.iface.VirtManager; -import com.suse.manager.webui.services.test.TestSaltApi; - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import java.util.HashSet; -import java.util.Set; - - -/** - * ProvisionVirtualizationWizardActionTest - */ -public class ProvisionVirtualizationWizardActionTest extends RhnMockStrutsTestCase { - - private Server s; - private final SaltApi saltApi = new TestSaltApi(); - private final ServerGroupManager serverGroupManager = new ServerGroupManager(saltApi); - private final VirtManager virtManager = new VirtManagerSalt(saltApi); - private final MonitoringManager monitoringManager = new FormulaMonitoringManager(saltApi); - private final SystemEntitlementManager systemEntitlementManager = new SystemEntitlementManager( - new SystemUnentitler(virtManager, monitoringManager, serverGroupManager), - new SystemEntitler(saltApi, virtManager, monitoringManager, serverGroupManager) - ); - - /** - * {@inheritDoc} - */ - @Override - @BeforeEach - public void setUp() throws Exception { - super.setUp(); - setRequestPathInfo("/systems/details/virtualization/ProvisionVirtualizationWizard"); - user.addPermanentRole(RoleFactory.ORG_ADMIN); - s = ServerFactoryTest.createTestServer(user, true, - ServerConstants.getServerGroupTypeEnterpriseEntitled()); - s.addChannel(ChannelFactoryTest.createBaseChannel(user)); - EntitlementServerGroup sg = ServerGroupTestUtils.createEntitled(user.getOrg(), - ServerFactory.lookupServerGroupTypeByLabel("enterprise_entitled")); - systemEntitlementManager.addEntitlementToServer(s, sg.getGroupType().getAssociatedEntitlement()); - Channel c = ChannelFactoryTest.createTestChannel(user); - // Required so the Server has a base channel - // otherwise we cant ks. - s.addChannel(c); - - PackageManagerTest.addPackageToSystemAndChannel( - ConfigDefaults.get().getKickstartPackageNames().get(0), s, c); - TestUtils.saveAndFlush(s); - TestUtils.saveAndFlush(c); - - PackageManagerTest. - addUp2dateToSystemAndChannel(user, s, - KickstartScheduleCommand.UP2DATE_VERSION, c); - - TestUtils.flushAndEvict(s); - TestUtils.flushAndEvict(c); - addRequestParameter(RequestContext.SID, s.getId().toString()); - } - - @Test - public void testStepOne() { - actionPerform(); - verifyNoActionErrors(); - } - - @Test - public void testStepTwo() throws Exception { - KickstartData k = KickstartDataTest.createKickstartWithProfile(user); - ProfileManagerTest.createProfileWithServer(user); - - ActivationKey key = ActivationKeyFactory.createNewKey(user, "some key"); - ActivationKeyFactory.save(key); - key = TestUtils.reload(key); - Token t = TokenFactory.lookupById(key.getId()); - Set tokens = new HashSet<>(); - tokens.add(t); - k.setDefaultRegTokens(tokens); - - - // Step Two - addRequestParameter(RequestContext.SID, s.getId().toString()); - addRequestParameter("wizardStep", "second"); - addRequestParameter("items_selected", k.getCobblerId().toString()); - addRequestParameter("scheduleAsap", "false"); - addRequestParameter("date_month", "2"); - addRequestParameter("date_day", "16"); - addRequestParameter("date_year", "2006"); - addRequestParameter("date_hour", "8"); - addRequestParameter("date_minute", "0"); - addRequestParameter("date_am_pm", "1"); - addRequestParameter(ProvisionVirtualizationWizardAction.GUEST_NAME, "testName"); - addRequestParameter(RequestContext.COBBLER_ID, k.getCobblerId()); - actionPerform(); - verifyNoActionErrors(); - assertNotNull(request.getAttribute(RequestContext.KICKSTART)); - assertNotNull(request.getAttribute(RequestContext.SYSTEM)); - verifyFormList(ScheduleKickstartWizardAction.SYNCH_PACKAGES, - ProfileDto.class); - verifyFormList(ScheduleKickstartWizardAction.SYNCH_SYSTEMS, - Row.class); - - } - - public void executeStepThree(boolean addProxy) throws Exception { - // Perform step 1 - actionPerform(); - verifyNoActionErrors(); - try { - verifyActionMessage("kickstart.schedule.noprofiles"); - } - catch (AssertionError e) { - verifyActionMessages(new String[] {"kickstart.schedule.noprofiles"}); - } - assertNotNull(request.getAttribute(RequestContext.SYSTEM)); - clearRequestParameters(); - - // Perform step2 - KickstartData k = KickstartDataTest.createKickstartWithProfile(user); - // Required so the server and profile match base channels - k.getKickstartDefaults().getKstree().setChannel(s.getBaseChannel()); - - // Create other server to sync - Server otherServer = ServerFactoryTest.createTestServer(user, true, - ServerConstants.getServerGroupTypeEnterpriseEntitled()); - otherServer.addChannel(ChannelFactoryTest.createTestChannel(user)); - - addRequestParameter(RequestContext.SID, s.getId().toString()); - addRequestParameter("targetProfileType", - KickstartScheduleCommand.TARGET_PROFILE_TYPE_SYSTEM); - addRequestParameter("targetServerProfile", otherServer.getId().toString()); - addRequestParameter("wizardStep", "third"); - addRequestParameter("items_selected", k.getCobblerId().toString()); - addRequestParameter("scheduleAsap", "false"); - addRequestParameter("date_month", "2"); - addRequestParameter("date_day", "16"); - addRequestParameter("date_year", "2006"); - addRequestParameter("date_hour", "8"); - addRequestParameter("date_minute", "0"); - addRequestParameter("date_am_pm", "1"); - addRequestParameter(ProvisionVirtualizationWizardAction.GUEST_NAME, "testName"); - addRequestParameter(RequestContext.COBBLER_ID, k.getCobblerId()); - Server proxy = null; - if (addProxy) { - proxy = ScheduleKickstartWizardTest.addProxy(user, s); - assertNotNull(proxy.getHostname()); - /** Assign a proxy host, this would be the case - * When user selects a proxy entry from the proxies combo - */ - addRequestParameter(ScheduleKickstartWizardAction.PROXY_HOST, - proxy.getId().toString()); - } - - actionPerform(); - verifyNoActionErrors(); - - verifyActionMessage("kickstart.schedule.success"); - assertEquals(getActualForward(), - "/systems/details/kickstart/SessionStatus.do?sid=" + s.getId()); - - assertNotNull(KickstartFactory.lookupKickstartSessionByServer(s.getId())); - if (addProxy && proxy != null) { - verifyFormValue(ScheduleKickstartWizardAction.PROXY_HOST, - proxy.getId().toString()); - KickstartSession session = KickstartFactory. - lookupKickstartSessionByServer(s.getId()); - assertNotNull(session.getSystemRhnHost()); - assertEquals(proxy.getHostname(), session.getSystemRhnHost()); - } - } - - - @Test - public void testStepThreeWithProxy() throws Exception { - executeStepThree(true); - } - - @Test - public void testStepThreeNoProxy() throws Exception { - executeStepThree(false); - } -} diff --git a/java/code/src/com/redhat/rhn/frontend/xmlrpc/admin/configuration/test/AdminConfigurationHandlerTest.java b/java/code/src/com/redhat/rhn/frontend/xmlrpc/admin/configuration/test/AdminConfigurationHandlerTest.java index 31fa55deddf1..4d5cfe15211a 100644 --- a/java/code/src/com/redhat/rhn/frontend/xmlrpc/admin/configuration/test/AdminConfigurationHandlerTest.java +++ b/java/code/src/com/redhat/rhn/frontend/xmlrpc/admin/configuration/test/AdminConfigurationHandlerTest.java @@ -64,13 +64,11 @@ import com.suse.cloud.CloudPaygManager; import com.suse.cloud.test.TestCloudPaygManagerBuilder; import com.suse.manager.attestation.AttestationManager; -import com.suse.manager.virtualization.VirtManagerSalt; import com.suse.manager.webui.controllers.bootstrap.RegularMinionBootstrapper; import com.suse.manager.webui.controllers.bootstrap.SSHMinionBootstrapper; import com.suse.manager.webui.services.iface.MonitoringManager; import com.suse.manager.webui.services.iface.SaltApi; import com.suse.manager.webui.services.iface.SystemQuery; -import com.suse.manager.webui.services.iface.VirtManager; import com.suse.manager.webui.services.test.TestSaltApi; import com.suse.manager.webui.services.test.TestSystemQuery; @@ -108,11 +106,10 @@ public class AdminConfigurationHandlerTest extends BaseHandlerTestCase { regularMinionBootstrapper, sshMinionBootstrapper ); - private final VirtManager virtManager = new VirtManagerSalt(saltApi); private final MonitoringManager monitoringManager = new FormulaMonitoringManager(saltApi); private final SystemEntitlementManager systemEntitlementManager = new SystemEntitlementManager( - new SystemUnentitler(virtManager, monitoringManager, serverGroupManager), - new SystemEntitler(saltApi, virtManager, monitoringManager, serverGroupManager) + new SystemUnentitler(monitoringManager, serverGroupManager), + new SystemEntitler(saltApi, monitoringManager, serverGroupManager) ); private SystemManager systemManager = new SystemManager(ServerFactory.SINGLETON, ServerGroupFactory.SINGLETON, saltApi); diff --git a/java/code/src/com/redhat/rhn/frontend/xmlrpc/ansible/test/AnsibleHandlerTest.java b/java/code/src/com/redhat/rhn/frontend/xmlrpc/ansible/test/AnsibleHandlerTest.java index 5b2f2f73da3f..27b7e9a0ee64 100644 --- a/java/code/src/com/redhat/rhn/frontend/xmlrpc/ansible/test/AnsibleHandlerTest.java +++ b/java/code/src/com/redhat/rhn/frontend/xmlrpc/ansible/test/AnsibleHandlerTest.java @@ -52,10 +52,8 @@ import com.redhat.rhn.taskomatic.TaskomaticApiException; import com.redhat.rhn.testing.TestUtils; -import com.suse.manager.virtualization.VirtManagerSalt; import com.suse.manager.webui.services.iface.MonitoringManager; import com.suse.manager.webui.services.iface.SaltApi; -import com.suse.manager.webui.services.iface.VirtManager; import com.suse.salt.netapi.calls.LocalCall; import com.suse.salt.netapi.datatypes.target.MinionList; import com.suse.salt.netapi.utils.Xor; @@ -324,12 +322,11 @@ public void testFetchPlaybookContents() throws Exception { } private MinionServer createAnsibleControlNode(User user) throws Exception { - VirtManager virtManager = new VirtManagerSalt(saltApi); MonitoringManager monitoringManager = new FormulaMonitoringManager(saltApi); ServerGroupManager groupManager = new ServerGroupManager(saltApi); SystemEntitlementManager entitlementManager = new SystemEntitlementManager( - new SystemUnentitler(virtManager, monitoringManager, groupManager), - new SystemEntitler(saltApi, virtManager, monitoringManager, groupManager) + new SystemUnentitler(monitoringManager, groupManager), + new SystemEntitler(saltApi, monitoringManager, groupManager) ); context.checking(new Expectations() {{ diff --git a/java/code/src/com/redhat/rhn/frontend/xmlrpc/channel/software/test/ChannelSoftwareHandlerTest.java b/java/code/src/com/redhat/rhn/frontend/xmlrpc/channel/software/test/ChannelSoftwareHandlerTest.java index 23aeef849f5d..7ae2ae42cf82 100644 --- a/java/code/src/com/redhat/rhn/frontend/xmlrpc/channel/software/test/ChannelSoftwareHandlerTest.java +++ b/java/code/src/com/redhat/rhn/frontend/xmlrpc/channel/software/test/ChannelSoftwareHandlerTest.java @@ -75,13 +75,11 @@ import com.suse.cloud.CloudPaygManager; import com.suse.cloud.test.TestCloudPaygManagerBuilder; import com.suse.manager.attestation.AttestationManager; -import com.suse.manager.virtualization.VirtManagerSalt; import com.suse.manager.webui.controllers.bootstrap.RegularMinionBootstrapper; import com.suse.manager.webui.controllers.bootstrap.SSHMinionBootstrapper; import com.suse.manager.webui.services.iface.MonitoringManager; import com.suse.manager.webui.services.iface.SaltApi; import com.suse.manager.webui.services.iface.SystemQuery; -import com.suse.manager.webui.services.iface.VirtManager; import com.suse.manager.webui.services.test.TestSaltApi; import com.suse.manager.webui.services.test.TestSystemQuery; @@ -127,11 +125,10 @@ public class ChannelSoftwareHandlerTest extends BaseHandlerTestCase { regularMinionBootstrapper, sshMinionBootstrapper ); - private final VirtManager virtManager = new VirtManagerSalt(saltApi); private final MonitoringManager monitoringManager = new FormulaMonitoringManager(saltApi); private final SystemEntitlementManager systemEntitlementManager = new SystemEntitlementManager( - new SystemUnentitler(virtManager, monitoringManager, serverGroupManager), - new SystemEntitler(saltApi, virtManager, monitoringManager, serverGroupManager) + new SystemUnentitler(monitoringManager, serverGroupManager), + new SystemEntitler(saltApi, monitoringManager, serverGroupManager) ); private SystemManager systemManager = new SystemManager(ServerFactory.SINGLETON, ServerGroupFactory.SINGLETON, saltApi); diff --git a/java/code/src/com/redhat/rhn/frontend/xmlrpc/image/test/ImageInfoHandlerTest.java b/java/code/src/com/redhat/rhn/frontend/xmlrpc/image/test/ImageInfoHandlerTest.java index a6a43c3f1e6a..0ab5190374d4 100644 --- a/java/code/src/com/redhat/rhn/frontend/xmlrpc/image/test/ImageInfoHandlerTest.java +++ b/java/code/src/com/redhat/rhn/frontend/xmlrpc/image/test/ImageInfoHandlerTest.java @@ -67,9 +67,7 @@ import com.redhat.rhn.testing.ImageTestUtils; import com.redhat.rhn.testing.TestUtils; -import com.suse.manager.virtualization.VirtManagerSalt; import com.suse.manager.webui.services.iface.MonitoringManager; -import com.suse.manager.webui.services.iface.VirtManager; import com.suse.manager.webui.services.impl.SaltSSHService; import com.suse.manager.webui.services.impl.SaltService; import com.suse.manager.webui.services.impl.runner.MgrUtilRunner; @@ -114,11 +112,10 @@ public void setUp() throws Exception { Config.get().setBoolean(ConfigDefaults.KIWI_OS_IMAGE_BUILDING_ENABLED, "true"); saltServiceMock = context.mock(SaltService.class); ServerGroupManager serverGroupManager = new ServerGroupManager(saltServiceMock); - VirtManager virtManager = new VirtManagerSalt(saltServiceMock); MonitoringManager monitoringManager = new FormulaMonitoringManager(saltServiceMock); systemEntitlementManager = new SystemEntitlementManager( - new SystemUnentitler(virtManager, monitoringManager, serverGroupManager), - new SystemEntitler(saltServiceMock, virtManager, monitoringManager, serverGroupManager) + new SystemUnentitler(monitoringManager, serverGroupManager), + new SystemEntitler(saltServiceMock, monitoringManager, serverGroupManager) ); handler = new ImageInfoHandler(saltServiceMock); context.checking(new Expectations() {{ diff --git a/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/SystemHandler.java b/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/SystemHandler.java index e063cd464f24..693acdecbd2c 100644 --- a/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/SystemHandler.java +++ b/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/SystemHandler.java @@ -45,8 +45,6 @@ import com.redhat.rhn.domain.action.script.ScriptResult; import com.redhat.rhn.domain.action.script.ScriptRunAction; import com.redhat.rhn.domain.action.server.ServerAction; -import com.redhat.rhn.domain.action.virtualization.VirtualizationSetMemoryGuestAction; -import com.redhat.rhn.domain.action.virtualization.VirtualizationSetVcpusGuestAction; import com.redhat.rhn.domain.channel.Channel; import com.redhat.rhn.domain.channel.ChannelArch; import com.redhat.rhn.domain.channel.ChannelFactory; @@ -101,7 +99,6 @@ import com.redhat.rhn.domain.token.ActivationKeyFactory; import com.redhat.rhn.domain.user.User; import com.redhat.rhn.frontend.action.kickstart.KickstartHelper; -import com.redhat.rhn.frontend.context.Context; import com.redhat.rhn.frontend.dto.ActivationKeyDto; import com.redhat.rhn.frontend.dto.ErrataOverview; import com.redhat.rhn.frontend.dto.EssentialChannelDto; @@ -198,9 +195,6 @@ import com.suse.manager.model.attestation.CoCoEnvironmentType; import com.suse.manager.model.attestation.ServerCoCoAttestationConfig; import com.suse.manager.model.attestation.ServerCoCoAttestationReport; -import com.suse.manager.virtualization.VirtualizationActionHelper; -import com.suse.manager.webui.controllers.virtualization.gson.VirtualGuestSetterActionJson; -import com.suse.manager.webui.controllers.virtualization.gson.VirtualGuestsBaseActionJson; import com.suse.manager.webui.services.pillar.MinionPillarManager; import com.suse.manager.webui.utils.gson.BootstrapParameters; import com.suse.manager.xmlrpc.NoSuchHistoryEventException; @@ -216,8 +210,6 @@ import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; -import java.time.LocalDateTime; -import java.time.ZoneId; import java.util.ArrayList; import java.util.Arrays; import java.util.Calendar; @@ -6431,173 +6423,6 @@ public List listVirtualGuests(User loggedInUser, return result; } - /** - * Schedules an action to set the guests memory usage - * @param loggedInUser The current user - * @param sid the server ID of the guest - * @param memory the amount of memory to set the guest to use - * @return the action id of the scheduled action - * - * @apidoc.doc Schedule an action of a guest's host, to set that guest's memory - * allocation - * @apidoc.param #session_key() - * @apidoc.param #param_desc("int", "sid", "The guest's system id") - * @apidoc.param #param_desc("int", "memory", "The amount of memory to - * allocate to the guest") - * @apidoc.returntype #param_desc("int", "actionID", "the action Id for the schedule action - * on the host system") - * - */ - public int setGuestMemory(User loggedInUser, Integer sid, Integer memory) { - VirtualInstance vi = VirtualInstanceFactory.getInstance().lookupByGuestId( - loggedInUser.getOrg(), sid.longValue()); - - try { - return VirtualizationActionHelper.scheduleAction( - vi.getUuid(), - loggedInUser, - vi.getHostSystem(), - VirtualizationActionHelper.getGuestSetterActionCreator( - ActionFactory.TYPE_VIRTUALIZATION_SET_MEMORY, - (data) -> memory * 1024, - (action, value) -> ((VirtualizationSetMemoryGuestAction)action).setMemory(value), - Map.of(vi.getUuid(), vi.getGuestSystem().getName()) - ), - new VirtualGuestSetterActionJson()); - } - catch (com.redhat.rhn.taskomatic.TaskomaticApiException e) { - throw new TaskomaticApiException(e.getMessage()); - } - } - - - /** - * Schedules an actino to set the guests CPU allocation - * @param loggedInUser The current user - * @param sid the server ID of the guest - * @param numOfCpus the num of cpus to set - * @return the action id of the scheduled action - * - * @apidoc.doc Schedule an action of a guest's host, to set that guest's CPU - * allocation - * @apidoc.param #session_key() - * @apidoc.param #param_desc("int", "sid", "The guest's system id") - * @apidoc.param #param_desc("int", "numOfCpus", "The number of virtual cpus to - * allocate to the guest") - * @apidoc.returntype #param_desc("int", "actionID", "the action Id for the schedule action - * on the host system") - * - */ - public int setGuestCpus(User loggedInUser, Integer sid, Integer numOfCpus) { - VirtualInstance vi = VirtualInstanceFactory.getInstance().lookupByGuestId( - loggedInUser.getOrg(), sid.longValue()); - - try { - return VirtualizationActionHelper.scheduleAction( - vi.getUuid(), - loggedInUser, - vi.getHostSystem(), - VirtualizationActionHelper.getGuestSetterActionCreator( - ActionFactory.TYPE_VIRTUALIZATION_SET_VCPUS, - (data) -> numOfCpus, - (action, value) -> ((VirtualizationSetVcpusGuestAction)action).setVcpu(value), - Map.of(vi.getUuid(), vi.getGuestSystem().getName()) - ), - new VirtualGuestSetterActionJson()); - } - catch (com.redhat.rhn.taskomatic.TaskomaticApiException e) { - throw new TaskomaticApiException(e.getMessage()); - } - } - - /** - * schedules the specified action on the guest - * @param loggedInUser The current user - * @param sid the id of the system - * @param state one of the following: 'start', 'suspend', 'resume', 'restart', - * 'shutdown' - * @param date the date to schedule it - * @return action ID - * - * @apidoc.doc Schedules a guest action for the specified virtual guest for a given - * date/time. - * @apidoc.param #session_key() - * @apidoc.param #param_desc("int", "sid", "the system Id of the guest") - * @apidoc.param #param_desc("string", "state", "One of the following actions 'start', - * 'suspend', 'resume', 'restart', 'shutdown'.") - * @apidoc.param #param_desc($date, "date", "the time/date to schedule the action") - * @apidoc.returntype #param_desc("int", "actionId", "The action id of the scheduled action") - */ - public int scheduleGuestAction(User loggedInUser, Integer sid, String state, - Date date) { - VirtualInstance vi = VirtualInstanceFactory.getInstance().lookupByGuestId( - loggedInUser.getOrg(), sid.longValue()); - - ActionType action; - if (state.equals("start")) { - action = ActionFactory.TYPE_VIRTUALIZATION_START; - } - else if (state.equals("suspend")) { - action = ActionFactory.TYPE_VIRTUALIZATION_SUSPEND; - } - else if (state.equals("resume")) { - action = ActionFactory.TYPE_VIRTUALIZATION_RESUME; - } - else if (state.equals("restart")) { - action = ActionFactory.TYPE_VIRTUALIZATION_REBOOT; - } - else if (state.equals("shutdown")) { - action = ActionFactory.TYPE_VIRTUALIZATION_SHUTDOWN; - } - else { - throw new InvalidActionTypeException(); - } - - try { - VirtualGuestsBaseActionJson data = new VirtualGuestsBaseActionJson(); - data.setUuids(List.of(vi.getUuid())); - data.setForce(false); - data.setEarliest( - Optional.ofNullable(date).map((localDate) -> { - ZoneId zoneId = Optional.ofNullable(Context.getCurrentContext().getTimezone()) - .orElse(TimeZone.getDefault()).toZoneId(); - return LocalDateTime.ofInstant(localDate.toInstant(), zoneId); - }) - ); - return VirtualizationActionHelper.scheduleAction( - vi.getUuid(), - loggedInUser, - vi.getHostSystem(), - VirtualizationActionHelper.getGuestActionCreator( - action, - Map.of(vi.getUuid(), vi.getGuestSystem().getName())), - data); - } - catch (com.redhat.rhn.taskomatic.TaskomaticApiException e) { - throw new TaskomaticApiException(e.getMessage()); - } - } - - /** - * schedules the specified action on the guest - * @param loggedInUser The current user - * @param sid the id of the system - * @param state one of the following: 'start', 'suspend', 'resume', 'restart', - * 'shutdown' - * @return action ID - * - * @apidoc.doc Schedules a guest action for the specified virtual guest for the - * current time. - * @apidoc.param #session_key() - * @apidoc.param #param_desc("int", "sid", "the system Id of the guest") - * @apidoc.param #param_desc("string", "state", "One of the following actions 'start', - * 'suspend', 'resume', 'restart', 'shutdown'.") - * @apidoc.returntype #param_desc("int", "actionId", "The action id of the scheduled action") - */ - public int scheduleGuestAction(User loggedInUser, Integer sid, String state) { - return scheduleGuestAction(loggedInUser, sid, state, null); - } - /** * List the activation keys the system was registered with. * @param loggedInUser The current user diff --git a/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/test/SystemHandlerPtfTest.java b/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/test/SystemHandlerPtfTest.java index 220d742ad6d6..8071f2acca84 100644 --- a/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/test/SystemHandlerPtfTest.java +++ b/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/test/SystemHandlerPtfTest.java @@ -49,13 +49,11 @@ import com.suse.cloud.CloudPaygManager; import com.suse.cloud.test.TestCloudPaygManagerBuilder; import com.suse.manager.attestation.AttestationManager; -import com.suse.manager.virtualization.VirtManagerSalt; import com.suse.manager.webui.controllers.bootstrap.RegularMinionBootstrapper; import com.suse.manager.webui.controllers.bootstrap.SSHMinionBootstrapper; import com.suse.manager.webui.services.iface.MonitoringManager; import com.suse.manager.webui.services.iface.SaltApi; import com.suse.manager.webui.services.iface.SystemQuery; -import com.suse.manager.webui.services.iface.VirtManager; import com.suse.manager.webui.services.test.TestSaltApi; import com.suse.manager.webui.services.test.TestSystemQuery; @@ -116,11 +114,10 @@ public void setUp() throws Exception { XmlRpcSystemHelper xmlRpcHelper = new XmlRpcSystemHelper(regularBootstrapper, sshBootstrapper); ServerGroupManager groupManager = new ServerGroupManager(saltApi); - VirtManager virtManager = new VirtManagerSalt(saltApi); MonitoringManager monitoringManager = new FormulaMonitoringManager(saltApi); - SystemUnentitler unentitler = new SystemUnentitler(virtManager, monitoringManager, groupManager); - SystemEntitler entitler = new SystemEntitler(saltApi, virtManager, monitoringManager, groupManager); + SystemUnentitler unentitler = new SystemUnentitler(monitoringManager, groupManager); + SystemEntitler entitler = new SystemEntitler(saltApi, monitoringManager, groupManager); SystemEntitlementManager entitlementManager = new SystemEntitlementManager(unentitler, entitler); SystemManager systemManager = new SystemManager(ServerFactory.SINGLETON, ServerGroupFactory.SINGLETON, saltApi); diff --git a/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/test/SystemHandlerTest.java b/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/test/SystemHandlerTest.java index ca80165730ea..fdc9fe0264de 100644 --- a/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/test/SystemHandlerTest.java +++ b/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/test/SystemHandlerTest.java @@ -44,8 +44,6 @@ import com.redhat.rhn.domain.action.script.ScriptRunAction; import com.redhat.rhn.domain.action.server.ServerAction; import com.redhat.rhn.domain.action.server.test.ServerActionTest; -import com.redhat.rhn.domain.action.virtualization.VirtualizationSetMemoryGuestAction; -import com.redhat.rhn.domain.action.virtualization.VirtualizationSetVcpusGuestAction; import com.redhat.rhn.domain.channel.Channel; import com.redhat.rhn.domain.channel.ChannelFactory; import com.redhat.rhn.domain.channel.ChannelFamily; @@ -90,10 +88,7 @@ import com.redhat.rhn.domain.server.ServerGroup; import com.redhat.rhn.domain.server.ServerGroupFactory; import com.redhat.rhn.domain.server.ServerHistoryEvent; -import com.redhat.rhn.domain.server.VirtualInstance; -import com.redhat.rhn.domain.server.VirtualInstanceFactory; import com.redhat.rhn.domain.server.test.CPUTest; -import com.redhat.rhn.domain.server.test.GuestBuilder; import com.redhat.rhn.domain.server.test.MinionServerFactoryTest; import com.redhat.rhn.domain.server.test.NetworkInterfaceTest; import com.redhat.rhn.domain.server.test.ServerFactoryTest; @@ -106,7 +101,6 @@ import com.redhat.rhn.domain.token.test.ActivationKeyTest; import com.redhat.rhn.domain.user.User; import com.redhat.rhn.domain.user.UserFactory; -import com.redhat.rhn.frontend.context.Context; import com.redhat.rhn.frontend.dto.ErrataOverview; import com.redhat.rhn.frontend.dto.HistoryEvent; import com.redhat.rhn.frontend.dto.OperationDetailsDto; @@ -166,13 +160,11 @@ import com.suse.cloud.CloudPaygManager; import com.suse.cloud.test.TestCloudPaygManagerBuilder; import com.suse.manager.attestation.AttestationManager; -import com.suse.manager.virtualization.VirtManagerSalt; import com.suse.manager.webui.controllers.bootstrap.RegularMinionBootstrapper; import com.suse.manager.webui.controllers.bootstrap.SSHMinionBootstrapper; import com.suse.manager.webui.services.iface.MonitoringManager; import com.suse.manager.webui.services.iface.SaltApi; import com.suse.manager.webui.services.iface.SystemQuery; -import com.suse.manager.webui.services.iface.VirtManager; import com.suse.manager.webui.services.pillar.MinionCustomInfoPillarGenerator; import com.suse.manager.webui.services.test.TestSaltApi; import com.suse.manager.webui.services.test.TestSystemQuery; @@ -203,7 +195,6 @@ import java.util.Map; import java.util.Optional; import java.util.Set; -import java.util.TimeZone; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; @@ -225,11 +216,10 @@ public class SystemHandlerTest extends BaseHandlerTestCase { sshMinionBootstrapper ); private final ServerGroupManager serverGroupManager = new ServerGroupManager(saltApi); - private final VirtManager virtManager = new VirtManagerSalt(saltApi); private final MonitoringManager monitoringManager = new FormulaMonitoringManager(saltApi); private final SystemEntitlementManager systemEntitlementManager = new SystemEntitlementManager( - new SystemUnentitler(virtManager, monitoringManager, serverGroupManager), - new SystemEntitler(saltApi, virtManager, monitoringManager, serverGroupManager) + new SystemUnentitler(monitoringManager, serverGroupManager), + new SystemEntitler(saltApi, monitoringManager, serverGroupManager) ); private SystemManager systemManager = new SystemManager(ServerFactory.SINGLETON, ServerGroupFactory.SINGLETON, saltApi); @@ -2538,90 +2528,6 @@ public void testListSystemsWithPackage() { } - @Test - public void testScheduleGuestAction() throws Exception { - Context.getCurrentContext().setTimezone(TimeZone.getTimeZone("UTC")); - Server host = ServerFactoryTest.createTestServer(admin, true); - GuestBuilder build = new GuestBuilder(admin); - VirtualInstance guest = build.createGuest().withVirtHost().build(); - guest.setHostSystem(host); - - VirtualInstanceFactory.getInstance().saveVirtualInstance(guest); - - int id = handler.scheduleGuestAction(admin, - guest.getGuestSystem().getId().intValue(), "restart"); - - List actions = ActionFactory.listActionsForServer(admin, host); - - boolean contains = false; - for (Action act : actions) { - if (act.getId() == id) { - contains = true; - assertEquals(act.getActionType(), ActionFactory.TYPE_VIRTUALIZATION_REBOOT); - } - } - assertTrue(contains); - } - - @Test - public void testSetGuestMemory() throws Exception { - Context.getCurrentContext().setTimezone(TimeZone.getTimeZone("UTC")); - Server host = ServerFactoryTest.createTestServer(admin, true); - GuestBuilder build = new GuestBuilder(admin); - VirtualInstance guest = build.createGuest().withVirtHost().build(); - guest.setHostSystem(host); - - VirtualInstanceFactory.getInstance().saveVirtualInstance(guest); - - int id = handler.setGuestMemory(admin, - guest.getGuestSystem().getId().intValue(), 512); - - List actions = ActionFactory.listActionsForServer(admin, host); - - boolean contains = false; - for (Action act : actions) { - if (act.getId() == id) { - contains = true; - assertEquals(act.getActionType(), - ActionFactory.TYPE_VIRTUALIZATION_SET_MEMORY); - VirtualizationSetMemoryGuestAction action = HibernateFactory.getSession().load( - VirtualizationSetMemoryGuestAction.class, (long) id); - assertEquals(action.getMemory(), Integer.valueOf(512 * 1024)); - } - } - assertTrue(contains); - } - - - @Test - public void testSetGuestCpus() throws Exception { - Context.getCurrentContext().setTimezone(TimeZone.getTimeZone("UTC")); - Server host = ServerFactoryTest.createTestServer(admin, true); - GuestBuilder build = new GuestBuilder(admin); - VirtualInstance guest = build.createGuest().withVirtHost().build(); - guest.setHostSystem(host); - - VirtualInstanceFactory.getInstance().saveVirtualInstance(guest); - - int id = handler.setGuestCpus(admin, - guest.getGuestSystem().getId().intValue(), 3); - - List actions = ActionFactory.listActionsForServer(admin, host); - - boolean contains = false; - for (Action act : actions) { - if (act.getId() == id) { - contains = true; - assertEquals(act.getActionType(), - ActionFactory.TYPE_VIRTUALIZATION_SET_VCPUS); - VirtualizationSetVcpusGuestAction action = HibernateFactory.getSession().load( - VirtualizationSetVcpusGuestAction.class, (long) id); - assertEquals(action.getVcpu(), Integer.valueOf(3)); - } - } - assertTrue(contains); - } - @Test public void testListActivationKeys() throws Exception { Server server = ServerFactoryTest.createTestServer(admin, true); diff --git a/java/code/src/com/redhat/rhn/manager/action/ActionManager.java b/java/code/src/com/redhat/rhn/manager/action/ActionManager.java index 0c8c333787be..3e5d7fb0aeb7 100644 --- a/java/code/src/com/redhat/rhn/manager/action/ActionManager.java +++ b/java/code/src/com/redhat/rhn/manager/action/ActionManager.java @@ -38,8 +38,6 @@ import com.redhat.rhn.domain.action.dup.DistUpgradeAction; import com.redhat.rhn.domain.action.dup.DistUpgradeActionDetails; import com.redhat.rhn.domain.action.errata.ErrataAction; -import com.redhat.rhn.domain.action.image.DeployImageAction; -import com.redhat.rhn.domain.action.image.DeployImageActionDetails; import com.redhat.rhn.domain.action.kickstart.KickstartAction; import com.redhat.rhn.domain.action.kickstart.KickstartActionDetails; import com.redhat.rhn.domain.action.kickstart.KickstartGuestAction; @@ -64,7 +62,6 @@ import com.redhat.rhn.domain.errata.Errata; import com.redhat.rhn.domain.image.ImageProfile; import com.redhat.rhn.domain.image.ImageStore; -import com.redhat.rhn.domain.image.ProxyConfig; import com.redhat.rhn.domain.kickstart.KickstartData; import com.redhat.rhn.domain.kickstart.KickstartFactory; import com.redhat.rhn.domain.org.Org; @@ -105,7 +102,6 @@ import com.suse.manager.webui.controllers.utils.ContactMethodUtil; import com.suse.manager.webui.services.pillar.MinionPillarManager; -import org.apache.commons.codec.binary.Base64; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; @@ -718,43 +714,6 @@ public static Action createConfigAction(User user, Collection revisions, return createConfigActionForServers(user, revisions, servers, type, earliest); } - /** - * Schedule deployment of an image to a vhost. - * - * @return The created action - * @param user The user scheduling image deployment - * @param imageUrl The URL of the image to be deployed - * @param vcpus number of vcpus - * @param memkb memory in Kb - * @param bridge device - * @param proxy proxy configuration - */ - public static Action createDeployImageAction(User user, String imageUrl, - Long vcpus, Long memkb, String bridge, ProxyConfig proxy) { - DeployImageAction a = (DeployImageAction) ActionFactory - .createAction(ActionFactory.TYPE_DEPLOY_IMAGE); - if (user != null) { - a.setSchedulerUser(user); - a.setOrg(user.getOrg()); - } - - DeployImageActionDetails details = new DeployImageActionDetails(); - details.setParentAction(a); - details.setVcpus(vcpus); - details.setMemKb(memkb); - details.setBridgeDevice(bridge); - details.setDownloadUrl(imageUrl); - if (proxy != null) { - details.setProxyServer(proxy.getServer()); - details.setProxyUser(proxy.getUser()); - details.setProxyPass(new String(Base64.encodeBase64( - proxy.getPass().getBytes()))); - } - a.setDetails(details); - a.setName("Image Deployment: " + imageUrl); - return a; - } - /** * * @param user The user scheduling the action diff --git a/java/code/src/com/redhat/rhn/manager/action/test/ActionManagerTest.java b/java/code/src/com/redhat/rhn/manager/action/test/ActionManagerTest.java index c50637cf2bc5..52288a6be758 100644 --- a/java/code/src/com/redhat/rhn/manager/action/test/ActionManagerTest.java +++ b/java/code/src/com/redhat/rhn/manager/action/test/ActionManagerTest.java @@ -102,11 +102,9 @@ import com.redhat.rhn.testing.TestUtils; import com.redhat.rhn.testing.UserTestUtils; -import com.suse.manager.virtualization.VirtManagerSalt; import com.suse.manager.webui.services.iface.MonitoringManager; import com.suse.manager.webui.services.iface.SaltApi; import com.suse.manager.webui.services.iface.SystemQuery; -import com.suse.manager.webui.services.iface.VirtManager; import com.suse.manager.webui.services.test.TestSaltApi; import com.suse.manager.webui.services.test.TestSystemQuery; import com.suse.salt.netapi.calls.modules.Schedule; @@ -151,11 +149,10 @@ public class ActionManagerTest extends JMockBaseTestCaseWithUser { private final SystemQuery systemQuery = new TestSystemQuery(); private final SaltApi saltApi = new TestSaltApi(); private final ServerGroupManager serverGroupManager = new ServerGroupManager(saltApi); - private final VirtManager virtManager = new VirtManagerSalt(saltApi); private final MonitoringManager monitoringManager = new FormulaMonitoringManager(saltApi); private final SystemEntitlementManager systemEntitlementManager = new SystemEntitlementManager( - new SystemUnentitler(virtManager, monitoringManager, serverGroupManager), - new SystemEntitler(saltApi, virtManager, monitoringManager, serverGroupManager) + new SystemUnentitler(monitoringManager, serverGroupManager), + new SystemEntitler(saltApi, monitoringManager, serverGroupManager) ); private final SystemManager systemManager = new SystemManager(ServerFactory.SINGLETON, new ServerGroupFactory(), saltApi); diff --git a/java/code/src/com/redhat/rhn/manager/action/test/MinionActionManagerTest.java b/java/code/src/com/redhat/rhn/manager/action/test/MinionActionManagerTest.java index abd887c63e21..e538fc00aac9 100644 --- a/java/code/src/com/redhat/rhn/manager/action/test/MinionActionManagerTest.java +++ b/java/code/src/com/redhat/rhn/manager/action/test/MinionActionManagerTest.java @@ -58,13 +58,11 @@ import com.suse.cloud.CloudPaygManager; import com.suse.cloud.test.TestCloudPaygManagerBuilder; import com.suse.manager.attestation.AttestationManager; -import com.suse.manager.virtualization.VirtManagerSalt; import com.suse.manager.webui.controllers.bootstrap.RegularMinionBootstrapper; import com.suse.manager.webui.controllers.bootstrap.SSHMinionBootstrapper; import com.suse.manager.webui.services.iface.MonitoringManager; import com.suse.manager.webui.services.iface.SaltApi; import com.suse.manager.webui.services.iface.SystemQuery; -import com.suse.manager.webui.services.iface.VirtManager; import com.suse.manager.webui.services.test.TestSaltApi; import com.suse.manager.webui.services.test.TestSystemQuery; @@ -101,11 +99,10 @@ public class MinionActionManagerTest extends JMockBaseTestCaseWithUser { private final SystemQuery systemQuery = new TestSystemQuery(); private final SaltApi saltApi = new TestSaltApi(); private final ServerGroupManager serverGroupManager = new ServerGroupManager(saltApi); - private final VirtManager virtManager = new VirtManagerSalt(saltApi); private final MonitoringManager monitoringManager = new FormulaMonitoringManager(saltApi); private final SystemEntitlementManager systemEntitlementManager = new SystemEntitlementManager( - new SystemUnentitler(virtManager, monitoringManager, serverGroupManager), - new SystemEntitler(saltApi, virtManager, monitoringManager, serverGroupManager) + new SystemUnentitler(monitoringManager, serverGroupManager), + new SystemEntitler(saltApi, monitoringManager, serverGroupManager) ); private final CloudPaygManager paygManager = new TestCloudPaygManagerBuilder().build(); private final AttestationManager attestationManager = new AttestationManager(); diff --git a/java/code/src/com/redhat/rhn/manager/org/test/MigrationManagerTest.java b/java/code/src/com/redhat/rhn/manager/org/test/MigrationManagerTest.java index 00c375be999a..bc9e8657ae6b 100644 --- a/java/code/src/com/redhat/rhn/manager/org/test/MigrationManagerTest.java +++ b/java/code/src/com/redhat/rhn/manager/org/test/MigrationManagerTest.java @@ -47,10 +47,8 @@ import com.redhat.rhn.testing.ServerTestUtils; import com.redhat.rhn.testing.UserTestUtils; -import com.suse.manager.virtualization.VirtManagerSalt; import com.suse.manager.webui.services.iface.MonitoringManager; import com.suse.manager.webui.services.iface.SaltApi; -import com.suse.manager.webui.services.iface.VirtManager; import com.suse.manager.webui.services.test.TestSaltApi; import org.junit.jupiter.api.BeforeEach; @@ -75,11 +73,10 @@ public class MigrationManagerTest extends BaseTestCaseWithUser { private final SaltApi saltApi = new TestSaltApi(); private final ServerGroupManager serverGroupManager = new ServerGroupManager(saltApi); - private final VirtManager virtManager = new VirtManagerSalt(saltApi); private final MonitoringManager monitoringManager = new FormulaMonitoringManager(saltApi); private final SystemEntitlementManager systemEntitlementManager = new SystemEntitlementManager( - new SystemUnentitler(virtManager, monitoringManager, serverGroupManager), - new SystemEntitler(saltApi, virtManager, monitoringManager, serverGroupManager) + new SystemUnentitler(monitoringManager, serverGroupManager), + new SystemEntitler(saltApi, monitoringManager, serverGroupManager) ); private final MigrationManager migrationManager = new MigrationManager(serverGroupManager); diff --git a/java/code/src/com/redhat/rhn/manager/system/SystemManager.java b/java/code/src/com/redhat/rhn/manager/system/SystemManager.java index fa6f2a6c7335..8e704444856a 100644 --- a/java/code/src/com/redhat/rhn/manager/system/SystemManager.java +++ b/java/code/src/com/redhat/rhn/manager/system/SystemManager.java @@ -131,13 +131,11 @@ import com.suse.manager.ssl.SSLCertManager; import com.suse.manager.ssl.SSLCertPair; import com.suse.manager.utils.PagedSqlQueryBuilder; -import com.suse.manager.virtualization.VirtManagerSalt; import com.suse.manager.webui.controllers.StatesAPI; import com.suse.manager.webui.services.SaltStateGeneratorService; import com.suse.manager.webui.services.StateRevisionService; import com.suse.manager.webui.services.iface.MonitoringManager; import com.suse.manager.webui.services.iface.SaltApi; -import com.suse.manager.webui.services.iface.VirtManager; import com.suse.manager.webui.services.impl.SaltSSHService; import com.suse.manager.webui.services.impl.runner.MgrUtilRunner; import com.suse.manager.webui.utils.YamlHelper; @@ -218,11 +216,10 @@ public SystemManager(ServerFactory serverFactoryIn, ServerGroupFactory serverGro this.serverGroupFactory = serverGroupFactoryIn; this.saltApi = saltApiIn; ServerGroupManager serverGroupManager = new ServerGroupManager(saltApiIn); - VirtManager virtManager = new VirtManagerSalt(saltApi); MonitoringManager monitoringManager = new FormulaMonitoringManager(saltApi); systemEntitlementManager = new SystemEntitlementManager( - new SystemUnentitler(virtManager, monitoringManager, serverGroupManager), - new SystemEntitler(saltApiIn, virtManager, monitoringManager, serverGroupManager) + new SystemUnentitler(monitoringManager, serverGroupManager), + new SystemEntitler(saltApiIn, monitoringManager, serverGroupManager) ); } diff --git a/java/code/src/com/redhat/rhn/manager/system/VirtualInstanceManager.java b/java/code/src/com/redhat/rhn/manager/system/VirtualInstanceManager.java index debd9100e1a8..f1423cc080b8 100644 --- a/java/code/src/com/redhat/rhn/manager/system/VirtualInstanceManager.java +++ b/java/code/src/com/redhat/rhn/manager/system/VirtualInstanceManager.java @@ -24,7 +24,6 @@ import com.suse.manager.utils.SaltUtils; import com.suse.manager.webui.utils.salt.custom.VmInfo; -import com.suse.manager.webui.websocket.VirtNotifications; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -194,7 +193,6 @@ public static void deleteGuestVirtualInstance(VirtualInstance virtualInstance) { else { VirtualInstanceFactory.getInstance().deleteVirtualInstanceOnly(virtualInstance); } - VirtNotifications.spreadRefresh("guest"); } /** @@ -266,8 +264,6 @@ public static void addGuestVirtualInstance(String vmGuid, String name, VirtualInstanceFactory.getInstance() .saveVirtualInstance(virtualInstance); - - VirtNotifications.spreadRefresh("guest"); } else { log.warn("Preventing creation of a duplicated VirtualInstance for 'uuid': {}", vmGuid); @@ -345,8 +341,6 @@ public static void updateGuestVirtualInstanceProperties(VirtualInstance virtualI virtualInstance.setNumberOfCPUs(vCpus); virtualInstance.setTotalMemory(memory); VirtualInstanceFactory.getInstance().saveVirtualInstance(virtualInstance); - - VirtNotifications.spreadRefresh("guest"); } /** diff --git a/java/code/src/com/redhat/rhn/manager/system/entitling/SystemEntitler.java b/java/code/src/com/redhat/rhn/manager/system/entitling/SystemEntitler.java index e51f8da78843..a9b74837ec28 100644 --- a/java/code/src/com/redhat/rhn/manager/system/entitling/SystemEntitler.java +++ b/java/code/src/com/redhat/rhn/manager/system/entitling/SystemEntitler.java @@ -19,21 +19,16 @@ import com.redhat.rhn.common.validator.ValidatorException; import com.redhat.rhn.common.validator.ValidatorResult; import com.redhat.rhn.domain.entitlement.Entitlement; -import com.redhat.rhn.domain.server.MinionServer; import com.redhat.rhn.domain.server.Server; import com.redhat.rhn.domain.server.ServerFactory; import com.redhat.rhn.domain.server.ServerGroup; import com.redhat.rhn.domain.server.ServerGroupFactory; -import com.redhat.rhn.domain.server.VirtualInstanceFactory; import com.redhat.rhn.manager.entitlement.EntitlementManager; import com.redhat.rhn.manager.system.ServerGroupManager; -import com.redhat.rhn.manager.system.VirtualInstanceManager; import com.suse.manager.webui.services.iface.MonitoringManager; import com.suse.manager.webui.services.iface.SaltApi; -import com.suse.manager.webui.services.iface.VirtManager; import com.suse.manager.webui.services.impl.SaltSSHService; -import com.suse.manager.webui.services.pillar.MinionPillarManager; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -50,20 +45,17 @@ public class SystemEntitler { private static final Logger LOG = LogManager.getLogger(SystemEntitler.class); private SaltApi saltApi; - private VirtManager virtManager; private MonitoringManager monitoringManager; private ServerGroupManager serverGroupManager; /** * @param saltApiIn instance for gathering data from a system. - * @param virtManagerIn instance for managing virtual machines. * @param monitoringManagerIn instance for handling monitoring configuration. * @param serverGroupManagerIn */ - public SystemEntitler(SaltApi saltApiIn, VirtManager virtManagerIn, + public SystemEntitler(SaltApi saltApiIn, MonitoringManager monitoringManagerIn, ServerGroupManager serverGroupManagerIn) { this.saltApi = saltApiIn; - this.virtManager = virtManagerIn; this.monitoringManager = monitoringManagerIn; this.serverGroupManager = serverGroupManagerIn; } @@ -113,13 +105,6 @@ else if (EntitlementManager.OSIMAGE_BUILD_HOST.equals(ent)) { server.asMinionServer().ifPresent(minion -> { serverGroupManager.updatePillarAfterGroupUpdateForServers(Arrays.asList(minion)); - if (wasVirtEntitled && !EntitlementManager.VIRTUALIZATION.equals(ent) || - !wasVirtEntitled && EntitlementManager.VIRTUALIZATION.equals(ent)) { - this.updateLibvirtEngine(minion); - MinionPillarManager.INSTANCE.generatePillar(minion, false, - MinionPillarManager.PillarSubset.VIRTUALIZATION); - } - if (EntitlementManager.MONITORING.equals(ent)) { try { monitoringManager.enableMonitoring(minion); @@ -192,10 +177,4 @@ private Optional findServerGroupToEntitleAnEntitledServer(Server se } return serverGroup; } - - private void updateLibvirtEngine(MinionServer minion) { - VirtualInstanceManager.updateHostVirtualInstance(minion, - VirtualInstanceFactory.getInstance().getFullyVirtType()); - virtManager.updateLibvirtEngine(minion); - } } diff --git a/java/code/src/com/redhat/rhn/manager/system/entitling/SystemUnentitler.java b/java/code/src/com/redhat/rhn/manager/system/entitling/SystemUnentitler.java index 1386165c21b0..87e33f37152c 100644 --- a/java/code/src/com/redhat/rhn/manager/system/entitling/SystemUnentitler.java +++ b/java/code/src/com/redhat/rhn/manager/system/entitling/SystemUnentitler.java @@ -24,8 +24,6 @@ import com.redhat.rhn.manager.system.ServerGroupManager; import com.suse.manager.webui.services.iface.MonitoringManager; -import com.suse.manager.webui.services.iface.VirtManager; -import com.suse.manager.webui.services.pillar.MinionPillarManager; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -42,17 +40,14 @@ public class SystemUnentitler { private static final Logger LOG = LogManager.getLogger(SystemUnentitler.class); private final MonitoringManager monitoringManager; - private final VirtManager virtManager; private final ServerGroupManager serverGroupManager; /** - * @param virtManagerIn instance for managing virtual machines. * @param monitoringManagerIn instance for handling monitoring configuration. * @param serverGroupManagerIn */ - public SystemUnentitler(VirtManager virtManagerIn, MonitoringManager monitoringManagerIn, + public SystemUnentitler(MonitoringManager monitoringManagerIn, ServerGroupManager serverGroupManagerIn) { - this.virtManager = virtManagerIn; this.monitoringManager = monitoringManagerIn; this.serverGroupManager = serverGroupManagerIn; } @@ -97,12 +92,6 @@ public void removeServerEntitlement(Server server, Entitlement ent) { LOG.warn("Error disabling monitoring: {}", e.getMessage()); } } - - if (EntitlementManager.VIRTUALIZATION.equals(ent)) { - virtManager.updateLibvirtEngine(s); - MinionPillarManager.INSTANCE.generatePillar(s, false, - MinionPillarManager.PillarSubset.VIRTUALIZATION); - } }); } diff --git a/java/code/src/com/redhat/rhn/manager/system/entitling/test/SystemEntitlementManagerTest.java b/java/code/src/com/redhat/rhn/manager/system/entitling/test/SystemEntitlementManagerTest.java index e93ed630dad7..942a90141802 100644 --- a/java/code/src/com/redhat/rhn/manager/system/entitling/test/SystemEntitlementManagerTest.java +++ b/java/code/src/com/redhat/rhn/manager/system/entitling/test/SystemEntitlementManagerTest.java @@ -38,9 +38,7 @@ import com.redhat.rhn.testing.TestUtils; import com.redhat.rhn.testing.UserTestUtils; -import com.suse.manager.virtualization.VirtManagerSalt; import com.suse.manager.webui.services.iface.MonitoringManager; -import com.suse.manager.webui.services.iface.VirtManager; import com.suse.manager.webui.services.impl.SaltSSHService; import com.suse.manager.webui.services.impl.SaltService; import com.suse.salt.netapi.datatypes.target.MinionList; @@ -62,11 +60,10 @@ public void setUp() throws Exception { setImposteriser(ByteBuddyClassImposteriser.INSTANCE); saltServiceMock = mock(SaltService.class); ServerGroupManager serverGroupManager = new ServerGroupManager(saltServiceMock); - VirtManager virtManager = new VirtManagerSalt(saltServiceMock); MonitoringManager monitoringManager = new FormulaMonitoringManager(saltServiceMock); systemEntitlementManager = new SystemEntitlementManager( - new SystemUnentitler(virtManager, monitoringManager, serverGroupManager), - new SystemEntitler(saltServiceMock, virtManager, monitoringManager, serverGroupManager) + new SystemUnentitler(monitoringManager, serverGroupManager), + new SystemEntitler(saltServiceMock, monitoringManager, serverGroupManager) ); context().checking(new Expectations() {{ allowing(saltServiceMock).refreshPillar(with(any(MinionList.class))); diff --git a/java/code/src/com/redhat/rhn/manager/system/test/AnsibleManagerTest.java b/java/code/src/com/redhat/rhn/manager/system/test/AnsibleManagerTest.java index 57cf112651c7..df9ce3562db5 100644 --- a/java/code/src/com/redhat/rhn/manager/system/test/AnsibleManagerTest.java +++ b/java/code/src/com/redhat/rhn/manager/system/test/AnsibleManagerTest.java @@ -39,10 +39,8 @@ import com.redhat.rhn.testing.TestUtils; import com.redhat.rhn.testing.UserTestUtils; -import com.suse.manager.virtualization.VirtManagerSalt; import com.suse.manager.webui.services.iface.MonitoringManager; import com.suse.manager.webui.services.iface.SaltApi; -import com.suse.manager.webui.services.iface.VirtManager; import com.suse.manager.webui.utils.salt.custom.AnsiblePlaybookSlsResult; import com.suse.salt.netapi.calls.LocalCall; import com.suse.salt.netapi.datatypes.target.MinionList; @@ -464,12 +462,11 @@ public void testIntrospectInventoryInPlaybook() throws Exception { } private MinionServer createAnsibleControlNode(User user) throws Exception { - VirtManager virtManager = new VirtManagerSalt(saltApi); MonitoringManager monitoringManager = new FormulaMonitoringManager(saltApi); ServerGroupManager groupManager = new ServerGroupManager(saltApi); SystemEntitlementManager entitlementManager = new SystemEntitlementManager( - new SystemUnentitler(virtManager, monitoringManager, groupManager), - new SystemEntitler(saltApi, virtManager, monitoringManager, groupManager) + new SystemUnentitler(monitoringManager, groupManager), + new SystemEntitler(saltApi, monitoringManager, groupManager) ); context.checking(new Expectations() {{ diff --git a/java/code/src/com/redhat/rhn/manager/system/test/SystemManagerTest.java b/java/code/src/com/redhat/rhn/manager/system/test/SystemManagerTest.java index d3c3c3fd0929..b73b309b6b35 100644 --- a/java/code/src/com/redhat/rhn/manager/system/test/SystemManagerTest.java +++ b/java/code/src/com/redhat/rhn/manager/system/test/SystemManagerTest.java @@ -132,11 +132,9 @@ import com.suse.manager.metrics.SystemsCollector; import com.suse.manager.ssl.SSLCertManager; import com.suse.manager.ssl.SSLCertPair; -import com.suse.manager.virtualization.test.TestVirtManager; import com.suse.manager.webui.controllers.utils.ContactMethodUtil; import com.suse.manager.webui.services.iface.MonitoringManager; import com.suse.manager.webui.services.iface.SaltApi; -import com.suse.manager.webui.services.iface.VirtManager; import com.suse.manager.webui.services.impl.SaltSSHService; import com.suse.manager.webui.services.impl.SaltService; import com.suse.manager.webui.services.impl.runner.MgrUtilRunner; @@ -216,12 +214,11 @@ public void setUp() throws Exception { } }); SaltApi saltApi = new TestSaltApi(); - VirtManager virtManager = new TestVirtManager(); MonitoringManager monitoringManager = new FormulaMonitoringManager(saltApi); ServerGroupManager serverGroupManager = new ServerGroupManager(saltApi); systemEntitlementManager = new SystemEntitlementManager( - new SystemUnentitler(virtManager, monitoringManager, serverGroupManager), - new SystemEntitler(saltApi, virtManager, monitoringManager, serverGroupManager) + new SystemUnentitler(monitoringManager, serverGroupManager), + new SystemEntitler(saltApi, monitoringManager, serverGroupManager) ); this.systemManager = new SystemManager(ServerFactory.SINGLETON, ServerGroupFactory.SINGLETON, saltServiceMock); createMetadataFiles(); diff --git a/java/code/src/com/redhat/rhn/taskomatic/task/payg/test/PaygComputeDimensionsTaskTest.java b/java/code/src/com/redhat/rhn/taskomatic/task/payg/test/PaygComputeDimensionsTaskTest.java index 6aaa13e88e96..28111beb8852 100644 --- a/java/code/src/com/redhat/rhn/taskomatic/task/payg/test/PaygComputeDimensionsTaskTest.java +++ b/java/code/src/com/redhat/rhn/taskomatic/task/payg/test/PaygComputeDimensionsTaskTest.java @@ -41,10 +41,8 @@ import com.suse.cloud.domain.PaygDimensionComputation; import com.suse.cloud.domain.PaygDimensionFactory; import com.suse.cloud.test.TestCloudPaygManagerBuilder; -import com.suse.manager.virtualization.VirtManagerSalt; import com.suse.manager.webui.services.iface.MonitoringManager; import com.suse.manager.webui.services.iface.SaltApi; -import com.suse.manager.webui.services.iface.VirtManager; import com.suse.manager.webui.services.test.TestSaltApi; import org.junit.jupiter.api.BeforeEach; @@ -74,12 +72,11 @@ public void before() { SaltApi saltApi = new TestSaltApi(); ServerGroupManager serverGroupManager = new ServerGroupManager(saltApi); - VirtManager virtManager = new VirtManagerSalt(saltApi); MonitoringManager monitoringManager = new FormulaMonitoringManager(saltApi); systemEntitlementManager = new SystemEntitlementManager( - new SystemUnentitler(virtManager, monitoringManager, serverGroupManager), - new SystemEntitler(saltApi, virtManager, monitoringManager, serverGroupManager) + new SystemUnentitler(monitoringManager, serverGroupManager), + new SystemEntitler(saltApi, monitoringManager, serverGroupManager) ); } diff --git a/java/code/src/com/suse/manager/matcher/test/MatcherJsonIOTest.java b/java/code/src/com/suse/manager/matcher/test/MatcherJsonIOTest.java index 1d75e0fe7197..bd89402e54b8 100644 --- a/java/code/src/com/suse/manager/matcher/test/MatcherJsonIOTest.java +++ b/java/code/src/com/suse/manager/matcher/test/MatcherJsonIOTest.java @@ -31,7 +31,6 @@ import com.redhat.rhn.domain.rhnpackage.PackageFactory; import com.redhat.rhn.domain.server.CPU; import com.redhat.rhn.domain.server.InstalledProduct; -import com.redhat.rhn.domain.server.MinionServer; import com.redhat.rhn.domain.server.PinnedSubscription; import com.redhat.rhn.domain.server.Server; import com.redhat.rhn.domain.server.ServerFactory; @@ -53,10 +52,8 @@ import com.suse.manager.maintenance.BaseProductManager; import com.suse.manager.matcher.MatcherJsonIO; -import com.suse.manager.virtualization.test.TestVirtManager; import com.suse.manager.webui.services.iface.MonitoringManager; import com.suse.manager.webui.services.iface.SaltApi; -import com.suse.manager.webui.services.iface.VirtManager; import com.suse.manager.webui.services.test.TestSaltApi; import com.suse.matcher.json.MatchJson; import com.suse.matcher.json.ProductJson; @@ -110,17 +107,12 @@ public void setUp() throws Exception { super.setUp(); setImposteriser(ByteBuddyClassImposteriser.INSTANCE); - VirtManager virtManager = new TestVirtManager() { - @Override - public void updateLibvirtEngine(MinionServer minion) { - } - }; SaltApi saltApi = new TestSaltApi(); MonitoringManager monitoringManager = new FormulaMonitoringManager(saltApi); ServerGroupManager serverGroupManager = new ServerGroupManager(saltApi); systemEntitlementManager = new SystemEntitlementManager( - new SystemUnentitler(virtManager, monitoringManager, serverGroupManager), - new SystemEntitler(saltApi, virtManager, monitoringManager, serverGroupManager) + new SystemUnentitler(monitoringManager, serverGroupManager), + new SystemEntitler(saltApi, monitoringManager, serverGroupManager) ); baseProductManagerMock = mock(BaseProductManager.class); diff --git a/java/code/src/com/suse/manager/reactor/SaltReactor.java b/java/code/src/com/suse/manager/reactor/SaltReactor.java index da14cd785180..92a4a9a5bb16 100644 --- a/java/code/src/com/suse/manager/reactor/SaltReactor.java +++ b/java/code/src/com/suse/manager/reactor/SaltReactor.java @@ -27,7 +27,6 @@ import com.suse.cloud.CloudPaygManager; import com.suse.manager.attestation.AttestationManager; -import com.suse.manager.reactor.messaging.AbstractLibvirtEngineMessage; import com.suse.manager.reactor.messaging.ApplyStatesEventMessage; import com.suse.manager.reactor.messaging.ApplyStatesEventMessageAction; import com.suse.manager.reactor.messaging.BatchStartedEventMessage; @@ -38,13 +37,6 @@ import com.suse.manager.reactor.messaging.ImageSyncedEventMessageAction; import com.suse.manager.reactor.messaging.JobReturnEventMessage; import com.suse.manager.reactor.messaging.JobReturnEventMessageAction; -import com.suse.manager.reactor.messaging.LibvirtEngineDomainLifecycleMessage; -import com.suse.manager.reactor.messaging.LibvirtEngineDomainLifecycleMessageAction; -import com.suse.manager.reactor.messaging.LibvirtEngineNetworkLifecycleMessage; -import com.suse.manager.reactor.messaging.LibvirtEngineNetworkMessageAction; -import com.suse.manager.reactor.messaging.LibvirtEnginePoolLifecycleMessage; -import com.suse.manager.reactor.messaging.LibvirtEnginePoolMessageAction; -import com.suse.manager.reactor.messaging.LibvirtEnginePoolRefreshMessage; import com.suse.manager.reactor.messaging.RefreshGeneratedSaltFilesEventMessage; import com.suse.manager.reactor.messaging.RefreshGeneratedSaltFilesEventMessageAction; import com.suse.manager.reactor.messaging.RegisterMinionEventMessage; @@ -57,11 +49,9 @@ import com.suse.manager.saltboot.PXEEventMessage; import com.suse.manager.saltboot.PXEEventMessageAction; import com.suse.manager.utils.SaltUtils; -import com.suse.manager.virtualization.VirtManagerSalt; import com.suse.manager.webui.services.SaltServerActionService; import com.suse.manager.webui.services.iface.SaltApi; import com.suse.manager.webui.services.iface.SystemQuery; -import com.suse.manager.webui.services.iface.VirtManager; import com.suse.manager.webui.utils.salt.custom.ImageDeployedEvent; import com.suse.manager.webui.utils.salt.custom.ImageSyncedEvent; import com.suse.manager.webui.utils.salt.custom.MinionStartupGrains; @@ -69,7 +59,6 @@ import com.suse.salt.netapi.datatypes.Event; import com.suse.salt.netapi.event.BatchStartedEvent; import com.suse.salt.netapi.event.BeaconEvent; -import com.suse.salt.netapi.event.EngineEvent; import com.suse.salt.netapi.event.EventStream; import com.suse.salt.netapi.event.JobReturnEvent; import com.suse.salt.netapi.event.MinionStartEvent; @@ -128,8 +117,6 @@ public SaltReactor(SaltApi saltApiIn, SystemQuery systemQueryIn, SaltServerActio * Start the salt reactor. */ public void start() { - VirtManager virtManager = new VirtManagerSalt(saltApi); - // Configure message queue to handle minion registrations MessageQueue.registerAction(new RegisterMinionEventMessageAction(systemQuery, saltApi, paygMgr, attestationMgr), RegisterMinionEventMessage.class); @@ -145,14 +132,6 @@ public void start() { SystemIdGenerateEventMessage.class); MessageQueue.registerAction(new ImageDeployedEventMessageAction(systemQuery), ImageDeployedEventMessage.class); - MessageQueue.registerAction(new LibvirtEngineDomainLifecycleMessageAction(virtManager), - LibvirtEngineDomainLifecycleMessage.class); - MessageQueue.registerAction(new LibvirtEnginePoolMessageAction(), - LibvirtEnginePoolLifecycleMessage.class); - MessageQueue.registerAction(new LibvirtEnginePoolMessageAction(), - LibvirtEnginePoolRefreshMessage.class); - MessageQueue.registerAction(new LibvirtEngineNetworkMessageAction(), - LibvirtEngineNetworkLifecycleMessage.class); MessageQueue.registerAction(new BatchStartedEventMessageAction(), BatchStartedEventMessage.class); MessageQueue.registerAction(new ImageSyncedEventMessageAction(), @@ -204,10 +183,9 @@ private Stream eventToMessages(Event event) { ImageDeployedEvent.parse(event).map(this::eventToMessages).orElseGet(() -> ImageSyncedEvent.parse(event).map(this::eventToMessages).orElseGet(() -> PXEEvent.parse(event).map(this::eventToMessages).orElseGet(() -> - EngineEvent.parse(event).map(this::eventToMessages).orElseGet(() -> BeaconEvent.parse(event).map(this::eventToMessages).orElse( empty() - ))))))))); + )))))))); } /** @@ -270,30 +248,6 @@ private Stream eventToMessages(MinionStartEvent minionStartEvent) ); } - /** - * Trigger handling of engine events - * - * @param engineEvent engine event - * @return event handler runnable - */ - private Stream eventToMessages(EngineEvent engineEvent) { - if ("libvirt_events".equals(engineEvent.getEngine())) { - try { - AbstractLibvirtEngineMessage message = AbstractLibvirtEngineMessage.create(engineEvent); - if (message != null) { - return of(message); - } - else { - LOG.debug("Unhandled libvirt engine event:{}", engineEvent.getAdditional()); - } - } - catch (IllegalArgumentException e) { - LOG.warn("Invalid libvirt engine event: {}", engineEvent.getAdditional()); - } - } - return empty(); - } - /** * Trigger handling of job return events. * diff --git a/java/code/src/com/suse/manager/reactor/messaging/AbstractLibvirtEngineMessage.java b/java/code/src/com/suse/manager/reactor/messaging/AbstractLibvirtEngineMessage.java deleted file mode 100644 index ac2227728bce..000000000000 --- a/java/code/src/com/suse/manager/reactor/messaging/AbstractLibvirtEngineMessage.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright (c) 2018 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.suse.manager.reactor.messaging; - -import com.redhat.rhn.common.hibernate.HibernateFactory; -import com.redhat.rhn.common.messaging.EventDatabaseMessage; -import com.redhat.rhn.common.messaging.EventMessage; - -import com.suse.salt.netapi.event.EngineEvent; - -import com.google.gson.JsonElement; - -import org.hibernate.Transaction; - -import java.util.Arrays; -import java.util.List; -import java.util.Optional; - -/** - * Libvirt_events engine message to handle - */ -public abstract class AbstractLibvirtEngineMessage implements EventMessage, EventDatabaseMessage { - - private static final int LIBVIRT_EVENTS_ADDITIONAL_PARTS_COUNT = 3; - - private String connection; - private Optional minionId; - private String timestamp; - private Transaction txn; - - /** - * Parse the engine event if it is a libvirt_events one. - * - * @param engineEvent the event to parse - * @return the corresponding event message or null if not handled - * - * @throws IllegalArgumentException if the event is invalid - */ - public static AbstractLibvirtEngineMessage create(EngineEvent engineEvent) throws IllegalArgumentException { - List additionalParts = Arrays.asList(engineEvent.getAdditional().split("/")); - if (additionalParts.size() < LIBVIRT_EVENTS_ADDITIONAL_PARTS_COUNT) { - throw new IllegalArgumentException("Invalid libvirt engine event: " + engineEvent.getAdditional()); - } - String eventType = additionalParts.get(additionalParts.size() - 1); - String objectType = additionalParts.get(additionalParts.size() - 2); - String connection = String.join("/", additionalParts.subList(0, additionalParts.size() - 2)); - - if ("domain".equals(objectType)) { - return LibvirtEngineDomainMessage.createDomainMessage(connection, - eventType, engineEvent.getMinionId(), engineEvent.getTimestamp(), - engineEvent.getData(JsonElement.class)); - } - else if ("pool".equals(objectType)) { - return LibvirtEnginePoolMessage.createPoolMessage(connection, - eventType, engineEvent.getMinionId(), engineEvent.getTimestamp(), - engineEvent.getData(JsonElement.class)); - } - else if ("network".equals(objectType)) { - return LibvirtEngineNetworkMessage.createNetworkMessage(connection, - eventType, engineEvent.getMinionId(), engineEvent.getTimestamp(), - engineEvent.getData(JsonElement.class)); - } - return null; - } - - /** - * @return the libvirt connection of the event (not in an URI format) - */ - public String getConnection() { - return connection; - } - - /** - * @return the ID of the minion that generated the message or empty if - * the message was generated by the master - */ - public Optional getMinionId() { - return minionId; - } - - /** - * @return the timestamp of the event - */ - public String getTimestamp() { - return timestamp; - } - - @Override - public Long getUserId() { - return null; - } - - /** - * - * {@inheritDoc} - */ - @Override - public Transaction getTransaction() { - return txn; - } - - @Override - public String toText() { - return toString(); - } - - @Override - public String toString() { - String origin = minionId.orElse("master"); - return this.getClass().getName() + "[" + origin + "]"; - } - - protected AbstractLibvirtEngineMessage(String connectIn, Optional minionIdIn, - String timestampIn) { - this.connection = connectIn; - this.minionId = minionIdIn; - this.timestamp = timestampIn; - - this.txn = HibernateFactory.getSession().getTransaction(); - } -} diff --git a/java/code/src/com/suse/manager/reactor/messaging/LibvirtEngineDomainLifecycleMessage.java b/java/code/src/com/suse/manager/reactor/messaging/LibvirtEngineDomainLifecycleMessage.java deleted file mode 100644 index ca63ba18747e..000000000000 --- a/java/code/src/com/suse/manager/reactor/messaging/LibvirtEngineDomainLifecycleMessage.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2018 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.suse.manager.reactor.messaging; - -import com.google.gson.JsonElement; - -import java.util.Optional; - -/** - * - * LibvirtEngineDomainLifecycleMessage - */ -public class LibvirtEngineDomainLifecycleMessage extends LibvirtEngineDomainMessage { - - private String event; - private String detail; - - /** - * @return the domain lifecycle event type (start, destroy, etc) - */ - public String getEvent() { - return event; - } - - /** - * @return the domain lifecycle event detail, mostly indicating the - * reason of the event - */ - public String getDetail() { - return detail; - } - - @Override - public String toString() { - return super.toString() + "[" + event + "]"; - } - - protected LibvirtEngineDomainLifecycleMessage(String connection, - Optional minionId, String timestamp, JsonElement data) { - super(connection, minionId, timestamp, data); - - this.event = data.getAsJsonObject().get("event").getAsString(); - this.detail = data.getAsJsonObject().get("detail").getAsString(); - } -} diff --git a/java/code/src/com/suse/manager/reactor/messaging/LibvirtEngineDomainLifecycleMessageAction.java b/java/code/src/com/suse/manager/reactor/messaging/LibvirtEngineDomainLifecycleMessageAction.java deleted file mode 100644 index ee28e711ea71..000000000000 --- a/java/code/src/com/suse/manager/reactor/messaging/LibvirtEngineDomainLifecycleMessageAction.java +++ /dev/null @@ -1,202 +0,0 @@ -/* - * Copyright (c) 2018 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.suse.manager.reactor.messaging; - -import com.redhat.rhn.common.messaging.EventMessage; -import com.redhat.rhn.common.messaging.MessageAction; -import com.redhat.rhn.domain.server.MinionServerFactory; -import com.redhat.rhn.domain.server.VirtualInstance; -import com.redhat.rhn.domain.server.VirtualInstanceFactory; -import com.redhat.rhn.domain.server.VirtualInstanceState; -import com.redhat.rhn.manager.system.VirtualInstanceManager; - -import com.suse.manager.virtualization.GuestDefinition; -import com.suse.manager.webui.services.iface.VirtManager; -import com.suse.manager.webui.websocket.VirtNotifications; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; - -/** - * Virt Engine Domain Lifecycle Event Action Handler - */ -public class LibvirtEngineDomainLifecycleMessageAction implements MessageAction { - - private static final Logger LOG = LogManager.getLogger(LibvirtEngineDomainLifecycleMessageAction.class); - - private final VirtManager virtManager; - private final List toRestart = new ArrayList<>(); - - /** - * @param virtManagerIn instance to manage virtualization - */ - public LibvirtEngineDomainLifecycleMessageAction(VirtManager virtManagerIn) { - this.virtManager = virtManagerIn; - } - - @Override - public void execute(EventMessage msg) { - LibvirtEngineDomainLifecycleMessage message = (LibvirtEngineDomainLifecycleMessage)msg; - - if (message.getMinionId().isPresent()) { - String minionId = message.getMinionId().get(); - String event = message.getEvent(); - - MinionServerFactory.findByMinionId(minionId).ifPresent(minion -> { - LOG.debug("Processing {}/{} on minion {}", message.getEvent(), message.getDetail(), minionId); - VirtualInstanceManager.updateHostVirtualInstance(minion, - VirtualInstanceFactory.getInstance().getFullyVirtType()); - - final String guid = VirtualInstanceManager.fixUuidIfSwappedUuidExists( - message.getDomainUUID().replaceAll("-", "")); - - VirtNotifications.spreadGuestEvent(minion.getId(), guid, event, message.getDetail()); - - List vms = VirtualInstanceFactory.getInstance().lookupVirtualInstanceByUuid(guid); - if (vms.isEmpty()) { - // We got a machine created from outside SUMA, - // ask Salt for details on it to create it - Optional result = virtManager.getGuestDefinition( - minionId, message.getDomainUUID()); - - result.ifPresent(def -> { - VirtualInstanceState state = VirtualInstanceFactory.getInstance().getStoppedState(); - if (Arrays.asList("started", "resumed").contains(event)) { - state = VirtualInstanceFactory.getInstance().getRunningState(); - } - - LOG.debug("Adding VM {} with state to {}", def.getName(), state.getLabel()); - VirtualInstanceManager.addGuestVirtualInstance(def.getUuid().replaceAll("-", ""), - def.getName(), def.getVirtualInstanceType(), state, minion, null, - def.getVcpu().getMax(), def.getMaxMemory() / 1024); - - // Check if the defined VM will require a manual restart - if (def.isRequiresRestart()) { - watchVirtualMachine(minionId, message.getDomainName()); - } - }); - } - else if (vms.size() == 1) { - // There shouldn't be two VMs with the same UUID across the world - VirtualInstance vm = vms.get(0); - List stoppedEvents = Arrays.asList("defined", "stopped", "shutdown"); - List runningEvents = Arrays.asList("started", "resumed"); - List pausedEvents = Arrays.asList("suspended", "pmsuspended"); - List crashedEvents = Collections.singletonList("crashed"); - - Map, VirtualInstanceState> statesMap = new HashMap<>(); - statesMap.put(stoppedEvents, VirtualInstanceFactory.getInstance().getStoppedState()); - statesMap.put(runningEvents, VirtualInstanceFactory.getInstance().getRunningState()); - statesMap.put(pausedEvents, VirtualInstanceFactory.getInstance().getPausedState()); - statesMap.put(crashedEvents, VirtualInstanceFactory.getInstance().getCrashedState()); - - VirtualInstanceState state = statesMap.entrySet().stream() - .filter(entry -> entry.getKey().contains(event)) - .map(Map.Entry::getValue) - .findFirst().orElse(vms.get(0).getState()); - - LOG.debug("Changing VM {} state to {}", vm, state.getLabel()); - - // At the end of a migration we get a stopped/migrated event from the source host - // and a resumed/migrated event from the target host. - // Skip the stopped event since we will update the virtual host in the resumed one. - boolean migrated = message.getDetail().equals("migrated"); - if (migrated && event.equals("stopped")) { - return; - } - - // We need to check if the VM is still defined and delete it if needed - if (!migrated && Arrays.asList("undefined", "stopped", "shutdown", "crashed").contains(event) && - virtManager.getGuestDefinition(minionId, message.getDomainUUID()).isEmpty()) { - // Ensure the state is updated since this could be shown for stopped cluster VMs - if (vm.isRegisteredGuest()) { - VirtualInstanceManager.updateGuestVirtualInstance(vm, vm.getName(), state, null, - vm.getGuestSystem(), vm.getNumberOfCPUs(), vm.getTotalMemory()); - } - VirtualInstanceManager.deleteGuestVirtualInstance(vm); - unwatchVirtualMachine(minionId, message.getDomainName()); - } - else { - // Update the host when getting the event of the end of a live migration - // or if the server doesn't our record. This could happen if the hypervisor has been fenced - // and the VM moved to another hypervisor in the cluster. - boolean changedHost = event.equals("started") && !message.getDetail().equals("migrated") && - (vm.getHostSystem() == null || !vm.getHostSystem().getId().equals(minion.getId())); - if (migrated && event.equals("resumed") || changedHost) { - VirtualInstanceManager.updateGuestVirtualInstance(vm, vm.getName(), state, - minion, vm.getGuestSystem(), vm.getNumberOfCPUs(), vm.getTotalMemory()); - return; - } - final Optional updatedDef = message.getDetail().equals("updated") ? - virtManager.getGuestDefinition(minionId, message.getDomainUUID()) : - Optional.empty(); - - // Check if we need to restart the VM now - if (event.equals("stopped")) { - checkForRestart(minionId, message.getDomainName()); - } - - String name = updatedDef.isPresent() ? updatedDef.get().getName() : vm.getName(); - Integer cpuCount = updatedDef.map(guestDefinitionIn -> guestDefinitionIn.getVcpu().getMax()) - .orElseGet(vm::getNumberOfCPUs); - Long memory = updatedDef.map(guestDefinitionIn -> guestDefinitionIn.getMaxMemory() / 1024) - .orElseGet(vm::getTotalMemory); - VirtualInstanceManager.updateGuestVirtualInstanceProperties( - vm, name, "updated".equals(message.getDetail()) ? vm.getState() : state, - cpuCount, memory); - } - } - else { - LOG.error(String.format("More than one virtual machine with UUID %s: skipping data update", guid)); - } - }); - } - VirtNotifications.spreadRefresh("guest"); - } - - private void unwatchVirtualMachine(String minionId, String vmName) { - synchronized (toRestart) { - toRestart.remove(computeName(minionId, vmName)); - } - } - - private void watchVirtualMachine(String minionId, String vmName) { - synchronized (toRestart) { - toRestart.add(computeName(minionId, vmName)); - } - } - - private void checkForRestart(String minionId, String vmName) { - String name = computeName(minionId, vmName); - synchronized (toRestart) { - if (toRestart.contains(name)) { - virtManager.startGuest(minionId, vmName); - toRestart.remove(name); - } - } - } - - private String computeName(String minionId, String vmName) { - return minionId + "-" + vmName; - } -} diff --git a/java/code/src/com/suse/manager/reactor/messaging/LibvirtEngineDomainMessage.java b/java/code/src/com/suse/manager/reactor/messaging/LibvirtEngineDomainMessage.java deleted file mode 100644 index 4a7dc2ca0790..000000000000 --- a/java/code/src/com/suse/manager/reactor/messaging/LibvirtEngineDomainMessage.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (c) 2018 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.suse.manager.reactor.messaging; - -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; - -import java.util.Optional; - -/** - * Libvirt_events engine domain message to handle - */ -public abstract class LibvirtEngineDomainMessage extends AbstractLibvirtEngineMessage { - - private String domainName; - private String domainId; - private String domainUUID; - - /** - * Create a domain message corresponding to the event type - * - * @param connection libvirt connection - * @param eventType libvirt event type (lifecycle, refresh, etc) - * @param minionId the minion ID or empty if the message comes from the master - * @param timestamp the event time stamp - * @param data the JSon data of the event - * - * @return a specialized object matching the event - */ - public static AbstractLibvirtEngineMessage createDomainMessage(String connection, - String eventType, Optional minionId, String timestamp, - JsonElement data) { - if (eventType.equals("lifecycle")) { - return new LibvirtEngineDomainLifecycleMessage(connection, minionId, - timestamp, data); - } - return null; - } - - /** - * @return name of the domain related to the event - */ - public String getDomainName() { - return domainName; - } - - /** - * @return id of the domain related to the event - */ - public String getDomainId() { - return domainId; - } - - /** - * @return uuid of the domain related to the event - */ - public String getDomainUUID() { - return domainUUID; - } - - @Override - public String toString() { - return super.toString() + "[" + domainName + "]"; - } - - protected LibvirtEngineDomainMessage(String connection, Optional minionId, - String timestamp, JsonElement data) { - super(connection, minionId, timestamp); - - JsonObject domain = data.getAsJsonObject().get("domain").getAsJsonObject(); - this.domainName = domain.get("name").getAsString(); - this.domainId = domain.get("id").getAsString(); - this.domainUUID = domain.get("uuid").getAsString(); - } -} diff --git a/java/code/src/com/suse/manager/reactor/messaging/LibvirtEngineNetworkLifecycleMessage.java b/java/code/src/com/suse/manager/reactor/messaging/LibvirtEngineNetworkLifecycleMessage.java deleted file mode 100644 index 4acadf83da4c..000000000000 --- a/java/code/src/com/suse/manager/reactor/messaging/LibvirtEngineNetworkLifecycleMessage.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2020 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.suse.manager.reactor.messaging; - -import com.google.gson.JsonElement; - -import java.util.Optional; - -/** - * Class representing a Salt virtual network Lifecycle event - */ -public class LibvirtEngineNetworkLifecycleMessage extends LibvirtEngineNetworkMessage { - - private String event; - private String detail; - - /** - * @return the lifecycle event type (start, destroy, etc) - */ - public String getEvent() { - return event; - } - - /** - * @return the lifecycle event detail, mostly indicating the - * reason of the event - */ - public String getDetail() { - return detail; - } - - @Override - public String toString() { - return super.toString() + "[" + event + "]"; - } - - protected LibvirtEngineNetworkLifecycleMessage(String connection, Optional minionId, - String timestamp, JsonElement data) { - super(connection, minionId, timestamp, data); - - event = data.getAsJsonObject().get("event").getAsString(); - detail = data.getAsJsonObject().get("detail").getAsString(); - } -} diff --git a/java/code/src/com/suse/manager/reactor/messaging/LibvirtEngineNetworkMessage.java b/java/code/src/com/suse/manager/reactor/messaging/LibvirtEngineNetworkMessage.java deleted file mode 100644 index 989c2936199b..000000000000 --- a/java/code/src/com/suse/manager/reactor/messaging/LibvirtEngineNetworkMessage.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2020 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.suse.manager.reactor.messaging; - -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; - -import java.util.Optional; - -/** - * Libvirt_events engine network message to handle - */ -public class LibvirtEngineNetworkMessage extends AbstractLibvirtEngineMessage { - private String netName; - private String netUUID; - - /** - * Create a network message corresponding to the event type - * - * @param connection libvirt connection - * @param eventType libvirt event type (lifecycle...) - * @param minionId the minion ID or empty if the message comes from the master - * @param timestamp the event time stamp - * @param data the JSon data of the event - * - * @return a specialized object matching the event - */ - public static AbstractLibvirtEngineMessage createNetworkMessage(String connection, String eventType, - Optional minionId, String timestamp, - JsonElement data) { - if (eventType.equals("lifecycle")) { - return new LibvirtEngineNetworkLifecycleMessage(connection, minionId, - timestamp, data); - } - return null; - } - - /** - * @return name of the network related to the event - */ - public String getNetworkName() { - return netName; - } - - /** - * @return uuid of the pool related to the event - */ - public String getNetworkUUID() { - return netUUID; - } - - @Override - public String toString() { - return super.toString() + "[" + netName + "]"; - } - - protected LibvirtEngineNetworkMessage(String connection, Optional minionId, - String timestamp, JsonElement data) { - super(connection, minionId, timestamp); - - JsonObject net = data.getAsJsonObject().get("network").getAsJsonObject(); - this.netName = net.get("name").getAsString(); - this.netUUID = net.get("uuid").getAsString(); - } -} diff --git a/java/code/src/com/suse/manager/reactor/messaging/LibvirtEngineNetworkMessageAction.java b/java/code/src/com/suse/manager/reactor/messaging/LibvirtEngineNetworkMessageAction.java deleted file mode 100644 index 4b184ef6a532..000000000000 --- a/java/code/src/com/suse/manager/reactor/messaging/LibvirtEngineNetworkMessageAction.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2020 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.suse.manager.reactor.messaging; - -import com.redhat.rhn.common.messaging.EventMessage; -import com.redhat.rhn.common.messaging.MessageAction; - -import com.suse.manager.webui.websocket.VirtNotifications; - -/** - * Virt engine virtual network lifecycle event action handler - */ -public class LibvirtEngineNetworkMessageAction implements MessageAction { - @Override - public void execute(EventMessage msg) { - // Notify that there was a pool change - VirtNotifications.spreadRefresh("network"); - } -} diff --git a/java/code/src/com/suse/manager/reactor/messaging/LibvirtEnginePoolLifecycleMessage.java b/java/code/src/com/suse/manager/reactor/messaging/LibvirtEnginePoolLifecycleMessage.java deleted file mode 100644 index 55fa57190e04..000000000000 --- a/java/code/src/com/suse/manager/reactor/messaging/LibvirtEnginePoolLifecycleMessage.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2020 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.suse.manager.reactor.messaging; - -import com.google.gson.JsonElement; - -import java.util.Optional; - -/** - * Class representing a Salt Pool Lifecycle event - */ -public class LibvirtEnginePoolLifecycleMessage extends LibvirtEnginePoolMessage { - - private String event; - private String detail; - - /** - * @return the lifecycle event type (start, destroy, etc) - */ - public String getEvent() { - return event; - } - - /** - * @return the lifecycle event detail, mostly indicating the - * reason of the event - */ - public String getDetail() { - return detail; - } - - @Override - public String toString() { - return super.toString() + "[" + event + "]"; - } - - protected LibvirtEnginePoolLifecycleMessage(String connection, Optional minionId, - String timestamp, JsonElement data) { - super(connection, minionId, timestamp, data); - - event = data.getAsJsonObject().get("event").getAsString(); - detail = data.getAsJsonObject().get("detail").getAsString(); - } -} diff --git a/java/code/src/com/suse/manager/reactor/messaging/LibvirtEnginePoolMessage.java b/java/code/src/com/suse/manager/reactor/messaging/LibvirtEnginePoolMessage.java deleted file mode 100644 index 76b87dd6738e..000000000000 --- a/java/code/src/com/suse/manager/reactor/messaging/LibvirtEnginePoolMessage.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2020 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.suse.manager.reactor.messaging; - -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; - -import java.util.Optional; - -/** - * Libvirt_events engine pool message to handle - */ -public class LibvirtEnginePoolMessage extends AbstractLibvirtEngineMessage { - private String poolName; - private String poolUUID; - - /** - * Create a pool message corresponding to the event type - * - * @param connection libvirt connection - * @param eventType libvirt event type (lifecycle, refresh) - * @param minionId the minion ID or empty if the message comes from the master - * @param timestamp the event time stamp - * @param data the JSon data of the event - * - * @return a specialized object matching the event - */ - public static AbstractLibvirtEngineMessage createPoolMessage(String connection, String eventType, - Optional minionId, String timestamp, - JsonElement data) { - if (eventType.equals("lifecycle")) { - return new LibvirtEnginePoolLifecycleMessage(connection, minionId, - timestamp, data); - } - else if (eventType.equals("refresh")) { - return new LibvirtEnginePoolRefreshMessage(connection, minionId, - timestamp, data); - } - return null; - } - - /** - * @return name of the pool related to the event - */ - public String getPoolName() { - return poolName; - } - - /** - * @return uuid of the pool related to the event - */ - public String getPoolUUID() { - return poolUUID; - } - - @Override - public String toString() { - return super.toString() + "[" + poolName + "]"; - } - - protected LibvirtEnginePoolMessage(String connection, Optional minionId, - String timestamp, JsonElement data) { - super(connection, minionId, timestamp); - - JsonObject pool = data.getAsJsonObject().get("pool").getAsJsonObject(); - this.poolName = pool.get("name").getAsString(); - this.poolUUID = pool.get("uuid").getAsString(); - } -} diff --git a/java/code/src/com/suse/manager/reactor/messaging/LibvirtEnginePoolMessageAction.java b/java/code/src/com/suse/manager/reactor/messaging/LibvirtEnginePoolMessageAction.java deleted file mode 100644 index e1fa91bf0eff..000000000000 --- a/java/code/src/com/suse/manager/reactor/messaging/LibvirtEnginePoolMessageAction.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2020 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.suse.manager.reactor.messaging; - -import com.redhat.rhn.common.messaging.EventMessage; -import com.redhat.rhn.common.messaging.MessageAction; - -import com.suse.manager.webui.websocket.VirtNotifications; - -/** - * Virt Engine Storage Pool Lifecycle Event Action Handler - */ -public class LibvirtEnginePoolMessageAction implements MessageAction { - @Override - public void execute(EventMessage msg) { - // Notify that there was a pool change - VirtNotifications.spreadRefresh("pool"); - } -} diff --git a/java/code/src/com/suse/manager/reactor/messaging/LibvirtEnginePoolRefreshMessage.java b/java/code/src/com/suse/manager/reactor/messaging/LibvirtEnginePoolRefreshMessage.java deleted file mode 100644 index e8528548f58c..000000000000 --- a/java/code/src/com/suse/manager/reactor/messaging/LibvirtEnginePoolRefreshMessage.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2020 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.suse.manager.reactor.messaging; - -import com.google.gson.JsonElement; - -import java.util.Optional; - -/** - * Class representing a Salt Pool refresh event - */ -public class LibvirtEnginePoolRefreshMessage extends LibvirtEnginePoolMessage { - private String event; - - /** - * @return the domain lifecycle event type (start, destroy, etc) - */ - public String getEvent() { - return event; - } - - @Override - public String toString() { - return super.toString() + "[" + event + "]"; - } - - protected LibvirtEnginePoolRefreshMessage(String connection, Optional minionId, - String timestamp, JsonElement data) { - super(connection, minionId, timestamp, data); - - event = data.getAsJsonObject().get("event").getAsString(); - } -} diff --git a/java/code/src/com/suse/manager/reactor/messaging/RegisterMinionEventMessageAction.java b/java/code/src/com/suse/manager/reactor/messaging/RegisterMinionEventMessageAction.java index c597189045a7..73f559f268c9 100644 --- a/java/code/src/com/suse/manager/reactor/messaging/RegisterMinionEventMessageAction.java +++ b/java/code/src/com/suse/manager/reactor/messaging/RegisterMinionEventMessageAction.java @@ -66,14 +66,12 @@ import com.suse.manager.model.attestation.ServerCoCoAttestationConfig; import com.suse.manager.reactor.utils.ValueMap; import com.suse.manager.utils.SaltUtils; -import com.suse.manager.virtualization.VirtManagerSalt; import com.suse.manager.webui.controllers.StatesAPI; import com.suse.manager.webui.services.SaltActionChainGeneratorService; import com.suse.manager.webui.services.SaltStateGeneratorService; import com.suse.manager.webui.services.iface.MonitoringManager; import com.suse.manager.webui.services.iface.SaltApi; import com.suse.manager.webui.services.iface.SystemQuery; -import com.suse.manager.webui.services.iface.VirtManager; import com.suse.manager.webui.services.impl.MinionPendingRegistrationService; import com.suse.manager.webui.services.impl.SaltSSHService; import com.suse.manager.webui.services.pillar.MinionPillarManager; @@ -145,12 +143,11 @@ public RegisterMinionEventMessageAction(SystemQuery systemQueryIn, SaltApi saltA systemQuery = systemQueryIn; cloudPaygManager = paygMgrIn; attestationManager = attMgrIn; - VirtManager virtManager = new VirtManagerSalt(saltApi); MonitoringManager monitoringManager = new FormulaMonitoringManager(saltApi); ServerGroupManager groupManager = new ServerGroupManager(saltApi); entitlementManager = new SystemEntitlementManager( - new SystemUnentitler(virtManager, monitoringManager, groupManager), - new SystemEntitler(saltApi, virtManager, monitoringManager, groupManager) + new SystemUnentitler(monitoringManager, groupManager), + new SystemEntitler(saltApi, monitoringManager, groupManager) ); } diff --git a/java/code/src/com/suse/manager/reactor/messaging/test/JobReturnEventMessageActionTest.java b/java/code/src/com/suse/manager/reactor/messaging/test/JobReturnEventMessageActionTest.java index a40985023e3c..0ff67b54c7fe 100644 --- a/java/code/src/com/suse/manager/reactor/messaging/test/JobReturnEventMessageActionTest.java +++ b/java/code/src/com/suse/manager/reactor/messaging/test/JobReturnEventMessageActionTest.java @@ -84,10 +84,8 @@ import com.suse.manager.reactor.utils.test.RhelUtilsTest; import com.suse.manager.utils.SaltKeyUtils; import com.suse.manager.utils.SaltUtils; -import com.suse.manager.virtualization.VirtManagerSalt; import com.suse.manager.webui.services.SaltServerActionService; import com.suse.manager.webui.services.iface.MonitoringManager; -import com.suse.manager.webui.services.iface.VirtManager; import com.suse.manager.webui.services.impl.SaltSSHService; import com.suse.manager.webui.services.impl.SaltService; import com.suse.manager.webui.services.impl.runner.MgrUtilRunner; @@ -160,11 +158,10 @@ public void setUp() throws Exception { DigestUtils.sha256Hex(TestUtils.randomString())); saltServiceMock = context().mock(SaltService.class); ServerGroupManager serverGroupManager = new ServerGroupManager(saltServiceMock); - VirtManager virtManager = new VirtManagerSalt(saltServiceMock); MonitoringManager monitoringManager = new FormulaMonitoringManager(saltServiceMock); systemEntitlementManager = new SystemEntitlementManager( - new SystemUnentitler(virtManager, monitoringManager, serverGroupManager), - new SystemEntitler(saltServiceMock, virtManager, monitoringManager, serverGroupManager) + new SystemUnentitler(monitoringManager, serverGroupManager), + new SystemEntitler(saltServiceMock, monitoringManager, serverGroupManager) ); saltUtils = new SaltUtils(saltServiceMock, saltServiceMock); saltServerActionService = new SaltServerActionService(saltServiceMock, saltUtils, diff --git a/java/code/src/com/suse/manager/reactor/messaging/test/LibvirtEngineDomainLifecycleMessageActionTest.java b/java/code/src/com/suse/manager/reactor/messaging/test/LibvirtEngineDomainLifecycleMessageActionTest.java deleted file mode 100644 index 0a90936e9ea9..000000000000 --- a/java/code/src/com/suse/manager/reactor/messaging/test/LibvirtEngineDomainLifecycleMessageActionTest.java +++ /dev/null @@ -1,304 +0,0 @@ -/* - * Copyright (c) 2018 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.suse.manager.reactor.messaging.test; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -import com.redhat.rhn.common.db.datasource.DataResult; -import com.redhat.rhn.domain.role.RoleFactory; -import com.redhat.rhn.domain.server.MinionServer; -import com.redhat.rhn.domain.server.Server; -import com.redhat.rhn.domain.server.VirtualInstanceFactory; -import com.redhat.rhn.frontend.dto.VirtualSystemOverview; -import com.redhat.rhn.manager.formula.FormulaMonitoringManager; -import com.redhat.rhn.manager.system.ServerGroupManager; -import com.redhat.rhn.manager.system.SystemManager; -import com.redhat.rhn.manager.system.entitling.SystemEntitlementManager; -import com.redhat.rhn.manager.system.entitling.SystemEntitler; -import com.redhat.rhn.manager.system.entitling.SystemUnentitler; -import com.redhat.rhn.testing.JMockBaseTestCaseWithUser; -import com.redhat.rhn.testing.ServerTestUtils; -import com.redhat.rhn.testing.TestUtils; - -import com.suse.manager.reactor.messaging.AbstractLibvirtEngineMessage; -import com.suse.manager.reactor.messaging.LibvirtEngineDomainLifecycleMessageAction; -import com.suse.manager.virtualization.GuestDefinition; -import com.suse.manager.webui.services.iface.MonitoringManager; -import com.suse.manager.webui.services.iface.SaltApi; -import com.suse.manager.webui.services.iface.VirtManager; -import com.suse.manager.webui.services.test.TestSaltApi; -import com.suse.salt.netapi.datatypes.Event; -import com.suse.salt.netapi.event.EngineEvent; -import com.suse.salt.netapi.parser.JsonParser; - -import com.google.gson.JsonElement; -import com.google.gson.reflect.TypeToken; - -import org.apache.commons.lang3.StringUtils; -import org.jmock.Expectations; -import org.jmock.States; -import org.jmock.imposters.ByteBuddyClassImposteriser; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import java.io.File; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.stream.Collectors; - -/** - * Test for {@link LibvirtEngineDomainLifecycleMessageAction} - */ -public class LibvirtEngineDomainLifecycleMessageActionTest extends JMockBaseTestCaseWithUser { - - private Server host; - private VirtManager virtManager; - private String guid = "b99a81764f40498d8e612f6ade654fe2"; - private String uuid = "b99a8176-4f40-498d-8e61-2f6ade654fe2"; - - // JsonParser for parsing events from files - public static final JsonParser EVENTS = - new JsonParser<>(new TypeToken<>() { - }); - - @Override - @BeforeEach - public void setUp() throws Exception { - super.setUp(); - user.addPermanentRole(RoleFactory.ORG_ADMIN); - setImposteriser(ByteBuddyClassImposteriser.INSTANCE); - - virtManager = mock(VirtManager.class); - context().checking(new Expectations() { { - allowing(virtManager).getCapabilities("testminion.local"); - will(returnValue( - SaltTestUtils.getSaltResponse( - "/com/suse/manager/webui/controllers/virtualization/test/virt.guest.allcaps.json", null, - new TypeToken>() { }) - )); - allowing(virtManager).updateLibvirtEngine(with(any(MinionServer.class))); - }}); - - SaltApi saltApi = new TestSaltApi(); - MonitoringManager monitoringManager = new FormulaMonitoringManager(saltApi); - ServerGroupManager serverGroupManager = new ServerGroupManager(saltApi); - SystemEntitlementManager systemEntitlementManager = new SystemEntitlementManager( - new SystemUnentitler(virtManager, monitoringManager, serverGroupManager), - new SystemEntitler(new TestSaltApi(), virtManager, monitoringManager, serverGroupManager) - ); - - host = ServerTestUtils.createVirtHostWithGuests(user, 1, true, systemEntitlementManager); - host.getGuests().iterator().next().setUuid(guid); - host.getGuests().iterator().next().setName("sles12sp2"); - host.asMinionServer().get().setMinionId("testminion.local"); - } - - @Test - public void testNewGuestNoRestart() throws Exception { - Map placeholders = new HashMap<>(); - placeholders.put("sles12sp2", "sles12sp2-new"); - placeholders.put(uuid, "98eef4f7-eb7f-4be8-859d-11658506c496"); - expectGuestDefinition("98eef4f7-eb7f-4be8-859d-11658506c496", - "/com/suse/manager/reactor/messaging/test/virt.guest.definition.xml", placeholders); - Optional startEvent = EngineEvent.parse(getEngineEvent("virtevents.guest.started.json", null)); - AbstractLibvirtEngineMessage startMessage = AbstractLibvirtEngineMessage.create(startEvent.get()); - - // Start event - LibvirtEngineDomainLifecycleMessageAction action = new LibvirtEngineDomainLifecycleMessageAction(virtManager); - action.execute(startMessage); - - DataResult guests = SystemManager.virtualGuestsForHostList(user, host.getId(), null); - List newGuests = guests.stream().filter(vso -> vso.getName().equals("sles12sp2-new")) - .collect(Collectors.toList()); - - assertEquals(VirtualInstanceFactory.getInstance().getRunningState().getLabel(), - newGuests.get(0).getStateLabel()); - - // Shutdown event - context().checking(new Expectations() {{ - never(virtManager).startGuest(host.getMinionId(), "sles12sp2-new"); - }}); - Optional stopEvent = EngineEvent.parse( - getEngineEvent("virtevents.guest.shutdown.json", placeholders)); - AbstractLibvirtEngineMessage stopMessage = AbstractLibvirtEngineMessage.create(stopEvent.get()); - - action.execute(stopMessage); - } - - @Test - public void testNewGuestFirstReboot() throws Exception { - Map placeholders = new HashMap<>(); - placeholders.put("sles12sp2", "sles12sp2-new"); - placeholders.put(uuid, "98eef4f7-eb7f-4be8-859d-11658506c496"); - placeholders.put("restart", "destroy"); - expectGuestDefinition("98eef4f7-eb7f-4be8-859d-11658506c496", - "/com/suse/manager/reactor/messaging/test/virt.guest.definition.xml", placeholders); - - // Start event - Optional startEvent = EngineEvent.parse(getEngineEvent("virtevents.guest.started.json", null)); - AbstractLibvirtEngineMessage startMessage = AbstractLibvirtEngineMessage.create(startEvent.get()); - - LibvirtEngineDomainLifecycleMessageAction action = new LibvirtEngineDomainLifecycleMessageAction(virtManager); - action.execute(startMessage); - - // Shutdown event - context().checking(new Expectations() {{ - oneOf(virtManager).startGuest(host.getMinionId(), "sles12sp2-new"); - }}); - Optional stopEvent = EngineEvent.parse( - getEngineEvent("virtevents.guest.shutdown.json", placeholders)); - AbstractLibvirtEngineMessage stopMessage = AbstractLibvirtEngineMessage.create(stopEvent.get()); - - action.execute(stopMessage); - } - - @Test - public void testNewGuestFirstRebootAborted() throws Exception { - States vmState = context().states("vm").startsAs("started"); - - Map placeholders = new HashMap<>(); - placeholders.put("sles12sp2", "sles12sp2-new"); - placeholders.put(uuid, "98eef4f7-eb7f-4be8-859d-11658506c496"); - placeholders.put("restart", "destroy"); - expectGuestDefinition("98eef4f7-eb7f-4be8-859d-11658506c496", - "/com/suse/manager/reactor/messaging/test/virt.guest.definition.xml", placeholders, - vmState, "started"); - expectGuestDefinition("98eef4f7-eb7f-4be8-859d-11658506c496", "virt.noguest.txt", null, - vmState, "deleted"); - - // Start event - Optional startEvent = EngineEvent.parse(getEngineEvent("virtevents.guest.started.json", null)); - AbstractLibvirtEngineMessage startMessage = AbstractLibvirtEngineMessage.create(startEvent.get()); - - LibvirtEngineDomainLifecycleMessageAction action = new LibvirtEngineDomainLifecycleMessageAction(virtManager); - action.execute(startMessage); - - // Shutdown event - vmState.become("deleted"); - - context().checking(new Expectations() { { - never(virtManager).startGuest(host.getMinionId(), "sles12sp2-new"); - } }); - Optional stopEvent = EngineEvent.parse( - getEngineEvent("virtevents.guest.shutdown.json", placeholders)); - AbstractLibvirtEngineMessage stopMessage = AbstractLibvirtEngineMessage.create(stopEvent.get()); - - action.execute(stopMessage); - } - - @Test - public void testShutdownPersistent() throws Exception { - expectGuestDefinition(uuid, - "/com/suse/manager/reactor/messaging/test/virt.guest.definition.xml", null); - context().checking(new Expectations() {{ - never(virtManager).startGuest(host.getMinionId(), "sles12sp2"); - }}); - Optional event = EngineEvent.parse( - getEngineEvent("virtevents.guest.shutdown.json", Collections.emptyMap())); - AbstractLibvirtEngineMessage message = AbstractLibvirtEngineMessage.create(event.get()); - - new LibvirtEngineDomainLifecycleMessageAction(virtManager).execute(message); - - DataResult guests = SystemManager.virtualGuestsForHostList(user, host.getId(), null); - List matchingGuests = guests.stream().filter(vso -> vso.getUuid().equals(guid)) - .collect(Collectors.toList()); - assertEquals(VirtualInstanceFactory.getInstance().getStoppedState().getLabel(), - matchingGuests.get(0).getStateLabel()); - } - - @Test - public void testShutdownTransient() throws Exception { - expectGuestDefinition(uuid, null, null); - context().checking(new Expectations() {{ - never(virtManager).startGuest(host.getMinionId(), "sles12sp2"); - }}); - Optional event = EngineEvent.parse( - getEngineEvent("virtevents.guest.shutdown.json", Collections.emptyMap())); - AbstractLibvirtEngineMessage message = AbstractLibvirtEngineMessage.create(event.get()); - - new LibvirtEngineDomainLifecycleMessageAction(virtManager).execute(message); - - DataResult guests = SystemManager.virtualGuestsForHostList(user, host.getId(), null); - List matchingGuests = guests.stream().filter(vso -> vso.getUuid().equals(guid)) - .collect(Collectors.toList()); - - assertEquals(0, matchingGuests.size()); - } - - @Test - public void testUpdate() throws Exception { - expectGuestDefinition(uuid, - "/com/suse/manager/reactor/messaging/test/virt.guest.definition.xml", null); - Optional event = EngineEvent.parse( - getEngineEvent("virtevents.guest.updated.json", Collections.emptyMap())); - AbstractLibvirtEngineMessage message = AbstractLibvirtEngineMessage.create(event.get()); - - new LibvirtEngineDomainLifecycleMessageAction(virtManager).execute(message); - - DataResult guests = SystemManager.virtualGuestsForHostList(user, host.getId(), null); - List matchingGuests = guests.stream().filter(vso -> vso.getUuid().equals(guid)) - .collect(Collectors.toList()); - - - assertEquals(Long.valueOf(2), matchingGuests.get(0).getVcpus()); - assertEquals(Long.valueOf(1024), matchingGuests.get(0).getMemory()); - } - - protected Optional getSaltResponse(String filename, Map placeholders) { - return SaltTestUtils.getSaltResponse("/com/suse/manager/reactor/messaging/test/" + filename, - placeholders, null); - } - - private Event getEngineEvent(String filename, Map placeholders) throws Exception { - Path path = new File(TestUtils.findTestData( - "/com/suse/manager/reactor/messaging/test/" + filename).getPath()).toPath(); - String eventString = Files.lines(path).collect(Collectors.joining("\n")); - - if (placeholders != null) { - for (Map.Entry entry : placeholders.entrySet()) { - eventString = StringUtils.replace(eventString, entry.getKey(), entry.getValue()); - } - } - return EVENTS.parse(eventString); - } - - private void expectGuestDefinition(String uuidIn, String file, - Map placeholders) { - expectGuestDefinition(uuidIn, file, placeholders, null, null); - } - - private void expectGuestDefinition(String uuidIn, String file, - Map placeholders, - States state, String expectedState) { - context().checking(new Expectations() {{ - allowing(virtManager).getGuestDefinition("testminion.local", uuidIn); - will(returnValue( - file == null ? - Optional.empty() : - SaltTestUtils - .getSaltResponse(file, placeholders, null) - .map(xml -> GuestDefinition.parse(xml, Optional.empty())) - )); - if (state != null && expectedState != null) { - when(state.is(expectedState)); - } - }}); - } -} diff --git a/java/code/src/com/suse/manager/utils/SaltUtils.java b/java/code/src/com/suse/manager/utils/SaltUtils.java index b27d26adf9d0..5ba6762825ea 100644 --- a/java/code/src/com/suse/manager/utils/SaltUtils.java +++ b/java/code/src/com/suse/manager/utils/SaltUtils.java @@ -43,9 +43,6 @@ import com.redhat.rhn.domain.action.script.ScriptResult; import com.redhat.rhn.domain.action.script.ScriptRunAction; import com.redhat.rhn.domain.action.server.ServerAction; -import com.redhat.rhn.domain.action.virtualization.BaseVirtualizationGuestAction; -import com.redhat.rhn.domain.action.virtualization.BaseVirtualizationNetworkAction; -import com.redhat.rhn.domain.action.virtualization.BaseVirtualizationPoolAction; import com.redhat.rhn.domain.channel.AccessTokenFactory; import com.redhat.rhn.domain.channel.Channel; import com.redhat.rhn.domain.config.ConfigRevision; @@ -124,7 +121,6 @@ import com.suse.manager.webui.utils.salt.custom.PkgProfileUpdateSlsResult; import com.suse.manager.webui.utils.salt.custom.RetOpt; import com.suse.manager.webui.utils.salt.custom.SystemInfo; -import com.suse.manager.webui.websocket.VirtNotifications; import com.suse.salt.netapi.calls.modules.Openscap; import com.suse.salt.netapi.calls.modules.Pkg; import com.suse.salt.netapi.calls.modules.Pkg.Info; @@ -715,14 +711,6 @@ else if (action.getActionType().equals(ActionFactory.TYPE_CONFIGFILES_DEPLOY)) { else if (action.getActionType().equals(ActionFactory.TYPE_SUBSCRIBE_CHANNELS)) { handleSubscribeChannels(serverAction, jsonResult, action); } - else if (action instanceof BaseVirtualizationGuestAction || - action instanceof BaseVirtualizationPoolAction || - action instanceof BaseVirtualizationNetworkAction) { - // Tell VirtNotifications that we got an action change, passing action - VirtNotifications.spreadActionUpdate(action); - // Intentionally don't get only the comment since the changes value could be interesting - serverAction.setResultMsg(getJsonResultWithPrettyPrint(jsonResult)); - } else if (action.getActionType().equals(ActionFactory.TYPE_COCO_ATTESTATION)) { handleCocoAttestationResult(action, serverAction, jsonResult); } diff --git a/java/code/src/com/suse/manager/virtualization/DhcpHostDef.java b/java/code/src/com/suse/manager/virtualization/DhcpHostDef.java deleted file mode 100644 index 98d19fa64872..000000000000 --- a/java/code/src/com/suse/manager/virtualization/DhcpHostDef.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2021 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.suse.manager.virtualization; - -import org.jdom.Element; - -import java.util.Optional; - -public class DhcpHostDef { - private String ip; - private Optional mac = Optional.empty(); - private Optional id = Optional.empty(); - private Optional name = Optional.empty(); - - /** - * @return IP address - */ - public String getIp() { - return ip; - } - - /** - * @param ipIn IP address - */ - public void setIp(String ipIn) { - ip = ipIn; - } - - /** - * @return MAC address for IPv4 DHCP hosts - */ - public Optional getMac() { - return mac; - } - - /** - * @param macIn MAC address for IPv4 DHCP hosts - */ - public void setMac(Optional macIn) { - mac = macIn; - } - - /** - * @return DUID for DHCPv6 hosts - */ - public Optional getId() { - return id; - } - - /** - * @param idIn DUID for DHCPv6 hosts - */ - public void setId(Optional idIn) { - id = idIn; - } - - /** - * @return host name - */ - public Optional getName() { - return name; - } - - /** - * @param nameIn host name - */ - public void setName(Optional nameIn) { - name = nameIn; - } - - /** - * Parse DHCP host XML node - * @param node node to parse - * @return the parsed DHCP host definition - */ - public static DhcpHostDef parse(Element node) { - DhcpHostDef def = new DhcpHostDef(); - def.setIp(node.getAttributeValue("ip")); - def.setId(Optional.ofNullable(node.getAttributeValue("id"))); - def.setMac(Optional.ofNullable(node.getAttributeValue("mac"))); - def.setName(Optional.ofNullable(node.getAttributeValue("name"))); - return def; - } -} - diff --git a/java/code/src/com/suse/manager/virtualization/DnsDef.java b/java/code/src/com/suse/manager/virtualization/DnsDef.java deleted file mode 100644 index afe32a5ea1b3..000000000000 --- a/java/code/src/com/suse/manager/virtualization/DnsDef.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (c) 2021 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.suse.manager.virtualization; - -import org.jdom.Element; - -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - -/** - * Represents a virtual network DNS definition - */ -public class DnsDef { - private List forwarders = new ArrayList<>(); - private List hosts = new ArrayList<>(); - private List srvs = new ArrayList<>(); - private List txts = new ArrayList<>(); - - /** - * @return value of forwarders - */ - public List getForwarders() { - return forwarders; - } - - /** - * @param forwardersIn value of forwarders - */ - public void setForwarders(List forwardersIn) { - forwarders = forwardersIn; - } - - /** - * @return value of hosts - */ - public List getHosts() { - return hosts; - } - - /** - * @param hostsIn value of hosts - */ - public void setHosts(List hostsIn) { - hosts = hostsIn; - } - - /** - * @return value of srvs - */ - public List getSrvs() { - return srvs; - } - - /** - * @param srvsIn value of srvs - */ - public void setSrvs(List srvsIn) { - srvs = srvsIn; - } - - /** - * @return value of txts - */ - public List getTxts() { - return txts; - } - - /** - * @param txtsIn value of txts - */ - public void setTxts(List txtsIn) { - txts = txtsIn; - } - - /** - * Parse dns XML node - * - * @param node the node to parse - * - * @return the parsed definition - */ - public static Optional parse(Element node) { - if (node == null) { - return Optional.empty(); - } - DnsDef def = new DnsDef(); - for (Object child : node.getChildren("forwarder")) { - def.forwarders.add(DnsForwarderDef.parse((Element)child)); - } - - for (Object child : node.getChildren("host")) { - def.hosts.add(DnsHostDef.parse((Element)child)); - } - - for (Object child : node.getChildren("srv")) { - def.srvs.add(DnsSrvDef.parse((Element)child)); - } - - for (Object child : node.getChildren("txt")) { - def.txts.add(DnsTxtDef.parse((Element)child)); - } - - return Optional.of(def); - } -} diff --git a/java/code/src/com/suse/manager/virtualization/DnsForwarderDef.java b/java/code/src/com/suse/manager/virtualization/DnsForwarderDef.java deleted file mode 100644 index 6adb3edfec10..000000000000 --- a/java/code/src/com/suse/manager/virtualization/DnsForwarderDef.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2021 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.suse.manager.virtualization; - -import org.jdom.Element; - -import java.util.Optional; - -/** - * Represents a virtual network DNS forwarder definition - */ -public class DnsForwarderDef { - private Optional domain; - private Optional address; - - /** - * @return value of domain - */ - public Optional getDomain() { - return domain; - } - - /** - * @param domainIn value of domain - */ - public void setDomain(Optional domainIn) { - domain = domainIn; - } - - /** - * @return value of address - */ - public Optional getAddress() { - return address; - } - - /** - * @param addressIn value of address - */ - public void setAddress(Optional addressIn) { - address = addressIn; - } - - /** - * Parse dns forwarder node - * - * @param node the node to parse - * @return the parsed forwarder definition - */ - public static DnsForwarderDef parse(Element node) { - DnsForwarderDef def = new DnsForwarderDef(); - def.setAddress(Optional.ofNullable(node.getAttributeValue("addr"))); - def.setDomain(Optional.ofNullable(node.getAttributeValue("domain"))); - return def; - } -} diff --git a/java/code/src/com/suse/manager/virtualization/DnsHostDef.java b/java/code/src/com/suse/manager/virtualization/DnsHostDef.java deleted file mode 100644 index 6b44d721b96f..000000000000 --- a/java/code/src/com/suse/manager/virtualization/DnsHostDef.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2021 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.suse.manager.virtualization; - -import org.jdom.Element; - -import java.util.ArrayList; -import java.util.List; - -public class DnsHostDef { - private String address; - private List names = new ArrayList<>(); - - /** - * @return value of address - */ - public String getAddress() { - return address; - } - - /** - * @param addressIn value of address - */ - public void setAddress(String addressIn) { - address = addressIn; - } - - /** - * @return value of names - */ - public List getNames() { - return names; - } - - /** - * @param namesIn value of names - */ - public void setNames(List namesIn) { - names = namesIn; - } - - /** - * Parse DNS host node - * @param node the node to parse - * @return the parsed host definition - */ - public static DnsHostDef parse(Element node) { - DnsHostDef def = new DnsHostDef(); - def.setAddress(node.getAttributeValue("ip")); - for (Object child : node.getChildren("hostname")) { - def.names.add(((Element)child).getTextTrim()); - } - return def; - } -} diff --git a/java/code/src/com/suse/manager/virtualization/DnsSrvDef.java b/java/code/src/com/suse/manager/virtualization/DnsSrvDef.java deleted file mode 100644 index 8e4e272c8daf..000000000000 --- a/java/code/src/com/suse/manager/virtualization/DnsSrvDef.java +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright (c) 2021 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.suse.manager.virtualization; - -import org.jdom.Element; - -import java.util.Optional; -import java.util.function.Function; - -/** - * Represents a virtual network DNS SRV record definition - */ -public class DnsSrvDef { - private String name; - private String protocol; - private Optional domain; - private Optional target; - private Optional port; - private Optional priority; - private Optional weight; - - /** - * @return value of name - */ - public String getName() { - return name; - } - - /** - * @param nameIn value of name - */ - public void setName(String nameIn) { - name = nameIn; - } - - /** - * @return value of protocol - */ - public String getProtocol() { - return protocol; - } - - /** - * @param protocolIn value of protocol - */ - public void setProtocol(String protocolIn) { - protocol = protocolIn; - } - - /** - * @return value of domain - */ - public Optional getDomain() { - return domain; - } - - /** - * @param domainIn value of domain - */ - public void setDomain(Optional domainIn) { - domain = domainIn; - } - - /** - * @return value of target - */ - public Optional getTarget() { - return target; - } - - /** - * @param targetIn value of target - */ - public void setTarget(Optional targetIn) { - target = targetIn; - } - - /** - * @return value of port - */ - public Optional getPort() { - return port; - } - - /** - * @param portIn value of port - */ - public void setPort(Optional portIn) { - port = portIn; - } - - /** - * @return value of priority - */ - public Optional getPriority() { - return priority; - } - - /** - * @param priorityIn value of priority - */ - public void setPriority(Optional priorityIn) { - priority = priorityIn; - } - - /** - * @return value of weight - */ - public Optional getWeight() { - return weight; - } - - /** - * @param weightIn value of weight - */ - public void setWeight(Optional weightIn) { - weight = weightIn; - } - - /** - * Parse a DNS srv XML node - * - * @param node the node to parse - * @return the parsed srv definition - */ - public static DnsSrvDef parse(Element node) { - DnsSrvDef def = new DnsSrvDef(); - def.setName(node.getAttributeValue("service")); - def.setProtocol(node.getAttributeValue("protocol")); - - Function> asInt = str -> Optional.ofNullable(str).map(Integer::parseInt); - - def.setDomain(Optional.ofNullable(node.getAttributeValue("domain"))); - def.setTarget(Optional.ofNullable(node.getAttributeValue("target"))); - def.setPort(asInt.apply(node.getAttributeValue("port"))); - def.setPriority(asInt.apply(node.getAttributeValue("priority"))); - def.setWeight(asInt.apply(node.getAttributeValue("weight"))); - return def; - } -} diff --git a/java/code/src/com/suse/manager/virtualization/DnsTxtDef.java b/java/code/src/com/suse/manager/virtualization/DnsTxtDef.java deleted file mode 100644 index db79e2b61fc1..000000000000 --- a/java/code/src/com/suse/manager/virtualization/DnsTxtDef.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2021 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.suse.manager.virtualization; - -import org.jdom.Element; - -/** - * Represents a virtual network DNS TXT record definition - */ -public class DnsTxtDef { - private String name; - private String value; - - /** - * @return value of name - */ - public String getName() { - return name; - } - - /** - * @param nameIn value of name - */ - public void setName(String nameIn) { - name = nameIn; - } - - /** - * @return value of value - */ - public String getValue() { - return value; - } - - /** - * @param valueIn value of value - */ - public void setValue(String valueIn) { - value = valueIn; - } - - /** - * Parse DNS TXT XML node - * @param node the node to parse - * @return the parsed TXT definition - */ - public static DnsTxtDef parse(Element node) { - DnsTxtDef def = new DnsTxtDef(); - def.setName(node.getAttributeValue("name")); - def.setValue(node.getAttributeValue("value")); - return def; - } -} diff --git a/java/code/src/com/suse/manager/virtualization/DomainCapabilitiesJson.java b/java/code/src/com/suse/manager/virtualization/DomainCapabilitiesJson.java deleted file mode 100644 index 4e98e27b2f42..000000000000 --- a/java/code/src/com/suse/manager/virtualization/DomainCapabilitiesJson.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2018 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.suse.manager.virtualization; - -import java.util.List; -import java.util.Map; - -/** - * Class representing the salt output for domain capabilities - */ -public class DomainCapabilitiesJson { - - private String arch; - private String domain; - private Map>> devices; - - /** - * @return Returns the arch. - */ - public String getArch() { - return arch; - } - - /** - * @param archIn The arch to set. - */ - public void setArch(String archIn) { - arch = archIn; - } - - /** - * @return Returns the domain. - */ - public String getDomain() { - return domain; - } - - /** - * @param domainIn The domain to set. - */ - public void setDomain(String domainIn) { - domain = domainIn; - } - - /** - * @return Returns the devices. - */ - public Map>> getDevices() { - return devices; - } - - /** - * @param devicesIn The devices to set. - */ - public void setDevices(Map>> devicesIn) { - devices = devicesIn; - } -} diff --git a/java/code/src/com/suse/manager/virtualization/GuestCreateDetails.java b/java/code/src/com/suse/manager/virtualization/GuestCreateDetails.java deleted file mode 100644 index fa8975717858..000000000000 --- a/java/code/src/com/suse/manager/virtualization/GuestCreateDetails.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (c) 2021 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.suse.manager.virtualization; - -import com.suse.manager.reactor.utils.LocalDateTimeISOAdapter; -import com.suse.manager.reactor.utils.OptionalTypeAdapterFactory; -import com.suse.manager.webui.controllers.virtualization.gson.VirtualGuestsUpdateActionJson; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.annotations.SerializedName; -import com.google.gson.reflect.TypeToken; - -import java.time.LocalDateTime; - -/** - * Represents the data stored for the VM create or update actions. - */ -public class GuestCreateDetails extends VirtualGuestsUpdateActionJson { - - private static final Gson GSON = new GsonBuilder() - .registerTypeAdapter(LocalDateTime.class, new LocalDateTimeISOAdapter()) - .registerTypeAdapterFactory(new OptionalTypeAdapterFactory()) - .serializeNulls() - .create(); - - @SerializedName("remove_disks") - private boolean removeDisks; - @SerializedName("remove_interfaces") - private boolean removeInterfaces; - @SerializedName("kickstart_host") - private String kickstartHost; - @SerializedName("cobbler_system") - private String cobblerSystem; - - /** - * Create object instance from JSON string - * - * @param json the json representation to be parsed - * @return the created instance - */ - public static GuestCreateDetails parse(String json) { - return GSON.fromJson(json, new TypeToken() { }.getType()); - } - - /** - * @return JSON representation - */ - public String toJson() { - return GSON.toJson(this); - } - - /** - * @return value of removeDisks - */ - public boolean isRemoveDisks() { - return removeDisks; - } - - /** - * @param removeDisksIn value of removeDisks - */ - public void setRemoveDisks(boolean removeDisksIn) { - removeDisks = removeDisksIn; - } - - /** - * @return value of removeInterfaces - */ - public boolean isRemoveInterfaces() { - return removeInterfaces; - } - - /** - * @param removeInterfacesIn value of removeInterfaces - */ - public void setRemoveInterfaces(boolean removeInterfacesIn) { - removeInterfaces = removeInterfacesIn; - } - - /** - * @return value of kickstartHost - */ - public String getKickstartHost() { - return kickstartHost; - } - - /** - * @param kickstartHostIn value of kickstartHost - */ - public void setKickstartHost(String kickstartHostIn) { - kickstartHost = kickstartHostIn; - } - - /** - * @return value of cobblerSystem - */ - public String getCobblerSystem() { - return cobblerSystem; - } - - /** - * @param cobblerSystemIn value of cobblerSystem - */ - public void setCobblerSystem(String cobblerSystemIn) { - cobblerSystem = cobblerSystemIn; - } -} diff --git a/java/code/src/com/suse/manager/virtualization/GuestDefinition.java b/java/code/src/com/suse/manager/virtualization/GuestDefinition.java deleted file mode 100644 index 6e84ae45bbd2..000000000000 --- a/java/code/src/com/suse/manager/virtualization/GuestDefinition.java +++ /dev/null @@ -1,330 +0,0 @@ -/* - * Copyright (c) 2018 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.suse.manager.virtualization; - -import com.redhat.rhn.domain.server.VirtualInstanceFactory; -import com.redhat.rhn.domain.server.VirtualInstanceType; -import com.redhat.rhn.frontend.dto.VirtualSystemOverview; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.jdom.Document; -import org.jdom.Element; -import org.jdom.input.SAXBuilder; - -import java.io.StringReader; -import java.util.Arrays; -import java.util.List; -import java.util.Optional; -import java.util.stream.Collectors; - -/** - * Class representing the VM XML Definition. - */ -public class GuestDefinition { - - private static final Logger LOG = LogManager.getLogger(GuestDefinition.class); - - private String type; - private String name; - private String uuid; - private long memory; - private long maxMemory; - private boolean requiresRestart; - - private GuestVcpuDef vcpu; - private GuestOsDef os; - private GuestGraphicsDef graphics; - private List interfaces; - private List disks; - - - /** - * Create a guest definition from a virtual system overview. - * - * This is to be used for guests hosted on traditional hosts. - * Obviously only a minimal set of the definition data will be set - * since the overview doesn't hold them all. - * - * @param guest the guest to read data from. - */ - public GuestDefinition(VirtualSystemOverview guest) { - String guid = guest.getUuid(); - setUuid(guid.replaceAll("(\\w{8})(\\w{4})(\\w{4})(\\w{4})(\\w{12})", "$1-$2-$3-$4-$5")); - setName(guest.getName()); - setMemory(guest.getMemory()); - setMaxMemory(guest.getMemory()); - - GuestVcpuDef vcpuDef = new GuestVcpuDef(); - vcpuDef.setCurrent(guest.getVcpus().intValue()); - vcpuDef.setMax(guest.getVcpus().intValue()); - setVcpu(vcpuDef); - } - - /** - * @return the machine type (hypervisor dependent) - */ - public String getType() { - return type; - } - - /** - * @param typeIn The type to set. - */ - public void setType(String typeIn) { - type = typeIn; - } - - /** - * @return domain name - */ - public String getName() { - return name; - } - - /** - * Set the guest name - * - * @param nameIn guest name - */ - public void setName(String nameIn) { - this.name = nameIn; - } - - /** - * @return domain UUID - */ - public String getUuid() { - return uuid; - } - - /** - * @param uuidIn The uuid to set. - */ - public void setUuid(String uuidIn) { - uuid = uuidIn; - } - - /** - * @return current amount of memory in KiB. - */ - public long getMemory() { - return memory; - } - - /** - * Set the current amount of memory in KiB. - * - * Don't forget to change the maximum before raising the current amount - * of memory or it will be capped. - * - * @param memoryIn current amount of memory - */ - public void setMemory(long memoryIn) { - this.memory = Math.min(this.maxMemory, memoryIn); - } - - /** - * @return the maximum amount of memory allocated to the guest in KiB - */ - public long getMaxMemory() { - return maxMemory; - } - - /** - * Set the maximum number of memory in KiB. - * - * If setting a value smaller than the current amount of memory, the - * latter will be adjusted. - * - * @param maxIn maximum number of Virtual CPUs - */ - public void setMaxMemory(long maxIn) { - this.maxMemory = maxIn; - this.memory = Math.min(this.maxMemory, this.memory); - } - - /** - * @return Vcpu definition - */ - public GuestVcpuDef getVcpu() { - return vcpu; - } - - /** - * @param vcpuIn The vcpu to set. - */ - public void setVcpu(GuestVcpuDef vcpuIn) { - vcpu = vcpuIn; - } - - /** - * @return whether the guest needs a manual restart. This usually means on_reboot is set to destroy - */ - public boolean isRequiresRestart() { - return requiresRestart; - } - - /** - * @return OS definition - */ - public GuestOsDef getOs() { - return os; - } - - /** - * @param osIn The os to set. - */ - public void setOs(GuestOsDef osIn) { - os = osIn; - } - - /** - * Note that we are only storing one graphics device definition for the guest - * even if libvirt schema allows more. I couldn't get libvirt to do anything - * useful with a second one: this limitation should make sense. - * - * @return the graphic device definition - */ - public GuestGraphicsDef getGraphics() { - return graphics; - } - - /** - * Set the graphic device definition - * - * @param graphicsIn the definition to set - */ - public void setGraphics(GuestGraphicsDef graphicsIn) { - graphics = graphicsIn; - } - - /** - * @return Returns the interfaces. - */ - public List getInterfaces() { - return interfaces; - } - - /** - * @param interfacesIn The interfaces to set. - */ - public void setInterfaces(List interfacesIn) { - interfaces = interfacesIn; - } - - /** - * @return Returns the disks. - */ - public List getDisks() { - return disks; - } - - /** - * @param disksIn The disks to set. - */ - public void setDisks(List disksIn) { - disks = disksIn; - } - - /** - * Compute the virtual instance type from the VM OS definition. - * - * @return the VirtualInstanceType - */ - public VirtualInstanceType getVirtualInstanceType() { - // FIXME This logic is actually not perfect, but matches the legacy one - VirtualInstanceType virtType = VirtualInstanceFactory.getInstance().getFullyVirtType(); - if (!getOs().getType().equals("hvm")) { - virtType = VirtualInstanceFactory.getInstance().getParaVirtType(); - } - return virtType; - } - - /** - * Create a new VM definition from a libvirt XML description. - * - * @param xmlDef libvirt XML domain definition - * @param vmInfo output of virt.vm_info to be merged with the XML guest definition - * @return parsed definition or {@code null} - */ - @SuppressWarnings("unchecked") - public static GuestDefinition parse(String xmlDef, Optional vmInfo) { - GuestDefinition def = null; - SAXBuilder builder = new SAXBuilder(); - builder.setValidation(false); - - try { - Document doc = builder.build(new StringReader(xmlDef)); - def = new GuestDefinition(); - - Element domainElement = doc.getRootElement(); - def.type = domainElement.getAttributeValue("type"); - def.setName(domainElement.getChildText("name")); - def.uuid = domainElement.getChildText("uuid"); - def.setMemory(parseMemory(domainElement.getChild("currentMemory"))); - def.setMaxMemory(parseMemory(domainElement.getChild("memory"))); - - def.vcpu = GuestVcpuDef.parse(domainElement.getChild("vcpu")); - def.os = GuestOsDef.parse(domainElement.getChild("os")); - - Element onRebootNode = domainElement.getChild("on_reboot"); - def.requiresRestart = onRebootNode != null && onRebootNode.getTextTrim().equals("destroy"); - - Element devices = domainElement.getChild("devices"); - def.graphics = GuestGraphicsDef.parse(devices.getChild("graphics")); - - def.interfaces = ((List)devices.getChildren("interface")).stream() - .map(GuestInterfaceDef::parse).collect(Collectors.toList()); - def.disks = ((List)devices.getChildren("disk")).stream() - .map(node -> GuestDiskDef.parse(node, vmInfo)).collect(Collectors.toList()); - } - catch (Exception e) { - LOG.error("failed to parse libvirt XML definition: {}", e.getMessage()); - } - - return def; - } - - /** - * Convert the memory value + unit pair into a KiB value - * - * @param element XML element with unit attribute and value as text - * @return the amount in KiB - */ - private static long parseMemory(Element element) { - String unit = element.getAttributeValue("unit", "KiB"); - long value = Long.parseLong(element.getText()); - - List prefixes = Arrays.asList('K', 'M', 'G', 'T'); - int multiplier = 1000; - if (unit.endsWith("iB")) { - multiplier = 1024; - } - - char prefix = unit.charAt(0); - int rank = prefixes.indexOf(prefix) + 1; - long bytes = value * (long)Math.pow(multiplier, rank); - - return bytes / 1024; - } - - /** - * Default constructor shouldn't not be used. Either construct from - * an XML definition to parse or a VirtualSystemOverview instance. - */ - private GuestDefinition() { - } -} diff --git a/java/code/src/com/suse/manager/virtualization/GuestDiskDef.java b/java/code/src/com/suse/manager/virtualization/GuestDiskDef.java deleted file mode 100644 index aa89ab0bf8a4..000000000000 --- a/java/code/src/com/suse/manager/virtualization/GuestDiskDef.java +++ /dev/null @@ -1,237 +0,0 @@ -/* - * Copyright (c) 2018 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.suse.manager.virtualization; - -import org.jdom.Attribute; -import org.jdom.Element; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.function.Function; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import java.util.stream.Collectors; - -/** - * Class representing the VM disk device XML definition. - */ -public class GuestDiskDef { - - private static final List NETWORK_CONVERTED_TYPES = Arrays.asList("rbd", "gluster"); - private static final Pattern BLOCK_REGEX = Pattern.compile("([^/]+)/([^/]+)"); - - private String type; - private String device; - private String format; - private String target; - private String bus; - private Map source; - - /** - * @return Returns the type. - */ - public String getType() { - return type; - } - - /** - * @param typeIn The type to set. - */ - public void setType(String typeIn) { - type = typeIn; - } - - /** - * @return Returns the device. - */ - public String getDevice() { - return device; - } - - /** - * @param deviceIn The device to set. - */ - public void setDevice(String deviceIn) { - device = deviceIn; - } - - /** - * @return Returns the format. - */ - public String getFormat() { - return format; - } - - /** - * @param formatIn The format to set. - */ - public void setFormat(String formatIn) { - format = formatIn; - } - - /** - * @return Returns the target. - */ - public String getTarget() { - return target; - } - - /** - * @param targetIn The target to set. - */ - public void setTarget(String targetIn) { - target = targetIn; - } - - /** - * @return Returns the bus. - */ - public String getBus() { - return bus; - } - - /** - * @param busIn The bus to set. - */ - public void setBus(String busIn) { - bus = busIn; - } - - /** - * @return Returns the source. - */ - public Map getSource() { - return source; - } - - /** - * @param sourceIn The source to set. - */ - public void setSource(Map sourceIn) { - source = sourceIn; - } - - /** - * Parse the <disk> element of a domain XML definition - * - * @param node the disk element - * @param vmInfo the VM informations to merge with the disk definition - * @return the created disk object - * - * @throws IllegalArgumentException if the input element is badly formatted - */ - @SuppressWarnings("unchecked") - public static GuestDiskDef parse(Element node, Optional vmInfo) throws IllegalArgumentException { - GuestDiskDef disk = new GuestDiskDef(); - disk.setType(node.getAttributeValue("type")); - disk.setDevice(node.getAttributeValue("device", "disk")); - - Element targetNode = node.getChild("target"); - if (targetNode == null) { - throw new IllegalArgumentException("Missing disk device target"); - } - disk.setBus(targetNode.getAttributeValue("bus")); - disk.setTarget(targetNode.getAttributeValue("dev")); - - Element driverNode = node.getChild("driver"); - if (driverNode != null) { - disk.setFormat(driverNode.getAttributeValue("type")); - } - - Element sourceNode = node.getChild("source"); - if (sourceNode != null) { - // Declare functions extracting the data from each source type. - // extractors maps a disk type to a map of properties / functions to get the value - Map>> extractors = new HashMap<>(); - - Map> fileExtractors = new HashMap<>(); - fileExtractors.put("file", element -> element.getAttributeValue("file")); - extractors.put("file", fileExtractors); - - Map> dirExtractors = new HashMap<>(); - dirExtractors.put("dir", element -> element.getAttributeValue("dir")); - extractors.put("dir", dirExtractors); - - Map> blockExtractors = new HashMap<>(); - blockExtractors.put("dev", element -> element.getAttributeValue("dev")); - extractors.put("block", blockExtractors); - - Map> netExtractors = new HashMap<>(); - netExtractors.put("protocol", element -> element.getAttributeValue("protocol")); - netExtractors.put("name", element -> element.getAttributeValue("name")); - netExtractors.put("host", element -> ((List)element.getChildren("host")).stream() - .map(hostNode -> ((List)hostNode.getAttributes()).stream() - .collect(Collectors.toMap(attr -> attr.getName(), attr -> attr.getValue())))); - extractors.put("network", netExtractors); - - Map> volumeExtractors = new HashMap<>(); - volumeExtractors.put("pool", element -> element.getAttributeValue("pool")); - volumeExtractors.put("volume", element -> element.getAttributeValue("volume")); - extractors.put("volume", volumeExtractors); - - // Now extract the data for the source - Map source = new HashMap<>(); - Map> extractor = extractors.get(disk.getType()); - if (extractor != null) { - extractor.forEach((key, func) -> { - Object value = func.apply(sourceNode); - if (value != null) { - source.put(key, value); - } - }); - } - - // virt.vm_info provides consolidated file using pools when possible, use it - Optional diskInfo = vmInfo.map(info -> info.getDisks().get(disk.getTarget())); - diskInfo.ifPresent(info -> { - if ("network".equals(disk.getType())) { - String protocol = (String)source.get("protocol"); - // RBD and gluster volumes are automatically converted to network disks. Take the infos from Salt - if (NETWORK_CONVERTED_TYPES.contains(protocol) && - !info.getFile().startsWith(protocol + ":")) { - String[] parts = info.getFile().split("/", 2); - if (parts.length == 2) { - disk.setType("volume"); - source.clear(); - source.put("pool", parts[0]); - source.put("volume", parts[1]); - } - } - // Get the re-assembled URL for network remote cdroms - else if ("cdrom".equals(disk.getDevice())) { - disk.setType("file"); - source.clear(); - source.put("file", info.getFile()); - } - } - else if (Arrays.asList("block", "file").contains(disk.getType())) { - Matcher matcher = BLOCK_REGEX.matcher(info.getFile()); - if (matcher.matches()) { - disk.setType("volume"); - source.clear(); - source.put("pool", matcher.group(1)); - source.put("volume", matcher.group(2)); - } - } - }); - disk.setSource(source); - } - - return disk; - } -} diff --git a/java/code/src/com/suse/manager/virtualization/GuestGraphicsDef.java b/java/code/src/com/suse/manager/virtualization/GuestGraphicsDef.java deleted file mode 100644 index 8f081bd0dc99..000000000000 --- a/java/code/src/com/suse/manager/virtualization/GuestGraphicsDef.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2018 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.suse.manager.virtualization; - -import org.jdom.Element; - -/** - * Class representing the graphics device XML definition. - */ -public class GuestGraphicsDef { - - private String type; - private int port; - - /** - * @return Returns the type ("spice", "vnc"...) - */ - public String getType() { - return type; - } - - /** - * @param typeIn The graphics type to set ("spice", "vnc"...) - */ - public void setType(String typeIn) { - type = typeIn; - } - - /** - * @return The port on which the graphics device is listening - */ - public int getPort() { - return port; - } - - /** - * @param portIn the port on which the graphics device is listening or -1 for automatic port. - */ - public void setPort(int portIn) { - port = portIn; - } - - /** - * Parse the libvirt graphics element - * - * @param element XML element - * - * @return the graphics definition - */ - public static GuestGraphicsDef parse(Element element) { - GuestGraphicsDef def = new GuestGraphicsDef(); - def.setType(element.getAttributeValue("type")); - def.setPort(Integer.parseInt(element.getAttributeValue("port", "-1"))); - - return def; - } -} diff --git a/java/code/src/com/suse/manager/virtualization/GuestInterfaceDef.java b/java/code/src/com/suse/manager/virtualization/GuestInterfaceDef.java deleted file mode 100644 index 8e3ac3fb4263..000000000000 --- a/java/code/src/com/suse/manager/virtualization/GuestInterfaceDef.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (c) 2018 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.suse.manager.virtualization; - -import org.jdom.Element; - -/** - * Class representing the VM interface device XML definition. - */ -public class GuestInterfaceDef { - - private String type; - private String source; - private String mac; - - /** - * @return Returns the type. - */ - public String getType() { - return type; - } - - /** - * @param typeIn The type to set. - */ - public void setType(String typeIn) { - type = typeIn; - } - - /** - * @return Returns the source (network, bridge, etc depending on the type). - */ - public String getSource() { - return source; - } - - /** - * @param sourceIn The source to set. - */ - public void setSource(String sourceIn) { - source = sourceIn; - } - - /** - * @return Returns the mac. - */ - public String getMac() { - return mac; - } - - /** - * @param macIn The mac to set. - */ - public void setMac(String macIn) { - mac = macIn; - } - - /** - * Parse the <interface> element of a domain XML definition - * - * @param element the interface element - * @return the created interface object - * - * @throws IllegalArgumentException if the input element is badly formatted - */ - public static GuestInterfaceDef parse(Element element) throws IllegalArgumentException { - GuestInterfaceDef iface = new GuestInterfaceDef(); - iface.setType(element.getAttributeValue("type")); - Element source = element.getChild("source"); - if (iface.getType() == null || source == null) { - throw new IllegalArgumentException("invalid interface XML definition"); - } - - if (iface.getType().equals("network")) { - iface.setSource(source.getAttributeValue("network")); - } - - // MAC address may be omitted even though libvirt always outputs one. - Element mac = element.getChild("mac"); - if (mac != null) { - iface.setMac(mac.getAttributeValue("address")); - } - - return iface; - } -} diff --git a/java/code/src/com/suse/manager/virtualization/GuestOsDef.java b/java/code/src/com/suse/manager/virtualization/GuestOsDef.java deleted file mode 100644 index fa436df9c656..000000000000 --- a/java/code/src/com/suse/manager/virtualization/GuestOsDef.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright (c) 2018 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.suse.manager.virtualization; - -import org.jdom.Element; - -import java.util.Arrays; -import java.util.List; - -/** - * Class representing the libvirt domain definition <os> element. - */ -public class GuestOsDef { - - private String arch; - private String type; - private String machine; - private String uefiLoader; - private String nvramTemplate; - - /** - * @return VM architecture - */ - public String getArch() { - return arch; - } - - /** - * Set the VM architecture. - * - * @param archIn the VM architecture - */ - public void setArch(String archIn) { - this.arch = archIn; - } - - /** - * @return Virtual Machine type. One of "hvm", "linux", "xen", "exe" or "uml" - */ - public String getType() { - return type; - } - - /** - * Set the virtual machine type. - * - * @param typeIn one of "hvm", "linux", "xen", "exe" or "uml" - */ - public void setType(String typeIn) { - List types = Arrays.asList("hvm", "linux", "xen", "exe", "uml"); - if (types.contains(typeIn)) { - this.type = typeIn; - } - } - - /** - * @return VM machine - */ - public String getMachine() { - return machine; - } - - /** - * Set the machine VM ID. This value is depending on the underlying hypervisor. - * - * @param machineIn the machine type - */ - public void setMachine(String machineIn) { - this.machine = machineIn; - } - - /** - * @return value of uefiLoader - */ - public String getUefiLoader() { - return uefiLoader; - } - - /** - * @param uefiLoaderIn value of uefiLoader - */ - public void setUefiLoader(String uefiLoaderIn) { - uefiLoader = uefiLoaderIn; - } - - /** - * @return value of nvramTemplate - */ - public String getNvramTemplate() { - return nvramTemplate; - } - - /** - * @param nvramTemplateIn value of nvramTemplate - */ - public void setNvramTemplate(String nvramTemplateIn) { - nvramTemplate = nvramTemplateIn; - } - - /** - * Parse the libvirt <os> element - * - * @param element XML element - * - * @return the OS definition - */ - public static GuestOsDef parse(Element element) { - GuestOsDef def = new GuestOsDef(); - - Element typeElement = element.getChild("type"); - def.setArch(typeElement.getAttributeValue("arch")); - def.setType(typeElement.getTextTrim()); - def.setMachine(typeElement.getAttributeValue("machine")); - - Element loaderElement = element.getChild("loader"); - if (loaderElement != null && "pflash".equals(loaderElement.getAttributeValue("type"))) { - def.setUefiLoader(loaderElement.getTextTrim()); - Element nvramElement = element.getChild("nvram"); - if (nvramElement != null) { - def.setNvramTemplate(nvramElement.getAttributeValue("template")); - } - } - return def; - } - -} diff --git a/java/code/src/com/suse/manager/virtualization/GuestVcpuDef.java b/java/code/src/com/suse/manager/virtualization/GuestVcpuDef.java deleted file mode 100644 index f6ea8b5fd797..000000000000 --- a/java/code/src/com/suse/manager/virtualization/GuestVcpuDef.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2018 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.suse.manager.virtualization; - -import org.jdom.Element; - -/** - * Represents the libvirt domain vcpu definition - */ -public class GuestVcpuDef { - - private int max; - private int current; - - /** - * @return maximum number of Virtual CPUs - */ - public int getMax() { - return max; - } - - /** - * Set the maximum number of virtual CPUs. - * - * If setting a value smaller than the amount of current VCPUs, the - * latter will be adjusted. - * - * @param maxIn maximum number of Virtual CPUs - */ - public void setMax(int maxIn) { - this.max = maxIn; - this.current = Math.min(this.max, this.current); - } - - /** - * @return current number of Virtual CPUs - */ - public int getCurrent() { - return current; - } - - /** - * Set the current number of virtual CPUs. - * - * Don't forget to change the maximum before raising the current amount of CPUs - * or it will be capped. - * - * @param currentIn current number of Virtual CPUs - */ - public void setCurrent(int currentIn) { - this.current = Math.min(currentIn, this.max); - } - - /** - * Parse libvirt domain definition XML <vcpu> element - * - * @param element XML element - * @return the cpu definition - */ - public static GuestVcpuDef parse(Element element) { - GuestVcpuDef def = new GuestVcpuDef(); - - def.setMax(Integer.parseUnsignedInt(element.getTextTrim())); - def.setCurrent(def.max); - String value = element.getAttributeValue("current"); - if (value != null) { - def.setCurrent(Integer.parseUnsignedInt(value)); - } - - return def; - } - -} diff --git a/java/code/src/com/suse/manager/virtualization/HostCapabilitiesJson.java b/java/code/src/com/suse/manager/virtualization/HostCapabilitiesJson.java deleted file mode 100644 index 7a3d08128f11..000000000000 --- a/java/code/src/com/suse/manager/virtualization/HostCapabilitiesJson.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (c) 2018 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.suse.manager.virtualization; - -import com.google.gson.annotations.SerializedName; - -import java.util.List; -import java.util.Map; - -/** - * Class representing the salt output for host capabilities - */ -public class HostCapabilitiesJson { - - private List guests; - - /** - * @return Returns the guests. - */ - public List getGuests() { - return guests; - } - - /** - * @param guestsIn The guests to set. - */ - public void setGuests(List guestsIn) { - guests = guestsIn; - } - - - /** - * Represents the items in the guests field. - */ - public class Guest { - - private Arch arch; - - @SerializedName("os_type") - private String osType; - - /** - * @return Returns the arch. - */ - public Arch getArch() { - return arch; - } - - /** - * @param archIn The arch to set. - */ - public void setArch(Arch archIn) { - arch = archIn; - } - - /** - * @return Returns the osType. - */ - public String getOsType() { - return osType; - } - - /** - * @param osTypeIn The osType to set. - */ - public void setOsType(String osTypeIn) { - osType = osTypeIn; - } - - } - - /** - * Represents the arch field of a guest. - */ - public class Arch { - - private String name; - private Map domains; - - /** - * @return Returns the name. - */ - public String getName() { - return name; - } - - /** - * @param nameIn The name to set. - */ - public void setName(String nameIn) { - name = nameIn; - } - - /** - * @return Returns the domains. - */ - public Map getDomains() { - return domains; - } - - /** - * @param domainsIn The domains to set. - */ - public void setDomains(Map domainsIn) { - domains = domainsIn; - } - } -} diff --git a/java/code/src/com/suse/manager/virtualization/HostInfo.java b/java/code/src/com/suse/manager/virtualization/HostInfo.java deleted file mode 100644 index 7b155e287bde..000000000000 --- a/java/code/src/com/suse/manager/virtualization/HostInfo.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2021 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.suse.manager.virtualization; - - -import com.google.gson.annotations.SerializedName; - -import java.util.List; - -/** - * Represents virtualization host informations - */ -public class HostInfo { - private String hypervisor; - - @SerializedName("cluster_other_nodes") - private List clusterOtherNodes = List.of(); - - /** - * @return value of hypervisor - */ - public String getHypervisor() { - return hypervisor; - } - - /** - * @param hypervisorIn value of hypervisor - */ - public void setHypervisor(String hypervisorIn) { - hypervisor = hypervisorIn; - } - - /** - * @return value of clusterOtherNodes - */ - public List getClusterOtherNodes() { - return clusterOtherNodes; - } - - /** - * @param clusterOtherNodesIn value of clusterOtherNodes - */ - public void setClusterOtherNodes(List clusterOtherNodesIn) { - clusterOtherNodes = clusterOtherNodesIn; - } -} diff --git a/java/code/src/com/suse/manager/virtualization/IpDef.java b/java/code/src/com/suse/manager/virtualization/IpDef.java deleted file mode 100644 index 050951248c6d..000000000000 --- a/java/code/src/com/suse/manager/virtualization/IpDef.java +++ /dev/null @@ -1,207 +0,0 @@ -/* - * Copyright (c) 2021 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.suse.manager.virtualization; - -import com.suse.utils.Ip; - -import com.google.gson.annotations.SerializedName; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.jdom.Element; - -import java.net.UnknownHostException; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - -/** - * Represents the IP configuration of a virtual network - */ -public class IpDef { - private static final Logger LOG = LogManager.getLogger(IpDef.class); - - private String address; - private Integer prefix; - - @SerializedName("dhcpranges") - private List> dhcpRanges = new ArrayList<>(); - private List hosts = new ArrayList<>(); - - @SerializedName("bootpfile") - private Optional bootpFile = Optional.empty(); - - @SerializedName("bootpserver") - private Optional bootpServer = Optional.empty(); - private Optional tftp = Optional.empty(); - - /** - * @return value of address - */ - public String getAddress() { - return address; - } - - /** - * @param addressIn value of address - */ - public void setAddress(String addressIn) { - address = addressIn; - } - - /** - * @return value of prefix - */ - public Integer getPrefix() { - return prefix; - } - - /** - * @param prefixIn value of prefix - */ - public void setPrefix(Integer prefixIn) { - prefix = prefixIn; - } - - /** - * @return value of dhcpRange - */ - public List> getDhcpRanges() { - return dhcpRanges; - } - - /** - * @param dhcpRangesIn value of dhcpRange - */ - public void setDhcpRanges(List> dhcpRangesIn) { - dhcpRanges = dhcpRangesIn; - } - - /** - * @return value of host - */ - public List getHosts() { - return hosts; - } - - /** - * @param hostsIn value of host - */ - public void setHosts(List hostsIn) { - hosts = hostsIn; - } - - /** - * @return value of bootpFile - */ - public Optional getBootpFile() { - return bootpFile; - } - - /** - * @param bootpFileIn value of bootpFile - */ - public void setBootpFile(Optional bootpFileIn) { - bootpFile = bootpFileIn; - } - - /** - * @return value of bootpServer - */ - public Optional getBootpServer() { - return bootpServer; - } - - /** - * @param bootpServerIn value of bootpServer - */ - public void setBootpServer(Optional bootpServerIn) { - bootpServer = bootpServerIn; - } - - /** - * @return value of tftp - */ - public Optional getTftp() { - return tftp; - } - - /** - * @param tftpIn value of tftp - */ - public void setTftp(Optional tftpIn) { - tftp = tftpIn; - } - - /** - * Parse IP XML node - * @param node the node to parse - * @return the parsed IP definition - */ - public static Optional parse(Element node) { - IpDef def = new IpDef(); - String address = node.getAttributeValue("address"); - - String prefixStr = node.getAttributeValue("prefix"); - String netmask = node.getAttributeValue("netmask"); - int prefix = 0; - if (prefixStr != null) { - prefix = Integer.parseInt(prefixStr); - } - else if (netmask != null) { - // Convert netmask into prefix - try { - prefix = Ip.netmaskToPrefix(netmask); - } - catch (UnknownHostException e) { - LOG.error("Invalid netmask: {}", netmask); - return Optional.empty(); - } - } - def.setPrefix(prefix); - - // Address needs to be the network address (not the gateway one) - try { - def.setAddress(Ip.getNetworkAddress(address, prefix)); - } - catch (UnknownHostException e) { - LOG.error("Invalid IP address: {}", address); - return Optional.empty(); - } - - Element dhcpNode = node.getChild("dhcp"); - if (dhcpNode != null) { - for (Object o : dhcpNode.getChildren("range")) { - Optional> range = Range.parse((Element)o); - range.ifPresent(r -> def.dhcpRanges.add(r)); - } - - for (Object o : dhcpNode.getChildren("host")) { - def.hosts.add(DhcpHostDef.parse((Element)o)); - } - - Element bootpNode = dhcpNode.getChild("bootp"); - if (bootpNode != null) { - def.setBootpFile(Optional.ofNullable(bootpNode.getAttributeValue("file"))); - def.setBootpServer(Optional.ofNullable(bootpNode.getAttributeValue("server"))); - } - } - Element tftpNode = node.getChild("tftp"); - if (tftpNode != null) { - def.setTftp(Optional.ofNullable(tftpNode.getAttributeValue("root"))); - } - return Optional.of(def); - } -} diff --git a/java/code/src/com/suse/manager/virtualization/NatDef.java b/java/code/src/com/suse/manager/virtualization/NatDef.java deleted file mode 100644 index 360bb1b5d04b..000000000000 --- a/java/code/src/com/suse/manager/virtualization/NatDef.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2021 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.suse.manager.virtualization; - -import org.jdom.Element; - -import java.util.Optional; - -/** - * Represents virtual network NAT configuration - */ -public class NatDef { - private Optional> address = Optional.empty(); - private Optional> port = Optional.empty(); - - /** - * @return NAT address range - */ - public Optional> getAddress() { - return address; - } - - /** - * @param addressIn NAT address range - */ - public void setAddress(Optional> addressIn) { - address = addressIn; - } - - /** - * @return NAT port range - */ - public Optional> getPort() { - return port; - } - - /** - * @param portIn NAT port range - */ - public void setPort(Optional> portIn) { - port = portIn; - } - - /** - * Parse the nat element of the network XML definition - * - * @param node the XML node - * @return the created Nat definition - */ - public static NatDef parseNat(Element node) { - NatDef def = null; - if (node != null) { - def = new NatDef(); - def.setPort(Range.parse(node.getChild("port"), Integer::parseInt)); - def.setAddress(Range.parse(node.getChild("address"))); - } - return def; - } -} diff --git a/java/code/src/com/suse/manager/virtualization/NetworkDefinition.java b/java/code/src/com/suse/manager/virtualization/NetworkDefinition.java deleted file mode 100644 index 7147f898b79b..000000000000 --- a/java/code/src/com/suse/manager/virtualization/NetworkDefinition.java +++ /dev/null @@ -1,450 +0,0 @@ -/* - * Copyright (c) 2021 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.suse.manager.virtualization; - -import com.google.gson.annotations.SerializedName; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.jdom.Document; -import org.jdom.Element; -import org.jdom.input.SAXBuilder; - -import java.io.StringReader; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.function.Consumer; -import java.util.function.Supplier; -import java.util.stream.Collectors; - -/** - * Represents the virtual network create action request body structure. - */ -public class NetworkDefinition { - private static final Logger LOG = LogManager.getLogger(NetworkDefinition.class); - - private String type; - - @SerializedName("macvtapmode") - private Optional macvtapMode = Optional.empty(); - private boolean autostart; - private Optional bridge = Optional.empty(); - private Optional mtu = Optional.empty(); - @SerializedName("virtualport") - private Optional virtualPort = Optional.empty(); - private List interfaces = new ArrayList<>(); - - @SerializedName("vf") - private List virtualFunctions = new ArrayList<>(); - - @SerializedName("pf") - private Optional physicalFunction = Optional.empty(); - - @SerializedName("vlantrunk") - private Optional vlanTrunk = Optional.empty(); - private List vlans = new ArrayList<>(); - private Optional nat = Optional.empty(); - - private Optional ipv4 = Optional.empty(); - private Optional ipv6 = Optional.empty(); - private Optional domain = Optional.empty(); - private Optional dns = Optional.empty(); - - // name and uuid will be empty when creating a new network - private Optional name = Optional.empty(); - private Optional uuid = Optional.empty(); - - /** - * @return value of type - */ - public String getType() { - return type; - } - - /** - * @param typeIn value of type - */ - public void setType(String typeIn) { - type = typeIn; - } - - /** - * @return value of macvtapMode - */ - public Optional getMacvtapMode() { - return macvtapMode; - } - - /** - * @param macvtapModeIn value of macvtapMode - */ - public void setMacvtapMode(Optional macvtapModeIn) { - macvtapMode = macvtapModeIn; - } - - /** - * @return the forward mode as accepted by Salt-virt and libvirt - */ - public String getForwardMode() { - Map> converters = Map.of( - "isolated", () -> null, - "macvtap", () -> getMacvtapMode().orElse("vepa") - ); - return converters.getOrDefault(getType(), this::getType).get(); - } - - /** - * Set the forward mode - * - * @param modeIn the forward mode as found in the XML - */ - public void setForwardMode(String modeIn) { - if (modeIn == null) { - setType("isolated"); - } - else { - Consumer macvtapSetter = mode -> { - setType("macvtap"); - setMacvtapMode(Optional.of(mode)); - }; - Map> converters = Map.of( - "private", macvtapSetter, - "passthrough", macvtapSetter, - "vepa", macvtapSetter - ); - converters.getOrDefault(modeIn, this::setType).accept(modeIn); - } - } - - /** - * @return value of autostart - */ - public boolean isAutostart() { - return autostart; - } - - /** - * @param autostartIn value of autostart - */ - public void setAutostart(boolean autostartIn) { - autostart = autostartIn; - } - - /** - * @return value of bridge - */ - public Optional getBridge() { - return bridge; - } - - /** - * @param bridgeIn value of bridge - */ - public void setBridge(Optional bridgeIn) { - bridge = bridgeIn; - } - - /** - * @return value of mtu - */ - public Optional getMtu() { - return mtu; - } - - /** - * @param mtuIn value of mtu - */ - public void setMtu(Optional mtuIn) { - mtu = mtuIn; - } - - /** - * @return value of virtualPort - */ - public Optional getVirtualPort() { - return virtualPort; - } - - /** - * @param virtualPortIn value of virtualPort - */ - public void setVirtualPort(Optional virtualPortIn) { - virtualPort = virtualPortIn; - } - - /** - * @return value of interfaces - */ - public List getInterfaces() { - return interfaces; - } - - /** - * @param interfacesIn value of interfaces - */ - public void setInterfaces(List interfacesIn) { - interfaces = interfacesIn; - } - - /** - * @return value of virtualFunctions - */ - public List getVirtualFunctions() { - return virtualFunctions; - } - - /** - * @param virtualFunctionsIn value of virtualFunctions - */ - public void setVirtualFunctions(List virtualFunctionsIn) { - virtualFunctions = virtualFunctionsIn; - } - - /** - * @return value of physicalFunction - */ - public Optional getPhysicalFunction() { - return physicalFunction; - } - - /** - * @param physicalFunctionIn value of physicalFunction - */ - public void setPhysicalFunction(Optional physicalFunctionIn) { - physicalFunction = physicalFunctionIn; - } - - /** - * @return value of vlanTrunk - */ - public Optional getVlanTrunk() { - return vlanTrunk; - } - - /** - * @param vlanTrunkIn value of vlanTrunk - */ - public void setVlanTrunk(Optional vlanTrunkIn) { - vlanTrunk = vlanTrunkIn; - } - - /** - * @return value of vlans - */ - public List getVlans() { - return vlans; - } - - /** - * @param vlansIn value of vlans - */ - public void setVlans(List vlansIn) { - vlans = vlansIn; - } - - /** - * @return value of nat - */ - public Optional getNat() { - return nat; - } - - /** - * @param natIn value of nat - */ - public void setNat(Optional natIn) { - nat = natIn; - } - - /** - * @return value of ipv4 - */ - public Optional getIpv4() { - return ipv4; - } - - /** - * @param ipv4In value of ipv4 - */ - public void setIpv4(Optional ipv4In) { - ipv4 = ipv4In; - } - - /** - * @return value of ipv6 - */ - public Optional getIpv6() { - return ipv6; - } - - /** - * @param ipv6In value of ipv6 - */ - public void setIpv6(Optional ipv6In) { - ipv6 = ipv6In; - } - - /** - * @return value of domain - */ - public Optional getDomain() { - return domain; - } - - /** - * @param domainIn value of domain - */ - public void setDomain(Optional domainIn) { - domain = domainIn; - } - - /** - * @return value of dns - */ - public Optional getDns() { - return dns; - } - - /** - * @param dnsIn value of dns - */ - public void setDns(Optional dnsIn) { - dns = dnsIn; - } - - /** - * @return value of name - */ - public Optional getName() { - return name; - } - - /** - * @param nameIn value of name - */ - public void setName(Optional nameIn) { - name = nameIn; - } - - /** - * @return value of uuid - */ - public Optional getUuid() { - return uuid; - } - - /** - * @param uuidIn value of uuid - */ - public void setUuid(Optional uuidIn) { - uuid = uuidIn; - } - - /** - * Parse libvirt network definition - * - * @param xml the libvirt definition XML string - * - * @return the created definition object - */ - public static NetworkDefinition parse(String xml) { - NetworkDefinition def = null; - SAXBuilder builder = new SAXBuilder(); - builder.setValidation(false); - - try { - Document doc = builder.build(new StringReader(xml)); - def = new NetworkDefinition(); - - Element netElement = doc.getRootElement(); - Element forwardNode = netElement.getChild("forward"); - def.setForwardMode(forwardNode != null ? forwardNode.getAttributeValue("mode") : null); - - def.setName(Optional.ofNullable(netElement.getChildText("name"))); - def.setUuid(Optional.ofNullable(netElement.getChildText("uuid"))); - - if (forwardNode != null) { - for (Object child : forwardNode.getChildren()) { - Element node = (Element) child; - switch (node.getName()) { - case "nat": def.setNat(Optional.of(NatDef.parseNat(node))); break; - case "pf": def.setPhysicalFunction(Optional.of(node.getAttributeValue("dev"))); break; - case "interface": def.interfaces.add(node.getAttributeValue("dev")); break; - case "address": def.virtualFunctions.add(NetworkDefinition.getPCIAddress(node)); break; - default: - LOG.error("Unexpected forward mode: {}", node.getName()); - } - } - } - Element bridgeNode = netElement.getChild("bridge"); - if (bridgeNode != null) { - def.setBridge(Optional.ofNullable(bridgeNode.getAttributeValue("name"))); - } - Element mtuNode = netElement.getChild("mtu"); - if (mtuNode != null) { - def.setMtu(Optional.of(Integer.parseInt(mtuNode.getAttributeValue("size")))); - } - def.setVirtualPort(VirtualPortDef.parse(netElement.getChild("virtualport"))); - Element vlanNode = netElement.getChild("vlan"); - if (vlanNode != null) { - String trunk = vlanNode.getAttributeValue("trunk"); - if (trunk != null) { - def.setVlanTrunk(Optional.of(trunk.equals("yes"))); - } - for (Object tag : vlanNode.getChildren("tag")) { - def.vlans.add(VlanDef.parse((Element)tag)); - } - } - Element domainNode = netElement.getChild("domain"); - if (domainNode != null) { - def.setDomain(Optional.ofNullable(domainNode.getAttributeValue("name"))); - } - def.setDns(DnsDef.parse(netElement.getChild("dns"))); - for (Object child : netElement.getChildren("ip")) { - Element ipNode = (Element)child; - String family = ipNode.getAttributeValue("family", "ipv4"); - if ("ipv4".equals(family) && def.getIpv4().isEmpty()) { - def.setIpv4(IpDef.parse(ipNode)); - } - else if ("ipv6".equals(family) && def.getIpv6().isEmpty()) { - def.setIpv6(IpDef.parse(ipNode)); - } - } - } - catch (Exception e) { - LOG.error("failed to parse libvirt network XML definition: {}", e.getMessage()); - def = null; - } - - return def; - } - - private static String getPCIAddress(Element node) { - List attributes = List.of("domain", "bus", "slot", "function"); - List parts = attributes.stream().map( - attr -> parseNumber(node.getAttributeValue(attr)) - ).collect(Collectors.toList()); - return String.format("%04x:%02x:%02x.%x", parts.get(0), parts.get(1), parts.get(2), parts.get(3)).toUpperCase(); - } - - private static int parseNumber(String value) { - if (value.startsWith("0x")) { - return Integer.parseInt(value.substring(2), 16); - } - return Integer.parseInt(value); - } -} diff --git a/java/code/src/com/suse/manager/virtualization/PoolCapabilitiesJson.java b/java/code/src/com/suse/manager/virtualization/PoolCapabilitiesJson.java deleted file mode 100644 index 8373d8fe6ed7..000000000000 --- a/java/code/src/com/suse/manager/virtualization/PoolCapabilitiesJson.java +++ /dev/null @@ -1,222 +0,0 @@ -/* - * Copyright (c) 2019 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.suse.manager.virtualization; - -import com.google.gson.annotations.SerializedName; - -import java.util.List; - -/** - * Class representing the salt output for pool capabilities - */ -public class PoolCapabilitiesJson { - private boolean computed; - - @SerializedName("pool_types") - private List poolTypes; - - - /** - * @return Returns the computed flag. - */ - public boolean isComputed() { - return computed; - } - - - /** - * @param computedIn The computed flag to set. - */ - public void setComputed(boolean computedIn) { - computed = computedIn; - } - - - /** - * @return Returns the pool types. - */ - public List getPoolTypes() { - return poolTypes; - } - - - /** - * @param poolTypesIn The pool types to set. - */ - public void setPoolTypes(List poolTypesIn) { - poolTypes = poolTypesIn; - } - - /** - * Represents the items in the poolTypes property - */ - public class PoolType { - private String name; - private boolean supported; - private Options options; - - /** - * @return Returns the name. - */ - public String getName() { - return name; - } - - /** - * @param nameIn The name to set. - */ - public void setName(String nameIn) { - name = nameIn; - } - - /** - * @return Returns the supported. - */ - public boolean isSupported() { - return supported; - } - - /** - * @param supportedIn The supported to set. - */ - public void setSupported(boolean supportedIn) { - supported = supportedIn; - } - - /** - * @return Returns the options. - */ - public Options getOptions() { - return options; - } - - /** - * @param optionsIn The options to set. - */ - public void setOptions(Options optionsIn) { - options = optionsIn; - } - } - - /** - * Holds the pool and volume options structures - */ - public class Options { - private PoolOptions pool; - private VolumeOptions volume; - - /** - * @return Returns the pool options. - */ - public PoolOptions getPool() { - return pool; - } - - /** - * @param poolIn The pool options to set. - */ - public void setPool(PoolOptions poolIn) { - pool = poolIn; - } - - /** - * @return Returns the volume options. - */ - public VolumeOptions getVolume() { - return volume; - } - - /** - * @param volumeIn The volume options to set. - */ - public void setVolume(VolumeOptions volumeIn) { - volume = volumeIn; - } - } - - /** - * Represents the pool options - */ - public class PoolOptions { - @SerializedName("default_format") - private String defaultFormat; - private List sourceFormatType; - - /** - * @return Returns the default format. - */ - public String getDefaultFormat() { - return defaultFormat; - } - - /** - * @param defaultFormatIn The default format to set. - */ - public void setDefaultFormat(String defaultFormatIn) { - defaultFormat = defaultFormatIn; - } - - /** - * @return Returns the sourceFormatType. - */ - public List getSourceFormatType() { - return sourceFormatType; - } - - /** - * @param sourceFormatTypeIn The sourceFormatType to set. - */ - public void setSourceFormatType(List sourceFormatTypeIn) { - sourceFormatType = sourceFormatTypeIn; - } - } - - /** - * Represents the volume options - */ - public class VolumeOptions { - @SerializedName("default_format") - private String defaultFormat; - private List targetFormatType; - - /** - * @return Returns the default format. - */ - public String getDefaultFormat() { - return defaultFormat; - } - - /** - * @param defaultFormatIn The default format to set. - */ - public void setDefaultFormat(String defaultFormatIn) { - defaultFormat = defaultFormatIn; - } - - /** - * @return Returns the targetFormatType. - */ - public List getTargetFormatType() { - return targetFormatType; - } - - /** - * @param targetFormatTypeIn The targetFormatType to set. - */ - public void setTargetFormatType(List targetFormatTypeIn) { - targetFormatType = targetFormatTypeIn; - } - } -} diff --git a/java/code/src/com/suse/manager/virtualization/PoolDefinition.java b/java/code/src/com/suse/manager/virtualization/PoolDefinition.java deleted file mode 100644 index 38c5f70e8382..000000000000 --- a/java/code/src/com/suse/manager/virtualization/PoolDefinition.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Copyright (c) 2019 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.suse.manager.virtualization; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.jdom.Document; -import org.jdom.Element; -import org.jdom.input.SAXBuilder; - -import java.io.StringReader; - -/** - * Class representing the Virtual Storage Pool XML Definition. - */ -public class PoolDefinition { - private static final Logger LOG = LogManager.getLogger(PoolDefinition.class); - - private String type; - private String name; - private String uuid; - private boolean autostart; - - private PoolTarget target; - private PoolSource source; - - /** - * @return the pool type - */ - public String getType() { - return type; - } - - /** - * @param typeIn The type to set. - */ - public void setType(String typeIn) { - type = typeIn; - } - - /** - * @return pool name - */ - public String getName() { - return name; - } - - /** - * Set the pool name - * - * @param nameIn pool name - */ - public void setName(String nameIn) { - this.name = nameIn; - } - - /** - * @return pool UUID - */ - public String getUuid() { - return uuid; - } - - /** - * @param uuidIn The uuid to set. - */ - public void setUuid(String uuidIn) { - uuid = uuidIn; - } - - /** - * @return Returns whether the pool is to be autostarted. - */ - public boolean isAutostart() { - return autostart; - } - - /** - * @param autostartIn whether the pool is to be autostarted. - */ - public void setAutostart(boolean autostartIn) { - autostart = autostartIn; - } - - /** - * @return Returns the target. - */ - public PoolTarget getTarget() { - return target; - } - - /** - * @param targetIn The target to set. - */ - public void setTarget(PoolTarget targetIn) { - target = targetIn; - } - - /** - * @return Returns the source. - */ - public PoolSource getSource() { - return source; - } - - /** - * @param sourceIn The source to set. - */ - public void setSource(PoolSource sourceIn) { - source = sourceIn; - } - - /** - * Create a new storage pool definition from a libvirt XML description. - * - * @param xmlDef libvirt XML storage pool definition - * @return parsed definition or {@code null} - */ - public static PoolDefinition parse(String xmlDef) { - PoolDefinition def = null; - SAXBuilder builder = new SAXBuilder(); - builder.setValidation(false); - - try { - Document doc = builder.build(new StringReader(xmlDef)); - def = new PoolDefinition(); - - Element poolElement = doc.getRootElement(); - def.type = poolElement.getAttributeValue("type"); - def.setName(poolElement.getChildText("name")); - def.uuid = poolElement.getChildText("uuid"); - - def.setTarget(PoolTarget.parse(poolElement.getChild("target"))); - def.setSource(PoolSource.parse(poolElement.getChild("source"))); - } - catch (Exception e) { - LOG.error("failed to parse libvirt pool XML definition: {}", e.getMessage()); - def = null; - } - - return def; - } -} diff --git a/java/code/src/com/suse/manager/virtualization/PoolSource.java b/java/code/src/com/suse/manager/virtualization/PoolSource.java deleted file mode 100644 index 7facb23a7bd2..000000000000 --- a/java/code/src/com/suse/manager/virtualization/PoolSource.java +++ /dev/null @@ -1,194 +0,0 @@ -/* - * Copyright (c) 2019 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.suse.manager.virtualization; - -import org.jdom.Element; - -import java.util.List; -import java.util.stream.Collectors; - -/** - * Represents a virtual pool storage source definition - */ -public class PoolSource { - - private String dir; - private List devices; - private List hosts; - private PoolSourceAdapter adapter; - private PoolSourceAuthentication auth; - private String name; - private String format; - private String initiator; - - /** - * @return Returns the source directory. - */ - public String getDir() { - return dir; - } - - /** - * @param dirIn The source directory to set. - */ - public void setDir(String dirIn) { - dir = dirIn; - } - - /** - * @return Returns the source devices. - */ - public List getDevices() { - return devices; - } - - /** - * @param devicesIn The source devices to set. - */ - public void setDevices(List devicesIn) { - devices = devicesIn; - } - - /** - * @return Returns the source hosts. - */ - public List getHosts() { - return hosts; - } - - /** - * @param hostsIn The source hosts to set. - */ - public void setHosts(List hostsIn) { - hosts = hostsIn; - } - - /** - * @return Returns the source SCSI adapter. - */ - public PoolSourceAdapter getAdapter() { - return adapter; - } - - /** - * @param adapterIn The source SCSI adapter to set. - */ - public void setAdapter(PoolSourceAdapter adapterIn) { - adapter = adapterIn; - } - - /** - * @return Returns the source authentication. - */ - public PoolSourceAuthentication getAuth() { - return auth; - } - - /** - * @param authIn The source authentication to set. - */ - public void setAuth(PoolSourceAuthentication authIn) { - auth = authIn; - } - - /** - * @return Returns the source name. - */ - public String getName() { - return name; - } - - /** - * @param nameIn The source name to set. - */ - public void setName(String nameIn) { - name = nameIn; - } - - /** - * @return Returns the source format. - */ - public String getFormat() { - return format; - } - - /** - * @param formatIn The source format to set. - */ - public void setFormat(String formatIn) { - format = formatIn; - } - - /** - * @return Returns the initiator IQN. - */ - public String getInitiator() { - return initiator; - } - - /** - * @param initiatorIn The initiator IQN to set. - */ - public void setInitiator(String initiatorIn) { - initiator = initiatorIn; - } - - /** - * Extract the data from the libvirt pool XML source element. - * - * @param node the source XML element - * @return the created source - */ - @SuppressWarnings("unchecked") - public static PoolSource parse(Element node) { - PoolSource result = null; - if (node != null) { - result = new PoolSource(); - Element dir = node.getChild("dir"); - if (dir != null) { - result.setDir(dir.getAttributeValue("path")); - } - result.setName(node.getChildText("name")); - if (dir != null) { - result.setDir(dir.getAttributeValue("path")); - } - Element format = node.getChild("format"); - if (format != null) { - result.setFormat(format.getAttributeValue("type")); - } - Element initiator = node.getChild("initiator"); - if (initiator != null) { - Element iqn = initiator.getChild("iqn"); - if (iqn != null) { - result.setInitiator(iqn.getAttributeValue("name")); - } - } - result.setAdapter(PoolSourceAdapter.parse(node.getChild("adapter"))); - result.setAuth(PoolSourceAuthentication.parse(node.getChild("auth"))); - result.setDevices(((List)node.getChildren("device")).stream() - .map(PoolSourceDevice::parse) - .collect(Collectors.toList())); - result.setHosts(((List)node.getChildren("host")).stream() - .map(host -> { - String name = host.getAttributeValue("name"); - String port = host.getAttributeValue("port"); - return String.format("%s%s", name, port != null ? ":" + port : ""); - }) - .collect(Collectors.toList())); - } - return result; - } - -} diff --git a/java/code/src/com/suse/manager/virtualization/PoolSourceAdapter.java b/java/code/src/com/suse/manager/virtualization/PoolSourceAdapter.java deleted file mode 100644 index d95df93dcd07..000000000000 --- a/java/code/src/com/suse/manager/virtualization/PoolSourceAdapter.java +++ /dev/null @@ -1,253 +0,0 @@ -/* - * Copyright (c) 2019 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.suse.manager.virtualization; - -import org.jdom.Element; - -import java.util.HashMap; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * Class representing the adapter parameters for SCSI sources. - */ -public class PoolSourceAdapter { - private String type; - private String name; - private String parent; - private boolean managed = false; - private String wwnn; - private String wwpn; - private String parentWwnn; - private String parentWwpn; - private String parentFabricWwn; - private String parentAddressUid; - private String parentAddress; - - /** - * @return Returns the type. - */ - public String getType() { - return type; - } - - /** - * @param typeIn The type to set. Should be one of 'scsi_host' or 'fc_host'. - */ - public void setType(String typeIn) { - type = typeIn; - } - - /** - * @return Returns the name. - */ - public String getName() { - return name; - } - - /** - * @param nameIn The name to set. - */ - public void setName(String nameIn) { - name = nameIn; - } - - /** - * @return Returns the parent. - */ - public String getParent() { - return parent; - } - - /** - * @param parentIn The parent to set. - */ - public void setParent(String parentIn) { - parent = parentIn; - } - - /** - * @return Returns true if the vHBA should be destroyed with the pool. - */ - public boolean isManaged() { - return managed; - } - - /** - * @param managedIn true if the vHBA should be destroyed with the pool. - */ - public void setManaged(boolean managedIn) { - managed = managedIn; - } - - /** - * @return Returns the wwnn. - */ - public String getWwnn() { - return wwnn; - } - - /** - * @param wwnnIn The wwnn to set. - */ - public void setWwnn(String wwnnIn) { - wwnn = wwnnIn; - } - - /** - * @return Returns the wwpn. - */ - public String getWwpn() { - return wwpn; - } - - /** - * @param wwpnIn The wwpn to set. - */ - public void setWwpn(String wwpnIn) { - wwpn = wwpnIn; - } - - /** - * @return Returns the parent wwnn. - */ - public String getParentWwnn() { - return parentWwnn; - } - - /** - * @param parentWwnnIn The parent wwnn to set. - */ - public void setParentWwnn(String parentWwnnIn) { - parentWwnn = parentWwnnIn; - } - - /** - * @return Returns the parent wwpn. - */ - public String getParentWwpn() { - return parentWwpn; - } - - /** - * @param parentWwpnIn The parent wwpn to set. - */ - public void setParentWwpn(String parentWwpnIn) { - parentWwpn = parentWwpnIn; - } - - /** - * @return Returns the parent fabric_wwn. - */ - public String getParentFabricWwn() { - return parentFabricWwn; - } - - /** - * @param parentFabricWwnIn The parent fabric_wwn to set. - */ - public void setParentFabricWwn(String parentFabricWwnIn) { - parentFabricWwn = parentFabricWwnIn; - } - - /** - * @return Returns the parent address unique id. - */ - public String getParentAddressUid() { - return parentAddressUid; - } - - /** - * @param parentAddressUidIn The parent address unique id to set. - */ - public void setParentAddressUid(String parentAddressUidIn) { - parentAddressUid = parentAddressUidIn; - } - - /** - * @return Returns the parent address domain part. - */ - public String getParentAddress() { - return parentAddress; - } - - /** - * @param parentAddressIn The parent PCI address. - * @throws IllegalArgumentException if the value is not in format 0000:00:00.0 - */ - public void setParentAddress(String parentAddressIn) throws IllegalArgumentException { - if (parentAddressIn != null && - !parentAddressIn.matches("^([0-9a-fA-F]{4}):([0-9a-fA-F]{2}):([0-9a-fA-F]{2}).([0-9a-fA-F])$")) { - throw new IllegalArgumentException("Parent address not in format 0000:00:00.0: " + parentAddressIn); - } - parentAddress = parentAddressIn; - } - - /** - * @return Returns the parent PCI address parsed into a map with keys 'domain', 'bus', 'slot' and 'function' - */ - public Map getParentAddressParsed() { - Matcher matcher = Pattern.compile("^([0-9a-fA-F]{4}):([0-9a-fA-F]{2}):([0-9a-fA-F]{2}).([0-9a-fA-F])$") - .matcher(parentAddress); - Map result = new HashMap<>(); - result.put("domain", matcher.group(1)); - result.put("bus", matcher.group(2)); - result.put("slot", matcher.group(3)); - result.put("function", matcher.group(4)); - return result; - } - - /** - * Extract the data from the libvirt pool XML source adapter element. - * - * @param node the source adapter XML element - * @return the created source adapter - * @throws IllegalArgumentException if the node is missing required attributes or children - */ - public static PoolSourceAdapter parse(Element node) throws IllegalArgumentException { - PoolSourceAdapter result = null; - if (node != null) { - result = new PoolSourceAdapter(); - result.setType(node.getAttributeValue("type")); - result.setName(node.getAttributeValue("name")); - Element parentAddr = node.getChild("parentaddr"); - if (parentAddr != null) { - result.setParentAddressUid(parentAddr.getAttributeValue("unique_id")); - Element addr = parentAddr.getChild("address"); - if (addr == null) { - throw new IllegalArgumentException("Missing source adapter parent address PCI address"); - } - result.setParentAddress(String.format("%s:%s:%s.%s", - addr.getAttributeValue("domain"), - addr.getAttributeValue("bus"), - addr.getAttributeValue("slot"), - addr.getAttributeValue("function")).replaceAll("0x", "")); - } - result.setParent(node.getAttributeValue("parent")); - result.setManaged("yes".equals(node.getAttributeValue("managed"))); - result.setParentWwnn(node.getAttributeValue("parent_wwnn")); - result.setParentWwpn(node.getAttributeValue("parent_wwpn")); - result.setParentFabricWwn(node.getAttributeValue("parent_fabric_wwn")); - result.setWwnn(node.getAttributeValue("wwnn")); - result.setWwpn(node.getAttributeValue("wwpn")); - - if ("fc_host".equals(result.getType()) && (result.getWwnn() == null || result.getWwpn() == null)) { - throw new IllegalArgumentException("Missing mandatory wwnn or wwpn in source adapter"); - } - } - return result; - } -} diff --git a/java/code/src/com/suse/manager/virtualization/PoolSourceAuthentication.java b/java/code/src/com/suse/manager/virtualization/PoolSourceAuthentication.java deleted file mode 100644 index 4d3faefa3ec9..000000000000 --- a/java/code/src/com/suse/manager/virtualization/PoolSourceAuthentication.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright (c) 2019 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.suse.manager.virtualization; - -import org.jdom.Element; - -/** - * Class representing the virtual storage source authentication parameters. - */ -public class PoolSourceAuthentication { - private String username; - private String password; - private String type; - private String secretType; - private String secretValue; - - /** - * Construct authentication - * - * @param usernameIn the username - * @param secretIn the secret - */ - public PoolSourceAuthentication(String usernameIn, String secretIn) { - setUsername(usernameIn); - setPassword(secretIn); - } - - /** - * @return Returns the username. - */ - public String getUsername() { - return username; - } - - /** - * @param usernameIn The username to set. - */ - public void setUsername(String usernameIn) { - username = usernameIn; - } - - /** - * @return Returns the secret. - */ - public String getPassword() { - return password; - } - - /** - * @param passwordIn The secret to set - */ - public void setPassword(String passwordIn) { - password = passwordIn; - } - - - /** - * @return Returns the type. - */ - public String getType() { - return type; - } - - - /** - * @param typeIn The type to set. - */ - public void setType(String typeIn) { - type = typeIn; - } - - - /** - * @return Returns the secretType. - */ - public String getSecretType() { - return secretType; - } - - - /** - * @param secretTypeIn The secretType to set. - */ - public void setSecretType(String secretTypeIn) { - secretType = secretTypeIn; - } - - - /** - * @return Returns the secretValue. - */ - public String getSecretValue() { - return secretValue; - } - - - /** - * @param secretValueIn The secretValue to set. - */ - public void setSecretValue(String secretValueIn) { - secretValue = secretValueIn; - } - - /** - * Extract the data from the libvirt pool XML source authentication element. - * - * @param node the source authentication XML element - * @return the created source authentication - * @throws IllegalArgumentException if the node is missing required attributes or children - */ - public static PoolSourceAuthentication parse(Element node) throws IllegalArgumentException { - PoolSourceAuthentication result = null; - if (node != null) { - String username = node.getAttributeValue("username"); - if (username == null) { - throw new IllegalArgumentException("Missing required username in pool source authentication"); - } - result = new PoolSourceAuthentication(username, null); - result.setType(node.getAttributeValue("type")); - Element secret = node.getChild("secret"); - if (secret != null) { - String uuid = secret.getAttributeValue("uuid"); - String usage = secret.getAttributeValue("usage"); - if (uuid != null) { - result.setSecretType("uuid"); - result.setSecretValue(uuid); - } - else if (usage != null) { - result.setSecretType("usage"); - result.setSecretValue(usage); - } - } - } - return result; - } -} diff --git a/java/code/src/com/suse/manager/virtualization/PoolSourceDevice.java b/java/code/src/com/suse/manager/virtualization/PoolSourceDevice.java deleted file mode 100644 index 876ced0d7b27..000000000000 --- a/java/code/src/com/suse/manager/virtualization/PoolSourceDevice.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (c) 2019 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.suse.manager.virtualization; - -import org.jdom.Element; - -import java.util.Optional; - -/** - * Class representing a virtual storage pool device source. - */ -public class PoolSourceDevice { - private String path; - private Optional separator; - - /** - * Device constructor - * - * @param pathIn the path or iSCSI Qualified Name - */ - public PoolSourceDevice(String pathIn) { - setPath(pathIn); - setSeparator(Optional.empty()); - } - - /** - * Device constructor - * - * @param pathIn the path or iSCSI Qualified Name - * @param separatorIn the separator - */ - public PoolSourceDevice(String pathIn, Optional separatorIn) { - setPath(pathIn); - setSeparator(separatorIn); - } - - /** - * @return Returns the device path of iSCSI Qualified Name. - */ - public String getPath() { - return path; - } - - /** - * @param pathIn The device path of iSCSI Qualified Name to set. - */ - public void setPath(String pathIn) { - path = pathIn; - } - - /** - * @return Returns the separator. - */ - public Optional isSeparator() { - return separator; - } - - /** - * @param separatorIn The separator to set. - */ - public void setSeparator(Optional separatorIn) { - separator = separatorIn; - } - - /** - * Extract the data from a libvirt pool XML source device element. - * - * @param node the source device XML element - * @return the created device - * @throws IllegalArgumentException if the node is missing required attributes or children - */ - public static PoolSourceDevice parse(Element node) throws IllegalArgumentException { - PoolSourceDevice result = null; - if (node != null) { - String path = node.getAttributeValue("path"); - String separatorStr = node.getAttributeValue("part_separator"); - if (path == null) { - throw new IllegalArgumentException("Missing mandatory path attribute in device"); - } - Optional separator = Optional.empty(); - if (separatorStr != null) { - separator = Optional.of("yes".equals(separatorStr)); - } - - result = new PoolSourceDevice(path, separator); - } - return result; - } -} diff --git a/java/code/src/com/suse/manager/virtualization/PoolTarget.java b/java/code/src/com/suse/manager/virtualization/PoolTarget.java deleted file mode 100644 index cac8916bc2ae..000000000000 --- a/java/code/src/com/suse/manager/virtualization/PoolTarget.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (c) 2019 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.suse.manager.virtualization; - -import org.jdom.Element; - -/** - * Describes the target properties of a virtual storage pool - */ -public class PoolTarget { - private String path; - private String owner; - private String group; - private String mode; - private String seclabel; - - /** - * @return Returns the path. - */ - public String getPath() { - return path; - } - - /** - * @param pathIn The path to set. - */ - public void setPath(String pathIn) { - path = pathIn; - } - - /** - * @return Returns the owner. - */ - public String getOwner() { - return owner; - } - - /** - * @param ownerIn The owner to set. - */ - public void setOwner(String ownerIn) { - owner = ownerIn; - } - - /** - * @return Returns the group. - */ - public String getGroup() { - return group; - } - - /** - * @param groupIn The group to set. - */ - public void setGroup(String groupIn) { - group = groupIn; - } - - /** - * @return Returns the mode. - */ - public String getMode() { - return mode; - } - - /** - * @param modeIn The mode to set. - */ - public void setMode(String modeIn) { - mode = modeIn; - } - - /** - * @return Returns the seclabel. - */ - public String getSeclabel() { - return seclabel; - } - - /** - * @param seclabelIn The seclabel to set. - */ - public void setSeclabel(String seclabelIn) { - seclabel = seclabelIn; - } - - /** - * Extract the data from the libvirt pool XML target element. - * - * @param node the target XML element - * @return the created target - */ - public static PoolTarget parse(Element node) { - PoolTarget result = null; - if (node != null) { - result = new PoolTarget(); - - result.setPath(node.getChildText("path")); - Element permissions = node.getChild("permissions"); - if (permissions != null) { - result.setOwner(permissions.getChildText("owner")); - result.setGroup(permissions.getChildText("group")); - result.setMode(permissions.getChildText("mode")); - result.setSeclabel(permissions.getChildText("label")); - } - } - return result; - } -} diff --git a/java/code/src/com/suse/manager/virtualization/Range.java b/java/code/src/com/suse/manager/virtualization/Range.java deleted file mode 100644 index 3d84a9e69126..000000000000 --- a/java/code/src/com/suse/manager/virtualization/Range.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2021 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.suse.manager.virtualization; - -import org.jdom.Element; - -import java.util.Optional; -import java.util.function.Function; - -public class Range { - private final T start; - private final T end; - - /** - * Construct a range object. - * - * @param startIn the start value of the range - * @param endIn the end value of the range - * - */ - public Range(T startIn, T endIn) { - this.start = startIn; - this.end = endIn; - } - /** - * @return start value of the range - */ - public T getStart() { - return start; - } - - /** - * @return end value of the range - */ - public T getEnd() { - return end; - } - - /** - * Parse a range XML node - * - * @param node the node to parse - * - * @return the Range definition - */ - public static Optional> parse(Element node) { - return parse(node, Function.identity()); - } - - /** - * Parse a range XML node - * - * @param node the node to parse - * @param converter function converting the string representation to the destination type - * @param The type of the range to create - * - * @return the Range definition - */ - public static Optional> parse(Element node, Function converter) { - if (node == null) { - return Optional.empty(); - } - Range def = new Range<>( - converter.apply(node.getAttributeValue("start")), - converter.apply(node.getAttributeValue("end")) - ); - return Optional.of(def); - } -} diff --git a/java/code/src/com/suse/manager/virtualization/VirtManagerSalt.java b/java/code/src/com/suse/manager/virtualization/VirtManagerSalt.java deleted file mode 100644 index 645c9c29108c..000000000000 --- a/java/code/src/com/suse/manager/virtualization/VirtManagerSalt.java +++ /dev/null @@ -1,337 +0,0 @@ -/* - * Copyright (c) 2018--2020 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.suse.manager.virtualization; - -import com.redhat.rhn.domain.server.MinionServer; -import com.redhat.rhn.domain.server.Server; -import com.redhat.rhn.manager.system.VirtualInstanceManager; - -import com.suse.manager.webui.services.iface.SaltApi; -import com.suse.manager.webui.services.iface.VirtManager; -import com.suse.manager.webui.utils.salt.custom.GuestProperties; -import com.suse.manager.webui.utils.salt.custom.VmInfo; -import com.suse.salt.netapi.calls.LocalCall; -import com.suse.salt.netapi.calls.modules.Grains; -import com.suse.salt.netapi.calls.modules.State; - -import com.google.gson.GsonBuilder; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.reflect.TypeToken; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import java.util.stream.Collectors; - -/** - * Service providing utility functions to handle virtual machines using salt. - */ -public class VirtManagerSalt implements VirtManager { - - private final SaltApi saltApi; - - /** - * Service providing utility functions to handle virtual machines. - * @param saltApiIn instance interacting with salt. - */ - public VirtManagerSalt(SaltApi saltApiIn) { - this.saltApi = saltApiIn; - } - - /** - * {@inheritDoc} - */ - @Override - public Optional getGuestDefinition(String minionId, String uuid) { - String fixedUuid = uuid; - String uuidPattern = "^([0-9a-fA-F]{8})([0-9a-fA-F]{4})([0-9a-fA-F]{4})([0-9a-fA-F]{4})([0-9a-fA-F]{12}$)"; - Matcher matcher = Pattern.compile(uuidPattern).matcher(uuid); - if (matcher.matches()) { - fixedUuid = String.format("%s-%s-%s-%s-%s", matcher.group(1), matcher.group(2), matcher.group(3), - matcher.group(4), matcher.group(5)); - } - - Map args = new LinkedHashMap<>(); - args.put("uuid", fixedUuid); - - LocalCall> vmDefCall = new LocalCall<>("virt_utils.vm_definition", - Optional.empty(), Optional.of(args), - new TypeToken<>() { - }); - Optional> data = saltApi.callSync(vmDefCall, minionId); - - return data.map(vmData -> { - Optional info = Optional.empty(); - if (vmData.containsKey("info")) { - info = Optional.ofNullable(new GsonBuilder().create() - .fromJson(vmData.get("info"), new TypeToken() { }.getType())); - } - if (vmData.containsKey("definition")) { - String xml = vmData.get("definition").getAsString(); - return GuestDefinition.parse(xml, info); - } - return null; - }); - } - - /** - * {@inheritDoc} - */ - @Override - public Optional> getCapabilities(String minionId) { - LocalCall> call = - new LocalCall<>("virt.all_capabilities", Optional.empty(), Optional.empty(), - new TypeToken<>() { - }); - - return saltApi.callSync(call, minionId); - } - - /** - * {@inheritDoc} - */ - @Override - public Optional getPoolCapabilities(String minionId) { - LocalCall call = - new LocalCall<>("virt.pool_capabilities", Optional.empty(), Optional.empty(), - new TypeToken<>() { - }); - - return saltApi.callSync(call, minionId); - } - - /** - * {@inheritDoc} - */ - @Override - public Optional getPoolDefinition(String minionId, String poolName) { - Map infos = getPools(minionId); - - Map args = new LinkedHashMap<>(); - args.put("name", poolName); - LocalCall call = - new LocalCall<>("virt.pool_get_xml", Optional.empty(), Optional.of(args), new TypeToken<>() { - }); - - Optional result = saltApi.callSync(call, minionId); - return result.filter(s -> !s.startsWith("ERROR")).map(xml -> { - PoolDefinition pool = PoolDefinition.parse(xml); - if (pool != null) { - pool.setAutostart(infos.get(poolName).get("autostart").getAsInt() == 1); - } - return pool; - }); - } - - /** - * {@inheritDoc} - */ - @Override - public Map getNetworks(String minionId) { - Map args = new LinkedHashMap<>(); - LocalCall> call = - new LocalCall<>("virt.network_info", Optional.empty(), Optional.of(args), - new TypeToken<>() { - }); - - Optional> nets = saltApi.callSync(call, minionId); - Map result = nets.orElse(new HashMap<>()); - - // Workaround: Filter out the entries that don't match since we may get a retcode=0 one. - return result.entrySet().stream() - .filter(entry -> entry.getValue().isJsonObject()) - .collect(Collectors.toMap(Map.Entry::getKey, entry -> entry.getValue().getAsJsonObject())); - } - - @Override - public Optional getNetworkDefinition(String minionId, String netName) { - Map infos = getNetworks(minionId); - Map args = new LinkedHashMap<>(); - args.put("name", netName); - LocalCall call = - new LocalCall<>("virt.network_get_xml", Optional.empty(), Optional.of(args), - new TypeToken<>() { - }); - - Optional result = saltApi.callSync(call, minionId); - return result.filter(s -> !s.startsWith("ERROR")).map(xml -> { - NetworkDefinition network = NetworkDefinition.parse(xml); - if (network != null) { - network.setAutostart(infos.get(netName).get("autostart").getAsInt() == 1); - } - return network; - }); - } - - /** - * {@inheritDoc} - */ - @Override - public List getHostDevices(String minionId) { - LocalCall> call = - new LocalCall<>("virt.node_devices", Optional.empty(), Optional.empty(), - new TypeToken<>() { - }); - return saltApi.callSync(call, minionId).orElse(new ArrayList<>()); - } - - /** - * {@inheritDoc} - */ - @Override - public Map getPools(String minionId) { - Map args = new LinkedHashMap<>(); - LocalCall> call = - new LocalCall<>("virt.pool_info", Optional.empty(), Optional.of(args), - new TypeToken<>() { - }); - - Optional> pools = saltApi.callSync(call, minionId); - Map result = pools.orElse(new HashMap<>()); - - // Workaround: Filter out the entries that don't match since we may get a retcode=0 one. - return result.entrySet().stream() - .filter(entry -> entry.getValue().isJsonObject()) - .collect(Collectors.toMap(Map.Entry::getKey, entry -> entry.getValue().getAsJsonObject())); - } - - /** - * {@inheritDoc} - */ - @Override - public Map> getVolumes(String minionId) { - List args = Arrays.asList(null, null); - LocalCall>> call = - new LocalCall<>("virt.volume_infos", Optional.of(args), Optional.empty(), - new TypeToken<>() { - }); - - Optional>> volumes = saltApi.callSync(call, minionId); - return volumes.orElse(new HashMap<>()); - } - - /** - * {@inheritDoc} - */ - @Override - public void updateLibvirtEngine(MinionServer minion) { - Map pillar = new HashMap<>(); - pillar.put("virt_entitled", minion.hasVirtualizationEntitlement()); - saltApi.callSync(State.apply(Collections.singletonList("virt.engine-events"), - Optional.of(pillar)), minion.getMinionId()); - } - - /** - * {@inheritDoc} - */ - @Override - public Optional getHostInfo(String minionId) { - LocalCall call = - new LocalCall<>("virt_utils.host_info", Optional.empty(), Optional.empty(), - new TypeToken<>() { - }); - - return saltApi.callSync(call, minionId); - } - - @Override - public boolean startGuest(String minionId, String domainName) { - Map args = new LinkedHashMap<>(); - args.put("name", domainName); - LocalCall call = - new LocalCall<>("virt.start", Optional.empty(), Optional.of(args), - new TypeToken<>() { - }); - - return saltApi.callSync(call, minionId).orElse(false); - } - - /** - * Get the plan to update the virtual machines list of a minion. - * - * @param minionId the virtualization host minionId - * - * @return the plan to pass to {@link VirtualInstanceManager#updateGuestsVirtualInstances(Server, List)} - */ - @Override - public Optional> getGuestsUpdatePlan(String minionId) { - // Get the list of VMs with at least (name, cpu, memory, status) virt.vm_info - LocalCall>> call = - new LocalCall<>("virt.vm_info", Optional.empty(), Optional.empty(), - new TypeToken<>() { - }); - - Optional>> vmInfos = saltApi.callSync(call, minionId); - return vmInfos.map( - infos -> { - List plan = new ArrayList<>(); - plan.add(new VmInfo(0, VirtualInstanceManager.EVENT_TYPE_FULLREPORT, null, null)); - - plan.addAll( - infos.entrySet().stream().map(entry -> { - Map vm = entry.getValue(); - String state = vm.get("state").toString(); - GuestProperties props = new GuestProperties( - ((Double)vm.get("maxMem")).longValue() / 1024, - entry.getKey(), - "shutdown".equals(state) ? "stopped" : state, - vm.get("uuid").toString(), - ((Double)vm.get("cpu")).intValue(), - null - ); - return new VmInfo(0, VirtualInstanceManager.EVENT_TYPE_EXISTS, null, props); - }).collect(Collectors.toList()) - ); - return plan; - } - ); - } - - @Override - public Optional> getFeatures(String minionId) { - String grainName = "virt_features"; - Optional>> data = saltApi.callSync(Grains.item(false, - new TypeToken>>() { }, grainName), minionId); - return data.map(features -> features.get(grainName)); - } - - @Override - public Optional>> getVmInfos(String minionId) { - LocalCall>> call = - new LocalCall<>("virt_utils.vm_info", Optional.empty(), Optional.empty(), - new TypeToken<>() { - }); - - return saltApi.callSync(call, minionId); - } - - @Override - public Optional> getTuningTemplates(String minionId) { - LocalCall> call = - new LocalCall<>("virt_utils.virt_tuner_templates", Optional.empty(), Optional.empty(), - new TypeToken<>() { - }); - - return saltApi.callSync(call, minionId); - } -} diff --git a/java/code/src/com/suse/manager/virtualization/VirtStatesHelper.java b/java/code/src/com/suse/manager/virtualization/VirtStatesHelper.java deleted file mode 100644 index 7a335f1a8a1a..000000000000 --- a/java/code/src/com/suse/manager/virtualization/VirtStatesHelper.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2021 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.suse.manager.virtualization; - -import java.util.HashMap; -import java.util.Map; -import java.util.stream.Collectors; - -/** - * Helper functions to call the virtualization states - */ -public abstract class VirtStatesHelper { - - /** - * Convert a Range object to a map with start and end keys. - * - * @param data the Range to convert - * @param the type of the value contained in the Range - * @return the pillar fragment - */ - public static Map rangeToPillar(Range data) { - Map pillar = new HashMap<>(); - pillar.put("start", data.getStart()); - pillar.put("end", data.getEnd()); - return pillar; - } - - - /** - * Convert an IpDef object to pillar data. - * - * @param ip the IpDef to convert - * @return the pillar fragment - */ - public static Map ipToPillar(IpDef ip) { - Map pillar = new HashMap<>(); - pillar.put("cidr", ip.getAddress() + "/" + ip.getPrefix()); - ip.getBootpFile().ifPresent(path -> { - Map bootp = new HashMap<>(); - bootp.put("file", path); - ip.getBootpServer().ifPresent(server -> bootp.put("server", server)); - pillar.put("bootp", bootp); - }); - ip.getTftp().ifPresent(tftp -> pillar.put("tftp", tftp)); - if (!ip.getDhcpRanges().isEmpty()) { - pillar.put("dhcp_ranges", ip.getDhcpRanges().stream() - .map(VirtStatesHelper::rangeToPillar) - .collect(Collectors.toList())); - } - if (!ip.getHosts().isEmpty()) { - pillar.put("hosts", ip.getHosts().stream() - .collect(Collectors.toMap( - DhcpHostDef::getIp, - host -> { - Map res = new HashMap<>(); - host.getMac().ifPresent(mac -> res.put("mac", mac)); - host.getId().ifPresent(id -> res.put("id", id)); - host.getName().ifPresent(name -> res.put("name", name)); - return res; - }))); - } - return pillar; - } -} diff --git a/java/code/src/com/suse/manager/virtualization/VirtualPortDef.java b/java/code/src/com/suse/manager/virtualization/VirtualPortDef.java deleted file mode 100644 index 4d2638851b44..000000000000 --- a/java/code/src/com/suse/manager/virtualization/VirtualPortDef.java +++ /dev/null @@ -1,181 +0,0 @@ -/* - * Copyright (c) 2021 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.suse.manager.virtualization; - -import com.google.gson.annotations.SerializedName; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.jdom.Attribute; -import org.jdom.Element; - -import java.util.Optional; - -/** - * Represents the virtual network virtualport configuration - */ -public class VirtualPortDef { - private static final Logger LOG = LogManager.getLogger(VirtualPortDef.class); - - private String type; - - @SerializedName("profileid") - private Optional profileId = Optional.empty(); - - @SerializedName("interfaceid") - private Optional interfaceId = Optional.empty(); - - @SerializedName("managerid") - private Optional managerId = Optional.empty(); - - @SerializedName("typeid") - private Optional typeId = Optional.empty(); - - @SerializedName("typeidversion") - private Optional typeIdVersion = Optional.empty(); - - @SerializedName("instanceid") - private Optional instanceId = Optional.empty(); - - /** - * @return value of type - */ - public String getType() { - return type; - } - - /** - * @param typeIn value of type - */ - public void setType(String typeIn) { - type = typeIn; - } - - /** - * @return the profile Id - */ - public Optional getProfileId() { - return profileId; - } - - /** - * @param profileIdIn the profile Id - */ - public void setProfileId(Optional profileIdIn) { - profileId = profileIdIn; - } - - /** - * @return the interface Id - */ - public Optional getInterfaceId() { - return interfaceId; - } - - /** - * @param interfaceIdIn the interface Id - */ - public void setInterfaceId(Optional interfaceIdIn) { - interfaceId = interfaceIdIn; - } - - /** - * @return the manager Id - */ - public Optional getManagerId() { - return managerId; - } - - /** - * @param managerIdIn the manager Id - */ - public void setManagerId(Optional managerIdIn) { - managerId = managerIdIn; - } - - /** - * @return the type Id - */ - public Optional getTypeId() { - return typeId; - } - - /** - * @param typeIdIn the type Id - */ - public void setTypeId(Optional typeIdIn) { - typeId = typeIdIn; - } - - /** - * @return the type Id version - */ - public Optional getTypeIdVersion() { - return typeIdVersion; - } - - /** - * @param typeIdVersionIn the type Id version - */ - public void setTypeIdVersion(Optional typeIdVersionIn) { - typeIdVersion = typeIdVersionIn; - } - - /** - * @return the instance Id - */ - public Optional getInstanceId() { - return instanceId; - } - - /** - * @param instanceIdIn the instance Id - */ - public void setInstanceId(Optional instanceIdIn) { - instanceId = instanceIdIn; - } - - /** - * Extract information from virtualport JDOM XML Node - * - * @param node the node to parse - * - * @return the virtual port definition - */ - public static Optional parse(Element node) { - if (node == null) { - return Optional.empty(); - } - VirtualPortDef def = new VirtualPortDef(); - def.setType(node.getAttributeValue("type")); - Element parametersNode = node.getChild("parameters"); - if (parametersNode != null) { - for (Object attribute : parametersNode.getAttributes()) { - Attribute attr = (Attribute)attribute; - switch (attr.getName()) { - case "interfaceid": def.setInterfaceId(Optional.of(attr.getValue())); break; - case "instanceid": def.setInstanceId(Optional.of(attr.getValue())); break; - case "managerid": def.setManagerId(Optional.of(attr.getValue())); break; - case "profileid": def.setProfileId(Optional.of(attr.getValue())); break; - case "typeid": def.setTypeId(Optional.of(attr.getValue())); break; - case "typeidversion": def.setTypeIdVersion(Optional.of(attr.getValue())); break; - default: - LOG.error("Unexpected virtual port attribute: {}", attr.getName()); - } - } - } - return Optional.of(def); - } -} diff --git a/java/code/src/com/suse/manager/virtualization/VirtualizationActionHelper.java b/java/code/src/com/suse/manager/virtualization/VirtualizationActionHelper.java deleted file mode 100644 index b8964689681b..000000000000 --- a/java/code/src/com/suse/manager/virtualization/VirtualizationActionHelper.java +++ /dev/null @@ -1,371 +0,0 @@ -/* - * Copyright (c) 2021 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.suse.manager.virtualization; - -import com.redhat.rhn.common.localization.LocalizationService; -import com.redhat.rhn.domain.action.Action; -import com.redhat.rhn.domain.action.ActionChain; -import com.redhat.rhn.domain.action.ActionChainFactory; -import com.redhat.rhn.domain.action.ActionFactory; -import com.redhat.rhn.domain.action.ActionType; -import com.redhat.rhn.domain.action.virtualization.BaseVirtualizationGuestAction; -import com.redhat.rhn.domain.action.virtualization.VirtualizationCreateGuestAction; -import com.redhat.rhn.domain.action.virtualization.VirtualizationMigrateGuestAction; -import com.redhat.rhn.domain.kickstart.KickstartData; -import com.redhat.rhn.domain.kickstart.KickstartFactory; -import com.redhat.rhn.domain.server.Server; -import com.redhat.rhn.domain.server.VirtualInstance; -import com.redhat.rhn.domain.server.VirtualInstanceFactory; -import com.redhat.rhn.domain.user.User; -import com.redhat.rhn.frontend.action.kickstart.KickstartHelper; -import com.redhat.rhn.manager.action.ActionManager; -import com.redhat.rhn.manager.common.UninitializedCommandException; -import com.redhat.rhn.manager.kickstart.cobbler.CobblerVirtualSystemCommand; -import com.redhat.rhn.manager.kickstart.cobbler.CobblerXMLRPCHelper; -import com.redhat.rhn.taskomatic.TaskomaticApi; -import com.redhat.rhn.taskomatic.TaskomaticApiException; - -import com.suse.manager.webui.controllers.virtualization.gson.VirtualGuestMigrateActionJson; -import com.suse.manager.webui.controllers.virtualization.gson.VirtualGuestsBaseActionJson; -import com.suse.manager.webui.controllers.virtualization.gson.VirtualGuestsUpdateActionJson; -import com.suse.manager.webui.utils.MinionActionUtils; -import com.suse.manager.webui.utils.gson.ScheduledRequestJson; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.cobbler.Profile; - -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.concurrent.atomic.AtomicReference; -import java.util.function.BiConsumer; -import java.util.function.BiFunction; -import java.util.function.Function; -import java.util.stream.Collectors; - -import javax.servlet.http.HttpServletRequest; - -/** - * Provides utility functions to create the virtualization actions - */ -public class VirtualizationActionHelper { - - private static final Logger LOG = LogManager.getLogger(VirtualizationActionHelper.class); - - private static TaskomaticApi taskomaticApi = new TaskomaticApi(); - - /** - * Schedule a virtualization action - * - * @param key the key identifying the object - * @param user the user performing the request - * @param host the host the VM is running on - * @param actionCreator a function creation the action out of the parsed Json data - * @param data the Json Data - * @param Type of the json data - * - * @return the scheduled action id - * @throws TaskomaticApiException if the action couldn't be scheduled - */ - public static int scheduleAction(String key, User user, Server host, - BiFunction actionCreator, - T data) throws TaskomaticApiException { - Action action = actionCreator.apply(data, key); - if (action == null) { - // Should never happen that we get no action created, but still report it - throw new TaskomaticApiException(new NullPointerException()); - } - action.setOrg(user.getOrg()); - action.setSchedulerUser(user); - action.setEarliestAction(MinionActionUtils.getScheduleDate(data.getEarliest())); - - ActionChain actionChain = MinionActionUtils.getActionChain(data.getActionChain(), user); - - schedule(action, host, actionChain); - return action.getId().intValue(); - } - - /** - * Get action creator for guest actions needing a force parameter - * - * @param actionType the type of the action to create - * @param setter function setting the force value - * @param guestNames the guests names mapped to their UUID - * @param Type of the json data - * - * @return the action creator - */ - public static BiFunction getGuestForceActionCreator( - ActionType actionType, - BiConsumer setter, - Map guestNames - ) { - BiFunction, - BaseVirtualizationGuestAction> actionCreator = (data, name) -> { - BaseVirtualizationGuestAction action = (BaseVirtualizationGuestAction) - ActionFactory.createAction(actionType); - action.setName(actionType.getName()); - setter.accept(action, data.getForce() != null ? data.getForce() : false); - return action; - }; - - return getGuestBaseActionCreator(actionCreator, guestNames); - } - - /** - * Get action creator for guest simple actions - * - * @param actionType the type of the action to create - * @param guestNames the guests names mapped to their UUID - * @param Type of the json data - * - * @return the action creator - */ - public static BiFunction getGuestActionCreator( - ActionType actionType, - Map guestNames - ) { - BiFunction, - BaseVirtualizationGuestAction> actionCreator = (data, name) -> { - AtomicReference action = - new AtomicReference<>((BaseVirtualizationGuestAction) ActionFactory.createAction(actionType)); - name.ifPresent(vmName -> { - String uuid = guestNames.entrySet().stream() - .filter(e -> e.getValue().equals(name.get())) - .map(Map.Entry::getKey) - .findFirst() - .orElse(null); - List instances = VirtualInstanceFactory.getInstance() - .lookupVirtualInstanceByUuid(uuid); - if (instances.size() == 1 && actionType.equals(ActionFactory.TYPE_VIRTUALIZATION_START) && - instances.get(0).getState().getLabel().equals("paused")) { - action.set((BaseVirtualizationGuestAction) ActionFactory - .createAction(ActionFactory.TYPE_VIRTUALIZATION_RESUME)); - } - }); - action.get().setName(actionType.getName()); - return action.get(); - }; - - return getGuestBaseActionCreator(actionCreator, guestNames); - } - - /** - * Get action creator for guest setters (vcpus and memory). - * - * @param actionType the type of the action to create - * @param getter how to get the value from the data - * @param setter how to set the value in the action - * @param guestNames the guests names mapped to their UUID - * @param Type of the json data - * - * @return the action creator - */ - public static BiFunction getGuestSetterActionCreator( - ActionType actionType, - Function getter, - BiConsumer setter, - Map guestNames - ) { - BiFunction, - BaseVirtualizationGuestAction> actionCreator = (data, name) -> { - BaseVirtualizationGuestAction action = - (BaseVirtualizationGuestAction) ActionFactory.createAction(actionType); - action.setName(actionType.getName()); - setter.accept(action, getter.apply(data)); - return action; - }; - - return getGuestBaseActionCreator(actionCreator, guestNames); - } - - /** - * Get action creator for guest create or update actions - * - * @param host the virtualization host server - * @param user the user performing the action - * @param request the HTTP Servlet request for the kickstart helper - * @param guestNames the guests names mapped to their UUID - * - * @return the action creator - */ - public static BiFunction getGuestActionCreateCreator( - Server host, - User user, - HttpServletRequest request, - Map guestNames - ) { - BiFunction, - BaseVirtualizationGuestAction> actionCreator = (data, name) -> { - VirtualizationCreateGuestAction action = (VirtualizationCreateGuestAction) - ActionFactory.createAction(ActionFactory.TYPE_VIRTUALIZATION_CREATE); - - String actionName = ActionFactory.TYPE_VIRTUALIZATION_CREATE.getName().replaceAll("\\.$", ""); - actionName += ": " + data.getName(); - if (data.getUuids() != null && !data.getUuids().isEmpty()) { - actionName = LocalizationService.getInstance().getMessage("virt.update"); - } - action.setName(actionName); - - GuestCreateDetails details = new GuestCreateDetails(); - action.setDetails(details); - details.setType(data.getType()); - // So far the salt virt.update function doesn't allow renaming a guest, - // and that is only possible for the KVM driver. - details.setName(data.getName()); - details.setOsType(data.getOsType()); - details.setMemory(data.getMemory()); - details.setVcpu(data.getVcpu()); - details.setArch(data.getArch()); - details.setGraphicsType(data.getGraphicsType()); - details.setKernelOptions(data.getKernelOptions()); - details.setClusterDefinitions(data.getClusterDefinitions()); - details.setTemplate(data.getTemplate()); - details.setUefi(data.isUefi()); - details.setUefiLoader(data.getUefiLoader()); - details.setNvramTemplate(data.getNvramTemplate()); - - if (name.isEmpty() && data.getCobblerId() != null && !data.getCobblerId().isEmpty()) { - // Create cobbler profile - KickstartHelper helper = new KickstartHelper(request); - Profile cobblerProfile = Profile.lookupById( - CobblerXMLRPCHelper.getConnection(user), data.getCobblerId()); - KickstartData ksData = KickstartFactory. - lookupKickstartDataByCobblerIdAndOrg(user.getOrg(), cobblerProfile.getId()); - CobblerVirtualSystemCommand cobblerCmd = new CobblerVirtualSystemCommand(user, cobblerProfile.getName(), - data.getName(), ksData, host.getName(), host.getOrgId()); - String ksHost = helper.getKickstartHost(); - cobblerCmd.setKickstartHost(ksHost); - cobblerCmd.store(); - - details.setCobblerSystem(cobblerCmd.getCobblerSystemRecordName()); - details.setKickstartHost(ksHost); - } - - if (data.getDisks() != null) { - details.setDisks(data.getDisks().stream().map(disk -> { - VirtualGuestsUpdateActionJson.DiskData diskDetails = details.new DiskData(); - diskDetails.setDevice(disk.getDevice()); - diskDetails.setTemplate(disk.getTemplate()); - diskDetails.setSize(disk.getSize()); - diskDetails.setBus(disk.getBus()); - diskDetails.setPool(disk.getPool()); - diskDetails.setSourceFile(disk.getSourceFile()); - diskDetails.setFormat(disk.getFormat()); - return diskDetails; - }).collect(Collectors.toList())); - } - - if (data.getInterfaces() != null) { - details.setInterfaces(data.getInterfaces().stream().map(nic -> { - VirtualGuestsUpdateActionJson.InterfaceData ifaceDetails = details.new InterfaceData(); - ifaceDetails.setType(nic.getType()); - ifaceDetails.setSource(nic.getSource()); - ifaceDetails.setMac(nic.getMac()); - return ifaceDetails; - }).collect(Collectors.toList())); - } - details.setRemoveDisks(data.getDisks() != null && data.getDisks().isEmpty()); - - details.setRemoveInterfaces(data.getInterfaces() != null && data.getInterfaces().isEmpty()); - return action; - }; - - return getGuestBaseActionCreator(actionCreator, guestNames); - } - - /** - * Get action creator for guest migration actions - * - * @param guestNames the guests names mapped to their UUID - * - * @return the action creator - */ - public static BiFunction getGuestMigrateActionCreator( - Map guestNames - ) { - BiFunction, - BaseVirtualizationGuestAction> actionCreator = (data, name) -> { - VirtualizationMigrateGuestAction action = (VirtualizationMigrateGuestAction) - ActionFactory.createAction(ActionFactory.TYPE_VIRTUALIZATION_GUEST_MIGRATE); - action.setName(ActionFactory.TYPE_VIRTUALIZATION_GUEST_MIGRATE.getName()); - action.setUuid(data.getUuids().get(0)); - action.setPrimitive(data.getPrimitive()); - action.setTarget(data.getTarget()); - return action; - }; - - return getGuestBaseActionCreator(actionCreator, guestNames); - } - - private static BiFunction getGuestBaseActionCreator( - BiFunction, - BaseVirtualizationGuestAction> actionCreator, - Map guestNames - ) { - return (data, key) -> { - Optional name = Optional.ofNullable(guestNames.get(key)); - BaseVirtualizationGuestAction action = actionCreator.apply(data, name); - action.setUuid(key); - if (name.isPresent()) { - String actionName = action.getName().replaceAll("\\.$", ""); - action.setName(actionName + ": " + name.get()); - } - return action; - }; - } - - /** - * Helper function to schedule actions. - * - * @param action the action to schedule - * @param targetSystem the system to run the action on - * @param actionChain an optional action chain to append the action to - * - * @throws TaskomaticApiException if an error happened while scheduling - */ - public static void schedule(Action action, Server targetSystem, ActionChain actionChain) - throws TaskomaticApiException { - if (targetSystem == null) { - throw new UninitializedCommandException("No targetSystem for virtualization action"); - } - - LOG.debug("schedule() called."); - ActionFactory.save(action); - - if (actionChain == null) { - ActionManager.scheduleForExecution(action, Collections.singleton(targetSystem.getId())); - taskomaticApi.scheduleActionExecution(action); - } - else { - Integer sortOrder = ActionChainFactory.getNextSortOrderValue(actionChain); - ActionChainFactory.queueActionChainEntry(action, actionChain, - targetSystem.getId(), sortOrder); - } - } - - /** - * Set the {@link TaskomaticApi} instance to use. Only needed for unit tests. - * @param taskomaticApiIn the {@link TaskomaticApi} - */ - public static void setTaskomaticApi(TaskomaticApi taskomaticApiIn) { - taskomaticApi = taskomaticApiIn; - } - - private VirtualizationActionHelper() { - } -} diff --git a/java/code/src/com/suse/manager/virtualization/VlanDef.java b/java/code/src/com/suse/manager/virtualization/VlanDef.java deleted file mode 100644 index 21fb9f7966d6..000000000000 --- a/java/code/src/com/suse/manager/virtualization/VlanDef.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2021 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.suse.manager.virtualization; - -import com.google.gson.annotations.SerializedName; - -import org.jdom.Element; - -import java.util.Optional; - -/** - * Represents a virtual network VLAN configuration - */ -public class VlanDef { - private int tag; - - @SerializedName("native") - private Optional nativeMode = Optional.empty(); - - /** - * @return the VLAN tag - */ - public int getTag() { - return tag; - } - - /** - * @param tagIn the VLAN tag - */ - public void setTag(int tagIn) { - tag = tagIn; - } - - /** - * @return the native mode (tagged or untagged) for open vSwitch - */ - public Optional getNativeMode() { - return nativeMode; - } - - /** - * @param nativeModeIn the native mode (tagged or untagged) for open vSwitch - */ - public void setNativeMode(Optional nativeModeIn) { - nativeMode = nativeModeIn; - } - - /** - * Parse tag XML node - * - * @param node the non-null node - * @return the parsed VlanDef - */ - public static VlanDef parse(Element node) { - VlanDef def = new VlanDef(); - def.setTag(Integer.parseInt(node.getAttributeValue("id"))); - def.setNativeMode(Optional.ofNullable(node.getAttributeValue("nativeMode"))); - return def; - } -} diff --git a/java/code/src/com/suse/manager/virtualization/VmInfoDiskJson.java b/java/code/src/com/suse/manager/virtualization/VmInfoDiskJson.java deleted file mode 100644 index 51983eb069b6..000000000000 --- a/java/code/src/com/suse/manager/virtualization/VmInfoDiskJson.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (c) 2020 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.suse.manager.virtualization; - -import com.google.gson.annotations.SerializedName; - -/** - * Represents the informations for a disk in result from a Salt virt.vm_info or virt.get_disks call. - */ -public class VmInfoDiskJson { - private String file; - private String type; - - @SerializedName("file format") - private String format; - - @SerializedName("disk size") - private Long size; - - @SerializedName("virtual size") - private Long virtualSize; - - /** - * @return the file for the disk. Can also be in the [pool]/[volume] form. - */ - public String getFile() { - return file; - } - - /** - * @param fileIn the file for the disk. Can also be in the [pool]/[volume] form. - */ - public void setFile(String fileIn) { - file = fileIn; - } - - /** - * @return one of "disk", "cdrom", "floppy" - */ - public String getType() { - return type; - } - - /** - * @param typeIn one of "disk", "cdrom", "floppy" - */ - public void setType(String typeIn) { - type = typeIn; - } - - /** - * @return the disk format - */ - public String getFormat() { - return format; - } - - /** - * @param formatIn the disk format - */ - public void setFormat(String formatIn) { - format = formatIn; - } - - /** - * @return the physical disk size - */ - public Long getSize() { - return size; - } - - /** - * @param sizeIn the physical disk size - */ - public void setSize(Long sizeIn) { - size = sizeIn; - } - - /** - * @return the size of the disk as seen by the OS - */ - public Long getVirtualSize() { - return virtualSize; - } - - /** - * @param virtualSizeIn the size of the disk as seen by the OS - */ - public void setVirtualSize(Long virtualSizeIn) { - virtualSize = virtualSizeIn; - } -} diff --git a/java/code/src/com/suse/manager/virtualization/VmInfoJson.java b/java/code/src/com/suse/manager/virtualization/VmInfoJson.java deleted file mode 100644 index b40b8bb13f43..000000000000 --- a/java/code/src/com/suse/manager/virtualization/VmInfoJson.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2020 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.suse.manager.virtualization; - -import java.util.Map; - -/** - * Represents the result from a Salt virt.vm_info call. - */ -public class VmInfoJson { - /** Maps the disk target type to its informations */ - private Map disks; - - /** - * @return the disks informations mapped to their target name (hda, vdb...) - */ - public Map getDisks() { - return disks; - } - - /** - * @param disksIn the disks informations mapped to their target name (hda, vdb...) - */ - public void setDisks(Map disksIn) { - disks = disksIn; - } -} - diff --git a/java/code/src/com/suse/manager/virtualization/test/NetworkDefinitionTest.java b/java/code/src/com/suse/manager/virtualization/test/NetworkDefinitionTest.java deleted file mode 100644 index 747f5880149e..000000000000 --- a/java/code/src/com/suse/manager/virtualization/test/NetworkDefinitionTest.java +++ /dev/null @@ -1,231 +0,0 @@ -/* - * Copyright (c) 2021 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.suse.manager.virtualization.test; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import com.suse.manager.virtualization.DnsDef; -import com.suse.manager.virtualization.IpDef; -import com.suse.manager.virtualization.NetworkDefinition; - -import org.junit.jupiter.api.Test; - -import java.util.Arrays; -import java.util.Optional; - -public class NetworkDefinitionTest { - - @Test - public void testParseBridge() { - String xml = "\n" + - " default\n" + - " 8b612d0f-25b3-4bf5-b6f8-19cbd918fa11\n" + - " \n" + - " \n" + - "\n"; - NetworkDefinition def = NetworkDefinition.parse(xml); - assertEquals(Optional.of("default"), def.getName()); - assertEquals(Optional.of("8b612d0f-25b3-4bf5-b6f8-19cbd918fa11"), def.getUuid()); - assertEquals("bridge", def.getForwardMode()); - assertEquals(Optional.of("br0"), def.getBridge()); - } - - @Test - public void testParseNat() { - String xml = "\n" + - " default\n" + - " d6c95a31-16a2-473a-b8cd-7ad2fe2dd855\n" + - " \n" + - " \n" + - " \n" + - " \n" + - "
\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - ""; - NetworkDefinition def = NetworkDefinition.parse(xml); - assertEquals("nat", def.getForwardMode()); - assertEquals(Optional.of(7000), def.getMtu()); - assertEquals(Integer.valueOf(1024), def.getNat().orElseThrow().getPort().orElseThrow().getStart()); - assertEquals(Integer.valueOf(65535), def.getNat().orElseThrow().getPort().orElseThrow().getEnd()); - assertEquals("192.168.122.5", def.getNat().orElseThrow().getAddress().orElseThrow().getStart()); - assertEquals("192.168.122.6", def.getNat().orElseThrow().getAddress().orElseThrow().getEnd()); - assertEquals(Optional.of("virbr0"), def.getBridge()); - assertEquals(Optional.of("tf.local"), def.getDomain()); - - IpDef ipv4 = def.getIpv4().orElseThrow(); - assertEquals("192.168.122.0", ipv4.getAddress()); - assertEquals(Integer.valueOf(24), ipv4.getPrefix()); - assertEquals("192.168.122.2", ipv4.getDhcpRanges().get(0).getStart()); - assertEquals("192.168.122.254", ipv4.getDhcpRanges().get(0).getEnd()); - assertEquals(Optional.of("2A:C3:A7:A6:01:00"), ipv4.getHosts().get(0).getMac()); - assertEquals("192.168.122.110", ipv4.getHosts().get(0).getIp()); - assertEquals(Optional.of("dev-srv"), ipv4.getHosts().get(0).getName()); - assertEquals(Optional.of("pxelinux.0"), ipv4.getBootpFile()); - assertEquals(Optional.of("192.168.122.110"), ipv4.getBootpServer()); - - IpDef ipv6 = def.getIpv6().orElseThrow(); - assertEquals("2001:db8:ac10:fd01:0:0:0:0", ipv6.getAddress()); - assertEquals(Integer.valueOf(64), ipv6.getPrefix()); - assertEquals(Optional.of("0:3:0:1:0:16:3e:11:22:33"), ipv6.getHosts().get(0).getId()); - assertEquals(Optional.of("peter.xyz"), ipv6.getHosts().get(0).getName()); - } - - @Test - public void testParseDns() { - String xml = "\n" + - " default\n" + - " 81ff0d90-c91e-6742-64da-4a736edb9a9c\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " host\n" + - " gateway\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " " + - ""; - NetworkDefinition def = NetworkDefinition.parse(xml); - DnsDef dnsDef = def.getDns().orElseThrow(); - assertEquals("192.168.122.1", dnsDef.getHosts().get(0).getAddress()); - assertEquals(Arrays.asList("host", "gateway"), dnsDef.getHosts().get(0).getNames()); - assertEquals("name", dnsDef.getSrvs().get(0).getName()); - assertEquals("tcp", dnsDef.getSrvs().get(0).getProtocol()); - assertEquals(Optional.of("test-domain-name.com"), dnsDef.getSrvs().get(0).getDomain()); - assertEquals(Optional.of("test.example.com"), dnsDef.getSrvs().get(0).getTarget()); - assertEquals(Optional.of(1111), dnsDef.getSrvs().get(0).getPort()); - assertEquals(Optional.of(11), dnsDef.getSrvs().get(0).getPriority()); - assertEquals(Optional.of(111), dnsDef.getSrvs().get(0).getWeight()); - assertEquals("name2", dnsDef.getSrvs().get(1).getName()); - assertEquals("tcp", dnsDef.getSrvs().get(1).getProtocol()); - assertTrue(dnsDef.getSrvs().get(1).getDomain().isEmpty()); - assertEquals("example", dnsDef.getTxts().get(0).getName()); - assertEquals("example value", dnsDef.getTxts().get(0).getValue()); - assertEquals(Optional.of("8.8.4.4"), dnsDef.getForwarders().get(0).getAddress()); - assertTrue(dnsDef.getForwarders().get(0).getDomain().isEmpty()); - assertEquals(Optional.of("192.168.1.1"), dnsDef.getForwarders().get(1).getAddress()); - assertEquals(Optional.of("example.com"), dnsDef.getForwarders().get(1).getDomain()); - assertEquals(Optional.of("www.example.com"), dnsDef.getForwarders().get(2).getDomain()); - assertTrue(dnsDef.getForwarders().get(2).getAddress().isEmpty()); - } - - @Test - public void testParseOpenVSwitch() { - String xml = "\n" + - " ovs-net\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - ""; - NetworkDefinition def = NetworkDefinition.parse(xml); - assertEquals("openvswitch", def.getVirtualPort().orElseThrow().getType()); - assertEquals(Optional.of("09b11c53-8b5c-4eeb-8f00-d84eaa0aaa4f"), - def.getVirtualPort().orElseThrow().getInterfaceId()); - assertTrue(def.getVlanTrunk().orElseThrow()); - assertEquals(42, def.getVlans().get(0).getTag()); - assertEquals(Optional.of("untagged"), def.getVlans().get(0).getNativeMode()); - assertEquals(47, def.getVlans().get(1).getTag()); - } - - @Test - public void testParseIsolated() { - String xml = "\n" + - " private\n" + - " 81ff0d90-c91e-6742-64da-4a736edb9a9b\n" + - " \n" + - ""; - NetworkDefinition def = NetworkDefinition.parse(xml); - assertEquals("isolated", def.getType()); - assertTrue(def.getBridge().isEmpty()); - } - - @Test - public void testParsePassthrough() { - String xml = "\n" + - " test\n" + - " 81ff0d90-c91e-6742-64da-4a736edb9a9b\n" + - " \n" + - " \n" + - " \n" + - " \n" + - ""; - NetworkDefinition def = NetworkDefinition.parse(xml); - assertEquals("macvtap", def.getType()); - assertEquals(Optional.of("passthrough"), def.getMacvtapMode()); - assertEquals(Arrays.asList("eth10", "eth11"), def.getInterfaces()); - } - - @Test - public void testParsePrivate() { - String xml = "\n" + - " test\n" + - " 81ff0d90-c91e-6742-64da-4a736edb9a9b\n" + - " \n" + - " \n" + - " \n" + - ""; - NetworkDefinition def = NetworkDefinition.parse(xml); - assertEquals("macvtap", def.getType()); - assertEquals(Optional.of("private"), def.getMacvtapMode()); - assertEquals(Optional.of("eth0"), def.getPhysicalFunction()); - } - - @Test - public void testParseHostdev() { - String xml = "\n" + - " test\n" + - " 81ff0d90-c91e-6742-64da-4a736edb9a9b\n" + - " \n" + - " \n" + - "
\n" + - "
" + - " \n" + - ""; - NetworkDefinition def = NetworkDefinition.parse(xml); - assertEquals("hostdev", def.getType()); - assertEquals(Arrays.asList("000A:12:01.6", "0000:10:04.3"), def.getVirtualFunctions()); - } -} diff --git a/java/code/src/com/suse/manager/virtualization/test/PoolDefinitionTest.java b/java/code/src/com/suse/manager/virtualization/test/PoolDefinitionTest.java deleted file mode 100644 index 98dde1454f72..000000000000 --- a/java/code/src/com/suse/manager/virtualization/test/PoolDefinitionTest.java +++ /dev/null @@ -1,246 +0,0 @@ -/* - * Copyright (c) 2020 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.suse.manager.virtualization.test; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import com.suse.manager.virtualization.PoolDefinition; - -import org.junit.jupiter.api.Test; - -import java.util.Arrays; - -public class PoolDefinitionTest { - - @Test - public void testParseRbd() { - String xml = - "\n" + - " test-ses\n" + - " ede33e0a-9df0-479f-8afd-55085a01b244\n" + - " 0\n" + - " 0\n" + - " 0\n" + - " \n" + - " \n" + - " \n" + - " libvirt-pool\n" + - " \n" + - " \n" + - " \n" + - " \n" + - ""; - PoolDefinition actual = PoolDefinition.parse(xml); - assertEquals("test-ses", actual.getName()); - assertEquals("ede33e0a-9df0-479f-8afd-55085a01b244", actual.getUuid()); - assertEquals("rbd", actual.getType()); - assertNull(actual.getTarget()); - assertEquals("libvirt-pool", actual.getSource().getName()); - assertEquals("ceph", actual.getSource().getAuth().getType()); - assertEquals("libvirt", actual.getSource().getAuth().getUsername()); - assertEquals("usage", actual.getSource().getAuth().getSecretType()); - assertEquals("pool_test-ses", actual.getSource().getAuth().getSecretValue()); - assertEquals(Arrays.asList("ses2.tf.local:1234", "ses3.tf.local"), actual.getSource().getHosts()); - } - - @Test - public void testParseDir() { - String xml = - "\n" + - " default\n" + - " 9f2d114f-4dc7-4f76-8831-062931c04a9a\n" + - " 210303426560\n" + - " 6631251968\n" + - " 203672174592\n" + - " \n" + - " \n" + - " \n" + - " /var/lib/libvirt/images\n" + - " \n" + - " 0755\n" + - " 0\n" + - " 123\n" + - " \n" + - " \n" + - " \n" + - ""; - PoolDefinition actual = PoolDefinition.parse(xml); - assertEquals("default", actual.getName()); - assertEquals("9f2d114f-4dc7-4f76-8831-062931c04a9a", actual.getUuid()); - assertEquals("dir", actual.getType()); - assertEquals("/var/lib/libvirt/images", actual.getTarget().getPath()); - assertEquals("0755", actual.getTarget().getMode()); - assertEquals("0", actual.getTarget().getOwner()); - assertEquals("123", actual.getTarget().getGroup()); - assertEquals("virt_image_t", actual.getTarget().getSeclabel()); - } - - @Test - public void testParseFs() { - String xml = - "\n" + - " virtimages\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " /var/lib/virt/images\n" + - " \n" + - ""; - PoolDefinition actual = PoolDefinition.parse(xml); - assertEquals("virtimages", actual.getName()); - assertNull(actual.getUuid()); - assertEquals("fs", actual.getType()); - assertEquals("/var/lib/virt/images", actual.getTarget().getPath()); - assertEquals(1, actual.getSource().getDevices().size()); - assertEquals("/dev/VolGroup00/VirtImages", actual.getSource().getDevices().get(0).getPath()); - assertEquals("ocfs2", actual.getSource().getFormat()); - } - - @Test - public void testParseNetfs() { - String xml = - "\n" + - " virtimages\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " /var/lib/virt/images\n" + - " \n" + - ""; - PoolDefinition actual = PoolDefinition.parse(xml); - assertEquals("virtimages", actual.getName()); - assertNull(actual.getUuid()); - assertEquals("netfs", actual.getType()); - assertEquals("/var/lib/virt/images", actual.getTarget().getPath()); - assertEquals(Arrays.asList("nfs.example.com"), actual.getSource().getHosts()); - assertEquals("/var/lib/virt/images", actual.getSource().getDir()); - assertEquals("nfs", actual.getSource().getFormat()); - } - - @Test - public void testParseLogical() { - String xml = - "\n" + - " HostVG\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " /dev/HostVG\n" + - " \n" + - ""; - PoolDefinition actual = PoolDefinition.parse(xml); - assertEquals("logical", actual.getType()); - assertEquals("/dev/HostVG", actual.getTarget().getPath()); - assertEquals(2, actual.getSource().getDevices().size()); - assertEquals("/dev/sda1", actual.getSource().getDevices().get(0).getPath()); - assertTrue(actual.getSource().getDevices().get(0).isSeparator().get()); - assertEquals("/dev/sdb1", actual.getSource().getDevices().get(1).getPath()); - assertTrue(actual.getSource().getDevices().get(1).isSeparator().isEmpty()); - } - - @Test - public void testParseScsi() { - String xml = - "\n" + - " virtimages\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " /dev/disk/by-path\n" + - " \n" + - ""; - PoolDefinition actual = PoolDefinition.parse(xml); - assertEquals("host0", actual.getSource().getAdapter().getName()); - } - - @Test - public void testParseIscsiDirect() { - String xml = - "\n" + - " virtimages\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - ""; - PoolDefinition actual = PoolDefinition.parse(xml); - assertEquals("iqn.2013-06.com.example:iscsi-initiator", actual.getSource().getInitiator()); - assertEquals("chap", actual.getSource().getAuth().getType()); - assertEquals("myname", actual.getSource().getAuth().getUsername()); - assertEquals("uuid", actual.getSource().getAuth().getSecretType()); - assertEquals("2ec115d7-3a88-3ceb-bc12-0ac909a6fd87", actual.getSource().getAuth().getSecretValue()); - } - - @Test - public void testParseIscsiAddress() { - String xml = - "\n" + - " virtimages\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - "
\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " /dev/disk/by-path\n" + - " \n" + - ""; - PoolDefinition actual = PoolDefinition.parse(xml); - assertEquals("scsi_host", actual.getSource().getAdapter().getType()); - assertEquals("1", actual.getSource().getAdapter().getParentAddressUid()); - assertEquals("0000:00:1f.2", actual.getSource().getAdapter().getParentAddress()); - } - - @Test - public void testParseIscsiWwnn() { - String xml = - "\n" + - " virtimages\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " /dev/disk/by-path\n" + - " \n" + - ""; - PoolDefinition actual = PoolDefinition.parse(xml); - assertEquals("fc_host", actual.getSource().getAdapter().getType()); - assertEquals("scsi_host5", actual.getSource().getAdapter().getParent()); - assertEquals("20000000c9831b4b", actual.getSource().getAdapter().getWwnn()); - assertEquals("10000000c9831b4b", actual.getSource().getAdapter().getWwpn()); - } -} diff --git a/java/code/src/com/suse/manager/virtualization/test/TestVirtManager.java b/java/code/src/com/suse/manager/virtualization/test/TestVirtManager.java deleted file mode 100644 index 92b22fc8e22f..000000000000 --- a/java/code/src/com/suse/manager/virtualization/test/TestVirtManager.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (c) 2020 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.suse.manager.virtualization.test; - -import com.redhat.rhn.domain.server.MinionServer; - -import com.suse.manager.virtualization.GuestDefinition; -import com.suse.manager.virtualization.HostInfo; -import com.suse.manager.virtualization.NetworkDefinition; -import com.suse.manager.virtualization.PoolCapabilitiesJson; -import com.suse.manager.virtualization.PoolDefinition; -import com.suse.manager.webui.services.iface.VirtManager; -import com.suse.manager.webui.utils.salt.custom.VmInfo; - -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; - -import java.util.List; -import java.util.Map; -import java.util.Optional; - -public class TestVirtManager implements VirtManager { - - @Override - public Optional getGuestDefinition(String minionId, String domainName) { - throw new UnsupportedOperationException(); - } - - @Override - public boolean startGuest(String minionId, String domainName) { - throw new UnsupportedOperationException(); - } - - @Override - public Optional> getCapabilities(String minionId) { - throw new UnsupportedOperationException(); - } - - @Override - public Optional getPoolCapabilities(String minionId) { - throw new UnsupportedOperationException(); - } - - @Override - public Optional getPoolDefinition(String minionId, String poolName) { - throw new UnsupportedOperationException(); - } - - @Override - public Map getNetworks(String minionId) { - throw new UnsupportedOperationException(); - } - - @Override - public Optional getNetworkDefinition(String minionId, String netName) { - throw new UnsupportedOperationException(); - } - - @Override - public List getHostDevices(String minionId) { - throw new UnsupportedOperationException(); - } - - @Override - public Map getPools(String minionId) { - throw new UnsupportedOperationException(); - } - - @Override - public Map> getVolumes(String minionId) { - throw new UnsupportedOperationException(); - } - - @Override - public void updateLibvirtEngine(MinionServer minion) { - throw new UnsupportedOperationException(); - } - - @Override - public Optional getHostInfo(String minionId) { - throw new UnsupportedOperationException(); - } - - @Override - public Optional> getGuestsUpdatePlan(String minionId) { - throw new UnsupportedOperationException(); - } - - @Override - public Optional> getFeatures(String minionId) { - throw new UnsupportedOperationException(); - } - - @Override - public Optional>> getVmInfos(String minionId) { - throw new UnsupportedOperationException(); - } - - @Override - public Optional> getTuningTemplates(String minionId) { - throw new UnsupportedOperationException(); - } -} diff --git a/java/code/src/com/suse/manager/virtualization/test/VirtManagerSaltTest.java b/java/code/src/com/suse/manager/virtualization/test/VirtManagerSaltTest.java deleted file mode 100644 index cd315da01900..000000000000 --- a/java/code/src/com/suse/manager/virtualization/test/VirtManagerSaltTest.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (c) 2020 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.suse.manager.virtualization.test; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import com.redhat.rhn.manager.system.VirtualInstanceManager; - -import com.suse.manager.reactor.messaging.test.SaltTestUtils; -import com.suse.manager.virtualization.VirtManagerSalt; -import com.suse.manager.webui.services.iface.SaltApi; -import com.suse.manager.webui.services.iface.VirtManager; -import com.suse.manager.webui.services.test.TestSaltApi; -import com.suse.manager.webui.utils.salt.custom.VmInfo; -import com.suse.salt.netapi.calls.LocalCall; - -import com.google.gson.reflect.TypeToken; - -import org.junit.jupiter.api.Test; - -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Optional; - -/** - * Test the Salt implementation of the VirtManager interface - */ -public class VirtManagerSaltTest { - - /** - * Test the getGuestsUpdatePlan method - */ - @Test - public void testGetGuestsUpdatePlan() { - SaltApi testSaltApi = new TestSaltApi() { - @Override - public Optional callSync(LocalCall call, String minionId) { - return SaltTestUtils.getSaltResponse( - "/com/suse/manager/virtualization/test/virt.vm_info.all.json", - Collections.emptyMap(), - new TypeToken<>() { - }); - } - }; - VirtManager virtManager = new VirtManagerSalt(testSaltApi); - Optional> plan = virtManager.getGuestsUpdatePlan("theminion"); - - assertTrue(plan.isPresent()); - assertEquals(3, plan.get().size()); - assertTrue(plan.get().stream(). - anyMatch(info -> info.getEventType().equals(VirtualInstanceManager.EVENT_TYPE_FULLREPORT))); - - VmInfo vm1infos = plan.get().stream() - .filter(info -> info.getGuestProperties() != null && info.getGuestProperties().getName().equals("vm01")) - .findFirst().get(); - assertEquals(2, vm1infos.getGuestProperties().getVcpus()); - assertEquals(1024, vm1infos.getGuestProperties().getMemorySize()); - assertEquals("stopped", vm1infos.getGuestProperties().getState()); - assertEquals("b99a8176-4f40-498d-8e61-2f6ade654fe2", vm1infos.getGuestProperties().getUuid()); - assertEquals(VirtualInstanceManager.EVENT_TYPE_EXISTS, vm1infos.getEventType()); - - VmInfo vm2infos = plan.get().stream() - .filter(info -> info.getGuestProperties() != null && info.getGuestProperties().getName().equals("vm02")) - .findFirst().get(); - assertEquals(12, vm2infos.getGuestProperties().getVcpus()); - assertEquals(2048L, vm2infos.getGuestProperties().getMemorySize()); - assertEquals("running", vm2infos.getGuestProperties().getState()); - assertEquals("98eef4f7-eb7f-4be8-859d-11658506c496", vm2infos.getGuestProperties().getUuid()); - assertEquals(VirtualInstanceManager.EVENT_TYPE_EXISTS, vm2infos.getEventType()); - } - - @Test - public void testGetFeatures() { - SaltApi testSaltApi = new TestSaltApi() { - @Override - public Optional callSync(LocalCall call, String minionId) { - return SaltTestUtils.getSaltResponse( - "/com/suse/manager/virtualization/test/virt.features.json", - Collections.emptyMap(), - new TypeToken<>() { - }); - } - }; - VirtManager virtManager = new VirtManagerSalt(testSaltApi); - Optional> actual = virtManager.getFeatures("minion0"); - assertTrue(actual.get().get("enhanced_network")); - } -} diff --git a/java/code/src/com/suse/manager/virtualization/test/virt.features.json b/java/code/src/com/suse/manager/virtualization/test/virt.features.json deleted file mode 100644 index ffd1fb091b99..000000000000 --- a/java/code/src/com/suse/manager/virtualization/test/virt.features.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "virt_features": { - "enhanced_network": true - } -} \ No newline at end of file diff --git a/java/code/src/com/suse/manager/virtualization/test/virt.vm_info.all.json b/java/code/src/com/suse/manager/virtualization/test/virt.vm_info.all.json deleted file mode 100644 index 315a74e59f95..000000000000 --- a/java/code/src/com/suse/manager/virtualization/test/virt.vm_info.all.json +++ /dev/null @@ -1,108 +0,0 @@ -{ - "vm01": { - "cpu": 2, - "cputime": 0, - "disks": { - "vda": { - "file": "/srv/vms/sles12sp2.qcow2", - "type": "disk", - "file format": "qcow2", - "disk size": 350658560, - "virtual size": 214748364800, - "cluster size": 65536 - }, - "vdb": { - "file": "ses-pool/test-vol", - "type": "disk", - "file format": "raw" - } - }, - "graphics": { - "autoport": "yes", - "keymap": "None", - "listen": "127.0.0.1", - "port": "None", - "type": "spice" - }, - "nics": { - "52:54:00:b3:0e:ea": { - "type": "network", - "mac": "52:54:00:b3:0e:ea", - "source": { - "network": "default" - }, - "model": "rtl8139", - "address": { - "type": "pci", - "domain": "0x0000", - "bus": "0x00", - "slot": "0x03", - "function": "0x0" - } - } - }, - "uuid": "b99a8176-4f40-498d-8e61-2f6ade654fe2", - "loader": { - "path": "None" - }, - "on_crash": "restart", - "on_reboot": "restart", - "on_poweroff": "destroy", - "maxMem": 1048576, - "mem": 1048576, - "state": "shutdown" - }, - "vm02": { - "cpu": 12, - "cputime": 0, - "disks": { - "vda": { - "file": "/srv/vms/sles12sp2.qcow2", - "type": "disk", - "file format": "qcow2", - "disk size": 350658560, - "virtual size": 214748364800, - "cluster size": 65536 - }, - "vdb": { - "file": "ses-pool/test-vol", - "type": "disk", - "file format": "raw" - } - }, - "graphics": { - "autoport": "yes", - "keymap": "None", - "listen": "127.0.0.1", - "port": "None", - "type": "spice" - }, - "nics": { - "52:54:00:b3:0e:ea": { - "type": "network", - "mac": "52:54:00:b3:0e:ea", - "source": { - "network": "default" - }, - "model": "rtl8139", - "address": { - "type": "pci", - "domain": "0x0000", - "bus": "0x00", - "slot": "0x03", - "function": "0x0" - } - } - }, - "uuid": "98eef4f7-eb7f-4be8-859d-11658506c496", - "loader": { - "path": "None" - }, - "on_crash": "restart", - "on_reboot": "restart", - "on_poweroff": "destroy", - "maxMem": 2097152, - "mem": 1048576, - "state": "running" - } -} diff --git a/java/code/src/com/suse/manager/webui/Router.java b/java/code/src/com/suse/manager/webui/Router.java index ffc0dd911478..b0a32aa11e19 100644 --- a/java/code/src/com/suse/manager/webui/Router.java +++ b/java/code/src/com/suse/manager/webui/Router.java @@ -78,13 +78,9 @@ import com.suse.manager.webui.controllers.maintenance.MaintenanceCalendarController; import com.suse.manager.webui.controllers.maintenance.MaintenanceController; import com.suse.manager.webui.controllers.maintenance.MaintenanceScheduleController; -import com.suse.manager.webui.controllers.virtualization.VirtualGuestsController; -import com.suse.manager.webui.controllers.virtualization.VirtualNetsController; -import com.suse.manager.webui.controllers.virtualization.VirtualPoolsController; import com.suse.manager.webui.errors.NotFoundException; import com.suse.manager.webui.services.iface.SaltApi; import com.suse.manager.webui.services.iface.SystemQuery; -import com.suse.manager.webui.services.iface.VirtManager; import org.apache.http.HttpStatus; @@ -116,7 +112,6 @@ public void init() { SystemQuery systemQuery = GlobalInstanceHolder.SYSTEM_QUERY; SaltApi saltApi = GlobalInstanceHolder.SALT_API; KubernetesManager kubernetesManager = GlobalInstanceHolder.KUBERNETES_MANAGER; - VirtManager virtManager = GlobalInstanceHolder.VIRT_MANAGER; RegularMinionBootstrapper regularMinionBootstrapper = GlobalInstanceHolder.REGULAR_MINION_BOOTSTRAPPER; SSHMinionBootstrapper sshMinionBootstrapper = GlobalInstanceHolder.SSH_MINION_BOOTSTRAPPER; SaltKeyUtils saltKeyUtils = GlobalInstanceHolder.SALT_KEY_UTILS; @@ -154,9 +149,6 @@ public void init() { // Virtual Host Managers VirtualHostManagerController.initRoutes(jade); - // Virtualization Routes - initVirtualizationRoutes(jade, virtManager); - // Content Management Routes ContentManagementViewsController.initRoutes(jade); ContentManagementApiController.initRoutes(); @@ -280,15 +272,6 @@ private void initNotFoundRoutes(JadeTemplateEngine jade) { }); } - private void initVirtualizationRoutes(JadeTemplateEngine jade, VirtManager virtManager) { - VirtualGuestsController virtualGuestsController = new VirtualGuestsController(virtManager); - VirtualNetsController virtualNetsController = new VirtualNetsController(virtManager); - VirtualPoolsController virtualPoolsController = new VirtualPoolsController(virtManager); - virtualGuestsController.initRoutes(jade); - virtualNetsController.initRoutes(jade); - virtualPoolsController.initRoutes(jade); - } - private void initContentManagementRoutes(JadeTemplateEngine jade, KubernetesManager kubernetesManager) { ImageBuildController imageBuildController = new ImageBuildController(kubernetesManager); ImageStoreController.initRoutes(jade); diff --git a/java/code/src/com/suse/manager/webui/controllers/test/SystemsControllerTest.java b/java/code/src/com/suse/manager/webui/controllers/test/SystemsControllerTest.java index 076a1bd23a6a..18d380115eea 100644 --- a/java/code/src/com/suse/manager/webui/controllers/test/SystemsControllerTest.java +++ b/java/code/src/com/suse/manager/webui/controllers/test/SystemsControllerTest.java @@ -21,7 +21,6 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import com.redhat.rhn.domain.role.RoleFactory; -import com.redhat.rhn.domain.server.MinionServer; import com.redhat.rhn.domain.server.Server; import com.redhat.rhn.domain.server.VirtualInstance; import com.redhat.rhn.manager.formula.FormulaMonitoringManager; @@ -33,20 +32,15 @@ import com.redhat.rhn.testing.ServerTestUtils; import com.redhat.rhn.testing.SparkTestUtils; -import com.suse.manager.reactor.messaging.test.SaltTestUtils; import com.suse.manager.webui.controllers.SystemsController; import com.suse.manager.webui.services.iface.MonitoringManager; import com.suse.manager.webui.services.iface.SaltApi; -import com.suse.manager.webui.services.iface.VirtManager; import com.suse.manager.webui.services.test.TestSaltApi; import com.google.gson.Gson; import com.google.gson.GsonBuilder; -import com.google.gson.JsonElement; -import com.google.gson.reflect.TypeToken; import org.apache.commons.lang3.StringUtils; -import org.jmock.Expectations; import org.jmock.imposters.ByteBuddyClassImposteriser; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -75,7 +69,6 @@ public class SystemsControllerTest extends BaseControllerTestCase { private static final String PROPERTY_SERVER_NAME = "name"; // - private VirtManager virtManager; private Map serversByHostServerName; private SystemsController systemsController; @@ -86,27 +79,13 @@ public void setUp() throws Exception { user.addPermanentRole(RoleFactory.ORG_ADMIN); setImposteriser(ByteBuddyClassImposteriser.INSTANCE); - virtManager = mock(VirtManager.class); - context().checking(new Expectations() { - { - allowing(virtManager).getCapabilities("testminion.local"); - will(returnValue( - SaltTestUtils.getSaltResponse( - "/com/suse/manager/webui/controllers/virtualization/test/virt.guest.allcaps.json", null, - new TypeToken>() { - }) - )); - allowing(virtManager).updateLibvirtEngine(with(any(MinionServer.class))); - } - }); - SaltApi saltApi = new TestSaltApi(); systemsController = new SystemsController(saltApi); MonitoringManager monitoringManager = new FormulaMonitoringManager(saltApi); ServerGroupManager serverGroupManager = new ServerGroupManager(saltApi); SystemEntitlementManager systemEntitlementManager = new SystemEntitlementManager( - new SystemUnentitler(virtManager, monitoringManager, serverGroupManager), - new SystemEntitler(new TestSaltApi(), virtManager, monitoringManager, serverGroupManager) + new SystemUnentitler(monitoringManager, serverGroupManager), + new SystemEntitler(new TestSaltApi(), monitoringManager, serverGroupManager) ); serversByHostServerName = new HashMap<>(); diff --git a/java/code/src/com/suse/manager/webui/controllers/virtualization/AbstractVirtualizationController.java b/java/code/src/com/suse/manager/webui/controllers/virtualization/AbstractVirtualizationController.java deleted file mode 100644 index 101be6d7cb4f..000000000000 --- a/java/code/src/com/suse/manager/webui/controllers/virtualization/AbstractVirtualizationController.java +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Copyright (c) 2020 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.suse.manager.webui.controllers.virtualization; - - -import static com.suse.manager.webui.utils.SparkApplicationHelper.json; - -import com.redhat.rhn.common.hibernate.LookupException; -import com.redhat.rhn.domain.action.Action; -import com.redhat.rhn.domain.server.Server; -import com.redhat.rhn.domain.user.User; -import com.redhat.rhn.manager.system.SystemManager; -import com.redhat.rhn.taskomatic.TaskomaticApiException; - -import com.suse.manager.reactor.utils.LocalDateTimeISOAdapter; -import com.suse.manager.reactor.utils.OptionalTypeAdapterFactory; -import com.suse.manager.virtualization.VirtualizationActionHelper; -import com.suse.manager.webui.controllers.ECMAScriptDateAdapter; -import com.suse.manager.webui.errors.NotFoundException; -import com.suse.manager.webui.services.iface.VirtManager; -import com.suse.manager.webui.utils.gson.ScheduledRequestJson; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.reflect.TypeToken; - -import org.apache.http.HttpStatus; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import java.time.LocalDateTime; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.function.BiFunction; -import java.util.function.Function; -import java.util.function.Supplier; -import java.util.stream.Collectors; - -import spark.ModelAndView; -import spark.Request; -import spark.Response; -import spark.Spark; - -/** - * Base controller class offering convenience functions for other virtualization-related controllers - */ -public abstract class AbstractVirtualizationController { - private static final Logger LOG = LogManager.getLogger(AbstractVirtualizationController.class); - - protected static final Gson GSON = new GsonBuilder() - .registerTypeAdapter(Date.class, new ECMAScriptDateAdapter()) - .registerTypeAdapter(LocalDateTime.class, new LocalDateTimeISOAdapter()) - .registerTypeAdapterFactory(new OptionalTypeAdapterFactory()) - .serializeNulls() - .create(); - - protected final String jadeTemplatesPath; - protected final VirtManager virtManager; - - /** - * @param virtManagerIn instance to manage virtualization - * @param jadeTemplatesPathIn the path to the folder containing the Jade templates - */ - protected AbstractVirtualizationController(VirtManager virtManagerIn, String jadeTemplatesPathIn) { - this.virtManager = virtManagerIn; - this.jadeTemplatesPath = jadeTemplatesPathIn; - } - - /** - * Extract the server ID from the request. The Server ID should be in the sid Spark parameter. - * - * @param request the Spark request - * @return the server Id - * - * @throws NotFoundException if the server id has an invalid format or if the sid parameter can't be found - */ - protected long getServerId(Request request) throws NotFoundException { - try { - return Long.parseLong(request.params("sid")); - } - catch (NumberFormatException e) { - LOG.error("Invalid server id: {}", request.params("sid"), e); - throw Spark.halt(HttpStatus.SC_NOT_FOUND, "Invalid server id: " + request.params("sid")); - } - } - - /** - * Get the server from the request. The Server ID should be in the sid Spark parameter. - * - * @param request the Spark request - * @return the server Id - * - * @throws NotFoundException if the server can't be found in the request or in the database - */ - protected Server getServer(Request request, User user) throws NotFoundException { - Server server; - long serverId = getServerId(request); - - try { - server = SystemManager.lookupByIdAndUser(serverId, user); - } - catch (LookupException e) { - throw new NotFoundException(); - } - return server; - } - - /** - * Displays a page server-related virtual page - * - * @param template the name to the Jade template of the page - * @param modelExtender provides additional properties to pass to the Jade template - * @return the ModelAndView object to render the page - */ - protected ModelAndView renderPage(String template, Supplier> modelExtender) { - Map data = new HashMap<>(); - if (modelExtender != null) { - data.putAll(modelExtender.get()); - } - - /* For the rest of the template */ - - return new ModelAndView(data, String.format("%s/%s.jade", jadeTemplatesPath, template)); - } - - protected String action(Request request, Response response, User user, - Server host, - BiFunction actionCreator, - Function> actionKeysGetter, - Class jsonClass) { - - T data; - try { - data = GSON.fromJson(request.body(), jsonClass); - - List actionKeys = actionKeysGetter.apply(data); - if (!actionKeys.isEmpty()) { - Map actionsResults = actionKeys.stream().collect( - Collectors.toMap(Function.identity(), - key -> scheduleAction(key, user, host, actionCreator, data) - )); - return json(response, actionsResults, new TypeToken<>() { }); - } - - String result = scheduleAction(null, user, host, actionCreator, data); - return json(response, result); - } - catch (Exception e) { - LOG.error("Bad Request", e); - throw Spark.halt(HttpStatus.SC_BAD_REQUEST); - } - } - - private String scheduleAction(String key, User user, Server host, - BiFunction actionCreator, - T data) { - String status = "Failed"; - try { - status = String.valueOf(VirtualizationActionHelper.scheduleAction(key, user, host, actionCreator, data)); - } - catch (TaskomaticApiException e) { - LOG.error("Could not schedule virtualization action:", e); - } - return status; - } -} diff --git a/java/code/src/com/suse/manager/webui/controllers/virtualization/VirtualGuestsController.java b/java/code/src/com/suse/manager/webui/controllers/virtualization/VirtualGuestsController.java deleted file mode 100644 index ab33d9813a38..000000000000 --- a/java/code/src/com/suse/manager/webui/controllers/virtualization/VirtualGuestsController.java +++ /dev/null @@ -1,821 +0,0 @@ -/* - * Copyright (c) 2018 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.suse.manager.webui.controllers.virtualization; - -import static com.suse.manager.webui.utils.SparkApplicationHelper.asJson; -import static com.suse.manager.webui.utils.SparkApplicationHelper.json; -import static com.suse.manager.webui.utils.SparkApplicationHelper.withCsrfToken; -import static com.suse.manager.webui.utils.SparkApplicationHelper.withDocsLocale; -import static com.suse.manager.webui.utils.SparkApplicationHelper.withUser; -import static com.suse.manager.webui.utils.SparkApplicationHelper.withUserAndServer; -import static com.suse.manager.webui.utils.SparkApplicationHelper.withUserPreferences; -import static spark.Spark.get; -import static spark.Spark.post; - -import com.redhat.rhn.common.db.datasource.DataResult; -import com.redhat.rhn.common.hibernate.LookupException; -import com.redhat.rhn.common.util.StringUtil; -import com.redhat.rhn.domain.action.Action; -import com.redhat.rhn.domain.action.ActionFactory; -import com.redhat.rhn.domain.action.ActionType; -import com.redhat.rhn.domain.action.virtualization.VirtualizationRebootGuestAction; -import com.redhat.rhn.domain.action.virtualization.VirtualizationSetMemoryGuestAction; -import com.redhat.rhn.domain.action.virtualization.VirtualizationSetVcpusGuestAction; -import com.redhat.rhn.domain.action.virtualization.VirtualizationShutdownGuestAction; -import com.redhat.rhn.domain.role.RoleFactory; -import com.redhat.rhn.domain.server.MinionServer; -import com.redhat.rhn.domain.server.Server; -import com.redhat.rhn.domain.server.VirtualInstance; -import com.redhat.rhn.domain.server.VirtualInstanceFactory; -import com.redhat.rhn.domain.server.VirtualInstanceState; -import com.redhat.rhn.domain.user.User; -import com.redhat.rhn.frontend.dto.SystemOverview; -import com.redhat.rhn.frontend.dto.VirtualSystemOverview; -import com.redhat.rhn.frontend.dto.kickstart.KickstartDto; -import com.redhat.rhn.manager.entitlement.EntitlementManager; -import com.redhat.rhn.manager.kickstart.KickstartScheduleCommand; -import com.redhat.rhn.manager.kickstart.ProvisionVirtualInstanceCommand; -import com.redhat.rhn.manager.system.SystemManager; -import com.redhat.rhn.manager.system.VirtualInstanceManager; - -import com.suse.manager.reactor.utils.LocalDateTimeISOAdapter; -import com.suse.manager.reactor.utils.OptionalTypeAdapterFactory; -import com.suse.manager.virtualization.DomainCapabilitiesJson; -import com.suse.manager.virtualization.GuestDefinition; -import com.suse.manager.virtualization.HostCapabilitiesJson; -import com.suse.manager.virtualization.VirtualizationActionHelper; -import com.suse.manager.webui.controllers.ECMAScriptDateAdapter; -import com.suse.manager.webui.controllers.MinionController; -import com.suse.manager.webui.controllers.virtualization.gson.VirtualGuestMigrateActionJson; -import com.suse.manager.webui.controllers.virtualization.gson.VirtualGuestSetterActionJson; -import com.suse.manager.webui.controllers.virtualization.gson.VirtualGuestsBaseActionJson; -import com.suse.manager.webui.controllers.virtualization.gson.VirtualGuestsUpdateActionJson; -import com.suse.manager.webui.errors.NotFoundException; -import com.suse.manager.webui.services.iface.VirtManager; -import com.suse.manager.webui.utils.TokenBuilder; -import com.suse.manager.webui.utils.WebSockifyTokenBuilder; -import com.suse.manager.webui.utils.salt.custom.VmInfo; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonElement; -import com.google.gson.JsonPrimitive; -import com.google.gson.reflect.TypeToken; - -import org.apache.http.HttpStatus; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.jose4j.lang.JoseException; - -import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.function.BiConsumer; -import java.util.function.BiFunction; -import java.util.function.Function; -import java.util.stream.Collectors; - -import spark.ModelAndView; -import spark.Request; -import spark.Response; -import spark.Spark; -import spark.template.jade.JadeTemplateEngine; - -/** - * Controller class providing backend for Virtual Guests list page - */ -public class VirtualGuestsController extends AbstractVirtualizationController { - - private static final Logger LOG = LogManager.getLogger(VirtualGuestsController.class); - - private static final Gson GSON = new GsonBuilder() - .registerTypeAdapter(Date.class, new ECMAScriptDateAdapter()) - .registerTypeAdapter(LocalDateTime.class, new LocalDateTimeISOAdapter()) - .registerTypeAdapterFactory(new OptionalTypeAdapterFactory()) - .serializeNulls() - .create(); - - /** - * @param virtManagerIn instance to manage virtualization - */ - public VirtualGuestsController(VirtManager virtManagerIn) { - super(virtManagerIn, "templates/virtualization/guests"); - } - - /** - * Initialize request routes for the pages served by VirtualGuestsController - * - * @param jade jade engine - */ - public void initRoutes(JadeTemplateEngine jade) { - get("/manager/systems/details/virtualization/guests/:sid", - withUserPreferences(withCsrfToken(withDocsLocale(withUserAndServer(this::show)))), jade); - get("/manager/systems/details/virtualization/guests/:sid/edit/:guestuuid", - withUserPreferences(withCsrfToken(withDocsLocale(withUserAndServer(this::edit)))), jade); - get("/manager/systems/details/virtualization/guests/:sid/new", - withUserPreferences(withCsrfToken(withDocsLocale(withUserAndServer(this::create)))), jade); - get("/manager/systems/details/virtualization/guests/console/:guestuuid", - withUserPreferences(withCsrfToken(withDocsLocale(withUser(this::console)))), jade); - get("/manager/api/systems/details/virtualization/guests/:sid/data", - asJson(withUserAndServer(this::data))); - post("/manager/api/systems/details/virtualization/guests/consoleToken/:guestuuid", - withUser(this::refreshConsoleToken)); - post("/manager/api/systems/details/virtualization/guests/:sid/refresh", - withUserAndServer(this::refresh)); - post("/manager/api/systems/details/virtualization/guests/:sid/shutdown", - withUserAndServer(this::shutdown)); - post("/manager/api/systems/details/virtualization/guests/:sid/restart", - withUserAndServer(this::restart)); - post("/manager/api/systems/details/virtualization/guests/:sid/setVcpu", - withUserAndServer(this::setVcpu)); - post("/manager/api/systems/details/virtualization/guests/:sid/setMemory", - withUserAndServer(this::setMemory)); - post("/manager/api/systems/details/virtualization/guests/:sid/new", - withUserAndServer(this::newGuest)); - post("/manager/api/systems/details/virtualization/guests/:sid/update", - withUserAndServer(this::update)); - post("/manager/api/systems/details/virtualization/guests/:sid/migrate", - withUserAndServer(this::migrate)); - post("/manager/api/systems/details/virtualization/guests/:sid/:action", - withUserAndServer(this::guestAction)); - get("/manager/api/systems/details/virtualization/guests/:sid/guest/:uuid", - withUserAndServer(this::getGuest)); - get("/manager/api/systems/details/virtualization/guests/:sid/domains_capabilities", - withUserAndServer(this::getDomainsCapabilities)); - } - - /** - * Displays the virtual guests page. - * - * @param request the request - * @param response the response - * @param user the user - * @param server the server - * @return the ModelAndView object to render the page - */ - public ModelAndView show(Request request, Response response, User user, Server server) { - Map data = new HashMap<>(); - - data.put("salt_entitled", server.hasEntitlement(EntitlementManager.SALT)); - data.put("foreign_entitled", server.hasEntitlement(EntitlementManager.FOREIGN)); - data.put("is_admin", user.hasRole(RoleFactory.ORG_ADMIN)); - data.put("hostInfo", server.hasVirtualizationEntitlement() && server.asMinionServer().isPresent() ? - virtManager.getHostInfo(server.getMinionId()).map(GSON::toJson).orElse("{}") : - "{}"); - - return renderPage("show", () -> data); - } - - /** - * Returns JSON data describing the virtual guests - * - * @param request the request - * @param response the response - * @param user the user - * @param server the server - * @return JSON result of the API call - */ - public String data(Request request, Response response, User user, Server server) { - DataResult data = - SystemManager.virtualGuestsForHostList(user, server.getId(), null); - data.elaborate(); - - for (VirtualSystemOverview current : data) { - current.setSystemId(current.getVirtualSystemId()); - - if (current.getSystemId() != null) { - current.updateStatusType(user); - } - } - - String json = GSON.toJson(data); - List> mergeData = GSON.fromJson(json, - new TypeToken>>() { }.getType()); - - server.asMinionServer().ifPresent(minionServer -> { - Optional>> extraData = - virtManager.getVmInfos(minionServer.getMinionId()); - - DataResult noHostData = - SystemManager.virtualGuestsForHostList(user, null, null); - noHostData.elaborate(); - - extraData.ifPresent(extra -> { - // Add all the extra data to the existing ones - extra.forEach((key, value) -> mergeData.stream() - .filter(element -> element.get("name").getAsString().equals(key)) - .findFirst() - .ifPresent(item -> { - if (value.get("uuid") != null) { - value.remove("uuid"); - } - item.putAll(value); - })); - // Find the VMs that aren't listed on the host - List> missing = extra.entrySet().stream() - .filter(entry -> entry.getValue().get("uuid") != null) - .peek(entry -> { - final String guid = VirtualInstanceManager.fixUuidIfSwappedUuidExists( - entry.getValue().get("uuid").getAsString().replaceAll("-", "")); - entry.getValue().put("uuid", new JsonPrimitive(guid)); - }) - .filter(entry -> entry.getValue().get("uuid") != null && data.stream() - .noneMatch(item -> item.getUuid().equals(entry.getValue().get("uuid").getAsString()))) - .map(entry -> { - VirtualSystemOverview vso = noHostData.stream() - .filter(vm -> vm.getUuid().equals(entry.getValue().get("uuid").getAsString())) - .findFirst() - .orElseGet(() -> { - VirtualSystemOverview fakeVso = new VirtualSystemOverview(); - fakeVso.setUuid(entry.getValue().get("uuid").getAsString()); - fakeVso.setMemory(entry.getValue().get("memory").getAsLong()); - fakeVso.setVcpus(entry.getValue().get("vcpus").getAsLong()); - fakeVso.setName(entry.getKey()); - VirtualInstanceState state = VirtualInstanceFactory.getInstance() - .getStoppedState(); - fakeVso.setStateLabel(state.getLabel()); - fakeVso.setStateName(state.getName()); - return fakeVso; - }); - Map vmData = GSON.fromJson(GSON.toJson(vso), - new TypeToken>() { }.getType()); - vmData.putAll(extra.get(entry.getKey())); - return vmData; - }) - .collect(Collectors.toList()); - mergeData.addAll(missing); - }); - }); - - return GSON.toJson(mergeData); - } - - /** - * Return the definition of the virtual machine - * - * @param request the request - * @param response the response - * @param user the user - * @param host the server - * @return the json response - */ - public String getGuest(Request request, Response response, User user, Server host) { - String uuid = request.params("uuid"); - MinionServer minion = host.asMinionServer().orElseThrow(NotFoundException::new); - - GuestDefinition definition = virtManager.getGuestDefinition(minion.getMinionId(), uuid) - .orElseThrow(NotFoundException::new); - - return json(response, definition, new TypeToken<>() { }); - } - - /** - * Return the list of all domain capabilities from a given salt virtual host - * - * @param request the request - * @param response the response - * @param user the user - * @param host the server - * @return the json response - */ - public String getDomainsCapabilities(Request request, Response response, User user, Server host) { - String minionId = host.asMinionServer().orElseThrow(() -> - Spark.halt(HttpStatus.SC_BAD_REQUEST, "Can only get capabilities of Salt system")).getMinionId(); - - Map capabilities = virtManager.getCapabilities(minionId) - .orElseThrow(() -> Spark.halt(HttpStatus.SC_BAD_REQUEST, - "Failed to get virtual host capabilities")); - - HostCapabilitiesJson hostCaps = GSON.fromJson(capabilities.get("host"), - new TypeToken() { }.getType()); - List domainsCaps = GSON.fromJson(capabilities.get("domains"), - new TypeToken>() { }.getType()); - - Map allDomainCaps = new HashMap<>(); - allDomainCaps.put("osTypes", hostCaps.getGuests().stream().map(HostCapabilitiesJson.Guest::getOsType) - .distinct() - .collect(Collectors.toList())); - allDomainCaps.put("domainsCaps", domainsCaps); - - return json(response, allDomainCaps, new TypeToken<>() { }); - } - - /** - * Display the edit page of a virtual guest - * - * @param request the request - * @param response the response - * @param user the user - * @param host the server - * @return the ModelAndView object to render the page - */ - public ModelAndView edit(Request request, Response response, User user, Server host) { - Map data = new HashMap<>(); - - // Use uuids since the IDs may change - String guestUuid = request.params("guestuuid"); - - DataResult guests = - SystemManager.virtualGuestsForHostList(user, host.getId(), null); - - Optional guest = guests.stream(). - filter(item -> item.getUuid().equals(guestUuid)).findFirst(); - - if (guest.isEmpty()) { - host.asMinionServer().ifPresentOrElse(minionServer -> { - Optional>> vmInfos = - virtManager.getVmInfos(minionServer.getMinionId()); - boolean inCluster = vmInfos.map(info -> info.values().stream() - .anyMatch(entry -> { - if (entry.containsKey("uuid")) { - String uuid = entry.get("uuid").getAsString().replaceAll("-", ""); - return uuid.equals(guestUuid); - } - return false; - }) - ).orElse(false); - if (!inCluster) { - LOG.error("No such virtual machine"); - throw Spark.halt(HttpStatus.SC_BAD_REQUEST, "No such virtual machine"); - } - }, - () -> { - LOG.error("No such virtual machine"); - throw Spark.halt(HttpStatus.SC_BAD_REQUEST, "No such virtual machine"); - } - ); - } - - /* For the rest of the template */ - MinionController.addActionChains(user, data); - data.put("guestUuid", guestUuid); - data.put("isSalt", host.hasEntitlement(EntitlementManager.SALT)); - - return renderPage("edit", () -> data); - } - - /** - * Display the New Virtual Guest page - * - * @param request the request - * @param response the response - * @param user the user - * @param host the server - * @return the ModelAndView object to render the page - */ - public ModelAndView create(Request request, Response response, User user, Server host) { - Map data = new HashMap<>(); - - if (!host.hasEntitlement(EntitlementManager.SALT)) { - LOG.error("Only for Salt-managed virtual hosts"); - Spark.halt(HttpStatus.SC_BAD_REQUEST, "Only for Salt-managed virtual hosts"); - } - - String minionId = host.asMinionServer().orElseThrow(NotFoundException::new).getMinionId(); - Map features = virtManager.getFeatures(minionId).orElse(new HashMap<>()); - List templates = virtManager.getTuningTemplates(minionId).orElse(new ArrayList<>()); - - /* For the rest of the template */ - MinionController.addActionChains(user, data); - data.put("isSalt", true); - // If the resource agent doesn't support the new start_resources we'll get into troubles with pools and networks - data.put("inCluster", features.getOrDefault("cluster", false)); - data.put("raCanStartResources", - features.getOrDefault("resource_agent_start_resources", false)); - data.put("templates", GSON.toJson(templates)); - data.put("uefiAutoLoader", features.getOrDefault("uefi_auto_loader", false)); - - KickstartScheduleCommand cmd = new ProvisionVirtualInstanceCommand(host.getId(), user); - DataResult profiles = cmd.getKickstartProfiles(); - data.put("cobblerProfiles", - GSON.toJson(profiles.stream().collect( - Collectors.toMap(KickstartDto::getCobblerId, KickstartDto::getLabel)))); - - return renderPage("create", () -> data); - } - - /** - * Display the console page of a virtual guest - * - * @param request the request - * @param response the response - * @param user the user - * @return the ModelAndView object to render the page - */ - public ModelAndView console(Request request, Response response, User user) { - Map data = new HashMap<>(); - - // Use uuids since the IDs may change - String guestUuid = request.params("guestuuid"); - data.put("guestUuid", guestUuid); - VirtualInstance guest = getVirtualInstanceFromUuid(guestUuid); - - if (guest == null || guest.getHostSystem() == null) { - // Not having the VM in the database doesn't mean it doesn't exist somewhere. - // Stopped clustered VMs are transient and thus not in the database. - // Showing the page and then waiting for an event to come should help when the VM starts. - data.put("serverId", "undefined"); - data.put("guestName", guest != null ? String.format("'%s'", guest.getName()) : "undefined"); - data.put("guestState", guest != null ? String.format("'%s'", guest.getState().getLabel()) : "undefined"); - data.put("graphicsType", "undefined"); - data.put("token", String.format("'%s'", getConsoleToken(null, -1))); - return new ModelAndView(data, jadeTemplatesPath + "/console.jade"); - } - Server host = guest.getHostSystem(); - - try { - ensureAccessToVirtualInstance(user, guest); - } - catch (LookupException e) { - LOG.error("Unauthorized", e); - Spark.halt(HttpStatus.SC_UNAUTHORIZED, e.getLocalizedMessage()); - } - - String minionId = host.asMinionServer().orElseThrow(() -> Spark.halt(HttpStatus.SC_BAD_REQUEST)).getMinionId(); - GuestDefinition def = virtManager.getGuestDefinition(minionId, guestUuid) - .orElseThrow(() -> Spark.halt(HttpStatus.SC_BAD_REQUEST)); - String hostname = host.getName(); - - data.put("serverId", String.format("'%d'", guest.getHostSystem().getId())); - data.put("guestName", String.format("'%s'", guest.getName())); - data.put("guestState", String.format("'%s'", guest.getState().getLabel())); - data.put("graphicsType", String.format("'%s'", def.getGraphics().getType())); - data.put("token", String.format("'%s'", getConsoleToken(hostname, def.getGraphics().getPort()))); - - return new ModelAndView(data, jadeTemplatesPath + "/console.jade"); - } - - /** - * Refresh the JWT token to be used for the console display. - * - * @param request the request - * @param response the response - * @param user the user - * - * @return the new JWT token - */ - public String refreshConsoleToken(Request request, Response response, User user) { - if (!TokenBuilder.verifyToken(request.body())) { - LOG.error("Invalid token"); - Spark.halt(HttpStatus.SC_FORBIDDEN, "Invalid token"); - } - - String guestUuid = request.params("guestuuid"); - VirtualInstance guest = getVirtualInstanceFromUuid(guestUuid); - if (guest == null) { - LOG.error("Virtual machine not found"); - Spark.halt(HttpStatus.SC_NOT_FOUND, "Virtual machine not found"); - } - Server host = guest.getHostSystem(); - try { - ensureAccessToVirtualInstance(user, guest); - } - catch (LookupException e) { - LOG.error("Unauthorized", e); - Spark.halt(HttpStatus.SC_UNAUTHORIZED, e.getLocalizedMessage()); - } - - String minionId = host.asMinionServer().orElseThrow(() -> Spark.halt(HttpStatus.SC_BAD_REQUEST)).getMinionId(); - GuestDefinition def = virtManager.getGuestDefinition(minionId, guestUuid) - .orElseThrow(() -> Spark.halt(HttpStatus.SC_BAD_REQUEST)); - String hostname = host.getName(); - - return json(response, getConsoleToken(hostname, def.getGraphics().getPort())); - } - - private void ensureAccessToVirtualInstance(User user, VirtualInstance guest) throws LookupException { - if (guest.getGuestSystem() != null) { - SystemManager.ensureAvailableToUser(user, guest.getGuestSystem().getId()); - } - else { - SystemManager.ensureAvailableToUser(user, guest.getHostSystem().getId()); - } - } - - private VirtualInstance getVirtualInstanceFromUuid(String uuid) { - List guests = VirtualInstanceFactory.getInstance().lookupVirtualInstanceByUuid(uuid); - if (guests.isEmpty()) { - return null; - } - if (guests.size() > 1) { - if (LOG.isDebugEnabled()) { - LOG.error("More than one virtual machine found for this UUID: {}", - StringUtil.sanitizeLogInput(uuid)); - } - Spark.halt(HttpStatus.SC_NOT_FOUND, "More than one virtual machine found for this UUID"); - } - return guests.get(0); - } - - private String getConsoleToken(String hostname, int port) { - String token = null; - try { - WebSockifyTokenBuilder tokenBuilder = new WebSockifyTokenBuilder(hostname, port); - tokenBuilder.useServerSecret(); - token = tokenBuilder.getToken(); - } - catch (JoseException e) { - LOG.error("Service unavailable", e); - Spark.halt(HttpStatus.SC_SERVICE_UNAVAILABLE); - } - return token; - } - - /** - * Refresh the database with the actual list of virtual machines from the host - * - * @param request the request - * @param response the response - * @param user the user - * @param host the server - * @return Boolean indicating the success of the operation - */ - public Boolean refresh(Request request, Response response, User user, Server host) { - if (noHostSupportAction(host, true)) { - LOG.error("Action not supported for this host"); - Spark.halt(HttpStatus.SC_BAD_REQUEST, "Action not supported for this host"); - } - - VirtualInstanceManager.updateHostVirtualInstance(host, - VirtualInstanceFactory.getInstance().getFullyVirtType()); - Optional> plan = virtManager.getGuestsUpdatePlan(host.getMinionId()); - plan.ifPresent(updatePlan -> VirtualInstanceManager.updateGuestsVirtualInstances(host, updatePlan)); - return plan.isPresent(); - } - - /** - * Set the memory amount of a virtual guest - * - * @param request the request - * @param response the response - * @param user the user - * @param host the server - * @return the action id or "Failed" in case of failure - */ - public String setMemory(Request request, Response response, User user, Server host) { - if (noHostSupportAction(host, false)) { - LOG.error("Action not supported for this host"); - Spark.halt(HttpStatus.SC_BAD_REQUEST, "Action not supported for this host"); - } - - return setterAction(request, response, user, host, - ActionFactory.TYPE_VIRTUALIZATION_SET_MEMORY, - data -> data.getValue().intValue(), - (action, value) -> ((VirtualizationSetMemoryGuestAction)action).setMemory(value), - VirtualGuestSetterActionJson.class); - } - - /** - * Set the number of vCPUs of a virtual guest - * - * @param request the request - * @param response the response - * @param user the user - * @param host the server - * @return the action id or "Failed" in case of failure - */ - public String setVcpu(Request request, Response response, User user, Server host) { - if (noHostSupportAction(host, false)) { - LOG.error("Action not supported for this host"); - Spark.halt(HttpStatus.SC_BAD_REQUEST, "Action not supported for this host"); - } - - return setterAction(request, response, user, host, - ActionFactory.TYPE_VIRTUALIZATION_SET_VCPUS, - data -> data.getValue().intValue(), - (action, value) -> ((VirtualizationSetVcpusGuestAction)action).setVcpu(value), - VirtualGuestSetterActionJson.class); - } - - /** - * reboot a virtual guest - * - * @param request the request - * @param response the response - * @param user the user - * @param host the server - * @return the action id or "Failed" in case of failure - */ - public String restart(Request request, Response response, User user, Server host) { - if (noHostSupportAction(host, false)) { - LOG.error("Action not supported for this host"); - Spark.halt(HttpStatus.SC_BAD_REQUEST, "Action not supported for this host"); - } - - return doGuestAction(request, response, user, host, - VirtualizationActionHelper.getGuestForceActionCreator( - ActionFactory.TYPE_VIRTUALIZATION_REBOOT, - (action, force) -> ((VirtualizationRebootGuestAction)action).setForce(force), - getGuestNames(user, host)), - VirtualGuestsBaseActionJson.class); - } - - /** - * shut down a virtual guest - * - * @param request the request - * @param response the response - * @param user the user - * @param host the server - * @return the action id or "Failed" in case of failure - */ - public String shutdown(Request request, Response response, User user, Server host) { - if (noHostSupportAction(host, false)) { - LOG.error("Action not supported for this host"); - Spark.halt(HttpStatus.SC_BAD_REQUEST, "Action not supported for this host"); - } - - return doGuestAction(request, response, user, host, - VirtualizationActionHelper.getGuestForceActionCreator( - ActionFactory.TYPE_VIRTUALIZATION_SHUTDOWN, - (action, force) -> ((VirtualizationShutdownGuestAction)action).setForce(force), - getGuestNames(user, host)), - VirtualGuestsBaseActionJson.class); - } - - /** - * Run a guest action - * - * @param request the request - * @param response the response - * @param user the user - * @param host the server - * @return the JSON result - */ - public String guestAction(Request request, Response response, User user, Server host) { - Map actionsMap = new HashMap<>(); - actionsMap.put("start", ActionFactory.TYPE_VIRTUALIZATION_START); - actionsMap.put("suspend", ActionFactory.TYPE_VIRTUALIZATION_SUSPEND); - actionsMap.put("resume", ActionFactory.TYPE_VIRTUALIZATION_RESUME); - actionsMap.put("restart", ActionFactory.TYPE_VIRTUALIZATION_REBOOT); - actionsMap.put("delete", ActionFactory.TYPE_VIRTUALIZATION_DELETE); - - if (noHostSupportAction(host, false)) { - LOG.error("Action not supported for this host"); - Spark.halt(HttpStatus.SC_BAD_REQUEST, "Action not supported for this host"); - } - - String actionParam = request.params("action"); - ActionType actionType = actionsMap.get(actionParam); - - return doGuestAction(request, response, user, host, - VirtualizationActionHelper.getGuestActionCreator(actionType, getGuestNames(user, host)), - VirtualGuestsBaseActionJson.class); - } - - /** - * Migrate a virtual guest to an other virtual host - * - * @param request the request - * @param response the response - * @param user the user - * @param host the server - * @return the action id or "Failed" in case of failure - */ - public String migrate(Request request, Response response, User user, Server host) { - if (noHostSupportAction(host, true)) { - LOG.error("Action not supported for this host"); - Spark.halt(HttpStatus.SC_BAD_REQUEST, "Action not supported for this host"); - } - - return doGuestAction(request, response, user, host, - VirtualizationActionHelper.getGuestMigrateActionCreator(getGuestNames(user, host)), - VirtualGuestMigrateActionJson.class); - } - - /** - * Update the definition of a virtual guest. - * - * For traditional guests only the vCPU count and memory amount will be changed. - * - * @param request the request - * @param response the response - * @param user the user - * @param host the server - * @return the action id or "Failed" in case of failure - */ - public String update(Request request, Response response, User user, Server host) { - if (noHostSupportAction(host, false)) { - LOG.error("Action not supported for this host"); - Spark.halt(HttpStatus.SC_BAD_REQUEST, "Action not supported for this host"); - } - - if (host.asMinionServer().isPresent()) { - return newGuest(request, response, user, host); - } - - String memResult = setterAction(request, response, user, host, - ActionFactory.TYPE_VIRTUALIZATION_SET_MEMORY, - data -> data.getMemory().intValue(), - (action, value) -> ((VirtualizationSetMemoryGuestAction)action).setMemory(value), - VirtualGuestsUpdateActionJson.class); - Map results = new HashMap<>( - GSON.fromJson(memResult, new TypeToken>() { }.getType()) - ); - - String vcpuResult = setterAction(request, response, user, host, - ActionFactory.TYPE_VIRTUALIZATION_SET_VCPUS, - data -> data.getVcpu().intValue(), - (action, value) -> ((VirtualizationSetVcpusGuestAction)action).setVcpu(value), - VirtualGuestsUpdateActionJson.class); - results.putAll(GSON.fromJson(vcpuResult, new TypeToken>() { }.getType())); - return json(response, results, new TypeToken<>() { }); - } - - /** - * Create or update a virtual guest - * - * @param request the request - * @param response the response - * @param user the user - * @param host the server - * @return the action id or "Failed" in case of failure - */ - public String newGuest(Request request, Response response, User user, Server host) { - if (noHostSupportAction(host, true)) { - LOG.error("Action not supported for this host"); - Spark.halt(HttpStatus.SC_BAD_REQUEST, "Action not supported for this host"); - } - - return doGuestAction(request, response, user, host, - VirtualizationActionHelper.getGuestActionCreateCreator(host, user, request.raw(), - getGuestNames(user, host)), VirtualGuestsUpdateActionJson.class); - } - - private String setterAction(Request request, Response response, - User user, Server host, ActionType actionType, - Function getter, - BiConsumer setter, - Class dataClass) { - if (noHostSupportAction(host, false)) { - LOG.error("Action not supported for this host"); - Spark.halt(HttpStatus.SC_BAD_REQUEST, "Action not supported for this host"); - } - - return doGuestAction(request, response, user, host, - VirtualizationActionHelper.getGuestSetterActionCreator( - actionType, getter, setter, getGuestNames(user, host)), - dataClass); - } - - private Map getGuestNames(User user, Server host) { - DataResult guests = - SystemManager.virtualGuestsForHostList(user, host.getId(), null); - Map names = guests.stream().collect(Collectors.toMap( - VirtualSystemOverview::getUuid, - SystemOverview::getName - )); - - // Get the names of the VMs defined on the cluster if any - host.asMinionServer() - .flatMap(minionServer -> virtManager.getVmInfos(minionServer.getMinionId())) - .ifPresent(data -> names.putAll(data.entrySet().stream() - .filter(entry -> entry.getValue().containsKey("uuid")) - .collect(Collectors.toMap( - entry -> entry.getValue().get("uuid").getAsString().replaceAll("-", ""), - Map.Entry::getKey)))); - - return names; - } - - private boolean noHostSupportAction(Server host, boolean saltOnly) { - if (host.hasEntitlement(EntitlementManager.FOREIGN)) { - LOG.warn("Foreign systems don't support virtual guest actions"); - return true; - } - // Traditionally registered systems aren't able to really delete the VM: fail - // the delete action for them - if (host.hasEntitlement(EntitlementManager.MANAGEMENT) && saltOnly) { - LOG.warn("Traditional systems don't support virtual guests deletion"); - return true; - } - - return false; - } - - private String doGuestAction(Request request, Response response, User user, - Server server, - BiFunction actionCreator, - Class jsonClass) { - return action(request, response, user, server, actionCreator, - VirtualGuestsBaseActionJson::getUuids, - jsonClass - ); - } -} diff --git a/java/code/src/com/suse/manager/webui/controllers/virtualization/VirtualNetsController.java b/java/code/src/com/suse/manager/webui/controllers/virtualization/VirtualNetsController.java deleted file mode 100644 index 115c62108a55..000000000000 --- a/java/code/src/com/suse/manager/webui/controllers/virtualization/VirtualNetsController.java +++ /dev/null @@ -1,357 +0,0 @@ -/* - * Copyright (c) 2018 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.suse.manager.webui.controllers.virtualization; - -import static com.suse.manager.webui.utils.SparkApplicationHelper.asJson; -import static com.suse.manager.webui.utils.SparkApplicationHelper.json; -import static com.suse.manager.webui.utils.SparkApplicationHelper.withCsrfToken; -import static com.suse.manager.webui.utils.SparkApplicationHelper.withDocsLocale; -import static com.suse.manager.webui.utils.SparkApplicationHelper.withUserAndServer; -import static com.suse.manager.webui.utils.SparkApplicationHelper.withUserPreferences; -import static spark.Spark.get; -import static spark.Spark.post; - -import com.redhat.rhn.common.localization.LocalizationService; -import com.redhat.rhn.domain.action.ActionFactory; -import com.redhat.rhn.domain.action.virtualization.BaseVirtualizationNetworkAction; -import com.redhat.rhn.domain.action.virtualization.VirtualizationNetworkCreateAction; -import com.redhat.rhn.domain.action.virtualization.VirtualizationNetworkStateChangeAction; -import com.redhat.rhn.domain.server.Server; -import com.redhat.rhn.domain.user.User; - -import com.suse.manager.virtualization.HostInfo; -import com.suse.manager.virtualization.NetworkDefinition; -import com.suse.manager.webui.controllers.MinionController; -import com.suse.manager.webui.controllers.virtualization.gson.VirtualNetworkBaseActionJson; -import com.suse.manager.webui.controllers.virtualization.gson.VirtualNetworkCreateActionJson; -import com.suse.manager.webui.controllers.virtualization.gson.VirtualNetworkInfoJson; -import com.suse.manager.webui.errors.NotFoundException; -import com.suse.manager.webui.services.iface.VirtManager; - -import com.google.gson.JsonObject; -import com.google.gson.reflect.TypeToken; - -import org.apache.http.HttpStatus; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.function.Function; -import java.util.stream.Collectors; - -import spark.ModelAndView; -import spark.Request; -import spark.Response; -import spark.Spark; -import spark.template.jade.JadeTemplateEngine; - -/** - * Controller class providing backend for Virtual networks UI - */ -public class VirtualNetsController extends AbstractVirtualizationController { - - /** - * Controller class providing backend for Virtual networks UI - * @param virtManagerIn instance to manage virtualization - */ - public VirtualNetsController(VirtManager virtManagerIn) { - super(virtManagerIn, "templates/virtualization/nets"); - } - - /** - * Initialize request routes for the pages served by VirtualNetsController - * - * @param jade jade engine - */ - public void initRoutes(JadeTemplateEngine jade) { - get("/manager/systems/details/virtualization/nets/:sid", - withUserPreferences(withCsrfToken(withDocsLocale(withUserAndServer(this::show)))), jade); - get("/manager/systems/details/virtualization/nets/:sid/new", - withUserPreferences(withCsrfToken(withDocsLocale(withUserAndServer(this::createDialog)))), jade); - get("/manager/systems/details/virtualization/nets/:sid/edit/:name", - withUserPreferences(withCsrfToken(withDocsLocale(withUserAndServer(this::editDialog)))), jade); - - get("/manager/api/systems/details/virtualization/nets/:sid/data", - withUserAndServer(this::data)); - get("/manager/api/systems/details/virtualization/nets/:sid/devices", - withUserAndServer(this::devices)); - post("/manager/api/systems/details/virtualization/nets/:sid/start", - withUserAndServer(this::start)); - post("/manager/api/systems/details/virtualization/nets/:sid/stop", - withUserAndServer(this::stop)); - post("/manager/api/systems/details/virtualization/nets/:sid/delete", - withUserAndServer(this::delete)); - post("/manager/api/systems/details/virtualization/nets/:sid/create", - withUserAndServer(this::create)); - post("/manager/api/systems/details/virtualization/nets/:sid/edit", - withUserAndServer(this::edit)); - get("/manager/api/systems/details/virtualization/nets/:sid/net/:name", - asJson(withUserAndServer(this::getNetwork))); - } - - /** - * Displays the virtual networks page. - * - * @param request the request - * @param response the response - * @param user the user - * @param host the server - * @return the ModelAndView object to render the page - */ - public ModelAndView show(Request request, Response response, User user, Server host) { - String minionId = host.asMinionServer().orElseThrow(NotFoundException::new).getMinionId(); - Map features = virtManager.getFeatures(minionId).orElse(new HashMap<>()); - return renderPage("show", () -> { - Map extra = new HashMap<>(); - Optional hostInfo = virtManager.getHostInfo(host.getMinionId()); - String hypervisor = hostInfo.isPresent() ? hostInfo.get().getHypervisor() : ""; - extra.put("hypervisor", host.hasVirtualizationEntitlement() ? hypervisor : ""); - extra.put("support_enhanced_network", features.getOrDefault("enhanced_network", false)); - return extra; - }); - } - - /** - * Displays the virtual network creation page. - * - * @param request the request - * @param response the response - * @param user the user - * @param host the server - * @return the ModelAndView object to render the page - */ - public ModelAndView createDialog(Request request, Response response, User user, Server host) { - return renderPage("create", () -> { - Map data = new HashMap<>(); - MinionController.addActionChains(user, data); - return data; - }); - } - - /** - * Displays the virtual network editing page. - * - * @param request the request - * @param response the response - * @param user the user - * @param host the server - * @return the ModelAndView object to render the page - */ - public ModelAndView editDialog(Request request, Response response, User user, Server host) { - return renderPage("edit", () -> { - Map data = new HashMap<>(); - data.put("netName", request.params("name")); - MinionController.addActionChains(user, data); - return data; - }); - } - - /** - * Returns JSON data describing the virtual networks - * - * @param request the request - * @param response the response - * @param user the user - * @param host the server - * @return JSON result of the API call - */ - public String data(Request request, Response response, User user, Server host) { - String minionId = host.asMinionServer().orElseThrow(NotFoundException::new).getMinionId(); - - Map infos = virtManager.getNetworks(minionId); - List networks = infos.entrySet().stream() - .map(entry -> new VirtualNetworkInfoJson(entry.getKey(), entry.getValue())) - .collect(Collectors.toList()); - - return json(response, networks, new TypeToken<>() { }); - } - - /** - * Returns JSON data describing the host ethernet devices - * - * @param request the request - * @param response the response - * @param user the user - * @param host the server - * @return JSON result of the API call - */ - public String devices(Request request, Response response, User user, Server host) { - String minionId = host.asMinionServer().orElseThrow(NotFoundException::new).getMinionId(); - - List allDevices = virtManager.getHostDevices(minionId); - Map byName = allDevices.stream().collect( - Collectors.toMap(item -> item.get("name").getAsString(), Function.identity())); - - List netDevices = allDevices.stream() - .filter(item -> "net".equals(item.get("caps").getAsString())) - .map(item -> { - item.remove("caps"); - // Extract infos from the parent device if possible - if (item.has("device name")) { - JsonObject parent = byName.get(item.get("device name").getAsString()); - item.remove("device name"); - if (parent != null) { - boolean isVirtual = parent.has("physical function"); - item.addProperty("VF", isVirtual); - if (isVirtual) { - item.addProperty("PCI address", parent.get("address").getAsString()); - } - item.addProperty("PF", parent.has("virtual functions")); - } - } - return item; - }) - .collect(Collectors.toList()); - - return json(response, netDevices, new TypeToken<>() { }); - } - - /** - * Executes the POST query to start a set of virtual networks - * - * @param request the request - * @param response the response - * @param user the user - * @param host the server - * @return JSON list of created action IDs - */ - public String start(Request request, Response response, User user, Server host) { - return netStateChangeAction(request, response, user, host, "start"); - } - - /** - * Executes the POST query to stop a set of virtual networks - * - * @param request the request - * @param response the response - * @param user the user - * @param host the server - * @return JSON list of created action IDs - */ - public String stop(Request request, Response response, User user, Server host) { - return netStateChangeAction(request, response, user, host, "stop"); - } - - /** - * Executes the POST query to delete a set of virtual networks - * - * @param request the request - * @param response the response - * @param user the user - * @param host the server - * @return JSON list of created action IDs - */ - public String delete(Request request, Response response, User user, Server host) { - return netStateChangeAction(request, response, user, host, "delete"); - } - - /** - * Executes the POST query to create a virtual network - * - * @param request the request - * @param response the response - * @param user the user - * @param host the server - * @return JSON list of created action IDs - */ - public String create(Request request, Response response, User user, Server host) { - return createOrUpdate(request, response, user, host, null); - } - - /** - * Executes the POST query to edit a virtual network - * - * @param request the request - * @param response the response - * @param user the user - * @param host the server - * @return JSON list of created action IDs - */ - public String edit(Request request, Response response, User user, Server host) { - String actionName = LocalizationService.getInstance().getMessage("virt.network_update"); - return createOrUpdate(request, response, user, host, actionName); - } - - private String createOrUpdate(Request request, Response response, User user, Server host, String actionName) { - return netAction(request, response, user, host, (data) -> { - VirtualizationNetworkCreateAction action = (VirtualizationNetworkCreateAction) - ActionFactory.createAction(ActionFactory.TYPE_VIRTUALIZATION_NETWORK_CREATE); - String displayName = actionName != null ? actionName : action.getActionType().getName(); - action.setName(displayName + ": " + String.join(",", data.getNames())); - - if (data.getNames().isEmpty()) { - throw new IllegalArgumentException("Network names needs to contain an element"); - } - - action.setNetworkName(data.getNames().get(0)); - action.setDefinition(data.getDefinition()); - - return action; - }, VirtualNetworkCreateActionJson.class); - } - - /** - * Executes the GET query to extract the network definition - * - * @param request the request - * @param response the response - * @param user the user - * @param host the server - * @return JSON-formatted capabilities - */ - public String getNetwork(Request request, Response response, User user, Server host) { - String minionId = host.asMinionServer().orElseThrow(() -> - Spark.halt(HttpStatus.SC_BAD_REQUEST, "Can only get network definition of Salt system")).getMinionId(); - - String netName = request.params("name"); - NetworkDefinition definition = virtManager.getNetworkDefinition(minionId, netName) - .orElseThrow(NotFoundException::new); - - return GSON.toJson(definition); - } - - private String netStateChangeAction(Request request, Response response, User user, Server server, String state) { - return netAction(request, response, user, server, (data) -> { - VirtualizationNetworkStateChangeAction action = (VirtualizationNetworkStateChangeAction) - ActionFactory.createAction(ActionFactory.TYPE_VIRTUALIZATION_NETWORK_STATE_CHANGE); - action.setState(state); - - action.setName(LocalizationService.getInstance().getMessage("virt.network_" + state) + ": " + - String.join(",", data.getNames())); - return action; - }); - } - - private String netAction(Request request, Response response, User user, Server server, - Function actionCreator) { - return netAction(request, response, user, server, actionCreator, VirtualNetworkBaseActionJson.class); - } - - private String netAction(Request request, Response response, User user, - Server server, - Function actionCreator, - Class jsonClass) { - return action(request, response, user, server, - (data, key) -> { - BaseVirtualizationNetworkAction action = actionCreator.apply(data); - action.setNetworkName(key); - return action; - }, - VirtualNetworkBaseActionJson::getNames, - jsonClass - ); - } -} diff --git a/java/code/src/com/suse/manager/webui/controllers/virtualization/VirtualPoolsController.java b/java/code/src/com/suse/manager/webui/controllers/virtualization/VirtualPoolsController.java deleted file mode 100644 index 320c76c3daa2..000000000000 --- a/java/code/src/com/suse/manager/webui/controllers/virtualization/VirtualPoolsController.java +++ /dev/null @@ -1,457 +0,0 @@ -/* - * Copyright (c) 2018 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.suse.manager.webui.controllers.virtualization; - -import static com.suse.manager.webui.utils.SparkApplicationHelper.json; -import static com.suse.manager.webui.utils.SparkApplicationHelper.withCsrfToken; -import static com.suse.manager.webui.utils.SparkApplicationHelper.withDocsLocale; -import static com.suse.manager.webui.utils.SparkApplicationHelper.withUserAndServer; -import static com.suse.manager.webui.utils.SparkApplicationHelper.withUserPreferences; -import static spark.Spark.get; -import static spark.Spark.post; - -import com.redhat.rhn.common.localization.LocalizationService; -import com.redhat.rhn.domain.action.ActionFactory; -import com.redhat.rhn.domain.action.virtualization.BaseVirtualizationPoolAction; -import com.redhat.rhn.domain.action.virtualization.BaseVirtualizationVolumeAction; -import com.redhat.rhn.domain.action.virtualization.VirtualizationPoolCreateAction; -import com.redhat.rhn.domain.action.virtualization.VirtualizationPoolDeleteAction; -import com.redhat.rhn.domain.action.virtualization.VirtualizationPoolRefreshAction; -import com.redhat.rhn.domain.action.virtualization.VirtualizationPoolStartAction; -import com.redhat.rhn.domain.action.virtualization.VirtualizationPoolStopAction; -import com.redhat.rhn.domain.server.Server; -import com.redhat.rhn.domain.user.User; - -import com.suse.manager.virtualization.HostInfo; -import com.suse.manager.virtualization.PoolCapabilitiesJson; -import com.suse.manager.virtualization.PoolDefinition; -import com.suse.manager.webui.controllers.MinionController; -import com.suse.manager.webui.controllers.virtualization.gson.VirtualPoolBaseActionJson; -import com.suse.manager.webui.controllers.virtualization.gson.VirtualPoolCreateActionJson; -import com.suse.manager.webui.controllers.virtualization.gson.VirtualPoolDeleteActionJson; -import com.suse.manager.webui.controllers.virtualization.gson.VirtualStoragePoolInfoJson; -import com.suse.manager.webui.controllers.virtualization.gson.VirtualStorageVolumeInfoJson; -import com.suse.manager.webui.controllers.virtualization.gson.VirtualVolumeBaseActionJson; -import com.suse.manager.webui.errors.NotFoundException; -import com.suse.manager.webui.services.iface.VirtManager; - -import com.google.gson.JsonObject; -import com.google.gson.reflect.TypeToken; - -import org.apache.http.HttpStatus; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.function.Function; -import java.util.function.Supplier; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import java.util.stream.Collectors; - -import spark.ModelAndView; -import spark.Request; -import spark.Response; -import spark.Spark; -import spark.template.jade.JadeTemplateEngine; - -/** - * Controller class providing backend for Virtual storage pools UI - */ -public class VirtualPoolsController extends AbstractVirtualizationController { - - /** - * Controller class providing backend for Virtual storage pools UI - * @param virtManagerIn instance to manage virtualization - */ - public VirtualPoolsController(VirtManager virtManagerIn) { - super(virtManagerIn, "templates/virtualization/pools"); - } - - /** - * Initialize request routes for the pages served by VirtualPoolsController - * - * @param jade jade engine - */ - public void initRoutes(JadeTemplateEngine jade) { - get("/manager/systems/details/virtualization/storage/:sid", - withUserPreferences(withCsrfToken(withDocsLocale(withUserAndServer(this::show)))), jade); - get("/manager/systems/details/virtualization/storage/:sid/new", - withUserPreferences(withCsrfToken(withDocsLocale(withUserAndServer(this::createDialog)))), jade); - get("/manager/systems/details/virtualization/storage/:sid/edit/:name", - withUserPreferences(withCsrfToken(withDocsLocale(withUserAndServer(this::editDialog)))), jade); - get("/manager/api/systems/details/virtualization/pools/:sid/data", - withUserAndServer(this::data)); - get("/manager/api/systems/details/virtualization/pools/:sid/capabilities", - withUserAndServer(this::getCapabilities)); - get("/manager/api/systems/details/virtualization/pools/:sid/pool/:name", - withUserAndServer(this::getPool)); - post("/manager/api/systems/details/virtualization/pools/:sid/refresh", - withUserAndServer(this::poolRefresh)); - post("/manager/api/systems/details/virtualization/pools/:sid/start", - withUserAndServer(this::poolStart)); - post("/manager/api/systems/details/virtualization/pools/:sid/stop", - withUserAndServer(this::poolStop)); - post("/manager/api/systems/details/virtualization/pools/:sid/delete", - withUserAndServer(this::poolDelete)); - post("/manager/api/systems/details/virtualization/pools/:sid/create", - withUserAndServer(this::poolCreate)); - post("/manager/api/systems/details/virtualization/pools/:sid/edit", - withUserAndServer(this::poolEdit)); - post("/manager/api/systems/details/virtualization/volumes/:sid/delete", - withUserAndServer(this::volumeDelete)); - } - - /** - * Displays the virtual storages page. - * - * @param request the request - * @param response the response - * @param user the user - * @param host the server - * @return the ModelAndView object to render the page - */ - public ModelAndView show(Request request, Response response, User user, Server host) { - return renderPage("show", () -> { - Map extra = new HashMap<>(); - Optional hostInfo = virtManager.getHostInfo(host.getMinionId()); - String hypervisor = hostInfo.isPresent() ? hostInfo.get().getHypervisor() : ""; - extra.put("hypervisor", host.hasVirtualizationEntitlement() ? hypervisor : ""); - return extra; - }); - } - - - /** - * Displays the virtual storage pool creation page. - * - * @param request the request - * @param response the response - * @param user the user - * @param server the server - * @return the ModelAndView object to render the page - */ - public ModelAndView createDialog(Request request, Response response, User user, Server server) { - return renderWithActionChains(user, "create", null); - } - - - /** - * Displays the virtual storage pool edit page. - * - * @param request the request - * @param response the response - * @param user the user - * @param server the server - * @return the ModelAndView object to render the page - */ - public ModelAndView editDialog(Request request, Response response, User user, Server server) { - return renderWithActionChains(user, "edit", - () -> { - Map data = new HashMap<>(); - data.put("poolName", request.params("name")); - return data; - } - ); - } - - - /** - * Returns JSON data describing the storage pools - * - * @param request the request - * @param response the response - * @param user the user - * @param host the server - * @return JSON result of the API call - */ - public String data(Request request, Response response, User user, Server host) { - String minionId = host.asMinionServer().orElseThrow(NotFoundException::new).getMinionId(); - - Map infos = virtManager.getPools(minionId); - Map> volInfos = virtManager.getVolumes(minionId); - List pools = infos.entrySet().stream().map(entry -> { - Map poolVols = volInfos.getOrDefault(entry.getKey(), new HashMap<>()); - List volumes = poolVols.entrySet().stream() - .map(volEntry -> new VirtualStorageVolumeInfoJson(volEntry.getKey(), volEntry.getValue())) - .collect(Collectors.toList()); - - return new VirtualStoragePoolInfoJson(entry.getKey(), entry.getValue(), volumes); - }).collect(Collectors.toList()); - - return json(response, pools, new TypeToken<>() { }); - } - - /** - * Executes the GET query to extract the pool capabilities - * - * @param request the request - * @param response the response - * @param user the user - * @param host the server - * @return JSON-formatted capabilities - */ - public String getCapabilities(Request request, Response response, User user, Server host) { - String minionId = host.asMinionServer().orElseThrow(() -> - Spark.halt(HttpStatus.SC_BAD_REQUEST, "Can only get capabilities of Salt system")).getMinionId(); - - PoolCapabilitiesJson caps = virtManager.getPoolCapabilities(minionId) - .orElseThrow(() -> Spark.halt(HttpStatus.SC_BAD_REQUEST, - "Failed to get virtual host storage pool capabilities")); - - return json(response, caps, new TypeToken<>() { }); - } - - /** - * Executes the GET query to extract the pool definition - * - * @param request the request - * @param response the response - * @param user the user - * @param host the server - * @return JSON-formatted capabilities - */ - public String getPool(Request request, Response response, User user, Server host) { - String minionId = host.asMinionServer().orElseThrow(() -> - Spark.halt(HttpStatus.SC_BAD_REQUEST, "Can only get pool definition of Salt system")).getMinionId(); - - String poolName = request.params("name"); - PoolDefinition definition = virtManager.getPoolDefinition(minionId, poolName) - .orElseThrow(NotFoundException::new); - - return json(response, definition, new TypeToken<>() { }); - } - - /** - * Executes the POST query to refresh a set of virtual pools. - * - * @param request the request - * @param response the response - * @param user the user - * @param host the server - * @return JSON list of created action IDs - */ - public String poolRefresh(Request request, Response response, User user, Server host) { - return poolAction(request, response, user, host, (data) -> { - VirtualizationPoolRefreshAction action = (VirtualizationPoolRefreshAction) - ActionFactory.createAction(ActionFactory.TYPE_VIRTUALIZATION_POOL_REFRESH); - action.setName(action.getActionType().getName() + ": " + String.join(",", data.getPoolNames())); - return action; - }); - } - - /** - * Executes the POST query to start a set of virtual pools. - * - * @param request the request - * @param response the response - * @param user the user - * @param host the server - * @return JSON list of created action IDs - */ - public String poolStart(Request request, Response response, User user, Server host) { - return poolAction(request, response, user, host, (data) -> { - VirtualizationPoolStartAction action = (VirtualizationPoolStartAction) - ActionFactory.createAction(ActionFactory.TYPE_VIRTUALIZATION_POOL_START); - action.setName(action.getActionType().getName() + ": " + String.join(",", data.getPoolNames())); - return action; - }); - } - - /** - * Executes the POST query to stop a set of virtual pools. - * - * @param request the request - * @param response the response - * @param user the user - * @param host the server - * @return JSON list of created action IDs - */ - public String poolStop(Request request, Response response, User user, Server host) { - return poolAction(request, response, user, host, (data) -> { - VirtualizationPoolStopAction action = (VirtualizationPoolStopAction) - ActionFactory.createAction(ActionFactory.TYPE_VIRTUALIZATION_POOL_STOP); - action.setName(action.getActionType().getName() + ": " + String.join(",", data.getPoolNames())); - return action; - }); - } - - /** - * Executes the POST query to delete a set of virtual pools. - * - * @param request the request - * @param response the response - * @param user the user - * @param host the server - * @return JSON list of created action IDs - */ - public String poolDelete(Request request, Response response, User user, Server host) { - return poolAction(request, response, user, host, (data) -> { - VirtualizationPoolDeleteAction action = (VirtualizationPoolDeleteAction) - ActionFactory.createAction(ActionFactory.TYPE_VIRTUALIZATION_POOL_DELETE); - action.setName(action.getActionType().getName() + ": " + String.join(",", data.getPoolNames())); - - if (data.getPurge() != null) { - action.setPurge(data.getPurge()); - } - return action; - }, VirtualPoolDeleteActionJson.class); - } - - /** - * Executes the POST query to create a virtual pool. - * - * @param request the request - * @param response the response - * @param user the user - * @param host the server - * @return JSON list of created action IDs - */ - public String poolCreate(Request request, Response response, User user, Server host) { - return poolCreateOrUpdate(request, response, user, host, null); - } - - /** - * - * @param request the request - * @param response the response - * @param user the user - * @param server the server - * @param actionName the display name of the action. If null, default to the one from the ActionType - * @return JSON list of created action IDs - */ - public String poolCreateOrUpdate(Request request, Response response, User user, Server server, String actionName) { - return poolAction(request, response, user, server, (data) -> { - VirtualizationPoolCreateAction action = (VirtualizationPoolCreateAction) - ActionFactory.createAction(ActionFactory.TYPE_VIRTUALIZATION_POOL_CREATE); - String displayName = actionName != null ? actionName : action.getActionType().getName(); - action.setName(displayName + ": " + String.join(",", data.getPoolNames())); - - if (data.getPoolNames().isEmpty()) { - throw new IllegalArgumentException("pool names needs to contain an element"); - } - - action.setUuid(data.getUuid()); - action.setPoolName(data.getPoolNames().get(0)); - action.setType(data.getType()); - action.setAutostart(data.isAutostart()); - if (data.getTarget() != null) { - action.setTarget(data.getTarget().getPath()); - action.setOwner(data.getTarget().getOwner()); - action.setGroup(data.getTarget().getGroup()); - action.setMode(data.getTarget().getMode()); - action.setSeclabel(data.getTarget().getSeclabel()); - } - action.setSource(data.getSource()); - - return action; - }, VirtualPoolCreateActionJson.class); - } - - - /** - * Executes the POST query to edit a virtual pool. - * - * @param request the request - * @param response the response - * @param user the user - * @param server the server - * @return JSON list of created action IDs - */ - public String poolEdit(Request request, Response response, User user, Server server) { - String actionName = LocalizationService.getInstance().getMessage("virt.pool_update"); - return poolCreateOrUpdate(request, response, user, server, actionName); - } - - /** - * Executes the POST query to delete a set of virtual volumes. - * - * @param request the request - * @param response the response - * @param user the user - * @param server the server - * @return JSON list of created action IDs - */ - public String volumeDelete(Request request, Response response, User user, Server server) { - return volumeAction(request, response, user, server, - data -> (BaseVirtualizationVolumeAction)ActionFactory.createAction( - ActionFactory.TYPE_VIRTUALIZATION_VOLUME_DELETE), - VirtualVolumeBaseActionJson.class); - } - - - - /** - * Displays a virtual storage pool-relate page with actionChains in the model. - * - * @param user the user - * @param template the name to the Jade template of the page - * @param modelExtender provides additional properties to pass to the Jade template - * @return the ModelAndView object to render the page - */ - private ModelAndView renderWithActionChains(User user, String template, - Supplier> modelExtender) { - return renderPage(template, - () -> { - Map data = new HashMap<>(); - MinionController.addActionChains(user, data); - if (modelExtender != null) { - data.putAll(modelExtender.get()); - } - return data; - } - ); - } - - private String poolAction(Request request, Response response, User user, Server server, - Function actionCreator) { - return poolAction(request, response, user, server, actionCreator, VirtualPoolBaseActionJson.class); - } - - private String poolAction(Request request, Response response, User user, - Server server, - Function actionCreator, - Class jsonClass) { - return action(request, response, user, server, - (data, key) -> { - BaseVirtualizationPoolAction action = actionCreator.apply(data); - action.setPoolName(key); - return action; - }, - VirtualPoolBaseActionJson::getPoolNames, - jsonClass); - } - - private String volumeAction(Request request, Response response, User user, - Server server, - Function actionCreator, - Class jsonClass) { - return action(request, response, user, server, - (data, key) -> { - BaseVirtualizationVolumeAction action = actionCreator.apply(data); - action.setName(action.getActionType().getName() + ": " + key); - Matcher m = Pattern.compile("^([^/]+)/(.*)$").matcher(key); - if (m.matches()) { - action.setPoolName(m.group(1)); - action.setVolumeName(m.group(2)); - } - return action; - }, - VirtualVolumeBaseActionJson::getVolumesPath, - jsonClass - ); - } -} diff --git a/java/code/src/com/suse/manager/webui/controllers/virtualization/gson/VirtualGuestMigrateActionJson.java b/java/code/src/com/suse/manager/webui/controllers/virtualization/gson/VirtualGuestMigrateActionJson.java deleted file mode 100644 index de5adb510d2d..000000000000 --- a/java/code/src/com/suse/manager/webui/controllers/virtualization/gson/VirtualGuestMigrateActionJson.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2021 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.suse.manager.webui.controllers.virtualization.gson; - -/** - * Represents the data passed for a migration action - */ -public class VirtualGuestMigrateActionJson extends VirtualGuestsBaseActionJson { - private String primitive; - private String target; - - /** - * @return value of primitive - */ - public String getPrimitive() { - return primitive; - } - - /** - * @param primitiveIn value of primitive - */ - public void setPrimitive(String primitiveIn) { - primitive = primitiveIn; - } - - /** - * @return value of target - */ - public String getTarget() { - return target; - } - - /** - * @param targetIn value of target - */ - public void setTarget(String targetIn) { - target = targetIn; - } -} diff --git a/java/code/src/com/suse/manager/webui/controllers/virtualization/gson/VirtualGuestSetterActionJson.java b/java/code/src/com/suse/manager/webui/controllers/virtualization/gson/VirtualGuestSetterActionJson.java deleted file mode 100644 index ec0a294ac6ab..000000000000 --- a/java/code/src/com/suse/manager/webui/controllers/virtualization/gson/VirtualGuestSetterActionJson.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2018 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.suse.manager.webui.controllers.virtualization.gson; - -/** - * VirtualGuestsBaseAction represents most of the virtual guests actions - * requests Json data. - */ -public class VirtualGuestSetterActionJson extends VirtualGuestsBaseActionJson { - - private Long value; - - /** - * @return the value to set. - */ - public Long getValue() { - return value; - } - - /** - * @param settingValue the value to set. Only needed for setMemory and setVcpu actions. - */ - public void setValue(Long settingValue) { - this.value = settingValue; - } -} diff --git a/java/code/src/com/suse/manager/webui/controllers/virtualization/gson/VirtualGuestsBaseActionJson.java b/java/code/src/com/suse/manager/webui/controllers/virtualization/gson/VirtualGuestsBaseActionJson.java deleted file mode 100644 index 33b262d1775c..000000000000 --- a/java/code/src/com/suse/manager/webui/controllers/virtualization/gson/VirtualGuestsBaseActionJson.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2018 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.suse.manager.webui.controllers.virtualization.gson; - -import com.suse.manager.webui.utils.gson.ScheduledRequestJson; - -import java.util.List; - -/** - * VirtualGuestsBaseAction represents the common properties for all the virtualization guests - * action requests JSON data. - */ -public class VirtualGuestsBaseActionJson extends ScheduledRequestJson { - - private List uuids; - private Boolean force; - - /** - * @return the list of UUIDs of virtual guests to act on - */ - public List getUuids() { - return uuids; - } - - /** - * @param uuidsIn the list of UUIDs of virtual guests to act on - */ - public void setUuids(List uuidsIn) { - this.uuids = uuidsIn; - } - - /** - * @return Returns whether to force the action. - */ - public Boolean getForce() { - return force; - } - - /** - * @param forceIn whether to force the action. - */ - public void setForce(Boolean forceIn) { - force = forceIn; - } -} diff --git a/java/code/src/com/suse/manager/webui/controllers/virtualization/gson/VirtualGuestsUpdateActionJson.java b/java/code/src/com/suse/manager/webui/controllers/virtualization/gson/VirtualGuestsUpdateActionJson.java deleted file mode 100644 index d6216f721548..000000000000 --- a/java/code/src/com/suse/manager/webui/controllers/virtualization/gson/VirtualGuestsUpdateActionJson.java +++ /dev/null @@ -1,435 +0,0 @@ -/* - * Copyright (c) 2018 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.suse.manager.webui.controllers.virtualization.gson; - -import com.google.gson.annotations.SerializedName; - -import java.util.ArrayList; -import java.util.List; - -/** - * VirtualGuestsUpdate represents the JSON data for the virtual guests - * update or create action. A create action just doesn't have any uuid - * defined. - */ -public class VirtualGuestsUpdateActionJson extends VirtualGuestsBaseActionJson { - private Long vcpu; - private String type; - private String name; - private String osType; - private String arch; - private Long memory; - private List disks = new ArrayList<>(); - private List interfaces = new ArrayList<>(); - private String graphicsType; - @SerializedName("cobbler_profile") - private String cobblerId; - @SerializedName("kernel_options") - private String kernelOptions; - @SerializedName("cluster_definitions") - private String clusterDefinitions; - private String template; - private boolean uefi; - private String uefiLoader; - private String nvramTemplate; - - /** - * @return the domain type (kvm, qemu, linux, xen...) - */ - public String getType() { - return type; - } - - /** - * - * @param typeIn the domain type (kvm, qemu, linux, xen...) - */ - public void setType(String typeIn) { - type = typeIn; - } - - /** - * @return the VM name - */ - public String getName() { - return name; - } - - /** - * @param nameIn the VM name - */ - public void setName(String nameIn) { - this.name = nameIn; - } - - /** - * @return the VM type (HVM / PV) - */ - public String getOsType() { - return osType; - } - - /** - * @param osTypeIn the VM type (HVM / PV) - */ - public void setOsType(String osTypeIn) { - this.osType = osTypeIn; - } - - /** - * @return the VM CPU architecture - */ - public String getArch() { - return arch; - } - - /** - * @param archIn the VM CPU architecture - */ - public void setArch(String archIn) { - this.arch = archIn; - } - - /** - * @return number of VCPUs to set - */ - public Long getVcpu() { - return vcpu; - } - - /** - * @param vcpuIn number of VCPUs to set - */ - public void setVcpu(Long vcpuIn) { - vcpu = vcpuIn; - } - - /** - * @return amount of memory in MiB to set - */ - public Long getMemory() { - return memory; - } - - /** - * @param memoryIn amount of memory in MiB to set - */ - public void setMemory(Long memoryIn) { - memory = memoryIn; - } - /** - * @return the disks definitions for the VM - */ - public List getDisks() { - return disks; - } - - /** - * @param disksIn the disks definitions for the VM - */ - public void setDisks(List disksIn) { - this.disks = disksIn; - } - - /** - * @return the virtual NIC definitions for the VM - */ - public List getInterfaces() { - return interfaces; - } - - /** - * @param interfacesIn the virtual NIC definitions for the VM - */ - public void setInterfaces(List interfacesIn) { - this.interfaces = interfacesIn; - } - - /** - * @return the graphics type of the VM (VNC / Spice / None) - */ - public String getGraphicsType() { - return graphicsType; - } - - /** - * @param graphicsTypeIn the graphics type of the VM (VNC / Spice / None) - */ - public void setGraphicsType(String graphicsTypeIn) { - this.graphicsType = graphicsTypeIn; - } - - /** - * @return The ID of the cobbler profile to use to create the VM - */ - public String getCobblerId() { - return cobblerId; - } - - /** - * @param cobblerIdIn the ID of the cobbler profile to use to create the VM - */ - public void setCobblerId(String cobblerIdIn) { - cobblerId = cobblerIdIn; - } - - /** - * @return the kernel options to use with cobbler profile - */ - public String getKernelOptions() { - return kernelOptions; - } - - /** - * @param kernelOptionsIn the kernel options to use with cobbler profile - */ - public void setKernelOptions(String kernelOptionsIn) { - kernelOptions = kernelOptionsIn; - } - - /** - * @return value of clusterDefinitions - */ - public String getClusterDefinitions() { - return clusterDefinitions; - } - - /** - * @param clusterDefinitionsIn value of clusterDefinitions - */ - public void setClusterDefinitions(String clusterDefinitionsIn) { - clusterDefinitions = clusterDefinitionsIn; - } - - /** - * @return value of template - */ - public String getTemplate() { - return template; - } - - /** - * @param templateIn value of template - */ - public void setTemplate(String templateIn) { - template = templateIn; - } - - /** - * @return value of uefi - */ - public boolean isUefi() { - return uefi; - } - - /** - * @param uefiIn value of uefi - */ - public void setUefi(boolean uefiIn) { - uefi = uefiIn; - } - - /** - * @return value of uefiLoader - */ - public String getUefiLoader() { - return uefiLoader; - } - - /** - * @param uefiLoaderIn value of uefiLoader - */ - public void setUefiLoader(String uefiLoaderIn) { - uefiLoader = uefiLoaderIn; - } - - /** - * @return value of nvramTemplate - */ - public String getNvramTemplate() { - return nvramTemplate; - } - - /** - * @param nvramTemplateIn value of nvramTemplate - */ - public void setNvramTemplate(String nvramTemplateIn) { - nvramTemplate = nvramTemplateIn; - } - - /** - * Class describing the JSON disk data - */ - public class DiskData { - private String device; - private String template; - private long size = 0; - private String bus; - private String pool; - private String format; - - @SerializedName("source_file") - private String sourceFile; - - /** - * @return Returns the device. - */ - public String getDevice() { - return device; - } - - /** - * @param deviceIn The device to set. - */ - public void setDevice(String deviceIn) { - device = deviceIn; - } - - /** - * @return Returns the source file. - */ - public String getSourceFile() { - return sourceFile; - } - - /** - * @param sourceFileIn The source_file to set. - */ - public void setSourceFile(String sourceFileIn) { - sourceFile = sourceFileIn; - } - - /** - * @return the disk image template URI - */ - public String getTemplate() { - return template; - } - - /** - * @param templateIn the disk image template URI - */ - public void setTemplate(String templateIn) { - this.template = templateIn; - } - - /** - * @return Returns the size. - */ - public long getSize() { - return size; - } - - /** - * @param sizeIn The size to set. - */ - public void setSize(long sizeIn) { - size = sizeIn; - } - - /** - * @return the disk bus type to use - */ - public String getBus() { - return bus; - } - - /** - * @param busIn the disk bus type to use - */ - public void setBus(String busIn) { - this.bus = busIn; - } - - /** - * @return where the disk will be located - */ - public String getPool() { - return pool; - } - - /** - * @param poolIn where the disk will be located - */ - public void setPool(String poolIn) { - pool = poolIn; - } - - /** - * @return the disk format - */ - public String getFormat() { - return format; - } - - /** - * @param formatIn the disk format - */ - public void setFormat(String formatIn) { - format = formatIn; - } - } - - /** - * Class describing the JSON network data - */ - public class InterfaceData { - private String type; - private String source; - private String mac; - - /** - * @return Returns the type. - */ - public String getType() { - return type; - } - - /** - * @param typeIn The type to set. - */ - public void setType(String typeIn) { - type = typeIn; - } - - /** - * @return the name of the defined network to use - */ - public String getSource() { - return source; - } - - /** - * @param networkIn the name of the defined network to use - */ - public void setSource(String networkIn) { - this.source = networkIn; - } - - /** - * @return Returns the mac. - */ - public String getMac() { - return mac; - } - - /** - * @param macIn The mac to set. - */ - public void setMac(String macIn) { - mac = macIn; - } - } -} diff --git a/java/code/src/com/suse/manager/webui/controllers/virtualization/gson/VirtualNetworkBaseActionJson.java b/java/code/src/com/suse/manager/webui/controllers/virtualization/gson/VirtualNetworkBaseActionJson.java deleted file mode 100644 index 67306fd2f0e8..000000000000 --- a/java/code/src/com/suse/manager/webui/controllers/virtualization/gson/VirtualNetworkBaseActionJson.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2020 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.suse.manager.webui.controllers.virtualization.gson; - -import com.suse.manager.webui.utils.gson.ScheduledRequestJson; - -import java.util.List; - -/** - * Represents the generic virtual network action request body structure. - */ -public class VirtualNetworkBaseActionJson extends ScheduledRequestJson { - private List names; - - /** - * @return the names of the pools to action on - */ - public List getNames() { - return names; - } - - /** - * @param namesIn The poolNames to set. - */ - public void setNames(List namesIn) { - names = namesIn; - } -} diff --git a/java/code/src/com/suse/manager/webui/controllers/virtualization/gson/VirtualNetworkCreateActionJson.java b/java/code/src/com/suse/manager/webui/controllers/virtualization/gson/VirtualNetworkCreateActionJson.java deleted file mode 100644 index 99c4d441bbff..000000000000 --- a/java/code/src/com/suse/manager/webui/controllers/virtualization/gson/VirtualNetworkCreateActionJson.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2021 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.suse.manager.webui.controllers.virtualization.gson; - -import com.suse.manager.virtualization.NetworkDefinition; - -/** - * Represents the virtual network create action request body structure. - */ -public class VirtualNetworkCreateActionJson extends VirtualNetworkBaseActionJson { - private NetworkDefinition definition; - - /** - * @return the network definition - */ - public NetworkDefinition getDefinition() { - return definition; - } - - /** - * @param definitionIn network definition - */ - public void setDefinition(NetworkDefinition definitionIn) { - definition = definitionIn; - } -} diff --git a/java/code/src/com/suse/manager/webui/controllers/virtualization/gson/VirtualNetworkInfoJson.java b/java/code/src/com/suse/manager/webui/controllers/virtualization/gson/VirtualNetworkInfoJson.java deleted file mode 100644 index 6f207fcaaa33..000000000000 --- a/java/code/src/com/suse/manager/webui/controllers/virtualization/gson/VirtualNetworkInfoJson.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (c) 2018 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.suse.manager.webui.controllers.virtualization.gson; - -import com.google.gson.JsonObject; - -/** - * Represents the virtual network informations data to display in the UI. - * Those data are directly passed over from Salt response. - */ -public class VirtualNetworkInfoJson { - - private String uuid; - private String name; - private String bridge; - private boolean active; - private boolean autostart; - private boolean persistent; - - /** - * Build up an instance from the data returned from salt virt.network_info - * - * @param nameIn the name of the network - * @param values the JSON values returned by salt - */ - public VirtualNetworkInfoJson(String nameIn, JsonObject values) { - setName(nameIn); - setUuid(values.get("uuid").getAsString()); - if (!values.get("bridge").isJsonNull()) { - setBridge(values.get("bridge").getAsString()); - } - setActive(values.get("active").getAsInt() == 1); - setAutostart(values.get("autostart").getAsInt() == 1); - setPersistent(values.get("persistent").getAsInt() == 1); - } - - /** - * @return Returns the uuid. - */ - public String getUuid() { - return uuid; - } - - /** - * @param uuidIn The uuid to set. - */ - public void setUuid(String uuidIn) { - uuid = uuidIn; - } - - /** - * @return Returns the name. - */ - public String getName() { - return name; - } - - /** - * @param nameIn The name to set. - */ - public void setName(String nameIn) { - name = nameIn; - } - - /** - * @return Returns the bridge. - */ - public String getBridge() { - return bridge; - } - - /** - * @param bridgeIn The bridge to set. - */ - public void setBridge(String bridgeIn) { - bridge = bridgeIn; - } - - /** - * @return Returns the active. - */ - public boolean isActive() { - return active; - } - - /** - * @param activeIn The active to set. - */ - public void setActive(boolean activeIn) { - active = activeIn; - } - - /** - * @return Returns the autostart. - */ - public boolean isAutostart() { - return autostart; - } - - /** - * @param autostartIn The autostart to set. - */ - public void setAutostart(boolean autostartIn) { - autostart = autostartIn; - } - - /** - * @return Returns the persistent. - */ - public boolean isPersistent() { - return persistent; - } - - /** - * @param persistentIn The persistent to set. - */ - public void setPersistent(boolean persistentIn) { - persistent = persistentIn; - } -} diff --git a/java/code/src/com/suse/manager/webui/controllers/virtualization/gson/VirtualPoolBaseActionJson.java b/java/code/src/com/suse/manager/webui/controllers/virtualization/gson/VirtualPoolBaseActionJson.java deleted file mode 100644 index bc2cde546960..000000000000 --- a/java/code/src/com/suse/manager/webui/controllers/virtualization/gson/VirtualPoolBaseActionJson.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2020 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.suse.manager.webui.controllers.virtualization.gson; - -import com.suse.manager.webui.utils.gson.ScheduledRequestJson; - -import java.util.List; - -/** - * - * VirtualPoolBaseAction represents the generic pool action request body structure. - */ -public class VirtualPoolBaseActionJson extends ScheduledRequestJson { - private List poolNames; - - /** - * @return the names of the pools to action on - */ - public List getPoolNames() { - return poolNames; - } - - /** - * @param poolNamesIn The poolNames to set. - */ - public void setPoolNames(List poolNamesIn) { - poolNames = poolNamesIn; - } - -} diff --git a/java/code/src/com/suse/manager/webui/controllers/virtualization/gson/VirtualPoolCreateActionJson.java b/java/code/src/com/suse/manager/webui/controllers/virtualization/gson/VirtualPoolCreateActionJson.java deleted file mode 100644 index 612e6e9b4700..000000000000 --- a/java/code/src/com/suse/manager/webui/controllers/virtualization/gson/VirtualPoolCreateActionJson.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (c) 2020 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.suse.manager.webui.controllers.virtualization.gson; - -import com.redhat.rhn.domain.action.virtualization.VirtualizationPoolCreateActionSource; - -import com.suse.manager.virtualization.PoolTarget; - -/** -* -* represents the pool create action request body structure. -*/ -public class VirtualPoolCreateActionJson extends VirtualPoolBaseActionJson { - - private String uuid; - private String type; - private boolean autostart; - private VirtualizationPoolCreateActionSource source; - private PoolTarget target; - - - /** - * @return Returns the uuid. - */ - public String getUuid() { - return uuid; - } - - - /** - * @param uuidIn The uuid to set. - */ - public void setUuid(String uuidIn) { - uuid = uuidIn; - } - - /** - * @return Returns the type. - */ - public String getType() { - return type; - } - - /** - * @param typeIn The type to set. - */ - public void setType(String typeIn) { - type = typeIn; - } - - /** - * @return Returns whether the pool is to be autostarted. - */ - public boolean isAutostart() { - return autostart; - } - - /** - * @param autostartIn whether the pool is to be autostarted. - */ - public void setAutostart(boolean autostartIn) { - autostart = autostartIn; - } - - /** - * @return Returns the source. - */ - public VirtualizationPoolCreateActionSource getSource() { - return source; - } - - /** - * @param sourceIn The source to set. - */ - public void setSource(VirtualizationPoolCreateActionSource sourceIn) { - source = sourceIn; - } - - /** - * @return Returns the target. - */ - public PoolTarget getTarget() { - return target; - } - - /** - * @param targetIn The target to set. - */ - public void setTarget(PoolTarget targetIn) { - target = targetIn; - } -} diff --git a/java/code/src/com/suse/manager/webui/controllers/virtualization/gson/VirtualPoolDeleteActionJson.java b/java/code/src/com/suse/manager/webui/controllers/virtualization/gson/VirtualPoolDeleteActionJson.java deleted file mode 100644 index c282aa23dfc2..000000000000 --- a/java/code/src/com/suse/manager/webui/controllers/virtualization/gson/VirtualPoolDeleteActionJson.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2020 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.suse.manager.webui.controllers.virtualization.gson; - -/** -* -* represents the pool delete action request body structure. -*/ -public class VirtualPoolDeleteActionJson extends VirtualPoolBaseActionJson { - - private Boolean purge; - - /** - * @return Returns whether to remove all volumes or not. - */ - public Boolean getPurge() { - return purge; - } - - /** - * @param purgeIn whether to remove all volumes or not. - */ - public void setPurge(Boolean purgeIn) { - purge = purgeIn; - } -} diff --git a/java/code/src/com/suse/manager/webui/controllers/virtualization/gson/VirtualStoragePoolInfoJson.java b/java/code/src/com/suse/manager/webui/controllers/virtualization/gson/VirtualStoragePoolInfoJson.java deleted file mode 100644 index 00f78a6f597b..000000000000 --- a/java/code/src/com/suse/manager/webui/controllers/virtualization/gson/VirtualStoragePoolInfoJson.java +++ /dev/null @@ -1,228 +0,0 @@ -/* - * Copyright (c) 2018 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.suse.manager.webui.controllers.virtualization.gson; - -import com.google.gson.JsonObject; - -import java.util.List; - -/** - * Represents the virtual storage pool informations data to display in the UI. - * Those data are directly passed over from Salt response. - */ -public class VirtualStoragePoolInfoJson { - - private String uuid; - private String name; - private boolean autostart; - private boolean persistent; - private String state; - private String type; - private String targetPath; - private Long allocation; - private Long capacity; - private Long free; - private List volumes; - - /** - * Build up an instance from the data returned from salt virt.pool_info - * - * @param nameIn the name of the pool - * @param values the JSON values returned by salt - * @param volumesIn the pool volumes infos - */ - public VirtualStoragePoolInfoJson(String nameIn, JsonObject values, List volumesIn) { - setName(nameIn); - setUuid(values.get("uuid").getAsString()); - setAutostart(values.get("autostart").getAsInt() == 1); - setPersistent(values.get("persistent").getAsInt() == 1); - setState(values.get("state").getAsString()); - setType(values.get("type").getAsString()); - setTargetPath(values.get("target_path").isJsonNull() ? null : values.get("target_path").getAsString()); - setAllocation(values.get("allocation").getAsLong()); - setCapacity(values.get("capacity").getAsLong()); - setFree(values.get("free").getAsLong()); - volumes = volumesIn; - } - - - /** - * @return Returns the uuid. - */ - public String getUuid() { - return uuid; - } - - - /** - * @param uuidIn The uuid to set. - */ - public void setUuid(String uuidIn) { - uuid = uuidIn; - } - - - /** - * @return Returns the name. - */ - public String getName() { - return name; - } - - - /** - * @param nameIn The name to set. - */ - public void setName(String nameIn) { - name = nameIn; - } - - - /** - * @return Returns the autostart. - */ - public boolean isAutostart() { - return autostart; - } - - - /** - * @param autostartIn The autostart to set. - */ - public void setAutostart(boolean autostartIn) { - autostart = autostartIn; - } - - - /** - * @return Returns the persistent. - */ - public boolean isPersistent() { - return persistent; - } - - - /** - * @param persistentIn The persistent to set. - */ - public void setPersistent(boolean persistentIn) { - persistent = persistentIn; - } - - - /** - * @return Returns the state. - */ - public String getState() { - return state; - } - - - /** - * @param stateIn The state to set. - */ - public void setState(String stateIn) { - state = stateIn; - } - - - /** - * @return Returns the type. - */ - public String getType() { - return type; - } - - - /** - * @param typeIn The type to set. - */ - public void setType(String typeIn) { - type = typeIn; - } - - - /** - * @return Returns the targetPath. - */ - public String getTargetPath() { - return targetPath; - } - - - /** - * @param targetPathIn The targetPath to set. - */ - public void setTargetPath(String targetPathIn) { - targetPath = targetPathIn; - } - - - /** - * @return Returns the allocation. - */ - public Long getAllocation() { - return allocation; - } - - - /** - * @param allocationIn The allocation to set. - */ - public void setAllocation(Long allocationIn) { - allocation = allocationIn; - } - - - /** - * @return Returns the capacity. - */ - public Long getCapacity() { - return capacity; - } - - - /** - * @param capacityIn The capacity to set. - */ - public void setCapacity(Long capacityIn) { - capacity = capacityIn; - } - - - /** - * @return Returns the free. - */ - public Long getFree() { - return free; - } - - - /** - * @param freeIn The free to set. - */ - public void setFree(Long freeIn) { - free = freeIn; - } - - - - /** - * @return Returns the volumes infos. - */ - public List getVolumes() { - return volumes; - } -} diff --git a/java/code/src/com/suse/manager/webui/controllers/virtualization/gson/VirtualStorageVolumeInfoJson.java b/java/code/src/com/suse/manager/webui/controllers/virtualization/gson/VirtualStorageVolumeInfoJson.java deleted file mode 100644 index 3d5c5c2f13bf..000000000000 --- a/java/code/src/com/suse/manager/webui/controllers/virtualization/gson/VirtualStorageVolumeInfoJson.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) 2019 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.suse.manager.webui.controllers.virtualization.gson; - -import com.google.gson.Gson; -import com.google.gson.JsonObject; -import com.google.gson.reflect.TypeToken; - -import java.util.List; - -/** - * Represents the virtual storage volume informations data to display in the UI. - * Those data are directly passed over from Salt response. - */ -public class VirtualStorageVolumeInfoJson { - - private String name; - private String type; - private String key; - private String path; - private Long capacity; - private Long allocation; - private List usedBy; - - /** - * Build up an instance from the data returned from salt virt.volume_infos - * - * @param nameIn the name of the volume - * @param values the JSON values returned by salt - */ - public VirtualStorageVolumeInfoJson(String nameIn, JsonObject values) { - name = nameIn; - type = values.get("type").getAsString(); - key = values.get("key").getAsString(); - path = values.get("path").getAsString(); - allocation = values.get("allocation").getAsLong(); - capacity = values.get("capacity").getAsLong(); - usedBy = (new Gson().fromJson(values.get("used_by").getAsJsonArray(), - new TypeToken>() { }.getType())); - } - - - /** - * @return Returns the name. - */ - public String getName() { - return name; - } - - - /** - * @return Returns the type. - */ - public String getType() { - return type; - } - - - /** - * @return Returns the key. - */ - public String getKey() { - return key; - } - - - /** - * @return Returns the path. - */ - public String getPath() { - return path; - } - - - /** - * @return Returns the capacity. - */ - public Long getCapacity() { - return capacity; - } - - - /** - * @return Returns the allocation. - */ - public Long getAllocation() { - return allocation; - } - - - /** - * @return Returns the names of the domains using the volume (not exhaustive). - */ - public List getUsedBy() { - return usedBy; - } -} diff --git a/java/code/src/com/suse/manager/webui/controllers/virtualization/gson/VirtualVolumeBaseActionJson.java b/java/code/src/com/suse/manager/webui/controllers/virtualization/gson/VirtualVolumeBaseActionJson.java deleted file mode 100644 index a66a43d7b636..000000000000 --- a/java/code/src/com/suse/manager/webui/controllers/virtualization/gson/VirtualVolumeBaseActionJson.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2020 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.suse.manager.webui.controllers.virtualization.gson; - -import com.suse.manager.webui.utils.gson.ScheduledRequestJson; - -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -/** - * VirtualVolumeBaseAction represents the generic virtual volume action request body structure. - */ -public class VirtualVolumeBaseActionJson extends ScheduledRequestJson { - - private Map> volumes; - - - /** - * The result maps each pool names to a list of volumes to act on within that pool - * - * @return Returns the volumes map. - */ - public Map> getVolumes() { - return volumes; - } - - - /** - * @param volumesIn The volumes to set. - */ - public void setVolumes(Map> volumesIn) { - volumes = volumesIn; - } - - /** - * @return the list of volumes in a <poolName>/<volumeName> form - */ - public List getVolumesPath() { - return getVolumes().entrySet().stream() - .flatMap(entry -> entry.getValue().stream().map(volume -> entry.getKey() + "/" + volume)) - .collect(Collectors.toList()); - } -} diff --git a/java/code/src/com/suse/manager/webui/controllers/virtualization/test/VirtualGuestsControllerTest.java b/java/code/src/com/suse/manager/webui/controllers/virtualization/test/VirtualGuestsControllerTest.java deleted file mode 100644 index cb8ab8d10e4d..000000000000 --- a/java/code/src/com/suse/manager/webui/controllers/virtualization/test/VirtualGuestsControllerTest.java +++ /dev/null @@ -1,473 +0,0 @@ -/* - * Copyright (c) 2018 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ - -package com.suse.manager.webui.controllers.virtualization.test; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.junit.jupiter.api.Assertions.fail; - -import com.redhat.rhn.common.db.datasource.DataResult; -import com.redhat.rhn.domain.action.Action; -import com.redhat.rhn.domain.action.ActionFactory; -import com.redhat.rhn.domain.action.virtualization.BaseVirtualizationGuestAction; -import com.redhat.rhn.domain.action.virtualization.VirtualizationSetMemoryGuestAction; -import com.redhat.rhn.domain.action.virtualization.VirtualizationSetVcpusGuestAction; -import com.redhat.rhn.domain.action.virtualization.VirtualizationShutdownGuestAction; -import com.redhat.rhn.domain.server.MinionServer; -import com.redhat.rhn.domain.server.Server; -import com.redhat.rhn.domain.server.VirtualInstance; -import com.redhat.rhn.frontend.context.Context; -import com.redhat.rhn.frontend.dto.ScheduledAction; -import com.redhat.rhn.manager.action.ActionManager; -import com.redhat.rhn.manager.formula.FormulaMonitoringManager; -import com.redhat.rhn.manager.system.ServerGroupManager; -import com.redhat.rhn.manager.system.entitling.SystemEntitlementManager; -import com.redhat.rhn.manager.system.entitling.SystemEntitler; -import com.redhat.rhn.manager.system.entitling.SystemUnentitler; -import com.redhat.rhn.taskomatic.TaskomaticApi; -import com.redhat.rhn.testing.ServerTestUtils; - -import com.suse.manager.reactor.messaging.test.SaltTestUtils; -import com.suse.manager.virtualization.DomainCapabilitiesJson; -import com.suse.manager.virtualization.GuestDefinition; -import com.suse.manager.virtualization.HostInfo; -import com.suse.manager.virtualization.VirtualizationActionHelper; -import com.suse.manager.virtualization.VmInfoJson; -import com.suse.manager.virtualization.test.TestVirtManager; -import com.suse.manager.webui.controllers.test.BaseControllerTestCase; -import com.suse.manager.webui.controllers.virtualization.VirtualGuestsController; -import com.suse.manager.webui.services.iface.MonitoringManager; -import com.suse.manager.webui.services.iface.SaltApi; -import com.suse.manager.webui.services.iface.VirtManager; -import com.suse.manager.webui.services.test.TestSaltApi; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonElement; -import com.google.gson.reflect.TypeToken; - -import org.jmock.Expectations; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.TimeZone; - -import spark.HaltException; -import spark.ModelAndView; - -/** - * Tests for VirtualGuestsController - */ -public class VirtualGuestsControllerTest extends BaseControllerTestCase { - - private TaskomaticApi taskomaticMock; - private static final Gson GSON = new GsonBuilder().create(); - private Server host; - private VirtManager virtManager; - private VirtualGuestsController virtualGuestsController; - private String guid = "b99a81764f40498d8e612f6ade654fe2"; - private String uuid = "b99a8176-4f40-498d-8e61-2f6ade654fe2"; - - /** - * {@inheritDoc} - */ - @Override - @BeforeEach - public void setUp() throws Exception { - super.setUp(); - - taskomaticMock = mock(TaskomaticApi.class); - ActionManager.setTaskomaticApi(taskomaticMock); - VirtualizationActionHelper.setTaskomaticApi(taskomaticMock); - context().checking(new Expectations() {{ - ignoring(taskomaticMock).scheduleActionExecution(with(any(Action.class))); - }}); - Context.getCurrentContext().setTimezone(TimeZone.getTimeZone("UTC")); - - virtManager = new TestVirtManager() { - - @Override - public Optional> getCapabilities(String minionId) { - return SaltTestUtils.getSaltResponse( - "/com/suse/manager/webui/controllers/virtualization/test/virt.guest.allcaps.json", null, - new TypeToken<>() { - }); - } - - @Override - public void updateLibvirtEngine(MinionServer minion) { - assertTrue(minion.getMinionId().startsWith("serverfactorytest")); - } - - @Override - public Optional getGuestDefinition(String minionId, String uuidIn) { - Optional> vm = SaltTestUtils.getSaltResponse( - "/com/suse/manager/webui/controllers/virtualization/test/virt_utils.vm_definition.json", - Collections.emptyMap(), - new TypeToken<>() { - }); - return vm.map(data -> { - Optional info = Optional.empty(); - if (data.containsKey("info")) { - info = Optional.ofNullable(new GsonBuilder().create() - .fromJson(data.get("info"), new TypeToken() { }.getType())); - } - if (data.containsKey("definition")) { - String xml = data.get("definition").getAsString(); - return GuestDefinition.parse(xml, info); - } - return null; - }); - } - - @Override - public Optional>> getVmInfos(String minionId) { - return SaltTestUtils.>>getSaltResponse( - "/com/suse/manager/webui/controllers/virtualization/test/virt_utils.vm.info.json", - Collections.emptyMap(), - new TypeToken<>() { - }); - } - - @Override - public Optional getHostInfo(String minionId) { - HostInfo info = new HostInfo(); - info.setHypervisor("kvm"); - return Optional.of(info); - } - }; - - SaltApi saltApi = new TestSaltApi(); - MonitoringManager monitoringManager = new FormulaMonitoringManager(saltApi); - ServerGroupManager serverGroupManager = new ServerGroupManager(saltApi); - SystemEntitlementManager systemEntitlementManager = new SystemEntitlementManager( - new SystemUnentitler(virtManager, monitoringManager, serverGroupManager), - new SystemEntitler(saltApi, virtManager, monitoringManager, serverGroupManager) - ); - - host = ServerTestUtils.createVirtHostWithGuests(user, 2, true, systemEntitlementManager); - host.asMinionServer().get().setMinionId("testminion.local"); - VirtualInstance guest = host.getGuests().iterator().next(); - guest.setUuid(guid); - guest.setName("sles12sp2"); - - virtualGuestsController = new VirtualGuestsController(virtManager); - - // Clean pending actions for easier checks in the tests - DataResult actions = ActionManager.allActions(user, null); - for (ScheduledAction scheduledAction : actions) { - ActionManager.failSystemAction(user, host.getId(), scheduledAction.getId(), "test clean up"); - } - } - - /** - * Test getting the data from a virtual host - * - */ - @SuppressWarnings("unchecked") - @Test - public void testData() { - int size = host.getGuests().size(); - VirtualInstance[] guests = host.getGuests().toArray(new VirtualInstance[size]); - Long sid = host.getId(); - - - String json = virtualGuestsController.data( - getRequestWithCsrf("/manager/api/systems/details/virtualization/guests/:sid/data", sid), - response, user, host); - List> model = GSON.fromJson(json, List.class); - - // Sort both actual and expected arrays to ease assertions - Arrays.sort(guests, Comparator.comparing(VirtualInstance::getUuid)); - model.sort(Comparator.comparing(oIn -> ((String) oIn.get("uuid")))); - - assertEquals(size, model.size()); - assertEquals(guests[0].getUuid(), model.get(0).get("uuid")); - assertEquals(guests[1].getUuid(), model.get(1).get("uuid")); - - Double vCpus = (Double)model.get(0).get("vcpus"); - assertEquals(guests[0].getNumberOfCPUs().intValue(), vCpus.intValue()); - assertEquals(guests[1].getState().getLabel(), model.get(1).get("stateLabel")); - } - - /** - * Test a VM state change action - * - * @throws Exception if anything unexpected happens during the test - */ - @Test - public void testStateChangeAction() throws Exception { - VirtualInstance guest = host.getGuests().iterator().next(); - Long sid = host.getId(); - - String json = virtualGuestsController.shutdown( - getPostRequestWithCsrfAndBody("/manager/api/systems/details/virtualization/guests/:sid/shutdown", - "{uuids: [\"" + guest.getUuid() + "\"]}", - sid), - response, user, host); - - // Make sure the shutdown action was queued - DataResult actions = ActionManager.pendingActions(user, null); - assertEquals(ActionFactory.TYPE_VIRTUALIZATION_SHUTDOWN.getName(), - actions.get(0).getTypeName()); - - Action action = ActionManager.lookupAction(user, actions.get(0).getId()); - VirtualizationShutdownGuestAction virtAction = (VirtualizationShutdownGuestAction)action; - assertEquals(guest.getUuid(), virtAction.getUuid()); - - // Check the response - Map model = GSON.fromJson(json, new TypeToken>() { }.getType()); - assertEquals(action.getId(), model.get(guest.getUuid())); - } - - - /** - * Test a VM vcpu change action - * - * @throws Exception if anything unexpected happens during the test - */ - @Test - public void testSetVcpuAction() throws Exception { - VirtualInstance guest = host.getGuests().iterator().next(); - Long sid = host.getId(); - - Integer vcpus = 3; - String json = virtualGuestsController.setVcpu( - getPostRequestWithCsrfAndBody("/manager/api/systems/details/virtualization/guests/:sid/:action", - "{uuids: [\"" + guest.getUuid() + "\"], value: " + vcpus + "}", - sid, "setVcpu"), - response, user, host); - - // Make sure the setVpu action was queued - DataResult actions = ActionManager.pendingActions(user, null); - assertEquals(ActionFactory.TYPE_VIRTUALIZATION_SET_VCPUS.getName(), - actions.get(0).getTypeName()); - - Action action = ActionManager.lookupAction(user, actions.get(0).getId()); - VirtualizationSetVcpusGuestAction virtAction = (VirtualizationSetVcpusGuestAction)action; - assertEquals(vcpus, virtAction.getVcpu()); - - // Check the response - Map model = GSON.fromJson(json, new TypeToken>() { }.getType()); - assertEquals(action.getId(), model.get(guest.getUuid())); - } - - /** - * Test a VM vcpu without value change action - * - * @throws Exception if anything unexpected happens during the test - */ - @Test - public void testSetVcpuInvalidAction() throws Exception { - VirtualInstance guest = host.getGuests().iterator().next(); - Long sid = host.getId(); - - try { - virtualGuestsController.setVcpu( - getPostRequestWithCsrfAndBody("/manager/api/systems/details/virtualization/guests/:sid/:action", - "{uuids: [\"" + guest.getUuid() + "\"]}", - sid, "setVcpu"), - response, user, host); - fail(); - } - catch (HaltException e) { - // Make sure the action was not queued - assertTrue(ActionManager.pendingActions(user, null).isEmpty()); - } - } - - /** - * Test a memory change on several VMs - * - * @throws Exception if anything unexpected happens during the test - */ - @Test - public void testSetMemMultiAction() throws Exception { - - VirtualInstance[] guests = host.getGuests().toArray(new VirtualInstance[host.getGuests().size()]); - Arrays.sort(guests, Comparator.comparing(VirtualInstance::getUuid)); - Long sid = host.getId(); - - Integer mem = 2048; - String json = virtualGuestsController.setMemory( - getPostRequestWithCsrfAndBody("/manager/api/systems/details/virtualization/guests/:sid/:action", - "{uuids: [\"" + guests[0].getUuid() + "\", " + - "\"" + guests[1].getUuid() + "\"], " + - "value: " + mem + "}", - sid, "setMemory"), - response, user, host); - - // Make sure the setVpu action was queued - DataResult scheduledActions = ActionManager.pendingActions(user, null); - ArrayList virtActions = new ArrayList<>(); - scheduledActions.stream().forEach(action -> virtActions.add( - (VirtualizationSetMemoryGuestAction)ActionManager.lookupAction(user, action.getId()))); - virtActions.sort(Comparator.comparing(BaseVirtualizationGuestAction::getUuid)); - - assertEquals(ActionFactory.TYPE_VIRTUALIZATION_SET_MEMORY.getName(), - scheduledActions.get(0).getTypeName()); - assertEquals(Integer.valueOf(mem), virtActions.get(0).getMemory()); - assertEquals(guests[0].getUuid(), virtActions.get(0).getUuid()); - - assertEquals(ActionFactory.TYPE_VIRTUALIZATION_SET_MEMORY.getName(), - scheduledActions.get(1).getTypeName()); - assertEquals(Integer.valueOf(mem), virtActions.get(1).getMemory()); - assertEquals(guests[1].getUuid(), virtActions.get(1).getUuid()); - - - // Check the response - Map model = GSON.fromJson(json, new TypeToken>() { }.getType()); - assertEquals(virtActions.get(0).getId(), model.get(guests[0].getUuid())); - assertEquals(virtActions.get(1).getId(), model.get(guests[1].getUuid())); - } - - /** - * Test the API querying the XML definition of a VM using salt. - * - */ - @Test - public void testGetGuest() { - String json = virtualGuestsController.getGuest( - getRequestWithCsrf("/manager/api/systems/details/virtualization/guests/:sid/guest/:uuid", - host.getId(), guid), - response, user, host); - GuestDefinition def = GSON.fromJson(json, new TypeToken() { }.getType()); - assertEquals(uuid, def.getUuid()); - assertEquals("sles12sp2", def.getName()); - assertEquals(1024 * 1024, def.getMaxMemory()); - assertEquals("spice", def.getGraphics().getType()); - assertEquals(5903, def.getGraphics().getPort()); - - assertEquals(1, def.getInterfaces().size()); - assertEquals("network", def.getInterfaces().get(0).getType()); - assertEquals("default", def.getInterfaces().get(0).getSource()); - - assertEquals(5, def.getDisks().size()); - assertEquals("file", def.getDisks().get(0).getType()); - assertEquals("disk", def.getDisks().get(0).getDevice()); - assertEquals("qcow2", def.getDisks().get(0).getFormat()); - assertEquals("vda", def.getDisks().get(0).getTarget()); - assertEquals("virtio", def.getDisks().get(0).getBus()); - assertEquals("/srv/vms/sles12sp2.qcow2", def.getDisks().get(0).getSource().get("file")); - - assertEquals("file", def.getDisks().get(1).getType()); - assertEquals("cdrom", def.getDisks().get(1).getDevice()); - assertEquals("raw", def.getDisks().get(1).getFormat()); - assertEquals("hda", def.getDisks().get(1).getTarget()); - assertEquals("ide", def.getDisks().get(1).getBus()); - assertNull(def.getDisks().get(1).getSource()); - - assertEquals("volume", def.getDisks().get(2).getType()); - assertEquals("disk", def.getDisks().get(2).getDevice()); - assertEquals("raw", def.getDisks().get(2).getFormat()); - assertEquals("vdb", def.getDisks().get(2).getTarget()); - assertEquals("virtio", def.getDisks().get(2).getBus()); - assertEquals("ses-pool", def.getDisks().get(2).getSource().get("pool")); - assertEquals("test-vol", def.getDisks().get(2).getSource().get("volume")); - - assertEquals("volume", def.getDisks().get(3).getType()); - assertEquals("disk", def.getDisks().get(3).getDevice()); - assertEquals("raw", def.getDisks().get(3).getFormat()); - assertEquals("vdc", def.getDisks().get(3).getTarget()); - assertEquals("virtio", def.getDisks().get(3).getBus()); - assertEquals("iscsi-pool", def.getDisks().get(3).getSource().get("pool")); - assertEquals("unit:0:0:1", def.getDisks().get(3).getSource().get("volume")); - - assertEquals("block", def.getDisks().get(4).getType()); - assertEquals("disk", def.getDisks().get(4).getDevice()); - assertEquals("raw", def.getDisks().get(4).getFormat()); - assertEquals("vdd", def.getDisks().get(4).getTarget()); - assertEquals("virtio", def.getDisks().get(4).getBus()); - assertEquals("/dev/disk/by-path/pci-0000:00:0b.0-scsi-0:0:0:0", - def.getDisks().get(4).getSource().get("dev")); - } - - /** - * Test the API querying the domains capabilities of a virtual host using salt. - * - */ - @Test - public void testGetDomainsCapabilities() { - Map placeholders = new HashMap<>(); - placeholders.put("[\"ide\", \"fdc\", \"scsi\", \"virtio\", \"usb\"]", "[\"ide\", \"fdc\", \"scsi\", \"usb\"]"); - - String json = virtualGuestsController.getDomainsCapabilities( - getRequestWithCsrf("/manager/api/systems/details/virtualization/guests/:sid/domains_capabilities", - host.getId()), response, user, host); - - DomainsCapsJson caps = GSON.fromJson(json, new TypeToken() { }.getType()); - assertTrue(caps.getOsTypes().contains("hvm")); - assertEquals("i686", caps.getDomainsCaps().get(0).getArch()); - - assertEquals("kvm", caps.getDomainsCaps().get(0).getDomain()); - assertTrue(caps.getDomainsCaps().get(0).getDevices().get("disk").get("bus").contains("virtio")); - assertFalse(caps.getDomainsCaps().get(1).getDevices().get("disk").get("bus").contains("virtio")); - } - - @Test - public void testShow() { - ModelAndView page = virtualGuestsController.show( - getRequestWithCsrf("/manager/systems/details/virtualization/guests/:sid", - host.getId()), response, user, host); - Map model = (Map) page.getModel(); - assertEquals("{\"hypervisor\":\"kvm\",\"cluster_other_nodes\":[]}", model.get("hostInfo")); - } - - @Test - public void testShowVHM() throws Exception { - Server vhmHost = ServerTestUtils.createForeignSystem(user, "server_digital_id"); - ModelAndView page = virtualGuestsController.show( - getRequestWithCsrf("/manager/systems/details/virtualization/guests/:sid", - vhmHost.getId()), response, user, vhmHost); - Map model = (Map) page.getModel(); - assertEquals("{}", model.get("hostInfo")); - } - - /** - * Represents the output of VirtualGuestsController.getDomainsCapabilities. - * There is no need to share this structure since these data will only be used from Javascript. - */ - private class DomainsCapsJson { - private List osTypes; - private List domainsCaps; - - public List getOsTypes() { - return osTypes; - } - - public void setOsTypes(List osTypesIn) { - osTypes = osTypesIn; - } - - public List getDomainsCaps() { - return domainsCaps; - } - - public void setDomainsCaps(List domainsCapsIn) { - domainsCaps = domainsCapsIn; - } - } -} diff --git a/java/code/src/com/suse/manager/webui/controllers/virtualization/test/VirtualNetsControllerTest.java b/java/code/src/com/suse/manager/webui/controllers/virtualization/test/VirtualNetsControllerTest.java deleted file mode 100644 index 45f979fa5309..000000000000 --- a/java/code/src/com/suse/manager/webui/controllers/virtualization/test/VirtualNetsControllerTest.java +++ /dev/null @@ -1,314 +0,0 @@ -/* - * Copyright (c) 2018 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.suse.manager.webui.controllers.virtualization.test; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import com.redhat.rhn.common.db.datasource.DataResult; -import com.redhat.rhn.domain.action.Action; -import com.redhat.rhn.domain.action.ActionFactory; -import com.redhat.rhn.domain.action.virtualization.VirtualizationNetworkCreateAction; -import com.redhat.rhn.domain.action.virtualization.VirtualizationNetworkStateChangeAction; -import com.redhat.rhn.domain.server.MinionServer; -import com.redhat.rhn.domain.server.Server; -import com.redhat.rhn.frontend.context.Context; -import com.redhat.rhn.frontend.dto.ScheduledAction; -import com.redhat.rhn.manager.action.ActionManager; -import com.redhat.rhn.manager.formula.FormulaMonitoringManager; -import com.redhat.rhn.manager.system.ServerGroupManager; -import com.redhat.rhn.manager.system.entitling.SystemEntitlementManager; -import com.redhat.rhn.manager.system.entitling.SystemEntitler; -import com.redhat.rhn.manager.system.entitling.SystemUnentitler; -import com.redhat.rhn.taskomatic.TaskomaticApi; -import com.redhat.rhn.testing.ServerTestUtils; - -import com.suse.manager.reactor.messaging.test.SaltTestUtils; -import com.suse.manager.virtualization.NetworkDefinition; -import com.suse.manager.virtualization.VirtualizationActionHelper; -import com.suse.manager.virtualization.test.TestVirtManager; -import com.suse.manager.webui.controllers.test.BaseControllerTestCase; -import com.suse.manager.webui.controllers.virtualization.VirtualNetsController; -import com.suse.manager.webui.controllers.virtualization.gson.VirtualNetworkInfoJson; -import com.suse.manager.webui.services.iface.MonitoringManager; -import com.suse.manager.webui.services.iface.SaltApi; -import com.suse.manager.webui.services.iface.VirtManager; -import com.suse.manager.webui.services.test.TestSaltApi; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonObject; -import com.google.gson.reflect.TypeToken; - -import org.hamcrest.collection.IsMapContaining; -import org.jmock.Expectations; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.TimeZone; - -public class VirtualNetsControllerTest extends BaseControllerTestCase { - - private TaskomaticApi taskomaticMock; - private VirtManager virtManager; - private Server host; - private static final Gson GSON = new GsonBuilder().create(); - - /** - * {@inheritDoc} - */ - @Override - @BeforeEach - public void setUp() throws Exception { - super.setUp(); - - taskomaticMock = mock(TaskomaticApi.class); - ActionManager.setTaskomaticApi(taskomaticMock); - VirtualizationActionHelper.setTaskomaticApi(taskomaticMock); - context().checking(new Expectations() {{ - ignoring(taskomaticMock).scheduleActionExecution(with(any(Action.class))); - }}); - - virtManager = new TestVirtManager() { - @Override - public void updateLibvirtEngine(MinionServer minion) { - } - - @Override - public Map getNetworks(String minionId) { - return SaltTestUtils.getSaltResponse( - "/com/suse/manager/webui/controllers/virtualization/test/virt.net.info.json", - null, - new TypeToken>() { }) - .orElse(Collections.emptyMap()); - } - - @Override - public List getHostDevices(String minionId) { - return SaltTestUtils.getSaltResponse( - "/com/suse/manager/webui/controllers/virtualization/test/virt.node_devices.json", - null, - new TypeToken>() { }) - .orElse(Collections.emptyList()); - } - }; - - SaltApi saltApi = new TestSaltApi(); - MonitoringManager monitoringManager = new FormulaMonitoringManager(saltApi); - ServerGroupManager serverGroupManager = new ServerGroupManager(saltApi); - SystemEntitlementManager systemEntitlementManager = new SystemEntitlementManager( - new SystemUnentitler(virtManager, monitoringManager, serverGroupManager), - new SystemEntitler(new TestSaltApi(), virtManager, monitoringManager, serverGroupManager) - ); - - host = ServerTestUtils.createVirtHostWithGuests(user, 1, true, systemEntitlementManager); - host.asMinionServer().get().setMinionId("testminion.local"); - - Context.getCurrentContext().setTimezone(TimeZone.getTimeZone("Europe/Paris")); - } - - @Test - public void testData() { - VirtualNetsController virtualNetsController = new VirtualNetsController(virtManager); - String json = virtualNetsController.data(getRequestWithCsrf( - "/manager/api/systems/details/virtualization/nets/:sid/data", host.getId()), response, user, host); - - List nets = GSON.fromJson( - json, new TypeToken>() { }.getType()); - assertTrue(nets.stream().filter(net -> net.getName().equals("net0")).findFirst().isPresent()); - VirtualNetworkInfoJson net1 = nets.stream().filter(net -> net.getName().equals("net1")).findFirst().get(); - assertEquals("virbr0", net1.getBridge()); - assertFalse(net1.isActive()); - assertFalse(net1.isAutostart()); - assertTrue(net1.isPersistent()); - assertEquals("860e49a3-d227-4105-95ca-d19dc8f0c8b6", net1.getUuid()); - - VirtualNetworkInfoJson net0 = nets.stream().filter(net -> net.getName().equals("net0")).findFirst().get(); - assertNull(net0.getBridge()); - } - - @Test - public void testDevices() { - VirtualNetsController virtualNetsController = new VirtualNetsController(virtManager); - String json = virtualNetsController.devices(getRequestWithCsrf( - "/manager/api/systems/details/virtualization/nets/:sid/devices", host.getId()), response, user, host); - - List devs = GSON.fromJson(json, new TypeToken>() { }.getType()); - - // Physical function device - JsonObject eth0 = devs.stream().filter(dev -> dev.get("name").getAsString().equals("eth0")).findFirst().get(); - assertTrue(eth0.get("PF").getAsBoolean()); - assertFalse(eth0.get("VF").getAsBoolean()); - - // Non SR-IOV device (can be a device where SR-IOV is not enabled from the host side) - JsonObject eth1 = devs.stream().filter(dev -> dev.get("name").getAsString().equals("eth1")).findFirst().get(); - assertFalse(eth1.get("PF").getAsBoolean()); - assertFalse(eth1.get("VF").getAsBoolean()); - - // Virtual function device - JsonObject eth4 = devs.stream().filter(dev -> dev.get("name").getAsString().equals("eth4")).findFirst().get(); - assertFalse(eth4.get("PF").getAsBoolean()); - assertTrue(eth4.get("VF").getAsBoolean()); - assertEquals("42:8a:c6:98:8d:00", eth4.get("address").getAsString()); - assertEquals("0000:3d:02.6", eth4.get("PCI address").getAsString()); - assertEquals("down", eth4.get("state").getAsString()); - } - - @Test - public void testStart() throws Exception { - VirtualNetsController virtualNetsController = new VirtualNetsController(virtManager); - String json = virtualNetsController.start( - getPostRequestWithCsrfAndBody("/manager/api/systems/details/virtualization/nets/:sid/start", - "{names: [\"net0\"]}", - host.getId()), - response, user, host); - - // Ensure the start action is queued - DataResult actions = ActionManager.pendingActions(user, null); - assertEquals(1, actions.size()); - assertEquals(ActionFactory.TYPE_VIRTUALIZATION_NETWORK_STATE_CHANGE.getName(), actions.get(0).getTypeName()); - - Action action = ActionManager.lookupAction(user, actions.get(0).getId()); - VirtualizationNetworkStateChangeAction virtAction = (VirtualizationNetworkStateChangeAction) action; - assertEquals("net0", virtAction.getNetworkName()); - assertEquals("start", virtAction.getState()); - - // Check the returned message - Map model = GSON.fromJson(json, new TypeToken>() { }.getType()); - assertTrue(IsMapContaining.hasEntry("net0", action.getId()).matches(model)); - } - - @Test - public void testStop() throws Exception { - VirtualNetsController virtualNetsController = new VirtualNetsController(virtManager); - String json = virtualNetsController.stop( - getPostRequestWithCsrfAndBody("/manager/api/systems/details/virtualization/nets/:sid/stop", - "{names: [\"net0\"]}", - host.getId()), - response, user, host); - - // Ensure the stop action is queued - DataResult actions = ActionManager.pendingActions(user, null); - assertEquals(1, actions.size()); - assertEquals(ActionFactory.TYPE_VIRTUALIZATION_NETWORK_STATE_CHANGE.getName(), actions.get(0).getTypeName()); - - Action action = ActionManager.lookupAction(user, actions.get(0).getId()); - VirtualizationNetworkStateChangeAction virtAction = (VirtualizationNetworkStateChangeAction) action; - assertEquals("net0", virtAction.getNetworkName()); - assertEquals("stop", virtAction.getState()); - - // Check the returned message - Map model = GSON.fromJson(json, new TypeToken>() { }.getType()); - assertTrue(IsMapContaining.hasEntry("net0", action.getId()).matches(model)); - } - - @Test - public void testDelete() throws Exception { - VirtualNetsController virtualNetsController = new VirtualNetsController(virtManager); - String json = virtualNetsController.delete( - getPostRequestWithCsrfAndBody("/manager/api/systems/details/virtualization/nets/:sid/delete", - "{names: [\"net0\"]}", - host.getId()), - response, user, host); - - // Ensure the stop action is queued - DataResult actions = ActionManager.pendingActions(user, null); - assertEquals(1, actions.size()); - assertEquals(ActionFactory.TYPE_VIRTUALIZATION_NETWORK_STATE_CHANGE.getName(), actions.get(0).getTypeName()); - - Action action = ActionManager.lookupAction(user, actions.get(0).getId()); - VirtualizationNetworkStateChangeAction virtAction = (VirtualizationNetworkStateChangeAction) action; - assertEquals("net0", virtAction.getNetworkName()); - assertEquals("delete", virtAction.getState()); - - // Check the returned message - Map model = GSON.fromJson(json, new TypeToken>() { }.getType()); - assertTrue(IsMapContaining.hasEntry("net0", action.getId()).matches(model)); - } - - @Test - public void testCreate() throws Exception { - VirtualNetsController virtualNetsController = new VirtualNetsController(virtManager); - String json = virtualNetsController.create( - getPostRequestWithCsrfAndBody("/manager/api/systems/details/virtualization/nets/:sid/create", - "{names: ['net0'], definition: {type: 'bridge', autostart: true, bridge: 'ovs0', " + - "virtualport: {type: 'openvswitch', interfaceid: 'thevportuuid'}, " + - "vlans:[{tag: 41}]}, earliest: '2021-02-17T10:09:00.000Z'}", - host.getId()), - response, user, host); - - // Ensure the stop action is queued - DataResult actions = ActionManager.pendingActions(user, null); - assertEquals(1, actions.size()); - assertEquals(ActionFactory.TYPE_VIRTUALIZATION_NETWORK_CREATE.getName(), actions.get(0).getTypeName()); - - Action action = ActionManager.lookupAction(user, actions.get(0).getId()); - VirtualizationNetworkCreateAction virtAction = (VirtualizationNetworkCreateAction) action; - assertEquals("net0", virtAction.getNetworkName()); - NetworkDefinition def = virtAction.getDefinition(); - assertEquals("bridge", def.getForwardMode()); - assertEquals(Optional.of("ovs0"), def.getBridge()); - assertTrue(def.isAutostart()); - assertEquals("openvswitch", def.getVirtualPort().get().getType()); - assertEquals(Optional.of("thevportuuid"), def.getVirtualPort().get().getInterfaceId()); - assertEquals(41, def.getVlans().get(0).getTag()); - - // Check the returned message - Map model = GSON.fromJson(json, new TypeToken>() { }.getType()); - assertTrue(IsMapContaining.hasEntry("net0", action.getId()).matches(model)); - } - - @Test - public void testCreateNat() throws Exception { - VirtualNetsController virtualNetsController = new VirtualNetsController(virtManager); - String json = virtualNetsController.create( - getPostRequestWithCsrfAndBody("/manager/api/systems/details/virtualization/nets/:sid/create", - "{names: ['net0'], definition: {type: 'nat', autostart: false, " + - "nat: {address: {start: '192.168.10.3', end: '192.168.10.4'}, " + - "port: {start: '1234', end: '1235'}}, ipv4: {address: '192.168.10.0', prefix: 24}}, " + - "earliest: '2021-02-17T10:09:00.000Z'}", - host.getId()), - response, user, host); - - // Ensure the stop action is queued - DataResult actions = ActionManager.pendingActions(user, null); - assertEquals(1, actions.size()); - assertEquals(ActionFactory.TYPE_VIRTUALIZATION_NETWORK_CREATE.getName(), actions.get(0).getTypeName()); - - Action action = ActionManager.lookupAction(user, actions.get(0).getId()); - VirtualizationNetworkCreateAction virtAction = (VirtualizationNetworkCreateAction) action; - assertEquals("net0", virtAction.getNetworkName()); - NetworkDefinition def = virtAction.getDefinition(); - assertEquals("nat", def.getForwardMode()); - assertEquals(Optional.empty(), def.getBridge()); - assertFalse(def.isAutostart()); - assertEquals("192.168.10.3", def.getNat().orElseThrow().getAddress().orElseThrow().getStart()); - assertEquals("192.168.10.4", def.getNat().orElseThrow().getAddress().orElseThrow().getEnd()); - assertEquals(Integer.valueOf(1234), def.getNat().get().getPort().orElseThrow().getStart()); - assertEquals(Integer.valueOf(1235), def.getNat().get().getPort().orElseThrow().getEnd()); - assertEquals("192.168.10.0", def.getIpv4().orElseThrow().getAddress()); - assertEquals(Integer.valueOf(24), def.getIpv4().orElseThrow().getPrefix()); - - // Check the returned message - Map model = GSON.fromJson(json, new TypeToken>() { }.getType()); - assertTrue(IsMapContaining.hasEntry("net0", action.getId()).matches(model)); - } -} diff --git a/java/code/src/com/suse/manager/webui/controllers/virtualization/test/VirtualPoolsControllerTest.java b/java/code/src/com/suse/manager/webui/controllers/virtualization/test/VirtualPoolsControllerTest.java deleted file mode 100644 index 3fb52228dad0..000000000000 --- a/java/code/src/com/suse/manager/webui/controllers/virtualization/test/VirtualPoolsControllerTest.java +++ /dev/null @@ -1,320 +0,0 @@ -/* - * Copyright (c) 2018 SUSE LLC - * - * This software is licensed to you under the GNU General Public License, - * version 2 (GPLv2). There is NO WARRANTY for this software, express or - * implied, including the implied warranties of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 - * along with this software; if not, see - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * Red Hat trademarks are not licensed under GPLv2. No permission is - * granted to use or replicate Red Hat trademarks that are incorporated - * in this software or its documentation. - */ -package com.suse.manager.webui.controllers.virtualization.test; - -import static org.hamcrest.collection.IsIterableContainingInAnyOrder.containsInAnyOrder; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import com.redhat.rhn.common.db.datasource.DataResult; -import com.redhat.rhn.domain.action.Action; -import com.redhat.rhn.domain.action.ActionFactory; -import com.redhat.rhn.domain.action.virtualization.BaseVirtualizationVolumeAction; -import com.redhat.rhn.domain.action.virtualization.VirtualizationPoolDeleteAction; -import com.redhat.rhn.domain.action.virtualization.VirtualizationPoolRefreshAction; -import com.redhat.rhn.domain.action.virtualization.VirtualizationPoolStartAction; -import com.redhat.rhn.domain.action.virtualization.VirtualizationPoolStopAction; -import com.redhat.rhn.domain.server.MinionServer; -import com.redhat.rhn.domain.server.Server; -import com.redhat.rhn.frontend.context.Context; -import com.redhat.rhn.frontend.dto.ScheduledAction; -import com.redhat.rhn.manager.action.ActionManager; -import com.redhat.rhn.manager.formula.FormulaMonitoringManager; -import com.redhat.rhn.manager.system.ServerGroupManager; -import com.redhat.rhn.manager.system.entitling.SystemEntitlementManager; -import com.redhat.rhn.manager.system.entitling.SystemEntitler; -import com.redhat.rhn.manager.system.entitling.SystemUnentitler; -import com.redhat.rhn.taskomatic.TaskomaticApi; -import com.redhat.rhn.testing.ServerTestUtils; - -import com.suse.manager.reactor.messaging.test.SaltTestUtils; -import com.suse.manager.virtualization.PoolCapabilitiesJson; -import com.suse.manager.virtualization.PoolCapabilitiesJson.PoolType; -import com.suse.manager.virtualization.VirtualizationActionHelper; -import com.suse.manager.virtualization.test.TestVirtManager; -import com.suse.manager.webui.controllers.test.BaseControllerTestCase; -import com.suse.manager.webui.controllers.virtualization.VirtualPoolsController; -import com.suse.manager.webui.controllers.virtualization.gson.VirtualStoragePoolInfoJson; -import com.suse.manager.webui.services.iface.MonitoringManager; -import com.suse.manager.webui.services.iface.SaltApi; -import com.suse.manager.webui.services.iface.VirtManager; -import com.suse.manager.webui.services.test.TestSaltApi; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonObject; -import com.google.gson.reflect.TypeToken; - -import org.hamcrest.collection.IsMapContaining; -import org.jmock.Expectations; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.TimeZone; -import java.util.stream.Collectors; - - -public class VirtualPoolsControllerTest extends BaseControllerTestCase { - - private TaskomaticApi taskomaticMock; - private Server host; - private static final Gson GSON = new GsonBuilder().create(); - private VirtManager virtManager; - private SystemEntitlementManager systemEntitlementManager; - - /** - * {@inheritDoc} - */ - @Override - @BeforeEach - public void setUp() throws Exception { - super.setUp(); - - taskomaticMock = mock(TaskomaticApi.class); - ActionManager.setTaskomaticApi(taskomaticMock); - VirtualizationActionHelper.setTaskomaticApi(taskomaticMock); - context().checking(new Expectations() {{ - ignoring(taskomaticMock).scheduleActionExecution(with(any(Action.class))); - }}); - - virtManager = new TestVirtManager() { - - @Override - public void updateLibvirtEngine(MinionServer minion) { - } - - @Override - public Map getPools(String minionId) { - return SaltTestUtils.getSaltResponse( - "/com/suse/manager/webui/controllers/virtualization/test/virt.pool.info.json", - null, - new TypeToken>() { }).get(); - } - - @Override - public Map> getVolumes(String minionId) { - return SaltTestUtils.getSaltResponse( - "/com/suse/manager/webui/controllers/virtualization/test/virt.volume.info.json", - null, - new TypeToken>>() { }).get(); - } - - @Override - public Optional getPoolCapabilities(String minionId) { - return SaltTestUtils.getSaltResponse( - "/com/suse/manager/webui/controllers/virtualization/test/virt.pool.caps.json", - null, - new TypeToken<>() { - }); - } - }; - SaltApi saltApi = new TestSaltApi(); - MonitoringManager monitoringManager = new FormulaMonitoringManager(saltApi); - ServerGroupManager serverGroupManager = new ServerGroupManager(saltApi); - systemEntitlementManager = new SystemEntitlementManager( - new SystemUnentitler(virtManager, monitoringManager, serverGroupManager), - new SystemEntitler(saltApi, virtManager, monitoringManager, serverGroupManager) - ); - - host = ServerTestUtils.createVirtHostWithGuests(user, 1, true, systemEntitlementManager); - Context.getCurrentContext().setTimezone(TimeZone.getTimeZone("Europe/Paris")); - } - - @Test - public void testData() { - VirtualPoolsController virtualPoolsController = new VirtualPoolsController(virtManager); - String json = virtualPoolsController.data(getRequestWithCsrf( - "/manager/api/systems/details/virtualization/pools/:sid/data", host.getId()), response, user, host); - - List pools = GSON.fromJson( - json, new TypeToken>() { }.getType()); - VirtualStoragePoolInfoJson pool0 = pools.stream() - .filter(pool -> pool.getName().equals("pool0")).findFirst().get(); - assertNull(pool0.getTargetPath()); - VirtualStoragePoolInfoJson pool1 = pools.stream() - .filter(pool -> pool.getName().equals("pool1")).findFirst().get(); - assertFalse(pool1.isAutostart()); - assertTrue(pool1.isPersistent()); - assertEquals("808befba-85b1-40d6-83dc-d248850962e4", pool1.getUuid()); - assertEquals("running", pool1.getState()); - assertEquals("dir", pool1.getType()); - assertEquals("/path/to/pool1", pool1.getTargetPath()); - assertEquals(Long.valueOf(14412120064L), pool1.getAllocation()); - assertEquals(Long.valueOf(21003628544L), pool1.getCapacity()); - assertEquals(Long.valueOf(6591508480L), pool1.getFree()); - } - - @Test - public void testGetCapabilities() { - VirtualPoolsController virtualPoolsController = new VirtualPoolsController(virtManager); - String json = virtualPoolsController.getCapabilities(getRequestWithCsrf( - "/manager/api/systems/details/virtualization/pools/:sid/capabilities", - host.getId()), response, user, host); - PoolCapabilitiesJson caps = GSON.fromJson(json, new TypeToken() { }.getType()); - assertTrue(caps.isComputed()); - PoolType pType = caps.getPoolTypes().stream().filter(type -> type.getName().equals("fs")).findFirst().get(); - assertTrue(pType.isSupported()); - assertEquals("auto", pType.getOptions().getPool().getDefaultFormat()); - assertTrue(pType.getOptions().getPool().getSourceFormatType().contains("iso9660")); - assertEquals("raw", pType.getOptions().getVolume().getDefaultFormat()); - assertTrue(pType.getOptions().getVolume().getTargetFormatType().contains("cloop")); - } - - @Test - public void testRefresh() throws Exception { - VirtualPoolsController virtualPoolsController = new VirtualPoolsController(virtManager); - String json = virtualPoolsController.poolRefresh( - getPostRequestWithCsrfAndBody("/manager/api/systems/details/virtualization/pools/:sid/refresh", - "{poolNames: [\"pool0\", \"pool1\"]}", - host.getId()), - response, user, host); - - // Ensure the two refresh actions are queued - DataResult actions = ActionManager.pendingActions(user, null); - assertEquals(2, actions.size()); - assertTrue(actions.stream().allMatch(action -> action.getTypeName().equals( - ActionFactory.TYPE_VIRTUALIZATION_POOL_REFRESH.getName()))); - - List actionsPools = actions.stream().map(scheduled -> { - Action action = ActionManager.lookupAction(user, scheduled.getId()); - VirtualizationPoolRefreshAction virtAction = (VirtualizationPoolRefreshAction)action; - return virtAction.getPoolName(); - }).collect(Collectors.toList()); - assertTrue(containsInAnyOrder("pool0", "pool1").matches(actionsPools)); - - // Check the returned message - Map actionsIds = actions.stream().collect(Collectors.toMap( - scheduled -> { - Action action = ActionManager.lookupAction(user, scheduled.getId()); - VirtualizationPoolRefreshAction virtAction = (VirtualizationPoolRefreshAction)action; - return virtAction.getPoolName(); - }, - ScheduledAction::getId)); - Map model = GSON.fromJson(json, new TypeToken>() { }.getType()); - assertTrue(IsMapContaining.hasEntry("pool0", actionsIds.get("pool0")).matches(model)); - assertTrue(IsMapContaining.hasEntry("pool1", actionsIds.get("pool1")).matches(model)); - } - - @Test - public void testStart() throws Exception { - VirtualPoolsController virtualPoolsController = new VirtualPoolsController(virtManager); - String json = virtualPoolsController.poolStart( - getPostRequestWithCsrfAndBody("/manager/api/systems/details/virtualization/pools/:sid/start", - "{poolNames: [\"pool0\"]}", - host.getId()), - response, user, host); - - // Ensure the start action is queued - DataResult actions = ActionManager.pendingActions(user, null); - assertEquals(1, actions.size()); - assertEquals(ActionFactory.TYPE_VIRTUALIZATION_POOL_START.getName(), actions.get(0).getTypeName()); - - Action action = ActionManager.lookupAction(user, actions.get(0).getId()); - VirtualizationPoolStartAction virtAction = (VirtualizationPoolStartAction)action; - assertEquals("pool0", virtAction.getPoolName()); - - // Check the returned message - Map model = GSON.fromJson(json, new TypeToken>() { }.getType()); - assertTrue(IsMapContaining.hasEntry("pool0", action.getId()).matches(model)); - } - - @Test - public void testStop() throws Exception { - VirtualPoolsController virtualPoolsController = new VirtualPoolsController(virtManager); - String json = virtualPoolsController.poolStop( - getPostRequestWithCsrfAndBody("/manager/api/systems/details/virtualization/pools/:sid/stop", - "{poolNames: [\"pool0\"]}", - host.getId()), - response, user, host); - - // Ensure the start action is queued - DataResult actions = ActionManager.pendingActions(user, null); - assertEquals(1, actions.size()); - assertEquals(ActionFactory.TYPE_VIRTUALIZATION_POOL_STOP.getName(), actions.get(0).getTypeName()); - - Action action = ActionManager.lookupAction(user, actions.get(0).getId()); - VirtualizationPoolStopAction virtAction = (VirtualizationPoolStopAction)action; - assertEquals("pool0", virtAction.getPoolName()); - - // Check the returned message - Map model = GSON.fromJson(json, new TypeToken>() { }.getType()); - assertTrue(IsMapContaining.hasEntry("pool0", action.getId()).matches(model)); - } - - @Test - public void testDelete() throws Exception { - VirtualPoolsController virtualPoolsController = new VirtualPoolsController(virtManager); - String json = virtualPoolsController.poolDelete( - getPostRequestWithCsrfAndBody("/manager/api/systems/details/virtualization/pools/:sid/delete", - "{poolNames: [\"pool0\"], purge: true}", - host.getId()), - response, user, host); - - // Ensure the start action is queued - DataResult actions = ActionManager.pendingActions(user, null); - assertEquals(1, actions.size()); - assertEquals(ActionFactory.TYPE_VIRTUALIZATION_POOL_DELETE.getName(), actions.get(0).getTypeName()); - - Action action = ActionManager.lookupAction(user, actions.get(0).getId()); - VirtualizationPoolDeleteAction virtAction = (VirtualizationPoolDeleteAction)action; - assertEquals("pool0", virtAction.getPoolName()); - assertTrue(virtAction.isPurge()); - - // Check the returned message - Map model = GSON.fromJson(json, new TypeToken>() { }.getType()); - assertTrue(IsMapContaining.hasEntry("pool0", action.getId()).matches(model)); - } - - @Test - public void testVolumeDelete() throws Exception { - VirtualPoolsController virtualPoolsController = new VirtualPoolsController(virtManager); - String json = virtualPoolsController.volumeDelete( - getPostRequestWithCsrfAndBody("/manager/api/systems/details/virtualization/volumes/:sid/delete", - "{volumes: {\"pool0\": [\"vol0\", \"vol1\"], \"pool1\": [\"vol2\"]}}", - host.getId()), - response, user, host); - - // Ensure the start action is queued - List actions = ActionManager.pendingActions(user, null).stream() - .filter(action -> ActionFactory.TYPE_VIRTUALIZATION_VOLUME_DELETE.getName().equals(action.getTypeName())) - .map(action -> (BaseVirtualizationVolumeAction)ActionManager.lookupAction(user, action.getId())) - .collect(Collectors.toList()); - - assertEquals(3, actions.size()); - Optional vol0 = actions.stream() - .filter(action -> "pool0".equals(action.getPoolName()) && "vol0".equals(action.getVolumeName())) - .findFirst(); - assertTrue(vol0.isPresent()); - - Optional vol1 = actions.stream() - .filter(action -> "pool0".equals(action.getPoolName()) && "vol1".equals(action.getVolumeName())) - .findFirst(); - assertTrue(vol1.isPresent()); - - Optional vol2 = actions.stream() - .filter(action -> "pool1".equals(action.getPoolName()) && "vol2".equals(action.getVolumeName())) - .findFirst(); - assertTrue(vol2.isPresent()); - - // Check the returned message - Map model = GSON.fromJson(json, new TypeToken>() { }.getType()); - assertTrue(IsMapContaining.hasEntry("pool0/vol1", vol1.get().getId()).matches(model)); - } -} diff --git a/java/code/src/com/suse/manager/webui/controllers/virtualization/test/virt.guest.allcaps.json b/java/code/src/com/suse/manager/webui/controllers/virtualization/test/virt.guest.allcaps.json deleted file mode 100644 index df548b1b7923..000000000000 --- a/java/code/src/com/suse/manager/webui/controllers/virtualization/test/virt.guest.allcaps.json +++ /dev/null @@ -1,837 +0,0 @@ -{ - "domains": [ - { - "domain": "kvm", - "os": { - "loader": { - "readonly": [ - "yes", - "no" - ], - "type": [ - "rom", - "pflash" - ] - } - }, - "devices": { - "disk": { - "bus": [ - "ide", - "fdc", - "scsi", - "virtio", - "usb" - ], - "diskDevice": [ - "disk", - "cdrom", - "floppy", - "lun" - ] - } - }, - "machine": "pc-i440fx-2.6", - "max_vcpus": 255, - "emulator": "/usr/bin/qemu-system-i386", - "arch": "i686" - }, - { - "domain": "qemu", - "os": { - "loader": { - "readonly": [ - "yes", - "no" - ], - "type": [ - "rom", - "pflash" - ] - } - }, - "devices": { - "disk": { - "bus": [ - "ide", - "fdc", - "scsi", - "usb" - ], - "diskDevice": [ - "disk", - "cdrom", - "floppy", - "lun" - ] - } - }, - "machine": "pc-i440fx-2.6", - "max_vcpus": 255, - "emulator": "/usr/bin/qemu-system-i386", - "arch": "i686" - }, - { - "domain": "kvm", - "os": { - "loader": { - "readonly": [ - "yes", - "no" - ], - "type": [ - "rom", - "pflash" - ] - } - }, - "devices": { - "disk": { - "bus": [ - "ide", - "fdc", - "scsi", - "virtio", - "usb" - ], - "diskDevice": [ - "disk", - "cdrom", - "floppy", - "lun" - ] - } - }, - "machine": "pc-i440fx-2.6", - "max_vcpus": 255, - "emulator": "/usr/bin/qemu-system-x86_64", - "arch": "x86_64" - }, - { - "domain": "qemu", - "os": { - "loader": { - "readonly": [ - "yes", - "no" - ], - "type": [ - "rom", - "pflash" - ] - } - }, - "devices": { - "disk": { - "bus": [ - "ide", - "fdc", - "scsi", - "virtio", - "usb" - ], - "diskDevice": [ - "disk", - "cdrom", - "floppy", - "lun" - ] - } - }, - "machine": "pc-i440fx-2.6", - "max_vcpus": 255, - "emulator": "/usr/bin/qemu-system-x86_64", - "arch": "x86_64" - } - ], - "host": { - "host": { - "power_management": [ - "suspend_mem", - "suspend_disk", - "suspend_hybrid" - ], - "uuid": "44454c4c-3400-105a-8033-b3c04f4b344a", - "migration": { - "live": true, - "transports": [ - "tcp", - "rdma" - ] - }, - "security": [ - { - "model": "apparmor", - "doi": "0", - "baselabels": [] - }, - { - "model": "dac", - "doi": "0", - "baselabels": [ - { - "type": "kvm", - "label": "+487:+486" - }, - { - "type": "qemu", - "label": "+487:+486" - } - ] - } - ], - "cpu": { - "vendor": "Intel", - "features": [ - "vme", - "ds", - "acpi", - "ss", - "ht", - "tm", - "pbe", - "dtes64", - "monitor", - "ds_cpl", - "vmx", - "est", - "tm2", - "xtpr", - "pdcm", - "dca", - "rdtscp", - "invtsc" - ], - "sockets": 1, - "threads": 2, - "microcode": "25", - "cores": 4, - "model": "Nehalem", - "arch": "x86_64", - "pages": [ - { - "size": "4 KiB" - }, - { - "size": "2048 KiB" - } - ] - }, - "topology": { - "cells": [ - { - "id": 0, - "distances": { - "0": 10 - }, - "memory": "12367120 KiB", - "pages": [ - { - "available": 3091780, - "size": "4 KiB" - }, - { - "available": 0, - "size": "2048 KiB" - } - ], - "cpus": [ - { - "core_id": 0, - "siblings": "0,4", - "socket_id": 0, - "id": 0 - }, - { - "core_id": 1, - "siblings": "1,5", - "socket_id": 0, - "id": 1 - }, - { - "core_id": 2, - "siblings": "2,6", - "socket_id": 0, - "id": 2 - }, - { - "core_id": 3, - "siblings": "3,7", - "socket_id": 0, - "id": 3 - }, - { - "core_id": 0, - "siblings": "0,4", - "socket_id": 0, - "id": 4 - }, - { - "core_id": 1, - "siblings": "1,5", - "socket_id": 0, - "id": 5 - }, - { - "core_id": 2, - "siblings": "2,6", - "socket_id": 0, - "id": 6 - }, - { - "core_id": 3, - "siblings": "3,7", - "socket_id": 0, - "id": 7 - } - ] - } - ] - } - }, - "guests": [ - { - "os_type": "hvm", - "arch": { - "domains": { - "kvm": { - "emulator": "/usr/bin/qemu-kvm", - "machines": { - "xenfv": { - "alternate_names": [], - "maxcpus": 128 - }, - "pc-q35-2.5": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-q35-2.6": { - "alternate_names": [ - "q35" - ], - "maxcpus": 255 - }, - "pc-1.1": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-1.0": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-1.3": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-1.2": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-q35-2.4": { - "alternate_names": [], - "maxcpus": 255 - }, - "xenpv": { - "alternate_names": [], - "maxcpus": 1 - }, - "isapc": { - "alternate_names": [], - "maxcpus": 1 - }, - "pc-i440fx-2.6": { - "alternate_names": [ - "pc" - ], - "maxcpus": 255 - }, - "pc-i440fx-2.5": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-i440fx-2.4": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-i440fx-2.3": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-i440fx-2.2": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-i440fx-2.1": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-i440fx-2.0": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-0.12": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-0.13": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-0.10": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-0.11": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-0.14": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-0.15": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-i440fx-1.4": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-i440fx-1.5": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-i440fx-1.6": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-i440fx-1.7": { - "alternate_names": [], - "maxcpus": 255 - } - } - }, - "qemu": { - "emulator": null, - "machines": {} - } - }, - "wordsize": 32, - "name": "i686", - "machines": { - "xenfv": { - "alternate_names": [], - "maxcpus": 128 - }, - "pc-q35-2.5": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-q35-2.6": { - "alternate_names": [ - "q35" - ], - "maxcpus": 255 - }, - "pc-1.1": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-1.0": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-1.3": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-1.2": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-q35-2.4": { - "alternate_names": [], - "maxcpus": 255 - }, - "xenpv": { - "alternate_names": [], - "maxcpus": 1 - }, - "isapc": { - "alternate_names": [], - "maxcpus": 1 - }, - "pc-i440fx-2.6": { - "alternate_names": [ - "pc" - ], - "maxcpus": 255 - }, - "pc-i440fx-2.5": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-i440fx-2.4": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-i440fx-2.3": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-i440fx-2.2": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-i440fx-2.1": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-i440fx-2.0": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-0.12": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-0.13": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-0.10": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-0.11": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-0.14": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-0.15": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-i440fx-1.4": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-i440fx-1.5": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-i440fx-1.6": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-i440fx-1.7": { - "alternate_names": [], - "maxcpus": 255 - } - }, - "emulator": "/usr/bin/qemu-system-i386" - }, - "features": { - "nonpae": { - "default": true, - "toggle": false - }, - "cpuselection": { - "default": true, - "toggle": false - }, - "disksnapshot": { - "default": true, - "toggle": false - }, - "deviceboot": { - "default": true, - "toggle": false - }, - "pae": { - "default": true, - "toggle": false - }, - "apic": { - "default": true, - "toggle": false - }, - "acpi": { - "default": true, - "toggle": true - } - } - }, - { - "os_type": "hvm", - "arch": { - "domains": { - "kvm": { - "emulator": "/usr/bin/qemu-kvm", - "machines": { - "xenfv": { - "alternate_names": [], - "maxcpus": 128 - }, - "pc-q35-2.5": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-q35-2.6": { - "alternate_names": [ - "q35" - ], - "maxcpus": 255 - }, - "pc-1.1": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-1.0": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-1.3": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-1.2": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-q35-2.4": { - "alternate_names": [], - "maxcpus": 255 - }, - "xenpv": { - "alternate_names": [], - "maxcpus": 1 - }, - "isapc": { - "alternate_names": [], - "maxcpus": 1 - }, - "pc-i440fx-2.6": { - "alternate_names": [ - "pc" - ], - "maxcpus": 255 - }, - "pc-i440fx-2.5": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-i440fx-2.4": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-i440fx-2.3": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-i440fx-2.2": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-i440fx-2.1": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-i440fx-2.0": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-0.12": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-0.13": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-0.10": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-0.11": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-0.14": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-0.15": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-i440fx-1.4": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-i440fx-1.5": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-i440fx-1.6": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-i440fx-1.7": { - "alternate_names": [], - "maxcpus": 255 - } - } - }, - "qemu": { - "emulator": null, - "machines": {} - } - }, - "wordsize": 64, - "name": "x86_64", - "machines": { - "xenfv": { - "alternate_names": [], - "maxcpus": 128 - }, - "pc-q35-2.5": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-q35-2.6": { - "alternate_names": [ - "q35" - ], - "maxcpus": 255 - }, - "pc-1.1": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-1.0": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-1.3": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-1.2": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-q35-2.4": { - "alternate_names": [], - "maxcpus": 255 - }, - "xenpv": { - "alternate_names": [], - "maxcpus": 1 - }, - "isapc": { - "alternate_names": [], - "maxcpus": 1 - }, - "pc-i440fx-2.6": { - "alternate_names": [ - "pc" - ], - "maxcpus": 255 - }, - "pc-i440fx-2.5": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-i440fx-2.4": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-i440fx-2.3": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-i440fx-2.2": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-i440fx-2.1": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-i440fx-2.0": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-0.12": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-0.13": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-0.10": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-0.11": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-0.14": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-0.15": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-i440fx-1.4": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-i440fx-1.5": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-i440fx-1.6": { - "alternate_names": [], - "maxcpus": 255 - }, - "pc-i440fx-1.7": { - "alternate_names": [], - "maxcpus": 255 - } - }, - "emulator": "/usr/bin/qemu-system-x86_64" - }, - "features": { - "cpuselection": { - "default": true, - "toggle": false - }, - "deviceboot": { - "default": true, - "toggle": false - }, - "disksnapshot": { - "default": true, - "toggle": false - }, - "acpi": { - "default": true, - "toggle": true - }, - "apic": { - "default": true, - "toggle": false - } - } - } - ] - } -} diff --git a/java/code/src/com/suse/manager/webui/controllers/virtualization/test/virt.net.info.json b/java/code/src/com/suse/manager/webui/controllers/virtualization/test/virt.net.info.json deleted file mode 100644 index 361fabd7047b..000000000000 --- a/java/code/src/com/suse/manager/webui/controllers/virtualization/test/virt.net.info.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "net0": { - "active": 1, - "autostart": 1, - "bridge": null, - "leases": [], - "persistent": 1, - "uuid": "6682ddbc-e02d-4a13-9c03-f4d4a4924f09" - }, - "net1": { - "active": 0, - "autostart": 0, - "bridge": "virbr0", - "leases": [], - "persistent": 1, - "uuid": "860e49a3-d227-4105-95ca-d19dc8f0c8b6" - } -} \ No newline at end of file diff --git a/java/code/src/com/suse/manager/webui/controllers/virtualization/test/virt.node_devices.json b/java/code/src/com/suse/manager/webui/controllers/virtualization/test/virt.node_devices.json deleted file mode 100644 index b1dff0330e07..000000000000 --- a/java/code/src/com/suse/manager/webui/controllers/virtualization/test/virt.node_devices.json +++ /dev/null @@ -1,3064 +0,0 @@ -[ - { - "caps": "pci", - "name": "pci_0000_85_08_6", - "vendor_id": "0x8086", - "product_id": "0x208d", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:85:08.6", - "PCI class": "0x088000" - }, - { - "caps": "net", - "name": "eth4", - "address": "42:8a:c6:98:8d:00", - "device name": "pci_0000_3d_02_6", - "state": "down" - }, - { - "caps": "pci", - "name": "pci_0000_85_10_1", - "vendor_id": "0x8086", - "product_id": "0x208e", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:85:10.1", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_ae_0c_3", - "vendor_id": "0x8086", - "product_id": "0x2043", - "vendor": "Intel Corporation", - "product": "Sky Lake-E Integrated Memory Controller", - "address": "0000:ae:0c.3", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_d7_05_4", - "vendor_id": "0x8086", - "product_id": "0x2036", - "vendor": "Intel Corporation", - "product": "Sky Lake-E IOxAPIC Configuration Registers", - "address": "0000:d7:05.4", - "PCI class": "0x080020" - }, - { - "caps": "pci", - "name": "pci_0000_80_05_2", - "vendor_id": "0x8086", - "product_id": "0x2025", - "vendor": "Intel Corporation", - "product": "Sky Lake-E RAS", - "address": "0000:80:05.2", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_00_05_2", - "vendor_id": "0x8086", - "product_id": "0x2025", - "vendor": "Intel Corporation", - "product": "Sky Lake-E RAS", - "address": "0000:00:05.2", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_85_0a_4", - "vendor_id": "0x8086", - "product_id": "0x208d", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:85:0a.4", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_ae_0c_6", - "vendor_id": "0x8086", - "product_id": "0x2046", - "vendor": "Intel Corporation", - "product": "Sky Lake-E LMS Channel 1", - "address": "0000:ae:0c.6", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_d7_16_0", - "vendor_id": "0x8086", - "product_id": "0x2018", - "vendor": "Intel Corporation", - "product": "Sky Lake-E M2PCI Registers", - "address": "0000:d7:16.0", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_3a_0b_1", - "vendor_id": "0x8086", - "product_id": "0x2049", - "vendor": "Intel Corporation", - "product": "Sky Lake-E LM Channel 2", - "address": "0000:3a:0b.1", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_86_00_0", - "vendor_id": "0x1077", - "product_id": "0x2432", - "vendor": "QLogic Corp.", - "product": "ISP2432-based 4Gb Fibre Channel to PCI Express HBA", - "address": "0000:86:00.0", - "PCI class": "0x0c0400" - }, - { - "caps": "pci", - "name": "pci_0000_85_10_6", - "vendor_id": "0x8086", - "product_id": "0x208e", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:85:10.6", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_80_08_0", - "vendor_id": "0x8086", - "product_id": "0x2014", - "vendor": "Intel Corporation", - "product": "Sky Lake-E Ubox Registers", - "address": "0000:80:08.0", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_d7_15_0", - "vendor_id": "0x8086", - "product_id": "0x2018", - "vendor": "Intel Corporation", - "product": "Sky Lake-E M2PCI Registers", - "address": "0000:d7:15.0", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_3d_02_5", - "vendor_id": "0x8086", - "product_id": "0x37cd", - "vendor": "Intel Corporation", - "product": "Ethernet Virtual Function 700 Series", - "address": "0000:3d:02.5", - "PCI class": "0x020000", - "physical function": "0000:3d:00.0" - }, - { - "caps": "pci", - "name": "pci_0000_00_11_5", - "vendor_id": "0x8086", - "product_id": "0xa1d2", - "vendor": "Intel Corporation", - "product": "C620 Series Chipset Family SSATA Controller [AHCI mode]", - "address": "0000:00:11.5", - "PCI class": "0x010601" - }, - { - "caps": "pci", - "name": "pci_0000_85_1d_2", - "vendor_id": "0x8086", - "product_id": "0x2056", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:85:1d.2", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_17_10_4", - "vendor_id": "0x8086", - "product_id": "0x208e", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:17:10.4", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_85_09_7", - "vendor_id": "0x8086", - "product_id": "0x208d", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:85:09.7", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_ae_0a_0", - "vendor_id": "0x8086", - "product_id": "0x2040", - "vendor": "Intel Corporation", - "product": "Sky Lake-E Integrated Memory Controller", - "address": "0000:ae:0a.0", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_85_0f_0", - "vendor_id": "0x8086", - "product_id": "0x208e", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:85:0f.0", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_80_04_4", - "vendor_id": "0x8086", - "product_id": "0x2021", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CBDMA Registers", - "address": "0000:80:04.4", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_85_0a_0", - "vendor_id": "0x8086", - "product_id": "0x208d", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:85:0a.0", - "PCI class": "0x088000" - }, - { - "caps": "net", - "name": "eth6", - "address": "76:fe:ce:4f:73:22", - "device name": "pci_0000_3d_02_4", - "state": "down" - }, - { - "caps": "pci", - "name": "pci_0000_3a_0d_1", - "vendor_id": "0x8086", - "product_id": "0x2049", - "vendor": "Intel Corporation", - "product": "Sky Lake-E LM Channel 2", - "address": "0000:3a:0d.1", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_d7_12_1", - "vendor_id": "0x8086", - "product_id": "0x204d", - "vendor": "Intel Corporation", - "product": "Sky Lake-E M3KTI Registers", - "address": "0000:d7:12.1", - "PCI class": "0x110100" - }, - { - "caps": "net", - "name": "eth5", - "address": "e2:58:67:95:a3:a3", - "device name": "pci_0000_3d_02_5", - "state": "down" - }, - { - "caps": "pci", - "name": "pci_0000_85_09_0", - "vendor_id": "0x8086", - "product_id": "0x208d", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:85:09.0", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_85_09_4", - "vendor_id": "0x8086", - "product_id": "0x208d", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:85:09.4", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_d7_0f_1", - "vendor_id": "0x8086", - "product_id": "0x2059", - "vendor": "Intel Corporation", - "product": "Sky Lake-E UPI Registers", - "address": "0000:d7:0f.1", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_85_08_5", - "vendor_id": "0x8086", - "product_id": "0x208d", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:85:08.5", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_85_0e_3", - "vendor_id": "0x8086", - "product_id": "0x208e", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:85:0e.3", - "PCI class": "0x088000" - }, - { - "caps": "net", - "name": "eth0", - "address": "a4:bf:01:1d:27:88", - "device name": "pci_0000_3d_00_0", - "state": "up" - }, - { - "caps": "pci", - "name": "pci_0000_17_10_3", - "vendor_id": "0x8086", - "product_id": "0x208e", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:17:10.3", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_3a_0c_2", - "vendor_id": "0x8086", - "product_id": "0x2042", - "vendor": "Intel Corporation", - "product": "Sky Lake-E Integrated Memory Controller", - "address": "0000:3a:0c.2", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_17_11_0", - "vendor_id": "0x8086", - "product_id": "0x208e", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:17:11.0", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_3a_0c_7", - "vendor_id": "0x8086", - "product_id": "0x2047", - "vendor": "Intel Corporation", - "product": "Sky Lake-E LMDP Channel 1", - "address": "0000:3a:0c.7", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_5d_10_1", - "vendor_id": "0x8086", - "product_id": "0x2059", - "vendor": "Intel Corporation", - "product": "Sky Lake-E UPI Registers", - "address": "0000:5d:10.1", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_80_04_6", - "vendor_id": "0x8086", - "product_id": "0x2021", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CBDMA Registers", - "address": "0000:80:04.6", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_00_08_0", - "vendor_id": "0x8086", - "product_id": "0x2014", - "vendor": "Intel Corporation", - "product": "Sky Lake-E Ubox Registers", - "address": "0000:00:08.0", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_17_09_3", - "vendor_id": "0x8086", - "product_id": "0x208d", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:17:09.3", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_ae_0d_2", - "vendor_id": "0x8086", - "product_id": "0x204a", - "vendor": "Intel Corporation", - "product": "Sky Lake-E LMS Channel 2", - "address": "0000:ae:0d.2", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_17_09_2", - "vendor_id": "0x8086", - "product_id": "0x208d", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:17:09.2", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_85_0e_1", - "vendor_id": "0x8086", - "product_id": "0x208e", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:85:0e.1", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_00_11_1", - "vendor_id": "0x8086", - "product_id": "0xa1ed", - "vendor": "Intel Corporation", - "product": "C620 Series Chipset Family MROM 1", - "address": "0000:00:11.1", - "PCI class": "0xff0000" - }, - { - "caps": "pci", - "name": "pci_0000_85_0b_1", - "vendor_id": "0x8086", - "product_id": "0x208d", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:85:0b.1", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_17_09_7", - "vendor_id": "0x8086", - "product_id": "0x208d", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:17:09.7", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_00_11_0", - "vendor_id": "0x8086", - "product_id": "0xa1ec", - "vendor": "Intel Corporation", - "product": "C620 Series Chipset Family MROM 0", - "address": "0000:00:11.0", - "PCI class": "0xff0000" - }, - { - "caps": "pci", - "name": "pci_0000_85_1e_3", - "vendor_id": "0x8086", - "product_id": "0x2083", - "vendor": "Intel Corporation", - "product": "Sky Lake-E PCU Registers", - "address": "0000:85:1e.3", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_3a_0c_1", - "vendor_id": "0x8086", - "product_id": "0x2041", - "vendor": "Intel Corporation", - "product": "Sky Lake-E Integrated Memory Controller", - "address": "0000:3a:0c.1", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_17_0e_6", - "vendor_id": "0x8086", - "product_id": "0x208e", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:17:0e.6", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_ae_0c_1", - "vendor_id": "0x8086", - "product_id": "0x2041", - "vendor": "Intel Corporation", - "product": "Sky Lake-E Integrated Memory Controller", - "address": "0000:ae:0c.1", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_17_1e_2", - "vendor_id": "0x8086", - "product_id": "0x2082", - "vendor": "Intel Corporation", - "product": "Sky Lake-E PCU Registers", - "address": "0000:17:1e.2", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_5d_12_1", - "vendor_id": "0x8086", - "product_id": "0x204d", - "vendor": "Intel Corporation", - "product": "Sky Lake-E M3KTI Registers", - "address": "0000:5d:12.1", - "PCI class": "0x110100" - }, - { - "caps": "pci", - "name": "pci_0000_3d_02_1", - "vendor_id": "0x8086", - "product_id": "0x37cd", - "vendor": "Intel Corporation", - "product": "Ethernet Virtual Function 700 Series", - "address": "0000:3d:02.1", - "PCI class": "0x020000", - "physical function": "0000:3d:00.0" - }, - { - "caps": "pci", - "name": "pci_0000_5d_10_0", - "vendor_id": "0x8086", - "product_id": "0x2058", - "vendor": "Intel Corporation", - "product": "Sky Lake-E KTI 0", - "address": "0000:5d:10.0", - "PCI class": "0x110100" - }, - { - "caps": "pci", - "name": "pci_0000_85_09_6", - "vendor_id": "0x8086", - "product_id": "0x208d", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:85:09.6", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_5d_0e_0", - "vendor_id": "0x8086", - "product_id": "0x2058", - "vendor": "Intel Corporation", - "product": "Sky Lake-E KTI 0", - "address": "0000:5d:0e.0", - "PCI class": "0x110100" - }, - { - "caps": "pci", - "name": "pci_0000_5d_05_4", - "vendor_id": "0x8086", - "product_id": "0x2036", - "vendor": "Intel Corporation", - "product": "Sky Lake-E IOxAPIC Configuration Registers", - "address": "0000:5d:05.4", - "PCI class": "0x080020" - }, - { - "caps": "pci", - "name": "pci_0000_80_08_1", - "vendor_id": "0x8086", - "product_id": "0x2015", - "vendor": "Intel Corporation", - "product": "Sky Lake-E Ubox Registers", - "address": "0000:80:08.1", - "PCI class": "0x110100" - }, - { - "caps": "pci", - "name": "pci_0000_17_09_6", - "vendor_id": "0x8086", - "product_id": "0x208d", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:17:09.6", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_5d_0f_0", - "vendor_id": "0x8086", - "product_id": "0x2058", - "vendor": "Intel Corporation", - "product": "Sky Lake-E KTI 0", - "address": "0000:5d:0f.0", - "PCI class": "0x110100" - }, - { - "caps": "pci", - "name": "pci_0000_17_08_6", - "vendor_id": "0x8086", - "product_id": "0x208d", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:17:08.6", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_80_04_5", - "vendor_id": "0x8086", - "product_id": "0x2021", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CBDMA Registers", - "address": "0000:80:04.5", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_85_08_3", - "vendor_id": "0x8086", - "product_id": "0x208d", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:85:08.3", - "PCI class": "0x088000" - }, - { - "caps": "net", - "name": "virbr0-nic", - "address": "52:54:00:ae:52:36", - "device name": "computer", - "state": "down" - }, - { - "caps": "pci", - "name": "pci_0000_00_04_2", - "vendor_id": "0x8086", - "product_id": "0x2021", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CBDMA Registers", - "address": "0000:00:04.2", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_3d_00_1", - "vendor_id": "0x8086", - "product_id": "0x37d2", - "vendor": "Intel Corporation", - "product": "Ethernet Connection X722 for 10GBASE-T", - "address": "0000:3d:00.1", - "PCI class": "0x020000" - }, - { - "caps": "pci", - "name": "pci_0000_5d_0f_1", - "vendor_id": "0x8086", - "product_id": "0x2059", - "vendor": "Intel Corporation", - "product": "Sky Lake-E UPI Registers", - "address": "0000:5d:0f.1", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_17_0f_7", - "vendor_id": "0x8086", - "product_id": "0x208e", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:17:0f.7", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_85_10_3", - "vendor_id": "0x8086", - "product_id": "0x208e", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:85:10.3", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_17_10_0", - "vendor_id": "0x8086", - "product_id": "0x208e", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:17:10.0", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_85_0a_1", - "vendor_id": "0x8086", - "product_id": "0x208d", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:85:0a.1", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_ae_05_4", - "vendor_id": "0x8086", - "product_id": "0x2036", - "vendor": "Intel Corporation", - "product": "Sky Lake-E IOxAPIC Configuration Registers", - "address": "0000:ae:05.4", - "PCI class": "0x080020" - }, - { - "caps": "pci", - "name": "pci_0000_85_0f_6", - "vendor_id": "0x8086", - "product_id": "0x208e", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:85:0f.6", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_85_08_0", - "vendor_id": "0x8086", - "product_id": "0x208d", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:85:08.0", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_3a_0d_0", - "vendor_id": "0x8086", - "product_id": "0x2048", - "vendor": "Intel Corporation", - "product": "Sky Lake-E DECS Channel 2", - "address": "0000:3a:0d.0", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_17_0b_0", - "vendor_id": "0x8086", - "product_id": "0x208d", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:17:0b.0", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_5d_15_0", - "vendor_id": "0x8086", - "product_id": "0x2018", - "vendor": "Intel Corporation", - "product": "Sky Lake-E M2PCI Registers", - "address": "0000:5d:15.0", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_d7_05_2", - "vendor_id": "0x8086", - "product_id": "0x2035", - "vendor": "Intel Corporation", - "product": "Sky Lake-E RAS Configuration Registers", - "address": "0000:d7:05.2", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_85_11_3", - "vendor_id": "0x8086", - "product_id": "0x208e", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:85:11.3", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_5d_05_2", - "vendor_id": "0x8086", - "product_id": "0x2035", - "vendor": "Intel Corporation", - "product": "Sky Lake-E RAS Configuration Registers", - "address": "0000:5d:05.2", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_17_08_0", - "vendor_id": "0x8086", - "product_id": "0x208d", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:17:08.0", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_5d_12_0", - "vendor_id": "0x8086", - "product_id": "0x204c", - "vendor": "Intel Corporation", - "product": "Sky Lake-E M3KTI Registers", - "address": "0000:5d:12.0", - "PCI class": "0x110100" - }, - { - "caps": "pci", - "name": "pci_0000_3a_05_2", - "vendor_id": "0x8086", - "product_id": "0x2035", - "vendor": "Intel Corporation", - "product": "Sky Lake-E RAS Configuration Registers", - "address": "0000:3a:05.2", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_00_04_6", - "vendor_id": "0x8086", - "product_id": "0x2021", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CBDMA Registers", - "address": "0000:00:04.6", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_00_04_1", - "vendor_id": "0x8086", - "product_id": "0x2021", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CBDMA Registers", - "address": "0000:00:04.1", - "PCI class": "0x088000" - }, - { - "caps": "usb_device", - "name": "usb_1_4_1", - "vendor_id": "0x10d5", - "product_id": "0x5532", - "vendor": "Uni Class Technology Co., Ltd", - "product": "KVM", - "address": "001:005" - }, - { - "caps": "pci", - "name": "pci_0000_85_11_1", - "vendor_id": "0x8086", - "product_id": "0x208e", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:85:11.1", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_85_10_4", - "vendor_id": "0x8086", - "product_id": "0x208e", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:85:10.4", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_80_04_0", - "vendor_id": "0x8086", - "product_id": "0x2021", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CBDMA Registers", - "address": "0000:80:04.0", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_80_04_1", - "vendor_id": "0x8086", - "product_id": "0x2021", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CBDMA Registers", - "address": "0000:80:04.1", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_17_05_2", - "vendor_id": "0x8086", - "product_id": "0x2035", - "vendor": "Intel Corporation", - "product": "Sky Lake-E RAS Configuration Registers", - "address": "0000:17:05.2", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_d7_0e_0", - "vendor_id": "0x8086", - "product_id": "0x2058", - "vendor": "Intel Corporation", - "product": "Sky Lake-E KTI 0", - "address": "0000:d7:0e.0", - "PCI class": "0x110100" - }, - { - "caps": "pci", - "name": "pci_0000_85_0a_5", - "vendor_id": "0x8086", - "product_id": "0x208d", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:85:0a.5", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_85_09_5", - "vendor_id": "0x8086", - "product_id": "0x208d", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:85:09.5", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_85_05_2", - "vendor_id": "0x8086", - "product_id": "0x2035", - "vendor": "Intel Corporation", - "product": "Sky Lake-E RAS Configuration Registers", - "address": "0000:85:05.2", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_17_0e_1", - "vendor_id": "0x8086", - "product_id": "0x208e", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:17:0e.1", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_17_0b_2", - "vendor_id": "0x8086", - "product_id": "0x208d", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:17:0b.2", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_00_16_4", - "vendor_id": "0x8086", - "product_id": "0xa1be", - "vendor": "Intel Corporation", - "product": "C620 Series Chipset Family MEI Controller #3", - "address": "0000:00:16.4", - "PCI class": "0x078000" - }, - { - "caps": "pci", - "name": "pci_0000_d7_0f_0", - "vendor_id": "0x8086", - "product_id": "0x2058", - "vendor": "Intel Corporation", - "product": "Sky Lake-E KTI 0", - "address": "0000:d7:0f.0", - "PCI class": "0x110100" - }, - { - "caps": "pci", - "name": "pci_0000_5d_12_4", - "vendor_id": "0x8086", - "product_id": "0x204c", - "vendor": "Intel Corporation", - "product": "Sky Lake-E M3KTI Registers", - "address": "0000:5d:12.4", - "PCI class": "0x110100" - }, - { - "caps": "pci", - "name": "pci_0000_ae_0a_7", - "vendor_id": "0x8086", - "product_id": "0x2047", - "vendor": "Intel Corporation", - "product": "Sky Lake-E LMDP Channel 1", - "address": "0000:ae:0a.7", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_ae_0c_5", - "vendor_id": "0x8086", - "product_id": "0x2045", - "vendor": "Intel Corporation", - "product": "Sky Lake-E LM Channel 1", - "address": "0000:ae:0c.5", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_ae_08_0", - "vendor_id": "0x8086", - "product_id": "0x2066", - "vendor": "Intel Corporation", - "product": "Sky Lake-E Integrated Memory Controller", - "address": "0000:ae:08.0", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_85_1e_2", - "vendor_id": "0x8086", - "product_id": "0x2082", - "vendor": "Intel Corporation", - "product": "Sky Lake-E PCU Registers", - "address": "0000:85:1e.2", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_17_0f_5", - "vendor_id": "0x8086", - "product_id": "0x208e", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:17:0f.5", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_5d_12_5", - "vendor_id": "0x8086", - "product_id": "0x204d", - "vendor": "Intel Corporation", - "product": "Sky Lake-E M3KTI Registers", - "address": "0000:5d:12.5", - "PCI class": "0x110100" - }, - { - "caps": "pci", - "name": "pci_0000_85_0e_2", - "vendor_id": "0x8086", - "product_id": "0x208e", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:85:0e.2", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_5d_17_1", - "vendor_id": "0x8086", - "product_id": "0x2088", - "vendor": "Intel Corporation", - "product": "Sky Lake-E DDRIO Registers", - "address": "0000:5d:17.1", - "PCI class": "0x110100" - }, - { - "caps": "pci", - "name": "pci_0000_d7_12_4", - "vendor_id": "0x8086", - "product_id": "0x204c", - "vendor": "Intel Corporation", - "product": "Sky Lake-E M3KTI Registers", - "address": "0000:d7:12.4", - "PCI class": "0x110100" - }, - { - "caps": "pci", - "name": "pci_0000_85_11_0", - "vendor_id": "0x8086", - "product_id": "0x208e", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:85:11.0", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_ae_0c_4", - "vendor_id": "0x8086", - "product_id": "0x2044", - "vendor": "Intel Corporation", - "product": "Sky Lake-E Integrated Memory Controller", - "address": "0000:ae:0c.4", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_00_17_0", - "vendor_id": "0x8086", - "product_id": "0xa182", - "vendor": "Intel Corporation", - "product": "C620 Series Chipset Family SATA Controller [AHCI mode]", - "address": "0000:00:17.0", - "PCI class": "0x010601" - }, - { - "caps": "pci", - "name": "pci_0000_5d_16_1", - "vendor_id": "0x8086", - "product_id": "0x2088", - "vendor": "Intel Corporation", - "product": "Sky Lake-E DDRIO Registers", - "address": "0000:5d:16.1", - "PCI class": "0x110100" - }, - { - "caps": "pci", - "name": "pci_0000_3a_0c_5", - "vendor_id": "0x8086", - "product_id": "0x2045", - "vendor": "Intel Corporation", - "product": "Sky Lake-E LM Channel 1", - "address": "0000:3a:0c.5", - "PCI class": "0x088000" - }, - { - "caps": "net", - "name": "eth8", - "address": "e6:86:48:46:c5:29", - "device name": "pci_0000_3d_02_2", - "state": "down" - }, - { - "caps": "pci", - "name": "pci_0000_17_1e_5", - "vendor_id": "0x8086", - "product_id": "0x2085", - "vendor": "Intel Corporation", - "product": "Sky Lake-E PCU Registers", - "address": "0000:17:1e.5", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_17_0e_4", - "vendor_id": "0x8086", - "product_id": "0x208e", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:17:0e.4", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_00_16_1", - "vendor_id": "0x8086", - "product_id": "0xa1bb", - "vendor": "Intel Corporation", - "product": "C620 Series Chipset Family MEI Controller #2", - "address": "0000:00:16.1", - "PCI class": "0x078000" - }, - { - "caps": "pci", - "name": "pci_0000_ae_0a_5", - "vendor_id": "0x8086", - "product_id": "0x2045", - "vendor": "Intel Corporation", - "product": "Sky Lake-E LM Channel 1", - "address": "0000:ae:0a.5", - "PCI class": "0x088000" - }, - { - "caps": "net", - "name": "eth1", - "address": "a4:bf:01:1d:27:89", - "device name": "pci_0000_3d_00_1", - "state": "down" - }, - { - "caps": "pci", - "name": "pci_0000_17_10_5", - "vendor_id": "0x8086", - "product_id": "0x208e", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:17:10.5", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_17_09_1", - "vendor_id": "0x8086", - "product_id": "0x208d", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:17:09.1", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_3a_05_4", - "vendor_id": "0x8086", - "product_id": "0x2036", - "vendor": "Intel Corporation", - "product": "Sky Lake-E IOxAPIC Configuration Registers", - "address": "0000:3a:05.4", - "PCI class": "0x080020" - }, - { - "caps": "pci", - "name": "pci_0000_d7_16_1", - "vendor_id": "0x8086", - "product_id": "0x2088", - "vendor": "Intel Corporation", - "product": "Sky Lake-E DDRIO Registers", - "address": "0000:d7:16.1", - "PCI class": "0x110100" - }, - { - "caps": "pci", - "name": "pci_0000_00_04_0", - "vendor_id": "0x8086", - "product_id": "0x2021", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CBDMA Registers", - "address": "0000:00:04.0", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_3a_0b_0", - "vendor_id": "0x8086", - "product_id": "0x2048", - "vendor": "Intel Corporation", - "product": "Sky Lake-E DECS Channel 2", - "address": "0000:3a:0b.0", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_00_16_0", - "vendor_id": "0x8086", - "product_id": "0xa1ba", - "vendor": "Intel Corporation", - "product": "C620 Series Chipset Family MEI Controller #1", - "address": "0000:00:16.0", - "PCI class": "0x078000" - }, - { - "caps": "pci", - "name": "pci_0000_00_04_5", - "vendor_id": "0x8086", - "product_id": "0x2021", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CBDMA Registers", - "address": "0000:00:04.5", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_85_05_4", - "vendor_id": "0x8086", - "product_id": "0x2036", - "vendor": "Intel Corporation", - "product": "Sky Lake-E IOxAPIC Configuration Registers", - "address": "0000:85:05.4", - "PCI class": "0x080020" - }, - { - "caps": "pci", - "name": "pci_0000_17_0b_1", - "vendor_id": "0x8086", - "product_id": "0x208d", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:17:0b.1", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_ae_0c_0", - "vendor_id": "0x8086", - "product_id": "0x2040", - "vendor": "Intel Corporation", - "product": "Sky Lake-E Integrated Memory Controller", - "address": "0000:ae:0c.0", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_17_1e_0", - "vendor_id": "0x8086", - "product_id": "0x2080", - "vendor": "Intel Corporation", - "product": "Sky Lake-E PCU Registers", - "address": "0000:17:1e.0", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_17_0a_1", - "vendor_id": "0x8086", - "product_id": "0x208d", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:17:0a.1", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_ae_0b_3", - "vendor_id": "0x8086", - "product_id": "0x204b", - "vendor": "Intel Corporation", - "product": "Sky Lake-E LMDP Channel 2", - "address": "0000:ae:0b.3", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_17_0a_0", - "vendor_id": "0x8086", - "product_id": "0x208d", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:17:0a.0", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_17_1d_0", - "vendor_id": "0x8086", - "product_id": "0x2054", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:17:1d.0", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_17_0f_1", - "vendor_id": "0x8086", - "product_id": "0x208e", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:17:0f.1", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_85_08_1", - "vendor_id": "0x8086", - "product_id": "0x208d", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:85:08.1", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_00_1f_5", - "vendor_id": "0x8086", - "product_id": "0xa1a4", - "vendor": "Intel Corporation", - "product": "C620 Series Chipset Family SPI Controller", - "address": "0000:00:1f.5", - "PCI class": "0x0c8000" - }, - { - "caps": "pci", - "name": "pci_0000_00_04_7", - "vendor_id": "0x8086", - "product_id": "0x2021", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CBDMA Registers", - "address": "0000:00:04.7", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_3a_08_0", - "vendor_id": "0x8086", - "product_id": "0x2066", - "vendor": "Intel Corporation", - "product": "Sky Lake-E Integrated Memory Controller", - "address": "0000:3a:08.0", - "PCI class": "0x088000" - }, - { - "caps": "usb_device", - "name": "usb_1_2", - "vendor_id": "0x0000", - "product_id": "0x0001", - "address": "001:002" - }, - { - "caps": "pci", - "name": "pci_0000_17_0f_4", - "vendor_id": "0x8086", - "product_id": "0x208e", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:17:0f.4", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_17_1e_1", - "vendor_id": "0x8086", - "product_id": "0x2081", - "vendor": "Intel Corporation", - "product": "Sky Lake-E PCU Registers", - "address": "0000:17:1e.1", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_85_0a_7", - "vendor_id": "0x8086", - "product_id": "0x208d", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:85:0a.7", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_00_05_0", - "vendor_id": "0x8086", - "product_id": "0x2024", - "vendor": "Intel Corporation", - "product": "Sky Lake-E MM/Vt-d Configuration Registers", - "address": "0000:00:05.0", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_85_08_7", - "vendor_id": "0x8086", - "product_id": "0x208d", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:85:08.7", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_3a_0a_1", - "vendor_id": "0x8086", - "product_id": "0x2041", - "vendor": "Intel Corporation", - "product": "Sky Lake-E Integrated Memory Controller", - "address": "0000:3a:0a.1", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_17_0a_6", - "vendor_id": "0x8086", - "product_id": "0x208d", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:17:0a.6", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_85_0f_5", - "vendor_id": "0x8086", - "product_id": "0x208e", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:85:0f.5", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_85_0e_6", - "vendor_id": "0x8086", - "product_id": "0x208e", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:85:0e.6", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_85_05_0", - "vendor_id": "0x8086", - "product_id": "0x2034", - "vendor": "Intel Corporation", - "product": "Sky Lake-E VT-d", - "address": "0000:85:05.0", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_3a_0a_3", - "vendor_id": "0x8086", - "product_id": "0x2043", - "vendor": "Intel Corporation", - "product": "Sky Lake-E Integrated Memory Controller", - "address": "0000:3a:0a.3", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_3a_0a_6", - "vendor_id": "0x8086", - "product_id": "0x2046", - "vendor": "Intel Corporation", - "product": "Sky Lake-E LMS Channel 1", - "address": "0000:3a:0a.6", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_85_0f_7", - "vendor_id": "0x8086", - "product_id": "0x208e", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:85:0f.7", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_3a_09_0", - "vendor_id": "0x8086", - "product_id": "0x2066", - "vendor": "Intel Corporation", - "product": "Sky Lake-E Integrated Memory Controller", - "address": "0000:3a:09.0", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_85_0e_4", - "vendor_id": "0x8086", - "product_id": "0x208e", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:85:0e.4", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_85_1d_0", - "vendor_id": "0x8086", - "product_id": "0x2054", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:85:1d.0", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_85_09_1", - "vendor_id": "0x8086", - "product_id": "0x208d", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:85:09.1", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_d7_12_0", - "vendor_id": "0x8086", - "product_id": "0x204c", - "vendor": "Intel Corporation", - "product": "Sky Lake-E M3KTI Registers", - "address": "0000:d7:12.0", - "PCI class": "0x110100" - }, - { - "caps": "pci", - "name": "pci_0000_17_0a_3", - "vendor_id": "0x8086", - "product_id": "0x208d", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:17:0a.3", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_85_0a_2", - "vendor_id": "0x8086", - "product_id": "0x208d", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:85:0a.2", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_85_0b_3", - "vendor_id": "0x8086", - "product_id": "0x208d", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:85:0b.3", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_ae_0b_0", - "vendor_id": "0x8086", - "product_id": "0x2048", - "vendor": "Intel Corporation", - "product": "Sky Lake-E DECS Channel 2", - "address": "0000:ae:0b.0", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_17_0a_4", - "vendor_id": "0x8086", - "product_id": "0x208d", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:17:0a.4", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_80_05_0", - "vendor_id": "0x8086", - "product_id": "0x2024", - "vendor": "Intel Corporation", - "product": "Sky Lake-E MM/Vt-d Configuration Registers", - "address": "0000:80:05.0", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_85_1e_0", - "vendor_id": "0x8086", - "product_id": "0x2080", - "vendor": "Intel Corporation", - "product": "Sky Lake-E PCU Registers", - "address": "0000:85:1e.0", - "PCI class": "0x088000" - }, - { - "caps": "usb_device", - "name": "usb_1_4", - "vendor_id": "0x04cc", - "product_id": "0x1520", - "vendor": "ST-Ericsson", - "product": "USB 2.0 Hub (Avocent KVM)", - "address": "001:003" - }, - { - "caps": "pci", - "name": "pci_0000_3a_0a_0", - "vendor_id": "0x8086", - "product_id": "0x2040", - "vendor": "Intel Corporation", - "product": "Sky Lake-E Integrated Memory Controller", - "address": "0000:3a:0a.0", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_ae_0c_7", - "vendor_id": "0x8086", - "product_id": "0x2047", - "vendor": "Intel Corporation", - "product": "Sky Lake-E LMDP Channel 1", - "address": "0000:ae:0c.7", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_ae_0d_3", - "vendor_id": "0x8086", - "product_id": "0x204b", - "vendor": "Intel Corporation", - "product": "Sky Lake-E LMDP Channel 2", - "address": "0000:ae:0d.3", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_17_0e_7", - "vendor_id": "0x8086", - "product_id": "0x208e", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:17:0e.7", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_85_10_5", - "vendor_id": "0x8086", - "product_id": "0x208e", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:85:10.5", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_ae_0a_2", - "vendor_id": "0x8086", - "product_id": "0x2042", - "vendor": "Intel Corporation", - "product": "Sky Lake-E Integrated Memory Controller", - "address": "0000:ae:0a.2", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_ae_0d_1", - "vendor_id": "0x8086", - "product_id": "0x2049", - "vendor": "Intel Corporation", - "product": "Sky Lake-E LM Channel 2", - "address": "0000:ae:0d.1", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_3d_02_6", - "vendor_id": "0x8086", - "product_id": "0x37cd", - "vendor": "Intel Corporation", - "product": "Ethernet Virtual Function 700 Series", - "address": "0000:3d:02.6", - "PCI class": "0x020000", - "physical function": "0000:3d:00.0" - }, - { - "caps": "pci", - "name": "pci_0000_85_1e_1", - "vendor_id": "0x8086", - "product_id": "0x2081", - "vendor": "Intel Corporation", - "product": "Sky Lake-E PCU Registers", - "address": "0000:85:1e.1", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_85_0b_2", - "vendor_id": "0x8086", - "product_id": "0x208d", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:85:0b.2", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_17_1d_1", - "vendor_id": "0x8086", - "product_id": "0x2055", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:17:1d.1", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_02_00_0", - "vendor_id": "0x1a03", - "product_id": "0x2000", - "vendor": "ASPEED Technology, Inc.", - "product": "ASPEED Graphics Family", - "address": "0000:02:00.0", - "PCI class": "0x030000" - }, - { - "caps": "pci", - "name": "pci_0000_3a_0d_2", - "vendor_id": "0x8086", - "product_id": "0x204a", - "vendor": "Intel Corporation", - "product": "Sky Lake-E LMS Channel 2", - "address": "0000:3a:0d.2", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_80_04_2", - "vendor_id": "0x8086", - "product_id": "0x2021", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CBDMA Registers", - "address": "0000:80:04.2", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_5d_16_4", - "vendor_id": "0x8086", - "product_id": "0x2018", - "vendor": "Intel Corporation", - "product": "Sky Lake-E M2PCI Registers", - "address": "0000:5d:16.4", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_17_09_0", - "vendor_id": "0x8086", - "product_id": "0x208d", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:17:09.0", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_17_1e_6", - "vendor_id": "0x8086", - "product_id": "0x2086", - "vendor": "Intel Corporation", - "product": "Sky Lake-E PCU Registers", - "address": "0000:17:1e.6", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_5d_05_0", - "vendor_id": "0x8086", - "product_id": "0x2034", - "vendor": "Intel Corporation", - "product": "Sky Lake-E VT-d", - "address": "0000:5d:05.0", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_3d_00_0", - "vendor_id": "0x8086", - "product_id": "0x37d2", - "vendor": "Intel Corporation", - "product": "Ethernet Connection X722 for 10GBASE-T", - "address": "0000:3d:00.0", - "PCI class": "0x020000", - "virtual functions": [ - "0000:3d:02.0", - "0000:3d:02.1", - "0000:3d:02.2", - "0000:3d:02.3", - "0000:3d:02.4", - "0000:3d:02.5", - "0000:3d:02.6" - ] - }, - { - "caps": "net", - "name": "eth7", - "address": "2e:ee:7b:ff:92:6a", - "device name": "pci_0000_3d_02_3", - "state": "down" - }, - { - "caps": "pci", - "name": "pci_0000_d7_16_4", - "vendor_id": "0x8086", - "product_id": "0x2018", - "vendor": "Intel Corporation", - "product": "Sky Lake-E M2PCI Registers", - "address": "0000:d7:16.4", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_80_05_4", - "vendor_id": "0x8086", - "product_id": "0x2026", - "vendor": "Intel Corporation", - "product": "Sky Lake-E IOAPIC", - "address": "0000:80:05.4", - "PCI class": "0x080020" - }, - { - "caps": "pci", - "name": "pci_0000_3a_0b_2", - "vendor_id": "0x8086", - "product_id": "0x204a", - "vendor": "Intel Corporation", - "product": "Sky Lake-E LMS Channel 2", - "address": "0000:3a:0b.2", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_17_0f_6", - "vendor_id": "0x8086", - "product_id": "0x208e", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:17:0f.6", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_00_08_1", - "vendor_id": "0x8086", - "product_id": "0x2015", - "vendor": "Intel Corporation", - "product": "Sky Lake-E Ubox Registers", - "address": "0000:00:08.1", - "PCI class": "0x110100" - }, - { - "caps": "pci", - "name": "pci_0000_ae_0b_2", - "vendor_id": "0x8086", - "product_id": "0x204a", - "vendor": "Intel Corporation", - "product": "Sky Lake-E LMS Channel 2", - "address": "0000:ae:0b.2", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_d7_05_0", - "vendor_id": "0x8086", - "product_id": "0x2034", - "vendor": "Intel Corporation", - "product": "Sky Lake-E VT-d", - "address": "0000:d7:05.0", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_17_0a_7", - "vendor_id": "0x8086", - "product_id": "0x208d", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:17:0a.7", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_17_05_4", - "vendor_id": "0x8086", - "product_id": "0x2036", - "vendor": "Intel Corporation", - "product": "Sky Lake-E IOxAPIC Configuration Registers", - "address": "0000:17:05.4", - "PCI class": "0x080020" - }, - { - "caps": "pci", - "name": "pci_0000_85_0f_4", - "vendor_id": "0x8086", - "product_id": "0x208e", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:85:0f.4", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_d7_10_1", - "vendor_id": "0x8086", - "product_id": "0x2059", - "vendor": "Intel Corporation", - "product": "Sky Lake-E UPI Registers", - "address": "0000:d7:10.1", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_17_08_7", - "vendor_id": "0x8086", - "product_id": "0x208d", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:17:08.7", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_00_14_2", - "vendor_id": "0x8086", - "product_id": "0xa1b1", - "vendor": "Intel Corporation", - "product": "C620 Series Chipset Family Thermal Subsystem", - "address": "0000:00:14.2", - "PCI class": "0x118000" - }, - { - "caps": "pci", - "name": "pci_0000_85_10_0", - "vendor_id": "0x8086", - "product_id": "0x208e", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:85:10.0", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_85_0b_0", - "vendor_id": "0x8086", - "product_id": "0x208d", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:85:0b.0", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_17_10_2", - "vendor_id": "0x8086", - "product_id": "0x208e", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:17:10.2", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_17_0e_5", - "vendor_id": "0x8086", - "product_id": "0x208e", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:17:0e.5", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_3a_0c_3", - "vendor_id": "0x8086", - "product_id": "0x2043", - "vendor": "Intel Corporation", - "product": "Sky Lake-E Integrated Memory Controller", - "address": "0000:3a:0c.3", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_5d_17_0", - "vendor_id": "0x8086", - "product_id": "0x2018", - "vendor": "Intel Corporation", - "product": "Sky Lake-E M2PCI Registers", - "address": "0000:5d:17.0", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_17_08_1", - "vendor_id": "0x8086", - "product_id": "0x208d", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:17:08.1", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_3a_0c_0", - "vendor_id": "0x8086", - "product_id": "0x2040", - "vendor": "Intel Corporation", - "product": "Sky Lake-E Integrated Memory Controller", - "address": "0000:3a:0c.0", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_17_10_6", - "vendor_id": "0x8086", - "product_id": "0x208e", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:17:10.6", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_85_08_4", - "vendor_id": "0x8086", - "product_id": "0x208d", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:85:08.4", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_ae_0a_1", - "vendor_id": "0x8086", - "product_id": "0x2041", - "vendor": "Intel Corporation", - "product": "Sky Lake-E Integrated Memory Controller", - "address": "0000:ae:0a.1", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_5d_16_5", - "vendor_id": "0x8086", - "product_id": "0x2088", - "vendor": "Intel Corporation", - "product": "Sky Lake-E DDRIO Registers", - "address": "0000:5d:16.5", - "PCI class": "0x110100" - }, - { - "caps": "pci", - "name": "pci_0000_85_08_2", - "vendor_id": "0x8086", - "product_id": "0x208d", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:85:08.2", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_17_0b_3", - "vendor_id": "0x8086", - "product_id": "0x208d", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:17:0b.3", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_85_09_3", - "vendor_id": "0x8086", - "product_id": "0x208d", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:85:09.3", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_85_1e_5", - "vendor_id": "0x8086", - "product_id": "0x2085", - "vendor": "Intel Corporation", - "product": "Sky Lake-E PCU Registers", - "address": "0000:85:1e.5", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_ae_0b_1", - "vendor_id": "0x8086", - "product_id": "0x2049", - "vendor": "Intel Corporation", - "product": "Sky Lake-E LM Channel 2", - "address": "0000:ae:0b.1", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_17_10_7", - "vendor_id": "0x8086", - "product_id": "0x208e", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:17:10.7", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_00_08_2", - "vendor_id": "0x8086", - "product_id": "0x2016", - "vendor": "Intel Corporation", - "product": "Sky Lake-E Ubox Registers", - "address": "0000:00:08.2", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_00_04_3", - "vendor_id": "0x8086", - "product_id": "0x2021", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CBDMA Registers", - "address": "0000:00:04.3", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_85_0f_1", - "vendor_id": "0x8086", - "product_id": "0x208e", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:85:0f.1", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_17_09_5", - "vendor_id": "0x8086", - "product_id": "0x208d", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:17:09.5", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_17_1d_3", - "vendor_id": "0x8086", - "product_id": "0x2057", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:17:1d.3", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_5d_15_1", - "vendor_id": "0x8086", - "product_id": "0x2088", - "vendor": "Intel Corporation", - "product": "Sky Lake-E DDRIO Registers", - "address": "0000:5d:15.1", - "PCI class": "0x110100" - }, - { - "caps": "pci", - "name": "pci_0000_17_10_1", - "vendor_id": "0x8086", - "product_id": "0x208e", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:17:10.1", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_17_08_5", - "vendor_id": "0x8086", - "product_id": "0x208d", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:17:08.5", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_17_09_4", - "vendor_id": "0x8086", - "product_id": "0x208d", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:17:09.4", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_85_0e_7", - "vendor_id": "0x8086", - "product_id": "0x208e", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:85:0e.7", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_17_0f_3", - "vendor_id": "0x8086", - "product_id": "0x208e", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:17:0f.3", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_ae_0a_4", - "vendor_id": "0x8086", - "product_id": "0x2044", - "vendor": "Intel Corporation", - "product": "Sky Lake-E Integrated Memory Controller", - "address": "0000:ae:0a.4", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_00_14_0", - "vendor_id": "0x8086", - "product_id": "0xa1af", - "vendor": "Intel Corporation", - "product": "C620 Series Chipset Family USB 3.0 xHCI Controller", - "address": "0000:00:14.0", - "PCI class": "0x0c0330" - }, - { - "caps": "pci", - "name": "pci_0000_5d_0e_1", - "vendor_id": "0x8086", - "product_id": "0x2059", - "vendor": "Intel Corporation", - "product": "Sky Lake-E UPI Registers", - "address": "0000:5d:0e.1", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_3a_0a_4", - "vendor_id": "0x8086", - "product_id": "0x2044", - "vendor": "Intel Corporation", - "product": "Sky Lake-E Integrated Memory Controller", - "address": "0000:3a:0a.4", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_17_1e_3", - "vendor_id": "0x8086", - "product_id": "0x2083", - "vendor": "Intel Corporation", - "product": "Sky Lake-E PCU Registers", - "address": "0000:17:1e.3", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_85_11_2", - "vendor_id": "0x8086", - "product_id": "0x208e", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:85:11.2", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_00_1f_0", - "vendor_id": "0x8086", - "product_id": "0xa1c3", - "vendor": "Intel Corporation", - "product": "C624 Series Chipset LPC/eSPI Controller", - "address": "0000:00:1f.0", - "PCI class": "0x060100" - }, - { - "caps": "pci", - "name": "pci_0000_3a_0a_2", - "vendor_id": "0x8086", - "product_id": "0x2042", - "vendor": "Intel Corporation", - "product": "Sky Lake-E Integrated Memory Controller", - "address": "0000:3a:0a.2", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_00_00_0", - "vendor_id": "0x8086", - "product_id": "0x2020", - "vendor": "Intel Corporation", - "product": "Sky Lake-E DMI3 Registers", - "address": "0000:00:00.0", - "PCI class": "0x060000" - }, - { - "caps": "pci", - "name": "pci_0000_17_08_2", - "vendor_id": "0x8086", - "product_id": "0x208d", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:17:08.2", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_3a_05_0", - "vendor_id": "0x8086", - "product_id": "0x2034", - "vendor": "Intel Corporation", - "product": "Sky Lake-E VT-d", - "address": "0000:3a:05.0", - "PCI class": "0x088000" - }, - { - "caps": "usb_device", - "name": "usb_1_2_1", - "vendor_id": "0x0b1f", - "product_id": "0x03e9", - "vendor": "Insyde Software Corp.", - "address": "001:004" - }, - { - "caps": "pci", - "name": "pci_0000_3a_0d_3", - "vendor_id": "0x8086", - "product_id": "0x204b", - "vendor": "Intel Corporation", - "product": "Sky Lake-E LMDP Channel 2", - "address": "0000:3a:0d.3", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_17_0e_3", - "vendor_id": "0x8086", - "product_id": "0x208e", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:17:0e.3", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_3a_0a_7", - "vendor_id": "0x8086", - "product_id": "0x2047", - "vendor": "Intel Corporation", - "product": "Sky Lake-E LMDP Channel 1", - "address": "0000:3a:0a.7", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_ae_05_2", - "vendor_id": "0x8086", - "product_id": "0x2035", - "vendor": "Intel Corporation", - "product": "Sky Lake-E RAS Configuration Registers", - "address": "0000:ae:05.2", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_17_1d_2", - "vendor_id": "0x8086", - "product_id": "0x2056", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:17:1d.2", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_80_08_2", - "vendor_id": "0x8086", - "product_id": "0x2016", - "vendor": "Intel Corporation", - "product": "Sky Lake-E Ubox Registers", - "address": "0000:80:08.2", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_d7_0e_1", - "vendor_id": "0x8086", - "product_id": "0x2059", - "vendor": "Intel Corporation", - "product": "Sky Lake-E UPI Registers", - "address": "0000:d7:0e.1", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_5d_12_2", - "vendor_id": "0x8086", - "product_id": "0x204e", - "vendor": "Intel Corporation", - "product": "Sky Lake-E M3KTI Registers", - "address": "0000:5d:12.2", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_00_04_4", - "vendor_id": "0x8086", - "product_id": "0x2021", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CBDMA Registers", - "address": "0000:00:04.4", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_17_11_1", - "vendor_id": "0x8086", - "product_id": "0x208e", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:17:11.1", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_d7_15_1", - "vendor_id": "0x8086", - "product_id": "0x2088", - "vendor": "Intel Corporation", - "product": "Sky Lake-E DDRIO Registers", - "address": "0000:d7:15.1", - "PCI class": "0x110100" - }, - { - "caps": "pci", - "name": "pci_0000_5d_16_0", - "vendor_id": "0x8086", - "product_id": "0x2018", - "vendor": "Intel Corporation", - "product": "Sky Lake-E M2PCI Registers", - "address": "0000:5d:16.0", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_3a_0a_5", - "vendor_id": "0x8086", - "product_id": "0x2045", - "vendor": "Intel Corporation", - "product": "Sky Lake-E LM Channel 1", - "address": "0000:3a:0a.5", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_85_0a_6", - "vendor_id": "0x8086", - "product_id": "0x208d", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:85:0a.6", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_3d_02_3", - "vendor_id": "0x8086", - "product_id": "0x37cd", - "vendor": "Intel Corporation", - "product": "Ethernet Virtual Function 700 Series", - "address": "0000:3d:02.3", - "PCI class": "0x020000", - "physical function": "0000:3d:00.0" - }, - { - "caps": "pci", - "name": "pci_0000_85_10_7", - "vendor_id": "0x8086", - "product_id": "0x208e", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:85:10.7", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_85_0a_3", - "vendor_id": "0x8086", - "product_id": "0x208d", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:85:0a.3", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_ae_0c_2", - "vendor_id": "0x8086", - "product_id": "0x2042", - "vendor": "Intel Corporation", - "product": "Sky Lake-E Integrated Memory Controller", - "address": "0000:ae:0c.2", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_17_05_0", - "vendor_id": "0x8086", - "product_id": "0x2034", - "vendor": "Intel Corporation", - "product": "Sky Lake-E VT-d", - "address": "0000:17:05.0", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_d7_16_5", - "vendor_id": "0x8086", - "product_id": "0x2088", - "vendor": "Intel Corporation", - "product": "Sky Lake-E DDRIO Registers", - "address": "0000:d7:16.5", - "PCI class": "0x110100" - }, - { - "caps": "pci", - "name": "pci_0000_17_11_3", - "vendor_id": "0x8086", - "product_id": "0x208e", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:17:11.3", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_ae_0a_3", - "vendor_id": "0x8086", - "product_id": "0x2043", - "vendor": "Intel Corporation", - "product": "Sky Lake-E Integrated Memory Controller", - "address": "0000:ae:0a.3", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_d7_10_0", - "vendor_id": "0x8086", - "product_id": "0x2058", - "vendor": "Intel Corporation", - "product": "Sky Lake-E KTI 0", - "address": "0000:d7:10.0", - "PCI class": "0x110100" - }, - { - "caps": "pci", - "name": "pci_0000_85_10_2", - "vendor_id": "0x8086", - "product_id": "0x208e", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:85:10.2", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_17_0f_2", - "vendor_id": "0x8086", - "product_id": "0x208e", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:17:0f.2", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_3d_02_0", - "vendor_id": "0x8086", - "product_id": "0x37cd", - "vendor": "Intel Corporation", - "product": "Ethernet Virtual Function 700 Series", - "address": "0000:3d:02.0", - "PCI class": "0x020000", - "physical function": "0000:3d:00.0" - }, - { - "caps": "pci", - "name": "pci_0000_17_0f_0", - "vendor_id": "0x8086", - "product_id": "0x208e", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:17:0f.0", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_17_08_4", - "vendor_id": "0x8086", - "product_id": "0x208d", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:17:08.4", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_85_1d_1", - "vendor_id": "0x8086", - "product_id": "0x2055", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:85:1d.1", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_d7_17_0", - "vendor_id": "0x8086", - "product_id": "0x2018", - "vendor": "Intel Corporation", - "product": "Sky Lake-E M2PCI Registers", - "address": "0000:d7:17.0", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_17_1e_4", - "vendor_id": "0x8086", - "product_id": "0x2084", - "vendor": "Intel Corporation", - "product": "Sky Lake-E PCU Registers", - "address": "0000:17:1e.4", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_ae_05_0", - "vendor_id": "0x8086", - "product_id": "0x2034", - "vendor": "Intel Corporation", - "product": "Sky Lake-E VT-d", - "address": "0000:ae:05.0", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_3a_0c_6", - "vendor_id": "0x8086", - "product_id": "0x2046", - "vendor": "Intel Corporation", - "product": "Sky Lake-E LMS Channel 1", - "address": "0000:3a:0c.6", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_85_0e_0", - "vendor_id": "0x8086", - "product_id": "0x208e", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:85:0e.0", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_ae_09_0", - "vendor_id": "0x8086", - "product_id": "0x2066", - "vendor": "Intel Corporation", - "product": "Sky Lake-E Integrated Memory Controller", - "address": "0000:ae:09.0", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_ae_0a_6", - "vendor_id": "0x8086", - "product_id": "0x2046", - "vendor": "Intel Corporation", - "product": "Sky Lake-E LMS Channel 1", - "address": "0000:ae:0a.6", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_ae_0d_0", - "vendor_id": "0x8086", - "product_id": "0x2048", - "vendor": "Intel Corporation", - "product": "Sky Lake-E DECS Channel 2", - "address": "0000:ae:0d.0", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_d7_12_2", - "vendor_id": "0x8086", - "product_id": "0x204e", - "vendor": "Intel Corporation", - "product": "Sky Lake-E M3KTI Registers", - "address": "0000:d7:12.2", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_85_0f_2", - "vendor_id": "0x8086", - "product_id": "0x208e", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:85:0f.2", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_3a_0b_3", - "vendor_id": "0x8086", - "product_id": "0x204b", - "vendor": "Intel Corporation", - "product": "Sky Lake-E LMDP Channel 2", - "address": "0000:3a:0b.3", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_85_1d_3", - "vendor_id": "0x8086", - "product_id": "0x2057", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:85:1d.3", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_00_1f_2", - "vendor_id": "0x8086", - "product_id": "0xa1a1", - "vendor": "Intel Corporation", - "product": "C620 Series Chipset Family Power Management Controller", - "address": "0000:00:1f.2", - "PCI class": "0x058000" - }, - { - "caps": "pci", - "name": "pci_0000_17_11_2", - "vendor_id": "0x8086", - "product_id": "0x208e", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:17:11.2", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_85_0e_5", - "vendor_id": "0x8086", - "product_id": "0x208e", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:85:0e.5", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_85_1e_6", - "vendor_id": "0x8086", - "product_id": "0x2086", - "vendor": "Intel Corporation", - "product": "Sky Lake-E PCU Registers", - "address": "0000:85:1e.6", - "PCI class": "0x088000" - }, - { - "caps": "net", - "name": "eth2", - "address": "72:98:05:69:58:98", - "device name": "pci_0000_3d_02_1", - "state": "down" - }, - { - "caps": "pci", - "name": "pci_0000_17_08_3", - "vendor_id": "0x8086", - "product_id": "0x208d", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:17:08.3", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_17_0a_2", - "vendor_id": "0x8086", - "product_id": "0x208d", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:17:0a.2", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_d7_12_5", - "vendor_id": "0x8086", - "product_id": "0x204d", - "vendor": "Intel Corporation", - "product": "Sky Lake-E M3KTI Registers", - "address": "0000:d7:12.5", - "PCI class": "0x110100" - }, - { - "caps": "pci", - "name": "pci_0000_80_04_7", - "vendor_id": "0x8086", - "product_id": "0x2021", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CBDMA Registers", - "address": "0000:80:04.7", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_00_1f_4", - "vendor_id": "0x8086", - "product_id": "0xa1a3", - "vendor": "Intel Corporation", - "product": "C620 Series Chipset Family SMBus", - "address": "0000:00:1f.4", - "PCI class": "0x0c0500" - }, - { - "caps": "pci", - "name": "pci_0000_85_09_2", - "vendor_id": "0x8086", - "product_id": "0x208d", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:85:09.2", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_3d_02_4", - "vendor_id": "0x8086", - "product_id": "0x37cd", - "vendor": "Intel Corporation", - "product": "Ethernet Virtual Function 700 Series", - "address": "0000:3d:02.4", - "PCI class": "0x020000", - "physical function": "0000:3d:00.0" - }, - { - "caps": "pci", - "name": "pci_0000_d7_17_1", - "vendor_id": "0x8086", - "product_id": "0x2088", - "vendor": "Intel Corporation", - "product": "Sky Lake-E DDRIO Registers", - "address": "0000:d7:17.1", - "PCI class": "0x110100" - }, - { - "caps": "pci", - "name": "pci_0000_3a_0c_4", - "vendor_id": "0x8086", - "product_id": "0x2044", - "vendor": "Intel Corporation", - "product": "Sky Lake-E Integrated Memory Controller", - "address": "0000:3a:0c.4", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_3d_02_2", - "vendor_id": "0x8086", - "product_id": "0x37cd", - "vendor": "Intel Corporation", - "product": "Ethernet Virtual Function 700 Series", - "address": "0000:3d:02.2", - "PCI class": "0x020000", - "physical function": "0000:3d:00.0" - }, - { - "caps": "pci", - "name": "pci_0000_17_0e_2", - "vendor_id": "0x8086", - "product_id": "0x208e", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:17:0e.2", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_17_0a_5", - "vendor_id": "0x8086", - "product_id": "0x208d", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:17:0a.5", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_00_05_4", - "vendor_id": "0x8086", - "product_id": "0x2026", - "vendor": "Intel Corporation", - "product": "Sky Lake-E IOAPIC", - "address": "0000:00:05.4", - "PCI class": "0x080020" - }, - { - "caps": "pci", - "name": "pci_0000_17_0e_0", - "vendor_id": "0x8086", - "product_id": "0x208e", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:17:0e.0", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_85_0f_3", - "vendor_id": "0x8086", - "product_id": "0x208e", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CHA Registers", - "address": "0000:85:0f.3", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_85_1e_4", - "vendor_id": "0x8086", - "product_id": "0x2084", - "vendor": "Intel Corporation", - "product": "Sky Lake-E PCU Registers", - "address": "0000:85:1e.4", - "PCI class": "0x088000" - }, - { - "caps": "pci", - "name": "pci_0000_80_04_3", - "vendor_id": "0x8086", - "product_id": "0x2021", - "vendor": "Intel Corporation", - "product": "Sky Lake-E CBDMA Registers", - "address": "0000:80:04.3", - "PCI class": "0x088000" - } -] diff --git a/java/code/src/com/suse/manager/webui/controllers/virtualization/test/virt.pool.caps.json b/java/code/src/com/suse/manager/webui/controllers/virtualization/test/virt.pool.caps.json deleted file mode 100644 index b87ec161f212..000000000000 --- a/java/code/src/com/suse/manager/webui/controllers/virtualization/test/virt.pool.caps.json +++ /dev/null @@ -1,248 +0,0 @@ -{ - "computed": true, - "pool_types": [ - { - "name": "fs", - "supported": true, - "options": { - "pool": { - "default_format": "auto", - "sourceFormatType": [ - "auto", - "ext2", - "ext3", - "ext4", - "ufs", - "iso9660", - "udf", - "gfs", - "gfs2", - "vfat", - "hfs+", - "xfs", - "ocfs2" - ] - }, - "volume": { - "default_format": "raw", - "targetFormatType": [ - "none", - "raw", - "dir", - "bochs", - "cloop", - "dmg", - "iso", - "vpc", - "vdi", - "fat", - "vhd", - "ploop", - "cow", - "qcow", - "qcow2", - "qed", - "vmdk" - ] - } - } - }, - { - "name": "dir", - "supported": true, - "options": { - "volume": { - "default_format": "raw", - "targetFormatType": [ - "none", - "raw", - "dir", - "bochs", - "cloop", - "dmg", - "iso", - "vpc", - "vdi", - "fat", - "vhd", - "ploop", - "cow", - "qcow", - "qcow2", - "qed", - "vmdk" - ] - } - } - }, - { - "name": "iscsi", - "supported": true - }, - { - "name": "scsi", - "supported": true - }, - { - "name": "logical", - "supported": true, - "options": { - "pool": { - "default_format": "lvm2", - "sourceFormatType": [ - "unknown", - "lvm2" - ] - } - } - }, - { - "name": "netfs", - "supported": true, - "options": { - "pool": { - "default_format": "auto", - "sourceFormatType": [ - "auto", - "nfs", - "glusterfs", - "cifs" - ] - }, - "volume": { - "default_format": "raw", - "targetFormatType": [ - "none", - "raw", - "dir", - "bochs", - "cloop", - "dmg", - "iso", - "vpc", - "vdi", - "fat", - "vhd", - "ploop", - "cow", - "qcow", - "qcow2", - "qed", - "vmdk" - ] - } - } - }, - { - "name": "disk", - "supported": true, - "options": { - "pool": { - "default_format": "unknown", - "sourceFormatType": [ - "unknown", - "dos", - "dvh", - "gpt", - "mac", - "bsd", - "pc98", - "sun", - "lvm2" - ] - }, - "volume": { - "default_format": "none", - "targetFormatType": [ - "none", - "linux", - "fat16", - "fat32", - "linux-swap", - "linux-lvm", - "linux-raid", - "extended" - ] - } - } - }, - { - "name": "mpath", - "supported": true - }, - { - "name": "rbd", - "supported": true, - "options": { - "volume": { - "default_format": "raw", - "targetFormatType": [] - } - } - }, - { - "name": "sheepdog", - "supported": true, - "options": { - "volume": { - "default_format": "raw", - "targetFormatType": [ - "none", - "raw", - "dir", - "bochs", - "cloop", - "dmg", - "iso", - "vpc", - "vdi", - "fat", - "vhd", - "ploop", - "cow", - "qcow", - "qcow2", - "qed", - "vmdk" - ] - } - } - }, - { - "name": "gluster", - "supported": true, - "options": { - "volume": { - "default_format": "raw", - "targetFormatType": [ - "none", - "raw", - "dir", - "bochs", - "cloop", - "dmg", - "iso", - "vpc", - "vdi", - "fat", - "vhd", - "ploop", - "cow", - "qcow", - "qcow2", - "qed", - "vmdk" - ] - } - } - }, - { - "name": "zfs", - "supported": false - }, - { - "name": "iscsi-direct", - "supported": true - } - ] -} \ No newline at end of file diff --git a/java/code/src/com/suse/manager/webui/controllers/virtualization/test/virt.pool.info.json b/java/code/src/com/suse/manager/webui/controllers/virtualization/test/virt.pool.info.json deleted file mode 100644 index 9cbff7beec70..000000000000 --- a/java/code/src/com/suse/manager/webui/controllers/virtualization/test/virt.pool.info.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "pool0": { - "target_path": null, - "capacity": 854374301696, - "uuid": "d92682d0-33cf-4e10-9837-a216c463e158", - "persistent": 1, - "free": 301218959360, - "allocation": 553155342336, - "state": "running", - "autostart": 1, - "type": "dir" - }, - "pool1": { - "target_path": "/path/to/pool1", - "capacity": 21003628544, - "uuid": "808befba-85b1-40d6-83dc-d248850962e4", - "persistent": 1, - "free": 6591508480, - "allocation": 14412120064, - "state": "running", - "autostart": 0, - "type": "dir" - } -} diff --git a/java/code/src/com/suse/manager/webui/controllers/virtualization/test/virt.volume.info.json b/java/code/src/com/suse/manager/webui/controllers/virtualization/test/virt.volume.info.json deleted file mode 100644 index 29651f471791..000000000000 --- a/java/code/src/com/suse/manager/webui/controllers/virtualization/test/virt.volume.info.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "pool0": { - "disk0.qcow2": { - "allocation": 298123264, - "capacity": 214748364800, - "key": "/path/to/pool0/disk0.qcow2", - "path": "/path/to/pool0/disk0.qcow2", - "type": "file", - "used_by": ["vm0"] - }, - "disk1.qcow2": { - "allocation": 298123264, - "capacity": 214748364800, - "key": "/path/to/pool0/disk1.qcow2", - "path": "/path/to/pool0/disk1.qcow2", - "type": "file", - "used_by": [] - } - }, - "pool1": { - } -} \ No newline at end of file diff --git a/java/code/src/com/suse/manager/webui/controllers/virtualization/test/virt_utils.vm.info.json b/java/code/src/com/suse/manager/webui/controllers/virtualization/test/virt_utils.vm.info.json deleted file mode 100644 index fa3ae3fcac9f..000000000000 --- a/java/code/src/com/suse/manager/webui/controllers/virtualization/test/virt_utils.vm.info.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "sles12sp2": { - "cluster_primitive": null, - "graphics_type": "spice" - } -} diff --git a/java/code/src/com/suse/manager/webui/controllers/virtualization/test/virt_utils.vm_definition.json b/java/code/src/com/suse/manager/webui/controllers/virtualization/test/virt_utils.vm_definition.json deleted file mode 100644 index 380da6b0ad4b..000000000000 --- a/java/code/src/com/suse/manager/webui/controllers/virtualization/test/virt_utils.vm_definition.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "definition": "\n sles12sp2\n b99a8176-4f40-498d-8e61-2f6ade654fe2\n 1048576\n 1048576\n 2\n \n /machine\n \n \n hvm\n \n \n \n \n \n \n \n \n Nehalem\n \n \n \n \n \n \n destroy\n restart\n restart\n \n \n \n \n \n /usr/bin/qemu-kvm\n \n \n \n \n \n \n
\n \n \n \n \n \n \n \n
\n \n \n \n \n \n \n \n \n \n \n \n
\n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n \n \n \n \n
\n \n \n \n \n
\n \n \n \n \n
\n \n \n \n \n \n \n
\n \n \n \n
\n \n \n \n \n \n \n \n
\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n \n \n \n \n
\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n \n