当前位置: 首页>>代码示例>>PHP>>正文


PHP Computer::add方法代码示例

本文整理汇总了PHP中Computer::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Computer::add方法的具体用法?PHP Computer::add怎么用?PHP Computer::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Computer的用法示例。


在下文中一共展示了Computer::add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: AddComputer

 /**
  * @test
  */
 public function AddComputer()
 {
     global $DB;
     $DB->connect();
     $date = date('Y-m-d H:i:s');
     $_SESSION["plugin_fusioninventory_entity"] = 0;
     $_SESSION['glpiactive_entity'] = 0;
     $_SESSION['glpiactiveentities_string'] = 0;
     $_SESSION['glpishowallentities'] = 1;
     $_SESSION["glpiname"] = 'Plugin_FusionInventory';
     $a_inventory = $this->computer_inventory;
     $pfiComputerLib = new PluginFusioninventoryInventoryComputerLib();
     $computer = new Computer();
     $pfFormatconvert = new PluginFusioninventoryFormatconvert();
     $a_inventory = $pfFormatconvert->replaceids($a_inventory);
     $serialized = gzcompress(serialize($a_inventory));
     $a_inventory['fusioninventorycomputer']['serialized_inventory'] = Toolbox::addslashes_deep($serialized);
     $this->items_id = $computer->add(array('serial' => 'XB63J7D', 'entities_id' => 0));
     $this->assertGreaterThan(0, $this->items_id, FALSE);
     $pfiComputerLib->updateComputer($a_inventory, $this->items_id, TRUE);
     // To be sure not have 2 same informations
     $pfiComputerLib->updateComputer($a_inventory, $this->items_id, FALSE);
     $GLPIlog = new GLPIlogs();
     $GLPIlog->testSQLlogs();
     $GLPIlog->testPHPlogs();
 }
开发者ID:korial29,项目名称:fusioninventory-for-glpi,代码行数:29,代码来源:VirtualmachineTest.php

