cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Marek 'marx' Grac <mgrac@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH] fence_rackswitch: Add metadata output for fence_rackswitch agent
Date: Mon, 28 Nov 2011 12:07:14 +0100	[thread overview]
Message-ID: <1322478434-22302-1-git-send-email-mgrac@redhat.com> (raw)

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



             reply	other threads:[~2011-11-28 11:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-28 11:07 Marek 'marx' Grac [this message]
2011-11-28 11:20 ` [Cluster-devel] [PATCH] fence_rackswitch: Add metadata output for fence_rackswitch agent Fabio M. Di Nitto

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1322478434-22302-1-git-send-email-mgrac@redhat.com \
    --to=mgrac@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).