diff --git a/interface/lib/plugins/vm_openvz_plugin.inc.php b/interface/lib/plugins/vm_openvz_plugin.inc.php index 1112e081c719fda1f38fffb09da8a8f66a4173f2..a926c0af294570cc7fb1c3bbd6ca7d30cf4371fe 100644 --- a/interface/lib/plugins/vm_openvz_plugin.inc.php +++ b/interface/lib/plugins/vm_openvz_plugin.inc.php @@ -23,6 +23,7 @@ class vm_openvz_plugin { //* Register for events $app->plugin->registerEvent('vm:openvz_vm:on_after_insert','vm_openvz_plugin','openvz_vm_insert'); $app->plugin->registerEvent('vm:openvz_vm:on_after_update','vm_openvz_plugin','openvz_vm_update'); + $app->plugin->registerEvent('vm:openvz_vm:on_after_delete','vm_openvz_plugin','openvz_vm_delete'); } /* @@ -105,6 +106,16 @@ class vm_openvz_plugin { } + function openvz_vm_delete($event_name, $page_form) { + global $app, $conf; + + //* Free the IP address + $tmp = $app->db->queryOneRecord("SELECT ip_address_id FROM openvz_ip WHERE vm_id = ".$page_form->id); + $app->db->datalogUpdate('openvz_ip', 'vm_id = 0', 'ip_address_id', $tmp['ip_address_id']); + unset($tmp); + + } + private function applyTemplate() { global $app, $conf; diff --git a/interface/web/vm/openvz_vm_del.php b/interface/web/vm/openvz_vm_del.php index 8d288444b6c6436ac05ab2e73b8d8c8923d4f447..c8d8e196af6032dd1150643fba8a07d5e2c36a55 100644 --- a/interface/web/vm/openvz_vm_del.php +++ b/interface/web/vm/openvz_vm_del.php @@ -49,14 +49,6 @@ $app->uses('tpl,tform'); $app->load('tform_actions'); class page_action extends tform_actions { - - function onAfterDelete() { - global $app, $conf; - - //* Release all IP addresses which are assigned to this VM - $app->db->query("UPDATE openvz_ip SET vm_id = 0 WHERE vm_id = '".$this->id."'"); - - } } diff --git a/server/plugins-available/openvz_plugin.inc.php b/server/plugins-available/openvz_plugin.inc.php index a0907ff8653733eff285e343862caab0750ebe4b..e14c0c4c9472ab04afb5b49d8c3820d1a99598eb 100644 --- a/server/plugins-available/openvz_plugin.inc.php +++ b/server/plugins-available/openvz_plugin.inc.php @@ -1,7 +1,7 @@