示例2: testLog

 public function testLog()
 {
     global $DB;
     $DB->connect();
     $pfFormatconvert = new PluginFusioninventoryFormatconvert();
     $computer = new Computer();
     $pfiComputerLib = new PluginFusioninventoryInventoryComputerLib();
     $date = date('Y-m-d H:i:s');
     $_SESSION["plugin_fusioninventory_entity"] = 0;
     $_SESSION['glpiactiveentities_string'] = 0;
     $_SESSION['glpishowallentities'] = 1;
     $_SESSION["glpiname"] = 'Plugin_FusionInventory';
     $this->a_inventory = array('fusioninventorycomputer' => array('winowner' => 'test', 'wincompany' => 'siprossii', 'operatingsystem_installationdate' => '2012-10-16 08:12:56', 'last_fusioninventory_update' => $date), 'soundcard' => array(), 'graphiccard' => array(), 'controller' => array(), 'processor' => array(), 'computerdisk' => array(), 'memory' => array(), 'monitor' => array(), 'printer' => array(), 'peripheral' => array(), 'networkport' => array(), 'SOFTWARES' => array(), 'harddrive' => array(), 'virtualmachine' => array(), 'antivirus' => array(), 'storage' => array(), 'licenseinfo' => array(), 'networkcard' => array(), 'drive' => array(), 'batteries' => array(), 'itemtype' => 'Computer');
     $this->a_inventory['Computer'] = array('name' => 'pc', 'users_id' => 0, 'operatingsystems_id' => 'freebsd', 'operatingsystemversions_id' => '9.1-RELEASE', 'uuid' => '68405E00-E5BE-11DF-801C-B05981201220', 'domains_id' => 'mydomain.local', 'os_licenseid' => '', 'os_license_number' => '', 'operatingsystemservicepacks_id' => 'GENERIC ()root@farrell.cse.buffalo.edu', 'manufacturers_id' => '', 'computermodels_id' => '', 'serial' => 'XB63J7D', 'computertypes_id' => 'Notebook', 'is_dynamic' => 1, 'contact' => 'ddurieux');
     $this->a_inventory['processor'] = array(array('nbcores' => 2, 'manufacturers_id' => 'Intel Corporation', 'designation' => 'Core i3', 'frequence' => 2400, 'nbthreads' => 2, 'serial' => '', 'frequency' => 2400, 'frequency_default' => 2400), array('nbcores' => 2, 'manufacturers_id' => 'Intel Corporation', 'designation' => 'Core i3', 'frequence' => 2400, 'nbthreads' => 2, 'serial' => '', 'frequency' => 2400, 'frequency_default' => 2400), array('nbcores' => 2, 'manufacturers_id' => 'Intel Corporation', 'designation' => 'Core i3', 'frequence' => 2400, 'nbthreads' => 2, 'serial' => '', 'frequency' => 2400, 'frequency_default' => 2400), array('nbcores' => 2, 'manufacturers_id' => 'Intel Corporation', 'designation' => 'Core i3', 'frequence' => 2400, 'nbthreads' => 2, 'serial' => '', 'frequency' => 2400, 'frequency_default' => 2400));
     $this->a_inventory['memory'] = array(array('size' => 2048, 'serial' => '98F6FF18', 'frequence' => '1067 MHz', 'devicememorytypes_id' => 'DDR3', 'designation' => 'DDR3 - SODIMM (None)', 'busID' => 1), array('size' => 2048, 'serial' => '95F1833E', 'frequence' => '1067 MHz', 'devicememorytypes_id' => 'DDR3', 'designation' => 'DDR3 - SODIMM (None)', 'busID' => 2));
     $this->a_inventory['monitor'] = array(array('name' => '', 'serial' => '', 'manufacturers_id' => ''));
     $this->a_inventory['networkport'] = array('em0-00:23:18:cf:0d:93' => array('name' => 'em0', 'netmask' => '255.255.255.0', 'subnet' => '192.168.30.0', 'mac' => '00:23:18:cf:0d:93', 'instantiation_type' => 'NetworkPortEthernet', 'virtualdev' => 0, 'ssid' => '', 'gateway' => '', 'dhcpserver' => '', 'logical_number' => 0, 'ipaddress' => array('192.168.30.198')), 'lo0-' => array('name' => 'lo0', 'virtualdev' => 1, 'mac' => '', 'instantiation_type' => 'NetworkPortLocal', 'subnet' => '', 'ssid' => '', 'gateway' => '', 'netmask' => '', 'dhcpserver' => '', 'logical_number' => 1, 'ipaddress' => array('::1', 'fe80::1', '127.0.0.1')));
     $this->a_inventory['software'] = array('gentiumbasic$$$$110$$$$1$$$$0' => array('name' => 'GentiumBasic', 'version' => 110, 'manufacturers_id' => 1, 'entities_id' => 0, 'is_template_computer' => 0, 'is_deleted_computer' => 0, 'is_dynamic' => 1), 'imagemagick$$$$6.8.0.7_1$$$$2$$$$0' => array('name' => 'ImageMagick', 'version' => '6.8.0.7_1', 'manufacturers_id' => 2, 'entities_id' => 0, 'is_template_computer' => 0, 'is_deleted_computer' => 0, 'is_dynamic' => 1), 'orbit2$$$$2.14.19$$$$3$$$$0' => array('name' => 'ORBit2', 'version' => '2.14.19', 'manufacturers_id' => 3, 'entities_id' => 0, 'is_template_computer' => 0, 'is_deleted_computer' => 0, 'is_dynamic' => 1));
     $this->a_inventory = $pfFormatconvert->replaceids($this->a_inventory);
     $serialized = gzcompress(serialize($this->a_inventory));
     $this->a_inventory['fusioninventorycomputer']['serialized_inventory'] = Toolbox::addslashes_deep($serialized);
     $computer->add(array('serial' => 'XB63J7D', 'entities_id' => 0));
     // truncate glpi_logs
     $DB->query('TRUNCATE TABLE `glpi_logs`;');
     $this->assertEquals(0, countElementsInTable('glpi_logs'), "Log must be empty (truncate)");
     $_SESSION['glpiactive_entity'] = 0;
     $pfiComputerLib->updateComputer($this->a_inventory, 1, TRUE);
     $a_logs = getAllDatasFromTable('glpi_logs');
     foreach ($a_logs as $id => $data) {
         unset($data['date_mod']);
         $a_logs[$id] = $data;
     }
     $a_reference = array(1 => array('id' => 1, 'itemtype' => 'Software', 'items_id' => 1, 'itemtype_link' => '', 'linked_action' => 20, 'user_name' => 'Plugin_FusionInventory', 'id_search_option' => 0, 'old_value' => '', 'new_value' => ''), 2 => array('id' => 2, 'itemtype' => 'Software', 'items_id' => 2, 'itemtype_link' => '', 'linked_action' => 20, 'user_name' => 'Plugin_FusionInventory', 'id_search_option' => 0, 'old_value' => '', 'new_value' => ''), 3 => array('id' => 3, 'itemtype' => 'Software', 'items_id' => 3, 'itemtype_link' => '', 'linked_action' => 20, 'user_name' => 'Plugin_FusionInventory', 'id_search_option' => 0, 'old_value' => '', 'new_value' => ''), 4 => array('id' => 4, 'itemtype' => 'SoftwareVersion', 'items_id' => 1, 'itemtype_link' => '', 'linked_action' => 20, 'user_name' => 'Plugin_FusionInventory', 'id_search_option' => 0, 'old_value' => '', 'new_value' => ''), 5 => array('id' => 5, 'itemtype' => 'SoftwareVersion', 'items_id' => 2, 'itemtype_link' => '', 'linked_action' => 20, 'user_name' => 'Plugin_FusionInventory', 'id_search_option' => 0, 'old_value' => '', 'new_value' => ''), 6 => array('id' => 6, 'itemtype' => 'SoftwareVersion', 'items_id' => 3, 'itemtype_link' => '', 'linked_action' => 20, 'user_name' => 'Plugin_FusionInventory', 'id_search_option' => 0, 'old_value' => '', 'new_value' => ''));
     $this->assertEquals($a_reference, $a_logs, "Log must be 6 " . print_r($a_logs, true));
     $DB->query('TRUNCATE `glpi_logs`');
     // Update a second time and must not have any new lines in glpi_logs
     $pfiComputerLib->updateComputer($this->a_inventory, 1, FALSE);
     $a_logs = getAllDatasFromTable('glpi_logs');
     $a_reference = array();
     $this->assertEquals($a_reference, $a_logs, "Log may be empty at second update " . print_r($a_logs, true));
     // * Modify: contact
     // * remove a processor
     // * Remove a software
     $this->a_inventory['Computer']['contact'] = 'root';
     unset($this->a_inventory['processor'][3]);
     unset($this->a_inventory['software']['orbit2$$$$2.14.19$$$$3$$$$0']);
     $DB->query('TRUNCATE `glpi_logs`');
     $pfiComputerLib->updateComputer($this->a_inventory, 1, FALSE);
     $a_logs = getAllDatasFromTable('glpi_logs');
     foreach ($a_logs as $id => $data) {
         unset($data['date_mod']);
         $a_logs[$id] = $data;
     }
     $a_reference = array(1 => array('id' => '1', 'itemtype' => 'Computer', 'items_id' => '1', 'itemtype_link' => '', 'linked_action' => '0', 'user_name' => '', 'id_search_option' => '7', 'old_value' => 'ddurieux', 'new_value' => 'root'), 2 => array('id' => '2', 'itemtype' => 'Computer', 'items_id' => '1', 'itemtype_link' => 'DeviceProcessor', 'linked_action' => '3', 'user_name' => '', 'id_search_option' => '0', 'old_value' => 'Core i3 (1)', 'new_value' => ''), 3 => array('id' => '3', 'itemtype' => 'Computer', 'items_id' => '1', 'itemtype_link' => 'SoftwareVersion', 'linked_action' => '5', 'user_name' => 'Plugin_FusionInventory', 'id_search_option' => '0', 'old_value' => 'ORBit2 - 2.14.19 (3)', 'new_value' => ''), 4 => array('id' => '4', 'itemtype' => 'SoftwareVersion', 'items_id' => '3', 'itemtype_link' => 'Computer', 'linked_action' => '5', 'user_name' => 'Plugin_FusionInventory', 'id_search_option' => '0', 'old_value' => 'pc (1)', 'new_value' => ''));
     $this->assertEquals($a_reference, $a_logs, "May have 5 logs (update contact, remove processor\n         and remove a software)");
 }
开发者ID:korial29,项目名称:fusioninventory-for-glpi,代码行数:57,代码来源:ComputerLogTest.php

