Code

Do not request a password for each created object, we may have created a template
[gosa.git] / gosa-si / tests / client.php
index 900c9bf7becf859f7479c295d1f617f6b10d0ee6..84c5d701a586e3159b259861cb5857f3cb50e721 100755 (executable)
@@ -4,6 +4,12 @@
 require_once("../../gosa-core/include/class_socketClient.inc");
 error_reporting(E_ALL);
 
+function microtime_float()
+{
+       list($usec, $sec) = explode(" ", microtime());
+       return ((float)$usec + (float)$sec);
+}
+
 $zahl= 1;
 
 for($count = 1; $count <= $zahl; $count++)
@@ -14,12 +20,15 @@ for($count = 1; $count <= $zahl; $count++)
   #$sock = new Socket_Client("10.89.1.42","20081",TRUE,5);
   #$sock->setEncryptionKey("secret-gosa-password");
 
+  $mac = "00:01:6C:9D:B9:FA"; # ws-muc-02
+
   if($sock->connected()){
 
        # Funktioniert noch nicht
        #$data = "<xml><header>gosa_opsi_test</header><source>GOSA</source><target>00:01:6C:9D:B9:FA</target><productId>acroread</productId></xml>";
 
-       #$data = "<xml><header>gosa_opsi_getLicenseInformationForProduct</header><source>GOSA</source><target>00:01:6C:9D:B9:FA</target><productId>acroread</productId></xml>";
+       #$data = "<xml><header>gosa_opsi_getLicenseInformationForProduct</header><source>GOSA</source><target>00:01:6C:9D:B9:FA</target><productId>python</productId></xml>";
+       #$data = "<xml><header>gosa_opsi_getLicenseInformationForProduct</header><source>GOSA</source><target>00:01:6C:9D:B9:FA</target><productId>firefox</productId></xml>";
 
        #$data = "<xml><header>gosa_opsi_getLicensePools_listOfHashes</header><source>GOSA</source><target>00:01:6C:9D:B9:FA</target></xml>";
 
@@ -29,7 +38,7 @@ for($count = 1; $count <= $zahl; $count++)
 
        #$data = "<xml><header>gosa_opsi_deleteLicensePool</header><source>GOSA</source><target>00:01:6C:9D:B9:FA</target><licensePoolId>Susi</licensePoolId></xml>";
 
-       #$data = "<xml><header>gosa_opsi_createLicense</header><source>GOSA</source><target>00:01:6C:9D:B9:FA</target><partner>Gonicus GmbH</partner><notes>I'm a note!</notes><maxInstallations>10</maxInstallations><licensePoolId>Harald</licensePoolId><licenseKey>abcdefghi</licenseKey></xml>";
+       #$data = "<xml><header>gosa_opsi_createLicense</header><source>GOSA</source><target>00:01:6C:9D:B9:FA</target><partner>Gonicus GmbH</partner><notes>I'm a note!</notes><maxInstallations>1</maxInstallations><licensePoolId>LicensePool</licensePoolId><licenseKey>abcdefghi</licenseKey><softwareLicenseId>andisLizenz</softwareLicenseId><licenseType>VOLUME</licenseType><boundToHost>krakenarme.intranet.gonicus.de</boundToHost></xml>";
 
        #$data = "<xml><header>gosa_opsi_assignSoftwareLicenseToHost</header><source>GOSA</source><target>00:01:6C:9D:B9:FA</target><licensePoolId>Susi</licensePoolId><hostId>linux-cl-2.intranet.gonicus.de</hostId></xml>";
 
@@ -37,14 +46,25 @@ for($count = 1; $count <= $zahl; $count++)
 
        #$data = "<xml><header>gosa_opsi_unassignAllSoftwareLicensesFromHost</header><source>GOSA</source><target>00:01:6C:9D:B9:FA</target><hostId>linux-cl-2.intranet.gonicus.de</hostId></xml>";
 
-       #$data = "<xml><header>gosa_opsi_getSoftwareLicenseUsages_listOfHashes</header><source>GOSA</source><target>00:01:6C:9D:B9:FA</target><hostId>linux-cl-2.intranet.gonicus.de</hostId></xml>";
-       #$data = "<xml><header>gosa_opsi_getSoftwareLicenseUsages_listOfHashes</header><source>GOSA</source><target>00:01:6C:9D:B9:FA</target><licensePoolId>Susi</licensePoolId></xml>";
-       #$data = "<xml><header>gosa_opsi_getSoftwareLicenseUsages_listOfHashes</header><source>GOSA</source><target>00:01:6C:9D:B9:FA</target></xml>";
+       #$data = "<xml><header>gosa_opsi_getSoftwareLicenseUsages</header><source>GOSA</source><target>00:01:6C:9D:B9:FA</target><hostId>krakenarme.intranet.gonicus.de</hostId></xml>";
+       #$data = "<xml><header>gosa_opsi_getSoftwareLicenseUsages</header><source>GOSA</source><target>00:01:6C:9D:B9:FA</target><licensePoolId>LicensePool</licensePoolId></xml>";
+       #$data = "<xml><header>gosa_opsi_getSoftwareLicenseUsages</header><source>GOSA</source><target>00:01:6C:9D:B9:FA</target></xml>";
+       #$data = "<xml><header>gosa_opsi_getSoftwareLicenseUsagesForProductId</header><source>GOSA</source><target>00:01:6C:9D:B9:FA</target><productId>firefox</productId></xml>";
 
        #$data = "<xml><header>gosa_opsi_getSoftwareLicense_hash</header><source>GOSA</source><target>00:01:6C:9D:B9:FA</target><softwareLicenseId>l_2009-09-22_09:50:58_0</softwareLicenseId></xml>";
 
-       $data = "<xml><header>gosa_opsi_getPool</header><source>GOSA</source><target>00:01:6C:9D:B9:FA</target><licensePoolId>LicensePool</licensePoolId></xml>";
+       #$data = "<xml><header>gosa_opsi_getPool</header><source>GOSA</source><target>00:01:6C:9D:B9:FA</target><licensePoolId>LicensePool</licensePoolId></xml>";
+
+       #$data = "<xml><header>gosa_opsi_removeLicense</header><source>GOSA</source><target>00:01:6C:9D:B9:FA</target><licensePoolId>LicensePool</licensePoolId><softwareLicenseId>l_2009-09-22_14:06:11</softwareLicenseId></xml>";
 
+       #$data = "<xml><header>gosa_opsi_getReservedLicenses</header><source>GOSA</source><target>00:01:6C:9D:B9:FA</target><hostId>linux-cl-2.intranet.gonicus.de</hostId></xml>";
+
+       #$data = "<xml><header>gosa_opsi_boundHostToLicense</header><source>GOSA</source><target>00:01:6C:9D:B9:FA</target><softwareLicenseId>andisLizenz</softwareLicenseId><hostId>krakenarme.intranet.gonicus.de</hostId></xml>";
+       #$data = "<xml><header>gosa_opsi_unboundHostFromLicense</header><source>GOSA</source><target>00:01:6C:9D:B9:FA</target><softwareLicenseId>andisLizenz</softwareLicenseId></xml>";
+
+       #$data = "<xml><header>gosa_opsi_getAllSoftwareLicenses</header><source>GOSA</source><target>00:01:6C:9D:B9:FA</target></xml>";
+
+       $data = "<xml><header>gosa_opsi_get_full_product_host_information</header><source>GOSA</source><target>00:01:6C:9D:B9:FA</target><hostId>linux-cl-2.intranet.gonicus.de</hostId></xml>";
 
        ##############################
        # periodical jobs
@@ -95,7 +115,7 @@ for($count = 1; $count <= $zahl; $count++)
     # trigger jobs at client
     #$data = "<xml> <header>gosa_trigger_goto_settings_reload</header> <target>00:01:6c:9d:b9:fa</target> <source>GOSA</source> </xml>";
     #$data = "<xml> <header>gosa_detect_hardware</header> <target>00:0C:29:4C:4B:0C</target> <source>GOSA</source> </xml>";
-    #$data = "<xml> <header>gosa_new_key_for_client</header> <target>00:0C:29:4C:4B:0C</target> <source>GOSA</source> </xml>";
+    #$data = "<xml> <header>gosa_new_key_for_client</header> <target>$mac</target> <source>GOSA</source> <macaddress>$mac</macaddress></xml>";
     #$data = "<xml> <header>gosa_trigger_action_wake</header> <target>00:0C:29:4C:4B:0C</target> <source>GOSA</source></xml>";
     #$data = "<xml> <header>gosa_trigger_action_faireboot</header> <target>00:0C:29:4C:4B:0C</target> <source>GOSA</source> </xml>";
     #$data = "<xml> <header>gosa_trigger_action_reboot</header> <target>00:0C:29:4C:4B:0C</target> <source>GOSA</source> </xml>";
@@ -181,6 +201,7 @@ for($count = 1; $count <= $zahl; $count++)
 
     # Get hardware inventory
     #$data = "<xml> <header>gosa_opsi_get_client_hardware</header> <source>GOSA</source> <target>GOSA</target> <hostId>linux-cl-2.intranet.gonicus.de</hostId> </xml>";
+    #$data = "<xml> <header>gosa_opsi_get_client_hardware</header> <source>GOSA</source> <target>GOSA</target> <hostId>metrischesgewinde.intranet.gonicus.de</hostId> </xml>";
     #$data = "<xml> <header>gosa_opsi_get_client_hardware</header> <source>GOSA</source> <target>GOSA</target> <hostId>der_neue.intranet.gonicus.de</hostId> </xml>";
     
     # Get software inventory
@@ -200,14 +221,21 @@ for($count = 1; $count <= $zahl; $count++)
     #$data = "<xml> <header>gosa_opsi_add_client</header> <source>GOSA</source> <target>00:01:6c:9d:b9:fa</target> <hostId>linux-cl-2.intranet.gonicus.de</hostId> <macaddress>00:11:25:4b:8c:e5</macaddress> <description>Test halt</description> <ip>1.2.3.4</ip> <notes>Im a note</notes> </xml>";
 
     # Add product to Opsi client
-    #$data = "<xml> <header>gosa_opsi_add_product_to_client</header> <source>GOSA</source> <target>00:01:6c:9d:b9:fa</target> <macaddress>00:11:25:4b:8c:e5</macaddress> <hostId>linux-cl-2.intranet.gonicus.de</hostId> <productId>winxppro</productId> </xml>";
+    #$data = "<xml><header>gosa_opsi_add_product_to_client</header><source>GOSA</source><target>$mac</target><hostId>linux-cl-2.intranet.gonicus.de</hostId><productId>winxppro</productId></xml>";
+    #$data = "<xml><header>gosa_opsi_add_product_to_client</header><source>GOSA</source><target>$mac</target><hostId>linux-cl-2.intranet.gonicus.de</hostId><productId>acroread</productId></xml>";
     #$data = "<xml> <header>gosa_opsi_add_product_to_client</header> <source>GOSA</source> <target>00:01:6c:9d:b9:fa</target> <macaddress>00:11:25:4b:8c:e5</macaddress> <hostId>linux-cl-2.intranet.gonicus.de</hostId> <productId>preloginloader</productId> </xml>";
-    #$data = "<xml> <header>gosa_opsi_add_product_to_client</header> <source>GOSA</source> <target>00:01:6c:9d:b9:fa</target> <macaddress>00:11:25:4b:8c:e5</macaddress> <hostId>linux-cl-2.intranet.gonicus.de</hostId> <productId>opsi-adminutils</productId> </xml>";
-    #$data = "<xml> <header>gosa_opsi_add_product_to_client</header> <source>GOSA</source> <target>00:01:6c:9d:b9:fa</target> <macaddress>00:11:25:4b:8c:e5</macaddress> <hostId>linux-cl-2.intranet.gonicus.de</hostId> <productId>xpconfig</productId> </xml>";
-    #$data = "<xml> <header>gosa_opsi_add_product_to_client</header> <source>GOSA</source> <target>00:01:6c:9d:b9:fa</target> <macaddress>00:11:25:4b:8c:e5</macaddress> <hostId>linux-cl-2.intranet.gonicus.de</hostId> <productId>hwaudit</productId> </xml>";
-    #$data = "<xml> <header>gosa_opsi_add_product_to_client</header> <source>GOSA</source> <target>00:01:6c:9d:b9:fa</target> <macaddress>00:11:25:4b:8c:e5</macaddress> <hostId>linux-cl-2.intranet.gonicus.de</hostId> <productId>javavm</productId> </xml>";
-    #$data = "<xml> <header>gosa_opsi_add_product_to_client</header> <source>GOSA</source> <target>00:01:6c:9d:b9:fa</target> <macaddress>00:11:25:4b:8c:e5</macaddress> <hostId>linux-cl-2.intranet.gonicus.de</hostId> <productId>firefox</productId> </xml>";
-    #$data = "<xml> <header>gosa_opsi_add_product_to_client</header> <source>GOSA</source> <target>00:01:6c:9d:b9:fa</target> <macaddress>00:11:25:4b:8c:e5</macaddress> <hostId>linux-cl-2.intranet.gonicus.de</hostId> <productId>flashplayer</productId> </xml>";
+    
+       #$data = "<xml> <header>gosa_opsi_add_product_to_client</header> <source>GOSA</source> <target>00:01:6c:9d:b9:fa</target> <macaddress>00:11:25:4b:8c:e5</macaddress> <hostId>linux-cl-2.intranet.gonicus.de</hostId> <productId>opsi-adminutils</productId> </xml>";
+    
+       #$data = "<xml> <header>gosa_opsi_add_product_to_client</header> <source>GOSA</source> <target>00:01:6c:9d:b9:fa</target> <macaddress>00:11:25:4b:8c:e5</macaddress> <hostId>linux-cl-2.intranet.gonicus.de</hostId> <productId>xpconfig</productId> </xml>";
+    
+       #$data = "<xml> <header>gosa_opsi_add_product_to_client</header> <source>GOSA</source> <target>00:01:6c:9d:b9:fa</target> <macaddress>00:11:25:4b:8c:e5</macaddress> <hostId>linux-cl-2.intranet.gonicus.de</hostId> <productId>hwaudit</productId> </xml>";
+    
+       #$data = "<xml> <header>gosa_opsi_add_product_to_client</header> <source>GOSA</source> <target>00:01:6c:9d:b9:fa</target> <macaddress>00:11:25:4b:8c:e5</macaddress> <hostId>linux-cl-2.intranet.gonicus.de</hostId> <productId>javavm</productId> </xml>";
+    
+       #$data = "<xml> <header>gosa_opsi_add_product_to_client</header> <source>GOSA</source> <target>00:01:6c:9d:b9:fa</target> <macaddress>00:11:25:4b:8c:e5</macaddress> <hostId>linux-cl-2.intranet.gonicus.de</hostId> <productId>firefox</productId> </xml>";
+    
+       #$data = "<xml> <header>gosa_opsi_add_product_to_client</header> <source>GOSA</source> <target>00:01:6c:9d:b9:fa</target> <macaddress>00:11:25:4b:8c:e5</macaddress> <hostId>linux-cl-2.intranet.gonicus.de</hostId> <productId>flashplayer</productId> </xml>";
 
     # Delete product from Opsi client
     #$data = "<xml> <header>gosa_opsi_del_product_from_client</header> <source>GOSA</source> <target>00:01:6c:9d:b9:fa</target> <hostId>linux-cl-1.intranet.gonicus.de</hostId> <macaddress>00:11:25:4b:8c:e5</macaddress> <productId>wipedisk</productId>  </xml>";
@@ -247,13 +275,18 @@ for($count = 1; $count <= $zahl; $count++)
     #$data = "<xml> <header>gosa_trigger_reload_syslog_config</header> <source>GOSA</source> <target>GOSA</target> <macaddress>00:0C:29:4C:4B:0C</macaddress> </xml>"; 
 
 
+       $time_start = microtime_float();
 
     $sock->write($data);
     $answer = "nothing";
     $answer = $sock->read();
-
     echo "$count: $answer\n";
     $sock->close();    
+
+       $time_end = microtime_float();
+       $time = $time_end - $time_start;
+       echo "Processing time: $time seconds\n";
+
   }else{
     echo "... FAILED!\n";
   }