Beispiel #1
0
 public function save($cascade = null, $use_transtation = false)
 {
     parent::save();
     if ($this->get('type') == 'hdd') {
         if (!$this->get('hdd')) {
             $props = array('fieldsetID' => $this->get('id'), 'raid_type' => 1, 'size' => 0, 'meta_update_time' => time(), 'meta_update_user' => 0, 'total' => 0);
             $raid = new Model_Raid($props);
             $raid->save();
         }
     }
     if ($this->get('type') == 'ram') {
         if (!$this->get('ram')) {
             $props = array('fieldsetID' => $this->get('id'), 'ram_type' => 1, 'size' => 0, 'total' => 0, 'meta_update_time' => time(), 'meta_update_user' => 0);
             $ram = new Model_Ram($props);
             $ram->save();
         }
     }
     if ($this->get('type') == 'network') {
         if (!$this->get('network')) {
             $dev = $this->get('device');
             $prop = array('fieldsetID' => $this->get('id'), 'deviceID' => $dev->id, 'nics' => 0, 'vports' => 0, 'ports' => 0, 'uplinks' => 0, 'config_data' => '', 'type' => $this->setTypeOfDevice($dev));
             $network = new Model_Device_Network($prop);
             $network->save();
         }
     }
     if ($this->get('type') == 'power_out') {
         if (!$this->get('power')) {
             $dev = $this->get('device');
             $prop = array('fieldsetID' => $this->get('id'), 'deviceID' => $dev->id, 'current' => 10, 'input' => 1, 'output' => 1, 'ru' => 1, 'pos' => 0, 'type' => 0);
             $power = new Model_Device_Power($prop);
             $power->save();
             //input socket
             $prop = array('powerID' => $power->id, 'conn_type' => 1, 'type' => 1);
             $socket = new Model_Device_Power_Socket($prop);
             $socket->save();
             //output socket
             $prop = array('powerID' => $power->id, 'conn_type' => 1, 'type' => 2);
             $socket = new Model_Device_Power_Socket($prop);
             $socket->save();
         }
     }
     if ($this->get('type') == 'power_in') {
         if (!$this->get('power')) {
             $dev = $this->get('device');
             $prop = array('fieldsetID' => $this->get('id'), 'deviceID' => $dev->id, 'current' => 0, 'input' => 1, 'output' => 0, 'ru' => 0, 'pos' => 0, 'type' => 0);
             $power = new Model_Device_Power($prop);
             $power->save();
             //input power
             $prop = array('powerID' => $power->id, 'conn_type' => 1, 'type' => 1);
             $socket = new Model_Device_Power_Socket($prop);
             $socket->save();
         }
     }
     if ($this->get('type') == 'kvm_in') {
         if (!$this->get('kvm')) {
             $dev = $this->get('device');
             $prop = array('fieldsetID' => $this->get('id'), 'deviceID' => $dev->id, 'input' => 1, 'output' => 0, 'type' => 0);
             $kvm = new Model_Device_Kvm($prop);
             $kvm->save();
             //input power
             $prop = array('kvmID' => $kvm->id, 'conn_type' => 1, 'type' => 1);
             $socket = new Model_Device_Kvm_Socket($prop);
             $socket->save();
         }
     }
     if ($this->get('type') == 'kvm_out') {
         if (!$this->get('kvm')) {
             $dev = $this->get('device');
             $prop = array('fieldsetID' => $this->get('id'), 'deviceID' => $dev->id, 'input' => 1, 'output' => 1, 'type' => 0);
             $kvm = new Model_Device_Kvm($prop);
             $kvm->save();
             //input kvm
             $prop = array('kvmID' => $kvm->id, 'conn_type' => 1, 'type' => 2);
             $socket = new Model_Device_Kvm_Socket($prop);
             $socket->save();
             //output kvm
             $prop = array('kvmID' => $kvm->id, 'conn_type' => 1, 'type' => 1);
             $socket = new Model_Device_Kvm_Socket($prop);
             $socket->save();
         }
     }
 }