示例3: prepareDB

 /**
  * @test
  */
 public function prepareDB()
 {
     global $DB;
     $DB->connect();
     $computer = new Computer();
     $pfAgent = new PluginFusioninventoryAgent();
     $pfTask = new PluginFusioninventoryTask();
     $pfTaskjob = new PluginFusioninventoryTaskjob();
     $pfIPRange = new PluginFusioninventoryIPRange();
     // Create computers + agents
     $input = array('entities_id' => 0, 'name' => 'computer1');
     $computers_id = $computer->add($input);
     $input = array('entities_id' => 0, 'name' => 'computer1', 'version' => '{"INVENTORY":"v2.3.11"}', 'device_id' => 'computer1', 'useragent' => 'FusionInventory-Agent_v2.3.11', 'computers_id' => $computers_id);
     $pfAgent->add($input);
     $input = array('entities_id' => 0, 'name' => 'computer2');
     $computers_id = $computer->add($input);
     $input = array('entities_id' => 0, 'name' => 'computer2', 'version' => '{"INVENTORY":"v2.3.11"}', 'device_id' => 'computer2', 'useragent' => 'FusionInventory-Agent_v2.3.11', 'computers_id' => $computers_id);
     $pfAgent->add($input);
     $input = array('entities_id' => 0, 'name' => 'computer3');
     $computers_id = $computer->add($input);
     $input = array('entities_id' => 0, 'name' => 'computer3', 'version' => '{"INVENTORY":"v2.3.11"}', 'device_id' => 'computer3', 'useragent' => 'FusionInventory-Agent_v2.3.11', 'computers_id' => $computers_id);
     $pfAgent->add($input);
     // Add IPRange
     $input = array('entities_id' => 0, 'name' => 'Office', 'ip_start' => '10.0.0.1', 'ip_end' => '10.0.0.254');
     $ipranges_id = $pfIPRange->add($input);
     $input = array('entities_id' => 0, 'name' => 'Office2', 'ip_start' => '10.0.2.1', 'ip_end' => '10.0.2.254');
     $ipranges_id2 = $pfIPRange->add($input);
     // Allow all agents to do network discovery
     $query = "UPDATE `glpi_plugin_fusioninventory_agentmodules` " . " SET `is_active`='1' " . " WHERE `modulename`='NETWORKDISCOVERY'";
     $DB->query($query);
     // create task
     $input = array('entities_id' => 0, 'name' => 'network discovery', 'is_active' => 1);
     $tasks_id = $pfTask->add($input);
     // create taskjob
     $input = array('plugin_fusioninventory_tasks_id' => $tasks_id, 'entities_id' => 0, 'name' => 'discovery', 'method' => 'networkdiscovery', 'targets' => '[{"PluginFusioninventoryIPRange":"' . $ipranges_id . '"}]', 'actors' => '[{"PluginFusioninventoryAgent":"2"}]');
     $pfTaskjob->add($input);
     // create task
     $input = array('entities_id' => 0, 'name' => 'network discovery2', 'is_active' => 1);
     $tasks2_id = $pfTask->add($input);
     // create taskjob
     $input = array('plugin_fusioninventory_tasks_id' => $tasks2_id, 'entities_id' => 0, 'name' => 'discovery', 'method' => 'networkdiscovery', 'targets' => '[{"PluginFusioninventoryIPRange":"' . $ipranges_id2 . '"}]', 'actors' => '[{"PluginFusioninventoryAgent":"3"}]');
     $pfTaskjob->add($input);
 }
开发者ID:korial29,项目名称:fusioninventory-for-glpi,代码行数:46,代码来源:NetworkDiscoveryTest.php

示例4: MonitorUniqueSerialimport

 /**
  * @test
  */
 public function MonitorUniqueSerialimport()
 {
     global $DB;
     $DB->connect();
     self::restore_database();
     $_SESSION['glpiactive_entity'] = 0;
     $_SESSION["plugin_fusioninventory_entity"] = 0;
     $_SESSION["glpiname"] = 'Plugin_FusionInventory';
     $pfConfig = new PluginFusioninventoryConfig();
     $pfiComputerLib = new PluginFusioninventoryInventoryComputerLib();
     $computer = new Computer();
     $a_computerinventory = $this->a_computer1;
     $a_computer = $a_computerinventory['Computer'];
     $a_computer["entities_id"] = 0;
     $computers_id = $computer->add($a_computer);
     $pfiComputerLib->updateComputer($a_computerinventory, $computers_id, FALSE, 1);
     $computer->getFromDB(1);
     $this->assertEquals('ggheb7ne7', $computer->fields['serial'], 'Computer not updated correctly');
     $this->assertEquals(1, countElementsInTable('glpi_monitors'), 'First computer');
     $this->assertEquals(1, countElementsInTable('glpi_computers_items', 'itemtype="Monitor"'), 'First computer (links)');
     // Second try (verify not create a second same monitor)
     $pfiComputerLib->updateComputer($a_computerinventory, $computers_id, FALSE, 1);
     $computer->getFromDB(1);
     $this->assertEquals('ggheb7ne7', $computer->fields['serial'], 'Computer not updated correctly (2)');
     $this->assertEquals(1, countElementsInTable('glpi_monitors'), 'First computer (2)');
     $this->assertEquals(1, countElementsInTable('glpi_computers_items', 'itemtype="Monitor"'), 'First computer (links) (2)');
     // Second computer with same monitor
     $a_computerinventory = $this->a_computer2;
     $a_computer = $a_computerinventory['Computer'];
     $a_computer["entities_id"] = 0;
     $computers_id = $computer->add($a_computer);
     $pfiComputerLib->updateComputer($a_computerinventory, $computers_id, FALSE, 1);
     $this->assertEquals(1, countElementsInTable('glpi_monitors'), 'Second computer');
     $this->assertEquals(1, countElementsInTable('glpi_computers_items', 'itemtype="Monitor"'), 'Second computer (links)');
     // Retry first computer without monitor
     $a_computerinventory = $this->a_computer1;
     $a_computerinventory['monitor'] = array();
     $pfiComputerLib->updateComputer($a_computerinventory, $computers_id, FALSE, 1);
     $computer->getFromDB(1);
     $this->assertEquals('ggheb7ne7', $computer->fields['serial'], 'Computer not updated correctly (3)');
     $this->assertEquals(1, countElementsInTable('glpi_monitors'), 'First computer (3)');
     $this->assertEquals(1, countElementsInTable('glpi_computers_items', 'itemtype="Monitor"'), 'First computer (links) (3)');
     // * Retry first computer with monitor
     $a_computerinventory = $this->a_computer1;
     $pfiComputerLib->updateComputer($a_computerinventory, $computers_id, FALSE, 1);
     $computer->getFromDB(1);
     $this->assertEquals('ggheb7ne7', $computer->fields['serial'], 'Computer not updated correctly (4)');
     $this->assertEquals(1, countElementsInTable('glpi_monitors'), 'First computer (4)');
     $this->assertEquals(1, countElementsInTable('glpi_computers_items', 'itemtype="Monitor"'), 'First computer (links) (4)');
     $this->assertEquals(0, countElementsInTable('glpi_computers_items', 'itemtype="Monitor" AND `id` > 3'), 'First computer (number id of links recreated) (4)');
 }
开发者ID:korial29,项目名称:fusioninventory-for-glpi,代码行数:54,代码来源:ComputerMonitorTest.php

示例5: Licenses

 /**
  * @test
  */
 public function Licenses()
 {
     global $DB;
     $DB->connect();
     $_SESSION['glpiactive_entity'] = 0;
     $_SESSION["plugin_fusioninventory_entity"] = 0;
     $_SESSION["glpiname"] = 'Plugin_FusionInventory';
     $pfiComputerLib = new PluginFusioninventoryInventoryComputerLib();
     $computer = new Computer();
     $GLPIlog = new GLPIlogs();
     $a_computerinventory = $this->a_computer1;
     $a_computer = $a_computerinventory['Computer'];
     $a_computer["entities_id"] = 0;
     $computers_id = $computer->add($a_computer);
     $pfiComputerLib->updateComputer($a_computerinventory, $computers_id, FALSE, 1);
     $computer->getFromDB(1);
     $this->assertEquals('ggheb7ne7', $computer->fields['serial'], 'Computer not updated correctly');
     $this->assertEquals(1, countElementsInTable('glpi_plugin_fusioninventory_computerlicenseinfos'), 'License may be added in fusion table');
     $pfComputerLicenseInfo = new PluginFusioninventoryComputerLicenseInfo();
     $pfComputerLicenseInfo->getFromDB(1);
     $a_ref = array('id' => 1, 'computers_id' => 1, 'softwarelicenses_id' => 0, 'name' => 'Microsoft Office 2003', 'fullname' => 'Microsoft Office Professional Edition 2003', 'serial' => 'xxxxx-xxxxx-P6RC4-xxxxx-xxxxx', 'is_trial' => '0', 'is_update' => '0', 'is_oem' => '0', 'activation_date' => NULL);
     $this->assertEquals($a_ref, $pfComputerLicenseInfo->fields, 'License data');
 }
