Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

machines: Add LibvirtDBus provider #9240

Merged
merged 8 commits into from
Sep 18, 2018
Prev Previous commit
Next Next commit
machines: actions.es6: Add id parameter to specific actions
The id parameter is going to be used by followup changes introducing new
provider.
KKoukiou committed Sep 17, 2018
commit df639bb49dd46148ba6869f3c3e0c403d31ef60e
13 changes: 7 additions & 6 deletions pkg/machines/actions/provider-actions.es6
Original file line number Diff line number Diff line change
@@ -59,8 +59,8 @@ import {
* The naming convention for action creator names is: <verb><Noun>
* with the present tense.
*/
export function attachDisk({ connectionName, diskFileName, target, permanent, hotplug, vmName }) {
return virt(ATTACH_DISK, { connectionName, diskFileName, target, permanent, hotplug, vmName });
export function attachDisk({ connectionName, diskFileName, target, permanent, hotplug, vmName, vmId }) {
return virt(ATTACH_DISK, { connectionName, diskFileName, target, permanent, hotplug, vmName, vmId });
}

export function changeNetworkState(vm, networkMac, state) {
@@ -116,10 +116,11 @@ export function getStorageVolumes(connectionName, poolName) {
return virt(GET_STORAGE_VOLUMES, { connectionName, poolName });
}

export function getVm(connectionName, lookupId) {
export function getVm({connectionName, name, id}) {
return virt(GET_VM, {
lookupId, // provider-specific (i.e. libvirt uses vm_name)
connectionName,
name,
id
});
}

@@ -177,8 +178,8 @@ export function vmDesktopConsole(vm, consoleDetail) {
return virt(CONSOLE_VM, { name: vm.name, id: vm.id, connectionName: vm.connectionName, consoleDetail });
}

export function volumeCreateAndAttach({ connectionName, poolName, volumeName, size, format, target, permanent, hotplug, vmName }) {
return virt(CREATE_AND_ATTACH_VOLUME, { connectionName, poolName, volumeName, size, format, target, permanent, hotplug, vmName });
export function volumeCreateAndAttach({ connectionName, poolName, volumeName, size, format, target, permanent, hotplug, vmName, vmId }) {
return virt(CREATE_AND_ATTACH_VOLUME, { connectionName, poolName, volumeName, size, format, target, permanent, hotplug, vmName, vmId });
}

/**
6 changes: 4 additions & 2 deletions pkg/machines/actions/store-actions.es6
Original file line number Diff line number Diff line change
@@ -94,10 +94,11 @@ export function deleteUiVm(vm) {
};
}

export function deleteUnlistedVMs(connectionName, vmNames) {
export function deleteUnlistedVMs(connectionName, vmNames, vmIds) {
return {
type: DELETE_UNLISTED_VMS,
vmNames,
vmIds,
connectionName,
};
}
@@ -131,10 +132,11 @@ export function setRefreshInterval(refreshInterval) {
};
}

export function undefineVm(connectionName, name, transientOnly) {
export function undefineVm({connectionName, name, id, transientOnly}) {
return {
type: UNDEFINE_VM,
name,
id,
connectionName,
transientOnly,
};
19 changes: 14 additions & 5 deletions pkg/machines/reducers.es6
Original file line number Diff line number Diff line change
@@ -160,13 +160,22 @@ function vms(state, action) {
return replaceVm({ state, updatedVm, index: indexedVm.index });
}
case UNDEFINE_VM: {
return state
.filter(vm => (action.connectionName !== vm.connectionName || action.name != vm.name ||
(action.transientOnly && vm.persistent)));
if (action.id)
return state
.filter(vm => (action.connectionName !== vm.connectionName || action.id != vm.id ||
(action.transientOnly && vm.persistent)));
else
return state
.filter(vm => (action.connectionName !== vm.connectionName || action.name != vm.name ||
(action.transientOnly && vm.persistent)));
}
case DELETE_UNLISTED_VMS: {
return state
.filter(vm => (action.connectionName !== vm.connectionName || action.vmNames.indexOf(vm.name) >= 0));
if (action.vmIDs)
return state
.filter(vm => (action.connectionName !== vm.connectionName || action.vmIDs.indexOf(vm.id) >= 0));
else
return state
.filter(vm => (action.connectionName !== vm.connectionName || action.vmNames.indexOf(vm.name) >= 0));
}
default: // by default all reducers should return initial state on unknown actions
return state;