Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 1835

Přidáno uživatelem Ondřej Fibich před více než 11 roky(ů)

Novinky:
- #465: optimalizace reloadu DHCP zaznamu

Zobrazit rozdíly:

freenetis/branches/1.1/db_upgrades/upgrade_1.1.0~alpha9.php
<?php defined('SYSPATH') or die('No direct script access.');
/*
* This file is part of open source system FreenetIS
* and it is released under GPLv3 licence.
*
* More info about licence can be found:
* http://www.gnu.org/licenses/gpl-3.0.html
*
* More info about project can be found:
* http://www.freenetis.org/
*
*/
/**
* This upgrade is not equal to any of previos upgrades
*
* @author Ondřej Fibich <ondrej.fibich@gmail.com>
*/
$upgrade_equal_to['1.1.0~alpha9'] = array();
/**
* Optimalization of reload of DHCP (#465)
*
* @author Ondřej Fibich <ondrej.fibich@gmail.com>
*/
$upgrade_sql['1.1.0~alpha9'] = array
(
/** Indicator of expired subnet (DHCP must reload) (#465) */
"ALTER TABLE `subnets` ADD `dhcp_expired` TINYINT( 1 ) NOT NULL DEFAULT '0'
COMMENT 'If DHCP is enabled on this subnet, this value indicates if any of its record was updated and not synchronized to DHCP server.'
AFTER `dhcp`",
// all DHCP expire
"UPDATE subnets SET dhcp_expired = 1 WHERE dhcp = 1",
);
freenetis/branches/1.1/application/models/subnet.php
* @property string $netmask
* @property integer $redirect
* @property integer $dhcp
* @property boolean $dhcp_expired
* @property Subnets_owner_Model $subnets_owner
* @property ORM_Iterator $clouds
* @property ORM_Iterator $ip_addresses
......
protected $has_and_belongs_to_many = array('clouds');
/**
* Sets subnets as (not) expired.
*
* @param array|int $subnets Multiple subnet IDs or a single subnet ID
* @param int $flag expired (1) or not (0) [optional]
*/
public function set_expired_subnets($subnets, $flag = 1)
{
if (!is_array($subnets))
{
$subnets = array($subnets);
}
if (count($subnets))
{
$this->db->query("
UPDATE subnets s
SET dhcp_expired = ?
WHERE s.dhcp > 0 AND s.id IN (?)
", $flag, implode(',', array_map('intval', $subnets)));
}
}
/**
* Check if the MAC address is unique in the subnet.
*
* @param string $mac MAC address
freenetis/branches/1.1/application/controllers/ifaces.php
}
$iface->save_throwable();
// expired subnets (#465)
$expired_subnets = array();
foreach ($iface->ip_addresses as $ip)
{
$expired_subnets[] = $ip->subnet_id;
}
ORM::factory('subnet')->set_expired_subnets($expired_subnets);
$iface->transaction_commit();
freenetis/branches/1.1/application/controllers/subnets.php
$subnet_model->OSPF_area_id = $form_data['OSPF_area_id'];
$subnet_model->dhcp = $form_data['dhcp'];
$subnet_model->qos = $form_data['qos'];
if ($subnet_model->dhcp)
{
$subnet_model->dhcp_expired = 1;
}
// redirect
if ($this->acl_check_new('Devices_Controller', 'redirect'))
......
$subnet_model->netmask = $form_data['netmask'];
$subnet_model->OSPF_area_id = $form_data['OSPF_area_id'];
$subnet_model->dhcp = $form_data['dhcp'];
$subnet_model->dhcp_expired = 1;
$subnet_model->qos = $form_data['qos'];
if ($this->acl_check_edit('Devices_Controller', 'redirect'))
{
$subnet_model->redirect = $form_data['redirect'];
freenetis/branches/1.1/application/controllers/ip_addresses.php
try // try to make DB transction
{
$ip_address->transaction_start();
$ip_address->delete_ip_address_with_member($form_data['ip_address']);
$ip_address->iface_id = $form_data['iface_id'];
$ip_address->ip_address = $form_data['ip_address'];
$ip_address->subnet_id = $form_data['subnet_id'];
......
$ip_address->whitelisted = Ip_address_Model::NO_WHITELIST;
$ip_address->member_id = NULL;
$ip_address->save_throwable();
// expired subnets (#465)
ORM::factory('subnet')->set_expired_subnets($ip_address->subnet_id);
$ip_address->transaction_commit();
try
{
Allowed_subnets_Controller::update_enabled(
$ip_address->iface->device->user->member->id, array($ip_address->subnet_id)
$ip_address->iface->device->user->member->id,
array($ip_address->subnet_id)
);
}
catch (Exception $e)
......
if (++$transaction_attempt_counter >= $max_attempts) // this was last attempt?
{
Log::add_exception($e);
status::error('Error - cant add ip address.');
status::error('Error - cant add ip address.' . $e->getMessage());
$this->redirect($linkback);
}
......
$ip_address->save_throwable();
// expired subnets (#465)
ORM::factory('subnet')->set_expired_subnets($ip_address->subnet_id);
$ip_address->transaction_commit();
$member_id = $device->user->member_id;
......
{
$ip_address->transaction_start();
// expired subnets (#465)
ORM::factory('subnet')->set_expired_subnets($ip_address->subnet_id);
if ($ip_address->subnet->subnets_owner->id)
{
$ip_address->member_id = $ip_address->subnet->subnets_owner->member->id;
......
$ip_address->save_throwable();
}
else
{
$ip_address->delete_throwable();
}
$ip_address->transaction_commit();
freenetis/branches/1.1/application/controllers/export.php
$view->render(TRUE);
}
/*
/**
* Function returns organization logo for export
*
* @author David Raska
freenetis/branches/1.1/application/controllers/devices.php
$dm = new Device_Model();
$update_allowed_params = array();
$expired_subnets = array(); // #465
// gets number of maximum of acceptable repeating of operation
// after reaching of deadlock and time of waiting between
......
$ipm->service = ($_POST['service'][$i] == 1);
$ipm->save_throwable();
// expired subnet
$expired_subnets[] = $ipm->subnet_id;
// allowed subnet to added IP
$update_allowed_params[] = array
(
......
$cr_model->member->save_throwable();
}
}
// expired subnets (#465)
ORM::factory('subnet')->set_expired_subnets($expired_subnets);
// connection request - notice /////////////////////////////////
......
{
status::warning('Error - cannot update allowed subnets of member.');
}
// expired subnets (#465)
ORM::factory('subnet')->set_expired_subnets($subnets);
// redirect
status::success('Device has been successfully deleted.');
freenetis/branches/1.1/version.php
* The current version of FreenetIS.
* This value must be changed by developers in a new release of FreenetIS.
*/
define('FREENETIS_VERSION', '1.1.0~alpha8');
define('FREENETIS_VERSION', '1.1.0~alpha9');

Také k dispozici: Unified diff