开发者ID:korial29,项目名称:fusioninventory-for-glpi,代码行数:26,代码来源:ComputerLicenseTest.php

示例6: generate_entity

/** Generate bigdump : generate items for an entity
 *
 * @param $ID_entity entity ID
**/
function generate_entity($ID_entity) {
   global $MAX, $DB, $percent, $FIRST, $LAST, $MAX_KBITEMS_BY_CAT, $MAX_DISK,
         $DOCUMENTS, $NET_PORT, $NET_LOC;

   regenerateTreeCompleteName("glpi_entities");

   $current_year = date("Y");


   // DOMAIN
   $items = array("SP2MI", "CAMPUS"," IUT86", "PRESIDENCE", "CEAT", "D'omaine");
   $dp    = new Domain();
   $FIRST["domain"] = getMaxItem("glpi_domains")+1;

   for ($i=0 ; $i<$MAX['domain'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "domain $ID_entity '$i";
      }
      $dp->add(toolbox::addslashes_deep(array('name'         => $val,
                                              'entities_id'  => $ID_entity,
                                              'is_recursive' => 1,
                                              'comment'      => "comment $val")));
   }
   $LAST["domain"] = getMaxItem("glpi_domains");


   // STATUS
   $items = array("Reparation", "En stock", "En fonction", "Retour SAV", "En attente d'");
   $dp    = new State();
   $FIRST["state"] = getMaxItem("glpi_states")+1;
   for ($i=0 ; $i<$MAX['state'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "State $ID_entity '$i";
      }
      $state_id = $dp->add(toolbox::addslashes_deep(array('name'         => $val,
                                                          'entities_id'  => $ID_entity,
                                                          'is_recursive' => 1,
                                                          'comment'      => "comment $val")));

      // generate sub status
      for ($j=0 ; $j<$MAX['state'] ; $j++) {
         $val2 = "Sub $val $j";

         $dp->add(toolbox::addslashes_deep(array('name'         => $val2,
                                                 'entities_id'  => $ID_entity,
                                                 'is_recursive' => 1,
                                                 'states_id'    => $state_id,
                                                 'comment'      => "comment $val")));
      }

   }
   $LAST["state"]      = getMaxItem("glpi_states");


   // glpi_groups
   $FIRST["groups"] = getMaxItem("glpi_groups")+1;
   $group           = new Group();
   for ($i=0 ; $i<$MAX['groups'] ; $i++) {
      $gID = $group->add(toolbox::addslashes_deep(
                         array('entities_id'  => $ID_entity,
                               'name'         => "group d'$i",
                               'comment'      => "comment group d'$i",
                               'is_assign'    => 0)));

      // Generate sub group
      for ($j=0 ; $j<$MAX['groups'] ; $j++) {
         $group->add(toolbox::addslashes_deep(
                     array('entities_id'  => $ID_entity,
                           'name'         => "subgroup d'$j",
                           'comment'      => "comment subgroup d'$j of group $i",
                           'groups_id'    => $gID,
                           'is_assign'    => 0)));
      }
   }

   $LAST["groups"]      = getMaxItem("glpi_groups");

   $FIRST["techgroups"] = $LAST["groups"]+1;

   for ($i=0 ; $i<$MAX['groups'] ; $i++) {
         $group->add(toolbox::addslashes_deep(
                     array('entities_id'  => $ID_entity,
                           'name'         => "tech group d'$i",
                           'comment'      => "comment tech group d'$i")));
   }

   $LAST["techgroups"] = getMaxItem("glpi_groups");
   regenerateTreeCompleteName("glpi_groups");


   // glpi_users
   $FIRST["users_sadmin"] = getMaxItem("glpi_users")+1;
//.........这里部分代码省略.........
开发者ID:KaneoGmbH,项目名称:glpi,代码行数:101,代码来源:generate_bigdump.function.php

示例7: importComputer

 static function importComputer($ocsid, $plugin_ocsinventoryng_ocsservers_id, $lock = 0, $defaultentity = -1, $defaultlocation = -1)
 {
     global $PluginOcsinventoryngDBocs;
     self::checkOCSconnection($plugin_ocsinventoryng_ocsservers_id);
     $comp = new Computer();
     $rules_matched = array();
     self::setChecksumForComputer($ocsid, self::MAX_CHECKSUM);
     //No entity or location predefined, check rules
     if ($defaultentity == -1 || $defaultlocation == 0) {
         //Try to affect computer to an entity
         $rule = new RuleImportEntityCollection();
         $data = array();
         $data = $rule->processAllRules(array('ocsservers_id' => $plugin_ocsinventoryng_ocsservers_id, '_source' => 'ocsinventoryng'), array(), array('ocsid' => $ocsid));
     } else {
         //An entity or a location has already been defined via the web interface
         $data['entities_id'] = $defaultentity;
         $data['locations_id'] = $defaultlocation;
     }
     //Try to match all the rules, return the first good one, or null if not rules matched
     if (isset($data['entities_id']) && $data['entities_id'] >= 0) {
         if ($lock) {
             while (!($fp = self::setEntityLock($data['entities_id']))) {
                 sleep(1);
             }
         }
         //Store rule that matched
         if (isset($data['_ruleid'])) {
             $rules_matched['RuleImportEntity'] = $data['_ruleid'];
         }
         //New machine to import
         $query = "SELECT `hardware`.*, `bios`.*, accountinfo.*\n                   FROM `hardware`\n                   LEFT JOIN `accountinfo` ON (`accountinfo`.`HARDWARE_ID`=`hardware`.`ID`)\n                   LEFT JOIN `bios` ON (`bios`.`HARDWARE_ID`=`hardware`.`ID`)\n                   WHERE `hardware`.`ID` = '{$ocsid}'";
         $result = $PluginOcsinventoryngDBocs->query($query);
         if ($result && $PluginOcsinventoryngDBocs->numrows($result) == 1) {
             $line = $PluginOcsinventoryngDBocs->fetch_array($result);
             $line = Toolbox::clean_cross_side_scripting_deep(Toolbox::addslashes_deep($line));
             $locations_id = isset($data['locations_id']) ? $data['locations_id'] : 0;
             $input = self::getComputerInformations($line, self::getConfig($plugin_ocsinventoryng_ocsservers_id), $data['entities_id'], $locations_id);
             //Check if machine could be linked with another one already in DB
             $rulelink = new RuleImportComputerCollection();
             $rulelink_results = array();
             $params = array('entities_id' => $data['entities_id'], 'plugin_ocsinventoryng_ocsservers_id' => $plugin_ocsinventoryng_ocsservers_id, 'ocsid' => $ocsid);
             $rulelink_results = $rulelink->processAllRules(Toolbox::stripslashes_deep($input), array(), $params);
             //If at least one rule matched
             //else do import as usual
             if (isset($rulelink_results['action'])) {
                 $rules_matched['RuleImportComputer'] = $rulelink_results['_ruleid'];
                 switch ($rulelink_results['action']) {
                     case self::LINK_RESULT_NO_IMPORT:
                         return array('status' => self::COMPUTER_LINK_REFUSED, 'entities_id' => $data['entities_id'], 'rule_matched' => $rules_matched);
                     case self::LINK_RESULT_LINK:
                         if (is_array($rulelink_results['found_computers']) && count($rulelink_results['found_computers']) > 0) {
                             foreach ($rulelink_results['found_computers'] as $tmp => $computers_id) {
                                 if (self::linkComputer($ocsid, $plugin_ocsinventoryng_ocsservers_id, $computers_id)) {
                                     return array('status' => self::COMPUTER_LINKED, 'entities_id' => $data['entities_id'], 'rule_matched' => $rules_matched, 'computers_id' => $computers_id);
                                 }
                             }
                             break;
                         }
                 }
             }
             $computers_id = $comp->add($input, array('unicity_error_message' => false));
             if ($computers_id) {
                 $ocsid = $line['ID'];
                 $changes[0] = '0';
                 $changes[1] = "";
                 $changes[2] = $ocsid;
                 PluginOcsinventoryngOcslink::history($computers_id, $changes, PluginOcsinventoryngOcslink::HISTORY_OCS_IMPORT);
                 if ($idlink = self::ocsLink($line['ID'], $plugin_ocsinventoryng_ocsservers_id, $computers_id)) {
                     self::updateComputer($idlink, $plugin_ocsinventoryng_ocsservers_id, 0);
                 }
                 //Return code to indicates that the machine was imported
                 return array('status' => self::COMPUTER_IMPORTED, 'entities_id' => $data['entities_id'], 'rule_matched' => $rules_matched, 'computers_id' => $computers_id);
             }
             return array('status' => self::COMPUTER_NOT_UNIQUE, 'entities_id' => $data['entities_id'], 'rule_matched' => $rules_matched);
         }
         if ($lock) {
             self::removeEntityLock($data['entities_id'], $fp);
         }
     }
     //ELSE Return code to indicates that the machine was not imported because it doesn't matched rules
     return array('status' => self::COMPUTER_FAILED_IMPORT, 'rule_matched' => $rules_matched);
 }
开发者ID:geldarr,项目名称:hack-space,代码行数:82,代码来源:ocsserver.class.php

示例8: NewComputer

 /**
  * @test
  */
 public function NewComputer()
 {
     global $DB;
     $_SESSION["plugin_fusioninventory_entity"] = 0;
     $_SESSION["glpiname"] = 'Plugin_FusionInventory';
     $a_inventory = array('fusioninventorycomputer' => array('last_fusioninventory_update' => date('Y-m-d H:i:s')), 'soundcard' => array(), 'graphiccard' => array(), 'controller' => array(), 'processor' => array(), 'computerdisk' => array(), 'memory' => array(), 'monitor' => array(), 'printer' => array(), 'peripheral' => array(), 'networkport' => array(), 'software' => array(), 'harddrive' => array(), 'virtualmachine' => array(), 'antivirus' => array(), 'storage' => array(), 'licenseinfo' => array(), 'networkcard' => array(), 'drive' => array(), 'batteries' => array(), 'itemtype' => 'Computer');
     $a_inventory['Computer'] = array('name' => 'pc', 'users_id' => 0, 'operatingsystems_id' => 1, 'operatingsystemversions_id' => 1, 'uuid' => 1, 'domains_id' => 1, 'os_licenseid' => '', 'os_license_number' => '', 'operatingsystemservicepacks_id' => 1, 'manufacturers_id' => 0, 'computermodels_id' => 0, 'serial' => 'XB63J7D', 'computertypes_id' => 1, 'is_dynamic' => 1, 'contact' => 'ddurieux');
     $a_inventory['networkport'] = array('em0-cc:f9:54:a1:03:45' => array('name' => 'em0', 'netmask' => '255.255.255.0', 'subnet' => '192.168.30.0', 'mac' => 'cc:f9:54:a1:03:45', 'instantiation_type' => 'NetworkPortEthernet', 'virtualdev' => 0, 'ssid' => '', 'gateway' => '', 'dhcpserver' => '', 'logical_number' => 1, 'ipaddress' => array('192.168.30.198')));
     $networkPort = new NetworkPort();
     $a_networkports = $networkPort->find("`mac`='cc:f9:54:a1:03:45'");
     $a_networkport = current($a_networkports);
     $networkports_id = $a_networkport['id'];
     $pfiComputerLib = new PluginFusioninventoryInventoryComputerLib();
     $computer = new Computer();
     $computers_id = $computer->add(array('serial' => 'XB63J7D', 'entities_id' => 0));
     $_SESSION['glpiactive_entity'] = 0;
     $pfiComputerLib->updateComputer($a_inventory, $computers_id, FALSE);
     $a_networkports = $networkPort->find("`mac`='cc:f9:54:a1:03:45'");
     $this->assertEquals(1, count($a_networkports), "The MAC address cc:f9:54:a1:03:45 must be tied to only one port");
     $a_networkport = current($a_networkports);
     $this->assertEquals($networkports_id, $a_networkport['id'], 'The networkport ID is not the same ' . 'between the unknown device and the computer');
     $this->assertEquals('Computer', $a_networkport['itemtype'], "Maybe Computer ");
 }
开发者ID:korial29,项目名称:fusioninventory-for-glpi,代码行数:26,代码来源:UnmanagedManagedTest.php

示例9: PrinterToInventoryWithoutIP

 /**
  * @test
  */
 public function PrinterToInventoryWithoutIP()
 {
     self::restore_database();
     $printer = new Printer();
     $networkport = new NetworkPort();
     $networkName = new NetworkName();
     $pfPrinter = new PluginFusioninventoryPrinter();
     $pfTask = new PluginFusioninventoryTask();
     $pfTaskjob = new PluginFusioninventoryTaskjob();
     $computer = new Computer();
     $pfAgent = new PluginFusioninventoryAgent();
     $communication = new PluginFusioninventoryCommunication();
     // Create computers + agents
     $input = array('entities_id' => 0, 'name' => 'computer1');
     $computers_id = $computer->add($input);
     $input = array('entities_id' => 0, 'name' => 'computer1', 'version' => '{"INVENTORY":"v2.3.11"}', 'device_id' => 'computer1', 'useragent' => 'FusionInventory-Agent_v2.3.11', 'computers_id' => $computers_id);
     $pfAgent->add($input);
     // Create printer
     $input = array('name' => 'printer 001', 'entities_id' => 0);
     $printers_id = $printer->add($input);
     // Add port
     $networkports_id = $networkport->add(array('itemtype' => 'Printer', 'instantiation_type' => 'NetworkPortEthernet', 'items_id' => $printers_id, 'entities_id' => 0));
     $networknames_id = $networkName->add(array('entities_id' => 0, 'itemtype' => 'NetworkPort', 'items_id' => $networkports_id));
     $input = array('printers_id' => 1, 'plugin_fusioninventory_configsecurities_id' => 2);
     $pfPrinter->add($input);
     // Add task
     // create task
     $input = array('entities_id' => 0, 'name' => 'network inventory', 'is_active' => 1);
     $tasks_id = $pfTask->add($input);
     // create taskjob
     $input = array('plugin_fusioninventory_tasks_id' => $tasks_id, 'entities_id' => 0, 'name' => 'inventory', 'method' => 'networkinventory', 'targets' => '[{"Printer":"' . $printers_id . '"}]', 'actors' => '[{"PluginFusioninventoryAgent":"1"}]');
     $pfTaskjob->add($input);
     PluginFusioninventoryTask::cronTaskscheduler();
     $data = $pfTask->getJoblogs(array(1));
     // Task is prepared
     // Agent will get data
     $communication->getTaskAgent(1);
     $message = $communication->getMessage();
     $json = json_encode($message);
     $array = json_decode($json, TRUE);
     $ref = array();
     $this->assertEquals($ref, $array, 'XML of SNMP inventory task');
 }
开发者ID:C-Duv,项目名称:fusioninventory-for-glpi,代码行数:46,代码来源:NetworkInventoryTest.php

示例10: SoftwareUniqueForTwoComputers

 /**
  * @test
  */
 public function SoftwareUniqueForTwoComputers()
 {
     global $DB;
     $DB->connect();
     $date = date('Y-m-d H:i:s');
     $_SESSION["plugin_fusioninventory_entity"] = 0;
     $_SESSION['glpiactiveentities_string'] = 0;
     $_SESSION['glpishowallentities'] = 1;
     $_SESSION["glpiname"] = 'Plugin_FusionInventory';
     $a_inventory = array('fusioninventorycomputer' => array('winowner' => 'test', 'wincompany' => 'siprossii', 'operatingsystem_installationdate' => '2012-10-16 08:12:56', 'last_fusioninventory_update' => $date), 'soundcard' => array(), 'graphiccard' => array(), 'controller' => array(), 'processor' => array(), 'computerdisk' => array(), 'memory' => array(), 'monitor' => array(), 'printer' => array(), 'peripheral' => array(), 'networkport' => array(), 'SOFTWARES' => array(), 'harddrive' => array(), 'virtualmachine' => array(), 'antivirus' => array(), 'storage' => array(), 'licenseinfo' => array(), 'networkcard' => array(), 'drive' => array(), 'batteries' => array(), 'itemtype' => 'Computer');
     $a_inventory['Computer'] = array('name' => 'pcJ1', 'comment' => 'amd64/-1-11-30 22:04:44', 'users_id' => 0, 'operatingsystems_id' => 'freebsd', 'operatingsystemversions_id' => '9.1-RELEASE', 'uuid' => '68405E00-E5BE-11DF-801C-B05981201220', 'domains_id' => 'mydomain.local', 'os_licenseid' => '', 'os_license_number' => '', 'operatingsystemservicepacks_id' => 'GENERIC ()root@farrell.cse.buffalo.edu', 'manufacturers_id' => '', 'computermodels_id' => '', 'serial' => 'XB63J7J1', 'computertypes_id' => 'Notebook', 'is_dynamic' => 1, 'contact' => 'ddurieux');
     $a_inventory['software'] = array('acrobat_reader_9.2$$$$1.0.0.0$$$$192$$$$0' => array('name' => 'acrobat_Reader_9.2', 'version' => '1.0.0.0', 'manufacturers_id' => 192, 'entities_id' => 0, 'is_template_computer' => 0, 'is_deleted_computer' => 0));
     $pfiComputerLib = new PluginFusioninventoryInventoryComputerLib();
     $computer = new Computer();
     $pfFormatconvert = new PluginFusioninventoryFormatconvert();
     $software = new Software();
     $a_inventory = $pfFormatconvert->replaceids($a_inventory);
     $serialized = gzcompress(serialize($a_inventory));
     $a_inventory['fusioninventorycomputer']['serialized_inventory'] = Toolbox::addslashes_deep($serialized);
     $this->items_id = $computer->add(array('serial' => 'XB63J7J1', 'entities_id' => 0));
     $_SESSION['glpiactive_entity'] = 0;
     $pfiComputerLib->updateComputer($a_inventory, $this->items_id, FALSE);
     $a_software = $software->find("`name`='acrobat_Reader_9.2'");
     $this->assertEquals(1, count($a_software), "First computer added");
     $a_inventory['Computer']['name'] = "pcJ2";
     $a_inventory['Computer']['serial'] = "XB63J7J2";
     $pfiComputerLib->updateComputer($a_inventory, $this->items_id, FALSE);
     $a_software = $software->find("`name`='acrobat_Reader_9.2'");
     $this->assertEquals(1, count($a_software), "Second computer added");
 }
开发者ID:C-Duv,项目名称:fusioninventory-for-glpi,代码行数:33,代码来源:ComputerUpdateTest.php

示例11: setUp

 protected function setUp()
 {
     parent::setUp();
     self::restore_database();
     // Add some computers
     $computer = new Computer();
     $pfAgent = new PluginFusioninventoryAgent();
     $computer->add(array('name' => 'pc01', 'entities_id' => 0));
     $pfAgent->add(array('computers_id' => 1, 'entities_id' => 0));
     $computer->add(array('name' => 'pc02', 'entities_id' => 0));
     $pfAgent->add(array('computers_id' => 2, 'entities_id' => 0));
     $computer->add(array('name' => 'pc03', 'entities_id' => 0));
     $pfAgent->add(array('computers_id' => 3, 'entities_id' => 0));
     $computer->add(array('name' => 'pc04', 'entities_id' => 0));
     $pfAgent->add(array('computers_id' => 4, 'entities_id' => 0));
     $computer->add(array('name' => 'pc05', 'entities_id' => 0));
     $pfAgent->add(array('computers_id' => 5, 'entities_id' => 0));
     $computer->add(array('name' => 'pc06', 'entities_id' => 0));
     $pfAgent->add(array('computers_id' => 6, 'entities_id' => 0));
     $computer->add(array('name' => 'pc07', 'entities_id' => 0));
     $pfAgent->add(array('computers_id' => 7, 'entities_id' => 0));
     $computer->add(array('name' => 'pc08', 'entities_id' => 0));
     $pfAgent->add(array('computers_id' => 8, 'entities_id' => 0));
     $computer->add(array('name' => 'pc09', 'entities_id' => 0));
     $pfAgent->add(array('computers_id' => 9, 'entities_id' => 0));
     $computer->add(array('name' => 'pc10', 'entities_id' => 0));
     $pfAgent->add(array('computers_id' => 10, 'entities_id' => 0));
     $computer->add(array('name' => 'pc11', 'entities_id' => 0));
     $pfAgent->add(array('computers_id' => 11, 'entities_id' => 0));
     $computer->add(array('name' => 'pc12', 'entities_id' => 0));
     $pfAgent->add(array('computers_id' => 12, 'entities_id' => 0));
     $computer->add(array('name' => 'pc13', 'entities_id' => 0));
     $pfAgent->add(array('computers_id' => 13, 'entities_id' => 0));
     $computer->add(array('name' => 'srv01', 'entities_id' => 0));
     $pfAgent->add(array('computers_id' => 14, 'entities_id' => 0));
     $computer->add(array('name' => 'srv02', 'entities_id' => 0));
     $pfAgent->add(array('computers_id' => 15, 'entities_id' => 0));
     $computer->add(array('name' => 'srv03', 'entities_id' => 0));
     $pfAgent->add(array('computers_id' => 16, 'entities_id' => 0));
     $computer->add(array('name' => 'srv04', 'entities_id' => 0));
     $pfAgent->add(array('computers_id' => 17, 'entities_id' => 0));
     $computer->add(array('name' => 'srv05', 'entities_id' => 0));
     $pfAgent->add(array('computers_id' => 18, 'entities_id' => 0));
 }
开发者ID:C-Duv,项目名称:fusioninventory-for-glpi,代码行数:44,代码来源:TaskDeployDynamicGroupTest.php

示例12: importComputer

 static function importComputer($ocsid, $plugin_ocsinventoryng_ocsservers_id, $lock = 0, $defaultentity = -1, $defaultlocation = -1)
 {
     self::checkOCSconnection($plugin_ocsinventoryng_ocsservers_id);
     $comp = new Computer();
     $rules_matched = array();
     $ocsClient = self::getDBocs($plugin_ocsinventoryng_ocsservers_id);
     $ocsClient->setChecksum(PluginOcsinventoryngOcsClient::CHECKSUM_ALL, $ocsid);
     //No entity or location predefined, check rules
     if ($defaultentity == -1 && ($defaultlocation == -1 || $defaultlocation == 0)) {
         //Try to affect computer to an entity
         $rule = new RuleImportEntityCollection();
         $data = array();
         $data = $rule->processAllRules(array('ocsservers_id' => $plugin_ocsinventoryng_ocsservers_id, '_source' => 'ocsinventoryng'), array(), array('ocsid' => $ocsid));
         if (isset($data['_ignore_import']) && $data['_ignore_import'] == 1) {
             //ELSE Return code to indicates that the machine was not imported because it doesn't matched rules
             return array('status' => self::COMPUTER_LINK_REFUSED, 'rule_matched' => $data['_ruleid']);
         }
     } else {
         //An entity or a location has already been defined via the web interface
         $data['entities_id'] = $defaultentity;
         $data['locations_id'] = $defaultlocation;
     }
     //Try to match all the rules, return the first good one, or null if not rules matched
     if (isset($data['entities_id']) && $data['entities_id'] >= 0) {
         if ($lock) {
             while (!($fp = self::setEntityLock($data['entities_id']))) {
                 sleep(1);
             }
         }
         //Store rule that matched
         if (isset($data['_ruleid'])) {
             $rules_matched['RuleImportEntity'] = $data['_ruleid'];
         }
         $ocsComputer = $ocsClient->getComputer($ocsid, array('DISPLAY' => array('CHECKSUM' => PluginOcsinventoryngOcsClient::CHECKSUM_HARDWARE | PluginOcsinventoryngOcsClient::CHECKSUM_BIOS, 'WANTED' => PluginOcsinventoryngOcsClient::WANTED_ACCOUNTINFO)));
         if (!is_null($ocsComputer)) {
             $computer = Toolbox::clean_cross_side_scripting_deep(Toolbox::addslashes_deep($ocsComputer));
             $locations_id = isset($data['locations_id']) ? $data['locations_id'] : 0;
             $input = self::getComputerInformations($computer, self::getConfig($plugin_ocsinventoryng_ocsservers_id), $data['entities_id'], $locations_id);
             //Check if machine could be linked with another one already in DB
             $rulelink = new RuleImportComputerCollection();
             $rulelink_results = array();
             $params = array('entities_id' => $data['entities_id'], 'plugin_ocsinventoryng_ocsservers_id' => $plugin_ocsinventoryng_ocsservers_id, 'ocsid' => $ocsid);
             $rulelink_results = $rulelink->processAllRules(Toolbox::stripslashes_deep($input), array(), $params);
             //If at least one rule matched
             //else do import as usual
             if (isset($rulelink_results['action'])) {
                 $rules_matched['RuleImportComputer'] = $rulelink_results['_ruleid'];
                 switch ($rulelink_results['action']) {
                     case self::LINK_RESULT_NO_IMPORT:
                         return array('status' => self::COMPUTER_LINK_REFUSED, 'entities_id' => $data['entities_id'], 'rule_matched' => $rules_matched);
                     case self::LINK_RESULT_LINK:
                         if (is_array($rulelink_results['found_computers']) && count($rulelink_results['found_computers']) > 0) {
                             foreach ($rulelink_results['found_computers'] as $tmp => $computers_id) {
                                 if (self::linkComputer($ocsid, $plugin_ocsinventoryng_ocsservers_id, $computers_id)) {
                                     return array('status' => self::COMPUTER_LINKED, 'entities_id' => $data['entities_id'], 'rule_matched' => $rules_matched, 'computers_id' => $computers_id);
                                 }
                             }
                             break;
                         }
                 }
             }
             $computers_id = $comp->add($input, array('unicity_error_message' => false));
             if ($computers_id) {
                 $ocsid = $computer['META']['ID'];
                 $changes[0] = '0';
                 $changes[1] = "";
                 $changes[2] = $ocsid;
                 PluginOcsinventoryngOcslink::history($computers_id, $changes, PluginOcsinventoryngOcslink::HISTORY_OCS_IMPORT);
                 if ($idlink = self::ocsLink($computer['META']['ID'], $plugin_ocsinventoryng_ocsservers_id, $computers_id)) {
                     self::updateComputer($idlink, $plugin_ocsinventoryng_ocsservers_id, 0);
                 }
                 //Return code to indicates that the machine was imported
                 return array('status' => self::COMPUTER_IMPORTED, 'entities_id' => $data['entities_id'], 'rule_matched' => $rules_matched, 'computers_id' => $computers_id);
             }
             return array('status' => self::COMPUTER_NOT_UNIQUE, 'entities_id' => $data['entities_id'], 'rule_matched' => $rules_matched);
         }
         if ($lock) {
             self::removeEntityLock($data['entities_id'], $fp);
         }
     }
     //ELSE Return code to indicates that the machine was not imported because it doesn't matched rules
     return array('status' => self::COMPUTER_FAILED_IMPORT, 'rule_matched' => $rules_matched);
 }
开发者ID:JULIO8,项目名称:respaldo_glpi,代码行数:83,代码来源:ocsserver.class.php

示例13: visitKeyboard

    public function visitKeyboard(Keyboard $keyboard)
    {
        echo "hello, " . $keyboard->getName() . "\n";
    }
}
/**
 *
 */
