Support for Xen-API authenticated session
PATCH RESEND 1/1 Support for Xen-API authenticated session
I am adding a tool 'xapi-setup.py' to the xm-test suite for being able to setup authentication credentials needed for automatically running Xen-API - related tests. The username and password information is stored in cleartext in lib/XmTestLib/xapi_auth.py.
In the one test using the Xen-API I add another check for availability of the python PAM module. The test is skipped if the module is not available on the system.
xen-unstable.hg/tools/xm-test/lib/XmTestLib/xapi.py +6 -5
@@ -24,9 +24,6 @@ from xen.util.xmlrpclib2 import ServerPr from types import DictType -XAPI_DEFAULT_LOGIN = " " -XAPI_DEFAULT_PASSWORD = " " - class XenAPIError(Exception): pass
@@ -58,8 +55,12 @@ def _connect(*args): global _server, _session, _initialised if not _initialised: _server = ServerProxy('httpu:///var/run/xend/xen-api.sock') - login = XAPI_DEFAULT_LOGIN - password = XAPI_DEFAULT_PASSWORD + try: + from XmTestLib import xapi_auth + except: + FAIL("Missing Xen-API credentials. Run xapi-setup.py!") + login = xapi_auth.XAPI_DEFAULT_LOGIN + password = xapi_auth.XAPI_DEFAULT_PASSWORD creds = (login, password) _session = execute(_server.session.login_with_password, *creds) _initialised = True
xen-unstable.hg/tools/xm-test/tests/vtpm/09_vtpm-xapi.py +4 -0
@@ -68,6 +68,10 @@ def do_test(): domain.destroy() +try: + import PAM +except ImportError: + SKIP("Skipping test. Python-PAM module not found.") try: do_test()
xen-unstable.hg/tools/xm-test/xapi-setup.py new file +41 -0
41 lines not on this page · raw message
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 9 lines · Stefan Berger
I am adding a tool '
xapi-setup.py' to the xm-test suite for being able to setup authentication credentials needed for automatically running Xen-API - related tests. The username and password information is stored in cleartext inlib/XmTestLib/xapi_auth.py.
In the one test using the Xen-API I add another check for availability of the python PAM module. The test is skipped if the module is not available on the system.Signed-off-by Stefan Berger <[email protected]>
Ah, sorry, I'd forgotten about this one.
There is now a configuration file for xm (see tools/examples/xm-config.xml) so would it make sense to pull the username and password from there? If you look at xen/xm/main.py, there's code for parsing the config file, and also for using the XenAPI session manager and server proxy -- you ought to be able to import that code now rather than using ServerProxy, and then there will be less for xapi.py to do, because it will be sharing with xm.
Cheers,
Ewan.
Quoted 90 lines
Index:
root/xen-unstable.hg/tools/xm-test/lib/XmTestLib/xapi.py
===================================================================xen-unstable.hg/tools/xm-test/lib/XmTestLib/xapi.py +6
-5@@ -24,9 +24,6 @@ from xen.util.xmlrpclib2 import ServerPr from types import DictType -XAPI_DEFAULT_LOGIN = " " -XAPI_DEFAULT_PASSWORD = " " - class XenAPIError(Exception): pass@@ -58,8 +55,12 @@ def _connect(*args): global _server, _session, _initialised if not _initialised: _server = ServerProxy('httpu:///var/run/xend/xen-api.sock') - login = XAPI_DEFAULT_LOGIN - password = XAPI_DEFAULT_PASSWORD + try: + from XmTestLib import xapi_auth + except: + FAIL("Missing Xen-API credentials. Run xapi-setup.py!") + login = xapi_auth.XAPI_DEFAULT_LOGIN + password = xapi_auth.XAPI_DEFAULT_PASSWORD creds = (login, password) _session = execute(_server.session.login_with_password, *creds) _initialised = TrueIndex:
root/xen-unstable.hg/tools/xm-test/tests/vtpm/09_vtpm-xapi.py
===================================================================xen-unstable.hg/tools/xm-test/tests/vtpm/09_vtpm-xapi.py +4
-0@@ -68,6 +68,10 @@ def do_test(): domain.destroy() +try: + import PAM +except ImportError: + SKIP("Skipping test. Python-PAM module not found.") try: do_test()Index:
root/xen-unstable.hg/tools/xm-test/xapi-setup.py
===================================================================xen-unstable.hg/tools/xm-test/xapi-setup.py new file +41
-0@@ -0,0 +1,41 @@ +#!/usr/bin/python +import sys as sys +import getpass as getpass + +XAPI_AUTH_FILE = "xapi_auth.py" +XAPI_AUTH_PATH = "./lib/XmTestLib/" +XAPI_FILE = XAPI_AUTH_PATH + XAPI_AUTH_FILE + +def usage(): + print "Usage: xapi-setup.py [<username>] [<password>]\n\n" \ + "Tool to setup the xm-test suite for being able to use the Xen-API\n" \ + "with authenticated sessions. Username and password are stored in\n" \ + "cleartext in %s.\n" % XAPI_FILE + +def main(): + if (len(sys.argv) >= 2) and sys.argv[1] == "-?": + usage() + sys.exit(0) + print "Enter username and password for usage with Xen-API:\n" + if (len(sys.argv) >=2 ): + username = sys.argv[1] + print "Login: %s" % username + else: + username = rawinput("Login: ") + if (len(sys.argv) >= 3 ): + password = sys.argv[2] + print "Password: <given>" + else: + password = getpass.getpass() + f = open(XAPI_FILE, "w") + if f: + f.write("# File was created by xapi-setup.py.\n" + "XAPI_DEFAULT_LOGIN = \"%s\"\n" + "XAPI_DEFAULT_PASSWORD = \"%s\"\n" + % (username, password)) + f.close() + else: + print("Could not open file %s for writing." % XAPI_FILE) + +if __name__ == "__main__": + sys.exit(main())
Ewan Mellor <[email protected]> wrote on 12/23/2006 07:45:04 AM:
Quoted 5 lines · Stefan Berger
Quoted 4 lines
I am adding a tool '
xapi-setup.py' to the xm-test suite for being able to setup authentication credentials needed for automatically running Xen-API - related tests. The username and password information is
stored
Quoted 5 lines
Quoted 5 lines
in cleartext in
lib/XmTestLib/xapi_auth.py.
In the one test using the Xen-API I add another check for availability of the python PAM module. The test is skipped if the module is not available on the system.
Quoted 7 lines
Quoted 1 line
Signed-off-by Stefan Berger <[email protected]>Ah, sorry, I'd forgotten about this one.
There is now a configuration file for xm (see
tools/examples/xm-config.xml) so would it make sense to pull the username and password from there? If you look atxen/xm/main.py,
I had not seen this file, but it seems not to be copied into /etc/xen/ by default. Would it be ok for now if I adapted the XML format and have xapi.py try to get username/password from the xm-config.xml file first and if it does not exist read the file created by the tool that I add to the xm test suite (xapi-setup.py) ?
Stefan
Quoted 23 lines
there's code for parsing the config file, and also for using the XenAPI session manager and server proxy -- you ought to be able to import that code now rather than using ServerProxy, and then there will be less for
xapi.pyto do, because it will be sharing with xm.Cheers,
Ewan.
Quoted 14 lines
Index:
root/xen-unstable.hg/tools/xm-test/lib/XmTestLib/xapi.py
===================================================================xen-unstable.hg/tools/xm-test/lib/XmTestLib/xapi.py +0
-3@@ -24,9 +24,6 @@ from xen.util.xmlrpclib2 import ServerPr from types import DictType -XAPI_DEFAULT_LOGIN = " " -XAPI_DEFAULT_PASSWORD = " " - class XenAPIError(Exception): pass
Quoted 14 lines
Quoted 4 lines
xen-unstable.hg/tools/xm-test/lib/XmTestLib/xapi.py +0
-0@@ -58,8 +55,12 @@ def _connect(*args): global _server, _session, _initialised if not _initialised: _server = ServerProxy('httpu:///var/run/xend/xen-api.sock')xen-unstable.hg/tools/xm-test/lib/XmTestLib/xapi.py def _connect(*args): · line 65
Quoted 10 lines
xen-unstable.hg/tools/xm-test/lib/XmTestLib/xapi.py +6
-2- login = XAPI_DEFAULT_LOGIN - password = XAPI_DEFAULT_PASSWORD + try: + from XmTestLib import xapi_auth + except: + FAIL("Missing Xen-API credentials. Run xapi-setup.py!") + login = xapi_auth.XAPI_DEFAULT_LOGIN + password = xapi_auth.XAPI_DEFAULT_PASSWORD creds = (login, password) _session = execute(_server.session.login_with_password,
*creds)
Quoted 56 lines
Quoted 22 lines
xen-unstable.hg/tools/xm-test/lib/XmTestLib/xapi.py +0
-0_initialised = TrueIndex:
root/xen-unstable.hg/tools/xm-test/tests/vtpm/09_vtpm-xapi.py
===================================================================xen-unstable.hg/tools/xm-test/tests/vtpm/09_vtpm-xapi.py +4
-0@@ -68,6 +68,10 @@ def do_test(): domain.destroy() +try: + import PAM +except ImportError: + SKIP("Skipping test. Python-PAM module not found.") try: do_test()Index:
root/xen-unstable.hg/tools/xm-test/xapi-setup.py
===================================================================xen-unstable.hg/tools/xm-test/xapi-setup.py new file +1
-0@@ -0,0 +1,41 @@ +#!/usr/bin/pythonxen-unstable.hg/tools/xm-test/xapi-setup.py line 11
Quoted 10 lines
xen-unstable.hg/tools/xm-test/xapi-setup.py new file +10
-0+import sys as sys +import getpass as getpass + +XAPI_AUTH_FILE = "xapi_auth.py" +XAPI_AUTH_PATH = "./lib/XmTestLib/" +XAPI_FILE = XAPI_AUTH_PATH + XAPI_AUTH_FILE + +def usage(): + print "Usage: xapi-setup.py [<username>] [<password>]\n\n" \ + "Tool to setup the xm-test suite for being able to usethe Xen-API\n" \
xen-unstable.hg/tools/xm-test/xapi-setup.py line 12
Quoted 1 line
xen-unstable.hg/tools/xm-test/xapi-setup.py new file +1
-0+ "with authenticated sessions. Username and password arestored in\n" \
Quoted 21 lines
xen-unstable.hg/tools/xm-test/xapi-setup.py new file +21
-0+ "cleartext in %s.\n" % XAPI_FILE + +def main(): + if (len(sys.argv) >= 2) and sys.argv[1] == "-?": + usage() + sys.exit(0) + print "Enter username and password for usage with Xen-API:\n" + if (len(sys.argv) >=2 ): + username = sys.argv[1] + print "Login: %s" % username + else: + username = rawinput("Login: ") + if (len(sys.argv) >= 3 ): + password = sys.argv[2] + print "Password: <given>" + else: + password = getpass.getpass() + f = open(XAPI_FILE, "w") + if f: + f.write("# File was created by xapi-setup.py.\n" + "XAPI_DEFAULT_LOGIN = \"%s\"\n"
Quoted 9 lines
xen-unstable.hg/tools/xm-test/xapi-setup.py line 41
Quoted 8 lines
xen-unstable.hg/tools/xm-test/xapi-setup.py new file +8
-0+ "XAPI_DEFAULT_PASSWORD = \"%s\"\n" + % (username, password)) + f.close() + else: + print("Could not open file %s for writing." % XAPI_FILE) + +if __name__ == "__main__": + sys.exit(main())
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 15 lines · Stefan Berger
Ewan Mellor <[email protected]> wrote on 12/23/2006 07:45:04 AM:
Quoted 5 lines · Stefan Berger
Quoted 4 lines
I am adding a tool '
xapi-setup.py' to the xm-test suite for being able to setup authentication credentials needed for automatically running Xen-API - related tests. The username and password information isstored
Quoted 7 lines
Quoted 6 lines
in cleartext in
lib/XmTestLib/xapi_auth.py.
In the one test using the Xen-API I add another check for availability of the python PAM module. The test is skipped if the module is not available on the system.Signed-off-by Stefan Berger <[email protected]>
Quoted 8 lines
Quoted 5 lines
Ah, sorry, I'd forgotten about this one.
There is now a configuration file for xm (see
tools/examples/xm-config.xml) so would it make sense to pull the username and password from there? If you look atxen/xm/main.py,I had not seen this file, but it seems not to be copied into
/etc/xen/by default.
No, it doesn't go in by default at the moment, because it arrived quite late in the 3.0.4 run-up, so I decided not to activate it by default. Sorry that you'd missed it. I'm going to change the Makefile in unstable now so that it gets put in there by default.
Quoted 4 lines
Would it be ok for now if I adapted the XML format and have
xapi.pytry to get username/password from the xm-config.xml file first and if it does not exist read the file created by the tool that I add to the xm test suite (xapi-setup.py) ?
You could if you want to, but you'll have a lot less code to write if you just import the relevant bits from xm:
~ # python
Python 2.4.4 (#2, Oct 19 2006, 23:03:48)
[GCC 4.1.2 20061007 (prerelease) (Debian 4.1.1-16)] on linux2 Type "help", "copyright", "credits" or "license" for more information.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
import sys
sys.path.append('/usr/lib/python')
import xen.xm.main
xen.xm.main.serverType
u'Xen-API'
Quoted 1 line
Quoted 1 line
Quoted 1 line
xen.xm.main.serverURI
Quoted 1 line
Quoted 1 line
Quoted 1 line
xen.xm.main.parseAuthentication()
(u'ewan', u'letmein')
Connecting to the server should be a lot easier now too:
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
from xen.xm import XenAPI
session =XenAPI.Session(xen.xm.main.serverURI)session.login_with_password(*xen.xm.main.parseAuthentication())session.xenapi.VM.get_all()
['00000000-0000-0000-0000-000000000000',
'2f8dada9-387c-d981-0e51-6f5e2732d752',
'53a01d42-c8c8-e561-6939-e2bc750454f7']
It would be best, I think, if xm-test shares those bits of code with xm.
It's possible that xm-test doesn't need that code at all, in the long run, because it ought to be able to drive xm from the outside (that's the whole point of xm-test after all -- its an end-to-end test). What you seem to be writing is tests for the API, but that don't test xm itself. That's great, if xm itself will never have the bits of functionality under test. The plan is for xm to move over to using the new API throughout, so for the majority of the functionality, we ought to be doing the full end-to-end test, and prodding xm from the outside, rather than using ServerProxy.
Coverage from both aspects -- the raw API and the xm-sanitised version -- would be best, of course, but we're already struggling to get enough people writing tests, so it'd be best to concentrate on the end-to-end tests for now.
Ewan.
Quoted 105 lines
Stefan
Quoted 23 lines
there's code for parsing the config file, and also for using the XenAPI session manager and server proxy -- you ought to be able to import that code now rather than using ServerProxy, and then there will be less for
xapi.pyto do, because it will be sharing with xm.Cheers,
Ewan.
Quoted 14 lines
Index:
root/xen-unstable.hg/tools/xm-test/lib/XmTestLib/xapi.py
===================================================================xen-unstable.hg/tools/xm-test/lib/XmTestLib/xapi.py +0
-3@@ -24,9 +24,6 @@ from xen.util.xmlrpclib2 import ServerPr from types import DictType -XAPI_DEFAULT_LOGIN = " " -XAPI_DEFAULT_PASSWORD = " " - class XenAPIError(Exception): passQuoted 14 lines
Quoted 4 lines
xen-unstable.hg/tools/xm-test/lib/XmTestLib/xapi.py +0
-0@@ -58,8 +55,12 @@ def _connect(*args): global _server, _session, _initialised if not _initialised: _server = ServerProxy('httpu:///var/run/xend/xen-api.sock')xen-unstable.hg/tools/xm-test/lib/XmTestLib/xapi.py def _connect(*args): · line 65
Quoted 10 lines
xen-unstable.hg/tools/xm-test/lib/XmTestLib/xapi.py +6
-2- login = XAPI_DEFAULT_LOGIN - password = XAPI_DEFAULT_PASSWORD + try: + from XmTestLib import xapi_auth + except: + FAIL("Missing Xen-API credentials. Run xapi-setup.py!") + login = xapi_auth.XAPI_DEFAULT_LOGIN + password = xapi_auth.XAPI_DEFAULT_PASSWORD creds = (login, password) _session = execute(_server.session.login_with_password,*creds)
Quoted 65 lines
Quoted 22 lines
xen-unstable.hg/tools/xm-test/lib/XmTestLib/xapi.py +0
-0_initialised = TrueIndex:
root/xen-unstable.hg/tools/xm-test/tests/vtpm/09_vtpm-xapi.py
===================================================================xen-unstable.hg/tools/xm-test/tests/vtpm/09_vtpm-xapi.py +4
-0@@ -68,6 +68,10 @@ def do_test(): domain.destroy() +try: + import PAM +except ImportError: + SKIP("Skipping test. Python-PAM module not found.") try: do_test()Index:
root/xen-unstable.hg/tools/xm-test/xapi-setup.py
===================================================================xen-unstable.hg/tools/xm-test/xapi-setup.py new file +1
-0@@ -0,0 +1,41 @@ +#!/usr/bin/pythonxen-unstable.hg/tools/xm-test/xapi-setup.py line 11
Quoted 10 lines
xen-unstable.hg/tools/xm-test/xapi-setup.py new file +10
-0+import sys as sys +import getpass as getpass + +XAPI_AUTH_FILE = "xapi_auth.py" +XAPI_AUTH_PATH = "./lib/XmTestLib/" +XAPI_FILE = XAPI_AUTH_PATH + XAPI_AUTH_FILE + +def usage(): + print "Usage: xapi-setup.py [<username>] [<password>]\n\n" \ + "Tool to setup the xm-test suite for being able to usethe Xen-API\n" \
xen-unstable.hg/tools/xm-test/xapi-setup.py line 12
Quoted 1 line
xen-unstable.hg/tools/xm-test/xapi-setup.py new file +1
-0+ "with authenticated sessions. Username and password arestored in\n" \
Quoted 29 lines
xen-unstable.hg/tools/xm-test/xapi-setup.py new file +29
-0+ "cleartext in %s.\n" % XAPI_FILE + +def main(): + if (len(sys.argv) >= 2) and sys.argv[1] == "-?": + usage() + sys.exit(0) + print "Enter username and password for usage with Xen-API:\n" + if (len(sys.argv) >=2 ): + username = sys.argv[1] + print "Login: %s" % username + else: + username = rawinput("Login: ") + if (len(sys.argv) >= 3 ): + password = sys.argv[2] + print "Password: <given>" + else: + password = getpass.getpass() + f = open(XAPI_FILE, "w") + if f: + f.write("# File was created by xapi-setup.py.\n" + "XAPI_DEFAULT_LOGIN = \"%s\"\n" + "XAPI_DEFAULT_PASSWORD = \"%s\"\n" + % (username, password)) + f.close() + else: + print("Could not open file %s for writing." % XAPI_FILE) + +if __name__ == "__main__": + sys.exit(main())
[email protected] wrote on 12/27/2006 11:09:46 AM:
Quoted 7 lines · Stefan Berger
Quoted 6 lines
Ewan Mellor <[email protected]> wrote on 12/23/2006 07:45:04 AM:
Quoted 3 lines · Stefan Berger
Quoted 2 lines
I am adding a tool '
xapi-setup.py' to the xm-test suite for being
able
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
to setup authentication credentials needed for automatically
running
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line
Xen-API - related tests. The username and password information is
stored
Quoted 2 lines
Quoted 2 lines
in cleartext in
lib/XmTestLib/xapi_auth.py.
In the one test using the Xen-API I add another check for
availability
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
of the python PAM module. The test is skipped if the module is not available on the system.
Signed-off-by Stefan Berger <[email protected]>
Quoted 7 lines
Quoted 7 lines
Quoted 5 lines
Ah, sorry, I'd forgotten about this one.
There is now a configuration file for xm (see
tools/examples/xm-config.xml) so would it make sense to pull the username and password from there? If you look atxen/xm/main.py,I had not seen this file, but it seems not to be copied into
/etc/xen/
by
Quoted 3 lines
Quoted 1 line
default.
No, it doesn't go in by default at the moment, because it arrived quite
late
Quoted 1 line
in the 3.0.4 run-up, so I decided not to activate it by default. Sorry
that
Quoted 1 line
you'd missed it. I'm going to change the
Makefilein unstable now so
that it
Quoted 1 line
gets put in there by default.
On my system I had quite a few problems when I copied the xm-config.xml file to /etc/xen. Probably you should change its contents so it does not use Xen-API by default, yet, since for example Fedora core installs don't come with a pyhton PAM module - at least I could not find it and many others might not have installed the package, either.
The patch I sent before was due to me trying to create a VM using the Xen_API and the ramdisk not becoming available. So I think there is a need for testing the
raw Xen-API as well. I wrote a basic test case for this and put it into a new directory tests/xapi into the xm-test suite.
Quoted 3 lines
Quoted 3 lines
Would it be ok for now if I adapted the XML format and have
xapi.pytry to get username/password from the xm-config.xml file first
and
Quoted 1 line
Quoted 1 line
if it does not exist read the file created by the tool that I add to
the
Quoted 3 lines
Quoted 1 line
xm test suite (
xapi-setup.py) ?You could if you want to, but you'll have a lot less code to write if
you just
Quoted 19 lines
import the relevant bits from xm:
~ # python
Python 2.4.4 (#2, Oct 19 2006, 23:03:48)
[GCC 4.1.2 20061007 (prerelease) (Debian 4.1.1-16)] on linux2 Type "help", "copyright", "credits" or "license" for more information.Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
import sys
sys.path.append('/usr/lib/python')
import xen.xm.main
xen.xm.main.serverTypeu'Xen-API'
Quoted 1 line
Quoted 1 line
Quoted 1 line
xen.xm.main.serverURI
Quoted 1 line
Quoted 1 line
Quoted 1 line
xen.xm.main.parseAuthentication()(u'ewan', u'letmein')
Connecting to the server should be a lot easier now too:
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
from xen.xm import XenAPI
session =XenAPI.Session(xen.xm.main.serverURI)session.login_with_password(*xen.xm.main.parseAuthentication())session.xenapi.VM.get_all()['00000000-0000-0000-0000-000000000000',
'2f8dada9-387c-d981-0e51-6f5e2732d752',
'53a01d42-c8c8-e561-6939-e2bc750454f7']
Thanks. This is helpful for raw xen-api testing.
Quoted 5 lines
It would be best, I think, if xm-test shares those bits of code with xm.
It's possible that xm-test doesn't need that code at all, in the long
run,
Quoted 1 line
because it ought to be able to drive xm from the outside (that's the
whole
Quoted 1 line
point of xm-test after all -- its an end-to-end test). What you seem to
be
I understand, but functionality of xm will likely not cover the whole xen-api and so I think that separate tests for the raw xen-api can be useful.
Quoted 1 line
writing is tests for the API, but that don't test xm itself.
That'sgreat, if
Quoted 1 line
xm itself will never have the bits of functionality under test. The
plan is
Quoted 1 line
for xm to move over to using the new API throughout, so for the majority
of
Quoted 1 line
the functionality, we ought to be doing the full end-to-end test, and
prodding
Quoted 3 lines
xm from the outside, rather than using ServerProxy.
Coverage from both aspects -- the raw API and the xm-sanitised version
--
Quoted 1 line
would be best, of course, but we're already struggling to get enough
people
Quoted 1 line
writing tests, so it'd be best to concentrate on the end-to-end tests
for now.
Agreed.
Stefan
Quoted 7 lines
Ewan.
Quoted 3 lines
Stefan
Quoted 1 line
there's code for parsing the config file, and also for using the
XenAPI
Quoted 1 line
Quoted 1 line
Quoted 1 line
session manager and server proxy -- you ought to be able to import
that
Quoted 1 line
Quoted 1 line
Quoted 1 line
code now rather than using ServerProxy, and then there will be less
for
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
xapi.pyto do, because it will be sharing with xm.Cheers,
Ewan.
Quoted 2 lines
Index:
root/xen-unstable.hg/tools/xm-test/lib/XmTestLib/xapi.py
===================================================================
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
xen-unstable.hg/tools/xm-test/lib/XmTestLib/xapi.py +0
-3@@ -24,9 +24,6 @@ from xen.util.xmlrpclib2 import ServerPr from types import DictType -XAPI_DEFAULT_LOGIN = " " -XAPI_DEFAULT_PASSWORD = " " - class XenAPIError(Exception): pass
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
xen-unstable.hg/tools/xm-test/lib/XmTestLib/xapi.py def _connect(*args): · line 57
Quoted 4 lines
xen-unstable.hg/tools/xm-test/lib/XmTestLib/xapi.py +0
-0@@ -58,8 +55,12 @@ def _connect(*args): global _server, _session, _initialised if not _initialised: _server =
ServerProxy('httpu:///var/run/xend/xen-api.sock')
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
xen-unstable.hg/tools/xm-test/lib/XmTestLib/xapi.py def _connect(*args):
Quoted 6 lines
xen-unstable.hg/tools/xm-test/lib/XmTestLib/xapi.py +4
-2- login = XAPI_DEFAULT_LOGIN - password = XAPI_DEFAULT_PASSWORD + try: + from XmTestLib import xapi_auth + except: + FAIL("Missing Xen-API credentials. Run
xapi-setup.py!")
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
xen-unstable.hg/tools/xm-test/lib/XmTestLib/xapi.py def _connect(*args):
Quoted 4 lines
xen-unstable.hg/tools/xm-test/lib/XmTestLib/xapi.py +2
-0+ login = xapi_auth.XAPI_DEFAULT_LOGIN + password = xapi_auth.XAPI_DEFAULT_PASSWORD creds = (login, password) _session = execute(_server.session.login_with_password,*creds)
Quoted 2 lines
Quoted 2 lines
xen-unstable.hg/tools/xm-test/lib/XmTestLib/xapi.py +0
-0_initialised = TrueIndex:
root/xen-unstable.hg/tools/xm-test/tests/vtpm/09_vtpm-xapi.py
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
===================================================================
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
---
root.orig/xen-unstable.hg/tools/xm-test/tests/vtpm/09_vtpm-xapi.py
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
+++
root/xen-unstable.hg/tools/xm-test/tests/vtpm/09_vtpm-xapi.pyxen-unstable.hg/tools/xm-test/lib/XmTestLib/xapi.py +4
-0@@ -68,6 +68,10 @@ def do_test(): domain.destroy() +try: + import PAM +except ImportError: + SKIP("Skipping test. Python-PAM module not found.")
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
xen-unstable.hg/tools/xm-test/lib/XmTestLib/xapi.py +0
-0try: do_test()Index:
root/xen-unstable.hg/tools/xm-test/xapi-setup.py
===================================================================
Quoted 48 lines
Quoted 39 lines
Quoted 39 lines
Quoted 4 lines
xen-unstable.hg/tools/xm-test/xapi-setup.py new file +1
-0@@ -0,0 +1,41 @@ +#!/usr/bin/pythonxen-unstable.hg/tools/xm-test/xapi-setup.py line 11
Quoted 10 lines
xen-unstable.hg/tools/xm-test/xapi-setup.py new file +10
-0+import sys as sys +import getpass as getpass + +XAPI_AUTH_FILE = "xapi_auth.py" +XAPI_AUTH_PATH = "./lib/XmTestLib/" +XAPI_FILE = XAPI_AUTH_PATH + XAPI_AUTH_FILE + +def usage(): + print "Usage: xapi-setup.py [<username>] [<password>]\n\n" \ + "Tool to setup the xm-test suite for being able to usethe Xen-API\n" \
xen-unstable.hg/tools/xm-test/xapi-setup.py line 12
Quoted 1 line
xen-unstable.hg/tools/xm-test/xapi-setup.py new file +1
-0+ "with authenticated sessions. Username and password arestored in\n" \
Quoted 22 lines
xen-unstable.hg/tools/xm-test/xapi-setup.py new file +22
-0+ "cleartext in %s.\n" % XAPI_FILE + +def main(): + if (len(sys.argv) >= 2) and sys.argv[1] == "-?": + usage() + sys.exit(0) + print "Enter username and password for usage with Xen-API:\n" + if (len(sys.argv) >=2 ): + username = sys.argv[1] + print "Login: %s" % username + else: + username = rawinput("Login: ") + if (len(sys.argv) >= 3 ): + password = sys.argv[2] + print "Password: <given>" + else: + password = getpass.getpass() + f = open(XAPI_FILE, "w") + if f: + f.write("# File was created by xapi-setup.py.\n" + "XAPI_DEFAULT_LOGIN = \"%s\"\n" + "XAPI_DEFAULT_PASSWORD = \"%s\"\n"Quoted 8 lines
Quoted 8 lines
xen-unstable.hg/tools/xm-test/xapi-setup.py line 41
Quoted 7 lines
xen-unstable.hg/tools/xm-test/xapi-setup.py new file +7
-0+ % (username, password)) + f.close() + else: + print("Could not open file %s for writing." % XAPI_FILE) + +if __name__ == "__main__": + sys.exit(main())
Quoted 4 lines
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 5 lines · Stefan Berger
On my system I had quite a few problems when I copied the xm-config.xml file to
/etc/xen. Probably you should change its contents so it does not use Xen-API by default, yet, since for example Fedora core installs don't come with a pyhton PAM module - at least I could not find it and many others might not have installed the package, either.
The version I've just committed keeps the config settings at their defaults, yes.
For full authenticated access, you need Python-PAM, yes. As an alternative, you can now set your Xen-API server up to use no authentication, with something like this in xend-config.sxp:
(xen-api-server ((127.0.0.1:9363 none)))
This will open TCP port 9363, listening only on the local interface, using no authentication.
Quoted 5 lines
The patch I sent before was due to me trying to create a VM using the
Xen_APIand the ramdisk not becoming available. So I think there is a need for testing the
raw Xen-API as well. I wrote a basic test case for this and put it into a new directory tests/xapi into the xm-test suite.
Certainly, I'd like to see tests that hit the raw API too. It's still a moving target, of course, but things are starting to settle down a bit, so comprehensive test suites, either through the Python bindings, or even the C bindings or the CIM providers would all be good.
Cheers,
Ewan.