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:
    MorpheusCloudService, MorpheusNetworkService, MorpheusTaskService, MorpheusVirtualImageService, MorpheusServicePlanService, MorpheusPolicyService, MorpheusOperationNotificationService
    • Method Detail

      • 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

        MorpheusAsyncServices 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
        MorpheusCloudService 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
        MorpheusComputeSiteService 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
        MorpheusProvisionService 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
        MorpheusNetworkService 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
        MorpheusNetworkSubnetService 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
        MorpheusTaskService 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
        MorpheusIntegrationService 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
        MorpheusVirtualImageService 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
        MorpheusServicePlanService 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
        MorpheusComputeServerService 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
        MorpheusWorkloadService 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
      • getReport

        @Deprecated
        MorpheusReportService 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
        MorpheusOsTypeService getOsType()
        Deprecated.
        Returns the Os Type Service
        Returns:
        an instance of the Os Type Service
      • getCypher

        @Deprecated
        MorpheusCypherService getCypher()
        Deprecated.
        Returns the Cypher Service
        Returns:
        an instance of the Cypher Service
      • getPolicy

        @Deprecated
        MorpheusPolicyService getPolicy()
        Deprecated.
        Returns the Policy Service for Governance related Policy information.
        Returns:
        an instance of the Policy Service
      • getCosting

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

        @Deprecated
        MorpheusWebRequestService 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
        MorpheusWikiPageService getWikiPage()
        Deprecated.
        Returns the Wiki Page Service
        Returns:
        An instance of the Wiki Page Service
      • getStorageVolume

        @Deprecated
        MorpheusStorageVolumeService getStorageVolume()
        Deprecated.
        Returns the StorageVolume Service
        Returns:
        An instance of the StorageVolume Service
      • getStorageController

        @Deprecated
        MorpheusStorageControllerService getStorageController()
        Deprecated.
        Returns the StorageController Service
        Returns:
        An instance of the StorageController Service
      • getUsage

        @Deprecated
        MorpheusUsageService getUsage()
        Deprecated.
        Returns the Usage Service
        Returns:
        An instance of the Usage Service
      • getStats

        @Deprecated
        MorpheusStatsService getStats()
        Deprecated.
        Returns the Stats Service
        Returns:
        An instance of the Stats Service
      • getSettings

        io.reactivex.Single<java.lang.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
        MorpheusInstanceService getInstance()
        Deprecated.
        Returns the Instance Service
        Returns:
        An instance of the Instance Service
      • getApp

        @Deprecated
        MorpheusAppService getApp()
        Deprecated.
        Returns the App Service
        Returns:
        An instance of the App Service
      • getSnapshot

        @Deprecated
        MorpheusSnapshotService 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
        MorpheusBackupService 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
        MorpheusBackupJobService 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
        MorpheusProcessService getProcess()
        Deprecated.
        Returns the Process Service
        Returns:
        An instance of the MorpheusProcessService
      • getPermission

        @Deprecated
        MorpheusPermissionService getPermission()
        Deprecated.
        Returns the Permission Service
        Returns:
        An instance of the MorpheusPermissionService
      • getAccountCredentialType

        @Deprecated
        MorpheusAccountCredentialTypeService getAccountCredentialType()
        Deprecated.
        Returns the MorpheusAccountCredentialTypeService
        Returns:
        An instance of the MorpheusAccountCredentialTypeService
      • getAccountCredential

        @Deprecated
        MorpheusAccountCredentialService getAccountCredential()
        Deprecated.
        Returns the MorpheusAccountCredentialService
        Returns:
        An instance of the MorpheusAccountCredentialService
      • getKeyPair

        @Deprecated
        MorpheusKeyPairService 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
        MorpheusDashboardService getDashboard()
        Deprecated.
        Returns the MorpheusDashboardService
        Returns:
        An instance of the MorpheusDashboardService
      • getLoadBalancer

        @Deprecated
        MorpheusLoadBalancerService getLoadBalancer()
        Deprecated.
        Returns the MorpheusLoadBalancerService
        Returns:
        An instance of the MorpheusLoadBalancerService
      • getReferenceData

        @Deprecated
        MorpheusReferenceDataService getReferenceData()
        Deprecated.
        Returns the MorpheusReferenceDataService
        Returns:
        an instance of the MorpheusReferenceDataService
      • getBackupProvider

        @Deprecated
        MorpheusBackupProviderService getBackupProvider()
        Deprecated.
        Returns the MorpheusBackupProviderService
        Returns:
        an instance of the MorpheusBackupProviderService
      • getAccountPriceSet

        @Deprecated
        MorpheusAccountPriceSetService getAccountPriceSet()
        Deprecated.
        Returns the MorpheusAccountPriceSetService
        Returns:
        an instance of the MorpheusAccountPriceSetService
      • getAccountPrice

        @Deprecated
        MorpheusAccountPriceService getAccountPrice()
        Deprecated.
        Returns the MorpheusAccountPriceService
        Returns:
        an instance of the MorpheusAccountPriceService
      • getServicePlanPriceSet

        @Deprecated
        MorpheusServicePlanPriceSetService getServicePlanPriceSet()
        Deprecated.
        Returns the MorpheusServicePlanPriceSetService
        Returns:
        an instance of the MorpheusServicePlanPriceSetService
      • getAccountIntegration

        @Deprecated
        MorpheusAccountIntegrationService getAccountIntegration()
        Deprecated.
        Returns the MorpheusAccountIntegrationService
        Returns:
        an instance of the MorpheusAccountIntegrationService
      • getAccountInventory

        @Deprecated
        MorpheusAccountInventoryService getAccountInventory()
        Deprecated.
        Returns the MorpheusAccountInventoryService
        Returns:
        an instance of the MorpheusAccountInventoryService
      • executeSshCommand

        io.reactivex.Single<TaskResult> executeSshCommand​(java.lang.String address,
                                                          java.lang.Integer port,
                                                          java.lang.String username,
                                                          java.lang.String password,
                                                          java.lang.String command,
                                                          java.lang.String publicKey,
                                                          java.lang.String privateKey,
                                                          java.lang.String passPhrase,
                                                          java.lang.Boolean ignoreExitStatus,
                                                          LogLevel logLevel,
                                                          java.lang.Boolean doPty,
                                                          java.lang.String runAsUser,
                                                          java.lang.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.Single<TaskResult> executeWindowsCommand​(java.lang.String address,
                                                              java.lang.Integer port,
                                                              java.lang.String username,
                                                              java.lang.String password,
                                                              java.lang.String command,
                                                              java.lang.Boolean noProfile,
                                                              java.lang.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.Single<TaskResult> executeCommandOnWorkload​(Container container,
                                                                 java.lang.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.Single<TaskResult> executeCommandOnWorkload​(Container container,
                                                                 java.lang.String command,
                                                                 java.lang.String sshUsername,
                                                                 java.lang.String sshPassword,
                                                                 java.lang.String publicKey,
                                                                 java.lang.String privateKey,
                                                                 java.lang.String passPhrase,
                                                                 java.lang.Boolean noProfile,
                                                                 java.lang.String runAsUser,
                                                                 java.lang.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.Single<TaskResult> executeCommandOnServer​(ComputeServer server,
                                                               java.lang.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.Single<TaskResult> executeCommandOnServer​(ComputeServer server,
                                                               java.lang.String command,
                                                               java.lang.Boolean rpc,
                                                               java.lang.String sshUsername,
                                                               java.lang.String sshPassword,
                                                               java.lang.String publicKey,
                                                               java.lang.String privateKey,
                                                               java.lang.String passPhrase,
                                                               java.lang.Boolean noProfile,
                                                               java.lang.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
      • executeCommandOnServer

        io.reactivex.Single<TaskResult> executeCommandOnServer​(ComputeServer server,
                                                               java.lang.String command,
                                                               java.lang.Boolean rpc,
                                                               java.lang.String sshUsername,
                                                               java.lang.String sshPassword,
                                                               java.lang.String publicKey,
                                                               java.lang.String privateKey,
                                                               java.lang.String passPhrase,
                                                               java.lang.Boolean noProfile,
                                                               java.lang.Boolean sudo,
                                                               java.lang.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.Single<TaskConfig> buildInstanceConfig​(Instance instance,
                                                            java.util.Map baseConfig,
                                                            Task task,
                                                            java.util.Collection excludes,
                                                            java.util.Map opts)
      • buildContainerConfig

        io.reactivex.Single<TaskConfig> buildContainerConfig​(Container container,
                                                             java.util.Map baseConfig,
                                                             Task task,
                                                             java.util.Collection excludes,
                                                             java.util.Map opts)
      • buildComputeServerConfig

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

        io.reactivex.Single<java.lang.String> acquireLock​(java.lang.String name,
                                                          java.util.Map<java.lang.String,​java.lang.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.Single<java.lang.Boolean> releaseLock​(java.lang.String name,
                                                           java.util.Map<java.lang.String,​java.lang.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