public function action_index() { $out = array('status' => 'ok', 'data' => array()); \Fuel\Core\Module::load('basic'); if ($_POST) { $val = \Validation::forge(); $val->add_field('eid', 'vps id', 'max_length[20]'); $val->add_field('val', 'ip address', 'required|min_length[1]|max_length[20]'); if ($val->run()) { $v = $val->validated('eid'); $ip = $val->validated('val'); $vps = \Basic\Model_Vps::find($v); foreach ($vps->device->network as $net) { //nope } if ($vps) { $i = \Basic\Model_Network_Ip::query()->where('ipv4', $ip)->get_one(); $ipv4 = new \Ipm\Ipv4object($ip); if (!$i) { $prop = array('networkID' => $net->id, 'nic_name' => '', 'ipv4' => $ip, 'ipv6' => '', 'conn_type' => 0, 'conn_speed' => 0, 'type' => 3, 'addrint' => $ipv4->toInt()); $netip = new \Basic\Model_Network_Ip($prop); $netip->save(); $vprop = array('vpsID' => $vps->id, 'portID' => $netip->id, 'type' => 1); $port = new \Basic\Model_Vps_Ports($vprop); $port->save(); $out['data'] = array('id' => $port->id, 'val' => $ip, 'vps' => $vps->id); $out['status'] = 'ok'; } } } } echo json_encode($out); }
private function parse_vps_address() { \Fuel\Core\Module::load('basic', APPPATH . 'modules/basic/'); \Fuel\Core\Module::load('ipm', APPPATH . 'modules/ipm/'); //select * ip from database $ips = \Basic\Model_Vps_Ip::find('all'); foreach ($ips as $ip) { $vps = \Basic\Model_Vps::find($ip->vpsID); $networks = $vps->device->network; foreach ($networks as $net) { } //print_r($net); $ipob = (object) array('ipv4' => $ip->data); if ($ip->data != '') { $ip_int = $this->___IPv4_dotquadA_to_intA($ipob); $ipvps = \Basic\Model_Network_Ip::find()->where('type', 3)->where('networkID', $net->id)->where('addrint', $ip_int)->get_one(); if (!$ipvps) { //make new ipv4 input with type 3 $prop = array('networkID' => $net->id, 'nic_name' => 'vps', 'ipv4' => $ip->data, 'ipv6' => '', 'conn_type' => 0, 'conn_speed' => 0, 'type' => 3, 'addrint' => $ip_int); $ipv4 = new \Basic\Model_Network_Ip($prop); $ipv4->save(); $vprop = array('vpsID' => $vps->id, 'portID' => $ipv4->id, 'type' => 1); //make link between vps and port $vport = new \Ipm\Model_Vps_Ports($vprop); $vport->save(); //detect new subnet and make/update location $subnet = $this->updateSubnet($ipv4); $this->update_location($subnet, $ipv4); $this->update_history($ipv4); } } } //check if subnet exist // }
public function action_index() { if ($_POST) { $val = \Validation::forge(); $val->add_field('room', 'Room id', 'required|min_length[1]|max_length[20]'); if ($val->run()) { \Fuel\Core\Module::load('basic'); $room = \Basic\Model_Room::find($val->validated('room')); if ($room) { $query = \DB::query('select distinct cables.id from cables, rack, device where rack.room=' . $room->id . ' and device.rack=rack.id and (device.id=cables.dev1 or device.id=cables.dev2)'); $cables = $query->as_object()->execute(); $cabledata = array(); foreach ($cables as $c) { $cab = \Basic\Model_Cable::find($c->id); $dev1 = \Basic\Model_Device::find($cab->dev1); $dev2 = \Basic\Model_Device::find($cab->dev2); array_push($cabledata, array('id' => $cab->id, 'dev1' => $cab->dev1, 'port1' => $cab->port1, 'dev2' => $cab->dev2, 'port2' => $cab->port2, 'name1' => $cab->name1, 'name2' => $cab->name2, 'type' => $cab->type, 'hostname1' => $dev1->hostname, 'hostname2' => $dev2->hostname)); } $data['cabledata'] = $cabledata; $data['room'] = $room; return \Response::forge(\View::forge('rack', $data)); } } } }
public function before() { parent::before(); $this->_module_Check(2); \Fuel\Core\Package::load('cacti'); \Fuel\Core\Package::load('munin'); \Fuel\Core\Module::load('basic'); }
public function before() { parent::before(); \Fuel\Core\Module::load('basic'); if ($_POST) { $val = \Validation::forge(); $val->add_field('id', 'subnet id', 'required|min_length[1]|max_length[20]'); if ($val->run()) { $this->id = $val->validated('id'); } } }
public function action_index() { \Fuel\Core\Module::load('basic'); $val = \Validation::forge(); $val->add_field('cat', 'Category', 'required|min_length[1]|max_length[20]'); $id = \Input::post('id'); $data = array('data' => array(), 'group' => array(), 'test' => array(), 'record' => array()); if ($val->run()) { switch ($val->validated('cat')) { case 'group': // get groups $group = \Debugger\Model_Group::find($id); $group_data = array('id' => $group->id, 'name' => $group->name, 'description' => $group->description, 'tests' => array()); array_push($data['group'], $group_data); break; case 'test': // get tests $test = \Debugger\Model_Test::find($id); $test_data = array('id' => $test->id, 'name' => $test->name, 'description' => $test->description, 'group_id' => $test->group_id, 'priority' => $test->priority, 'records' => array()); array_push($data['test'], $test_data); break; case 'record': // get records $records = \Debugger\Model_Record::find($id); $record_data = array('id' => $record->id, 'type' => $record->type, 'object' => $record->object, 'action' => $record->action, 'test_id' => $record->test_id); array_push($data['record'], $record_data); break; case 'all': // get groups $groups = \Debugger\Model_Group::find()->get(); foreach ($groups as $group) { $group_data = array('id' => $group->id, 'name' => $group->name, 'description' => $group->description, 'tests' => array()); // get tests $tests = \Debugger\Model_Test::find()->where('group_id', $group->id)->get(); foreach ($tests as $test) { $test_data = array('id' => $test->id, 'name' => $test->name, 'description' => $test->description, 'priority' => $test->priority, 'group_id' => $test->group_id, 'records' => array()); // get records $records = \Debugger\Model_Record::find()->where('test_id', $test->id)->get(); foreach ($records as $record) { array_push($test_data['records'], array('id' => $record->id, 'type' => $record->type, 'object' => $record->object, 'action' => $record->action, 'test_id' => $record->test_id)); } array_push($group_data['tests'], $test_data); } array_push($data['data'], $group_data); } break; } } echo json_encode($data); }
private function updateIpv4() { \Fuel\Core\Module::load('basic', APPPATH . 'modules/basic/'); \Fuel\Core\Module::load('ipm', APPPATH . 'modules/ipm/'); //select * ip from database $ips = \Basic\Model_Network_Ip::find('all'); foreach ($ips as $ip) { if ($ip->ipv4 != '') { $subnet = $this->updateSubnet($ip); $this->update_location($subnet, $ip); $this->update_history($ip); } } //check if subnet exist // }
public function shared($model, $function) { $manifest = new \Manifestreader(); $modules = $manifest->getDataKey('modules'); foreach ($modules as $modul) { $method_name = str_replace('Model_', '', get_class($model)); $method = explode('\\', $method_name); $module_method = array_pop($method); $module_observer = '\\' . ucfirst($modul) . '\\Observer::' . $module_method; $module_class = '\\' . ucfirst($modul) . '\\Observer'; $loaded = \Fuel\Core\Module::loaded($modul); if (!$loaded) { \Fuel\Core\Module::load($modul); } if (class_exists($module_class)) { if (method_exists($module_class, $module_method)) { call_user_func($module_observer, $model, $function); } } } }
public function before() { \Fuel\Core\Module::load('basic'); \Fuel\Core\Package::load('cacti'); }
public function before() { parent::before(); \Fuel\Core\Module::load('basic'); }