diff options
author | Phil Davis <phil.davis@inf.org> | 2015-04-19 18:00:00 +0545 |
---|---|---|
committer | Phil Davis <phil.davis@inf.org> | 2015-04-19 18:00:00 +0545 |
commit | 5f6010605ba8e3ab2fbc27080ec2db80dbd0e32e (patch) | |
tree | cd25c71caf551eb882f460ac6e1c32c8220fe58f /usr/local/www/diag_gmirror.php | |
parent | 0608bd3c354ea76eb6df9ed9322e2ef8686f15e7 (diff) | |
download | pfsense-5f6010605ba8e3ab2fbc27080ec2db80dbd0e32e.zip pfsense-5f6010605ba8e3ab2fbc27080ec2db80dbd0e32e.tar.gz |
Code style usr-local-www diag
Diffstat (limited to 'usr/local/www/diag_gmirror.php')
-rw-r--r-- | usr/local/www/diag_gmirror.php | 207 |
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"> </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&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&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&consumer=<?PHP echo htmlspecialchars($cname); ?>&mirror=<?PHP echo htmlspecialchars($name['name']); ?>">[<?PHP echo gettext("Rebuild"); ?>]</a> - <a href="diag_gmirror.php?action=deactivate&consumer=<?PHP echo htmlspecialchars($cname); ?>&mirror=<?PHP echo htmlspecialchars($name['name']); ?>">[<?PHP echo gettext("Deactivate"); ?>]</a> - <a href="diag_gmirror.php?action=remove&consumer=<?PHP echo htmlspecialchars($cname); ?>&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&consumer=<?php echo htmlspecialchars($cname); ?>&mirror=<?php echo htmlspecialchars($name['name']); ?>">[<?php echo gettext("Rebuild"); ?>]</a> + <a href="diag_gmirror.php?action=deactivate&consumer=<?php echo htmlspecialchars($cname); ?>&mirror=<?php echo htmlspecialchars($name['name']); ?>">[<?php echo gettext("Deactivate"); ?>]</a> + <a href="diag_gmirror.php?action=remove&consumer=<?php echo htmlspecialchars($cname); ?>&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&consumer=<?PHP echo htmlspecialchars($cname); ?>&mirror=<?PHP echo htmlspecialchars($name['name']); ?>">[<?PHP echo gettext("Rebuild"); ?>]</a> - <a href="diag_gmirror.php?action=deactivate&consumer=<?PHP echo htmlspecialchars($cname); ?>&mirror=<?PHP echo htmlspecialchars($name['name']); ?>">[<?PHP echo gettext("Deactivate"); ?>]</a> - <a href="diag_gmirror.php?action=remove&consumer=<?PHP echo htmlspecialchars($cname); ?>&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&consumer=<?php echo htmlspecialchars($cname); ?>&mirror=<?php echo htmlspecialchars($name['name']); ?>">[<?php echo gettext("Rebuild"); ?>]</a> + <a href="diag_gmirror.php?action=deactivate&consumer=<?php echo htmlspecialchars($cname); ?>&mirror=<?php echo htmlspecialchars($name['name']); ?>">[<?php echo gettext("Deactivate"); ?>]</a> + <a href="diag_gmirror.php?action=remove&consumer=<?php echo htmlspecialchars($cname); ?>&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&consumer=<?PHP echo htmlspecialchars($consumer['name']); ?>&mirror=<?PHP echo htmlspecialchars($oldmirror); ?>">[<?PHP echo gettext("Reactivate on:") . ' ' . htmlspecialchars($oldmirror); ?>]</a> - <br /><a href="diag_gmirror.php?action=clear&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&consumer=<?php echo htmlspecialchars($consumer['name']); ?>&mirror=<?php echo htmlspecialchars($oldmirror); ?>">[<?php echo gettext("Reactivate on:") . ' ' . htmlspecialchars($oldmirror); ?>]</a> + <br /><a href="diag_gmirror.php?action=clear&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&consumer=<?PHP echo htmlspecialchars($consumer['name']); ?>&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&consumer=<?php echo htmlspecialchars($consumer['name']); ?>&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=""> </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> |