feat: implement JSON-based IP configuration scripts for Windows and Linux and integrate service activation in provisioning flow
This commit is contained in:
@@ -96,6 +96,9 @@ class AssignIpToGuestJob implements ShouldQueue
|
||||
$vcenterUser = $vcenter->user;
|
||||
$vcenterPass = SignRSA::DecryptFunc($vcenter->password);
|
||||
|
||||
// Guest OS default admin user per OS family
|
||||
$guestUser = strtoupper($this->osFamily) === 'WINDOWS' ? 'Administrator' : 'root';
|
||||
|
||||
// ─── Attempt loop ────────────────────────────────────────────────────
|
||||
|
||||
for ($attempt = 1; $attempt <= self::MAX_ATTEMPTS; $attempt++) {
|
||||
@@ -129,6 +132,8 @@ class AssignIpToGuestJob implements ShouldQueue
|
||||
vcenterPassword: $vcenterPass,
|
||||
guestPassword: $this->guestPassword,
|
||||
osFamily: $this->osFamily,
|
||||
dns: $dns,
|
||||
guestUser: $guestUser,
|
||||
);
|
||||
|
||||
// [6] If assign failed → release and try next IP
|
||||
@@ -151,6 +156,7 @@ class AssignIpToGuestJob implements ShouldQueue
|
||||
vcenterPassword: $vcenterPass,
|
||||
guestPassword: $this->guestPassword,
|
||||
osFamily: $this->osFamily,
|
||||
guestUser: $guestUser,
|
||||
);
|
||||
|
||||
// [8] If verification failed → release and try next IP
|
||||
@@ -329,10 +335,11 @@ class AssignIpToGuestJob implements ShouldQueue
|
||||
// Micro-helpers
|
||||
// ─────────────────────────────────────────────────────────────────────────
|
||||
|
||||
/** PS1 scripts output exactly "SUCCESS" or "FAIL". */
|
||||
/** PS1 scripts return JSON: {"status":"ok"} or {"status":"error","message":"..."} */
|
||||
private function isSuccess(string $output): bool
|
||||
{
|
||||
return str_contains(strtoupper(trim($output)), 'SUCCESS');
|
||||
$data = json_decode(trim($output), true);
|
||||
return is_array($data) && ($data['status'] ?? '') === 'ok';
|
||||
}
|
||||
|
||||
/** Convert dotted-decimal netmask to CIDR prefix length (e.g. 255.255.255.0 → 24). */
|
||||
|
||||
Reference in New Issue
Block a user