Package com.morpheusdata.core
Interface MorpheusContext
public interface MorpheusContext
Provides a means to interact or query data from the main Morpheus application back into the various provider extensions
 It is important to note that most methods in the context are asynchronous and rely on RxJava based interfaces to
 present the ability for the implementation of the MorpheusContext to be disconnected from the core application.
 
The MorpheusContext typically provides getters for multiple services. These Service interfaces are useful for organizing calls to reduce the size of the individual Context Class
(i.e. a Connector app could implement the MorpheusContext and relay communication back to the Morpheus Application itself)- 
Method SummaryModifier and TypeMethodDescriptionio.reactivex.rxjava3.core.Single<String>acquireLock(String name, Map<String, Object> opts) Acquires a distributed lock by key and some additional lock options can be providedio.reactivex.rxjava3.core.Single<TaskConfig>buildComputeServerConfig(ComputeServer container, Map baseConfig, Task task, Collection excludes, Map opts) io.reactivex.rxjava3.core.Single<TaskConfig>buildContainerConfig(Container container, Map baseConfig, Task task, Collection excludes, Map opts) io.reactivex.rxjava3.core.Single<TaskConfig>buildInstanceConfig(Instance instance, Map baseConfig, Task task, Collection excludes, Map opts) io.reactivex.rxjava3.core.Single<TaskConfig>buildWorkloadConfig(Workload workload, Map baseConfig, Task task, Collection excludes, Map opts) io.reactivex.rxjava3.core.Maybe<String>Returns the unique lock key id for the specified lock key name if exists else null.io.reactivex.rxjava3.core.Single<TaskResult>executeCommandOnServer(ComputeServer server, String command) Execute a command on a server using the default connection detailsio.reactivex.rxjava3.core.Single<TaskResult>executeCommandOnServer(ComputeServer server, String command, Boolean rpc, String sshUsername, String sshPassword, String publicKey, String privateKey, String passPhrase, Boolean noProfile, Boolean sudo) Execute a command on a server using custom connection detailsio.reactivex.rxjava3.core.Single<TaskResult>executeCommandOnServer(ComputeServer server, String command, Boolean rpc, String sshUsername, String sshPassword, String publicKey, String privateKey, String passPhrase, Boolean noProfile, Boolean sudo, Boolean guestExec) Execute a command on a server using custom connection detailsio.reactivex.rxjava3.core.Single<TaskResult>executeCommandOnWorkload(Container container, String command) Execute a command on a Container or VM using the standard connection detailsio.reactivex.rxjava3.core.Single<TaskResult>executeCommandOnWorkload(Container container, String command, String sshUsername, String sshPassword, String publicKey, String privateKey, String passPhrase, Boolean noProfile, String runAsUser, Boolean sudo) Execute a command on a Container or VM using custom connection detailsio.reactivex.rxjava3.core.Single<TaskResult>executeSshCommand(String address, Integer port, String username, String password, String command, String publicKey, String privateKey, String passPhrase, Boolean ignoreExitStatus, LogLevel logLevel, Boolean doPty, String runAsUser, Boolean sudo) Execute an ssh commandio.reactivex.rxjava3.core.Single<TaskResult>executeWindowsCommand(String address, Integer port, String username, String password, String command, Boolean noProfile, Boolean elevated) Execute a command on a Windows machineDeprecated.Deprecated.Deprecated.Deprecated.Deprecated.Deprecated.Deprecated.getApp()Deprecated.getAsync()Gets references to all rxjava/async morpheus service calls.Deprecated.Deprecated.Deprecated.getCloud()Deprecated.Deprecated.Deprecated.Deprecated.Deprecated.Deprecated.Returns the factory for generating ComputeTypeLayoutsDeprecated.Deprecated.Deprecated.Deprecated.Deprecated.Deprecated.Deprecated.Deprecated.Deprecated.Deprecated.Deprecated.Deprecated.Deprecated.Deprecated.Deprecated.Deprecated.Deprecated.Deprecated.Deprecated.Deprecated.Returns the SecurityGroup ServiceDeprecated.Deprecated.Gets references to morpheus service calls for performing operations and/or queries within Morpheus.io.reactivex.rxjava3.core.Single<String>getSettings(Plugin plugin) Returns a json encoded string of the settings for the plugin requested.Deprecated.getStats()Deprecated.Deprecated.Deprecated.getTask()Deprecated.getUsage()Deprecated.Deprecated.Deprecated.Deprecated.Deprecated.Deprecated.Deprecated.voidqueueUpgradeServerAgent(Long serverId) Trigger an agent upgrade operation on a serverio.reactivex.rxjava3.core.Single<Boolean>releaseLock(String name, Map<String, Object> opts) Releases a lock key for other threads or nodes to be able to use it.
- 
Method Details- 
getServicesMorpheusServices getServices()Gets references to morpheus service calls for performing operations and/or queries within Morpheus. These services are the synchronous representations and wrap all services within the `MorpheusAsyncServices` class. This is useful when writing UI plugins or plugin sections that are probably blocking anyway.- Returns:
- references to all synchronous morpheus data services.
 
