Capture Production IP from Servers tab and use for flow matching
All checks were successful
Build and Release / Build Windows Exe (push) Successful in 11s
All checks were successful
Build and Release / Build Windows Exe (push) Successful in 11s
This commit is contained in:
@@ -77,9 +77,8 @@ def read_servers(filename: str) -> Dict[str, Server]:
|
||||
print("Warning: No 'Servers' sheet found.")
|
||||
return {}
|
||||
|
||||
# keywords: reference, platform, ip address, management ip?
|
||||
# Ruby script looked for: reference, type, alias, platform, middleware
|
||||
header_keywords = ['reference', 'platform', 'ip address']
|
||||
# keywords: reference, platform, ip address, management ip, production ip
|
||||
header_keywords = ['reference', 'platform', 'ip address', 'production ip']
|
||||
|
||||
header_row_idx, col_map = find_header_row(target_sheet, header_keywords)
|
||||
|
||||
@@ -98,7 +97,8 @@ def read_servers(filename: str) -> Dict[str, Server]:
|
||||
# Extract data
|
||||
ref_idx = col_map.get('reference')
|
||||
plat_idx = col_map.get('platform')
|
||||
ip_idx = col_map.get('ip address') # Generic IP
|
||||
ip_idx = col_map.get('ip address') # Generic/Management IP
|
||||
prod_ip_idx = col_map.get('production ip') # Specific Production IP
|
||||
|
||||
# Helper to get value
|
||||
def get_val(idx):
|
||||
@@ -111,19 +111,29 @@ def read_servers(filename: str) -> Dict[str, Server]:
|
||||
continue
|
||||
|
||||
plat = get_val(plat_idx) or 'unknown'
|
||||
ip_raw = get_val(ip_idx)
|
||||
|
||||
# Parse Management IP
|
||||
ip_raw = get_val(ip_idx)
|
||||
ip_addr = None
|
||||
if ip_raw:
|
||||
ips = parse_ip(ip_raw)
|
||||
if ips:
|
||||
ip_addr = ips[0] # Take first valid IP
|
||||
ip_addr = ips[0]
|
||||
|
||||
# Parse Production IP
|
||||
prod_ip_raw = get_val(prod_ip_idx)
|
||||
prod_ip_addr = None
|
||||
if prod_ip_raw:
|
||||
ips = parse_ip(prod_ip_raw)
|
||||
if ips:
|
||||
prod_ip_addr = ips[0]
|
||||
|
||||
s = Server(
|
||||
reference=ref,
|
||||
hostname=ref, # Default hostname to reference
|
||||
hostname=ref,
|
||||
platform=plat,
|
||||
ip_address=ip_addr
|
||||
ip_address=ip_addr,
|
||||
production_ip=prod_ip_addr
|
||||
)
|
||||
servers[ref] = s
|
||||
|
||||
|
||||
@@ -20,6 +20,8 @@ def generate_inventory(servers: Dict[str, Server], flows: List[Flow]) -> Dict[st
|
||||
for s in servers.values():
|
||||
if s.ip_address:
|
||||
ip_to_server[s.ip_address] = s
|
||||
if s.production_ip:
|
||||
ip_to_server[s.production_ip] = s
|
||||
# Also index by reference/hostname for DNS matches
|
||||
if s.reference:
|
||||
ip_to_server[s.reference.lower()] = s
|
||||
|
||||
@@ -6,6 +6,7 @@ class Server:
|
||||
reference: str
|
||||
hostname: str # This might be same as reference
|
||||
ip_address: Optional[str] = None
|
||||
production_ip: Optional[str] = None
|
||||
platform: str = 'unknown' # e.g. 'Windows', 'Linux'
|
||||
|
||||
def get_ansible_vars(self) -> Dict[str, Any]:
|
||||
|
||||
Reference in New Issue
Block a user