Initial
This commit is contained in:
@@ -9,8 +9,14 @@ function normalizeConnection(body, existing = {}) {
|
||||
...body,
|
||||
password: body.password || ''
|
||||
});
|
||||
const targetType = parsed.targetType || 'vcenter';
|
||||
const apiMode = targetType === 'host'
|
||||
? 'web-services'
|
||||
: (parsed.apiMode === 'web-services' ? 'auto' : parsed.apiMode);
|
||||
return {
|
||||
...parsed,
|
||||
targetType,
|
||||
apiMode,
|
||||
baseUrl: String(parsed.baseUrl || '').trim().replace(/\/+$/, ''),
|
||||
groupId: parsed.visibility === 'group' ? parsed.groupId || null : null
|
||||
};
|
||||
@@ -52,10 +58,10 @@ export function createVCenterConnection(body, userId) {
|
||||
db.prepare(`
|
||||
INSERT INTO vcenter_connections (
|
||||
id, name, base_url, username, secret_cipher, secret_iv, secret_tag,
|
||||
api_mode, request_timeout_ms, allow_untrusted_tls, enabled,
|
||||
target_type, api_mode, request_timeout_ms, allow_untrusted_tls, enabled,
|
||||
visibility, owner_user_id, group_id, created_by, created_at, updated_at
|
||||
)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
`).run(
|
||||
connectionId,
|
||||
payload.name,
|
||||
@@ -64,6 +70,7 @@ export function createVCenterConnection(body, userId) {
|
||||
encrypted.cipher,
|
||||
encrypted.iv,
|
||||
encrypted.tag,
|
||||
payload.targetType,
|
||||
payload.apiMode,
|
||||
payload.requestTimeoutMs,
|
||||
payload.allowUntrustedTls ? 1 : 0,
|
||||
@@ -85,6 +92,7 @@ export function updateVCenterConnection(connectionId, body, userId) {
|
||||
name: existing.name,
|
||||
baseUrl: existing.base_url,
|
||||
username: existing.username,
|
||||
targetType: existing.target_type || 'vcenter',
|
||||
apiMode: existing.api_mode,
|
||||
requestTimeoutMs: existing.request_timeout_ms,
|
||||
allowUntrustedTls: Boolean(existing.allow_untrusted_tls),
|
||||
@@ -100,7 +108,7 @@ export function updateVCenterConnection(connectionId, body, userId) {
|
||||
db.prepare(`
|
||||
UPDATE vcenter_connections
|
||||
SET name = ?, base_url = ?, username = ?, secret_cipher = ?, secret_iv = ?, secret_tag = ?,
|
||||
api_mode = ?, request_timeout_ms = ?, allow_untrusted_tls = ?, enabled = ?,
|
||||
target_type = ?, api_mode = ?, request_timeout_ms = ?, allow_untrusted_tls = ?, enabled = ?,
|
||||
visibility = ?, group_id = ?, updated_at = ?
|
||||
WHERE id = ?
|
||||
`).run(
|
||||
@@ -110,6 +118,7 @@ export function updateVCenterConnection(connectionId, body, userId) {
|
||||
encrypted.cipher,
|
||||
encrypted.iv,
|
||||
encrypted.tag,
|
||||
payload.targetType,
|
||||
payload.apiMode,
|
||||
payload.requestTimeoutMs,
|
||||
payload.allowUntrustedTls ? 1 : 0,
|
||||
|
||||
Reference in New Issue
Block a user