[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Cluster-devel] [PATCH] fence_rackswitch: Add metadata output for fence_rackswitch agent



Adding this feature allow us to generate manual pages directly from XML,
so both GUI tools and manual pages can see same feature.

Resolves: rhbz#714841 (partial)
---
 fence/agents/rackswitch/Makefile.am        |    8 +++
 fence/agents/rackswitch/do_rack.c          |   46 ++++++++++++++++++-
 fence/agents/rackswitch/fence_rackswitch.8 |   70 ----------------------------
 3 files changed, 53 insertions(+), 71 deletions(-)
 delete mode 100644 fence/agents/rackswitch/fence_rackswitch.8

diff --git a/fence/agents/rackswitch/Makefile.am b/fence/agents/rackswitch/Makefile.am
index 29cbef8..b6369e4 100644
--- a/fence/agents/rackswitch/Makefile.am
+++ b/fence/agents/rackswitch/Makefile.am
@@ -9,3 +9,11 @@ noinst_HEADERS		 = do_rack.h
 fence_rackswitch_SOURCES = do_rack.c
 
 dist_man_MANS		 = $(TARGET).8
+
+fence_rackswitch.8: fence_rackswitch $(top_srcdir)/fence/agents/lib/fence2man.xsl
+	set -e && \
+	./$^ -o metadata >  $  tmp && \
+	xsltproc $(top_srcdir)/fence/agents/lib/fence2man.xsl  $  tmp > $@
+
+clean-local:
+	rm -f *.8 .*.8.tmp
\ No newline at end of file
diff --git a/fence/agents/rackswitch/do_rack.c b/fence/agents/rackswitch/do_rack.c
index 854b475..67d24a2 100644
--- a/fence/agents/rackswitch/do_rack.c
+++ b/fence/agents/rackswitch/do_rack.c
@@ -158,6 +158,40 @@ static void print_usage(void)
 
 
 
