summaryrefslogtreecommitdiff
path: root/usr/src/man/man3scf/smf_enable_instance.3scf
blob: 9333b16265cd75bc6b7bc576f6595221efdf46dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
'\" te
.\" Copyright (c) 2007, Sun Microsystems, Inc. All Rights Reserved.
.\" Copyright 2020 Joyent, Inc.
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
.TH SMF_ENABLE_INSTANCE 3SCF "May 15, 2020"
.SH NAME
smf_enable_instance, smf_disable_instance, smf_disable_instance_with_comment,
smf_refresh_instance, smf_restart_instance, smf_maintain_instance,
smf_degrade_instance, smf_restore_instance, smf_get_state \-
administrative interface to the Service Configuration Facility
.SH SYNOPSIS
.nf
cc [ \fIflag\fR\&.\|.\|. ] \fIfile\fR\&.\|.\|. \fB-lscf\fR [ \fIlibrary\fR\&.\|.\|. ]
#include <libscf.h>

\fBint\fR \fBsmf_enable_instance\fR(\fBconst char *\fR\fIinstance\fR, \fBint\fR \fIflags\fR);
.fi

.LP
.nf
\fBint\fR \fBsmf_disable_instance\fR(\fBconst char *\fR\fIinstance\fR, \fBint\fR \fIflags\fR);
.fi

.LP
.nf
\fBint\fR \fBsmf_disable_instance_with_comment\fR(\fBconst char *\fR\fIinstance\fR,
    \fBint\fR \fIflags\fR, \fBconst char *\fR\fIcomment\fR);
.fi

.LP
.nf
\fBint\fR \fBsmf_refresh_instance\fR(\fBconst char *\fR\fIinstance\fR);
.fi

.LP
.nf
\fBint\fR \fBsmf_restart_instance\fR(\fBconst char *\fR\fIinstance\fR);
.fi

.LP
.nf
\fBint\fR \fBsmf_maintain_instance\fR(\fBconst char *\fR\fIinstance\fR, \fBint\fR \fIflags\fR);
.fi

.LP
.nf
\fBint\fR \fBsmf_degrade_instance\fR(\fBconst char *\fR\fIinstance\fR, \fBint\fR \fIflags\fR);
.fi

.LP
.nf
\fBint\fR \fBsmf_restore_instance\fR(\fBconst char *\fR\fIinstance\fR);
.fi

.LP
.nf
\fBchar *\fR\fBsmf_get_state\fR(\fBconst char *\fR\fIinstance\fR);
.fi

.SH DESCRIPTION
These functions provide administrative control over service instances. Using
these functions, an administrative tool can make a request to enable, disable,
refresh, or restart an instance. All calls are asynchronous. They request an
action, but do not wait to see if the action succeeds or fails.
.sp
.LP
The \fBsmf_enable_instance()\fR function enables the service instance specified
by \fIinstance\fR FMRI. If \fIflags\fR is \fBSMF_TEMPORARY\fR, the enabling of
the service instance is a temporary change, lasting only for the lifetime of
the current system instance. The \fIflags\fR argument is set to \fB0\fR if no
flags are to be use.
.sp
.LP
The \fBsmf_disable_instance()\fR function places the service instance specified
by \fIinstance\fR FMRI in the disabled state and triggers the stop method (see
\fBsvc.startd\fR(1M)). If \fIflags\fR is \fBSMF_TEMPORARY\fR, the disabling of
the service instance is a temporary change, lasting only for the lifetime of
the current system instance. The \fIflags\fR argument is set to \fB0\fR if no
flags are to be use.
.sp
.LP
The \fBsmf_disable_instance_with_comment()\fR function behaves the same as
\fBsmf_disable_instance()\fR, except the given free-form comment is recorded
under the \fIcomment\fR property, as reported by \fBsvcs\fR(1).
The comment may be up to \fBSCF_COMMENT_MAX_LENGTH\fR characters including
the NUL terminator.
.sp
.LP
The \fBsmf_refresh_instance()\fR function causes the service instance specified
by \fIinstance\fR FMRI to re-read its configuration information.
.sp
.LP
The \fBsmf_restart_instance()\fR function restarts the service instance
specified by \fIinstance\fR FMRI.
.sp
.LP
The \fBsmf_maintain_instance()\fR function moves the service instance specified
by \fIinstance\fR into the maintenance state. If \fIflags\fR is
\fBSMF_IMMEDIATE\fR, the instance is moved into maintenance state immediately,
killing any running methods. If \fIflags\fR is \fBSMF_TEMPORARY\fR, the change
to maintenance state is a temporary change, lasting only for the lifetime of
the current system instance. The \fIflags\fR argument is set to \fB0\fR if no
flags are to be use.
.sp
.LP
The \fBsmf_degrade_instance()\fR function moves an online service instance into
the degraded state. This function operates only on instances in the online
state. The \fIflags\fR argument is set to \fB0\fR if no flags are to be use.
The only available flag is \fBSMF_IMMEDIATE\fR, which causes the instance to be
moved into the degraded state immediately.
.sp
.LP
The \fBsmf_restore_instance()\fR function brings an instance currently in the
maintenance to the uninitialized state, so that it can be brought back online.
For a service in the degraded state, \fBsmf_restore_instance()\fR brings the
specified instance back to the online state.
.sp
.LP
The \fBsmf_get_state()\fR function returns a pointer to a string containing the
name of the instance's current state. The user is responsible for freeing this
string. Possible state strings are defined as the following:
.sp
.in +2
.nf
#define SCF_STATE_STRING_UNINIT         ((const char *)"uninitialized")
#define SCF_STATE_STRING_MAINT          ((const char *)"maintenance")
#define SCF_STATE_STRING_OFFLINE        ((const char *)"offline")
#define SCF_STATE_STRING_DISABLED       ((const char *)"disabled")
#define SCF_STATE_STRING_ONLINE         ((const char *)"online")
#define SCF_STATE_STRING_DEGRADED       ((const char *)"degraded")
.fi
.in -2

