summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--application/configs/application.ini.dist4
-rw-r--r--application/controllers/GearmanController.php37
-rw-r--r--gearman/controllerWorker/ControllerWorker/BootWorker.java5
-rw-r--r--gearman/controllerWorker/ControllerWorker/ShutdownWorker.java4
-rwxr-xr-xinstall.sh8
-rw-r--r--setup/poolctrl_data.sql10
6 files changed, 46 insertions, 22 deletions
diff --git a/application/configs/application.ini.dist b/application/configs/application.ini.dist
index 92cb0cf..123c33f 100644
--- a/application/configs/application.ini.dist
+++ b/application/configs/application.ini.dist
@@ -30,6 +30,10 @@ pbs2.getperson = /resource/getperson/apikey/
pbs2.getmembership = /resource/getmembership/apikey/
pbs2.getgroup = /resource/getgroup/apikey/
pbs2.getrole = /resource/getrole/apikey/
+gearman.server.host =
+gearman.server.port =
+gearman.worker.waitTime = 120
+gearman.worker.updateRate = 1
resources.layout.layout = "default"
resources.layout.layoutPath = APPLICATION_PATH "/layouts"
diff --git a/application/controllers/GearmanController.php b/application/controllers/GearmanController.php
index 7ca673d..8167275 100644
--- a/application/controllers/GearmanController.php
+++ b/application/controllers/GearmanController.php
@@ -7,6 +7,10 @@ class GearmanController extends Zend_Controller_Action
protected $pbs2host;
protected $userIDsNamespace;
protected $acl;
+ protected $gearmanServerHost;
+ protected $gearmanServerPort;
+ protected $gearmanWorkerUpdateRate;
+ protected $gearmanWorkerWaitTime;
public function init()
{
@@ -18,12 +22,17 @@ class GearmanController extends Zend_Controller_Action
if(isset($this->userIDsNamespace['apikey'])) {
$this->acl = new Poolctrl_Acl($this->pbs2host, $this->config['pbs2']['checkright'] . $this->userIDsNamespace['apikey'], 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
}
+ $this->gearmanServerHost = $this->config['gearman']['server']['host'];
+ $this->gearmanServerPort = $this->config['gearman']['server']['port'];
+ $this->gearmanWorkerWaitTime = $this->config['gearman']['worker']['waitTime'];
+ $this->gearmanWorkerUpdateRate = $this->config['gearman']['worker']['updateRate'];
$this->gearmanClient = new GearmanClient();
- $this->gearmanClient->addServer('127.0.0.1');
+ $this->gearmanClient->addServer($this->gearmanServerHost);
} else {
$this->_helper->redirector('login', 'auth');
return;
}
+
}
public function indexAction()
@@ -91,13 +100,13 @@ class GearmanController extends Zend_Controller_Action
public function bootAction() {
$eventName = 'bootTest';
$eventOS = 'testOS';
- $updateRate = 1;
- $waitTime = 120;
$clients = array(
'eventName' => $eventName,
'eventOS' => $eventOS,
- 'updateRate' => $updateRate,
- 'waitTime' => $waitTime,
+ 'updateRate' => $this->gearmanWorkerUpdateRate,
+ 'waitTime' => $this->gearmanWorkerWaitTime,
+ 'host' => $this->gearmanServerHost,
+ 'port' => $this->gearmanServerPort,
'clients' => array(
0 => array('id' => '1', 'ip' =>'132.230.4.24', 'mac' =>'00:13:72:C7:FD:A1'),
),
@@ -115,12 +124,12 @@ class GearmanController extends Zend_Controller_Action
public function shutdownAction() {
$eventName = 'shutdownTest';
- $updateRate = 1;
- $waitTime = 120;
$clients = array(
'eventName' => $eventName,
- 'updateRate' => $updateRate,
- 'waitTime' => $waitTime,
+ 'updateRate' => $this->gearmanWorkerUpdateRate,
+ 'waitTime' => $this->gearmanWorkerWaitTime,
+ 'host' => $this->gearmanServerHost,
+ 'port' => $this->gearmanServerPort,
'clients' => array(
0 => array('id' => '1', 'ip' =>'132.230.4.24', 'mac' =>'00:13:72:C7:FD:A1'),
),
@@ -135,15 +144,15 @@ class GearmanController extends Zend_Controller_Action
}
$this->view->result = $result;
}
-
+
public function maintenanceAction() {
$eventName = 'maintenance_pool-113'; //maintenance of pool-113
- $updateRate = 1;
- $waitTime = 120;
$clients = array(
'eventName' => $eventName,
- 'updateRate' => $updateRate,
- 'waitTime' => $waitTime,
+ 'updateRate' => $this->gearmanWorkerUpdateRate,
+ 'waitTime' => $this->gearmanWorkerWaitTime,
+ 'host' => $this->gearmanServerHost,
+ 'port' => $this->gearmanServerPort,
'clients' => array(
0 => array('id' => '1', 'ip' =>'132.230.4.121', 'mac' =>'00:1e:0b:a6:f8:19'),
0 => array('id' => '2', 'ip' =>'132.230.4.122', 'mac' =>'00:1e:0b:a6:d5:de'),
diff --git a/gearman/controllerWorker/ControllerWorker/BootWorker.java b/gearman/controllerWorker/ControllerWorker/BootWorker.java
index 9049971..e14e380 100644
--- a/gearman/controllerWorker/ControllerWorker/BootWorker.java
+++ b/gearman/controllerWorker/ControllerWorker/BootWorker.java
@@ -25,6 +25,8 @@ public class BootWorker extends AbstractGearmanFunction {
JSONObject jsonObject = (JSONObject) JSONValue.parse(data);
String event = jsonObject.get("eventName").toString();
String eventOS = jsonObject.get("eventOS").toString();
+ String host = jsonObject.get("host").toString();
+ int port = Integer.parseInt(jsonObject.get("port").toString());
int updateRate = Integer.parseInt(jsonObject.get("updateRate")
.toString());
long waitTime = Long.parseLong(jsonObject.get("waitTime").toString());
@@ -39,8 +41,7 @@ public class BootWorker extends AbstractGearmanFunction {
clients.add(clientMap);
}
- Boot boot = new Boot("127.0.0.1", 4730, clients, updateRate, waitTime,
- eventOS);
+ Boot boot = new Boot(host, port, clients, updateRate, waitTime, eventOS);
StatusWorker.BOOTTHREADS.put(event, boot);
boot.start();
System.out.println("Booting started");
diff --git a/gearman/controllerWorker/ControllerWorker/ShutdownWorker.java b/gearman/controllerWorker/ControllerWorker/ShutdownWorker.java
index d2bfbc3..73c659a 100644
--- a/gearman/controllerWorker/ControllerWorker/ShutdownWorker.java
+++ b/gearman/controllerWorker/ControllerWorker/ShutdownWorker.java
@@ -24,6 +24,8 @@ public class ShutdownWorker extends AbstractGearmanFunction {
Vector<HashMap<String, String>> clients = new Vector<HashMap<String, String>>();
JSONObject jsonObject = (JSONObject) JSONValue.parse(data);
String event = jsonObject.get("eventName").toString();
+ String host = jsonObject.get("host").toString();
+ int port = Integer.parseInt(jsonObject.get("port").toString());
int updateRate = Integer.parseInt(jsonObject.get("updateRate")
.toString());
long waitTime = Long.parseLong(jsonObject.get("waitTime").toString());
@@ -38,7 +40,7 @@ public class ShutdownWorker extends AbstractGearmanFunction {
clients.add(clientMap);
}
- Shutdown shutdown = new Shutdown("127.0.0.1", 4730, clients,
+ Shutdown shutdown = new Shutdown(host, port, clients,
updateRate, waitTime);
StatusWorker.SHUTDOWNTHREADS.put(event, shutdown);
shutdown.start();
diff --git a/install.sh b/install.sh
index d31aa06..51ece48 100755
--- a/install.sh
+++ b/install.sh
@@ -68,6 +68,14 @@ echo -n "Please enter host of pbs2: "
read pbs2_host
sed -e "19s/\$/$pbs2_host/" -i $targetDir/application/configs/application.ini
+echo -n "Please enter host of gearman server: "
+read gearman_server_host
+sed -e "33s/\$/$gearman_server_host/" -i $targetDir/application/configs/application.ini
+
+echo -n "Please enter port of gearman server: "
+read gearman_server_port
+sed -e "34s/\$/$gearman_server_port/" -i $targetDir/application/configs/application.ini
+
echo "Create database and tables"
cat $targetDir/setup/poolctrl.sql | sed -e "s,##poolctrl##,$db_name," > /tmp/poolctrl.sql
mysql -u $db_admin -p$db_adminpass < /tmp/poolctrl.sql
diff --git a/setup/poolctrl_data.sql b/setup/poolctrl_data.sql
index 87ed4ab..365a3a5 100644
--- a/setup/poolctrl_data.sql
+++ b/setup/poolctrl_data.sql
@@ -96,13 +96,13 @@ INSERT INTO `poolctrl_event` (`eventID`, `title`, `start`, `end`, `category`, `p
(2, 'Systeme II', '2011-06-24 14:10:00', '2011-06-24 16:00:00', '1', 1, 1, 1, 'Systeme II Vorlesung', 1, 1),
(3, 'Systeme III', '2011-06-24 16:10:00', '2011-06-24 18:00:00', '1', 1, 1, 1, 'Systeme III Vorlesung', 1, 1);
+-- Adding reporttypes
+INSERT INTO `poolctrl_reporttype` (`reporttypeID`, `title`) VALUES
+(1, 'Boot'),
+(2, 'Shutdown');
+
-- Adding eventreports
INSERT INTO `poolctrl_eventreport` (`reportID`, `report`, `type`, `eventID`) VALUES
(1, DEFAULT, 1, 1),
(2, DEFAULT, 1, 2),
(3, 'wake-on-lan failed', 1, 3);
-
--- Adding reporttypes
-INSERT INTO `poolctrl_reporttype` (`reporttypeID`, `title`) VALUES
-(1, 'Boot'),
-(2, 'Shutdown');