|
|
@ -48,7 +48,9 @@ export const buildQueryHostDetail: BuildQueryDetailFunction = ({ |
|
|
|
|
|
|
|
|
|
|
|
const query = ` |
|
|
|
const query = ` |
|
|
|
SELECT |
|
|
|
SELECT |
|
|
|
|
|
|
|
a.host_ipmi, |
|
|
|
a.host_name, |
|
|
|
a.host_name, |
|
|
|
|
|
|
|
a.host_status, |
|
|
|
a.host_type, |
|
|
|
a.host_type, |
|
|
|
a.host_uuid, |
|
|
|
a.host_uuid, |
|
|
|
b.variable_name, |
|
|
|
b.variable_name, |
|
|
@ -84,32 +86,35 @@ export const buildQueryHostDetail: BuildQueryDetailFunction = ({ |
|
|
|
if (output.length === 0) return {}; |
|
|
|
if (output.length === 0) return {}; |
|
|
|
|
|
|
|
|
|
|
|
const { |
|
|
|
const { |
|
|
|
0: [hostName, hostType, hostUUID], |
|
|
|
0: [hostIpmi, hostName, hostStatus, hostType, hostUUID], |
|
|
|
} = output; |
|
|
|
} = output; |
|
|
|
const shortHostName = getShortHostName(hostName); |
|
|
|
const shortHostName = getShortHostName(hostName); |
|
|
|
|
|
|
|
|
|
|
|
return output.reduce< |
|
|
|
/** |
|
|
|
{ |
|
|
|
* Assumes: |
|
|
|
hostName: string; |
|
|
|
* - ip is not quoted |
|
|
|
hostType: string; |
|
|
|
* - password is quoted, and it's the last switch in the string |
|
|
|
hostUUID: string; |
|
|
|
* - username has no space, and it's not quoted |
|
|
|
shortHostName: string; |
|
|
|
* |
|
|
|
} & Tree |
|
|
|
* TODO: replace with a package to handle parsing such command strings |
|
|
|
>( |
|
|
|
*/ |
|
|
|
( |
|
|
|
const ipmi: HostIpmi = { |
|
|
|
previous, |
|
|
|
command: hostIpmi, |
|
|
|
[ |
|
|
|
ip: hostIpmi.replace(/^.*--ip\s+([^\s'"]+).*$/, '$1'), |
|
|
|
, |
|
|
|
password: hostIpmi.replace(/^.*--password\s+"(.*)"$/, '$1'), |
|
|
|
, |
|
|
|
username: hostIpmi.replace(/^.*--username\s+(\w+).*$/, '$1'), |
|
|
|
, |
|
|
|
}; |
|
|
|
variableName, |
|
|
|
|
|
|
|
variableValue, |
|
|
|
return output.reduce<HostDetail>( |
|
|
|
, |
|
|
|
(previous, row) => { |
|
|
|
networkType, |
|
|
|
const { |
|
|
|
networkLink, |
|
|
|
5: variableName, |
|
|
|
networkInterfaceUuid, |
|
|
|
6: variableValue, |
|
|
|
], |
|
|
|
8: networkType, |
|
|
|
) => { |
|
|
|
9: networkLink, |
|
|
|
|
|
|
|
10: networkInterfaceUuid, |
|
|
|
|
|
|
|
} = row; |
|
|
|
|
|
|
|
|
|
|
|
if (!variableName) return previous; |
|
|
|
if (!variableName) return previous; |
|
|
|
|
|
|
|
|
|
|
|
const [variablePrefix, ...restVariableParts] = |
|
|
|
const [variablePrefix, ...restVariableParts] = |
|
|
@ -130,7 +135,14 @@ export const buildQueryHostDetail: BuildQueryDetailFunction = ({ |
|
|
|
|
|
|
|
|
|
|
|
return previous; |
|
|
|
return previous; |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ hostName, hostType, hostUUID, shortHostName }, |
|
|
|
{ |
|
|
|
|
|
|
|
hostName, |
|
|
|
|
|
|
|
hostStatus, |
|
|
|
|
|
|
|
hostType, |
|
|
|
|
|
|
|
hostUUID, |
|
|
|
|
|
|
|
ipmi, |
|
|
|
|
|
|
|
shortHostName, |
|
|
|
|
|
|
|
}, |
|
|
|
); |
|
|
|
); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|