class Computer
{
    protected $_items = [];
    public function add(Unit $unit)
    {
        $this->_items[] = $unit;
    }
    /**
     * 调用各个组件的accept方法
     */
    public function accept(Visitor $visitor)
    {
        foreach ($this->_items as $item) {
            $item->accept($visitor);
        }
    }
}
$computer = new Computer();
$computer->add(new Cpu());
$computer->add(new Memory());
$computer->add(new Keyboard());
$printVisitor = new PrintVisitor();
$computer->accept($printVisitor);
开发者ID:EdenChan,项目名称:Instances,代码行数:31,代码来源:visitor.php

示例14: prepareTaskWithNewComputer

 /**
  * @test
  */
 public function prepareTaskWithNewComputer()
 {
     global $DB;
     // Verify add new agent when have new computer (dynamic group) in deploy task
     $DB->connect();
     $computer = new Computer();
     $pfAgent = new PluginFusioninventoryAgent();
     $input = array('entities_id' => 0, 'name' => 'computer4');
     $computers_id = $computer->add($input);
     $input = array('entities_id' => 0, 'name' => 'computer4', 'version' => '{"INVENTORY":"v2.3.11"}', 'device_id' => 'computer4', 'useragent' => 'FusionInventory-Agent_v2.3.11', 'computers_id' => $computers_id);
     $pfAgent->add($input);
     PluginFusioninventoryTask::cronTaskscheduler();
     $pfTask = new PluginFusioninventoryTask();
     $data = $pfTask->getJoblogs(array(1));
     $ref = array(1 => 'portdavid', 2 => 'computer2', 3 => 'computer3', 4 => 'computer4');
     $this->assertEquals($ref, $data['agents']);
 }
