summaryrefslogtreecommitdiffstats
path: root/usr/local/www/diag_gmirror.php
diff options
context:
space:
mode:
Diffstat (limited to 'usr/local/www/diag_gmirror.php')
-rw-r--r--usr/local/www/diag_gmirror.php207
1 files changed, 110 insertions, 97 deletions
diff --git a/usr/local/www/diag_gmirror.php b/usr/local/www/diag_gmirror.php
index adb61f5..f1ceef2 100644
--- a/usr/local/www/diag_gmirror.php
+++ b/usr/local/www/diag_gmirror.php
@@ -8,11 +8,11 @@
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
+ this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INClUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
@@ -53,7 +53,7 @@ include("head.inc");
<?php include("fbegin.inc"); ?>
-<?PHP
+<?php
$action_list = array(
"forget" => gettext("Forget all formerly connected consumers"),
"clear" => gettext("Remove metadata from disk"),
@@ -77,41 +77,51 @@ if ($_POST) {
}
$input_errors = "";
- if (($_POST['action'] != "clear") && !is_valid_mirror($_POST['mirror']))
+ if (($_POST['action'] != "clear") && !is_valid_mirror($_POST['mirror'])) {
$input_errors[] = gettext("You must supply a valid mirror name.");
+ }
- if (!empty($_POST['consumer']) && !is_valid_consumer($_POST['consumer']))
+ if (!empty($_POST['consumer']) && !is_valid_consumer($_POST['consumer'])) {
$input_errors[] = gettext("You must supply a valid consumer name");
+ }
/* Additional action-specific validation that hasn't already been tested */
switch ($_POST['action']) {
case "insert":
- if (!is_consumer_unused($_POST['consumer']))
+ if (!is_consumer_unused($_POST['consumer'])) {
$input_errors[] = gettext("Consumer is already in use and cannot be inserted. Remove consumer from existing mirror first.");
- if (gmirror_consumer_has_metadata($_POST['consumer']))
+ }
+ if (gmirror_consumer_has_metadata($_POST['consumer'])) {
$input_errors[] = gettext("Consumer has metadata from an existing mirror. Clear metadata before inserting consumer.");
+ }
$mstat = gmirror_get_status_single($_POST['mirror']);
- if (strtoupper($mstat) != "COMPLETE")
+ if (strtoupper($mstat) != "COMPLETE") {
$input_errors[] = gettext("Mirror is not in a COMPLETE state, cannot insert consumer. Forget disconnected disks or wait for rebuild to finish.");
+ }
break;
case "clear":
- if (!is_consumer_unused($_POST['consumer']))
+ if (!is_consumer_unused($_POST['consumer'])) {
$input_errors[] = gettext("Consumer is in use and cannot be cleared. Deactivate disk first.");
- if (!gmirror_consumer_has_metadata($_POST['consumer']))
+ }
+ if (!gmirror_consumer_has_metadata($_POST['consumer'])) {
$input_errors[] = gettext("Consumer has no metadata to clear.");
+ }
break;
case "activate":
- if (is_consumer_in_mirror($_POST['consumer'], $_POST['mirror']))
+ if (is_consumer_in_mirror($_POST['consumer'], $_POST['mirror'])) {
$input_errors[] = gettext("Consumer is already present on specified mirror.");
- if (!gmirror_consumer_has_metadata($_POST['consumer']))
+ }
+ if (!gmirror_consumer_has_metadata($_POST['consumer'])) {
$input_errors[] = gettext("Consumer has no metadata and cannot be reactivated.");
-
+ }
+
break;
case "remove":
case "deactivate":
case "rebuild":
- if (!is_consumer_in_mirror($_POST['consumer'], $_POST['mirror']))
+ if (!is_consumer_in_mirror($_POST['consumer'], $_POST['mirror'])) {
$input_errors[] = gettext("Consumer must be present on the specified mirror.");
+ }
break;
}
@@ -156,14 +166,17 @@ $mirror_list = gmirror_get_mirrors();
$unused_disks = gmirror_get_disks();
$unused_consumers = array();
foreach ($unused_disks as $disk) {
- if (is_consumer_unused($disk))
+ if (is_consumer_unused($disk)) {
$unused_consumers = array_merge($unused_consumers, gmirror_get_all_unused_consumer_sizes_on_disk($disk));
+ }
}
-if ($input_errors)
+if ($input_errors) {
print_input_errors($input_errors);
-if ($_GET["error"] && ($_GET["error"] != 0))
+}
+if ($_GET["error"] && ($_GET["error"] != 0)) {
print_info_box(gettext("There was an error performing the chosen mirror operation. Check the System Log for details."));
+}
?>
<form action="diag_gmirror.php" method="POST" id="gmirror_form" name="gmirror_form">
@@ -181,152 +194,152 @@ if ($_GET["error"] && ($_GET["error"] != 0))
<p/>
<table width="100%" border="0" cellpadding="6" cellspacing="0">
-<?PHP if ($_GET["action"]): ?>
+<?php if ($_GET["action"]): ?>
<tr>
- <td colspan="2" valign="top" class="listtopic"><?PHP echo gettext("Confirm Action"); ?></td>
+ <td colspan="2" valign="top" class="listtopic"><?php echo gettext("Confirm Action"); ?></td>
</tr>
<tr>
<td width="22%" valign="top" class="vncell">&nbsp;</td>
<td width="78%" class="vtable">
- <strong><?PHP echo gettext("Please confirm the selected action"); ?></strong>:
+ <strong><?php echo gettext("Please confirm the selected action"); ?></strong>:
<br />
- <br /><strong><?PHP echo gettext("Action"); ?>:</strong> <?PHP echo $action_list[$_GET["action"]]; ?>
- <input type="hidden" name="action" value="<?PHP echo htmlspecialchars($_GET["action"]); ?>" />
- <?PHP if (!empty($_GET["mirror"])): ?>
- <br /><strong><?PHP echo gettext("Mirror"); ?>:</strong> <?PHP echo htmlspecialchars($_GET["mirror"]); ?>
- <input type="hidden" name="mirror" value="<?PHP echo htmlspecialchars($_GET["mirror"]); ?>" />
- <?PHP endif; ?>
- <?PHP if (!empty($_GET["consumer"])): ?>
- <br /><strong><?PHP echo gettext("Consumer"); ?>:</strong> <?PHP echo htmlspecialchars($_GET["consumer"]); ?>
- <input type="hidden" name="consumer" value="<?PHP echo htmlspecialchars($_GET["consumer"]); ?>" />
- <?PHP endif; ?>
+ <br /><strong><?php echo gettext("Action"); ?>:</strong> <?php echo $action_list[$_GET["action"]]; ?>
+ <input type="hidden" name="action" value="<?php echo htmlspecialchars($_GET["action"]); ?>" />
+ <?php if (!empty($_GET["mirror"])): ?>
+ <br /><strong><?php echo gettext("Mirror"); ?>:</strong> <?php echo htmlspecialchars($_GET["mirror"]); ?>
+ <input type="hidden" name="mirror" value="<?php echo htmlspecialchars($_GET["mirror"]); ?>" />
+ <?php endif; ?>
+ <?php if (!empty($_GET["consumer"])): ?>
+ <br /><strong><?php echo gettext("Consumer"); ?>:</strong> <?php echo htmlspecialchars($_GET["consumer"]); ?>
+ <input type="hidden" name="consumer" value="<?php echo htmlspecialchars($_GET["consumer"]); ?>" />
+ <?php endif; ?>
<br />
- <br /><input type="submit" name="confirm" value="<?PHP echo gettext("Confirm"); ?>" />
+ <br /><input type="submit" name="confirm" value="<?php echo gettext("Confirm"); ?>" />
</td>
</tr>
-<?PHP else: ?>
+<?php else: ?>
<tr>
- <td colspan="2" valign="top" class="listtopic"><?PHP echo gettext("GEOM Mirror information"); ?></td>
+ <td colspan="2" valign="top" class="listtopic"><?php echo gettext("GEOM Mirror information"); ?></td>
</tr>
<tr>
- <td width="22%" valign="top" class="vncell"><?PHP echo gettext("Mirror Status"); ?></td>
+ <td width="22%" valign="top" class="vncell"><?php echo gettext("Mirror Status"); ?></td>
<td width="78%" class="vtable">
<table width="100%" border="0" cellspacing="0" cellpadding="0" summary="gmirror status">
<tbody id="gmirror_status_table">
- <?PHP if (count($mirror_status) > 0): ?>
+ <?php if (count($mirror_status) > 0): ?>
<tr>
- <td width="30%" class="vncellt"><?PHP echo gettext("Name"); ?></td>
- <td width="30%" class="vncellt"><?PHP echo gettext("Status"); ?></td>
- <td width="40%" class="vncellt"><?PHP echo gettext("Component"); ?></td>
+ <td width="30%" class="vncellt"><?php echo gettext("Name"); ?></td>
+ <td width="30%" class="vncellt"><?php echo gettext("Status"); ?></td>
+ <td width="40%" class="vncellt"><?php echo gettext("Component"); ?></td>
</tr>
- <?PHP foreach ($mirror_status as $mirror => $name):
+ <?php foreach ($mirror_status as $mirror => $name):
$components = count($name["components"]); ?>
<tr>
- <td width="30%" rowspan="<?PHP echo $components; ?>" class="listr">
- <?PHP echo htmlspecialchars($name['name']); ?>
- <br />Size: <?PHP echo gmirror_get_mirror_size($name['name']); ?>
+ <td width="30%" rowspan="<?php echo $components; ?>" class="listr">
+ <?php echo htmlspecialchars($name['name']); ?>
+ <br />Size: <?php echo gmirror_get_mirror_size($name['name']); ?>
</td>
- <td width="30%" rowspan="<?PHP echo $components; ?>" class="listr">
- <?PHP echo htmlspecialchars($name['status']); ?>
- <?PHP if (strtoupper($name['status']) == "DEGRADED"): ?>
- <br /><a href="diag_gmirror.php?action=forget&amp;mirror=<?PHP echo htmlspecialchars($name['name']); ?>">[<?PHP echo gettext("Forget Disconnected Disks"); ?>]</a>
- <?PHP endif; ?>
+ <td width="30%" rowspan="<?php echo $components; ?>" class="listr">
+ <?php echo htmlspecialchars($name['status']); ?>
+ <?php if (strtoupper($name['status']) == "DEGRADED"): ?>
+ <br /><a href="diag_gmirror.php?action=forget&amp;mirror=<?php echo htmlspecialchars($name['name']); ?>">[<?php echo gettext("Forget Disconnected Disks"); ?>]</a>
+ <?php endif; ?>
</td>
<td width="40%" class="listr">
- <?PHP echo $name['components'][0]; ?>
- <?PHP list($cname, $cstatus) = explode(" ", $name['components'][0], 2); ?>
+ <?php echo $name['components'][0]; ?>
+ <?php list($cname, $cstatus) = explode(" ", $name['components'][0], 2); ?>
<br />
- <?PHP if ((strtoupper($name['status']) == "COMPLETE") && (count($name["components"]) > 1)): ?>
- <a href="diag_gmirror.php?action=rebuild&amp;consumer=<?PHP echo htmlspecialchars($cname); ?>&amp;mirror=<?PHP echo htmlspecialchars($name['name']); ?>">[<?PHP echo gettext("Rebuild"); ?>]</a>
- <a href="diag_gmirror.php?action=deactivate&amp;consumer=<?PHP echo htmlspecialchars($cname); ?>&amp;mirror=<?PHP echo htmlspecialchars($name['name']); ?>">[<?PHP echo gettext("Deactivate"); ?>]</a>
- <a href="diag_gmirror.php?action=remove&amp;consumer=<?PHP echo htmlspecialchars($cname); ?>&amp;mirror=<?PHP echo htmlspecialchars($name['name']); ?>">[<?PHP echo gettext("Remove"); ?>]</a>
- <?PHP endif; ?>
+ <?php if ((strtoupper($name['status']) == "COMPLETE") && (count($name["components"]) > 1)): ?>
+ <a href="diag_gmirror.php?action=rebuild&amp;consumer=<?php echo htmlspecialchars($cname); ?>&amp;mirror=<?php echo htmlspecialchars($name['name']); ?>">[<?php echo gettext("Rebuild"); ?>]</a>
+ <a href="diag_gmirror.php?action=deactivate&amp;consumer=<?php echo htmlspecialchars($cname); ?>&amp;mirror=<?php echo htmlspecialchars($name['name']); ?>">[<?php echo gettext("Deactivate"); ?>]</a>
+ <a href="diag_gmirror.php?action=remove&amp;consumer=<?php echo htmlspecialchars($cname); ?>&amp;mirror=<?php echo htmlspecialchars($name['name']); ?>">[<?php echo gettext("Remove"); ?>]</a>
+ <?php endif; ?>
</td>
</tr>
- <?PHP if (count($name["components"]) > 1):
+ <?php if (count($name["components"]) > 1):
$morecomponents = array_slice($name["components"], 1); ?>
- <?PHP foreach ($morecomponents as $component): ?>
+ <?php foreach ($morecomponents as $component): ?>
<tr>
<td width="40%" class="listr">
- <?PHP echo $component; ?>
- <?PHP list($cname, $cstatus) = explode(" ", $component, 2); ?>
+ <?php echo $component; ?>
+ <?php list($cname, $cstatus) = explode(" ", $component, 2); ?>
<br />
- <?PHP if ((strtoupper($name['status']) == "COMPLETE") && (count($name["components"]) > 1)): ?>
- <a href="diag_gmirror.php?action=rebuild&amp;consumer=<?PHP echo htmlspecialchars($cname); ?>&amp;mirror=<?PHP echo htmlspecialchars($name['name']); ?>">[<?PHP echo gettext("Rebuild"); ?>]</a>
- <a href="diag_gmirror.php?action=deactivate&amp;consumer=<?PHP echo htmlspecialchars($cname); ?>&amp;mirror=<?PHP echo htmlspecialchars($name['name']); ?>">[<?PHP echo gettext("Deactivate"); ?>]</a>
- <a href="diag_gmirror.php?action=remove&amp;consumer=<?PHP echo htmlspecialchars($cname); ?>&amp;mirror=<?PHP echo htmlspecialchars($name['name']); ?>">[<?PHP echo gettext("Remove"); ?>]</a>
- <?PHP endif; ?>
+ <?php if ((strtoupper($name['status']) == "COMPLETE") && (count($name["components"]) > 1)): ?>
+ <a href="diag_gmirror.php?action=rebuild&amp;consumer=<?php echo htmlspecialchars($cname); ?>&amp;mirror=<?php echo htmlspecialchars($name['name']); ?>">[<?php echo gettext("Rebuild"); ?>]</a>
+ <a href="diag_gmirror.php?action=deactivate&amp;consumer=<?php echo htmlspecialchars($cname); ?>&amp;mirror=<?php echo htmlspecialchars($name['name']); ?>">[<?php echo gettext("Deactivate"); ?>]</a>
+ <a href="diag_gmirror.php?action=remove&amp;consumer=<?php echo htmlspecialchars($cname); ?>&amp;mirror=<?php echo htmlspecialchars($name['name']); ?>">[<?php echo gettext("Remove"); ?>]</a>
+ <?php endif; ?>
</td>
</tr>
- <?PHP endforeach; ?>
- <?PHP endif; ?>
- <?PHP endforeach; ?>
- <?PHP else: ?>
- <tr><td colspan="3" class="listr"><?PHP echo gettext("No Mirrors Found"); ?></td></tr>
- <?PHP endif; ?>
+ <?php endforeach; ?>
+ <?php endif; ?>
+ <?php endforeach; ?>
+ <?php else: ?>
+ <tr><td colspan="3" class="listr"><?php echo gettext("No Mirrors Found"); ?></td></tr>
+ <?php endif; ?>
</tbody>
</table>
- <br /><?PHP echo gettext("Some disk operations may only be performed when there are multiple consumers present in a mirror."); ?>
+ <br /><?php echo gettext("Some disk operations may only be performed when there are multiple consumers present in a mirror."); ?>
</td>
</tr>
<tr>
- <td colspan="2" valign="top" class="listtopic"><?PHP echo gettext("Consumer information"); ?></td>
+ <td colspan="2" valign="top" class="listtopic"><?php echo gettext("Consumer information"); ?></td>
</tr>
<tr>
- <td width="22%" valign="top" class="vncell"><?PHP echo gettext("Available Consumers"); ?></td>
+ <td width="22%" valign="top" class="vncell"><?php echo gettext("Available Consumers"); ?></td>
<td width="78%" class="vtable">
<table width="100%" border="0" cellspacing="0" cellpadding="0" summary="consumer list">
<tbody id="consumer_list">
- <?PHP if (count($unused_consumers) > 0): ?>
+ <?php if (count($unused_consumers) > 0): ?>
<tr>
- <td width="30%" class="vncellt"><?PHP echo gettext("Name"); ?></td>
- <td width="30%" class="vncellt"><?PHP echo gettext("Size"); ?></td>
- <td width="40%" class="vncellt"><?PHP echo gettext("Add to Mirror"); ?></td>
+ <td width="30%" class="vncellt"><?php echo gettext("Name"); ?></td>
+ <td width="30%" class="vncellt"><?php echo gettext("Size"); ?></td>
+ <td width="40%" class="vncellt"><?php echo gettext("Add to Mirror"); ?></td>
</tr>
- <?PHP foreach ($unused_consumers as $consumer): ?>
+ <?php foreach ($unused_consumers as $consumer): ?>
<tr>
<td width="30%" class="listr">
- <?PHP echo htmlspecialchars($consumer['name']); ?>
+ <?php echo htmlspecialchars($consumer['name']); ?>
</td>
- <td width="30%" class="listr"><?PHP echo htmlspecialchars($consumer['size']); ?> <?PHP echo htmlspecialchars($consumer['humansize']); ?></td>
+ <td width="30%" class="listr"><?php echo htmlspecialchars($consumer['size']); ?> <?php echo htmlspecialchars($consumer['humansize']); ?></td>
<td width="40%" class="listr">
- <?PHP $oldmirror = gmirror_get_consumer_metadata_mirror($consumer['name']);
+ <?php $oldmirror = gmirror_get_consumer_metadata_mirror($consumer['name']);
if ($oldmirror): ?>
- <a href="diag_gmirror.php?action=activate&amp;consumer=<?PHP echo htmlspecialchars($consumer['name']); ?>&amp;mirror=<?PHP echo htmlspecialchars($oldmirror); ?>">[<?PHP echo gettext("Reactivate on:") . ' ' . htmlspecialchars($oldmirror); ?>]</a>
- <br /><a href="diag_gmirror.php?action=clear&amp;consumer=<?PHP echo htmlspecialchars($consumer['name']); ?>">[<?PHP echo gettext("Remove metadata from disk"); ?>]</a>
- <?PHP else: ?>
- <?PHP foreach ($mirror_list as $mirror):
+ <a href="diag_gmirror.php?action=activate&amp;consumer=<?php echo htmlspecialchars($consumer['name']); ?>&amp;mirror=<?php echo htmlspecialchars($oldmirror); ?>">[<?php echo gettext("Reactivate on:") . ' ' . htmlspecialchars($oldmirror); ?>]</a>
+ <br /><a href="diag_gmirror.php?action=clear&amp;consumer=<?php echo htmlspecialchars($consumer['name']); ?>">[<?php echo gettext("Remove metadata from disk"); ?>]</a>
+ <?php else: ?>
+ <?php foreach ($mirror_list as $mirror):
$mirror_size = gmirror_get_mirror_size($mirror);
$consumer_size = gmirror_get_unused_consumer_size($consumer['name']);
?>
- <?PHP if ($consumer_size > $mirror_size): ?>
- <a href="diag_gmirror.php?action=insert&amp;consumer=<?PHP echo htmlspecialchars($consumer['name']); ?>&amp;mirror=<?PHP echo htmlspecialchars($mirror); ?>"><?PHP echo htmlspecialchars($mirror); ?></a>
- <?PHP endif; ?>
- <?PHP endforeach; ?>
- <?PHP endif; ?>
+ <?php if ($consumer_size > $mirror_size): ?>
+ <a href="diag_gmirror.php?action=insert&amp;consumer=<?php echo htmlspecialchars($consumer['name']); ?>&amp;mirror=<?php echo htmlspecialchars($mirror); ?>"><?php echo htmlspecialchars($mirror); ?></a>
+ <?php endif; ?>
+ <?php endforeach; ?>
+ <?php endif; ?>
</td>
</tr>
- <?PHP endforeach; ?>
- <?PHP else: ?>
- <tr><td colspan="3" class="listr"><?PHP echo gettext("No unused consumers found"); ?></td></tr>
- <?PHP endif; ?>
+ <?php endforeach; ?>
+ <?php else: ?>
+ <tr><td colspan="3" class="listr"><?php echo gettext("No unused consumers found"); ?></td></tr>
+ <?php endif; ?>
</tbody>
</table>
- <br /><?PHP echo gettext("Consumers may only be added to a mirror if they are larger than the size of the mirror."); ?>
+ <br /><?php echo gettext("Consumers may only be added to a mirror if they are larger than the size of the mirror."); ?>
</td>
</tr>
<tr>
<td colspan="2" valign="top" class="">&nbsp;</td>
</tr>
<tr>
- <td colspan="2" valign="top" class=""><?PHP echo gettext("To repair a failed mirror, first perform a 'Forget' command on the mirror, followed by an 'insert' action on the new consumer."); ?></td>
+ <td colspan="2" valign="top" class=""><?php echo gettext("To repair a failed mirror, first perform a 'Forget' command on the mirror, followed by an 'insert' action on the new consumer."); ?></td>
</tr>
-<?PHP endif;?>
+<?php endif;?>
</table>
</div>
</td>
OpenPOWER on IntegriCloud