Exemplo n.º 1
0
 /**
  * 
  * Building Frontend create conntroler 
  */
 public function action_create()
 {
     $val = \Validation::forge();
     $val->add_field('id', 'node id', 'required|min_length[1]|max_length[20]');
     $val->add_field('position', 'node position', 'required|min_length[1]|max_length[20]');
     $val->add_field('title', 'node title', 'required|min_length[1]|max_length[20]');
     $val->add_field('type', 'node type', 'required|min_length[1]|max_length[20]');
     if ($val->run()) {
         //new building add
         if ($val->validated('type') == 'building') {
             $props = array('name' => $val->validated('title'), 'meta_update_time' => time(), 'meta_update_user' => $this->user);
             $new = new Model_Building($props);
         }
         //new floor add
         if ($val->validated('type') == 'floor') {
             $props = array('name' => $val->validated('title'), 'building' => $val->validated('id'), 'meta_update_time' => time(), 'meta_update_user' => $this->user);
             $new = new Model_Floor($props);
         }
         //new room add
         if ($val->validated('type') == 'room') {
             $props = array('name' => $val->validated('title'), 'floor' => $val->validated('id'), 'meta_update_time' => time(), 'meta_update_user' => $this->user);
             $new = new Model_Room($props);
         }
         $status = $new->save();
         $a = array("id" => $val->validated('type') . '_' . $new->id, "status" => $status);
         echo json_encode($a);
     }
 }
Exemplo n.º 2
0
 protected function newuserdata($user)
 {
     //add new building
     $props = array('name' => 'Building DEMO', 'meta_update_time' => time(), 'meta_update_user' => $user);
     $building = new Model_Building($props);
     $building->save();
     //add defualt floor
     $props = array('name' => 'Floor 1', 'building' => $building->id, 'meta_update_time' => time(), 'meta_update_user' => $user);
     $floor = new Model_Floor($props);
     $floor->save();
     //add default room
     $props = array('name' => 'Room A', 'floor' => $floor->id, 'meta_update_time' => time(), 'meta_update_user' => $user);
     $room = new Model_Room($props);
     $room->save();
     //add default room
     $props = array('name' => 'Default rack', 'room' => $room->id, 'room_pos' => 0, 'hidden_rack' => 0, 'size' => 48, 'numbering_direction' => 0, 'meta_default_data' => 0, 'meta_update_time' => time(), 'meta_update_user' => $user);
     $rack = new Model_Rack($props);
     $rack->save();
     //$switch=$this->add_switch($rack,$user,2,'c1-switch-windows');
     $switch = $this->add_switch($rack, $user, 48, 'c1-switch-linux');
     $pdu = $this->add_pdu($rack, $user);
     for ($i = 10; $i <= 47; $i++) {
         $this->add_server($i, $rack, $user, $switch['id'], $switch['macs'], $pdu);
     }
     //monitoring
     $qmonitor = array('iconw' => 1, 'iconc' => 1, 'iconu' => 1, 'osdw' => 1, 'osdu' => 1, 'osdc' => 1, 'soundw' => 1, 'soundu' => 1, 'soundc' => 1, 'meta_update_user' => $user);
     $monitor = new Model_Monitoring_Data($qmonitor);
     $monitor->save();
     $q = array('typeID' => 1, 'user' => 'guest', 'pass' => 'guest', 'content' => 'https://nagios.demo.netways.de/nagios/cgi-bin/status.cgi', 'meta_update_time' => time(), 'meta_update_user' => $user);
     $source = new Model_Monitoring_Source($q);
     $source->save();
     /*
      //server
     
     //cables
     DB::query("INSERT INTO `cables` (`id`, `dev1`, `port1`, `name1`, `dev2`, `port2`, `name2`, `type`, `meta_update_time`, `meta_update_user`) VALUES
     		('', 1, 1, 1, 2, 1, 1, 1, 1337743207, 2),
     		('', 1, 2, 2, 2, 2, 2, 1, 1337743221, 2);")->execute();
     
     //device_fieldset
     DB::query("INSERT INTO `device_fieldset` (`id`, `name`, `type`, `deviceID`, `tab`, `value`, `static`) VALUES
     		('', 'Manufacturer', 'input', 1, 1, NULL, 1),
     		('', 'Model', 'input', 1, 1, NULL, 1),
     		('', 'Admin url', 'input', 1, 2, NULL, 1),
     		('', 'Ports', 'network', 1, 2, NULL, 1),
     		('', 'Images', 'img', 1, 3, NULL, 0),
     		('', 'Export to pdf', 'print', 1, 3, NULL, 0),
     		('', 'Manufacturer', 'input', 2, 1, NULL, 1),
     		('', 'Model', 'input', 2, 1, NULL, 1),
     		('', 'Admin url', 'input', 2, 2, NULL, 1),
     		('', 'Ports', 'network', 2, 2, NULL, 1),
     		('', 'Images', 'img', 2, 3, NULL, 0),
     		('', 'Export to pdf', 'print', 2, 3, NULL, 0);")->execute();
     
     //device network
     DB::query("INSERT INTO `device_network` (`id`, `fieldsetID`, `deviceID`, `nics`, `vports`, `ports`, `uplinks`, `config_data`, `type`) VALUES
     		('', 4, 1, 2, 0, 0, 0, '', 1),
     		('', 10, 2, 0, 0, 24, 0, '', 2);")->execute();
     
     DB::query("INSERT INTO `network_ip_ports` (`id`, `networkID`, `nic_name`, `ipv4`, `ipv6`, `conn_type`, `conn_speed`, `type`) VALUES
     		('', 1, '', '', '', 1, 1, 1),
     		('', 1, '', '', '', 1, 3, 1);")->execute();
     
     DB::query("INSERT INTO `network_mac_ports` (`id`, `networkID`, `mac_address`, `conn_device`, `vlan`, `type`) VALUES
     		('', 2, '', 0, 0, 1),
     		('', 2, '', 0, 0, 1),
     		('', 2, '', 0, 0, 1),
     		('', 2, '', 0, 0, 1),
     		('', 2, '', 0, 0, 1),
     		('', 2, '', 0, 0, 1),
     		('', 2, '', 0, 0, 1),
     		('', 2, '', 0, 0, 1),
     		('', 2, '', 0, 0, 1),
     		('', 2, '', 0, 0, 1),
     		('', 2, '', 0, 0, 1),
     		('', 2, '', 0, 0, 1),
     		('', 2, '', 0, 0, 1),
     		('', 2, '', 0, 0, 1),
     		('', 2, '', 0, 0, 1),
     		('', 2, '', 0, 0, 1),
     		('', 2, '', 0, 0, 1),
     		('', 2, '', 0, 0, 1),
     		('', 2, '', 0, 0, 1),
     		('', 2, '', 0, 0, 1),
     		('', 2, '', 0, 0, 1),
     		('', 2, '', 0, 0, 1),
     		('', 2, '', 0, 0, 1),
     		('', 2, '', 0, 0, 1);")->execute();
     */
 }