Skip to content
Browse files

Add snapshot action to Status page

  • Loading branch information...
1 parent 4294dac commit e7e8118629dda51bb9e82f300b543ef4b2c037ed @lattera committed Feb 12, 2013
Showing with 25 additions and 0 deletions.
  1. +10 −0 jailadmin.module
  2. +15 −0 jailstatus.inc
View
10 jailadmin.module
@@ -127,6 +127,16 @@ function jailadmin_menu() {
'type' => MENU_NORMAL_ITEM,
);
+ $items['jailadmin/%/snapshot'] = array(
+ 'title' => 'Snapshot Jail',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('jail_snapshot', 1),
+ 'file' => 'jailstatus.inc',
+ 'access callback' => 'jail_config_access',
+ 'access arguments' => array(1),
+ 'type' => MENU_NORMAL_ITEM,
+ );
+
return $items;
}
View
15 jailstatus.inc
@@ -24,6 +24,8 @@ function jailadmin_status($form, &$form_state) {
else
$action = l("Start", "jailadmin/{$jail->name}/start");
+ $action .= " | " . l("Snapshot", "jailadmin/{$jail->name}/snapshot");
+
$rows[] = array($name, $jail->IsOnlineString(), $jail->NetworkStatus(), $action);
}
@@ -67,3 +69,16 @@ function jail_stop($form, &$form_state) {
return jailadmin_status($form, $form_state);
}
+
+function jail_snapshot($form, &$form_state) {
+ $jail = Jail::Load($form_state['build_info']['args'][0]);
+
+ if ($jail->Snapshot())
+ drupal_set_message(t('Jail @jail snapshot successful', array('@jail' => $jail->name)));
+ else
+ drupal_set_message(t('Jail @jail snapshot unsuccessful', array('@jail' => $jail->name)));
+
+ $form_state['rebuild'] = true;
+
+ return jailadmin_status($form, $form_state);
+}

0 comments on commit e7e8118

Please sign in to comment.
Something went wrong with that request. Please try again.