function __construct($id) { global $sql, $aeskey; $this->uniqueHex = dechex(mt_rand()); $query = $sql->prepare("SELECT *,AES_DECRYPT(`port`,:aeskey) AS `decryptedport`,AES_DECRYPT(`user`,:aeskey) AS `decrypteduser`,AES_DECRYPT(`pass`,:aeskey) AS `decryptedpass`,AES_DECRYPT(`steamAccount`,:aeskey) AS `decryptedsteamAccount`,AES_DECRYPT(`steamPassword`,:aeskey) AS `decryptedsteamPassword` FROM `rserverdata` WHERE `id`=:serverID LIMIT 1"); $query->execute(array(':serverID' => $id, ':aeskey' => $aeskey)); while ($row = $query->fetch(PDO::FETCH_ASSOC)) { $this->appMasterServerDetails['id'] = (int) $id; $this->appMasterServerDetails['notified'] = (int) $row['notified']; $this->appMasterServerDetails['ssh2IP'] = (string) $row['ip']; $this->appMasterServerDetails['ssh2Port'] = (int) $row['decryptedport']; $this->appMasterServerDetails['ssh2User'] = (string) $row['decrypteduser']; $this->appMasterServerDetails['ssh2Publickey'] = (string) $row['publickey']; $this->appMasterServerDetails['ssh2DecryptedPass'] = (string) $row['decryptedpass']; $this->appMasterServerDetails['ssh2KeyName'] = (string) $row['keyname']; $this->appMasterServerDetails['ftpPort'] = (string) $row['ftpport']; $this->appMasterServerDetails['os'] = (string) $row['os']; $this->appMasterServerDetails['iniVars'] = @parse_ini_string($row['install_paths'], true); # https://github.com/easy-wi/developer/issues/70 $this->appMasterServerDetails['privateKey'] = EASYWIDIR . '/keys/' . removePub($this->appMasterServerDetails['ssh2KeyName']); $this->appMasterServerDetails['quotaActive'] = $row['quota_active']; $this->appMasterServerDetails['quotaCmd'] = $row['quota_cmd']; $this->appMasterServerDetails['repquotaCmd'] = $row['repquota_cmd']; $this->appMasterServerDetails['blocksize'] = $row['blocksize']; $this->appMasterServerDetails['inodeBlockRatio'] = $row['inode_block_ratio']; $this->appMasterServerDetails['configBadFiles'] = preg_split('/,/', $row['config_bad_files'], -1, PREG_SPLIT_NO_EMPTY); $this->appMasterServerDetails['configBadTime'] = (int) $row['config_bad_time']; $this->appMasterServerDetails['configBinaries'] = preg_split('/,/', $row['config_binaries'], -1, PREG_SPLIT_NO_EMPTY); $this->appMasterServerDetails['configDemoTime'] = (int) $row['config_demo_time']; $this->appMasterServerDetails['configFiles'] = preg_split('/,/', $row['config_files'], -1, PREG_SPLIT_NO_EMPTY); $this->appMasterServerDetails['configIonice'] = (string) $row['config_ionice']; $this->appMasterServerDetails['configLogTime'] = (int) $row['config_log_time']; $this->appMasterServerDetails['configUserID'] = $row['config_user_id'] > 0 ? (int) $row['config_user_id'] : 1000; $this->appMasterServerDetails['configZtmpTime'] = (int) $row['config_ztmp_time']; if ($this->appMasterServerDetails['os'] == 'L') { $this->shellScriptHeader = "#!/bin/bash\n"; $this->shellScriptHeader .= "if ionice -c3 true 2>/dev/null; then IONICE='ionice -n 7 '; fi\n"; $this->shellScripts['user'] = $this->shellScriptHeader . 'rm -f /home/' . $this->appMasterServerDetails['ssh2User'] . '/temp/userCud-' . $this->uniqueHex . '.sh' . "\n"; } } return $query->rowCount() > 0 ? true : false; }
function __construct($rootID, $aeskey) { // fetch global PDO object global $sql; $this->aeskey = $aeskey; // store the rootserverID $this->rootID = $rootID; // fetch rootserverdata $query = $sql->prepare("SELECT *,AES_DECRYPT(`port`,:aeskey) AS `dport`,AES_DECRYPT(`user`,:aeskey) AS `duser`,AES_DECRYPT(`pass`,:aeskey) AS `dpass`,AES_DECRYPT(`steamAccount`,:aeskey) AS `steamAcc`,AES_DECRYPT(`steamPassword`,:aeskey) AS `steamPwd` FROM `rserverdata` WHERE `id`=:id LIMIT 1"); $query->execute(array(':aeskey' => $aeskey, ':id' => $rootID)); while ($row = $query->fetch(PDO::FETCH_ASSOC)) { $active = $row['active']; $this->rootNotifiedCount = $row['notified']; $this->sship = $row['ip']; $this->sshport = $row['dport']; $this->sshuser = $row['duser']; $this->sshpass = $row['dpass']; $this->publickey = $row['publickey']; $this->keyname = EASYWIDIR . '/keys/' . removePub($row['keyname']); $this->steamAccount = $row['steamAcc']; $this->steamPassword = $row['steamPwd']; $this->resellerID = $row['resellerid']; $this->updates = $row['updates']; $this->os = $row['os']; $this->masterserverDir = '/home/' . $row['duser'] . '/masterserver/'; } // In case the rootserver could be found and it is active return true if (isset($active) and $active == 'Y') { $this->rootOK = true; $this->getWebHost(); $this->getImageServer(); if ($this->os == 'L') { $this->startShellScript(); } } else { $this->rootOK = false; } }
function tsdns($action, $sship, $sshport, $sshuser, $keyuse, $sshkey, $sshpw, $notified, $path, $bitversion, $tsip, $tsport, $tsdns, $reseller_id, $maxnotified = 2) { global $sql; $sshSftpObject = new Net_SFTP($sship, $sshport); if ($keyuse != 'N') { $privateKey = EASYWIDIR . '/keys/' . removePub($sshkey); $sshpw = new Crypt_RSA(); if ($keyuse == 'B') { $sshpw->setPassword($sshpw); } $keyContent = @file_get_contents($privateKey); if ($keyContent) { $sshpw->loadKey($keyContent); } } if ($sshSftpObject->login($sshuser, $sshpw)) { $split_config = preg_split('/\\//', $path, -1, PREG_SPLIT_NO_EMPTY); $folderfilecount = count($split_config) - 1; $i = 0; $folders = substr($path, 0, 1) == '/' ? '/' : ''; $lastFolder = ''; while ($i <= $folderfilecount) { $folders .= $split_config[$i] . '/'; $lastFolder = $split_config[$i]; $i++; } if ($lastFolder != 'tsdns' or substr($path, 0, 1) != '/') { $folders .= 'tsdns/'; } if ($action == 'md' or $action == 'dl') { $newip = $tsip[0]; $oldip = isset($tsip[1]) ? $tsip[1] : ''; $newport = $tsport[0]; $oldport = isset($tsport[1]) ? $tsport[1] : ''; $newdns = $tsdns[0]; $olddns = isset($tsdns[1]) ? $tsdns[1] : ''; } else { $dnsarray = array(); } $file = substr($path, 0, 1) == '/' ? $folders . 'tsdns_settings.ini' : '/home/' . $sshuser . '/' . $folders . 'tsdns_settings.ini'; if ($action != 'rs') { $data = $sshSftpObject->get($file); $data = str_replace(array("", "\\b", "\r", "\\Z"), '', $data); } if ($action != 'rs' and $action != 'mw') { $edited = false; $ca = array(); foreach (preg_split('/\\n/', $data, -1, PREG_SPLIT_NO_EMPTY) as $configLine) { if ($action != 'li' and $configLine != $olddns . '=' . $oldip . ':' . $oldport and $configLine != $newdns . '=' . $newip . ':' . $newport) { $ca[] = $configLine . "\r\n"; } else { if ($action == 'md' and $edited == false and ($configLine == $olddns . '=' . $oldip . ':' . $oldport or $configLine == $newdns . '=' . $newip . ':' . $newport)) { $edited = true; $ca[] = $newdns . '=' . $newip . ':' . $newport . "\r\n"; } } if ($action == 'li' and $configLine != '' and !preg_match('/^#(|\\s+)(.*)$/', $configLine)) { $dnsconfig = explode('=', $configLine); if (isset($dnsconfig[1])) { $linedns = $dnsconfig[0]; $lineserver = $dnsconfig[1]; $dnsarray[$lineserver] = $linedns; } } } if ($action == 'md' and $edited == false) { $ca[] = $newdns . '=' . $newip . ':' . $newport . "\r\n"; } if ($action != 'li') { $ca = array_unique($ca); sort($ca); $newcfg = ''; foreach ($ca as $line) { $newcfg .= $line; } if ($newcfg == '') { $newcfg = '# No TSDNS data entered'; } $sshSftpObject->put($file, $newcfg); } } if ($action == 'mw' and isset($data)) { $usedIPs = array(); foreach (preg_split('/\\n/', $data, -1, PREG_SPLIT_NO_EMPTY) as $configLine) { if ($configLine != '' and !preg_match('/^#(|\\s+)(.*)$/', $configLine)) { $splittedLine = preg_split('/\\=/', $configLine, -1, PREG_SPLIT_NO_EMPTY); $usedIPs[] = isset($splittedLine[1]) ? array('dns' => $splittedLine[0], 'address' => $splittedLine[1]) : $configLine; } else { $usedIPs[] = $configLine; } } foreach ($tsip as $newLine) { $splittedLine = preg_split('/\\=/', strtolower($newLine), -1, PREG_SPLIT_NO_EMPTY); if (isset($splittedLine[1]) and !array_key_exists($splittedLine[1], $usedIPs)) { $usedIPs[] = array('dns' => $splittedLine[0], 'address' => $splittedLine[1]); } } function array_multi_dimensional_unique($multi) { $unique = array(); foreach ($multi as $sub) { if (!in_array($sub, $unique)) { $unique[] = $sub; } } return $unique; } $newCfg = ''; $usedIPs = array_multi_dimensional_unique($usedIPs); sort($usedIPs); foreach ($usedIPs as $value) { $newCfg .= (isset($value['dns']) and isset($value['address']) and !preg_match('/^#(|\\s+)(.*)$/', $value['dns'])) ? $value['dns'] . '=' . $value['address'] . "\r\n" : $value . "\r\n"; } if ($newCfg == '') { $bad = 'Nothing to write'; } else { $sshSftpObject->put($file, $newCfg); } } if (!isset($bad) and $action != 'li') { $sshObject = new Net_SSH2($sship, $sshport); if ($sshObject->error === false) { if ($sshObject->login($sshuser, $sshpw)) { $bin = $bitversion == 32 ? 'tsdnsserver_linux_x86' : 'tsdnsserver_linux_amd64'; $ssh2cmd = 'cd ' . $folders . ' && function restart () { if [ "`ps fx | grep ' . $bin . ' | grep -v grep`" == "" ]; then ./' . $bin . ' > /dev/null & else ./' . $bin . ' --update > /dev/null & fi }; restart& '; $sshObject->exec($ssh2cmd); if ($notified > 0) { $query = $sql->prepare("UPDATE `voice_masterserver` SET `notified`=0 WHERE `ssh2ip`=? AND `resellerid`=? LIMIT 1"); $query->execute(array($sship, $reseller_id)); } } else { $bad = 'The login data does not work'; $notified++; } } else { $bad = 'Could not connect to Server'; $notified++; } } } else { $bad = 'Could not connect to Server'; } if (isset($bad) and $notified == $maxnotified) { if ($reseller_id == 0) { $query = $sql->prepare("SELECT `id`,`mail_serverdown` FROM `userdata` WHERE `resellerid`=0 AND `accounttype`='a'"); $query->execute(); } else { $query = $sql->prepare("SELECT `id`,`mail_serverdown` FROM `userdata` WHERE (`id`=? AND `id`=`resellerid`) OR (`resellerid`=0 AND `accounttype`='a')"); $query->execute(array($reseller_id)); } while ($row = $query->fetch(PDO::FETCH_ASSOC)) { if ($row['mail_serverdown'] == 'Y') { sendmail('emaildown', $row['id'], 'TS3 Master ' . $sship . ' ( ' . $bad . ' )', ''); } } $query = $sql->prepare("UPDATE `voice_masterserver` SET `notified`=`notified`+1 WHERE `ssh2ip`=? AND `resellerid`=? LIMIT 1"); $query->execute(array($sship, $reseller_id)); return $bad; } else { if (isset($bad)) { return $bad; } else { if ($action == 'li' and isset($dnsarray)) { return $dnsarray; } } } return 'ok'; }
public function __construct($hostID, $resellerID) { // retrieve global vars global $sql, $aeskey; // define internal vars $this->sql = $sql; $this->aeskey = $aeskey; $this->resellerID = $resellerID; $query = $this->sql->prepare("SELECT *,AES_DECRYPT(`user`,:aeskey) AS `decrypteduser`,AES_DECRYPT(`pass`,:aeskey) AS `decryptedpass` FROM `webMaster` WHERE `webMasterID`=:id AND `resellerID`=:resellerID LIMIT 1"); $query->execute(array(':aeskey' => $this->aeskey, ':id' => $hostID, ':resellerID' => $this->resellerID)); while ($row = $query->fetch(PDO::FETCH_ASSOC)) { if ($row['active'] == 'N') { return false; } $this->hostData['defaultdns'] = $row['defaultdns']; $this->hostData['ip'] = $row['ip']; $this->hostData['port'] = $row['port']; $this->hostData['ftpIP'] = strlen($row['ftpIP']) > 0 ? $row['ftpIP'] : $row['ip']; $this->hostData['ftpPort'] = $row['ftpPort']; $this->hostData['user'] = $row['decrypteduser']; $this->hostData['httpdCmd'] = $row['httpdCmd']; $this->hostData['userGroup'] = $row['userGroup']; $this->hostData['userAddCmd'] = $row['userAddCmd']; $this->hostData['userModCmd'] = $row['userModCmd']; $this->hostData['userDelCmd'] = $row['userDelCmd']; $this->hostData['vhostStoragePath'] = $row['vhostStoragePath']; $this->hostData['vhostConfigPath'] = $row['vhostConfigPath']; $this->hostData['vhostTemplate'] = $row['vhostTemplate']; $this->hostData['blocksize'] = $row['blocksize']; $this->hostData['inodeBlockRatio'] = $row['inodeBlockRatio']; $this->hostData['dirHttpd'] = $row['dirHttpd']; $this->hostData['dirLogs'] = $row['dirLogs']; $this->hostData['usageType'] = $row['usageType']; $this->hostData['skelDir'] = $this->removeNotNeededSlashes($this->hostData['vhostStoragePath'] . '/' . $this->hostData['user'] . '/skel/'); if ($row['quotaActive'] == 'Y') { $this->hostData['quotaCmd'] = $row['quotaCmd']; $this->hostData['repquotaCmd'] = $row['repquotaCmd']; } if ($row['publickey'] != 'N') { $privateKey = EASYWIDIR . '/keys/' . removePub($row['keyname']); if (!file_exists($privateKey)) { return false; } $this->ssh2Pass = new Crypt_RSA(); if ($row['publickey'] == 'B') { $this->ssh2Pass->setPassword($row['pass']); } $this->ssh2Pass->loadKey(file_get_contents($privateKey)); } else { $this->ssh2Pass = $row['decryptedpass']; } $this->dataPrepared = true; return true; } $this->masterNotfound = true; return false; }
function ssh_check($ssh2IP, $ssh2Port, $ssh2User, $sshPublickey, $sshKey, $ssh2Pass) { $privateKey = EASYWIDIR . '/keys/' . removePub($sshKey); $sshObject = new Net_SSH2($ssh2IP, $ssh2Port); if ($sshObject->error === false) { if ($sshPublickey != 'N') { $key = new Crypt_RSA(); if ($sshPublickey == 'B') { $key->setPassword($ssh2Pass); } $key->loadKey(file_get_contents($privateKey)); $ssh2Pass = $key; } return $sshObject->login($ssh2User, $ssh2Pass) ? true : 'login'; } return 'ipport'; }
public function VMWare() { foreach ($this->vmwareHosts as $hID => $h) { $privateKey = EASYWIDIR . '/keys/' . removePub($this->vmwareHosts[$hID['hostID']]['vmIDs']['keyname']); $sftpObject = new Net_SFTP($this->vmwareHosts[$hID]['vmIDs']['ip'], $this->vmwareHosts[$hID]['vmIDs']['dport']); if (file_exists($privateKey) and $sftpObject->error === false) { if ($this->vmwareHosts[$hID]['vmIDs']['publickey'] != 'N') { $ssh2Pass = new Crypt_RSA(); if ($this->vmwareHosts[$hID]['vmIDs']['publickey'] == 'B') { $ssh2Pass->setPassword($this->vmwareHosts[$hID]['vmIDs']['dpass']); } $ssh2Pass->loadKey(file_get_contents($privateKey)); } else { $ssh2Pass = $this->vmwareHosts[$hID]['vmIDs']['dpass']; } if ($sftpObject->login($this->vmwareHosts[$hID]['vmIDs']['duser'], $ssh2Pass)) { $sshObject = new Net_SSH2($this->vmwareHosts[$hID]['vmIDs']['ip'], $this->vmwareHosts[$hID]['vmIDs']['dport']); if (file_exists($privateKey) and $sshObject->error === false) { if ($sshObject->login($this->vmwareHosts[$hID]['vmIDs']['duser'], $ssh2Pass)) { print "Prepare: unregister any invalid vms\r\n"; $cmd = 'vim-cmd vmsvc/getallvms | grep \'Skipping\' | while read line; do vim-cmd vmsvc/unregister `echo $line | grep \'Skipping\' | awk -F "\'" \'{print $2}\'`; done'; $sshObject->exec($cmd); foreach ($h['actions'] as $v) { $dir = '/vmfs/volumes/' . $this->ID['vmware'][$v['id']]['mountpoint'] . '/' . $this->ID['vmware'][$v['id']]['hostname']; if (in_array($v['action'], array('md', 'dl', 'st', 'ri', 're'))) { print "Step 1: Stop and remove if needed\r\n"; // Get current VM ID $cmd = 'i(){ echo `vim-cmd vmsvc/getallvms 2> /dev/null | grep -v \'Skipping\' | grep \'' . $this->ID['vmware'][$v['id']]['hostname'] . '.vmx\' | awk \'{print $1}\'`;};'; // Stop the VM $cmd .= ' o(){ vim-cmd vmsvc/power.off `i ' . $this->ID['vmware'][$v['id']]['hostname'] . '`; vim-cmd vmsvc/unregister `i ' . $this->ID['vmware'][$v['id']]['hostname'] . '`;}; o;'; if (in_array($v['action'], array('dl', 'ri', 're'))) { $cmd .= ' rm -rf /vmfs/volumes/' . $this->ID['vmware'][$v['id']]['mountpoint'] . '/' . $this->ID['vmware'][$v['id']]['hostname']; } $sshObject->exec($cmd); } if (in_array($v['action'], array('md', 'ad', 'ri', 're'))) { $harddisk = $this->ID['vmware'][$v['id']]['distro'] == 'windows7srv-64' ? 'lsisas1068' : 'lsilogic'; if ($sftpObject->mkdir(rtrim($dir, '/'), -1, true)) { $vmxFile = '.encoding = "UTF-8"' . "\n"; $vmxFile .= 'config.version = "8"' . "\n"; $vmxFile .= 'displayName = "' . $this->ID['vmware'][$v['id']]['hostname'] . '"' . "\n"; $vmxFile .= 'ethernet0.present = "TRUE"' . "\n"; $vmxFile .= 'ethernet0.virtualDev = "e1000"' . "\n"; $vmxFile .= 'ethernet0.networkName = "VM Network"' . "\n"; $vmxFile .= 'ethernet0.addressType = "static"' . "\n"; $vmxFile .= 'ethernet0.Address = "' . $this->ID['vmware'][$v['id']]['mac'] . '"' . "\n"; $vmxFile .= 'extendedConfigFile = "' . $this->ID['vmware'][$v['id']]['hostname'] . '.vmxf"' . "\n"; $vmxFile .= 'floppy0.clientDevice = "TRUE"' . "\n"; $vmxFile .= 'floppy0.fileName = ""' . "\n"; $vmxFile .= 'floppy0.present = "TRUE"' . "\n"; $vmxFile .= 'floppy0.startConnected = "FALSE"' . "\n"; $vmxFile .= 'guestOS = "' . $this->ID['vmware'][$v['id']]['guestos'] . '"' . "\n"; $vmxFile .= 'ide1:0.present = "TRUE"' . "\n"; $vmxFile .= 'ide1:0.clientDevice = "TRUE"' . "\n"; $vmxFile .= 'ide1:0.deviceType = "cdrom-raw"' . "\n"; $vmxFile .= 'ide1:0.startConnected = "FALSE"' . "\n"; $vmxFile .= 'memsize = "' . $this->ID['vmware'][$v['id']]['ram'] . '"' . "\n"; $vmxFile .= 'numvcpus = "' . $this->ID['vmware'][$v['id']]['cores'] . '"' . "\n"; $vmxFile .= 'nvram = "' . $this->ID['vmware'][$v['id']]['hostname'] . '.nvram"' . "\n"; $vmxFile .= 'pciBridge0.present = "TRUE"' . "\n"; $vmxFile .= 'pciBridge4.present = "TRUE"' . "\n"; $vmxFile .= 'pciBridge4.virtualDev = "pcieRootPort"' . "\n"; $vmxFile .= 'pciBridge4.functions = "8"' . "\n"; $vmxFile .= 'pciBridge5.present = "TRUE"' . "\n"; $vmxFile .= 'pciBridge5.virtualDev = "pcieRootPort"' . "\n"; $vmxFile .= 'pciBridge5.functions = "8"' . "\n"; $vmxFile .= 'pciBridge6.present = "TRUE"' . "\n"; $vmxFile .= 'pciBridge6.virtualDev = "pcieRootPort"' . "\n"; $vmxFile .= 'pciBridge6.functions = "8"' . "\n"; $vmxFile .= 'pciBridge7.present = "TRUE"' . "\n"; $vmxFile .= 'pciBridge7.virtualDev = "pcieRootPort"' . "\n"; $vmxFile .= 'pciBridge7.functions = "8"' . "\n"; $vmxFile .= 'powerType.powerOff = "soft"' . "\n"; $vmxFile .= 'powerType.powerOn = "hard"' . "\n"; $vmxFile .= 'powerType.suspend = "hard"' . "\n"; $vmxFile .= 'powerType.reset = "soft"' . "\n"; $vmxFile .= 'sched.cpu.min = "' . $this->ID['vmware'][$v['id']]['minmhz'] . '"' . "\n"; $vmxFile .= 'sched.cpu.units = "mhz"' . "\n"; $vmxFile .= 'sched.cpu.shares = "normal"' . "\n"; $vmxFile .= 'sched.cpu.max = "' . $this->ID['vmware'][$v['id']]['maxmhz'] . '"' . "\n"; $vmxFile .= 'sched.cpu.affinity = "all"' . "\n"; $vmxFile .= 'sched.mem.max = "' . $this->ID['vmware'][$v['id']]['maxram'] . '"' . "\n"; $vmxFile .= 'sched.mem.minsize = "' . $this->ID['vmware'][$v['id']]['minram'] . '"' . "\n"; $vmxFile .= 'sched.mem.shares = "normal"' . "\n"; $vmxFile .= 'scsi0.present = "TRUE"' . "\n"; $vmxFile .= 'scsi0.sharedBus = "none"' . "\n"; $vmxFile .= 'scsi0.virtualDev = "' . $harddisk . '"' . "\n"; $vmxFile .= 'scsi0:0.present = "TRUE"' . "\n"; $vmxFile .= 'scsi0:0.fileName = "' . $this->ID['vmware'][$v['id']]['hostname'] . '.vmdk"' . "\n"; $vmxFile .= 'scsi0:0.deviceType = "scsi-hardDisk"' . "\n"; $vmxFile .= 'uuid.location = "56 4d ce 4e ce 1e 51 4b-3f 61 d8 45 c0 c8 93 90"' . "\n"; $vmxFile .= 'uuid.bios = "56 4d ce 4e ce 1e 51 4b-3f 61 d8 45 c0 c8 93 90"' . "\n"; $vmxFile .= 'vc.uuid = "52 9c 06 a8 19 e6 40 c0-61 1b 6e 23 34 c8 c7 f9"' . "\n"; $vmxFile .= 'virtualHW.productCompatibility = "hosted"' . "\n"; $vmxFile .= 'virtualHW.version = "7"' . "\n"; $vmxFile .= 'vmci0.present = "TRUE"' . "\n"; $vmxFile .= 'uuid.action = "create"' . "\n"; $vmxFile .= 'bios.bootOrder = "ethernet0"' . "\n"; $filename = '/vmfs/volumes/' . $this->ID['vmware'][$v['id']]['mountpoint'] . '/' . $this->ID['vmware'][$v['id']]['hostname'] . '/' . $this->ID['vmware'][$v['id']]['hostname'] . '.vmx'; if ($sftpObject->put($filename, $vmxFile)) { print "Step 2: Create/edit vmx file (OK)\r\n"; } else { print "Step 2: Create/edit vmx file (FAILED)\r\n"; } } else { print "Step 2: Create/edit vmx file (FAILED)\r\n"; } print "Step 3: create volume\r\n"; $cmd = 'a() { vmkfstools -c ' . $this->ID['vmware'][$v['id']]['hddsize'] . ' -a lsilogic -d thin /vmfs/volumes/' . $this->ID['vmware'][$v['id']]['mountpoint'] . '/' . $this->ID['vmware'][$v['id']]['hostname'] . '/' . $this->ID['vmware'][$v['id']]['hostname'] . '.vmdk >/dev/null 2>&1;}; a'; $sshObject->exec($cmd); } else { print "Step 2-3: skipped as not required\r\n"; } if (in_array($v['action'], array('md', 'ad', 're', 'ri', 'rc'))) { print "Step 4: Start VM\r\n"; $cmd = 'a() { vim-cmd vmsvc/power.on `vim-cmd solo/registervm /vmfs/volumes/' . $this->ID['vmware'][$v['id']]['mountpoint'] . '/' . $this->ID['vmware'][$v['id']]['hostname'] . '/' . $this->ID['vmware'][$v['id']]['hostname'] . '.vmx 2> /dev/null` >/dev/null 2>&1;}; a&'; $sshObject->exec($cmd); } else { print "Step 4: skipped as not required\r\n"; } } } else { print "No Login\r\n"; } } else { print "No connection\r\n"; } } else { print "No login connection\r\n"; } } else { print "No connection\r\n"; } } return true; }