.SH RETURN VALUES
Upon successful completion, \fBsmf_enable_instance()\fR,
\fBsmf_disable_instance()\fR, \fBsmf_disable_instance_with_comment()\fR,
\fBsmf_refresh_instance()\fR, \fBsmf_restart_instance()\fR,
\fBsmf_maintain_instance()\fR, \fBsmf_degrade_instance()\fR,
and \fBsmf_restore_instance()\fR return \fB0\fR.
Otherwise, they return \fB-1\fR\&.
.sp
.LP
Upon successful completion, smf_get_state returns an allocated string.
Otherwise, it returns \fINULL\fR.
.SH ERRORS
These functions will fail if:
.sp
.ne 2
.na
\fB\fBSCF_ERROR_NO_MEMORY\fR\fR
.ad
.sp .6
.RS 4n
The memory allocation failed.
.RE

.sp
.ne 2
.na
\fB\fBSCF_ERROR_INVALID_ARGUMENT\fR\fR
.ad
.sp .6
.RS 4n
The \fIinstance\fR FMRI or \fIflags\fR argument is invalid.
.RE

.sp
.ne 2
.na
\fB\fBSCF_ERROR_NOT_FOUND\fR\fR
.ad
.sp .6
.RS 4n
The FMRI is valid but there is no matching instance found.
.RE

.sp
.ne 2
.na
\fB\fBSCF_ERROR_CONNECTION_BROKEN\fR\fR
.ad
.sp .6
.RS 4n
The connection to repository was broken.
.RE

.sp
.ne 2
.na
\fB\fBSCF_ERROR_NO_RESOURCES\fR\fR
.ad
.sp .6
.RS 4n
The server has insufficient resources.
.RE

.sp
.LP
The \fBsmf_maintain_instance()\fR, \fBsmf_refresh_instance()\fR,
\fBsmf_restart_instance()\fR, \fBsmf_degrade_instance()\fR, and
\fBsmf_restore_instance()\fR functions will fail if:
.sp
.ne 2
.na
\fB\fBSCF_ERROR_PERMISSION_DENIED\fR\fR
.ad
.sp .6
.RS 4n
User does not have proper authorizations. See \fBsmf_security\fR(5).
.RE

.sp
.ne 2
.na
\fB\fBSCF_ERROR_BACKEND_ACCESS\fR\fR
.ad
.sp .6
.RS 4n
The repository's backend refused access.
.RE

.sp
.ne 2
.na
\fB\fBSCF_ERROR_BACKEND_READONLY\fR\fR
.ad
.sp .6
.RS 4n
The repository's backend is read-only.
.RE

.sp
.LP
The \fBsmf_restore_instance()\fR and \fBsmf_degrade_instance()\fR functions
will fail if:
.sp
.ne 2
.na
\fB\fBSCF_ERROR_CONSTRAINT_VIOLATED\fR\fR
.ad
.sp .6
.RS 4n
The function is called on an instance in an inappropriate state.
.RE

.sp
.LP
The \fBscf_error\fR(3SCF) function can be used to retrieve the error value.
.SH ATTRIBUTES
See \fBattributes\fR(5) for descriptions of the following attributes:
.sp

.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE	ATTRIBUTE VALUE
_
Interface Stability	Committed
_
MT-Level	Safe
.TE

.SH SEE ALSO
\fBsvc.startd\fR(1M), \fBlibscf\fR(3LIB), \fBscf_error\fR(3SCF),
\fBattributes\fR(5), \fBsmf_security\fR(5), \fBsvcs\fR(1)