- 
getAsyncMorpheusAsyncServices getAsync()Gets references to all rxjava/async morpheus service calls. Most of these services will respond with `Observable` , `Single`, `Maybe`, or even `Completable` object types. These are most useful when performing high performance operations as in sync for various plugin types. These are also the same references as the original services and can be swapped in as the old service references are deprecated within the morpheusContext.- Returns:
- references to all the async morpheus data services.
 
- 
getCloudDeprecated.Returns the Compute Context used for performing updates or queries on compute related assets within Morpheus- Returns:
- An Instance of the Cloud Service to be used typically by CloudProviderimplementations.
 
- 
getComputeSiteDeprecated.Returns the ComputeSite Context used for performing updates or queries on compute related assets within Morpheus- Returns:
- An Instance of the ComputeSite Service to be used typically by CloudProviderimplementations.
 
- 
getProvisionDeprecated.Returns the Provision Service used for performing provisioning related updates to objects.- Returns:
- An Instance of the Provision Service to be used typically by a ProvisionProvider
 
- 
getNetworkDeprecated.Returns the NetworkContext used for performing updates or queries on network related assets within Morpheus. Typically this would be called by aDNSProviderorIPAMProvider.- Returns:
- An Instance of the Network Context to be used for calls by various network providers
 
- 
getNetworkSubnetDeprecated.Returns the NetworkSubnetContext used for performing updates or queries on network subnet related assets within Morpheus.- Returns:
- An Instance of the NetworkSubnet Context to be used for calls by various network providers
 
- 
getTaskDeprecated.Returns the Task context used for automation tasks on assets within Morpheus. Typically this would be called by aTaskProvider.- Returns:
- An Instance of the Task Context to be used for calls by various task providers
 
- 
getIntegrationDeprecated.Returns the Integration context used for performing common operations on varioues integration types Morpheus has to offer.- Returns:
- An instance of the Integration Context to bused for calls by various integration types
 
- 
getVirtualImageDeprecated.Returns the VirtualImage context used for syncing Cloud images within Morpheus. Typically this would be called by aCloudProvider.- Returns:
- An instance of the Virtual Image Context to be used for calls by various providers
 
- 
getServicePlanDeprecated.Returns the Service Plan context used for syncing Cloud images within Morpheus. Typically this would be called by aCloudProvider.- Returns:
- An instance of the Service Plan Context to be used for calls by various providers
 
- 
getComputeServerDeprecated.Returns the Compute Server context used for syncing machines within Morpheus. Typically this would be called by aCloudProvider.- Returns:
- An instance of the Compute Server Context to be used for calls by various providers
 
- 
getWorkloadDeprecated.Returns the workload context used for syncing workloads within Morpheus. Typically this would be called by aCloudProvider.- Returns:
- An instance of the workload Context to be used for calls by various providers
 
- 
getComputeTypeSetDeprecated.Returns the ComputeTypeSet context- Returns:
 
- 
getContainerTypeDeprecated.Returns the ContainerType context- Returns:
 
- 
getReportDeprecated.Returns the Custom Report Types Context used for generating custom reports. Typically this should only ever be used by a report provider as it may not be accessible in all other contexts.- Returns:
- an instance of the Report Service
 
- 
getOsTypeDeprecated.Returns the Os Type Service- Returns:
- an instance of the Os Type Service
 
