com.redhat.rhn.domain.server
Class VirtualInstance

java.lang.Object
  extended by com.redhat.rhn.domain.BaseDomainHelper
      extended by com.redhat.rhn.domain.server.VirtualInstance

public class VirtualInstance
extends BaseDomainHelper

VirtualInstance represents a virtual guest system. When the guest is registered, there is an associated Server that contains additional information about the guest. This class maps to the RHN.RhnVirtualInstance table. The schema for the RhnVirtualInstance supports guests of guests; however guests of guests is not being implemented in the RHN 500 release.


Constructor Summary
  VirtualInstance()
          Default constructor
protected VirtualInstance(java.lang.Long instanceId)
          This constructor is for testing only.
 
Method Summary
 GuestAndNonVirtHostView asGuestAndNonVirtHostView()
          An adapter method that transforms the virtual instance into a view.
 void deleteGuestSystem()
          Deletes the guest server when the virtual instance is a registered guest.
 boolean equals(java.lang.Object object)
          Two virtual instancess are considered equal when they share the same UUID.
 Server getGuestSystem()
          When the virtual instance is registered, this method returns a Server corresponding to the guest that this virtual instance represents.
 Server getHostSystem()
          Returns a guest's parent or host system.
 java.lang.Long getId()
          Return the database identifier, the primary key.
 java.lang.String getName()
          Returns the name of the virtual instance.
 java.lang.Integer getNumberOfCPUs()
          Returns the number of CPUs allocated to the virtual instance.
 VirtualInstanceState getState()
          Returns the state of the virtual instance.
 java.lang.Long getTotalMemory()
          Returns the total memory in KB allocated to the virtual instance.
 VirtualInstanceType getType()
          Returns the virtualization type for this instance.
 java.lang.String getUuid()
          Return the system's UUID.
 int hashCode()
          
 boolean isConfirmed()
           
 boolean isRegisteredGuest()
          Returns true if this virtual instance represents a registered guest.
 void setConfirmed(boolean isConfirmed)
           
 void setGuestSystem(Server system)
          Sets the Server corresponding to the guest represented by this virtual instance.
 void setHostSystem(Server system)
          Sets the parent/host for this guest.
 void setName(java.lang.String name)
          Set the name of the virtual instance.
 void setNumberOfCPUs(java.lang.Integer number)
          Sets the number of CPUs allocated to the virtual instance.
 void setState(VirtualInstanceState state)
          Sets the state of the virtual instance.
 void setTotalMemory(java.lang.Long memory)
          Sets the total memory in KB allocated to the virtual instance.
 void setType(VirtualInstanceType type)
          Sets the virtualization type for this instance.
 void setUuid(java.lang.String newUuid)
           
 java.lang.String toString()
          
 
Methods inherited from class com.redhat.rhn.domain.BaseDomainHelper
getCreated, getModified, setCreated, setModified
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

VirtualInstance

public VirtualInstance()
Default constructor


VirtualInstance

protected VirtualInstance(java.lang.Long instanceId)
This constructor is for testing only.

Parameters:
instanceId - The unique id to assign to the guest
Method Detail

getId

public java.lang.Long getId()
Return the database identifier, the primary key.

Returns:
The database identifier, the primary key.

getUuid

public java.lang.String getUuid()
Return the system's UUID.

Returns:
The system's UUID.

setUuid

public void setUuid(java.lang.String newUuid)
Parameters:
newUuid - The new UUID

isConfirmed

public boolean isConfirmed()
Returns:
true or false

setConfirmed

public void setConfirmed(boolean isConfirmed)
Parameters:
isConfirmed - true or false

getGuestSystem

public Server getGuestSystem()
When the virtual instance is registered, this method returns a Server corresponding to the guest that this virtual instance represents.

Returns:
A Server object corresponding to the guest that this virtual instance represents when the guest is registered; otherwise, null is returned

setGuestSystem

public void setGuestSystem(Server system)
Sets the Server corresponding to the guest represented by this virtual instance.

Parameters:
system - the guest system

deleteGuestSystem

public void deleteGuestSystem()
Deletes the guest server when the virtual instance is a registered guest.


getHostSystem

public Server getHostSystem()
Returns a guest's parent or host system. Note: For the RHN 500 release, the Server returned from this method will always be a non-virtual system. The underlying database schema is designed to support guests of guests, but we are not implementing guests of guests for the 500 release. With guests of guests, this method could return a virtual guest as well.

Returns:
A Server object that represents the actual host

setHostSystem

public void setHostSystem(Server system)
Sets the parent/host for this guest.

Parameters:
system - The host system

isRegisteredGuest

public boolean isRegisteredGuest()
Returns true if this virtual instance represents a registered guest.

Returns:
true if this virtual instance represents a registered guest, false otherwise.

getName

public java.lang.String getName()
Returns the name of the virtual instance.

Returns:
The name of the virtual instance

setName

public void setName(java.lang.String name)
Set the name of the virtual instance.

Parameters:
name - The new name

getTotalMemory

public java.lang.Long getTotalMemory()
Returns the total memory in KB allocated to the virtual instance.

Returns:
The total memory in KB allocated to the virtual instance.

setTotalMemory

public void setTotalMemory(java.lang.Long memory)
Sets the total memory in KB allocated to the virtual instance.

Parameters:
memory - The total memory in KB

getNumberOfCPUs

public java.lang.Integer getNumberOfCPUs()
Returns the number of CPUs allocated to the virtual instance.

Returns:
The number of CPUs allocated to the virtual instance

setNumberOfCPUs

public void setNumberOfCPUs(java.lang.Integer number)
Sets the number of CPUs allocated to the virtual instance.

Parameters:
number - The number of CPUs

getType

public VirtualInstanceType getType()
Returns the virtualization type for this instance.

Returns:
The virtualization type for this instance.

setType

public void setType(VirtualInstanceType type)
Sets the virtualization type for this instance.

Parameters:
type - The new virtualization type

getState

public VirtualInstanceState getState()
Returns the state of the virtual instance.

Returns:
The state of the virtual instance.

setState

public void setState(VirtualInstanceState state)
Sets the state of the virtual instance.

Parameters:
state - The new state

equals

public boolean equals(java.lang.Object object)
Two virtual instancess are considered equal when they share the same UUID.

Overrides:
equals in class java.lang.Object
Parameters:
object - The object to test against
Returns:
true if object is a VirtualInstance and has the same uuid as this VirtualInstance, false otherwise.

hashCode

public int hashCode()

Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object

asGuestAndNonVirtHostView

public GuestAndNonVirtHostView asGuestAndNonVirtHostView()
An adapter method that transforms the virtual instance into a view.

Returns:
A GuestAndNonVirtHostView