com.novell.zos.jdl
Class ResourceInfo

java.lang.Object
  extended by com.novell.zos.jdl.GridObjectInfo
      extended by com.novell.zos.jdl.ResourceInfo

public class ResourceInfo
extends GridObjectInfo

ResourceInfo is a representation of a Resource Grid Object. This class inherits the base fact operations from GridObjectInfo and adds the provisioning operations for provisionable resources such as VMs. See MatrixInfo for how to script creation of Resource objects.

Example to retrieve an existing ResourceInfo and print the value of a fact.

      resource = getMatrix().getGridObject(TYPE_RESOURCE, "sles_lab1")
      print resource.getFact("resource.os.name")
 

Example to retrieve an existing ResourceInfo and initiate a provision operation on the Resource.

      vm = getMatrix().getGridObject(TYPE_RESOURCE, "winxpvm")
      vm.provision()
 


Field Summary
static java.lang.String TYPE_BM_INSTANCE
          resource.type value for a Bare metal resource
static java.lang.String TYPE_BM_TEMPLATE
          resource.type value for a Bare metal Template resource
static java.lang.String TYPE_FIXED_PHYSICAL
          resource.type value for a fixed physical resource
static java.lang.String TYPE_VM_INSTANCE
          resource.type value for a VM resource
static java.lang.String TYPE_VM_TEMPLATE
          resource.type value for a VM Template resource
 
Method Summary
 void applyConfig()
          Apply VM configuration to a provisioned resource.
 void build(BuildSpec buildSpec)
          Create a new provisionable resource using the supplied BuildSpec.
 void cancel()
          Cancel the current action on this resource.
 void check()
          Check and resync the state of this resource.
 void checkpoint(java.lang.String checkpointName)
          Create a checkpoint for a provisioned resource supplying a checkpoint name.
 ResourceInfo clone(java.lang.String newName)
          Create a copy of this Resource using the supplied name.
 ResourceInfo clone(VmSpec vmSpec)
          Create a copy of this Resource using the supplied VmSpec.
 ResourceInfo createTemplate(java.lang.String newName)
          Create a new Template resource from this resource using the supplied name.
 ResourceInfo createTemplate(VmSpec vmSpec)
          Create a new Template resource from this resource using the supplied VmSpec instance.
 GridObjectInfo createVdisk()
          Create a new Vdisk Grid Object attached to this VM resource.
 GridObjectInfo createVdisk(java.lang.String diskName)
          Create a new Vdisk Grid Object attached to this VM resource using supplied name.
 GridObjectInfo createVmHost(java.lang.String provisionAdapter)
          Create a new Vm Host Grid Object associated with this physical resource.
 GridObjectInfo createVmHostCluster(java.lang.String provisionAdapter)
          Create a new Vm Host Cluster Grid Object associated with this physical resource.
 GridObjectInfo createVnic()
          Create a new Vnic Grid Object associated with this VM resource.
 void destroy()
          Destroy this provisionable resource.
 org.python.core.PyList getProvisionedInstances()
          Return all provisioned instances of this resource.
 GridObjectInfo getVmHost(java.lang.String provisionAdapter)
          Retrieve an existing Vm Host Grid Object associated with this physical resource.
 GridObjectInfo getVmHostCluster(java.lang.String provisionAdapter)
          Retrieve an existing Vm Host Grid Object associated with this physical resource.
 void installAgent()
          Install an Agent on this provisionable resource.
 void installAgent(org.python.core.PyDictionary params)
          Install an Agent on this provisionable resource.
 void makeStandAlone()
          Remove dependencies from provisionable instance to a parent template.
 void migrate()
          Migrate this provisioned resource to another host.
 void migrate(MigrateSpec spec)
          Migrate this provisioned resource using options specified in the supplied MigrateSpec.
 void migrate(java.lang.String newHostName)
          Migrate this provisioned resource to the supplied host.
 void move(java.lang.String repository, java.lang.String host)
          Move the disk images for this VM to a new repository.
 void pause()
          Pause this provisioned resource.
 void personalize()
          Personalize (autoprep) a provisionable resource.
 ResourceInfo provision()
          Provision this resource for general use.
 ResourceInfo provision(ProvisionSpec provisionSpec)
          Provision this resource using the supplied ProvisionSpec instance.
 void rediscover()
          Rediscover PSO facts for a managed node.
 void restart()
          Restart this provisioned resource.
 void restart(boolean hard)
          Restart this provisioned resource.
 void restore()
          Restore a provisioned resource to a checkpoint.
 void restore(java.lang.String checkpointName)
          Restore a provisioned resource to a checkpoint.
 void resume()
          Resume a previously paused provisioned resource.
 void saveConfig()
          Save the VM configuration of a provisionable resource.
 void shutdown()
          Initiate a soft shutdown of this provisioned resource.
 void shutdown(boolean hard)
          Shutdown this provisioned resource.
 void shutdownAgent()
          Shutdown the agent on this resource if it is online.
 void suspend()
          Suspend this provisioned resource.
 void suspend(boolean hard)
          Suspend this provisioned resource.
 
