Download the PHP package clivern/monkey without Composer
On this page you can find all versions of the php package clivern/monkey. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download clivern/monkey
More information about clivern/monkey
Files in clivern/monkey
Package monkey
Short Description Apache CloudStack SDK in PHP.
License MIT
Homepage https://github.com/clivern/monkey
Informations about the package monkey
Monkey
Apache CloudStack SDK in PHP.
Installation
To install the package via composer
, use the following:
This command requires you to have Composer installed globally.
CloudStack Simulator
Install Docker
To install docker on Ubuntu.
Then ensure that it is enabled to start after reboot:
Then Run CloudStack Simulator.
Usage
After adding the package as a dependency, Please read the following steps:
Configure CloudStack Credentials
Running Sync Calls
In order to run sync calls, Like creating a new user, you need to check cloudstack api to get the command and the required parameters. First lets create a call that will fail due to missing parametes and see the response data:
Now let's create a successful call:
Running Async Jobs
In case of async calls, we need to use another class called Job
to execute our caller(s). The Job
class can be exported as json encoded string and stored in database and reloaded again from the last state. This means that we can build a job that hold a lot of sync and async calls and the job class will continue every time we reload it and complete the main request.
Also Job
class can retry to run your caller(s) if it failed and once it succeeded, it will move to the next caller. and for sure you will provide the number of trials for each job or per each caller.
First let's create a job that will stop a virtual machine. This job needs to run at least two times, one to create the machine and another to check the job status. Since we don't use database to store job state, we will do this manually. But for sure in real world we will store job in database and run in background.
Also we can start the virtual machine again
Running Complex Jobs
If we want to run two calls but they are independent on each other, it is all about the order. We just need to run one then another like stop and start the virtual machine. In this case we will create two callers and create a job with the two callers like the following:
More Complex Usage
Let's make it more complex, Now we need to deploy a virtual server with these data:
- Template
CentOS 5.6 (64-bit) no GUI (Simulator)
- Service Offering:
Small Instance
- Zone:
Sandbox-simulator
And as you know from API we need the id of the template, service offering and zone. In this case we will create a separate callers to get these ids before we deploy the virtual server. and we will use response callbacks to store these ids in the caller shared data to be used by the job object.
Monkey on Production
Here I was trying to describe different usage cases of monkey but in case of production, we must have a database table(s) for our jobs and executer to run our jobs in background.
We will need custom request classes for each specific command so we don't need to provide command data every time we create a request.
We will need custom response classes for each specific command so we don't need to parse the response to fetch the useful response data and has a direct method to do that.
Also build our response callbacks for calls so when we use it, we will be sure that these data will be available for other callers within the job.
Usage as Command Line Tool
Create an executable file run
Misc
Changelog
Version 1.1.0:
Version 1.0.6:
Version 1.0.5:
Version 1.0.4:
Version 1.0.3:
Version 1.0.2:
Version 1.0.1:
Version 1.0.0:
Acknowledgements
© 2018, Clivern. Released under MIT License.
Monkey is authored and maintained by @clivern.