Basically working.

This commit is contained in:
Michael Lipp 2025-01-23 13:41:53 +01:00
parent d060a9334a
commit 6d5ba8829c
12 changed files with 493 additions and 148 deletions

View file

@ -0,0 +1,61 @@
/*
* VM-Operator
* Copyright (C) 2024 Michael N. Lipp
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.jdrupes.vmoperator.manager.events;
import org.jdrupes.vmoperator.manager.events.GetVms.VmData;
import org.jgrapes.core.Event;
/**
* Assign a VM from a pool to a user.
*/
@SuppressWarnings("PMD.DataClass")
public class AssignVm extends Event<VmData> {
private final String fromPool;
private final String toUser;
/**
* Instantiates a new event.
*
* @param fromPool the from pool
* @param toUser the to user
*/
public AssignVm(String fromPool, String toUser) {
this.fromPool = fromPool;
this.toUser = toUser;
}
/**
* Gets the pool to assign from.
*
* @return the pool
*/
public String fromPool() {
return fromPool;
}
/**
* Gets the user to assign to.
*
* @return the to user
*/
public String toUser() {
return toUser;
}
}

View file

@ -33,6 +33,8 @@ public class GetVms extends Event<List<GetVms.VmData>> {
private String name;
private String user;
private List<String> roles = Collections.emptyList();
private String fromPool;
private String toUser;
/**
* Return only the VMs with the given name.
@ -59,6 +61,28 @@ public class GetVms extends Event<List<GetVms.VmData>> {
return this;
}
/**
* Return only {@link VmDefinition}s that are assigned from the given pool.
*
* @param pool the pool
* @return the returns the vms
*/
public GetVms assignedFrom(String pool) {
this.fromPool = pool;
return this;
}
/**
* Return only {@link VmDefinition}s that are assigned to the given user.
*
* @param user the user
* @return the returns the vms
*/
public GetVms assignedTo(String user) {
this.toUser = user;
return this;
}
/**
* Returns the name filter criterion, if set.
*
@ -86,6 +110,24 @@ public class GetVms extends Event<List<GetVms.VmData>> {
return roles;
}
/**
* Returns the pool filter criterion, if set.
*
* @return the optional
*/
public Optional<String> fromPool() {
return Optional.ofNullable(fromPool);
}
/**
* Returns the user filter criterion, if set.
*
* @return the optional
*/
public Optional<String> toUser() {
return Optional.ofNullable(toUser);
}
/**
* Return tuple.
*