Methods inherited from class com.novell.zos.jdl.GridObjectInfo
deleteFact, factExists, getFact, getFact, getFactLastModified, getFactNames, refresh, setArrayFact, setBooleanArrayFact, setDateArrayFact, setDateFact, setFact, setIntegerArrayFact, setRealArrayFact, setStringArrayFact, setTimeArrayFact, setTimeFact
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TYPE_FIXED_PHYSICAL

public static final java.lang.String TYPE_FIXED_PHYSICAL
resource.type value for a fixed physical resource

See Also:
Constant Field Values

TYPE_VM_INSTANCE

public static final java.lang.String TYPE_VM_INSTANCE
resource.type value for a VM resource

See Also:
Constant Field Values

TYPE_VM_TEMPLATE

public static final java.lang.String TYPE_VM_TEMPLATE
resource.type value for a VM Template resource

See Also:
Constant Field Values

TYPE_BM_TEMPLATE

public static final java.lang.String TYPE_BM_TEMPLATE
resource.type value for a Bare metal Template resource

See Also:
Constant Field Values

TYPE_BM_INSTANCE

public static final java.lang.String TYPE_BM_INSTANCE
resource.type value for a Bare metal resource

See Also:
Constant Field Values
Method Detail

shutdownAgent

public void shutdownAgent()
Shutdown the agent on this resource if it is online. Operation has no effect if agent is already offline.


provision

public ResourceInfo provision()
Provision this resource for general use. If this resource is a template, a new instance will be created.

Returns:
The ResourceInfo representing the provisioned instance
Throws:
java.lang.Exception - if this is not a provisionable resource or provisioning results in error

provision

public ResourceInfo provision(ProvisionSpec provisionSpec)
Provision this resource using the supplied ProvisionSpec instance. If this resource is a template, a new instance will be created.

Parameters:
provisionSpec - ProvisionSpec instance to use for provisioning
Returns:
The ResourceInfo representing the provisioned instance
Throws:
java.lang.Exception - if this is not a provisionable resource or provisioning results in error

getProvisionedInstances

public org.python.core.PyList getProvisionedInstances()
Return all provisioned instances of this resource.

Returns:
List of ResourceInfo objects

shutdown

public void shutdown()
Initiate a soft shutdown of this provisioned resource.

Throws:
java.lang.Exception - if this is not a provisioned resource instance or the shutdown is not possible at present

move

public void move(java.lang.String repository,
                 java.lang.String host)
Move the disk images for this VM to a new repository.

Parameters:
host - Host id to affiliate to
repository - to choose from host.
Throws:
java.lang.Exception - if error occurs in trying to affiliate

shutdown

public void shutdown(boolean hard)
Shutdown this provisioned resource. Optionally initiating a hard shutdown.

Parameters:
hard - true to initiate a hard shutdown, false to initiate a soft shutdown
Throws:
java.lang.Exception - if this is not a provisioned resource instance or the shutdown is not possible at present

suspend

public void suspend()
Suspend this provisioned resource.

Throws:
java.lang.Exception - if this is not a provisioned resource or error occurs in suspending

suspend

public void suspend(boolean hard)
Suspend this provisioned resource. Optionally initiating a hard shutdown.

Parameters:
hard - true to shutdown hard. false to try a soft shutdown
Throws:
java.lang.Exception - if this is not a provisioned resource or error occurs in suspending

pause

public void pause()
Pause this provisioned resource.

Throws:
java.lang.Exception - if this is not a provisioned resource or error occurs in pausing

resume

