DataSift\Storyplayer\HostLib::getHostAdapter PHP Method

getHostAdapter() public static method

public static getHostAdapter ( StoryTeller $st, $hostType )
$st DataSift\Storyplayer\PlayerLib\StoryTeller
    public static function getHostAdapter($st, $hostType)
    {
        // what are we looking for?
        $className = 'DataSift\\Storyplayer\\HostLib\\' . $hostType;
        // does it exist?
        if (!class_exists($className)) {
            throw new E5xx_ActionFailed(__METHOD__, "cannot find class '{$className}' for host type '{$hostType}'");
        }
        // create the adapter
        $adapter = new $className($st);
        // all done
        return $adapter;
    }

Usage Example

示例#1
0
 public function createVm($vmName, $osName, $amiId, $instanceType, $securityGroup)
 {
     // what are we doing?
     $log = usingLog()->startAction("start EC2 VM '{$vmName}', running guest OS '{$osName}', using AMI ID '{$amiId}' and security group '{$securityGroup}'");
     // get the aws settings
     $awsSettings = fromConfig()->getModuleSetting('aws');
     // put the details into an array
     $vmDetails = new Ec2VmDetails();
     $vmDetails->hostId = $vmName;
     $vmDetails->environment = $this->st->getTestEnvironmentName();
     $vmDetails->osName = $osName;
     $vmDetails->amiId = $amiId;
     $vmDetails->type = 'Ec2Vm';
     $vmDetails->instanceType = $instanceType;
     $vmDetails->securityGroup = $securityGroup;
     $vmDetails->keyPairName = $awsSettings->ec2->keyPairName;
     $vmDetails->sshUsername = $awsSettings->ec2->sshUsername;
     $vmDetails->sshKeyFile = $awsSettings->ec2->sshKeyFile;
     $vmDetails->sshOptions = array("-i '" . $awsSettings->ec2->sshKeyFile . "'");
     $vmDetails->scpOptions = array("-i '" . $awsSettings->ec2->sshKeyFile . "'");
     // create our host adapter
     $host = HostLib::getHostAdapter($this->st, $vmDetails->type);
     // create our virtual machine
     $host->createHost($vmDetails);
     // all done
     $log->endAction();
 }
All Usage Examples Of DataSift\Storyplayer\HostLib::getHostAdapter