Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- *
- * @ This file is created by deZender.Net
- * @ deZender (PHP5 Decoder for ionCube Encoder)
- *
- * @ Version : 1.1.5.0
- * @ Author : DeZender
- * @ Release on : 09.06.2012
- * @ Official site : http://DeZender.Net
- *
- */
- require_once( MAINDIR . 'includes' . DS . 'libs' . DS . 'cloudstack' . DS . 'CloudStackClient.php' );
- require_once( MAINDIR . 'includes' . DS . 'libs' . DS . 'cloudstack' . DS . 'CloudStackAdmin.php' );
- class CloudStack extends VPSModule {
- var $onapp_tz = array( 'AX' => 'Europe/Minsk', 'AL' => 'CET', 'DZ' => 'CET', 'AS' => 'Pacific/Samoa', 'AD' => 'CET', 'AO' => 'CET', 'AI' => 'America/Santiago', 'AQ' => 'Asia/Taipei', 'AG' => 'America/Santiago', 'AR' => 'Etc/GMT+2', 'AW' => 'America/Santiago', 'AT' => 'CET', 'BS' => 'America/New_York', 'BH' => 'Africa/Nairobi', 'BB' => 'America/Santiago', 'BY' => 'Europe/Minsk', 'BE' => 'CET', 'BZ' => 'Canada/Saskatchewan', 'BJ' => 'CET', 'BM' => 'America/Santiago', 'BO' => 'America/Santiago', 'BA' => 'CET', 'BW' => 'Europe/Minsk', 'BR' => 'America/Montevideo', 'BN' => 'Asia/Taipei', 'BG' => 'Europe/Minsk', 'BI' => 'Europe/Minsk', 'CM' => 'CET', 'CA' => 'America/New_York', 'CV' => 'Atlantic/Cape_Verde', 'KY' => 'America/New_York', 'CF' => 'CET', 'TD' => 'CET', 'CL' => 'America/Montevideo', 'CN' => 'Asia/Taipei', 'CO' => 'America/New_York', 'KM' => 'Africa/Nairobi', 'CG' => 'CET', 'CD' => 'CET', 'CK' => 'Pacific/Honolulu', 'CR' => 'Canada/Saskatchewan', 'HR' => 'CET', 'CU' => 'America/New_York', 'CY' => 'Europe/Minsk', 'CZ' => 'CET', 'DK' => 'CET', 'DJ' => 'Africa/Nairobi', 'DM' => 'America/Santiago', 'DO' => 'America/Santiago', 'EC' => 'America/New_York', 'EG' => 'Europe/Minsk', 'SV' => 'Canada/Saskatchewan', 'GQ' => 'CET', 'ER' => 'Africa/Nairobi', 'EE' => 'Europe/Minsk', 'ET' => 'Africa/Nairobi', 'FK' => 'America/Montevideo', 'FJ' => 'Pacific/Auckland', 'FI' => 'Europe/Minsk', 'FR' => 'CET', 'GF' => 'America/Montevideo', 'PF' => 'US/Alaska', 'TF' => 'Asia/Karachi', 'GA' => 'CET', 'DE' => 'CET', 'GI' => 'CET', 'GR' => 'Europe/Minsk', 'GD' => 'America/Santiago', 'GP' => 'America/Santiago', 'GU' => 'Pacific/Guam', 'GT' => 'Canada/Saskatchewan', 'GY' => 'America/Santiago', 'HT' => 'America/New_York', 'VA' => 'CET', 'HN' => 'Canada/Saskatchewan', 'HK' => 'Asia/Taipei', 'HU' => 'CET', 'IN' => 'Asia/Bangkok', 'IQ' => 'Africa/Nairobi', 'IL' => 'Europe/Minsk', 'IT' => 'CET', 'JM' => 'America/New_York', 'JP' => 'Asia/Seoul', 'JO' => 'Europe/Minsk', 'KE' => 'Africa/Nairobi', 'KR' => 'Asia/Seoul', 'KW' => 'Africa/Nairobi', 'LV' => 'Europe/Minsk', 'LB' => 'Europe/Minsk', 'LS' => 'Europe/Minsk', 'LY' => 'Europe/Minsk', 'LI' => 'CET', 'LT' => 'Europe/Minsk', 'LU' => 'CET', 'MO' => 'Asia/Taipei', 'MK' => 'CET', 'MG' => 'Africa/Nairobi', 'MW' => 'Europe/Minsk', 'MY' => 'Asia/Taipei', 'MV' => 'Asia/Karachi', 'MT' => 'CET', 'MH' => 'Pacific/Auckland', 'MQ' => 'America/Santiago', 'MU' => 'Asia/Karachi', 'YT' => 'Africa/Nairobi', 'MX' => 'Canada/Saskatchewan', 'MD' => 'Europe/Minsk', 'MC' => 'CET', 'MN' => 'Asia/Taipei', 'ME' => 'CET', 'MS' => 'America/Santiago', 'MZ' => 'Europe/Minsk', 'NA' => 'Europe/Minsk', 'NR' => 'Pacific/Auckland', 'NL' => 'CET', 'AN' => 'America/Santiago', 'NI' => 'Canada/Saskatchewan', 'NE' => 'CET', 'NG' => 'CET', 'NU' => 'Pacific/Samoa', 'MP' => 'Pacific/Guam', 'NO' => 'CET', 'PK' => 'Asia/Karachi', 'PW' => 'Asia/Seoul', 'PS' => 'Europe/Minsk', 'PA' => 'America/New_York', 'PG' => 'Pacific/Guam', 'PY' => 'America/Montevideo', 'PE' => 'America/New_York', 'PH' => 'Asia/Taipei', 'PN' => 'Mexico/BajaNorte', 'PL' => 'CET', 'PT' => 'Atlantic/Cape_Verde', 'PR' => 'America/Santiago', 'QA' => 'Africa/Nairobi', 'RO' => 'Europe/Minsk', 'RU' => 'Pacific/Auckland', 'RW' => 'Europe/Minsk', 'BL' => 'America/Santiago', 'KN' => 'America/Santiago', 'LC' => 'America/Santiago', 'MF' => 'America/Santiago', 'PM' => 'America/Montevideo', 'VC' => 'America/Santiago', 'WS' => 'Pacific/Samoa', 'SM' => 'CET', 'SA' => 'Africa/Nairobi', 'RS' => 'CET', 'SG' => 'Asia/Taipei', 'SK' => 'CET', 'SI' => 'CET', 'SO' => 'Africa/Nairobi', 'ZA' => 'Europe/Minsk', 'GS' => 'Etc/GMT+2', 'ES' => 'CET', 'LK' => 'Asia/Bangkok', 'SD' => 'Africa/Nairobi', 'SR' => 'America/Montevideo', 'SJ' => 'CET', 'SZ' => 'Europe/Minsk', 'SE' => 'CET', 'CH' => 'CET', 'SY' => 'Europe/Minsk', 'TW' => 'Asia/Taipei', 'TJ' => 'Asia/Karachi', 'TZ' => 'Africa/Nairobi', 'TL' => 'Asia/Seoul', 'TK' => 'Pacific/Honolulu', 'TT' => 'America/Santiago', 'TN' => 'CET', 'TR' => 'Europe/Minsk', 'TM' => 'Asia/Karachi', 'TC' => 'America/New_York', 'TV' => 'Pacific/Auckland', 'UG' => 'Africa/Nairobi', 'UA' => 'Europe/Minsk', 'US' => 'Canada/Saskatchewan', 'UM' => 'Pacific/Honolulu', 'UY' => 'Etc/GMT+2', 'UZ' => 'Asia/Karachi', 'VG' => 'America/Santiago', 'VI' => 'America/Santiago', 'WF' => 'Pacific/Auckland', 'YE' => 'Africa/Nairobi', 'ZM' => 'Europe/Minsk', 'ZW' => 'Europe/Minsk' );
- private $version = '3.0.x.20121026';
- private $description = 'CloudStack provisioning module, learn more at http://hostbillapp.com/features/apps/cloudstack.html <br/><br/>
- For metered (hourly) billing to work your Cloudstack needs to have usage server running + daily task needs to be added (Settings->Task list)';
- var $serverTemplates = array( );
- private $serverFields = array( 'ssl' => true, 'maxaccounts' => false, 'status_url' => false, 'hash' => true, 'password' => false, 'field1' => true );
- private $serverFieldsDescription = array( 'username' => 'API Key', 'hash' => 'Secret Key', 'field1' => 'API port (default 8080)' );
- private $cache = array( );
- private $url = null;
- private $api_key = null;
- private $api_secret = null;
- private $connect_data = null;
- protected $admin_api = null;
- protected $client_api = null;
- private $vm_details = array( );
- private $cleanup = array( );
- private $lang = array( 'english' => array( 'OnAPPcrtype' => 'Signups of current client' ) );
- private $options = array( 'option30' => array( 'name' => 'networking type', 'value' => 'Basic', 'type' => 'select', 'default' => array( 0 => 'Basic', 1 => 'Advanced' ) ), 'option31' => array( 'name' => 'adv networking type', 'value' => 'a3', 'type' => 'select', 'default' => array( 0 => 'a1', 1 => 'a2', 2 => 'a3' ) ), 'option10' => array( 'name' => 'provtype', 'value' => 'Multiple Machines, full management', 'type' => 'select', 'default' => array( 0 => 'Multiple Machines, full management', 1 => 'Single Machine, autocreation' ) ), 'option3' => array( 'name' => 'mem_limit', 'value' => false, 'type' => 'input', 'variable' => 'memory', 'description' => 'Slider available: <a href="http://hostbillapp.com/fastconfig/forms/#onapp" target="_blank">learn more</a>' ), 'option4' => array( 'name' => 'cpu_limit', 'value' => false, 'type' => 'input', 'variable' => 'cpu', 'description' => 'Slider available: <a href="http://hostbillapp.com/fastconfig/forms/#onapp" target="_blank">learn more</a>' ), 'option5' => array( 'name' => 'cpu_share', 'value' => false, 'type' => 'input', 'variable' => 'cpu_share', 'description' => 'Slider available: <a href="http://hostbillapp.com/fastconfig/forms/#onapp" target="_blank">learn more</a>' ), 'option6' => array( 'name' => 'disk_size', 'value' => false, 'type' => 'input', 'variable' => 'disk_size', 'description' => 'Slider available: <a href="http://hostbillapp.com/fastconfig/forms/#onapp" target="_blank">learn more</a>' ), 'option9' => array( 'name' => 'pspeed', 'value' => false, 'type' => 'input', 'variable' => 'rate', 'description' => 'Slider available: <a href="http://hostbillapp.com/fastconfig/forms/#onapp" target="_blank">learn more</a>' ), 'option13' => array( 'name' => 'iplimit', 'value' => '1', 'type' => 'input', 'description' => 'Slider available: <a href="http://hostbillapp.com/fastconfig/forms/#onapp" target="_blank">learn more</a>', 'variable' => 'ip_address', 'default' => '1' ), 'option14' => array( 'name' => 'vmlimit', 'value' => '1', 'type' => 'input', 'default' => '1' ), 'option15' => array( 'name' => 'btlimit', 'value' => '1', 'type' => 'input', 'default' => '1' ), 'option16' => array( 'name' => 'tlimit', 'value' => '', 'type' => 'input', 'default' => '', 'description' => 'Slider available: <a href="http://hostbillapp.com/fastconfig/forms/#onapp" target="_blank">learn more</a>', 'variable' => 'datasent' ), 'option12' => array( 'name' => 'ost', 'value' => '', 'type' => 'input', 'variable' => 'os', 'description' => 'Allow to choose by client using <a href="#" onclick="$(\'#loadostemplates\').click();">Forms:Os</a>', 'default' => 'getOSTemplates' ), 'option22' => array( 'name' => 'networkzone', 'value' => array( 0 => 'Auto-Assign' ), 'type' => 'select', 'default' => array( 0 => 'Auto-Assign' ) ), 'option23' => array( 'name' => 'hypervisorzone', 'variable' => 'hypervisorzone', 'value' => array( 0 => 'Auto-Assign' ), 'type' => 'select', 'default' => array( 0 => 'Auto-Assign' ) ), 'offerha' => array( 'name' => 'OfferHa', 'variable' => 'offerha', 'value' => 0, 'type' => 'checkbox', 'default' => 0 ), 'primarystorage' => array( 'name' => 'primarystorage', 'variable' => 'primarystorage', 'value' => array( 0 => 'shared:Auto-Assign' ), 'type' => 'checkbox', 'default' => array( 0 => 'shared:Auto-Assign' ) ) );
- private $details = array( 'option1' => array( 'name' => 'username', 'value' => false, 'type' => 'input', 'default' => false ), 'option4' => array( 'name' => 'domain', 'value' => false, 'type' => 'input', 'default' => false ), 'option2' => array( 'name' => 'password', 'value' => false, 'type' => 'input', 'default' => false ), 'option5' => array( 'name' => 'rootpassword', 'value' => false, 'type' => 'hidden', 'default' => false ), 'option7' => array( 'name' => 'api_key', 'value' => false, 'type' => 'hidden', 'default' => false ), 'option8' => array( 'name' => 'secret_key', 'value' => false, 'type' => 'hidden', 'default' => false ), 'option9' => array( 'name' => 'account_id', 'value' => false, 'type' => 'hidden', 'default' => false ), 'option10' => array( 'name' => 'domain_id', 'value' => false, 'type' => 'hidden', 'default' => false ) );
- private $commands = array( 0 => 'Suspend', 1 => 'Terminate', 2 => 'Create', 3 => 'Unsuspend', 4 => 'ChangePackage' );
- function install() {
- }
- function upgrade(&$old_version) {
- $old = explode( '.', $old_version );
- if (( isset( $old[3] ) && (int)$old[3] < 20120806 )) {
- $task = 'custom:' . $this->id . ':call_Daily';
- $conf = array( 'name' => 'Module - ' . $this->getModName( ) . ', daily cron call', 'run_every' => 'Time' );
- $automation = HBLoader::loadmodel( 'Configuration/AutomationSettings' );
- $automation->addCronTask( $task, $conf );
- return null;
- }
- if (( isset( $old[3] ) && (int)$old[3] < 20121026 )) {
- $this->db->exec( 'UPDATE hb_mettered_variables mv
- JOIN hb_products p ON p.id=mv.product_id
- JOIN hb_products_modules pm ON pm.product_id=p.id
- JOIN hb_modules_configuration m ON m.id=pm.module
- SET mv.unit_name= \'Hour\'
- WHERE m.filename=\'class.cloudstack.php\' AND mv.name IN (\'Snapshot\',\'Template\',\'Volume\',\'Public IP address\')' );
- }
- }
- function connect($connect) {
- if ($connect['secure']) {
- $this->url = 'https://';
- } else {
- $this->url = 'http://';
- }
- $this->url = $this->url . (( !$connect['ip'] && $connect['host'] ) ? $connect['host'] : $connect['ip']);
- if ($connect['field1']) {
- $this->url .= ':' . $connect['field1'];
- } else {
- $this->url .= ':8080';
- }
- $this->url .= '/client/api';
- $this->api_key = $connect['username'];
- $this->api_secret = $connect['hash'];
- $this->connect_data = $connect;
- return $connect;
- }
- function adminApi($result = 'object') {
- if (is_null( $this->admin_api )) {
- $this->admin_api = new CloudStackAdmin( $this->url, $this->api_key, $this->api_secret );
- }
- $this->admin_api->setResponseMethod( $result );
- return $this->admin_api;
- }
- function dropApi() {
- $this->admin_api = null;
- $this->client_api = null;
- }
- function clientApi($result = 'object') {
- if (is_null( $this->client_api )) {
- $this->client_api = new CloudStackClient( $this->url, $this->details['option7']['value'], $this->details['option8']['value'] );
- }
- $this->client_api->setResponseMethod( $result );
- return $this->client_api;
- }
- function queryAsyncJob($api, $job, &$timelimit = 10) {
- if (is_object( $job )) {
- $job = (array)$job;
- }
- if (empty( $job['jobid'] )) {
- if (isset( $job['errortext'] )) {
- $this->addError( $job['errortext'] );
- }
- return false;
- }
- $begin = time( );
- while (time( ) < $begin + $timelimit) {
- $job = (array)$api->queryAsyncJobResult( $job['jobid'] );
- if (( !isset( $job['jobstatus'] ) && $job['errortext'] )) {
- return false;
- }
- if ($job['jobstatus'] == '1') {
- return $job['jobresult'];
- }
- if ($job['jobstatus'] == '2') {
- return false;
- }
- sleep( 1 );
- }
- return true;
- }
- .............................................................
- .........................
- .........
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement