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

[Xen-API] [PATCH 1 of 1] [CA-43971]: Adding the tool to generate the pool secret, including



 OMakefile                 |   1 +
 ocaml/OMakefile           |   1 +
 ocaml/ptoken/OMakefile    |  20 ++++++++++++++++++++
 ocaml/ptoken/genptoken.ml |  23 +++++++++++++++++++++++
 scripts/OMakefile         |   1 +
 scripts/init.d-genptoken  |  31 +++++++++++++++++++++++++++++++
 xapi.spec                 |   3 +++
 7 files changed, 80 insertions(+), 0 deletions(-)


# HG changeset patch
# User Magnus Therning <magnus.therning@xxxxxxxxxx>
# Date 1284031406 -3600
# Node ID a500d8f243184060e390f08e0c69f0a69a5c65e4
# Parent  b3d298b4ebab2ccfe6e481410008f54758615f2a
[CA-43971]: Adding the tool to generate the pool secret, including
the init-script to fire it off on boot.

Signed-off-by: Magnus Therning <magnus.therning@xxxxxxxxxx>

diff -r b3d298b4ebab -r a500d8f24318 OMakefile
--- a/OMakefile Wed Sep 01 11:41:42 2010 +0100
+++ b/OMakefile Thu Sep 09 12:23:26 2010 +0100
@@ -121,6 +121,7 @@
        ocaml/license/v6d-reopen-logs
 
 OCAML_PHASE3_NOXEN = \
+                    ocaml/ptoken/genptoken \
        ocaml/auth/testauthx \
        ocaml/xe-cli/xe \
        ocaml/xsh/xsh \
diff -r b3d298b4ebab -r a500d8f24318 ocaml/OMakefile
--- a/ocaml/OMakefile   Wed Sep 01 11:41:42 2010 +0100
+++ b/ocaml/OMakefile   Thu Sep 09 12:23:26 2010 +0100
@@ -5,6 +5,7 @@
 OCAMLPACKS    = stdext log
 
 .SUBDIRS: \
+    ptoken \
        autogen \
        xe-cli \
        xapimon \
