NET-API-BECOME-DC: at least find the 'provision' function in python mode
authorStefan Metzmacher <metze@samba.org>
Thu, 14 Feb 2008 13:56:58 +0000 (14:56 +0100)
committerStefan Metzmacher <metze@samba.org>
Fri, 15 Feb 2008 07:49:47 +0000 (08:49 +0100)
This is still broken, as we call provision() with wrong arguments.
Also the python provision() function, doesn't allow us
to specify the locations of the partition ldb files,
this is strictly needed otherwise the torture test destroys
a production databases.

I think we should have a provision_become_dc() again!

metze
(This used to be commit 096eafd34778dde222bce4b0a5c0fc38b7de0359)

source4/torture/libnet/libnet_BecomeDC.c

index 0dd06bda4cb771eb533264ae4ee04df83932fbd1..997dbc93b8c7eaf16722d0646183f3015b09a6d0 100644 (file)
@@ -284,6 +284,7 @@ static NTSTATUS test_become_dc_prepare_db_py(void *private_data,
 {
        struct test_become_dc_state *s = talloc_get_type(private_data, struct test_become_dc_state);
        bool ok;
+       PyObject *module, *module_dict;
        PyObject *provision_fn, *result, *parameters;
 
        DEBUG(0,("Provision for Become-DC test using PYTHON\n"));
@@ -293,13 +294,24 @@ static NTSTATUS test_become_dc_prepare_db_py(void *private_data,
 
        py_update_path("bin"); /* FIXME: Can't assume this always runs in source/... */
 
-       provision_fn = PyImport_Import(PyString_FromString("samba.provision.provision"));
+       module = PyImport_Import(PyString_FromString("samba.provision"));
+       if (module == NULL) {
+               DEBUG(0, ("Unable to import 'samba.provision' Python module.\n"));
+               return NT_STATUS_UNSUCCESSFUL;
+       }
+
+       module_dict = PyModule_GetDict(module);
+       if (module_dict == NULL) {
+               DEBUG(0, ("Unable to GetDict of 'samba.provision'.\n"));
+               return NT_STATUS_UNSUCCESSFUL;
+       }
 
+       provision_fn = PyDict_GetItemString(module_dict, "provision");
        if (provision_fn == NULL) {
-               DEBUG(0, ("Unable to import provision Python module.\n"));
-               return NT_STATUS_UNSUCCESSFUL;
+               DEBUG(0, ("Unable to get function 'provision' of 'samba.provision'.\n"));
+               return NT_STATUS_UNSUCCESSFUL;
        }
-       
+
        DEBUG(0,("New Server[%s] in Site[%s]\n",
                p->dest_dsa->dns_name, p->dest_dsa->site_name));