Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
5ab109f8
L
libvirt
项目概览
openeuler
/
libvirt
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
L
libvirt
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
5ab109f8
编写于
12月 05, 2007
作者:
D
Daniel P. Berrange
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add manual impl of virConnectOpenAuth python binding
上级
60a6bbe6
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
134 addition
and
0 deletion
+134
-0
ChangeLog
ChangeLog
+5
-0
python/libvir.c
python/libvir.c
+123
-0
python/libvir.py
python/libvir.py
+6
-0
未找到文件。
ChangeLog
浏览文件 @
5ab109f8
Wed Dec 5 14:08:00 EST 2007 Daniel P. Berrange <berrange@redhat.com>
* python/libvir.c, python/libvir.py: Add binding for the
virConnectOpenAuth() API which generator can't handle
Wed Dec 5 13:55:00 EST 2007 Daniel P. Berrange <berrange@redhat.com>
* qemud/qemud.c: Re-added listen_tcp & listen_tls config
...
...
python/libvir.c
浏览文件 @
5ab109f8
...
...
@@ -245,6 +245,128 @@ libvirt_virRegisterErrorHandler(ATTRIBUTE_UNUSED PyObject * self,
return
(
py_retval
);
}
static
int
virConnectCredCallbackWrapper
(
virConnectCredentialPtr
cred
,
unsigned
int
ncred
,
void
*
cbdata
)
{
PyObject
*
list
;
PyObject
*
pycred
;
PyObject
*
pyauth
=
(
PyObject
*
)
cbdata
;
PyObject
*
pycbdata
;
PyObject
*
pycb
;
PyObject
*
pyret
;
int
ret
=
-
1
,
i
;
LIBVIRT_ENSURE_THREAD_STATE
;
pycb
=
PyList_GetItem
(
pyauth
,
1
);
pycbdata
=
PyList_GetItem
(
pyauth
,
2
);
list
=
PyTuple_New
(
2
);
pycred
=
PyTuple_New
(
ncred
);
for
(
i
=
0
;
i
<
ncred
;
i
++
)
{
PyObject
*
pycreditem
;
pycreditem
=
PyList_New
(
5
);
Py_INCREF
(
Py_None
);
PyTuple_SetItem
(
pycred
,
i
,
pycreditem
);
PyList_SetItem
(
pycreditem
,
0
,
PyInt_FromLong
((
long
)
cred
[
i
].
type
));
PyList_SetItem
(
pycreditem
,
1
,
PyString_FromString
(
cred
[
i
].
prompt
));
if
(
cred
[
i
].
challenge
)
{
PyList_SetItem
(
pycreditem
,
2
,
PyString_FromString
(
cred
[
i
].
challenge
));
}
else
{
Py_INCREF
(
Py_None
);
PyList_SetItem
(
pycreditem
,
2
,
Py_None
);
}
if
(
cred
[
i
].
defresult
)
{
PyList_SetItem
(
pycreditem
,
3
,
PyString_FromString
(
cred
[
i
].
defresult
));
}
else
{
Py_INCREF
(
Py_None
);
PyList_SetItem
(
pycreditem
,
3
,
Py_None
);
}
PyList_SetItem
(
pycreditem
,
4
,
Py_None
);
}
PyTuple_SetItem
(
list
,
0
,
pycred
);
Py_XINCREF
(
pycbdata
);
PyTuple_SetItem
(
list
,
1
,
pycbdata
);
PyErr_Clear
();
pyret
=
PyEval_CallObject
(
pycb
,
list
);
if
(
PyErr_Occurred
())
goto
cleanup
;
ret
=
PyLong_AsLong
(
pyret
);
if
(
ret
==
0
)
{
for
(
i
=
0
;
i
<
ncred
;
i
++
)
{
PyObject
*
pycreditem
;
PyObject
*
pyresult
;
char
*
result
=
NULL
;
pycreditem
=
PyTuple_GetItem
(
pycred
,
i
);
pyresult
=
PyList_GetItem
(
pycreditem
,
4
);
if
(
pyresult
!=
Py_None
)
result
=
PyString_AsString
(
pyresult
);
if
(
result
!=
NULL
)
{
cred
[
i
].
result
=
strdup
(
result
);
cred
[
i
].
resultlen
=
strlen
(
result
);
}
else
{
cred
[
i
].
result
=
NULL
;
cred
[
i
].
resultlen
=
0
;
}
}
}
cleanup:
Py_XDECREF
(
list
);
Py_XDECREF
(
pyret
);
LIBVIRT_RELEASE_THREAD_STATE
;
return
ret
;
}
static
PyObject
*
libvirt_virConnectOpenAuth
(
PyObject
*
self
ATTRIBUTE_UNUSED
,
PyObject
*
args
)
{
PyObject
*
py_retval
;
virConnectPtr
c_retval
;
char
*
name
;
int
flags
;
PyObject
*
pyauth
;
PyObject
*
pycredcb
;
PyObject
*
pycredtype
;
virConnectAuth
auth
;
if
(
!
PyArg_ParseTuple
(
args
,
(
char
*
)
"zOi:virConnectOpenAuth"
,
&
name
,
&
pyauth
,
&
flags
))
return
(
NULL
);
pycredtype
=
PyList_GetItem
(
pyauth
,
0
);
pycredcb
=
PyList_GetItem
(
pyauth
,
1
);
auth
.
ncredtype
=
PyList_Size
(
pycredtype
);
if
(
auth
.
ncredtype
)
{
int
i
;
auth
.
credtype
=
malloc
(
sizeof
(
int
)
*
auth
.
ncredtype
);
if
(
auth
.
credtype
==
NULL
)
{
Py_INCREF
(
Py_None
);
return
(
Py_None
);
}
for
(
i
=
0
;
i
<
auth
.
ncredtype
;
i
++
)
{
PyObject
*
val
;
val
=
PyList_GetItem
(
pycredtype
,
i
);
auth
.
credtype
[
i
]
=
(
int
)
PyLong_AsLong
(
val
);
}
}
auth
.
cb
=
pycredcb
?
virConnectCredCallbackWrapper
:
NULL
;
auth
.
cbdata
=
pyauth
;
LIBVIRT_BEGIN_ALLOW_THREADS
;
c_retval
=
virConnectOpenAuth
(
name
,
&
auth
,
flags
);
LIBVIRT_END_ALLOW_THREADS
;
py_retval
=
libvirt_virConnectPtrWrap
((
virConnectPtr
)
c_retval
);
return
(
py_retval
);
}
/************************************************************************
* *
* Wrappers for functions where generator fails *
...
...
@@ -733,6 +855,7 @@ static PyMethodDef libvirtMethods[] = {
#include "libvirt-export.c"
{(
char
*
)
"virGetVersion"
,
libvirt_virGetVersion
,
METH_VARARGS
,
NULL
},
{(
char
*
)
"virDomainFree"
,
libvirt_virDomainFree
,
METH_VARARGS
,
NULL
},
{(
char
*
)
"virConnectOpenAuth"
,
libvirt_virConnectOpenAuth
,
METH_VARARGS
,
NULL
},
{(
char
*
)
"virConnectClose"
,
libvirt_virConnectClose
,
METH_VARARGS
,
NULL
},
{(
char
*
)
"virConnectListDomainsID"
,
libvirt_virConnectListDomainsID
,
METH_VARARGS
,
NULL
},
{(
char
*
)
"virConnectListDefinedDomains"
,
libvirt_virConnectListDefinedDomains
,
METH_VARARGS
,
NULL
},
...
...
python/libvir.py
浏览文件 @
5ab109f8
...
...
@@ -89,6 +89,12 @@ def registerErrorHandler(f, ctx):
Returns 1 in case of success."""
return
libvirtmod
.
virRegisterErrorHandler
(
f
,
ctx
)
def
openAuth
(
uri
,
auth
,
flags
):
ret
=
libvirtmod
.
virConnectOpenAuth
(
uri
,
auth
,
flags
)
if
ret
is
None
:
raise
libvirtError
(
'virConnectOpenAuth() failed'
)
return
virConnect
(
_obj
=
ret
)
#
# Return library version.
#
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录