diff -r b3d298b4ebab -r a500d8f24318 ocaml/ptoken/OMakefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/ocaml/ptoken/OMakefile    Thu Sep 09 12:23:26 2010 +0100
@@ -0,0 +1,20 @@
+OCAMLPACKS = uuid
+
+GENSECRET_SRC_FILES = genptoken.ml
+
+section
+       OCamlProgram(genptoken, genptoken)
+
+.PHONY: clean
+clean:
+       rm -f $(CLEAN_OBJS) genptoken
+
+.PHONY: install
+install:
+       mkdir -p $(LIBEXEC)
+       $(IPROG) genptoken $(LIBEXEC)
+       mkdir -p $(DIST)/genptoken-src
+       $(IDATA) $(GENSECRET_SRC_FILES) $(DIST)/genptoken-src
+
+.PHONY: sdk-install
+sdk-install: install
diff -r b3d298b4ebab -r a500d8f24318 ocaml/ptoken/genptoken.ml
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/ocaml/ptoken/genptoken.ml Thu Sep 09 12:23:26 2010 +0100
@@ -0,0 +1,23 @@
+(* tool to generate pool secrets *)
+
+type options = { force : bool; tgtfile : string }
+
+let options = ref { force = false; tgtfile = "/etc/xensource/ptoken" }
+
+let set_force _ = options := { !options with force = true }
+let set_target s = options := { !options with tgtfile = s }
+
+let opt_force = ("-f", Arg.Unit set_force, "force generation of pool token, 
overwriting any existing one")
+let opt_target = ("-o", Arg.String set_target, "name of file to write to 
[ptoken]")
+let opts = [opt_force; opt_target]
+
+let _ =
+       Arg.parse opts (fun _ -> ()) "Generate a pool token";
+       if Sys.file_exists !options.tgtfile
+               then if !options.force
+                       then Sys.remove !options.tgtfile
+                       else begin print_endline "File exists, use -f to 
replace it."; exit 1 end;
+       let uuid _ = Uuid.to_string (Uuid.make_uuid ()) in
+       let uuids = String.concat "/" [uuid (); uuid (); uuid ()] in
+       let f = open_out_gen [Open_wronly; Open_creat; Open_excl; Open_binary] 
0o640 !options.tgtfile in
+       output_string f uuids
diff -r b3d298b4ebab -r a500d8f24318 scripts/OMakefile
--- a/scripts/OMakefile Wed Sep 01 11:41:42 2010 +0100
+++ b/scripts/OMakefile Thu Sep 09 12:23:26 2010 +0100
@@ -32,6 +32,7 @@
        $(IPROG) init.d-xapi-domains $(DESTDIR)/etc/rc.d/init.d/xapi-domains
        $(IPROG) init.d-squeezed $(DESTDIR)/etc/rc.d/init.d/squeezed
        $(IPROG) init.d-management-interface 
$(DESTDIR)/etc/rc.d/init.d/management-interface
+       $(IPROG) init.d-genptoken $(DESTDIR)/etc/rc.d/init.d/genptoken
        $(IDATA) squeezed-logrotate $(DESTDIR)/etc/logrotate.d/squeezed
        $(IPROG) init.d-v6d $(DESTDIR)/etc/rc.d/init.d/v6d
        $(IDATA) v6d-logrotate $(DESTDIR)/etc/logrotate.d/v6d
diff -r b3d298b4ebab -r a500d8f24318 scripts/init.d-genptoken
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/init.d-genptoken  Thu Sep 09 12:23:26 2010 +0100
@@ -0,0 +1,31 @@
+#! /bin/sh
+#
+# genptoken    Generate a pool secret (ptoken)
+#
+# chkconfig: 2345 22 78
+# description: Generate pool secret
+
+. /etc/init.d/functions
+
+start() {
+    echo -n $"Creating pool secret (this may take some time)"
+
+    if [ ! -f /etc/xensource/ptoken ]; then
+        /opt/xensource/libexec/genptoken -f -o /etc/xensource/ptoken
+    fi
+
+    [ $? -eq 0 ] && success $"Done" || failure
+    echo
+}
+
+case "$1" in
+    start)
+        start
+       ;;
+    stop|status)
+       ;;
+    *)
+       echo $"Usage: $0 {start|stop|status}"
+       exit 1
+        ;;
+esac
diff -r b3d298b4ebab -r a500d8f24318 xapi.spec
--- a/xapi.spec Wed Sep 01 11:41:42 2010 +0100
+++ b/xapi.spec Thu Sep 09 12:23:26 2010 +0100
@@ -106,6 +106,7 @@
 [ ! -x /sbin/chkconfig ] || chkconfig --add xapi-domains
 [ ! -x /sbin/chkconfig ] || chkconfig --add perfmon
 [ ! -x /sbin/chkconfig ] || chkconfig --add v6d
+[ ! -x /sbin/chkconfig ] || chkconfig --add genptoken
 
 %post squeezed
 [ ! -x /sbin/chkconfig ] || chkconfig squeezed on
@@ -125,6 +126,7 @@
 /etc/rc.d/init.d/xapissl
 /etc/rc.d/init.d/xenservices
 /etc/rc.d/init.d/sdkinit
+/etc/rc.d/init.d/genptoken
 /etc/sysconfig/perfmon
 /etc/sysconfig/xapi
 /etc/udev/rules.d/xen-backend.rules
@@ -220,6 +222,7 @@
 /opt/xensource/libexec/mail-alarm
 /opt/xensource/libexec/print-custom-templates
 /opt/xensource/libexec/probe-device-for-file
+/opt/xensource/libexec/genptoken
 /opt/xensource/libexec/qemu-dm-wrapper
 /opt/xensource/libexec/restore-sr-metadata.py
 /opt/xensource/libexec/restore-sr-metadata.pyo
_______________________________________________
xen-api mailing list
xen-api@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/mailman/listinfo/xen-api

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.