#718: OGAgent realiza varios intentos de activación hasta que la interfaz de red esté activa o pasen 30 s.; mejorar proceso de creación de OGAgent en Windows y macOS.

git-svn-id: https://opengnsys.es/svn/branches/version1.1@5238 a21b9725-9963-47de-94b9-378ad31fedc9
oglive
ramon 2017-03-20 13:30:47 +00:00
parent 85b3316f82
commit 804c389b8f
4 changed files with 23 additions and 7 deletions

View File

@ -5,14 +5,16 @@
VERSION=1.1.0
AUTHOR="OpenGnsys Project"
# Create directories.
# Create empty directories.
cd $(dirname $0)
rm -fr build
mkdir -p build && cd build
mkdir -p flat/base.pkg flat/Resources/en.lproj
mkdir -p root/Applications
# Copy application and script files.
cp -r ../../src root/Applications/OGAgent.app
cp -r ../scripts .
cp -a ../../src root/Applications/OGAgent.app
cp -a ../scripts .
# Create plist file.
cat << EOT > root/Applications/OGAgent.app/OGAgent.plist

View File

@ -104,7 +104,7 @@ def getNetworkInfo():
'''
for ifname in _getInterfaces():
ip, mac = _getIpAndMac(ifname)
if mac != None: # Skips local interfaces
if mac != None and ip != None: # Skips local interfaces
yield utils.Bunch(name=ifname, mac=mac, ip=ip)

View File

@ -83,11 +83,24 @@ class OpenGnSysWorker(ServerWorker):
self.cmd = None
# Ensure cfg has required configuration variables or an exception will be thrown
self.REST = REST(self.service.config.get('opengnsys', 'remote'))
# Get network interfaces
# Get network interfaces until they are active or timeout (30 sec)
for t in range(0,30):
try:
self.interface = list(operations.getNetworkInfo())[0] # Get first network interface
except Exception as e:
# Wait 1 sec. and retry
sleep(1)
finally:
# Exit loop if interface is active
if self.interface:
if t > 0:
logger.debug("Fetch connection data after {} tries".format(t))
break
# Raise error after timeout
if not self.interface:
raise e
# Generate random secret to send on activation
self.random = ''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(self.length))
# Send initalization message
self.REST.sendMessage('ogagent/started', {'mac': self.interface.mac, 'ip': self.interface.ip, 'secret': self.random, 'ostype': operations.osType, 'osversion': operations.osVersion})

View File

@ -2,3 +2,4 @@
export WINEARCH=win32
export WINEPREFIX=$(realpath $(dirname $0)/wine)
wine cmd /c c:\\ogagent\\build.bat
chmod -x $(dirname $0)/../OGAgentSetup*.exe