开发者ID:C-Duv,项目名称:fusioninventory-for-glpi,代码行数:20,代码来源:CronTaskTest.php

示例15: import

 /**
  * Function to import discovered device
  *
  * @param $items_id id of the device to import
  *
  * @return nothing
  *
  **/
 function import($items_id, $Import = 0, $NoImport = 0)
 {
     global $DB;
     $NetworkPort = new NetworkPort();
     $a_NetworkPorts = $NetworkPort->find("`items_id` = '" . $items_id . "'\n                      AND `itemtype` = 'PluginFusioninventoryUnmanaged'");
     $this->getFromDB($items_id);
     $this->fields = Toolbox::addslashes_deep($this->fields);
     $data = array();
     switch ($this->fields['item_type']) {
         case 'Printer':
             $Printer = new Printer();
             $data["entities_id"] = $this->fields["entities_id"];
             if (!empty($this->fields["name"])) {
                 $data["name"] = $this->fields["name"];
             }
             $data["locations_id"] = $this->fields["locations_id"];
             $data["serial"] = $this->fields["serial"];
             $data["otherserial"] = $this->fields["otherserial"];
             $data["contact"] = $this->fields["contact"];
             $data["domain"] = $this->fields["domain"];
             $data["comment"] = $this->fields["comment"];
             $data["is_dynamic"] = 1;
             $printer_id = $Printer->add($data);
             foreach ($a_NetworkPorts as $data_Port) {
                 $data_Port['items_id'] = $printer_id;
                 $data_Port['itemtype'] = $Printer->getType();
                 $NetworkPort->update($data_Port);
             }
             // Import SNMP
             $pfPrinter = new PluginFusioninventoryPrinter();
             $_SESSION['glpi_plugins_fusinvsnmp_table'] = "glpi_plugin_fusioninventory_printers";
             $query = "SELECT *\n                      FROM `glpi_plugin_fusioninventory_printers`\n                      WHERE `printers_id`='" . $printer_id . "' ";
             $result = $DB->query($query);
             $data = array();
             if ($DB->numrows($result) > 0) {
                 $data = $DB->fetch_assoc($result);
             }
             $data['sysdescr'] = $this->fields['sysdescr'];
             $data['plugin_fusioninventory_configsecurities_id'] = $this->fields['plugin_fusioninventory_configsecurities_id'];
             if ($DB->numrows($result) == 0) {
                 $data['printers_id'] = $printer_id;
                 $pfPrinter->add($data);
             } else {
                 $pfPrinter->update($data);
             }
             $this->deleteFromDB($items_id, 1);
             $Import++;
             break;
         case 'NetworkEquipment':
             $NetworkEquipment = new NetworkEquipment();
             $data["entities_id"] = $this->fields["entities_id"];
             if (!empty($this->fields["name"])) {
                 $data["name"] = $this->fields["name"];
             }
             $data["locations_id"] = $this->fields["locations_id"];
             $data["serial"] = $this->fields["serial"];
             $data["otherserial"] = $this->fields["otherserial"];
             $data["contact"] = $this->fields["contact"];
             $data["domain"] = $this->fields["domain"];
             $data["comment"] = $this->fields["comment"];
             $data["is_dynamic"] = 1;
             //            $data_Port = current($a_NetworkPorts);
             //            $data["ip"] = $data_Port["ip"];
             //            $data["mac"] = $data_Port["mac"];
             $NetworkEquipment_id = $NetworkEquipment->add($data);
             foreach ($a_NetworkPorts as $data_Port) {
                 $data_Port['items_id'] = $NetworkEquipment_id;
                 $data_Port['itemtype'] = $NetworkEquipment->getType();
                 $NetworkPort->update($data_Port);
             }
             $pfNetworkEquipment = new PluginFusioninventoryNetworkEquipment();
             $_SESSION['glpi_plugins_fusinvsnmp_table'] = "glpi_plugin_fusioninventory_networkequipments";
             $query = "SELECT *\n                      FROM `glpi_plugin_fusioninventory_networkequipments`\n                      WHERE `networkequipments_id`='" . $NetworkEquipment_id . "' ";
             $result = $DB->query($query);
             $data = array();
             if ($DB->numrows($result) > 0) {
                 $data = $DB->fetch_assoc($result);
             }
             $data['sysdescr'] = $this->fields['sysdescr'];
             $data['plugin_fusioninventory_configsecurities_id'] = $this->fields['plugin_fusioninventory_configsecurities_id'];
             if ($DB->numrows($result) == 0) {
                 $data['networkequipments_id'] = $NetworkEquipment_id;
                 $pfNetworkEquipment->add($data);
             } else {
                 $pfNetworkEquipment->update($data);
             }
             $this->deleteFromDB($items_id, 1);
             $Import++;
             break;
         case 'Peripheral':
             $Peripheral = new Peripheral();
             $data["entities_id"] = $this->fields["entities_id"];
//.........这里部分代码省略.........
开发者ID:korial29,项目名称:fusioninventory-for-glpi,代码行数:101,代码来源:unmanaged.class.php


注:本文中的Computer::add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。