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)
See Also:
  • Method Details

    • getServices

      MorpheusServices 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.
    • 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.
    • getCloud

      Deprecated.
      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 CloudProvider implementations.
    • getComputeSite

      Deprecated.
      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 CloudProvider implementations.
    • getProvision

      Deprecated.
      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
    • getNetwork

      Deprecated.
      Returns the NetworkContext used for performing updates or queries on network related assets within Morpheus. Typically this would be called by a DNSProvider or IPAMProvider.
      Returns:
      An Instance of the Network Context to be used for calls by various network providers
    • getNetworkSubnet

      Deprecated.
      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
    • getTask

      Deprecated.
      Returns the Task context used for automation tasks on assets within Morpheus. Typically this would be called by a TaskProvider.
      Returns:
      An Instance of the Task Context to be used for calls by various task providers
    • getIntegration

      Deprecated.
      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
    • getVirtualImage

      Deprecated.
      Returns the VirtualImage context used for syncing Cloud images within Morpheus. Typically this would be called by a CloudProvider.
      Returns:
      An instance of the Virtual Image Context to be used for calls by various providers
    • getServicePlan

      Deprecated.
      Returns the Service Plan context used for syncing Cloud images within Morpheus. Typically this would be called by a CloudProvider.
      Returns:
      An instance of the Service Plan Context to be used for calls by various providers
    • getComputeServer

      Deprecated.
      Returns the Compute Server context used for syncing machines within Morpheus. Typically this would be called by a CloudProvider.
      Returns:
      An instance of the Compute Server Context to be used for calls by various providers
    • getWorkload

      Deprecated.
      Returns the workload context used for syncing workloads within Morpheus. Typically this would be called by a CloudProvider.
      Returns:
      An instance of the workload Context to be used for calls by various providers
    • getComputeTypeSet

      Deprecated.
      Returns the ComputeTypeSet context
      Returns:
    • getContainerType

      Deprecated.
      Returns the ContainerType context
      Returns:
    • getReport

      Deprecated.
      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
    • getOsType

      Deprecated.
      Returns the Os Type Service
      Returns:
      an instance of the Os Type Service
    • getCypher

      Deprecated.
      Returns the Cypher Service
      Returns:
      an instance of the Cypher Service
    • getPolicy

      Deprecated.
      Returns the Policy Service for Governance related Policy information.
      Returns:
      an instance of the Policy Service
    • getCosting

      Deprecated.
      Returns the Costing service and all related subservices for dealing with costing data.
      Returns:
      an instance of the Costing Service
    • getWebRequest

      Deprecated.
      Returns the Web Request Service. This is used by UI Providers to grab common request attributes
      Returns:
      an instance of the web request service
    • getOperationNotification

      MorpheusOperationNotificationService getOperationNotification()
      Deprecated.
      Returns the Operation Notification Service
      Returns:
      An instance of the Operation Notification Service
    • getMetadataTag

      MorpheusMetadataTagService getMetadataTag()
      Deprecated.
      Returns the Tag Service
      Returns:
      An instance of the Tag Service
    • getWikiPage

      Deprecated.
      Returns the Wiki Page Service
      Returns:
      An instance of the Wiki Page Service
    • getStorageVolume

      Deprecated.
      Returns the StorageVolume Service
      Returns:
      An instance of the StorageVolume Service
    • getStorageController

      Deprecated.
      Returns the StorageController Service
      Returns:
      An instance of the StorageController Service
    • getUsage

      Deprecated.
      Returns the Usage Service
      Returns:
      An instance of the Usage Service
    • getStats

      Deprecated.
      Returns the Stats Service
      Returns:
      An instance of the Stats Service
    • getSettings

      io.reactivex.rxjava3.core.Single<String> getSettings(Plugin plugin)
      Returns 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
    • getInstance

      Deprecated.
      Returns the Instance Service
      Returns:
      An instance of the Instance Service
    • getApp

      Deprecated.
      Returns the App Service
      Returns:
      An instance of the App Service
    • getSnapshot

      Deprecated.
      Returns the Snapshot service
      Returns:
      An instance of the Snapshot Service
    • getComputeTypeLayoutFactoryService

      MorpheusComputeTypeLayoutFactoryService getComputeTypeLayoutFactoryService()
      Returns the factory for generating ComputeTypeLayouts
      Returns:
      An instance of the ComputeTypeLayoutFactory
    • getBackup

      Deprecated.
      Returns the Backup Context for sync, executing and restoring backups Typically this would be called by a BackupProvider.
      Returns:
      an instance of the Backup Context
    • getBackupJob

      Deprecated.
      Returns the Backup Job Context for sync, executing and restoring backup jobs Typically this would be called by a BackupProvider.
      Returns:
      an instance of the Backup Job Context
    • getProcess

      Deprecated.
      Returns the Process Service
      Returns:
      An instance of the MorpheusProcessService
    • getPermission

      Deprecated.
      Returns the Permission Service
      Returns:
      An instance of the MorpheusPermissionService
    • getAccountCredentialType

      Deprecated.
      Returns the MorpheusAccountCredentialTypeService
      Returns:
      An instance of the MorpheusAccountCredentialTypeService
    • getAccountCredential

      Deprecated.
      Returns the MorpheusAccountCredentialService
      Returns:
      An instance of the MorpheusAccountCredentialService
    • getKeyPair

      Deprecated.
      Returns the MorpheusKeyPairService
      Returns:
      An instance of the MorpheusKeyPairService
    • getSecurityGroup

      MorpheusSecurityGroupService getSecurityGroup()
      Returns the SecurityGroup Service
      Returns:
      An instance of the SecurityGroup Service
    • getDashboard

      Deprecated.
      Returns the MorpheusDashboardService
      Returns:
      An instance of the MorpheusDashboardService
    • getLoadBalancer

      Deprecated.
      Returns the MorpheusLoadBalancerService
      Returns:
      An instance of the MorpheusLoadBalancerService
    • getReferenceData

      Deprecated.
      Returns the MorpheusReferenceDataService
      Returns:
      an instance of the MorpheusReferenceDataService
    • getBackupProvider

      Deprecated.
      Returns the MorpheusBackupProviderService
      Returns:
      an instance of the MorpheusBackupProviderService
    • getAccountPriceSet

      Deprecated.
      Returns the MorpheusAccountPriceSetService
      Returns:
      an instance of the MorpheusAccountPriceSetService
    • getAccountPrice

      Deprecated.
      Returns the MorpheusAccountPriceService
      Returns:
      an instance of the MorpheusAccountPriceService
    • getServicePlanPriceSet

      Deprecated.
      Returns the MorpheusServicePlanPriceSetService
      Returns:
      an instance of the MorpheusServicePlanPriceSetService
    • getAccountIntegration

      Deprecated.
      Returns the MorpheusAccountIntegrationService
      Returns:
      an instance of the MorpheusAccountIntegrationService
    • getAccountInventory

      Deprecated.
      Returns the MorpheusAccountInventoryService
      Returns:
      an instance of the MorpheusAccountInventoryService
    • getAccountInventoryType

      Deprecated.
      Returns the MorpheusAccountInventoryService
      Returns:
      an instance of the MorpheusAccountInventoryService
    • getCodeRepository

      Deprecated.
      Returns the MorpheusCodeRepositoryService
      Returns:
      an instance of the MorpheusCodeRepositoryService
    • getWorkspace

      Deprecated.
      Returns the MorpheusWorkspaceService
      Returns:
      an instance of the MorpheusWorkspaceService
    • getWorkspaceType

      Deprecated.
      Returns the MorpheusWorkspaceTypeService
      Returns:
      an instance of the MorpheusWorkspaceTypeService
    • getCodeRepositoryTrait

      Deprecated.
      Returns the MorpheusCodeRepositoryTraitService
      Returns:
      an instance of the MorpheusCodeRepositoryTraitService
    • getCodeRepositoryTraitType

      Deprecated.
      Returns the MorpheusCodeRepositoryTraitTypeService
      Returns:
      an instance of the MorpheusCodeRepositoryTraitTypeService
    • executeSshCommand

      io.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 LogLevel debug
      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
    • executeWindowsCommand

      io.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 –noprofile argument to PowerShell
      elevated - use elevated privileges
      Returns:
      A result object detailing the command execution
    • executeCommandOnWorkload

      io.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
    • executeCommandOnWorkload

      io.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 –noprofile argument 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
    • executeCommandOnServer

      io.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
    • executeCommandOnServer

      io.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 –noprofile argument to PowerShell
      sudo - execute the command with sudo permissions
      Returns:
      A result object detailing the command execution
    • queueUpgradeServerAgent

      void queueUpgradeServerAgent(Long serverId)
      Trigger an agent upgrade operation on a server
      Parameters:
      serverId - the ID of the ComputeServer object to initiate an agent upgrade on
      Since:
      1.1.6
    • executeCommandOnServer

      io.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 –noprofile argument to PowerShell
      sudo - execute the command with sudo permissions
      guestExec - execute the command with guest execution
      Returns:
      A result object detailing the command execution
    • buildInstanceConfig

      io.reactivex.rxjava3.core.Single<TaskConfig> buildInstanceConfig(Instance instance, Map baseConfig, Task task, Collection excludes, Map opts)
    • buildContainerConfig

      io.reactivex.rxjava3.core.Single<TaskConfig> buildContainerConfig(Container container, Map baseConfig, Task task, Collection excludes, Map opts)
    • buildWorkloadConfig

      io.reactivex.rxjava3.core.Single<TaskConfig> buildWorkloadConfig(Workload workload, Map baseConfig, Task task, Collection excludes, Map opts)
    • buildComputeServerConfig

      io.reactivex.rxjava3.core.Single<TaskConfig> buildComputeServerConfig(ComputeServer container, Map baseConfig, Task task, Collection excludes, Map opts)
    • acquireLock

      io.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 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]);
           }
       }
       
    • releaseLock

      io.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. 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
    • checkLock

      io.reactivex.rxjava3.core.Maybe<String> checkLock(String name, Map<String,Object> opts)
      Returns 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