Skip to content

Commit

Permalink
check public IP address properly: thanks Enol ;)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastian-luna-valero committed Jul 12, 2024
1 parent cfd3ff7 commit 410aad0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion fedcloud_vm_monitoring/site_monitor.py
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@
from datetime import datetime, timezone

import click
import ipaddress
import ldap3
import paramiko
from dateutil.parser import parse
@@ -129,7 +130,7 @@ def get_user_email(self, egi_user):
def get_public_ip(self, ip_addresses):
result = ""
for ip in ip_addresses:
if not ip.startswith("192.168") and not ip.startswith("172.16"):
if ipaddress.ip_address(ip).is_global:
result = ip
return result

@@ -151,6 +152,7 @@ def process_vm(self, vm):
vm_info = self.get_vm(vm)
flv = self.get_flavor(vm["Flavor"])
vm_ips = []
sshd_version = "N/A"
for net, addrs in vm["Networks"].items():
vm_ips.extend(addrs)
sshd_version = self.get_sshd_version(addrs)

0 comments on commit 410aad0

Please sign in to comment.