refs #708 OS agent: unhardcode string, do not activate within ogLive
parent
3682ac2b1d
commit
38815028a6
|
@ -106,20 +106,25 @@ class OpenGnSysWorker(ServerWorker):
|
||||||
"""
|
"""
|
||||||
Sends OGAgent activation notification to OpenGnsys server
|
Sends OGAgent activation notification to OpenGnsys server
|
||||||
"""
|
"""
|
||||||
|
if os.path.exists ('/scripts/oginit'):
|
||||||
|
## estamos en oglive, este modulo no debe cargarse
|
||||||
|
## esta lógica la saco de src/opengnsys/linux/operations.py, donde hay un if similar
|
||||||
|
raise Exception ('Refusing to load within an ogLive image')
|
||||||
|
|
||||||
e = None # Error info
|
e = None # Error info
|
||||||
t = 0 # Count of time
|
t = 0 # Count of time
|
||||||
# Generate random secret to send on activation
|
# Generate random secret to send on activation
|
||||||
self.random = ''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(self.length))
|
self.random = ''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(self.length))
|
||||||
# Ensure cfg has required configuration variables or an exception will be thrown
|
# Ensure cfg has required configuration variables or an exception will be thrown
|
||||||
try:
|
try:
|
||||||
url = self.service.config.get('opengnsys', 'remote')
|
url = self.service.config.get(self.name, 'remote')
|
||||||
except NoOptionError as e:
|
except NoOptionError as e:
|
||||||
logger.error("Configuration error: {}".format(e))
|
logger.error("Configuration error: {}".format(e))
|
||||||
raise e
|
raise e
|
||||||
self.REST = REST(url)
|
self.REST = REST(url)
|
||||||
# Execution level ('full' by default)
|
# Execution level ('full' by default)
|
||||||
try:
|
try:
|
||||||
self.exec_level = self.service.config.get('opengnsys', 'level')
|
self.exec_level = self.service.config.get(self.name, 'level')
|
||||||
except NoOptionError:
|
except NoOptionError:
|
||||||
self.exec_level = 'full'
|
self.exec_level = 'full'
|
||||||
# Get network interfaces until they are active or timeout (5 minutes)
|
# Get network interfaces until they are active or timeout (5 minutes)
|
||||||
|
@ -156,7 +161,7 @@ class OpenGnSysWorker(ServerWorker):
|
||||||
logger.warn (str (e))
|
logger.warn (str (e))
|
||||||
# Trying to initialize on alternative server, if defined
|
# Trying to initialize on alternative server, if defined
|
||||||
# (used in "exam mode" from the University of Seville)
|
# (used in "exam mode" from the University of Seville)
|
||||||
self.REST = REST(self.service.config.get('opengnsys', 'altremote'))
|
self.REST = REST(self.service.config.get(self.name, 'altremote'))
|
||||||
self.REST.sendMessage('ogagent/started', {'mac': self.interface.mac, 'ip': self.interface.ip,
|
self.REST.sendMessage('ogagent/started', {'mac': self.interface.mac, 'ip': self.interface.ip,
|
||||||
'secret': self.random, 'ostype': operations.os_type,
|
'secret': self.random, 'ostype': operations.os_type,
|
||||||
'osversion': operations.os_version, 'alt_url': True,
|
'osversion': operations.os_version, 'alt_url': True,
|
||||||
|
|
Loading…
Reference in New Issue