| 1 | ## Copyright 2005, 2006, 2007, 2008, 2009 Virginia Polytechnic Institute and State University |
|---|
| 2 | ## |
|---|
| 3 | ## This file is part of the OSSIE ALF Waveform Application Visualization Environment |
|---|
| 4 | ## |
|---|
| 5 | ## ALF is free software; you can redistribute it and/or modify |
|---|
| 6 | ## it under the terms of the GNU General Public License as published by |
|---|
| 7 | ## the Free Software Foundation; either version 2 of the License, or |
|---|
| 8 | ## (at your option) any later version. |
|---|
| 9 | ## |
|---|
| 10 | ## ALF is distributed in the hope that it will be useful, but WITHOUT ANY |
|---|
| 11 | ## WARRANTY; without even the implied warranty of |
|---|
| 12 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 13 | ## GNU General Public License for more details. |
|---|
| 14 | ## |
|---|
| 15 | ## You should have received a copy of the GNU General Public License |
|---|
| 16 | ## along with OSSIE Waveform Developer; if not, write to the Free Software |
|---|
| 17 | ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 18 | |
|---|
| 19 | import os |
|---|
| 20 | import subprocess |
|---|
| 21 | import shlex |
|---|
| 22 | import time |
|---|
| 23 | import ConfigParser |
|---|
| 24 | import wx |
|---|
| 25 | |
|---|
| 26 | DEFAULT_DOMAIN_MANAGER = 'dom/domain/DomainManager.dmd.xml' |
|---|
| 27 | DEFAULT_DEVICE_MANAGER = 'dev/nodes/default_GPP_node/DeviceManager.dcd.xml' |
|---|
| 28 | |
|---|
| 29 | class NodeBooterUtils: |
|---|
| 30 | def __init__(self, controller): |
|---|
| 31 | self.controller = controller |
|---|
| 32 | |
|---|
| 33 | def nodeBooterIsRunning(self): |
|---|
| 34 | processes = os.popen('ps x | grep nodeBooter').read() |
|---|
| 35 | processes = processes.split() |
|---|
| 36 | return ('/usr/local/bin/nodeBooter' in processes or '/usr/bin/nodeBooter' in processes) |
|---|
| 37 | |
|---|
| 38 | def startNodeBooter(self): |
|---|
| 39 | if self.controller.OSSIEPropertyFileExists(): |
|---|
| 40 | domainManager = self.controller.getOSSIEProperty('ossie', 'default.domain.manager') |
|---|
| 41 | deviceManager = self.controller.getOSSIEProperty('ossie', 'default.device.manager') |
|---|
| 42 | if domainManager == None: |
|---|
| 43 | domainManager = DEFAULT_DOMAIN_MANAGER |
|---|
| 44 | if deviceManager == None: |
|---|
| 45 | deviceManager = DEFAULT_DEVICE_MANAGER |
|---|
| 46 | |
|---|
| 47 | command = '/usr/local/bin/nodeBooter -D ' + domainManager + ' -d ' + deviceManager |
|---|
| 48 | args = shlex.split(command) |
|---|
| 49 | print "NodeBooter not running. Starting now with command: " + command |
|---|
| 50 | nodeBooterProcess = subprocess.Popen(args, cwd='/sdr') |
|---|
| 51 | time.sleep(2) |
|---|
| 52 | return nodeBooterProcess |
|---|
| 53 | |
|---|
| 54 | def namingServiceIsRunning(self): |
|---|
| 55 | namecltResult = os.popen('nameclt list').read() |
|---|
| 56 | if namecltResult.startswith('DomainName'): |
|---|
| 57 | return True |
|---|
| 58 | return False; |
|---|
| 59 | |
|---|
| 60 | def startNamingService(self): |
|---|
| 61 | nsCommand = self.controller.getOSSIEProperty('ossie', 'naming.service.start.command') |
|---|
| 62 | if not nsCommand == None: |
|---|
| 63 | if nsCommand.startswith('sudo'): |
|---|
| 64 | dialog = wx.TextEntryDialog(None, 'Please enter your root password to restart the naming service:', 'Restart Naming Service', '', style = wx.TE_PASSWORD | wx.OK | wx.CANCEL) |
|---|
| 65 | if dialog.ShowModal() == wx.ID_OK: |
|---|
| 66 | password = dialog.GetValue() |
|---|
| 67 | command = 'echo ' + '\"' + password + '\"' + ' | sudo -kS ' + nsCommand[5:] |
|---|
| 68 | subprocess.Popen(command, shell=True) |
|---|
| 69 | time.sleep(2) |
|---|
| 70 | else: |
|---|
| 71 | subprocess.Popen(nsCommand, shell=True) |
|---|
| 72 | else: |
|---|
| 73 | #default case |
|---|
| 74 | nsCommand = 'sudo service omniorb4-nameserver restart' |
|---|
| 75 | dialog = wx.TextEntryDialog(None, 'Please enter your root password to restart the naming service:', 'Restart Naming Service', '', style = wx.TE_PASSWORD | wx.OK | wx.CANCEL) |
|---|
| 76 | if dialog.ShowModal() == wx.ID_OK: |
|---|
| 77 | password = dialog.GetValue() |
|---|
| 78 | command = 'echo ' + '\"' + password + '\"' + ' | sudo -kS ' + nsCommand[5:] |
|---|
| 79 | subprocess.Popen(command, shell=True) |
|---|
| 80 | time.sleep(2) |
|---|
| 81 | |
|---|