public void resume()
Resume a previously paused provisioned resource.

Throws:
java.lang.Exception - if this is not a provisioned resource or error occurs in resuming

personalize

public void personalize()
Personalize (autoprep) a provisionable resource.

Throws:
java.lang.Exception - if this is not a provisionable resource or error occurs in personalization

saveConfig

public void saveConfig()
Save the VM configuration of a provisionable resource.

Throws:
java.lang.Exception - if this is not a provisioned resource or error occurs in saving configuration

applyConfig

public void applyConfig()
Apply VM configuration to a provisioned resource.

Throws:
java.lang.Exception - if this is not a provisioned resource or error occurs in applying configuration

restart

public void restart()
Restart this provisioned resource.

Throws:
java.lang.Exception - if this is not a provisioned resource or error occurs in restarting

restart

public void restart(boolean hard)
Restart this provisioned resource. Optionally initiating a hard shutdown.

Parameters:
hard - true to shutdown hard. false to try a soft shutdown
Throws:
java.lang.Exception - if this is not a provisioned resource or error occurs in restarting

createTemplate

public ResourceInfo createTemplate(java.lang.String newName)
Create a new Template resource from this resource using the supplied name.

Parameters:
newName - Name of template resource to create
Throws:
java.lang.Exception - if this is not a createable resource or creation results in error

createTemplate

public ResourceInfo createTemplate(VmSpec vmSpec)
Create a new Template resource from this resource using the supplied VmSpec instance.

Parameters:
vmSpec - VmSpec instance defining new vm attributes
Throws:
java.lang.Exception - if this is not a createable resource or creation results in error

clone

public ResourceInfo clone(java.lang.String newName)
Create a copy of this Resource using the supplied name.

This only applies if this ResourceInfo is a template.

Parameters:
newName - Name of new resource to create
Throws:
java.lang.Exception - if this is not a cloneable resource or cloning results in error

clone

public ResourceInfo clone(VmSpec vmSpec)
Create a copy of this Resource using the supplied VmSpec.

This only applies if this ResourceInfo is a template.

Parameters:
vmSpec - VmSpec instance defining attributes for new Vm
Throws:
java.lang.Exception - if this is not a cloneable resource or cloning results in error

migrate

public void migrate()
Migrate this provisioned resource to another host.

Throws:
java.lang.Exception - if this resource cannot be migrated

migrate

public void migrate(java.lang.String newHostName)
Migrate this provisioned resource to the supplied host.

Parameters:
newHostName - Host to migrate this resource to
Throws:
java.lang.Exception - if this resource cannot be migrated

migrate

public void migrate(MigrateSpec spec)
Migrate this provisioned resource using options specified in the supplied MigrateSpec.

Parameters:
spec - Spec instance to use for supplying the migrate options
Throws:
java.lang.Exception - if this resource cannot be migrated

check

public void check()
Check and resync the state of this resource. If this is a provisioned resource, this will determine whether the resource is up or down or does not exist.


rediscover

public void rediscover()
Rediscover PSO facts for a managed node. If the referenced node no longer exists then the resource grid object may be removed.


destroy

public void destroy()
Destroy this provisionable resource.


cancel

public void cancel()
Cancel the current action on this resource.


checkpoint

public void checkpoint(java.lang.String checkpointName)
Create a checkpoint for a provisioned resource supplying a checkpoint name.

Parameters:
checkpointName - Name of new checkpoint if supported. can be null if only one checkpoint supported
Throws:
java.lang.Exception - if checkpoints are not supported or errors occur in checkpointing

restore

public void restore()
Restore a provisioned resource to a checkpoint.

Throws:
java.lang.Exception - if checkpoints are not supported or error occurs in restoring

restore

public void restore(java.lang.String checkpointName)
Restore a provisioned resource to a checkpoint.

Parameters:
checkpointName - Name of checkpoint. can be null if only one checkpoint supported
Throws:
java.lang.Exception - if checkpoints are not supported or error occurs in restoring

makeStandAlone

public void makeStandAlone()
Remove dependencies from provisionable instance to a parent template.

This allows the template to be removed from the system without affecting the instance.

Throws:
java.lang.Exception - is error occurs in operation

installAgent

public void installAgent()
Install an Agent on this provisionable resource. The new Agent will communicate with this server.

