4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
24 */
25
26 #include <Python.h>
27 #include <sys/varargs.h>
28 #include <stdio.h>
29 #include <libnvpair.h>
30
31 #include <libbe.h>
32 #include <libbe_priv.h>
33
34 enum {
35 BE_PY_SUCCESS = 0,
36 BE_PY_ERR_APPEND = 6000,
37 BE_PY_ERR_DICT,
38 BE_PY_ERR_LIST,
39 BE_PY_ERR_NVLIST,
40 BE_PY_ERR_PARSETUPLE,
41 BE_PY_ERR_PRINT_ERR,
42 BE_PY_ERR_VAR_CONV,
43 } bePyErr;
151 * beNameProperties - The properties to use when creating
152 * the BE (optional)
153 *
154 * Returns a pointer to a python object. That Python object will consist of
155 * the return code and optional attributes, trgtBeName and snapshotName
156 * BE_SUCCESS, [trgtBeName], [trgtSnapName] - Success
157 * 1, [trgtBeName], [trgtSnapName] - Failure
158 * Scope:
159 * Public
160 */
161 /* ARGSUSED */
162 PyObject *
163 beCopy(PyObject *self, PyObject *args)
164 {
165 char *trgtBeName = NULL;
166 char *srcBeName = NULL;
167 char *srcSnapName = NULL;
168 char *trgtSnapName = NULL;
169 char *rpool = NULL;
170 char *beDescription = NULL;
171 int pos = 0;
172 int ret = BE_PY_SUCCESS;
173 nvlist_t *beAttrs = NULL;
174 nvlist_t *beProps = NULL;
175 PyObject *beNameProperties = NULL;
176 PyObject *pkey = NULL;
177 PyObject *pvalue = NULL;
178 PyObject *retVals = NULL;
179
180 if (!PyArg_ParseTuple(args, "|zzzzOz", &trgtBeName, &srcBeName,
181 &srcSnapName, &rpool, &beNameProperties, &beDescription)) {
182 return (Py_BuildValue("[iss]", BE_PY_ERR_PARSETUPLE,
183 NULL, NULL));
184 }
185
186 if (!convertPyArgsToNvlist(&beAttrs, 10,
187 BE_ATTR_NEW_BE_NAME, trgtBeName,
188 BE_ATTR_ORIG_BE_NAME, srcBeName,
189 BE_ATTR_SNAP_NAME, srcSnapName,
190 BE_ATTR_NEW_BE_POOL, rpool,
191 BE_ATTR_NEW_BE_DESC, beDescription)) {
|
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Copyright 2012 OmniTI Computer Consulting, Inc. All rights reserved.
25 */
26
27 #include <Python.h>
28 #include <sys/varargs.h>
29 #include <stdio.h>
30 #include <libnvpair.h>
31
32 #include <libbe.h>
33 #include <libbe_priv.h>
34
35 enum {
36 BE_PY_SUCCESS = 0,
37 BE_PY_ERR_APPEND = 6000,
38 BE_PY_ERR_DICT,
39 BE_PY_ERR_LIST,
40 BE_PY_ERR_NVLIST,
41 BE_PY_ERR_PARSETUPLE,
42 BE_PY_ERR_PRINT_ERR,
43 BE_PY_ERR_VAR_CONV,
44 } bePyErr;
152 * beNameProperties - The properties to use when creating
153 * the BE (optional)
154 *
155 * Returns a pointer to a python object. That Python object will consist of
156 * the return code and optional attributes, trgtBeName and snapshotName
157 * BE_SUCCESS, [trgtBeName], [trgtSnapName] - Success
158 * 1, [trgtBeName], [trgtSnapName] - Failure
159 * Scope:
160 * Public
161 */
162 /* ARGSUSED */
163 PyObject *
164 beCopy(PyObject *self, PyObject *args)
165 {
166 char *trgtBeName = NULL;
167 char *srcBeName = NULL;
168 char *srcSnapName = NULL;
169 char *trgtSnapName = NULL;
170 char *rpool = NULL;
171 char *beDescription = NULL;
172 Py_ssize_t pos = 0;
173 int ret = BE_PY_SUCCESS;
174 nvlist_t *beAttrs = NULL;
175 nvlist_t *beProps = NULL;
176 PyObject *beNameProperties = NULL;
177 PyObject *pkey = NULL;
178 PyObject *pvalue = NULL;
179 PyObject *retVals = NULL;
180
181 if (!PyArg_ParseTuple(args, "|zzzzOz", &trgtBeName, &srcBeName,
182 &srcSnapName, &rpool, &beNameProperties, &beDescription)) {
183 return (Py_BuildValue("[iss]", BE_PY_ERR_PARSETUPLE,
184 NULL, NULL));
185 }
186
187 if (!convertPyArgsToNvlist(&beAttrs, 10,
188 BE_ATTR_NEW_BE_NAME, trgtBeName,
189 BE_ATTR_ORIG_BE_NAME, srcBeName,
190 BE_ATTR_SNAP_NAME, srcSnapName,
191 BE_ATTR_NEW_BE_POOL, rpool,
192 BE_ATTR_NEW_BE_DESC, beDescription)) {
|