- 
getCypherDeprecated.Returns the Cypher Service- Returns:
- an instance of the Cypher Service
 
- 
getPolicyDeprecated.Returns the Policy Service for Governance related Policy information.- Returns:
- an instance of the Policy Service
 
- 
getCostingDeprecated.Returns the Costing service and all related subservices for dealing with costing data.- Returns:
- an instance of the Costing Service
 
- 
getWebRequestDeprecated.Returns the Web Request Service. This is used by UI Providers to grab common request attributes- Returns:
- an instance of the web request service
 
- 
getOperationNotificationMorpheusOperationNotificationService getOperationNotification()Deprecated.Returns the Operation Notification Service- Returns:
- An instance of the Operation Notification Service
 
- 
getMetadataTagMorpheusMetadataTagService getMetadataTag()Deprecated.Returns the Tag Service- Returns:
- An instance of the Tag Service
 
- 
getWikiPageDeprecated.Returns the Wiki Page Service- Returns:
- An instance of the Wiki Page Service
 
- 
getStorageVolumeDeprecated.Returns the StorageVolume Service- Returns:
- An instance of the StorageVolume Service
 
- 
getStorageControllerDeprecated.Returns the StorageController Service- Returns:
- An instance of the StorageController Service
 
- 
getUsageDeprecated.Returns the Usage Service- Returns:
- An instance of the Usage Service
 
- 
getStatsDeprecated.Returns the Stats Service- Returns:
- An instance of the Stats Service
 
- 
getSettingsReturns a json encoded string of the settings for the plugin requested. The settings are defined by getSettings() on Plugin- Parameters:
- plugin- the Plugin to fetch the settings for
- Returns:
- a JSON encoded string representing the settings for the plugin
 
- 
getInstanceDeprecated.Returns the Instance Service- Returns:
- An instance of the Instance Service
 
- 
getAppDeprecated.Returns the App Service- Returns:
- An instance of the App Service
 
- 
getSnapshotDeprecated.Returns the Snapshot service- Returns:
- An instance of the Snapshot Service
 
- 
getComputeTypeLayoutFactoryServiceMorpheusComputeTypeLayoutFactoryService getComputeTypeLayoutFactoryService()Returns the factory for generating ComputeTypeLayouts- Returns:
- An instance of the ComputeTypeLayoutFactory
 
- 
getBackupDeprecated.Returns the Backup Context for sync, executing and restoring backups Typically this would be called by aBackupProvider.- Returns:
- an instance of the Backup Context
 
- 
getBackupJobDeprecated.Returns the Backup Job Context for sync, executing and restoring backup jobs Typically this would be called by aBackupProvider.- Returns:
- an instance of the Backup Job Context
 
- 
getProcessDeprecated.Returns the Process Service- Returns:
- An instance of the MorpheusProcessService
 
- 
getPermissionDeprecated.Returns the Permission Service- Returns:
- An instance of the MorpheusPermissionService
 
- 
getAccountCredentialTypeDeprecated.Returns the MorpheusAccountCredentialTypeService- Returns:
- An instance of the MorpheusAccountCredentialTypeService
 
- 
getAccountCredentialDeprecated.Returns the MorpheusAccountCredentialService- Returns:
- An instance of the MorpheusAccountCredentialService
 
- 
getKeyPairDeprecated.Returns the MorpheusKeyPairService- Returns:
- An instance of the MorpheusKeyPairService
 
- 
getSecurityGroupMorpheusSecurityGroupService getSecurityGroup()Returns the SecurityGroup Service- Returns:
- An instance of the SecurityGroup Service
 
- 
getDashboardDeprecated.Returns the MorpheusDashboardService- Returns:
- An instance of the MorpheusDashboardService
 
- 
getLoadBalancerDeprecated.Returns the MorpheusLoadBalancerService- Returns:
- An instance of the MorpheusLoadBalancerService
 
- 
getReferenceDataDeprecated.Returns the MorpheusReferenceDataService- Returns:
- an instance of the MorpheusReferenceDataService
 
- 
getBackupProviderDeprecated.Returns the MorpheusBackupProviderService- Returns:
- an instance of the MorpheusBackupProviderService
 
- 
getAccountPriceSetDeprecated.Returns the MorpheusAccountPriceSetService- Returns:
- an instance of the MorpheusAccountPriceSetService
 
