Package org.jdrupes.vmoperator.common
Class VmDefinition
java.lang.Object
org.jdrupes.vmoperator.common.K8sDynamicModel
org.jdrupes.vmoperator.common.VmDefinition
- All Implemented Interfaces:
io.kubernetes.client.common.KubernetesObject
,io.kubernetes.client.common.KubernetesType
Represents a VM definition.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final record
The assignment information.static final record
Permissions granted to a user or role.static class
The Class Model.static enum
Permissions for accessing and manipulating the VM.static enum
The VM state from the VM definition. -
Constructor Summary
ConstructorsConstructorDescriptionVmDefinition
(com.google.gson.Gson delegate, com.google.gson.JsonObject json) Instantiates a new vm definition. -
Method Summary
Modifier and TypeMethodDescriptionThe assignment information.Optional
<io.kubernetes.client.openapi.models.V1Condition> Return a condition from the status.conditionStatus
(String name) Return a condition’s status.boolean
consoleAccessible
(String user, Set<VmDefinition.Permission> permissions) Check if the console is accessible.boolean
Return true if the console is in use.Return the last known console user.Get the display password serial.boolean
Equals.extra()
Return the extra data.(package private) VmDefinition
extra
(VmExtraData extraData) Set extra data (unknown to kubernetes).<T> Optional
<T> Get a value from the spec usingDataPath.get(java.lang.Object, java.lang.Object...)
.<T> Optional
<T> fromStatus
(Object... selectors) Get a value from the status usingDataPath.get(java.lang.Object, java.lang.Object...)
.<T> Optional
<T> Get a value from thespec().get("vm")
usingDataPath.get(java.lang.Object, java.lang.Object...)
.int
hashCode()
Hash code.name()
Returns the definition’s name.Returns the definition’s namespace.permissionsFor
(String user, Collection<String> roles) Collect all permissions for the given user with the given roles.pools()
The pools that this VM belongs to.spec()
Gets the spec.status()
Gets the status.vmState()
Return the requested VM state.Methods inherited from class org.jdrupes.vmoperator.common.K8sDynamicModel
apiVersion, data, getApiVersion, getKind, getMetadata, kind, metadata, statusJson, toString
-
Constructor Details
-
VmDefinition
Instantiates a new vm definition.- Parameters:
delegate
- the delegatejson
- the json
-
-
Method Details
-
spec
Gets the spec.- Returns:
- the spec
-
fromSpec
Get a value from the spec usingDataPath.get(java.lang.Object, java.lang.Object...)
.- Type Parameters:
T
- the generic type- Parameters:
selectors
- the selectors- Returns:
- the value, if found
-
pools
The pools that this VM belongs to.- Returns:
- the list
-
fromVm
Get a value from thespec().get("vm")
usingDataPath.get(java.lang.Object, java.lang.Object...)
.- Type Parameters:
T
- the generic type- Parameters:
selectors
- the selectors- Returns:
- the value, if found
-
status
Gets the status.- Returns:
- the status
-
fromStatus
Get a value from the status usingDataPath.get(java.lang.Object, java.lang.Object...)
.- Type Parameters:
T
- the generic type- Parameters:
selectors
- the selectors- Returns:
- the value, if found
-
assignment
The assignment information.- Returns:
- the optional
-
condition
Return a condition from the status.- Parameters:
name
- the condition’s name- Returns:
- the status, if the condition is defined
-
conditionStatus
Return a condition’s status.- Parameters:
name
- the condition’s name- Returns:
- the status, if the condition is defined
-
consoleConnected
Return true if the console is in use.- Returns:
- true, if successful
-
consoleUser
Return the last known console user.- Returns:
- the optional
-
extra
Set extra data (unknown to kubernetes).- Returns:
- the VM definition
-
extra
Return the extra data.- Returns:
- the data
-
name
Returns the definition’s name.- Returns:
- the string
-
namespace
Returns the definition’s namespace.- Returns:
- the string
-
vmState
Return the requested VM state.- Returns:
- the string
-
permissionsFor
Collect all permissions for the given user with the given roles.If permission “takeConsole” is granted, the result will also contain “accessConsole” to simplify checks.
- Parameters:
user
- the userroles
- the roles- Returns:
- the sets the
-
consoleAccessible
Check if the console is accessible.Always returns
true
if the VM is running and the permissions allow taking over the console. Else, returnstrue
if-
the permissions allow access to the console and
-
the VM is running and
-
the console is currently unused or used by the given user and
-
if user login is requested, the given user is logged in.
- Parameters:
user
- the userpermissions
- the permissions- Returns:
- true, if successful
-
-
displayPasswordSerial
Get the display password serial.- Returns:
- the optional
-
hashCode
Hash code. -
equals
Equals.
-