947 want basic administration and interrogation of NGZ services from GZ
Reviewed by: Eric Schrock <
[email protected]>
Reviewed by: Albert Lee <
[email protected]>
Reviewed by: Garrett D'Amore <
[email protected]>
Approved by: Garrett D'Amore <
[email protected]>
--- a/usr/src/cmd/svc/svcadm/svcadm.c Fri Jan 28 14:19:52 2011 -0800
+++ b/usr/src/cmd/svc/svcadm/svcadm.c Fri Feb 11 13:41:27 2011 -0800
@@ -24,6 +24,10 @@
*/
/*
+ * Copyright (c) 2011, Joyent, Inc. All rights reserved.
+ */
+
+/*
* svcadm - request adminstrative actions for service instances
*/
@@ -44,6 +48,7 @@
#include <procfs.h>
#include <assert.h>
#include <errno.h>
+#include <zone.h>
#ifndef TEXT_DOMAIN
#define TEXT_DOMAIN "SUNW_OST_OSCMD"
@@ -140,7 +145,7 @@
usage()
{
(void) fprintf(stderr, gettext(
- "Usage: %1$s [-v] [cmd [args ... ]]\n\n"
+ "Usage: %1$s [-v] [-z zone] [cmd [args ... ]]\n\n"
"\t%1$s enable [-rst] <service> ...\t- enable and online service(s)\n"
"\t%1$s disable [-st] <service> ...\t- disable and offline service(s)\n"
"\t%1$s restart <service> ...\t\t- restart specified service(s)\n"
@@ -2099,16 +2104,40 @@
if (h == NULL)
scfdie();
+ while ((o = getopt(argc, argv, "vz:")) != -1) {
+ switch (o) {
+ case 'v':
+ verbose = 1;
+ break;
+
+ case 'z': {
+ scf_value_t *zone;
+
+ if (getzoneid() != GLOBAL_ZONEID)
+ uu_die(gettext("svcadm -z may only be used "
+ "from the global zone\n"));
+
+ if ((zone = scf_value_create(h)) == NULL)
+ scfdie();
+
+ if (scf_value_set_astring(zone, optarg) != SCF_SUCCESS)
+ scfdie();
+
+ if (scf_handle_decorate(h, "zone", zone) != SCF_SUCCESS)
+ uu_die(gettext("invalid zone '%s'\n"), optarg);
+
+ scf_value_destroy(zone);
+ break;
+ }
+
+ default:
+ usage();
+ }
+ }
+
if (scf_handle_bind(h) == -1)
uu_die(gettext("Couldn't bind to svc.configd.\n"));
- while ((o = getopt(argc, argv, "v")) != -1) {
- if (o == 'v')
- verbose = 1;
- else
- usage();
- }
-
if (optind >= argc)
usage();
--- a/usr/src/cmd/svc/svcprop/svcprop.c Fri Jan 28 14:19:52 2011 -0800
+++ b/usr/src/cmd/svc/svcprop/svcprop.c Fri Feb 11 13:41:27 2011 -0800
@@ -24,7 +24,9 @@
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
+/*
+ * Copyright (c) 2011, Joyent, Inc. All rights reserved.
+ */
/*
* svcprop - report service configuration properties
@@ -41,6 +43,7 @@
#include <unistd.h>
#include <strings.h>
#include <assert.h>
+#include <zone.h>
#ifndef TEXT_DOMAIN
#define TEXT_DOMAIN "SUNW_OST_OSCMD"
@@ -140,10 +143,10 @@
usage()
{
(void) fprintf(stderr, gettext("Usage: %1$s [-fqtv] "
- "[-C | -c | -s snapshot] "
+ "[-C | -c | -s snapshot] [-z zone] "
"[-p [name/]name]... \n"
" {FMRI | pattern}...\n"
- " %1$s -w [-fqtv] [-p [name/]name] "
+ " %1$s -w [-fqtv] [-z zone] [-p [name/]name] "
"{FMRI | pattern}\n"), uu_getpname());
exit(UU_EXIT_USAGE);
}
@@ -1012,7 +1015,11 @@
prop_list = uu_list_create(prop_pool, NULL, 0);
- while ((c = getopt(argc, argv, "Ccfp:qs:tvw")) != -1) {
+ hndl = scf_handle_create(SCF_VERSION);
+ if (hndl == NULL)
+ scfdie();
+
+ while ((c = getopt(argc, argv, "Ccfp:qs:tvwz:")) != -1) {
switch (c) {
case 'C':
if (cflag || sflag || wait)
@@ -1064,6 +1071,27 @@
wait = 1;
break;
+ case 'z': {
+ scf_value_t *zone;
+ scf_handle_t *h = hndl;
+
+ if (getzoneid() != GLOBAL_ZONEID)
+ uu_die(gettext("svcprop -z may only be used "
+ "from the global zone\n"));
+
+ if ((zone = scf_value_create(h)) == NULL)
+ scfdie();
+
+ if (scf_value_set_astring(zone, optarg) != SCF_SUCCESS)
+ scfdie();
+
+ if (scf_handle_decorate(h, "zone", zone) != SCF_SUCCESS)
+ uu_die(gettext("invalid zone '%s'\n"), optarg);
+
+ scf_value_destroy(zone);
+ break;
+ }
+
case '?':
switch (optopt) {
case 'p':
@@ -1090,9 +1118,6 @@
max_scf_fmri_length == -1)
scfdie();
- hndl = scf_handle_create(SCF_VERSION);
- if (hndl == NULL)
- scfdie();
if (scf_handle_bind(hndl) == -1)
die(gettext("Could not connect to configuration repository: "
"%s.\n"), scf_strerror(scf_error()));
--- a/usr/src/man/man1/svcprop.1 Fri Jan 28 14:19:52 2011 -0800
+++ b/usr/src/man/man1/svcprop.1 Fri Feb 11 13:41:27 2011 -0800
@@ -9,13 +9,14 @@
.SH SYNOPSIS
.LP
.nf
-\fBsvcprop\fR [\fB-fqtv\fR] [\fB-C\fR | \fB-c\fR | \fB-s\fR \fIsnapshot\fR] [\fB-p\fR [\fIname\fR/]\fIname\fR]...
+\fBsvcprop\fR [\fB-fqtv\fR] [\fB-C\fR | \fB-c\fR | \fB-s\fR \fIsnapshot\fR]
+ [\fB-z\fR \fIzone\fR] [\fB-p\fR [\fIname\fR/]\fIname\fR]...
{\fIFMRI\fR | \fIpattern\fR}...
.fi
.LP
.nf
-\fBsvcprop\fR \fB-w\fR [\fB-fqtv\fR] [\fB-p\fR [\fIname\fR/]\fIname\fR] {\fIFMRI\fR | \fIpattern\fR}
+\fBsvcprop\fR \fB-w\fR [\fB-fqtv\fR] [\fB-z\fR \fIzone\fR] [\fB-p\fR [\fIname\fR/]\fIname\fR] {\fIFMRI\fR | \fIpattern\fR}
.fi
.SH DESCRIPTION
@@ -186,6 +187,17 @@
message is printed and no action is taken. The -C option is implied.
.RE
+.sp
+.ne 2
+.mk
+.na
+\fB-z\fR \fIzone\fR
+.ad
+.RS 14n
+.rt
+Uses properties from the service or instance in the specified \fIzone\fR.
+This option is only applicable from the global zone, see \fBzones\fR(5).
+
.SH OPERANDS
.sp
.LP
@@ -426,4 +438,5 @@
.LP
\fBsvcs\fR(1), \fBinetd\fR(1M), \fBsvcadm\fR(1M), \fBsvccfg\fR(1M),
\fBsvc.startd\fR(1M), \fBservice_bundle\fR(4), \fBattributes\fR(5),
-\fBfnmatch\fR(5), \fBsmf\fR(5), \fBsmf_method\fR(5), \fBsmf_security\fR(5)
+\fBfnmatch\fR(5), \fBsmf\fR(5), \fBsmf_method\fR(5), \fBsmf_security\fR(5),
+\fBzones\fR(5)
--- a/usr/src/man/man1m/svcadm.1m Fri Jan 28 14:19:52 2011 -0800
+++ b/usr/src/man/man1m/svcadm.1m Fri Feb 11 13:41:27 2011 -0800
@@ -9,32 +9,32 @@
.SH SYNOPSIS
.LP
.nf
-\fB/usr/sbin/svcadm\fR [\fB-v\fR] enable [\fB-rst\fR] {\fIFMRI\fR | \fIpattern\fR}...
+\fB/usr/sbin/svcadm\fR [\fB-v\fR] [\fB-z\fR \fIzone\fR] enable [\fB-rst\fR] {\fIFMRI\fR | \fIpattern\fR}...
.fi
.LP
.nf
-\fB/usr/sbin/svcadm\fR [\fB-v\fR] disable [\fB-st\fR] {\fIFMRI\fR | \fIpattern\fR}...
+\fB/usr/sbin/svcadm\fR [\fB-v\fR] [\fB-z\fR \fIzone\fR] disable [\fB-st\fR] {\fIFMRI\fR | \fIpattern\fR}...
.fi
.LP
.nf
-\fB/usr/sbin/svcadm\fR [\fB-v\fR] restart {\fIFMRI\fR | \fIpattern\fR}...
+\fB/usr/sbin/svcadm\fR [\fB-v\fR] [\fB-z\fR \fIzone\fR] restart {\fIFMRI\fR | \fIpattern\fR}...
.fi
.LP
.nf
-\fB/usr/sbin/svcadm\fR [\fB-v\fR] refresh {\fIFMRI\fR | \fIpattern\fR}...
+\fB/usr/sbin/svcadm\fR [\fB-v\fR] [\fB-z\fR \fIzone\fR] refresh {\fIFMRI\fR | \fIpattern\fR}...
.fi
.LP
.nf
-\fB/usr/sbin/svcadm\fR [\fB-v\fR] clear {\fIFMRI\fR | \fIpattern\fR}...
+\fB/usr/sbin/svcadm\fR [\fB-v\fR] [\fB-z\fR \fIzone\fR] clear {\fIFMRI\fR | \fIpattern\fR}...
.fi
.LP
.nf
-\fB/usr/sbin/svcadm\fR [\fB-v\fR] mark [\fB-It\fR] \fIinstance_state\fR
+\fB/usr/sbin/svcadm\fR [\fB-v\fR] [\fB-z\fR \fIzone\fR] mark [\fB-It\fR] \fIinstance_state\fR
{\fIFMRI\fR | \fIpattern\fR}...
.fi
@@ -60,11 +60,23 @@
.na
\fB\fB-v\fR\fR
.ad
-.RS 6n
+.RS 20n
.rt
Print actions verbosely to standard output.
.RE
+.sp
+.ne 2
+.mk
+.na
+\fB-z\fR \fIzone\fR
+.ad
+.RS 20n
+.rt
+Administer services in the specified zone. This option is only applicable
+from the global zone, see \fBzones\fR(5).
+.RE
+
.SH SUBCOMMANDS
.SS "Common Operations"
.sp
@@ -520,7 +532,7 @@
.LP
\fBsvcprop\fR(1), \fBsvcs\fR(1), \fBinetd\fR(1M), \fBinit\fR(1M),
\fBsvccfg\fR(1M), \fBsvc.startd\fR(1M), \fBlibscf\fR(3LIB), \fBcontract\fR(4),
-\fBattributes\fR(5), \fBsmf\fR(5), \fBsmf_security\fR(5)
+\fBattributes\fR(5), \fBsmf\fR(5), \fBsmf_security\fR(5), \fBzones\fR(5)
.SH NOTES
.sp
.LP