+static void print_metadata(void)
+{
+  printf("<?xml version=\"1.0\" ?>\n"
+        "<resource-agent name=\"fence_rackswitch\" shortdesc=\"fence_rackswitch - I/O Fencing agent for RackSaver RackSwitch\" >\n"
+        "<longdesc>fence_rackswitch is an I/O Fencing agent which can be used with the RackSaver RackSwitch. It logs into the RackSwitch and boots a specified plug. Using the http interface to the RackSwitch should be avoided while a GFS cluster is running because the connection may interfere with the operation of this agent.</longdesc>\n"
+	"<vendor-url>http://www.bladenetwork.net</vendor-url>\n"
+	"<parameters>\n"
+        "<parameter name=\"ipaddr\" unique=\"1\" required=\"1\">\n"
+        "\t<getopt mixed=\"-a &lt;ip&gt;\" />\n"
+        "\t<content type=\"string\"  />\n"
+        "\t<shortdesc lang=\"en\">IP Address or Hostname</shortdesc>\n"
+        "</parameter>\n"
+        "<parameter name=\"login\" unique=\"1\" required=\"1\">\n"
+        "\t<getopt mixed=\"-l &lt;name&gt;\" />\n"
+        "\t<content type=\"string\"  />\n"
+        "\t<shortdesc lang=\"en\">Login Name</shortdesc>\n"
+        "</parameter>\n"
+        "<parameter name=\"passwd\" unique=\"1\" required=\"0\">\n"
+        "\t<getopt mixed=\"-p &lt;password&gt;\" />\n"
+        "\t<content type=\"string\"  />\n"
+        "\t<shortdesc lang=\"en\">Login password or passphrase</shortdesc>\n"
+        "</parameter>\n"
+        "<parameter name=\"passwd_script\" unique=\"1\" required=\"0\">\n"
+        "\t<getopt mixed=\"-S &lt;script&gt;\" />\n"
+        "\t<content type=\"string\"  />\n"
+        "\t<shortdesc lang=\"en\">Script to retrieve password</shortdesc>\n"
+        "</parameter>\n"
+	"</parameters>\n"
+	"<actions>\n"
+	"\t<action name=\"metadata\" />\n"
+	"</actions>\n"
+	"</resource-agent>\n");
+}
+
 static void get_options(int argc, char **argv)
 {
   int c;
@@ -167,7 +201,7 @@ static void get_options(int argc, char **argv)
     /*
      * Command line input
      */
-    while ((c = getopt(argc, argv, "ha:n:l:p:S:vqVd")) != -1)
+    while ((c = getopt(argc, argv, "ha:n:l:p:S:vqVdo:")) != -1)
       {
 	switch(c)
 	  {
@@ -220,6 +254,16 @@ static void get_options(int argc, char **argv)
 	    fprintf(stderr, "Please use '-h' for usage.\n");
 	    exit(DID_FAILURE);
 	    break;
+          
+          case 'o':
+            if (strncasecmp(optarg, "metadata", 254) == 0) {
+              print_metadata();
+              exit(DID_SUCCESS);              
+            } else {
+              fprintf(stderr, "Only 'metadata' option is aviable for this fence agent\n");
+              exit(DID_FAILURE);
+            }
+            break;
 
 	  default:
 	    fprintf(stderr, "Bad programmer! You forgot to catch the %c flag\n", c);
diff --git a/fence/agents/rackswitch/fence_rackswitch.8 b/fence/agents/rackswitch/fence_rackswitch.8
deleted file mode 100644
index fc64a79..0000000
--- a/fence/agents/rackswitch/fence_rackswitch.8
+++ /dev/null
@@ -1,70 +0,0 @@
-.TH fence_rackswitch 8
-
-.SH NAME
-fence_rackswitch - I/O Fencing agent for RackSaver RackSwitch
-
-.SH SYNOPSIS
-.B
-fence_rackswitch
-[\fIOPTION\fR]...
-
-.SH DESCRIPTION
-fence_rackswitch is an I/O Fencing agent which can be used with the RackSaver 
-RackSwitch.  It logs into the RackSwitch and boots a specified plug.
-Using the http interface to the RackSwitch should be avoided while a GFS cluster is 
-running because the connection may interfere with the operation of this agent.
-
-fence_rackswitch accepts options on the command line as well as from stdin.  
-fenced sends the options through stdin when it execs the agent.  fence_rackswitch 
-can be run by itself with command line options which is useful for testing.
-
-Vendor URL: http://www.bladenetwork.net
-
-.SH OPTIONS
-.TP
-\fB-a\fP \fIIPaddress\fP
-IP address of the switch.
-.TP
-\fB-h\fP
-Print out a help message describing available options, then exit.
-.TP
-\fB-n\fP \fIplug\fP
-The plug number to power cycle.
-.TP
-\fB-p\fP \fIpassword\fP
-Password for login.
-.TP
-\fB-S\fP \fIpath\fR
-Full path to an executable to generate the password for login.
-.TP
-\fB-l\fP \fIusername\fP
-Username for login.
-.TP
-\fB-q\fP
-Quiet operation.  Only print out error messages.
-.TP
-\fB-V\fP
-Print out a version message, then exit.
-
-.SH STDIN PARAMETERS
-.TP
-\fIagent = < param >\fR
-This option is used by fence_node(8) and is ignored by fence_rackswitch.
-.TP
-\fIipaddr = < ip >\fR
-IP address of the switch.
-.TP
-\fIusername = < param >\fR
-Username for login.
-.TP
-\fIpassword = < param >\fR
-Password for login.
-.TP
-\fIpasswd_script = < param >\fR
-Full path to an executable to generate the password for login.
-.TP
-\fIport = < param >\fR
-The port (outlet) number to act upon.
-
-.SH SEE ALSO
-fence(8), fence_node(8)
-- 
1.7.4.4


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]