- 
getAccountPriceDeprecated.Returns the MorpheusAccountPriceService- Returns:
- an instance of the MorpheusAccountPriceService
 
- 
getServicePlanPriceSetDeprecated.Returns the MorpheusServicePlanPriceSetService- Returns:
- an instance of the MorpheusServicePlanPriceSetService
 
- 
getAccountIntegrationDeprecated.Returns the MorpheusAccountIntegrationService- Returns:
- an instance of the MorpheusAccountIntegrationService
 
- 
getAccountInventoryDeprecated.Returns the MorpheusAccountInventoryService- Returns:
- an instance of the MorpheusAccountInventoryService
 
- 
getAccountInventoryTypeDeprecated.Returns the MorpheusAccountInventoryService- Returns:
- an instance of the MorpheusAccountInventoryService
 
- 
getCodeRepositoryDeprecated.Returns the MorpheusCodeRepositoryService- Returns:
- an instance of the MorpheusCodeRepositoryService
 
- 
getWorkspaceDeprecated.Returns the MorpheusWorkspaceService- Returns:
- an instance of the MorpheusWorkspaceService
 
- 
getWorkspaceTypeDeprecated.Returns the MorpheusWorkspaceTypeService- Returns:
- an instance of the MorpheusWorkspaceTypeService
 
- 
getCodeRepositoryTraitDeprecated.Returns the MorpheusCodeRepositoryTraitService- Returns:
- an instance of the MorpheusCodeRepositoryTraitService
 
- 
getCodeRepositoryTraitTypeDeprecated.Returns the MorpheusCodeRepositoryTraitTypeService- Returns:
- an instance of the MorpheusCodeRepositoryTraitTypeService
 
- 
executeSshCommandio.reactivex.rxjava3.core.Single<TaskResult> executeSshCommand(String address, Integer port, String username, String password, String command, String publicKey, String privateKey, String passPhrase, Boolean ignoreExitStatus, LogLevel logLevel, Boolean doPty, String runAsUser, Boolean sudo) Execute an ssh command- Parameters:
- address- internet address
- port- port number
- username- ssh username
- password- ssh password
- command- the command to be executed
- publicKey- public key as a String
- privateKey- private key as a string
- passPhrase- passphrase for- privateKey
- ignoreExitStatus- defaults to false. When enabled, marks the command execution as successful, regardless of exit code
- logLevel- defaults to- LogLeveldebug
- doPty- Allocate a Pseudo-Terminal
- runAsUser- specify a user to run the command as
- sudo- execute the command with sudo permissions
- Returns:
- A result object detailing the command execution
 
- 
executeWindowsCommandio.reactivex.rxjava3.core.Single<TaskResult> executeWindowsCommand(String address, Integer port, String username, String password, String command, Boolean noProfile, Boolean elevated) Execute a command on a Windows machine- Parameters:
- address- internet address
- port- port number
- username- connection username
- password- connection password
- command- the command to be executed
- noProfile- add a- ânoprofileargument to PowerShell
- elevated- use elevated privileges
- Returns:
- A result object detailing the command execution
 
- 
executeCommandOnWorkloadio.reactivex.rxjava3.core.Single<TaskResult> executeCommandOnWorkload(Container container, String command) Execute a command on a Container or VM using the standard connection details- Parameters:
- container- resource to execute on which to execute the command
- command- the command to be executed
- Returns:
- A result object detailing the command execution
 
- 
executeCommandOnWorkloadio.reactivex.rxjava3.core.Single<TaskResult> executeCommandOnWorkload(Container container, String command, String sshUsername, String sshPassword, String publicKey, String privateKey, String passPhrase, Boolean noProfile, String runAsUser, Boolean sudo) Execute a command on a Container or VM using custom connection details- Parameters:
- container- resource to execute on which to execute the command
- command- the command to be executed
- sshUsername- username
- sshPassword- password
- publicKey- public key as a String
- privateKey- private key as a String
- passPhrase- passphrase for- privateKey
- noProfile- for Windows VMs, add a- ânoprofileargument to PowerShell
- runAsUser- run the command as a specific user
- sudo- execute the command with sudo permissions
- Returns:
- A result object detailing the command execution
 
