mirror of
https://github.com/Pardus-LiderAhenk/ahenk
synced 2024-11-13 01:02:16 +03:00
ip addresses formatted
This commit is contained in:
parent
114a44c223
commit
1979d4815e
1 changed files with 23 additions and 12 deletions
|
@ -12,6 +12,7 @@ import psutil
|
||||||
from uuid import getnode as get_mac
|
from uuid import getnode as get_mac
|
||||||
|
|
||||||
from base.Scope import Scope
|
from base.Scope import Scope
|
||||||
|
from base.system.system import System
|
||||||
from base.messaging.AnonymousMessager import AnonymousMessager
|
from base.messaging.AnonymousMessager import AnonymousMessager
|
||||||
|
|
||||||
|
|
||||||
|
@ -96,23 +97,32 @@ class Registration():
|
||||||
self.logger.debug('[Registration] Registration parameters were created')
|
self.logger.debug('[Registration] Registration parameters were created')
|
||||||
|
|
||||||
def get_registration_params(self):
|
def get_registration_params(self):
|
||||||
|
|
||||||
|
print(System.Hardware.Network.ip_addresses())
|
||||||
params = {
|
params = {
|
||||||
'ipAddresses': str(self.get_ip_address()),
|
'ipAddresses': self.get_ip_address(),
|
||||||
'macAddresses': str(':'.join(("%012X" % get_mac())[i:i + 2] for i in range(0, 12, 2))),
|
'macAddresses': System.Hardware.mac_address(),
|
||||||
'hostname': str(socket.gethostname()),
|
'hostname': str(socket.gethostname()),
|
||||||
'system':str(platform.system()),
|
'system': str(platform.system()),
|
||||||
'node':str(platform.node()),
|
'node': str(platform.node()),
|
||||||
'release':str(platform.release()),
|
'release': str(platform.release()),
|
||||||
'version':str(platform.version()),
|
'version': str(platform.version()),
|
||||||
'machine':str(platform.machine()),
|
'machine': str(platform.machine()),
|
||||||
'processor':str(platform.processor()),
|
'processor': str(platform.processor()),
|
||||||
'architecture':str(platform.architecture()),
|
'architecture': str(platform.architecture()),
|
||||||
'cpuCount':str(psutil.cpu_count()),
|
'cpuCount': str(psutil.cpu_count()),
|
||||||
'diskInfo':self.get_disks()
|
'diskInfo': self.get_disks()
|
||||||
}
|
}
|
||||||
|
|
||||||
return json.dumps(params)
|
return json.dumps(params)
|
||||||
|
|
||||||
|
def get_ip_address(self):
|
||||||
|
arr = []
|
||||||
|
for ip in System.Hardware.Network.ip_addresses():
|
||||||
|
if ip is not 'localhost' and ip is not '127.0.0.1':
|
||||||
|
arr.append(ip)
|
||||||
|
return str(arr).replace('[','').replace(']','')
|
||||||
|
|
||||||
def get_disks(self):
|
def get_disks(self):
|
||||||
disk_info = []
|
disk_info = []
|
||||||
for _disk in psutil.disk_partitions():
|
for _disk in psutil.disk_partitions():
|
||||||
|
@ -146,11 +156,12 @@ class Registration():
|
||||||
def generate_password(self):
|
def generate_password(self):
|
||||||
return uuid.uuid4()
|
return uuid.uuid4()
|
||||||
|
|
||||||
|
"""
|
||||||
def get_ip_address(self):
|
def get_ip_address(self):
|
||||||
f = os.popen('ifconfig eth0 | grep "inet\ addr" | cut -d: -f2 | cut -d" " -f1')
|
f = os.popen('ifconfig eth0 | grep "inet\ addr" | cut -d: -f2 | cut -d" " -f1')
|
||||||
return f.read()
|
return f.read()
|
||||||
|
|
||||||
"""
|
|
||||||
#TODO disabled because of netifaces dependency
|
#TODO disabled because of netifaces dependency
|
||||||
def get_ipAddresses(self):
|
def get_ipAddresses(self):
|
||||||
self.logger.debug('[Registration] looking for network interfaces')
|
self.logger.debug('[Registration] looking for network interfaces')
|
||||||
|
|
Loading…
Reference in a new issue