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

public class VmDefinition extends K8sDynamicModel
Represents a VM definition.
  • Constructor Details

    • VmDefinition

      public VmDefinition(com.google.gson.Gson delegate, com.google.gson.JsonObject json)
      Instantiates a new vm definition.
      Parameters:
      delegate - the delegate
      json - the json
  • Method Details

    • spec

      public Map<String,Object> spec()
      Gets the spec.
      Returns:
      the spec
    • fromSpec

      public <T> Optional<T> fromSpec(Object... selectors)
      Type Parameters:
      T - the generic type
      Parameters:
      selectors - the selectors
      Returns:
      the value, if found
    • pools

      public List<String> pools()
      The pools that this VM belongs to.
      Returns:
      the list
    • fromVm

      public <T> Optional<T> fromVm(Object... selectors)
      Get a value from the spec().get("vm") using DataPath.get(java.lang.Object, java.lang.Object...).
      Type Parameters:
      T - the generic type
      Parameters:
      selectors - the selectors
      Returns:
      the value, if found
    • status

      public Map<String,Object> status()
      Gets the status.
      Returns:
      the status
    • fromStatus

      public <T> Optional<T> fromStatus(Object... selectors)
      Get a value from the status using DataPath.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

      public Optional<io.kubernetes.client.openapi.models.V1Condition> condition(String name)
      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

      public boolean consoleConnected()
      Return true if the console is in use.
      Returns:
      true, if successful
    • consoleUser

      Return the last known console user.
      Returns:
      the optional
    • extra

      public VmExtraData extra()
      Return the extra data.
      Returns:
      the data
    • name

      public String name()
      Returns the definition’s name.
      Returns:
      the string
    • namespace

      public 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 user
      roles - the roles
      Returns:
      the sets the
    • consoleAccessible

      public boolean consoleAccessible(String user, Set<VmDefinition.Permission> permissions)
      Check if the console is accessible.

      Always returns true if the VM is running and the permissions allow taking over the console. Else, returns true 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 user
      permissions - the permissions
      Returns:
      true, if successful
    • displayPasswordSerial

      Get the display password serial.
      Returns:
      the optional
    • hashCode

      public int hashCode()
      Hash code.
      Overrides:
      hashCode in class Object
      Returns:
      the int
    • equals

      public boolean equals(Object obj)
      Equals.
      Overrides:
      equals in class Object
      Parameters:
      obj - the obj
      Returns:
      true, if successful