- 
executeCommandOnServerio.reactivex.rxjava3.core.Single<TaskResult> executeCommandOnServer(ComputeServer server, String command) Execute a command on a server using the default connection details- Parameters:
- server- server on which to execute the command
- command- the command to be executed
- Returns:
- A result object detailing the command execution
 
- 
executeCommandOnServerio.reactivex.rxjava3.core.Single<TaskResult> executeCommandOnServer(ComputeServer server, String command, Boolean rpc, String sshUsername, String sshPassword, String publicKey, String privateKey, String passPhrase, Boolean noProfile, Boolean sudo) Execute a command on a server using custom connection details- Parameters:
- server- server on which to execute the command
- command- the command to be executed
- rpc- when enabled, override the agent mode and execute over ssh/winrm
- sshUsername- username
- sshPassword- password
- publicKey- public key as a String
- privateKey- private key as a String
- passPhrase- passphrase for- privateKey
- noProfile- for Windows VMs, add a- ânoprofileargument to PowerShell
- sudo- execute the command with sudo permissions
- Returns:
- A result object detailing the command execution
 
- 
queueUpgradeServerAgentTrigger an agent upgrade operation on a server- Parameters:
- serverId- the ID of the- ComputeServerobject to initiate an agent upgrade on
- Since:
- 1.1.6
 
- 
executeCommandOnServerio.reactivex.rxjava3.core.Single<TaskResult> executeCommandOnServer(ComputeServer server, String command, Boolean rpc, String sshUsername, String sshPassword, String publicKey, String privateKey, String passPhrase, Boolean noProfile, Boolean sudo, Boolean guestExec) Execute a command on a server using custom connection details- Parameters:
- server- server on which to execute the command
- command- the command to be executed
- rpc- when enabled, override the agent mode and execute over ssh/winrm
- sshUsername- username
- sshPassword- password
- publicKey- public key as a String
- privateKey- private key as a String
- passPhrase- passphrase for- privateKey
- noProfile- for Windows VMs, add a- ânoprofileargument to PowerShell
- sudo- execute the command with sudo permissions
- guestExec- execute the command with guest execution
- Returns:
- A result object detailing the command execution
 
- 
buildInstanceConfigio.reactivex.rxjava3.core.Single<TaskConfig> buildInstanceConfig(Instance instance, Map baseConfig, Task task, Collection excludes, Map opts) 
- 
buildContainerConfigio.reactivex.rxjava3.core.Single<TaskConfig> buildContainerConfig(Container container, Map baseConfig, Task task, Collection excludes, Map opts) 
- 
buildWorkloadConfigio.reactivex.rxjava3.core.Single<TaskConfig> buildWorkloadConfig(Workload workload, Map baseConfig, Task task, Collection excludes, Map opts) 
- 
buildComputeServerConfigio.reactivex.rxjava3.core.Single<TaskConfig> buildComputeServerConfig(ComputeServer container, Map baseConfig, Task task, Collection excludes, Map opts) 
- 
acquireLockAcquires a distributed lock by key and some additional lock options can be provided- Parameters:
- name- the key name of the lock to acquire
- opts- the acquire wait timeout option via key [timeout:ms] as well as the locks ttl via [ttl:ms] property.
- Returns:
- a unique lock key id to control concurrent release attempts. send this to releaseLocks opts.lock key
 Example: String lockId try { lockId = morpheusContext.acquireLock('mylock.key',[ttl:600000L,timeout:600000L]); //do stuff } finally { if(lockId) { morpheusContext.releaseLock('mylock.key',[lock: lockId]); } }
 
- 
releaseLockReleases a lock key for other threads or nodes to be able to use it. It takes an optional set of opts that can be used to scope the lock release to a key hash for concurrency safety- Parameters:
- name- the key name of the lock to release
- opts- the opts map of wait timeouts or [lock:lockId] where the lockId is the return of- acquireLock(String, Map)
- Returns:
- the success state of the release lock attempt
 
- 
checkLockReturns the unique lock key id for the specified lock key name if exists else null. It takes an optional set of opts that can be used to scope the lock release to a key hash for concurrency safety- Parameters:
- name-
- opts-
- Returns:
- the unique lock key id to control concurrent release attempts. send this to releaseLocks opts.lock key
 
 
-