change ssh2 into new SSH2
This commit is contained in:
@@ -402,9 +402,7 @@ class ServiceController extends Controller
|
|||||||
|
|
||||||
\App\Jobs\VirtualMachine\Snapshot\CreateSnapshot::dispatch(
|
\App\Jobs\VirtualMachine\Snapshot\CreateSnapshot::dispatch(
|
||||||
$snapshot->id
|
$snapshot->id
|
||||||
)
|
)->delay(now()->addSeconds(3));
|
||||||
->onQueue('snapshots')
|
|
||||||
->delay(now()->addSeconds(3));
|
|
||||||
|
|
||||||
return redirect()->back()->with(
|
return redirect()->back()->with(
|
||||||
'success',
|
'success',
|
||||||
|
|||||||
@@ -300,11 +300,7 @@ class vCenter
|
|||||||
$action = "powershell.exe; Connect-viserver -Server '$this->apiUri' -User '$this->username' -Password \"'$this->password'\" -SaveCredentials; $cmd";
|
$action = "powershell.exe; Connect-viserver -Server '$this->apiUri' -User '$this->username' -Password \"'$this->password'\" -SaveCredentials; $cmd";
|
||||||
|
|
||||||
//Run action
|
//Run action
|
||||||
$stream = ssh2_exec($auth, $action);
|
return $auth->exec($action);
|
||||||
|
|
||||||
stream_set_blocking($stream, true);
|
|
||||||
|
|
||||||
return stream_get_contents($stream);
|
|
||||||
} catch (Exception $error) {
|
} catch (Exception $error) {
|
||||||
return $error->getCode();
|
return $error->getCode();
|
||||||
}
|
}
|
||||||
@@ -314,9 +310,10 @@ class vCenter
|
|||||||
{
|
{
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$connection = ssh2_connect('10.10.10.173', 22);
|
$connection = new SSH2('10.10.10.173', 22);
|
||||||
|
|
||||||
if (ssh2_auth_password($connection, 'administrator', 'Thegioiso@123**$$8899TgTk2')) {
|
if ($connection->login('administrator', 'Thegioiso@123**$$8899TgTk2')) {
|
||||||
|
$connection->setTimeout(0); // No timeout
|
||||||
return $connection;
|
return $connection;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -351,14 +348,8 @@ class vCenter
|
|||||||
. '-Command "' . str_replace('"', '\"', $psCommand) . '"';
|
. '-Command "' . str_replace('"', '\"', $psCommand) . '"';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$stream = ssh2_exec($auth, $action);
|
$out = $auth->exec($action);
|
||||||
if (!$stream)
|
$errOut = $auth->getStdError();
|
||||||
throw new \RuntimeException("ssh2_exec failed");
|
|
||||||
$err = ssh2_fetch_stream($stream, SSH2_STREAM_STDERR);
|
|
||||||
stream_set_blocking($stream, true);
|
|
||||||
stream_set_blocking($err, true);
|
|
||||||
$out = stream_get_contents($stream) ?: '';
|
|
||||||
$errOut = stream_get_contents($err) ?: '';
|
|
||||||
return $out . ($errOut ? "\n[STDERR]\n" . $errOut : '');
|
return $out . ($errOut ? "\n[STDERR]\n" . $errOut : '');
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
return "Error: " . $e->getMessage();
|
return "Error: " . $e->getMessage();
|
||||||
@@ -412,14 +403,8 @@ PS;
|
|||||||
$action = "powershell.exe -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Bypass -EncodedCommand $encoded";
|
$action = "powershell.exe -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Bypass -EncodedCommand $encoded";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$stream = ssh2_exec($auth, $action);
|
$out = $auth->exec($action);
|
||||||
if (!$stream)
|
$errOut = $auth->getStdError();
|
||||||
return "ssh2_exec failed";
|
|
||||||
$err = ssh2_fetch_stream($stream, SSH2_STREAM_STDERR);
|
|
||||||
stream_set_blocking($stream, true);
|
|
||||||
stream_set_blocking($err, true);
|
|
||||||
$out = stream_get_contents($stream) ?: '';
|
|
||||||
$errOut = stream_get_contents($err) ?: '';
|
|
||||||
return $out . ($errOut ? "\n[STDERR]\n" . $errOut : '');
|
return $out . ($errOut ? "\n[STDERR]\n" . $errOut : '');
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
return "Error: " . $e->getMessage();
|
return "Error: " . $e->getMessage();
|
||||||
@@ -467,15 +452,8 @@ PS;
|
|||||||
$action = "powershell.exe -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Bypass -EncodedCommand $encoded";
|
$action = "powershell.exe -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Bypass -EncodedCommand $encoded";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$stream = ssh2_exec($auth, $action);
|
$out = $auth->exec($action);
|
||||||
if (!$stream)
|
$errOut = $auth->getStdError();
|
||||||
return "ssh2_exec failed";
|
|
||||||
$err = ssh2_fetch_stream($stream, SSH2_STREAM_STDERR);
|
|
||||||
stream_set_blocking($stream, true);
|
|
||||||
stream_set_blocking($err, true);
|
|
||||||
|
|
||||||
$out = stream_get_contents($stream) ?: '';
|
|
||||||
$errOut = stream_get_contents($err) ?: '';
|
|
||||||
|
|
||||||
if ($expectJson) {
|
if ($expectJson) {
|
||||||
// CẮT JSON cuối: {...} hoặc [...]
|
// CẮT JSON cuối: {...} hoặc [...]
|
||||||
|
|||||||
@@ -58,8 +58,9 @@
|
|||||||
<i data-lucide="menu" class="w-6 h-6"></i>
|
<i data-lucide="menu" class="w-6 h-6"></i>
|
||||||
</div>
|
</div>
|
||||||
<div class="hidden lg:flex flex-wrap gap-2 sm:gap-4">
|
<div class="hidden lg:flex flex-wrap gap-2 sm:gap-4">
|
||||||
|
|
||||||
<!-- Số dư -->
|
<!-- Số dư -->
|
||||||
<a href="#"
|
<div
|
||||||
class="animate__animated animate__fadeInLeft items-center gap-2 text-sm text-primary hover:text-primary bg-white shadow-lg rounded-lg p-2 transition-transform duration-300 hover:translate-y-[10%] flex">
|
class="animate__animated animate__fadeInLeft items-center gap-2 text-sm text-primary hover:text-primary bg-white shadow-lg rounded-lg p-2 transition-transform duration-300 hover:translate-y-[10%] flex">
|
||||||
<div class="flex gap-2 items-center">
|
<div class="flex gap-2 items-center">
|
||||||
<span>
|
<span>
|
||||||
@@ -69,7 +70,7 @@
|
|||||||
{{ format_price(auth('users')->user()->credit ?? 0) }}
|
{{ format_price(auth('users')->user()->credit ?? 0) }}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<!-- Mobile Info Cards -->
|
<!-- Mobile Info Cards -->
|
||||||
|
|||||||
Reference in New Issue
Block a user