/** * Create a directory. * * @param string $dir * @param int $mode * @param bool $recursive * * @return bool */ public function mkdir($dir, $mode = -1, $recursive = false) { switch ($this->_connType) { case SftpHelper::TYPE_SFTP: default: $res = $this->_connection->mkdir($dir, $mode, $recursive); break; case SftpHelper::TYPE_FTP: $res = false; if ($recursive) { $pathArray = explode('/', $dir); } else { $pathArray = [$dir]; } $i = 0; $fullDirPath = ''; $pathArrayCount = count($pathArray); foreach ($pathArray as $dirPath) { $fullDirPath .= (!empty($fullDirPath) ? '/' : '') . $dirPath; $mode = $mode === -1 ? 0755 : $mode; $res = @ftp_mkdir($this->_connection, $fullDirPath); $i++; if ($i === $pathArrayCount) { @ftp_chmod($this->_connection, $mode, $fullDirPath); } } break; } return $res; }
/** * Create a directory * * @param string $dir * @param int $mode ignored here; uses logged-in user's umask * @param bool $recursive analogous to mkdir -p * * Note: if $recursive is true and an error occurs mid-execution, * false is returned and some part of the hierarchy might be created. * No rollback is performed. * * @return bool * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function mkdir($dir, $mode = 0777, $recursive = true) { if ($recursive) { $no_errors = true; $dirList = explode('/', $dir); reset($dirList); $currentWorkingDir = $this->_connection->pwd(); while ($no_errors && ($dir_item = next($dirList))) { $no_errors = $this->_connection->mkdir($dir_item) && $this->_connection->chdir($dir_item); } $this->_connection->chdir($currentWorkingDir); return $no_errors; } else { return $this->_connection->mkdir($dir); } }
public function mkdir($path) { try { return $this->client->mkdir($this->absPath($path)); } catch (\Exception $e) { return false; } }
public function mkdir($dir) { return $this->ftp->mkdir($dir) && $this->ftp->chmod($this->permDir, $dir); }
public static function test($settings) { self::_init(); // Connect to server. $server = $settings['address']; $port = '22'; // Default sFTP port. if (strstr($server, ':')) { // Handle custom sFTP port. $server_params = explode(':', $server); $server = $server_params[0]; $port = $server_params[1]; } pb_backupbuddy::status('details', 'Connecting to sFTP server...'); $sftp = new Net_SFTP($server, $port); if (!$sftp->login($settings['username'], $settings['password'])) { pb_backupbuddy::status('error', 'Connection to sFTP server FAILED.'); pb_backupbuddy::status('details', 'sFTP log (if available & enabled via full logging mode): `' . $sftp->getSFTPLog() . '`.'); return __('Unable to connect to server using host, username, and password combination provided.', 'it-l10n-backupbuddy'); } else { pb_backupbuddy::status('details', 'Success connecting to sFTP server.'); } pb_backupbuddy::status('details', 'Attempting to create path (if it does not exist)...'); if (true === $sftp->mkdir($settings['path'])) { // Try to make directory. pb_backupbuddy::status('details', 'Directory created.'); } else { pb_backupbuddy::status('details', 'Directory not created.'); } $destination_file = $settings['path'] . '/backupbuddy_test.txt'; pb_backupbuddy::status('details', 'About to put to sFTP test file `backupbuddy_test.txt` to remote location `' . $destination_file . '`.'); $send_time = -microtime(true); if (true !== $sftp->put($destination_file, 'Upload test for BackupBuddy destination. Delete me.')) { pb_backupbuddy::status('details', 'sFTP test: Failure uploading test file.'); $sftp->delete($destination_file); // Just in case it partionally made file. This has happened oddly. pb_backupbuddy::status('details', 'sFTP log (if available & enabled via full logging mode): `' . $sftp->getSFTPLog() . '`.'); return __('Failure uploading. Check path & permissions.', 'it-l10n-backupbuddy'); } else { // File uploaded. pb_backupbuddy::status('details', 'File uploaded.'); if ($settings['url'] != '') { $response = wp_remote_get(rtrim($settings['url'], '/\\') . '/backupbuddy_test.txt', array('method' => 'GET', 'timeout' => 20, 'redirection' => 5, 'httpversion' => '1.0', 'blocking' => true, 'headers' => array(), 'body' => null, 'cookies' => array())); if (is_wp_error($response)) { return __('Failure. Unable to connect to the provided optional URL.', 'it-l10n-backupbuddy'); } if (stristr($response['body'], 'backupbuddy') === false) { return __('Failure. The path appears valid but the URL does not correspond to it. Leave the URL blank if not using this destination for migrations.', 'it-l10n-backupbuddy'); } } pb_backupbuddy::status('details', 'sFTP test: Deleting temp test file.'); $sftp->delete($destination_file); } return true; // Success if we got this far. }
if (strstr($server, ':')) { // Handle custom sFTP port. $server_params = explode(':', $server); $server = $server_params[0]; $port = $server_params[1]; } pb_backupbuddy::status('details', 'Connecting to sFTP server...'); $sftp = new Net_SFTP($server, $port); if (!$sftp->login($destination['username'], $destination['password'])) { pb_backupbuddy::status('error', 'Connection to sFTP server FAILED.'); return false; } else { pb_backupbuddy::status('details', 'Success connecting to sFTP server.'); } pb_backupbuddy::status('details', 'Attempting to create path (if it does not exist)...'); if (true === $sftp->mkdir($destination['path'])) { // Try to make directory. pb_backupbuddy::status('details', 'Directory created.'); } else { pb_backupbuddy::status('details', 'Directory not created.'); } // List files. $files = $sftp->rawlist($destination['path']); $backups = array(); $backup_list_temp = array(); foreach ($files as $filename => $file) { if (false === stristr($filename, 'backup')) { // only show backup files continue; } if (stristr($filename, '-db-') !== false) {
include 'Net/SSH2.php'; include 'Net/SFTP.php'; //ssh connect to cr2g server $ssh = new Net_SSH2('cr2g01.cs.utep.edu', 22); if (!$ssh->login('rlgruver', 'utep$2015')) { exit('ssh Login Failed'); } //attempted to set an ssh timeout, not allowed on UTEP server $ssh->setTimeout(7200); //sftp connect to cr2g server $sftp = new Net_SFTP('cr2g01.cs.utep.edu', 22); if (!$sftp->login('rlgruver', 'utep$2015')) { exit('sftp Login Failed'); } //send input file to cr2g server $sftp->mkdir('/code/spopt-stable/tests/' . $session); $sftp->put($remoteInputFile, $localInputFile, NET_SFTP_LOCAL_FILE); $sftp->chmod(0777, $remoteInputFile); //execute python script in this order to run the Solver: //1. change to directory where solver script is located $ssh->write("cd /code/spopt-stable\n"); //2. 'read' command to ensure script is called from the proper directory $ssh->read('rlgruver@cr2g01:/code/spopt-stable$'); //3. run the solver script with the test from the current session $ssh->write("python SpOpt.py tests/" . $session . "/input.txt\n"); //start timerin case anything gets stuck, will break within 120 minutes (7200 sec) $starttime = time(); //ssh will break within 120 minutes (7200 sec) regardless of execution status while ($ssh->isConnected()) { $now = time() - $starttime; if ($now > 7200) {
/** * Attempts to create the directory specified by the path * * Makes a directory * * NOTE: Only valid option is STREAM_MKDIR_RECURSIVE ( http://www.php.net/manual/en/function.mkdir.php ) * * @param String $path * @param Integer $mode * @param Integer $options * @return bool * @access public */ public function mkdir($path, $mode, $options) { $connection = $this->stream_open($path, NULL, NULL, $opened_path); if ($connection === false) { return FALSE; } if ($options === STREAM_MKDIR_RECURSIVE) { $mkdir = $this->sftp->mkdir($this->path, $mode, true); } else { $mkdir = $this->sftp->mkdir($this->path, $mode, false); } $this->stream_close(); return $mkdir; }
public function mkdir($dir) { return $this->conn->mkdir($dir); }
/** * Uploads backup file from server to remote sftp server. * * @param array $args arguments passed to the function * [sftp_username] -> sftp username on remote server * [sftp_password] -> sftp password on remote server * [sftp_hostname] -> sftp hostname of remote host * [sftp_remote_folder] -> folder on remote site which backup file should be upload to * [sftp_site_folder] -> subfolder with site name in ftp_remote_folder which backup file should be upload to * [sftp_passive] -> passive mode or not * [sftp_ssl] -> ssl or not * [sftp_port] -> number of port for ssl protocol * [backup_file] -> absolute path of backup file on local server * @return bool|array true is successful, array with error message if not */ function sftp_backup($args) { extract($args); // file_put_contents("sftp_log.txt","sftp_backup",FILE_APPEND); $port = $sftp_port ? $sftp_port : 22; //default port is 22 // file_put_contents("sftp_log.txt","sftp port:".$sftp_port,FILE_APPEND); $sftp_hostname = $sftp_hostname ? $sftp_hostname : ""; // file_put_contents("sftp_log.txt","sftp host:".$sftp_hostname,FILE_APPEND); $sftp_username = $sftp_username ? $sftp_username : ""; // file_put_contents("sftp_log.txt","sftp user:"******""; // file_put_contents("sftp_log.txt","sftp pass:"******"sftp_log.txt","Creating NetSFTP",FILE_APPEND); $sftp = new Net_SFTP($sftp_hostname); // file_put_contents("sftp_log.txt","Created NetSFTP",FILE_APPEND); $remote = $sftp_remote_folder ? trim($sftp_remote_folder, "/") . "/" : ''; if (!$sftp->login($sftp_username, $sftp_password)) { file_put_contents("sftp_log.txt", "sftp login failed in sftp_backup", FILE_APPEND); return array('error' => 'SFTP login failed for ' . $sftp_username . ', ' . $sftp_password, 'partial' => 1); } file_put_contents("sftp_log.txt", "making remote dir", FILE_APPEND); $sftp->mkdir($remote); file_put_contents("sftp_log.txt", "made remote dir", FILE_APPEND); if ($sftp_site_folder) { $remote .= '/' . $this->site_name; } $sftp->mkdir($remote); file_put_contents("sftp_log.txt", "making {$sftp_remote_folder} dir", FILE_APPEND); $sftp->mkdir($sftp_remote_folder); file_put_contents("sftp_log.txt", "made {$sftp_remote_folder} dir", FILE_APPEND); file_put_contents("sftp_log.txt", "starting upload", FILE_APPEND); $upload = $sftp->put($remote . '/' . basename($backup_file), $backup_file, NET_SFTP_LOCAL_FILE); file_put_contents("sftp_log.txt", "finish upload", FILE_APPEND); $sftp->disconnect(); if ($upload === false) { file_put_contents("sftp_log.txt", "sftp upload failed", FILE_APPEND); return array('error' => 'Failed to upload file to SFTP. Please check your specified path.', 'partial' => 1); } return true; }
function ftp_backup($args) { extract($args); //Args: $ftp_username, $ftp_password, $ftp_hostname, $backup_file, $ftp_remote_folder, $ftp_site_folder if (isset($use_sftp) && $use_sftp == 1) { $port = $ftp_port ? $ftp_port : 22; //default port is 22 /* * SFTP section start here phpseclib library is used for this functionality */ $iwp_mmb_plugin_dir = WP_PLUGIN_DIR . '/' . basename(dirname(__FILE__)); $path = $iwp_mmb_plugin_dir . '/lib/phpseclib'; set_include_path(get_include_path() . PATH_SEPARATOR . $path); include_once 'Net/SFTP.php'; $sftp = new Net_SFTP($ftp_hostname, $port); if (!$sftp) { return array('error' => 'Failed to connect to ' . $ftp_hostname, 'partial' => 1); } if (!$sftp->login($ftp_username, $ftp_password)) { return array('error' => 'FTP login failed for ' . $ftp_username . ', ' . $ftp_password, 'partial' => 1); } else { if ($ftp_site_folder) { $ftp_remote_folder .= '/' . $this->site_name; } $remote_loation = basename($backup_file); $local_location = $backup_file; $sftp->mkdir($ftp_remote_folder, -1, true); $sftp->chdir($ftp_remote_folder); //$this->iwp_sftp_mkdir($sftp,'sftpbackup/test123/test1/test2'); $upload = $sftp->put(basename($backup_file), $backup_file, NET_SFTP_LOCAL_FILE); if ($upload === false) { return array('error' => 'Failed to upload file to FTP. Please check your specified path.', 'partial' => 1); } //SFTP library has automatic connection closed. So no need to call seperate connection close function } } else { $port = $ftp_port ? $ftp_port : 21; //default port is 21 if ($ftp_ssl) { if (function_exists('ftp_ssl_connect')) { $conn_id = ftp_ssl_connect($ftp_hostname, $port); if ($conn_id === false) { return array('error' => 'Failed to connect to ' . $ftp_hostname, 'error_code' => 'failed_to_connect_ftp_if_ftp_ssl', 'partial' => 1); } } else { return array('error' => 'Your server doesn\'t support FTP SSL', 'error_code' => 'no_ftp_ssl_support', 'partial' => 1); } } else { if (function_exists('ftp_connect')) { $conn_id = ftp_connect($ftp_hostname, $port); if ($conn_id === false) { return array('error' => 'Failed to connect to ' . $ftp_hostname, 'error_code' => 'failed_to_connect_ftp', 'partial' => 1); } } else { return array('error' => 'Your server doesn\'t support FTP', 'error_code' => 'no_ftp_support', 'partial' => 1); } } $login = @ftp_login($conn_id, $ftp_username, $ftp_password); if ($login === false) { return array('error' => 'FTP login failed for ' . $ftp_username . ', ' . $ftp_password, 'error_code' => 'ftp_login_failed', 'partial' => 1); } if ($ftp_passive) { @ftp_pasv($conn_id, true); } @ftp_mkdir($conn_id, $ftp_remote_folder); if ($ftp_site_folder) { $ftp_remote_folder .= '/' . $this->site_name; } @ftp_mkdir($conn_id, $ftp_remote_folder); $upload = @ftp_put($conn_id, $ftp_remote_folder . '/' . basename($backup_file), $backup_file, FTP_BINARY); if ($upload === false) { //Try ascii $upload = @ftp_put($conn_id, $ftp_remote_folder . '/' . basename($backup_file), $backup_file, FTP_ASCII); } @ftp_close($conn_id); if ($upload === false) { return array('error' => 'Failed to upload file to FTP. Please check your specified path.', 'error_code' => 'failed_to_upload_file_check_path', 'partial' => 1); } } return true; }
$ctinfo = mysqli_fetch_row($result); $result = mysqli_query($con, "SELECT ip FROM servers WHERE id='" . $_POST['serverid'] . "'"); $sinfo = mysqli_fetch_row($result); $build_location = "builds/" . $ctinfo[1]; $remote_sauce = "/home/" . $_POST['username'] . "/sauce/"; $remote_sauce_src = "/home/" . $_POST['username'] . "/sauce/src/"; $remote_location = $remote_sauce_src . $ctinfo[1]; $file_size = filesize($build_location); if (file_exists($build_location)) { $sftp = new Net_SFTP($sinfo[0]); $key = new Crypt_RSA(); $key->loadKey(file_get_contents($sshkey_location)); if (!$sftp->login('root', $key)) { $error[] = "Login Failed"; } else { $debug[] = $sftp->mkdir($remote_sauce); $debug[] = $sftp->mkdir($remote_sauce_src); $debug[] = $sftp->put($remote_location, $file_size); $debug[] = $sftp->put($remote_location, $build_location, NET_SFTP_LOCAL_FILE); $debug[] = $sftp->chmod(0755, $remote_location); echo "Daemon uploaded!"; } } else { //if file doesnt exist, check in the database to see if we can borrow from another server ;) $error[] = "Unable to find coind file in the /builds folder."; } print_r($debug); print_r($error); echo ' <form action=coinds.add-do.step5.php method=post> <input type=hidden name=templateid value="' . $_POST['templateid'] . '" />
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; }