Throws:
java.lang.Exception - if installation is not supported or error occurred in installation.

installAgent

public void installAgent(org.python.core.PyDictionary params)
Install an Agent on this provisionable resource.

The new Agent will communicate with this server or the server specified in the params dictionary. The key value pairs supplied in the dictionary are the equivalent to the install command line -D options.

Parameters:
params - Dictionary of install settings used by agent installer. May be null.
Throws:
java.lang.Exception - if installation is not supported or error occurred in installation.

createVnic

public GridObjectInfo createVnic()
Create a new Vnic Grid Object associated with this VM resource.

This operation is not supported if this is a physical resource object.

Returns:
Vnic Grid Object representing the new Vnic.
Throws:
java.lang.Exception - if operation is not supported or error occurs in creation

createVdisk

public GridObjectInfo createVdisk()
Create a new Vdisk Grid Object attached to this VM resource.

Vdisk name will be generated.

This operation is not supported if this is a physical resource object.

Returns:
Vdisk Grid Object representing the new Vdisk.
Throws:
java.lang.Exception - if operation is not supported or error occurs in creation

createVdisk

public GridObjectInfo createVdisk(java.lang.String diskName)
Create a new Vdisk Grid Object attached to this VM resource using supplied name.

Vdisk name will be generated using the supplied name and qualified with the VM name.

This operation is not supported if this is a physical resource object.

Parameters:
diskName - Disk name to use for generating Grid Object ID
Returns:
Vdisk Grid Object representing the new Vdisk.
Throws:
java.lang.Exception - if operation is not supported or error occurs in creation

createVmHost

public GridObjectInfo createVmHost(java.lang.String provisionAdapter)
Create a new Vm Host Grid Object associated with this physical resource.

The supplied provisioning adapter job name is required for qualifying the name of the new Vm Host. This operation is not supported if this is not a physical resource object.

Parameters:
provisionAdapter - Name of provisioning adapter job. The supplied job must exist.
Returns:
Vm Host Grid Object representing the new Vm Host.
Throws:
java.lang.Exception - if operation is not supported or error occurs in creation

createVmHostCluster

public GridObjectInfo createVmHostCluster(java.lang.String provisionAdapter)
Create a new Vm Host Cluster Grid Object associated with this physical resource.

The supplied provisioning adapter job name is required for qualifying the name of the new Vm Host Cluster. This operation is not supported if this is not a physical resource object.

Parameters:
provisionAdapter - Name of provisioning adapter job. The supplied job must exist.
Returns:
Vm Host Cluster Grid Object representing the new Vm Host Cluster.
Throws:
java.lang.Exception - if operation is not supported or error occurs in creation

getVmHost

public GridObjectInfo getVmHost(java.lang.String provisionAdapter)
Retrieve an existing Vm Host Grid Object associated with this physical resource.

The supplied provisioning adapter job name is required for qualifying which Vm Host to retrieve. This operation is not supported if this is not a physical resource object.

Parameters:
provisionAdapter - Name of provisioning adapter job. The supplied job must exist.
Returns:
Vm Host Grid Object representing an existing Vm Host.
Throws:
java.lang.Exception - if operation is not supported or Vm host does not exist

getVmHostCluster

public GridObjectInfo getVmHostCluster(java.lang.String provisionAdapter)
Retrieve an existing Vm Host Grid Object associated with this physical resource.

The supplied provisioning adapter job name is required for qualifying which Vm Host to retrieve. This operation is not supported if this is not a physical resource object.

Parameters:
provisionAdapter - Name of provisioning adapter job. The supplied job must exist.
Returns:
Vm Host Grid Object representing an existing Vm Host.
Throws:
java.lang.Exception - if operation is not supported or Vm host does not exist

build

public void build(BuildSpec buildSpec)
Create a new provisionable resource using the supplied BuildSpec.

This function only applies to newly built Resource objects.
You must set required facts on this ResourceInfo for the building process.
Required ResourceInfo facts include:

build() executes asynchronously, so to receive notification in your job, you must implement provisioner_completed_event(),provisioner_cancelled_event(), provisioner_failed_event()

Parameters:
buildSpec - VmSpec instance defining new vm attributes
Throws:
java.lang.Exception - if this ResourceInfo is not correctly setup for building or an error occurs in building


Copyright (c) 2011 Novell, Inc. All rights reserved.