mirror of
https://github.com/mclueppers/xo-server.git
synced 2025-04-08 20:55:02 +02:00
Various updates.
This commit is contained in:
parent
dd4a40ccab
commit
e3519f571e
@ -1,40 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is a part of Xen Orchestra Server.
|
||||
*
|
||||
* Xen Orchestra Server is free software: you can redistribute it
|
||||
* and/or modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* Xen Orchestra Server is distributed in the hope that it will be
|
||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Xen Orchestra Server. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Julien Fontanet <julien.fontanet@vates.fr>
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0-standalone.html GPLv3
|
||||
*
|
||||
* @package Xen Orchestra Server
|
||||
*/
|
||||
|
||||
return array(
|
||||
|
||||
'database' => array(
|
||||
'type' => 'json',
|
||||
'file' => '#{root_dir}/database.json',
|
||||
),
|
||||
|
||||
'listen' => array(
|
||||
'tcp://0.0.0.0:1024',
|
||||
),
|
||||
|
||||
'log' => array(
|
||||
//'email' => 'your.email@example.net',
|
||||
'file' => '#{root_dir}/log',
|
||||
),
|
||||
);
|
@ -1,80 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is a part of Xen Orchestra Server.
|
||||
*
|
||||
* Xen Orchestra Server is free software: you can redistribute it
|
||||
* and/or modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* Xen Orchestra Server is distributed in the hope that it will be
|
||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Xen Orchestra Server. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Julien Fontanet <julien.fontanet@vates.fr>
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0-standalone.html GPLv3
|
||||
*
|
||||
* @package Xen Orchestra Server
|
||||
*
|
||||
* Local Variables:
|
||||
* mode: php
|
||||
* End:
|
||||
*/
|
||||
|
||||
/* Local settings
|
||||
*
|
||||
* This file contains all settings related to this current
|
||||
* installation of Xen Orchestra Server.
|
||||
*
|
||||
* You MUST define the following settings for which no default
|
||||
* values exists.
|
||||
*
|
||||
* But, you MAY override any settings which already exists in
|
||||
* “global.php”.
|
||||
*/
|
||||
return array(
|
||||
|
||||
'listen' => array(
|
||||
|
||||
/* For security concerns, only local connections are accepted
|
||||
* by default.
|
||||
*
|
||||
* Uncomment the following entry to accept external connections.
|
||||
*/
|
||||
//'tcp://0.0.0.0:1024',
|
||||
|
||||
),
|
||||
|
||||
// For now, Xen servers/pool masters must be defined in this file.
|
||||
'xen' => array(
|
||||
|
||||
/* You MUST configure the following entries to connect XO-Server to your
|
||||
* Xen pool.
|
||||
*/
|
||||
array(
|
||||
// URL of the Xen API interface.
|
||||
'url' => 'https://xen1.example.net',
|
||||
|
||||
// Name of the user which will be used to connect.
|
||||
'username' => 'username',
|
||||
|
||||
// Uer password used for authentication.
|
||||
'password' => 'password'
|
||||
),
|
||||
|
||||
/* You may configure as many pools/servers as you want.
|
||||
*
|
||||
* Uncomment this entry to add a second one.
|
||||
*/
|
||||
// array(
|
||||
// 'url' => 'https://xen2.example.net',
|
||||
// 'username' => 'username',
|
||||
// 'password' => 'password'
|
||||
// ),
|
||||
),
|
||||
);
|
1494
lib/Application.php
1494
lib/Application.php
File diff suppressed because it is too large
Load Diff
51
lib/Base.php
51
lib/Base.php
@ -1,51 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is a part of Xen Orchestra Server.
|
||||
*
|
||||
* Xen Orchestra Server is free software: you can redistribute it
|
||||
* and/or modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* Xen Orchestra Server is distributed in the hope that it will be
|
||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Xen Orchestra Server. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Julien Fontanet <julien.fontanet@vates.fr>
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0-standalone.html GPLv3
|
||||
*
|
||||
* @package Xen Orchestra Server
|
||||
*/
|
||||
|
||||
/**
|
||||
* Ultimate base class.
|
||||
*/
|
||||
abstract class Base
|
||||
{
|
||||
function __destruct()
|
||||
{}
|
||||
|
||||
function __get($name)
|
||||
{
|
||||
trigger_error(
|
||||
'no such readable property '.get_class($this).'->'.$name,
|
||||
E_USER_ERROR
|
||||
);
|
||||
}
|
||||
|
||||
function __set($name, $value)
|
||||
{
|
||||
trigger_error(
|
||||
'no such writable property '.get_class($this).'->'.$name,
|
||||
E_USER_ERROR
|
||||
);
|
||||
}
|
||||
|
||||
protected function __construct()
|
||||
{}
|
||||
}
|
@ -1,99 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is a part of Xen Orchestra Server.
|
||||
*
|
||||
* Xen Orchestra Server is free software: you can redistribute it
|
||||
* and/or modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* Xen Orchestra Server is distributed in the hope that it will be
|
||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Xen Orchestra Server. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Julien Fontanet <julien.fontanet@vates.fr>
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0-standalone.html GPLv3
|
||||
*
|
||||
* @package Xen Orchestra Server
|
||||
*/
|
||||
|
||||
namespace Bean;
|
||||
|
||||
/**
|
||||
* @todo Migrate check() and checkAndSet() to \Rekodi\Bean.
|
||||
*/
|
||||
abstract class BeanAbstract extends \Rekodi\Bean
|
||||
{
|
||||
/**
|
||||
* This function is not necessary but allow us to dynamically
|
||||
* initialize our beans.
|
||||
*/
|
||||
static final function init($fields)
|
||||
{
|
||||
foreach ($fields as $key => $value)
|
||||
{
|
||||
if (is_bool($value))
|
||||
{
|
||||
static::$_fields[$key] = $value;
|
||||
}
|
||||
else
|
||||
{
|
||||
static::$_fields[$value] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
static function check($field, &$value)
|
||||
{
|
||||
return isset(static::$_fields[$field]);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function __get($name)
|
||||
{
|
||||
$value = parent::__get($name);
|
||||
if (static::$_fields[$name])
|
||||
{
|
||||
return json_decode($value, true);
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function __set($name, $value)
|
||||
{
|
||||
if (is_array($value)
|
||||
|| is_object($value))
|
||||
{
|
||||
$value = json_encode($value);
|
||||
}
|
||||
|
||||
return parent::__set($name, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
final function checkAndSet($field, $value)
|
||||
{
|
||||
if (!static::check($field, $value))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->__set($field, $value);
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,84 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is a part of Xen Orchestra Server.
|
||||
*
|
||||
* Xen Orchestra Server is free software: you can redistribute it
|
||||
* and/or modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* Xen Orchestra Server is distributed in the hope that it will be
|
||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Xen Orchestra Server. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Julien Fontanet <julien.fontanet@vates.fr>
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0-standalone.html GPLv3
|
||||
*
|
||||
* @package Xen Orchestra Server
|
||||
*/
|
||||
|
||||
namespace Bean;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
final class Host extends BeanAbstract
|
||||
{
|
||||
protected static $_fields;
|
||||
}
|
||||
Host::init(array(
|
||||
'id',
|
||||
'uuid',
|
||||
|
||||
'API_version_major',
|
||||
'API_version_minor',
|
||||
'API_version_vendor',
|
||||
'API_version_vendor_implementation' => true,
|
||||
'PBDs' => true,
|
||||
'PCIs' => true,
|
||||
'PGPUs' => true,
|
||||
'PIFs' => true,
|
||||
'address',
|
||||
'allowed_operations' => true,
|
||||
'bios_strings' => true,
|
||||
'blobs' => true,
|
||||
'capabilities' => true,
|
||||
'chipset_info' => true,
|
||||
'cpu_configuration' => true,
|
||||
'cpu_info' => true,
|
||||
'crash_dump_sr',
|
||||
'crashdumps' => true,
|
||||
'current_operations' => true,
|
||||
'edition',
|
||||
'enabled',
|
||||
'external_auth_configuration' => true,
|
||||
'external_auth_service_name',
|
||||
'external_auth_type',
|
||||
'ha_network_peers' => true,
|
||||
'ha_statefiles' => true,
|
||||
'host_CPUs' => true,
|
||||
'hostname',
|
||||
'license_params' => true,
|
||||
'license_server' => true,
|
||||
'local_cache_sr',
|
||||
'logging' => true,
|
||||
'memory_overhead',
|
||||
'metrics',
|
||||
'name_description',
|
||||
'name_label',
|
||||
'other_config' => true,
|
||||
'patches' => true,
|
||||
'power_on_config' => true,
|
||||
'power_on_mode',
|
||||
'resident_VMs' => true,
|
||||
'sched_policy',
|
||||
'software_version' => true,
|
||||
'supported_bootloaders' => true,
|
||||
'suspend_image_sr',
|
||||
'tags' => true,
|
||||
));
|
@ -1,38 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is a part of Xen Orchestra Server.
|
||||
*
|
||||
* Xen Orchestra Server is free software: you can redistribute it
|
||||
* and/or modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* Xen Orchestra Server is distributed in the hope that it will be
|
||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Xen Orchestra Server. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Julien Fontanet <julien.fontanet@vates.fr>
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0-standalone.html GPLv3
|
||||
*
|
||||
* @package Xen Orchestra Server
|
||||
*/
|
||||
|
||||
namespace Bean;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
final class HostCPU extends BeanAbstract
|
||||
{
|
||||
protected static $_fields;
|
||||
}
|
||||
HostCPU::init(array(
|
||||
'id',
|
||||
'uuid',
|
||||
|
||||
));
|
@ -1,43 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is a part of Xen Orchestra Server.
|
||||
*
|
||||
* Xen Orchestra Server is free software: you can redistribute it
|
||||
* and/or modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* Xen Orchestra Server is distributed in the hope that it will be
|
||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Xen Orchestra Server. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Julien Fontanet <julien.fontanet@vates.fr>
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0-standalone.html GPLv3
|
||||
*
|
||||
* @package Xen Orchestra Server
|
||||
*/
|
||||
|
||||
namespace Bean;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
final class HostMetrics extends BeanAbstract
|
||||
{
|
||||
protected static $_fields;
|
||||
}
|
||||
HostMetrics::init(array(
|
||||
'id',
|
||||
'uuid',
|
||||
|
||||
'last_updated' => true,
|
||||
'live',
|
||||
'memory_free',
|
||||
'memory_total',
|
||||
'other_config' => true,
|
||||
));
|
@ -1,45 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is a part of Xen Orchestra Server.
|
||||
*
|
||||
* Xen Orchestra Server is free software: you can redistribute it
|
||||
* and/or modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* Xen Orchestra Server is distributed in the hope that it will be
|
||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Xen Orchestra Server. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Julien Fontanet <julien.fontanet@vates.fr>
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0-standalone.html GPLv3
|
||||
*
|
||||
* @package Xen Orchestra Server
|
||||
*/
|
||||
|
||||
namespace Bean;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
final class Message extends BeanAbstract
|
||||
{
|
||||
protected static $_fields;
|
||||
}
|
||||
Message::init(array(
|
||||
'id',
|
||||
'uuid',
|
||||
|
||||
'timestamp' => true,
|
||||
'name',
|
||||
'body',
|
||||
'priority',
|
||||
|
||||
'cls', // Not class like in Event !!!
|
||||
'obj_uuid',
|
||||
));
|
@ -1,50 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is a part of Xen Orchestra Server.
|
||||
*
|
||||
* Xen Orchestra Server is free software: you can redistribute it
|
||||
* and/or modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* Xen Orchestra Server is distributed in the hope that it will be
|
||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Xen Orchestra Server. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Julien Fontanet <julien.fontanet@vates.fr>
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0-standalone.html GPLv3
|
||||
*
|
||||
* @package Xen Orchestra Server
|
||||
*/
|
||||
|
||||
namespace Bean;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
final class Network extends BeanAbstract
|
||||
{
|
||||
protected static $_fields;
|
||||
}
|
||||
Network::init(array(
|
||||
'id',
|
||||
'uuid',
|
||||
|
||||
'allowed_operations' => true,
|
||||
'blobs' => true,
|
||||
'bridge',
|
||||
'current_operations' => true,
|
||||
'default_locking_mode',
|
||||
'MTU',
|
||||
'name_description',
|
||||
'name_label',
|
||||
'other_config' => true,
|
||||
'PIFs' => true,
|
||||
'tags' => true,
|
||||
'VIFs' => true,
|
||||
));
|
@ -1,43 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is a part of Xen Orchestra Server.
|
||||
*
|
||||
* Xen Orchestra Server is free software: you can redistribute it
|
||||
* and/or modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* Xen Orchestra Server is distributed in the hope that it will be
|
||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Xen Orchestra Server. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Julien Fontanet <julien.fontanet@vates.fr>
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0-standalone.html GPLv3
|
||||
*
|
||||
* @package Xen Orchestra Server
|
||||
*/
|
||||
|
||||
namespace Bean;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
final class PBD extends BeanAbstract
|
||||
{
|
||||
protected static $_fields;
|
||||
}
|
||||
PBD::init(array(
|
||||
'id',
|
||||
'uuid',
|
||||
|
||||
'SR',
|
||||
'currently_attached',
|
||||
'device_config' => true,
|
||||
'host',
|
||||
'other_config' => true,
|
||||
));
|
@ -1,65 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is a part of Xen Orchestra Server.
|
||||
*
|
||||
* Xen Orchestra Server is free software: you can redistribute it
|
||||
* and/or modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* Xen Orchestra Server is distributed in the hope that it will be
|
||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Xen Orchestra Server. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Julien Fontanet <julien.fontanet@vates.fr>
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0-standalone.html GPLv3
|
||||
*
|
||||
* @package Xen Orchestra Server
|
||||
*/
|
||||
|
||||
namespace Bean;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
final class PIF extends BeanAbstract
|
||||
{
|
||||
protected static $_fields;
|
||||
}
|
||||
PIF::init(array(
|
||||
'id',
|
||||
'uuid',
|
||||
|
||||
'bond_master_of' => true,
|
||||
'bond_slave_of',
|
||||
'currently_attached',
|
||||
'device',
|
||||
'disallow_unplug',
|
||||
'DNS',
|
||||
'gateway',
|
||||
'host',
|
||||
'IP',
|
||||
'ip_configuration_mode',
|
||||
'IPv6' => true,
|
||||
'ipv6_configuration_mode',
|
||||
'ipv6_gateway',
|
||||
'MAC',
|
||||
'management',
|
||||
'metrics',
|
||||
'MTU',
|
||||
'netmask',
|
||||
'network',
|
||||
'other_config' => true,
|
||||
'physical',
|
||||
'primary_address_type',
|
||||
'tunnel_access_PIF_of' => true,
|
||||
'tunnel_transport_PIF_of' => true,
|
||||
'VLAN',
|
||||
'VLAN_master_of',
|
||||
'VLAN_slave_of' => true,
|
||||
));
|
@ -1,50 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is a part of Xen Orchestra Server.
|
||||
*
|
||||
* Xen Orchestra Server is free software: you can redistribute it
|
||||
* and/or modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* Xen Orchestra Server is distributed in the hope that it will be
|
||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Xen Orchestra Server. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Julien Fontanet <julien.fontanet@vates.fr>
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0-standalone.html GPLv3
|
||||
*
|
||||
* @package Xen Orchestra Server
|
||||
*/
|
||||
|
||||
namespace Bean;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
final class PIFMetrics extends BeanAbstract
|
||||
{
|
||||
protected static $_fields;
|
||||
}
|
||||
PIFMetrics::init(array(
|
||||
'id',
|
||||
'uuid',
|
||||
|
||||
'carrier',
|
||||
'device_id',
|
||||
'device_name',
|
||||
'duplex',
|
||||
'io_read_kbs',
|
||||
'io_write_kbs',
|
||||
'last_updated' => true,
|
||||
'other_config' => true,
|
||||
'pci_bus_path',
|
||||
'speed',
|
||||
'vendor_id',
|
||||
'vendor_name',
|
||||
));
|
@ -1,64 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is a part of Xen Orchestra Server.
|
||||
*
|
||||
* Xen Orchestra Server is free software: you can redistribute it
|
||||
* and/or modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* Xen Orchestra Server is distributed in the hope that it will be
|
||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Xen Orchestra Server. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Julien Fontanet <julien.fontanet@vates.fr>
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0-standalone.html GPLv3
|
||||
*
|
||||
* @package Xen Orchestra Server
|
||||
*/
|
||||
|
||||
namespace Bean;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
final class Pool extends BeanAbstract
|
||||
{
|
||||
protected static $_fields;
|
||||
}
|
||||
Pool::init(array(
|
||||
'id',
|
||||
'uuid',
|
||||
|
||||
'blobs' => true,
|
||||
'crash_dump_SR',
|
||||
'default_SR',
|
||||
'gui_config' => true,
|
||||
'ha_allow_overcommit',
|
||||
'ha_configuration' => true,
|
||||
'ha_enabled',
|
||||
'ha_host_failures_to_tolerate',
|
||||
'ha_overcommitted',
|
||||
'ha_plan_exists_for',
|
||||
'ha_statefiles' => true,
|
||||
'master',
|
||||
'metadata_VDIs' => true,
|
||||
'name_description',
|
||||
'name_label',
|
||||
'other_config' => true,
|
||||
'redo_log_enabled',
|
||||
'redo_log_vdi',
|
||||
'restrictions' => true,
|
||||
'suspend_image_SR',
|
||||
'tags' => true,
|
||||
'vswitch_controller',
|
||||
'wlb_enabled',
|
||||
'wlb_url',
|
||||
'wlb_username',
|
||||
'wlb_verify_cert',
|
||||
));
|
@ -1,56 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is a part of Xen Orchestra Server.
|
||||
*
|
||||
* Xen Orchestra Server is free software: you can redistribute it
|
||||
* and/or modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* Xen Orchestra Server is distributed in the hope that it will be
|
||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Xen Orchestra Server. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Julien Fontanet <julien.fontanet@vates.fr>
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0-standalone.html GPLv3
|
||||
*
|
||||
* @package Xen Orchestra Server
|
||||
*/
|
||||
|
||||
namespace Bean;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
final class SR extends BeanAbstract
|
||||
{
|
||||
protected static $_fields;
|
||||
}
|
||||
SR::init(array(
|
||||
'id',
|
||||
'uuid',
|
||||
|
||||
'PBDs' => true,
|
||||
'VDIs' => true,
|
||||
'allowed_operations' => true,
|
||||
'blobs' => true,
|
||||
'content_type',
|
||||
'current_operations' => true,
|
||||
'introduced_by',
|
||||
'local_cache_enabled',
|
||||
'name_description',
|
||||
'name_label',
|
||||
'other_config' => true,
|
||||
'physical_size',
|
||||
'physical_utilisation',
|
||||
'shared',
|
||||
'sm_config' => true,
|
||||
'tags' => true,
|
||||
'type',
|
||||
'virtual_allocation',
|
||||
));
|
@ -1,38 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is a part of Xen Orchestra Server.
|
||||
*
|
||||
* Xen Orchestra Server is free software: you can redistribute it
|
||||
* and/or modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* Xen Orchestra Server is distributed in the hope that it will be
|
||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Xen Orchestra Server. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Julien Fontanet <julien.fontanet@vates.fr>
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0-standalone.html GPLv3
|
||||
*
|
||||
* @package Xen Orchestra Server
|
||||
*/
|
||||
|
||||
namespace Bean;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
final class Token extends BeanAbstract
|
||||
{
|
||||
protected static $_fields;
|
||||
}
|
||||
Token::init(array(
|
||||
'id',
|
||||
'expiration',
|
||||
'user_id',
|
||||
));
|
@ -1,121 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is a part of Xen Orchestra Server.
|
||||
*
|
||||
* Xen Orchestra Server is free software: you can redistribute it
|
||||
* and/or modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* Xen Orchestra Server is distributed in the hope that it will be
|
||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Xen Orchestra Server. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Julien Fontanet <julien.fontanet@vates.fr>
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0-standalone.html GPLv3
|
||||
*
|
||||
* @package Xen Orchestra Server
|
||||
*/
|
||||
|
||||
namespace Bean;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
final class User extends BeanAbstract
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
const NONE = 0;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
const READ = 1;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
const WRITE = 2;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
const ADMIN = 3;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
static function permissionFromString($string)
|
||||
{
|
||||
$permissions = array(
|
||||
'none' => self::NONE,
|
||||
'read' => self::READ,
|
||||
'write' => self::WRITE,
|
||||
'admin' => self::ADMIN
|
||||
);
|
||||
|
||||
return isset($permissions[$string])
|
||||
? $permissions[$string]
|
||||
: false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
static function permissionToString($permission)
|
||||
{
|
||||
$permissions = array(
|
||||
self::NONE => 'none',
|
||||
self::READ => 'read',
|
||||
self::WRITE => 'write',
|
||||
self::ADMIN => 'admin',
|
||||
);
|
||||
|
||||
return isset($permissions[$permission])
|
||||
? $permissions[$permission]
|
||||
: false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
static function check($field, &$value)
|
||||
{
|
||||
switch ($field)
|
||||
{
|
||||
case 'name':
|
||||
return (
|
||||
is_string($value)
|
||||
&& preg_match('/^[a-z0-9]+(?:[-_.][a-z0-9]+)*$/', $value)
|
||||
);
|
||||
case 'password':
|
||||
if (!is_string($value)
|
||||
|| !preg_match('/^.{8,}$/', $value))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
$value = password_hash($value, PASSWORD_DEFAULT);
|
||||
return true;
|
||||
case 'permission':
|
||||
$value = self::permissionFromString($value);
|
||||
return (false !== $value);
|
||||
}
|
||||
|
||||
return parent::check($field, $value);
|
||||
}
|
||||
|
||||
protected static $_fields;
|
||||
}
|
||||
User::init(array(
|
||||
'id',
|
||||
'name',
|
||||
'password',
|
||||
'permission',
|
||||
));
|
@ -1,59 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is a part of Xen Orchestra Server.
|
||||
*
|
||||
* Xen Orchestra Server is free software: you can redistribute it
|
||||
* and/or modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* Xen Orchestra Server is distributed in the hope that it will be
|
||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Xen Orchestra Server. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Julien Fontanet <julien.fontanet@vates.fr>
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0-standalone.html GPLv3
|
||||
*
|
||||
* @package Xen Orchestra Server
|
||||
*/
|
||||
|
||||
namespace Bean;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
final class VBD extends BeanAbstract
|
||||
{
|
||||
protected static $_fields;
|
||||
}
|
||||
VBD::init(array(
|
||||
'id',
|
||||
'uuid',
|
||||
|
||||
'allowed_operations' => true,
|
||||
'bootable',
|
||||
'current_operations' => true,
|
||||
'currently_attached',
|
||||
'device',
|
||||
'empty',
|
||||
'metrics',
|
||||
'mode',
|
||||
'other_config' => true,
|
||||
'qos_algorithm_params' => true,
|
||||
'qos_algorithm_type',
|
||||
'qos_supported_algorithms' => true,
|
||||
'runtime_properties' => true,
|
||||
'status_code',
|
||||
'status_detail',
|
||||
'storage_lock',
|
||||
'type',
|
||||
'unpluggable',
|
||||
'userdevice',
|
||||
'VDI',
|
||||
'VM',
|
||||
));
|
@ -1,67 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is a part of Xen Orchestra Server.
|
||||
*
|
||||
* Xen Orchestra Server is free software: you can redistribute it
|
||||
* and/or modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* Xen Orchestra Server is distributed in the hope that it will be
|
||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Xen Orchestra Server. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Julien Fontanet <julien.fontanet@vates.fr>
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0-standalone.html GPLv3
|
||||
*
|
||||
* @package Xen Orchestra Server
|
||||
*/
|
||||
|
||||
namespace Bean;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
final class VDI extends BeanAbstract
|
||||
{
|
||||
protected static $_fields;
|
||||
}
|
||||
VDI::init(array(
|
||||
'id',
|
||||
'uuid',
|
||||
|
||||
'SR',
|
||||
'VBDs' => true,
|
||||
'allow_caching',
|
||||
'allowed_operations' => true,
|
||||
'crash_dumps' => true,
|
||||
'current_operations' => true,
|
||||
'is_a_snapshot',
|
||||
'location',
|
||||
'managed',
|
||||
'metadata_latest',
|
||||
'metadata_of_pool',
|
||||
'missing',
|
||||
'name_description',
|
||||
'name_label',
|
||||
'on_boot',
|
||||
'other_config' => true,
|
||||
'parent',
|
||||
'physical_utilisation',
|
||||
'read_only',
|
||||
'sharable',
|
||||
'sm_config' => true,
|
||||
'snapshot_of',
|
||||
'snapshot_time' => true,
|
||||
'snapshots' => true,
|
||||
'storage_lock',
|
||||
'tags' => true,
|
||||
'type',
|
||||
'virtual_size',
|
||||
'xenstore_data' => true,
|
||||
));
|
@ -1,58 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is a part of Xen Orchestra Server.
|
||||
*
|
||||
* Xen Orchestra Server is free software: you can redistribute it
|
||||
* and/or modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* Xen Orchestra Server is distributed in the hope that it will be
|
||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Xen Orchestra Server. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Julien Fontanet <julien.fontanet@vates.fr>
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0-standalone.html GPLv3
|
||||
*
|
||||
* @package Xen Orchestra Server
|
||||
*/
|
||||
|
||||
namespace Bean;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
final class VIF extends BeanAbstract
|
||||
{
|
||||
protected static $_fields;
|
||||
}
|
||||
VIF::init(array(
|
||||
'id',
|
||||
'uuid',
|
||||
|
||||
'MAC',
|
||||
'MAC_autogenerated',
|
||||
'MTU',
|
||||
'VM',
|
||||
'allowed_operations' => true,
|
||||
'current_operations' => true,
|
||||
'currently_attached',
|
||||
'device',
|
||||
'ipv4_allowed' => true,
|
||||
'ipv6_allowed' => true,
|
||||
'locking_mode',
|
||||
'metrics',
|
||||
'network',
|
||||
'other_config' => true,
|
||||
'qos_algorithm_params' => true,
|
||||
'qos_algorithm_type',
|
||||
'qos_supported_algorithms' => true,
|
||||
'runtime_properties' => true,
|
||||
'status_code',
|
||||
'status_detail',
|
||||
));
|
126
lib/Bean/VM.php
126
lib/Bean/VM.php
@ -1,126 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is a part of Xen Orchestra Server.
|
||||
*
|
||||
* Xen Orchestra Server is free software: you can redistribute it
|
||||
* and/or modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* Xen Orchestra Server is distributed in the hope that it will be
|
||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Xen Orchestra Server. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Julien Fontanet <julien.fontanet@vates.fr>
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0-standalone.html GPLv3
|
||||
*
|
||||
* @package Xen Orchestra Server
|
||||
*/
|
||||
|
||||
namespace Bean;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
final class VM extends BeanAbstract
|
||||
{
|
||||
protected static $_fields;
|
||||
}
|
||||
VM::init(array(
|
||||
// Identifiers.
|
||||
'id',
|
||||
'uuid',
|
||||
'name_label',
|
||||
'resident_on', // The host this VM is currently resident on.
|
||||
'domarch', // Domain architecture if available, null otherwise.
|
||||
'domid', // Domain ID.
|
||||
|
||||
// Description.
|
||||
'name_description',
|
||||
'is_a_template',
|
||||
'is_a_snapshot',
|
||||
'is_control_domain',
|
||||
'tags' => true,
|
||||
|
||||
// Technical characteristics.
|
||||
'attached_PCIs' => true,
|
||||
'bios_strings' => true,
|
||||
'HVM_boot_params' => true,
|
||||
'platform',
|
||||
'VBDs' => true, // Virtual Block Devices.
|
||||
'VCPUs_at_startup',
|
||||
'VCPUs_max',
|
||||
'VCPUs_params' => true,
|
||||
'VGPUs' => true,
|
||||
'VIFs' => true, // Virtual Network Interface.
|
||||
//'VTPMs' => true, // Virtual Trust Platform Modules ???
|
||||
|
||||
// Event-related actions.
|
||||
'actions_after_crash',
|
||||
'actions_after_reboot',
|
||||
'actions_after_shutdown',
|
||||
|
||||
// Current state.
|
||||
'guest_metrics',
|
||||
'memory_dynamic_max',
|
||||
'memory_dynamic_min',
|
||||
'memory_overhead',
|
||||
'memory_static_max',
|
||||
//'memory_static_min', // @deprecated
|
||||
'memory_target',
|
||||
'metrics',
|
||||
'power_state',
|
||||
|
||||
// Snapshot-related info.
|
||||
'shutdown_delay',
|
||||
'snapshot_info',
|
||||
'snapshot_metadata',
|
||||
'snapshot_of',
|
||||
'snapshot_time' => true,
|
||||
'snapshots' => true,
|
||||
'transportable_snapshot_id',
|
||||
|
||||
// Operations.
|
||||
'allowed_operations' => true,
|
||||
'current_operations',
|
||||
|
||||
// Various.
|
||||
'consoles' => true,
|
||||
|
||||
'affinity',
|
||||
'appliance',
|
||||
'blobs',
|
||||
'blocked_operations',
|
||||
'children' => true, // ???
|
||||
'crash_dumps' => true,
|
||||
'ha_always_run', // @deprecated
|
||||
'ha_restart_priority',
|
||||
'HVM_boot_policy',
|
||||
'HVM_shadow_multiplier',
|
||||
'is_snapshot_from_vmpp',
|
||||
'last_boot_CPU_flags',
|
||||
'last_booted_record',
|
||||
'order',
|
||||
'other_config',
|
||||
'parent', // ???
|
||||
'PCI_bus', // @deprecated
|
||||
'protection_policy',
|
||||
'PV_args',
|
||||
'PV_bootloader',
|
||||
'PV_bootloader_args',
|
||||
'PV_kernel',
|
||||
'PV_legacy_args',
|
||||
'PV_ramdisk',
|
||||
'recommendations',
|
||||
'start_delay',
|
||||
'suspend_SR',
|
||||
'suspend_VDI',
|
||||
'user_version',
|
||||
'version',
|
||||
'xenstore_data',
|
||||
));
|
@ -1,48 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is a part of Xen Orchestra Server.
|
||||
*
|
||||
* Xen Orchestra Server is free software: you can redistribute it
|
||||
* and/or modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* Xen Orchestra Server is distributed in the hope that it will be
|
||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Xen Orchestra Server. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Julien Fontanet <julien.fontanet@vates.fr>
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0-standalone.html GPLv3
|
||||
*
|
||||
* @package Xen Orchestra Server
|
||||
*/
|
||||
|
||||
namespace Bean;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
final class VMGuestMetrics extends BeanAbstract
|
||||
{
|
||||
protected static $_fields;
|
||||
}
|
||||
VMGuestMetrics::init(array(
|
||||
'id',
|
||||
'uuid',
|
||||
|
||||
'PV_drivers_up_to_date',
|
||||
'PV_drivers_version' => true,
|
||||
'disks' => true,
|
||||
'last_updated' => true,
|
||||
'live',
|
||||
'memory' => true,
|
||||
'networks' => true,
|
||||
'os_version' => true,
|
||||
'other' => true,
|
||||
'other_config' => true,
|
||||
));
|
@ -1,49 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is a part of Xen Orchestra Server.
|
||||
*
|
||||
* Xen Orchestra Server is free software: you can redistribute it
|
||||
* and/or modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* Xen Orchestra Server is distributed in the hope that it will be
|
||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Xen Orchestra Server. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Julien Fontanet <julien.fontanet@vates.fr>
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0-standalone.html GPLv3
|
||||
*
|
||||
* @package Xen Orchestra Server
|
||||
*/
|
||||
|
||||
namespace Bean;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
final class VMMetrics extends BeanAbstract
|
||||
{
|
||||
protected static $_fields;
|
||||
}
|
||||
VMMetrics::init(array(
|
||||
'id',
|
||||
'uuid',
|
||||
|
||||
'VCPUs_CPU' => true,
|
||||
'VCPUs_flags' => true,
|
||||
'VCPUs_number',
|
||||
'VCPUs_params' => true,
|
||||
'VCPUs_utilisation' => true,
|
||||
'install_time' => true,
|
||||
'last_updated' => true,
|
||||
'memory_actual',
|
||||
'other_config' => true,
|
||||
'start_time' => true,
|
||||
'state' => true,
|
||||
));
|
@ -1,65 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is a part of Xen Orchestra Server.
|
||||
*
|
||||
* Xen Orchestra Server is free software: you can redistribute it
|
||||
* and/or modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* Xen Orchestra Server is distributed in the hope that it will be
|
||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Xen Orchestra Server. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Julien Fontanet <julien.fontanet@vates.fr>
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0-standalone.html GPLv3
|
||||
*
|
||||
* @package Xen Orchestra Server
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
final class BufferedWriter
|
||||
{
|
||||
/**
|
||||
* @param string $data
|
||||
*/
|
||||
function __construct($data, $len = null)
|
||||
{
|
||||
$this->_data = $data;
|
||||
$this->_len = $len ?: strlen($data);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function onWrite($handle)
|
||||
{
|
||||
$written = @fwrite(
|
||||
$handle,
|
||||
$this->_data,
|
||||
$this->_len
|
||||
);
|
||||
|
||||
if ($written === false)
|
||||
{
|
||||
// @todo Log error.
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->_len -= $written;
|
||||
if (!$this->_len)
|
||||
{
|
||||
// Write complete, stops watching this handle.
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->_data = substr($this->_data, -$this->_len);
|
||||
}
|
||||
}
|
289
lib/Client.php
289
lib/Client.php
@ -1,289 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is a part of Xen Orchestra Server.
|
||||
*
|
||||
* Xen Orchestra Server is free software: you can redistribute it
|
||||
* and/or modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* Xen Orchestra Server is distributed in the hope that it will be
|
||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Xen Orchestra Server. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Julien Fontanet <julien.fontanet@vates.fr>
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0-standalone.html GPLv3
|
||||
*
|
||||
* @package Xen Orchestra Server
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
final class Client extends Base
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public $uid = null;
|
||||
|
||||
/**
|
||||
* @param Loop $loop
|
||||
* @param resource $handle
|
||||
* @param callable[] $methods
|
||||
*/
|
||||
function __construct(Loop $loop, $handle, $methods)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->_loop = $loop;
|
||||
$this->_handle = $handle;
|
||||
$this->_methods = $methods;
|
||||
|
||||
stream_set_blocking($this->_handle, false);
|
||||
$loop->addRead($this->_handle, array($this, '_onRead'));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function isAuthenticated()
|
||||
{
|
||||
return (null !== $this->uid);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function notify($method, array $params)
|
||||
{
|
||||
$this->_send(array(
|
||||
'method' => $method,
|
||||
'params' => $params
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function respond($id, $result)
|
||||
{
|
||||
if ($id === null)
|
||||
{
|
||||
trigger_error(
|
||||
'notifications do not expect responses',
|
||||
E_USER_ERROR
|
||||
);
|
||||
}
|
||||
|
||||
$this->_send(array(
|
||||
'id' => $id,
|
||||
'result' => $result
|
||||
));
|
||||
}
|
||||
|
||||
////////////////////////////////////////
|
||||
//
|
||||
////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* This function is called when data become available on the
|
||||
* connection.
|
||||
*
|
||||
* Its name starts with a “_” because it is only supposed to be
|
||||
* used internally (it is not private because of PHP limits).
|
||||
*/
|
||||
function _onRead()
|
||||
{
|
||||
// Read the message length.
|
||||
if (!$this->_len)
|
||||
{
|
||||
$len = stream_get_line($this->_handle, 1024, "\n");
|
||||
if ((false === $len)
|
||||
|| ('' === $len)) // @todo Not sure why but it seems necessary.
|
||||
{
|
||||
if (feof($this->_handle))
|
||||
{
|
||||
echo "client disconnected\n";
|
||||
|
||||
// Closes this socket and stops listening to it.
|
||||
stream_socket_shutdown($this->_handle, STREAM_SHUT_RDWR);
|
||||
fclose($this->_handle);
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->_error('failed to read the request length');
|
||||
}
|
||||
if (!ctype_digit($len)
|
||||
|| ($len <= 0))
|
||||
{
|
||||
$this->_error('invalid request length');
|
||||
}
|
||||
|
||||
$this->_len = (int) $len;
|
||||
}
|
||||
|
||||
$buf = @fread($this->_handle, $this->_len);
|
||||
if ($buf === false)
|
||||
{
|
||||
$this->_error('failed to read the request');
|
||||
}
|
||||
$this->_buf .= $buf;
|
||||
$this->_len -= strlen($buf);
|
||||
|
||||
if ($this->_len !== 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$request = @json_decode($this->_buf, true);
|
||||
$this->_buf = '';
|
||||
|
||||
if ($request === null)
|
||||
{
|
||||
$this->_warning(null, -32700, 'Parse error');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isset($request['jsonrpc'], $request['method'])
|
||||
|| ($request['jsonrpc'] !== '2.0'))
|
||||
{
|
||||
$this->_warning(null, -32600, 'Invalid request');
|
||||
return;
|
||||
}
|
||||
|
||||
$id = isset($request['id']) ? $request['id'] : null;
|
||||
$method = $request['method'];
|
||||
$params = isset($request['params']) ? $request['params'] : array();
|
||||
|
||||
if (isset($this->_methods[$method]))
|
||||
{
|
||||
$error = call_user_func(
|
||||
$this->_methods[$method],
|
||||
$id, $params, $this
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$error = array(-32601, 'Method not found', $method);
|
||||
}
|
||||
|
||||
if (($error === null)
|
||||
|| ($id === null))
|
||||
{
|
||||
// No errors or this was a notification (no error handling).
|
||||
return;
|
||||
}
|
||||
|
||||
$errors = array(
|
||||
-32602 => array(
|
||||
'Invalid params',
|
||||
$params
|
||||
),
|
||||
);
|
||||
if (is_numeric($error) && isset($errors[$error]))
|
||||
{
|
||||
$error = $errors[$error];
|
||||
}
|
||||
elseif (!is_array($error) || !isset($error[0], $error[1]))
|
||||
{
|
||||
trigger_error(
|
||||
'invalid error',
|
||||
E_USER_ERROR
|
||||
);
|
||||
}
|
||||
$this->_warning(
|
||||
$id,
|
||||
$error[0],
|
||||
$error[1],
|
||||
isset($error[2]) ? $error[2] : null
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @var Loop
|
||||
*/
|
||||
private $_loop;
|
||||
|
||||
/**
|
||||
* @var resource
|
||||
*/
|
||||
private $_handle;
|
||||
|
||||
/**
|
||||
* @var callable[]
|
||||
*/
|
||||
private $_methods;
|
||||
|
||||
/**
|
||||
* @var integer
|
||||
*/
|
||||
private $_len;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $_buf;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private function _error($message)
|
||||
{
|
||||
throw new Exception($message);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $message
|
||||
*/
|
||||
private function _send($message)
|
||||
{
|
||||
$message['jsonrpc'] = '2.0';
|
||||
$message = json_encode($message);
|
||||
|
||||
$data = strlen($message)."\n".$message;
|
||||
$len = strlen($data);
|
||||
|
||||
$written = @fwrite($this->_handle, $data, $len);
|
||||
if ($written === false)
|
||||
{
|
||||
$this->_error('failed to send the message');
|
||||
}
|
||||
|
||||
$len -= $written;
|
||||
if ($len)
|
||||
{
|
||||
echo "$len bytes to write, using a buffered writer\n";
|
||||
$this->_loop->addWrite(
|
||||
$this->_handle,
|
||||
array(
|
||||
new BufferedWriter(substr($data, -$len), $len),
|
||||
'onWrite'
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private function _warning($id, $code, $message, $data = null)
|
||||
{
|
||||
$message = array(
|
||||
'id' => $id,
|
||||
'error' => array(
|
||||
'code' => $code,
|
||||
'message' => $message
|
||||
)
|
||||
);
|
||||
($data !== null)
|
||||
and $message['error']['data'] = $data;
|
||||
|
||||
$this->_send($message);
|
||||
}
|
||||
}
|
255
lib/Config.php
255
lib/Config.php
@ -1,255 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is a part of Xen Orchestra Server.
|
||||
*
|
||||
* Xen Orchestra Server is free software: you can redistribute it
|
||||
* and/or modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* Xen Orchestra Server is distributed in the hope that it will be
|
||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Xen Orchestra Server. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Julien Fontanet <julien.fontanet@vates.fr>
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0-standalone.html GPLv3
|
||||
*
|
||||
* @package Xen Orchestra Server
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
final class Config extends Base implements
|
||||
ArrayAccess,
|
||||
Countable,
|
||||
IteratorAggregate
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function __construct(array $entries = null)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->_entries = isset($entries) ? $entries : array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an entry.
|
||||
*
|
||||
* @param string $path
|
||||
* @param mixed $default Optional.
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws Exception If there is no such entry and no default value as been
|
||||
* specified.
|
||||
*/
|
||||
function get($path, $default = 'throws an exception')
|
||||
{
|
||||
$entry = $this->_entries;
|
||||
|
||||
$parts = explode('.', $path);
|
||||
foreach ($parts as $part)
|
||||
{
|
||||
/*
|
||||
* Nothing found.
|
||||
*/
|
||||
if (!isset($entry[$part])
|
||||
&& !array_key_exists($part, $entry))
|
||||
{
|
||||
if (func_num_args() < 2)
|
||||
{
|
||||
throw new Exception('no such entry ('.$path.')');
|
||||
}
|
||||
|
||||
$entry = $default;
|
||||
break;
|
||||
}
|
||||
|
||||
$entry = $entry[$part];
|
||||
}
|
||||
|
||||
return $this->_resolve($entry);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function merge($entries)
|
||||
{
|
||||
if ($entries instanceof self)
|
||||
{
|
||||
$entries = $entries->_entries;
|
||||
}
|
||||
|
||||
self::_merge($this->_entries, $entries);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param string $path
|
||||
* @param array|string $value
|
||||
*/
|
||||
function set($path, $value)
|
||||
{
|
||||
$entry = &$this->_entries;
|
||||
|
||||
$parts = explode('.', $path);
|
||||
|
||||
$i = 0;
|
||||
$n = count($parts);
|
||||
while (
|
||||
($i < $n)
|
||||
&& (
|
||||
isset($entry[$part = $parts[$i]])
|
||||
|| (
|
||||
is_array($entry)
|
||||
&& array_key_exists($part, $entry)
|
||||
)
|
||||
)
|
||||
)
|
||||
{
|
||||
$entry = &$entry[$part];
|
||||
++$i;
|
||||
}
|
||||
|
||||
while ($i < $n)
|
||||
{
|
||||
if (!is_array($entry))
|
||||
{
|
||||
$entry = array();
|
||||
}
|
||||
|
||||
$entry = &$entry[$parts[$i]];
|
||||
++$i;
|
||||
}
|
||||
|
||||
$entry = $value;
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function offsetGet($offset)
|
||||
{
|
||||
return $this->get($offset);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function offsetExists($offset)
|
||||
{
|
||||
return (isset($this->_entries[$offset])
|
||||
|| array_key_exists($offset, $this->_entries));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function offsetSet($offset, $value)
|
||||
{
|
||||
$this->set($offset, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function offsetUnset($index)
|
||||
{
|
||||
trigger_error(
|
||||
get_class($this).'['.var_export($index, true).'] is not deletable',
|
||||
E_USER_ERROR
|
||||
);
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
|
||||
/**
|
||||
* @return integer
|
||||
*/
|
||||
function count()
|
||||
{
|
||||
return count($this->_entries);
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function getIterator()
|
||||
{
|
||||
return \ArrayIterator($this->_entries);
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
static private function _merge(array &$ar1, array $ar2)
|
||||
{
|
||||
foreach ($ar2 as $key => $val)
|
||||
{
|
||||
if (is_array($val)
|
||||
&& isset($ar1[$key])
|
||||
&& is_array($ar1[$key]))
|
||||
{
|
||||
self::_merge($ar1[$key], $val);
|
||||
}
|
||||
else
|
||||
{
|
||||
$ar1[$key] = $val;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $_entries;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private function _replaceCallback(array $match)
|
||||
{
|
||||
return $this->get($match[1]);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private function _resolve($entry)
|
||||
{
|
||||
if (is_string($entry))
|
||||
{
|
||||
return preg_replace_callback(
|
||||
'/#\{([-a-zA-Z0-9_.]+)\}/',
|
||||
array($this, '_replaceCallback'),
|
||||
$entry
|
||||
);
|
||||
}
|
||||
|
||||
if (is_array($entry))
|
||||
{
|
||||
foreach ($entry as &$item)
|
||||
{
|
||||
$item = $this->_resolve($item);
|
||||
}
|
||||
}
|
||||
|
||||
return $entry;
|
||||
}
|
||||
}
|
@ -1,83 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is a part of Xen Orchestra Server.
|
||||
*
|
||||
* Xen Orchestra Server is free software: you can redistribute it
|
||||
* and/or modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* Xen Orchestra Server is distributed in the hope that it will be
|
||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Xen Orchestra Server. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Julien Fontanet <julien.fontanet@vates.fr>
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0-standalone.html GPLv3
|
||||
*
|
||||
* @package Xen Orchestra Server
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
abstract class Connection extends Base
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function __construct($handle, Loop $loop)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->_handle = $handle;
|
||||
$this->_loop = $loop;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function __destruct()
|
||||
{
|
||||
$this->close();
|
||||
|
||||
parent::__destruct();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
final function close()
|
||||
{
|
||||
$this->_loop->removeRead($this->_handle);
|
||||
$this->_loop->removeWrite($this->_handle);
|
||||
|
||||
$this->handleClose();
|
||||
|
||||
if (is_resource($this->_handle))
|
||||
{
|
||||
stream_socket_shutdown($this->_handle, STREAM_SHUT_RDWR);
|
||||
fclose($this->_handle);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function handleClose()
|
||||
{}
|
||||
|
||||
/**
|
||||
* @var resource
|
||||
*/
|
||||
private $_handle;
|
||||
|
||||
/**
|
||||
* @var Loop
|
||||
*/
|
||||
private $_loop;
|
||||
}
|
312
lib/DI.php
312
lib/DI.php
@ -1,312 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is a part of Xen Orchestra Server.
|
||||
*
|
||||
* Xen Orchestra Server is free software: you can redistribute it
|
||||
* and/or modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* Xen Orchestra Server is distributed in the hope that it will be
|
||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Xen Orchestra Server. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Julien Fontanet <julien.fontanet@vates.fr>
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0-standalone.html GPLv3
|
||||
*
|
||||
* @package Xen Orchestra Server
|
||||
*/
|
||||
|
||||
/**
|
||||
* Dependency injector.
|
||||
*/
|
||||
final class DI extends Base
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
function get($id)
|
||||
{
|
||||
if (isset($this->_entries[$id])
|
||||
|| array_key_exists($id, $this->_entries))
|
||||
{
|
||||
return $this->_entries[$id];
|
||||
}
|
||||
|
||||
$tmp = str_replace(array('_', '.'), array('', '_'), $id);
|
||||
|
||||
if (method_exists($this, '_get_'.$tmp))
|
||||
{
|
||||
return $this->{'_get_'.$tmp}();
|
||||
}
|
||||
|
||||
if (method_exists($this, '_init_'.$tmp))
|
||||
{
|
||||
$value = $this->{'_init_'.$tmp}();
|
||||
$this->set($id, $value);
|
||||
return $value;
|
||||
}
|
||||
|
||||
throw new Exception('no such entry: '.$id);
|
||||
}
|
||||
|
||||
function set($id, $value)
|
||||
{
|
||||
$this->_entries[$id] = $value;
|
||||
}
|
||||
|
||||
private $_entries = array();
|
||||
|
||||
////////////////////////////////////////
|
||||
|
||||
private function _init_application()
|
||||
{
|
||||
return new Application($this);
|
||||
}
|
||||
|
||||
private function _init_database()
|
||||
{
|
||||
$config = $this->get('config');
|
||||
|
||||
$type = $config['database.type'];
|
||||
if ('json' !== $type)
|
||||
{
|
||||
trigger_error(
|
||||
'unsupported database type ('.$type.')',
|
||||
E_USER_ERROR
|
||||
);
|
||||
}
|
||||
|
||||
return JSONDatabase::factory($config['database.file']);
|
||||
}
|
||||
|
||||
private function _init_database_cache()
|
||||
{
|
||||
$database = new \Rekodi\Manager\Memory;
|
||||
|
||||
$database->createTable('hosts', function ($table) {
|
||||
$table
|
||||
->string('id')->unique()
|
||||
;
|
||||
});
|
||||
$database->createTable('hosts_cpus', function ($table) {
|
||||
$table
|
||||
->string('id')->unique()
|
||||
;
|
||||
});
|
||||
$database->createTable('hosts_metrics', function ($table) {
|
||||
$table
|
||||
->string('id')->unique()
|
||||
;
|
||||
});
|
||||
$database->createTable('messages', function ($table) {
|
||||
$table
|
||||
->string('id')->unique()
|
||||
;
|
||||
});
|
||||
$database->createTable('networks', function ($table) {
|
||||
$table
|
||||
->string('id')->unique()
|
||||
;
|
||||
});
|
||||
$database->createTable('pbds', function ($table) {
|
||||
$table
|
||||
->string('id')->unique()
|
||||
;
|
||||
});
|
||||
$database->createTable('pifs', function ($table) {
|
||||
$table
|
||||
->string('id')->unique()
|
||||
;
|
||||
});
|
||||
$database->createTable('pifs_metrics', function ($table) {
|
||||
$table
|
||||
->string('id')->unique()
|
||||
;
|
||||
});
|
||||
$database->createTable('pools', function ($table) {
|
||||
$table
|
||||
->string('id')->unique()
|
||||
;
|
||||
});
|
||||
$database->createTable('srs', function ($table) {
|
||||
$table
|
||||
->string('id')->unique()
|
||||
->boolean('shared')
|
||||
;
|
||||
});
|
||||
$database->createTable('vbds', function ($table) {
|
||||
$table
|
||||
->string('id')->unique()
|
||||
;
|
||||
});
|
||||
$database->createTable('vdis', function ($table) {
|
||||
$table
|
||||
->string('id')->unique()
|
||||
;
|
||||
});
|
||||
$database->createTable('vifs', function ($table) {
|
||||
$table
|
||||
->string('id')->unique()
|
||||
;
|
||||
});
|
||||
$database->createTable('vms', function ($table) {
|
||||
$table
|
||||
->string('id')->unique()
|
||||
->string('power_state')
|
||||
->boolean('is_control_domain')
|
||||
;
|
||||
});
|
||||
$database->createTable('vms_metrics', function ($table) {
|
||||
$table
|
||||
->string('id')->unique()
|
||||
;
|
||||
});
|
||||
$database->createTable('vms_guest_metrics', function ($table) {
|
||||
$table
|
||||
->string('id')->unique()
|
||||
;
|
||||
});
|
||||
|
||||
return $database;
|
||||
}
|
||||
|
||||
private function _init_errorLogger()
|
||||
{
|
||||
return new ErrorLogger($this->get('logger'));
|
||||
}
|
||||
|
||||
private function _init_logger()
|
||||
{
|
||||
$logger = new \Monolog\Logger('main');
|
||||
|
||||
$config = $this->get('config');
|
||||
if ($email = $config->get('log.email', false))
|
||||
{
|
||||
$logger->pushHandler(
|
||||
new \Monolog\Handler\FingersCrossedHandler(
|
||||
new \Monolog\Handler\NativeMailerHandler(
|
||||
$email,
|
||||
'[XO Server]',
|
||||
'no-reply@vates.fr',
|
||||
\Monolog\Logger::DEBUG
|
||||
),
|
||||
\Monolog\Logger::WARNING
|
||||
)
|
||||
);
|
||||
}
|
||||
if ($file = $config->get('log.file', false))
|
||||
{
|
||||
$logger->pushHandler(
|
||||
new \Monolog\Handler\StreamHandler($file)
|
||||
);
|
||||
}
|
||||
|
||||
return $logger;
|
||||
}
|
||||
|
||||
private function _init_loop()
|
||||
{
|
||||
return new Loop;
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
// Managers
|
||||
|
||||
private function _init_hosts()
|
||||
{
|
||||
return new \Manager\Hosts($this->get('database.cache'));
|
||||
}
|
||||
|
||||
private function _init_hostsCpus()
|
||||
{
|
||||
return new \Manager\HostsCPUs($this->get('database.cache'));
|
||||
}
|
||||
|
||||
private function _init_hostsMetrics()
|
||||
{
|
||||
return new \Manager\HostsMetrics($this->get('database.cache'));
|
||||
}
|
||||
|
||||
private function _init_messages()
|
||||
{
|
||||
return new \Manager\Messages($this->get('database.cache'));
|
||||
}
|
||||
|
||||
private function _init_networks()
|
||||
{
|
||||
return new \Manager\Networks($this->get('database.cache'));
|
||||
}
|
||||
|
||||
private function _init_pbds()
|
||||
{
|
||||
return new \Manager\PBDs($this->get('database.cache'));
|
||||
}
|
||||
|
||||
private function _init_pifs()
|
||||
{
|
||||
return new \Manager\PIFs($this->get('database.cache'));
|
||||
}
|
||||
|
||||
private function _init_pifsMetrics()
|
||||
{
|
||||
return new \Manager\PIFsMetrics($this->get('database.cache'));
|
||||
}
|
||||
|
||||
private function _init_pools()
|
||||
{
|
||||
return new \Manager\Pools($this->get('database.cache'));
|
||||
}
|
||||
|
||||
private function _init_srs()
|
||||
{
|
||||
return new \Manager\SRs($this->get('database.cache'));
|
||||
}
|
||||
|
||||
private function _init_tokens()
|
||||
{
|
||||
return new \Manager\Tokens($this->get('database'));
|
||||
}
|
||||
|
||||
private function _init_users()
|
||||
{
|
||||
return new \Manager\Users($this->get('database'));
|
||||
}
|
||||
|
||||
private function _init_vbds()
|
||||
{
|
||||
return new \Manager\VBDs($this->get('database.cache'));
|
||||
}
|
||||
|
||||
private function _init_vdis()
|
||||
{
|
||||
return new \Manager\VDIs($this->get('database.cache'));
|
||||
}
|
||||
|
||||
private function _init_vifs()
|
||||
{
|
||||
return new \Manager\VIFs($this->get('database.cache'));
|
||||
}
|
||||
|
||||
private function _init_vms()
|
||||
{
|
||||
return new \Manager\VMs($this->get('database.cache'));
|
||||
}
|
||||
|
||||
private function _init_vmsGuestMetrics()
|
||||
{
|
||||
return new \Manager\VMsGuestMetrics($this->get('database.cache'));
|
||||
}
|
||||
|
||||
private function _init_vmsMetrics()
|
||||
{
|
||||
return new \Manager\VMsMetrics($this->get('database.cache'));
|
||||
}
|
||||
}
|
@ -1,110 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is a part of Xen Orchestra Server.
|
||||
*
|
||||
* Xen Orchestra Server is free software: you can redistribute it
|
||||
* and/or modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* Xen Orchestra Server is distributed in the hope that it will be
|
||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Xen Orchestra Server. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Julien Fontanet <julien.fontanet@vates.fr>
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0-standalone.html GPLv3
|
||||
*
|
||||
* @package Xen Orchestra Server
|
||||
*/
|
||||
|
||||
use \Monolog\Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
final class ErrorLogger extends Base
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function __construct(Logger $logger)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->_logger = $logger;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles fatal errors on shutdown.
|
||||
*/
|
||||
function handleShutdown()
|
||||
{
|
||||
$e = error_get_Last();
|
||||
if ((($e['type'] === E_ERROR) || ($e['type'] === E_USER_ERROR))
|
||||
&& ($e !== $this->_last))
|
||||
{
|
||||
$this->log($e['type'], $e['message'], $e['file'], $e['line']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function log($no, $str, $file, $line)
|
||||
{
|
||||
static $map = array(
|
||||
E_NOTICE => Logger::NOTICE,
|
||||
E_USER_NOTICE => Logger::NOTICE,
|
||||
E_WARNING => Logger::WARNING,
|
||||
E_CORE_WARNING => Logger::WARNING,
|
||||
E_USER_WARNING => Logger::WARNING,
|
||||
E_ERROR => Logger::ERROR,
|
||||
E_USER_ERROR => Logger::ERROR,
|
||||
E_CORE_ERROR => Logger::ERROR,
|
||||
E_RECOVERABLE_ERROR => Logger::ERROR,
|
||||
E_STRICT => Logger::DEBUG,
|
||||
);
|
||||
|
||||
// Used to prevents the last error from being logged twice.
|
||||
$this->_last = array(
|
||||
'type' => $no,
|
||||
'message' => $str,
|
||||
'file' => $file,
|
||||
'line' => $line
|
||||
);
|
||||
|
||||
$priority = isset($map[$no])
|
||||
? $map[$no]
|
||||
: Logger::WARNING
|
||||
;
|
||||
|
||||
// Appends the location if necessary.
|
||||
if (!preg_match('/(?:at|in) [^ ]+:[0-9]+$/', $str))
|
||||
{
|
||||
$str .= " in $file:$line";
|
||||
}
|
||||
|
||||
$this->_logger->addRecord($priority, $str, array(
|
||||
'no' => $no,
|
||||
'file' => $file,
|
||||
'line' => $line,
|
||||
));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private $_last;
|
||||
|
||||
/**
|
||||
* @var Logger
|
||||
*/
|
||||
private $_logger;
|
||||
}
|
@ -1,163 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is a part of Xen Orchestra Server.
|
||||
*
|
||||
* Xen Orchestra Server is free software: you can redistribute it
|
||||
* and/or modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* Xen Orchestra Server is distributed in the hope that it will be
|
||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Xen Orchestra Server. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Julien Fontanet <julien.fontanet@vates.fr>
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0-standalone.html GPLv3
|
||||
*
|
||||
* @package Xen Orchestra Server
|
||||
*/
|
||||
|
||||
final class JSONDatabase extends \Rekodi\Manager\Memory
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
static function factory($file)
|
||||
{
|
||||
if (file_exists($file))
|
||||
{
|
||||
$data = @file_get_contents($file);
|
||||
if ((false === $data)
|
||||
|| (null === ($data = json_decode($data, true))))
|
||||
{
|
||||
trigger_error(
|
||||
'could not read the database',
|
||||
E_USER_ERROR
|
||||
);
|
||||
}
|
||||
|
||||
$manager = static::createFromState($data);
|
||||
}
|
||||
else
|
||||
{
|
||||
$manager = new static;
|
||||
|
||||
// Create tables.
|
||||
$manager->createTable('tokens', function ($table) {
|
||||
$table
|
||||
->string('id')->unique()
|
||||
->integer('expiration')
|
||||
->string('user_id')
|
||||
;
|
||||
});
|
||||
$manager->createTable('users', function ($table) {
|
||||
$table
|
||||
->integer('id')->autoIncremented()
|
||||
->string('name')->unique()
|
||||
->string('password')
|
||||
->integer('permission')
|
||||
;
|
||||
});
|
||||
|
||||
// Insert initial data.
|
||||
$manager->create('users', array(
|
||||
array(
|
||||
'name' => 'admin',
|
||||
'password' => '$2y$10$VzBQqiwnhG5zc2.MQmmW4ORcPW6FE7SLhPr1VBV2ubn5zJoesnmli',
|
||||
'permission' => \Bean\User::ADMIN,
|
||||
),
|
||||
));
|
||||
|
||||
trigger_error(
|
||||
'no existing database, creating default user (admin:admin)',
|
||||
E_USER_WARNING
|
||||
);
|
||||
}
|
||||
|
||||
$manager->_file = $file;
|
||||
return $manager;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function createTable($name, $callback)
|
||||
{
|
||||
$result = parent::createTable($name, $callback);
|
||||
$this->_save();
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function deleteTable($name)
|
||||
{
|
||||
$result = parent::deleteTable($name);
|
||||
$this->_save();
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function create($table, array $entries)
|
||||
{
|
||||
$result = parent::create($table, $entries);
|
||||
$this->_save();
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function delete($table, array $filter)
|
||||
{
|
||||
$result = parent::delete($table, $filter);
|
||||
$this->_save();
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function update($table, array $filter, array $properties)
|
||||
{
|
||||
$result = parent::update($table, $filter, $properties);
|
||||
$this->_save();
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private $_file;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private function _save()
|
||||
{
|
||||
if (!$this->_file)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$bytes = @file_put_contents(
|
||||
$this->_file,
|
||||
json_encode($this->getState())
|
||||
);
|
||||
if (!$bytes)
|
||||
{
|
||||
trigger_error(
|
||||
'could not write the database',
|
||||
E_USER_ERROR
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
180
lib/Loop.php
180
lib/Loop.php
@ -1,180 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is a part of Xen Orchestra Server.
|
||||
*
|
||||
* Xen Orchestra Server is free software: you can redistribute it
|
||||
* and/or modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* Xen Orchestra Server is distributed in the hope that it will be
|
||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Xen Orchestra Server. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Julien Fontanet <julien.fontanet@vates.fr>
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0-standalone.html GPLv3
|
||||
*
|
||||
* @package Xen Orchestra Server
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
final class Loop extends Base
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param resource $handle
|
||||
* @param callable $callback
|
||||
*/
|
||||
function addRead($handle, $callback)
|
||||
{
|
||||
$id = (int) $handle;
|
||||
|
||||
$this->_readHandles[$id] = $handle;
|
||||
$this->_readCallbacks[$id] = $callback;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function removeRead($handle)
|
||||
{
|
||||
$id = (int) $handle;
|
||||
|
||||
unset(
|
||||
$this->_readHandles[$id],
|
||||
$this->_readCallbacks[$id]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param resource $handle
|
||||
* @param callable $callback
|
||||
*/
|
||||
function addWrite($handle, $callback)
|
||||
{
|
||||
$id = (int) $handle;
|
||||
|
||||
$this->_writeHandles[$id] = $handle;
|
||||
$this->_writeCallbacks[$id] = $callback;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function removeWrite($handle)
|
||||
{
|
||||
$id = (int) $handle;
|
||||
|
||||
unset(
|
||||
$this->_writeHandles[$id],
|
||||
$this->_writeCallbacks[$id]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function remove($handle)
|
||||
{
|
||||
$id = (int) $handle;
|
||||
|
||||
unset(
|
||||
$this->_readHandles[$id],
|
||||
$this->_readCallbacks[$id],
|
||||
$this->_writeHandles[$id],
|
||||
$this->_writeCallbacks[$id]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $user_data
|
||||
*/
|
||||
function run($user_data = null)
|
||||
{
|
||||
$this->_running = true;
|
||||
|
||||
do
|
||||
{
|
||||
$read = $this->_readHandles;
|
||||
$write = $this->_writeHandles;
|
||||
$except = null;
|
||||
if (@stream_select($read, $write, $except, null) === false)
|
||||
{
|
||||
trigger_error(
|
||||
'error while waiting for activity',
|
||||
E_USER_ERROR
|
||||
);
|
||||
}
|
||||
|
||||
foreach ($read as $handle)
|
||||
{
|
||||
$result = call_user_func(
|
||||
$this->_readCallbacks[(int) $handle],
|
||||
$handle, $user_data
|
||||
);
|
||||
|
||||
if (!is_resource($handle))
|
||||
{
|
||||
$this->remove($handle);
|
||||
}
|
||||
elseif ($result === false)
|
||||
{
|
||||
$this->removeRead($handle);
|
||||
}
|
||||
}
|
||||
foreach ($write as $handle)
|
||||
{
|
||||
$result = call_user_func(
|
||||
$this->_writeCallbacks[(int) $handle],
|
||||
$handle, $user_data
|
||||
);
|
||||
|
||||
if (!is_resource($handle))
|
||||
{
|
||||
$this->remove($handle);
|
||||
}
|
||||
elseif ($result === false)
|
||||
{
|
||||
$this->removeWrite($handle);
|
||||
}
|
||||
}
|
||||
} while ($this->_running
|
||||
&& ($this->_readHandles || $this->_writeHandles));
|
||||
}
|
||||
|
||||
/**
|
||||
* @var boolean
|
||||
*/
|
||||
private $_running;
|
||||
|
||||
/**
|
||||
* @var resource[]
|
||||
*/
|
||||
private $_readHandles = array();
|
||||
|
||||
/**
|
||||
* @var callable[]
|
||||
*/
|
||||
private $_readCallbacks = array();
|
||||
|
||||
/**
|
||||
* @var resource[]
|
||||
*/
|
||||
private $_writeHandles = array();
|
||||
|
||||
/**
|
||||
* @var callable[]
|
||||
*/
|
||||
private $_writeCallbacks = array();
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is a part of Xen Orchestra Server.
|
||||
*
|
||||
* Xen Orchestra Server is free software: you can redistribute it
|
||||
* and/or modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* Xen Orchestra Server is distributed in the hope that it will be
|
||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Xen Orchestra Server. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Julien Fontanet <julien.fontanet@vates.fr>
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0-standalone.html GPLv3
|
||||
*
|
||||
* @package Xen Orchestra Server
|
||||
*/
|
||||
|
||||
namespace Manager;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
final class Hosts extends XCPAbstract
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function __construct(\Rekodi\Manager $manager)
|
||||
{
|
||||
parent::__construct($manager, 'hosts', '\Bean\Host');
|
||||
}
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is a part of Xen Orchestra Server.
|
||||
*
|
||||
* Xen Orchestra Server is free software: you can redistribute it
|
||||
* and/or modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* Xen Orchestra Server is distributed in the hope that it will be
|
||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Xen Orchestra Server. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Julien Fontanet <julien.fontanet@vates.fr>
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0-standalone.html GPLv3
|
||||
*
|
||||
* @package Xen Orchestra Server
|
||||
*/
|
||||
|
||||
namespace Manager;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
final class HostsCPUs extends XCPAbstract
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function __construct(\Rekodi\Manager $manager)
|
||||
{
|
||||
parent::__construct($manager, 'hosts_cpus', '\Bean\HostCPU');
|
||||
}
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is a part of Xen Orchestra Server.
|
||||
*
|
||||
* Xen Orchestra Server is free software: you can redistribute it
|
||||
* and/or modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* Xen Orchestra Server is distributed in the hope that it will be
|
||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Xen Orchestra Server. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Julien Fontanet <julien.fontanet@vates.fr>
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0-standalone.html GPLv3
|
||||
*
|
||||
* @package Xen Orchestra Server
|
||||
*/
|
||||
|
||||
namespace Manager;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
final class HostsMetrics extends XCPAbstract
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function __construct(\Rekodi\Manager $manager)
|
||||
{
|
||||
parent::__construct($manager, 'hosts_metrics', '\Bean\HostMetrics');
|
||||
}
|
||||
}
|
@ -1,237 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is a part of Xen Orchestra Server.
|
||||
*
|
||||
* Xen Orchestra Server is free software: you can redistribute it
|
||||
* and/or modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* Xen Orchestra Server is distributed in the hope that it will be
|
||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Xen Orchestra Server. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Julien Fontanet <julien.fontanet@vates.fr>
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0-standalone.html GPLv3
|
||||
*
|
||||
* @package Xen Orchestra Server
|
||||
*/
|
||||
|
||||
namespace Manager;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
abstract class ManagerAbstract
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected function __construct(\Rekodi\Manager $database, $table, $bean)
|
||||
{
|
||||
$this->_database = $database;
|
||||
$this->_table = $table;
|
||||
$this->_bean = $bean;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function __destruct()
|
||||
{}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function create(array $properties)
|
||||
{
|
||||
$class = $this->_bean;
|
||||
$bean = new $class($properties, true);
|
||||
|
||||
$new_props = $this->_database->create(
|
||||
$this->_table,
|
||||
array($bean->getProperties())
|
||||
);
|
||||
|
||||
$bean->set($new_props[0]);
|
||||
$bean->markAsClean();
|
||||
return $bean;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function count(array $filter = null)
|
||||
{
|
||||
return $this->_database->count(
|
||||
$this->_table,
|
||||
$filter
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function createOrUpdate(array $properties)
|
||||
{
|
||||
$bean = $this->get($properties['id'], false);
|
||||
if (!$bean)
|
||||
{
|
||||
return $this->create($properties);
|
||||
}
|
||||
|
||||
$bean->set($properties, true);
|
||||
$this->save($bean);
|
||||
return $bean;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function delete($id)
|
||||
{
|
||||
$n = $this->_database->delete($this->_table, array('id' => $id));
|
||||
|
||||
if (1 !== $n)
|
||||
{
|
||||
trigger_error(
|
||||
'unexpected number of deleted '.$this->_table.' ('.$n.')',
|
||||
E_USER_ERROR
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|array $filter Either the id of the entry to get or a
|
||||
* filter it must match.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function exists($filter)
|
||||
{
|
||||
if (!is_array($filter))
|
||||
{
|
||||
$filter = array('id' => $filter);
|
||||
}
|
||||
|
||||
// @todo Handle limit in Rekodi.
|
||||
return $this->_database->count(
|
||||
$this->_table,
|
||||
$filter
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|array $filter Either the id of the entry to get or a
|
||||
* filter it must match.
|
||||
* @param mixed $default Value returned if no entry has been found.
|
||||
*
|
||||
* @return Bean|mixed
|
||||
*/
|
||||
function first($filter, $default = 'fatal error')
|
||||
{
|
||||
if (!is_array($filter))
|
||||
{
|
||||
$filter = array('id' => $filter);
|
||||
}
|
||||
|
||||
$entries = $this->get($filter);
|
||||
if ($entries)
|
||||
{
|
||||
return $entries[0];
|
||||
}
|
||||
|
||||
if (func_num_args() >= 2)
|
||||
{
|
||||
return $default;
|
||||
}
|
||||
|
||||
foreach ($filter as $field => &$value)
|
||||
{
|
||||
$value = $field.'='.var_export($value, true);
|
||||
}
|
||||
trigger_error(
|
||||
'no such '.$this->_table.' ('.implode(', ', $filter).')',
|
||||
E_USER_ERROR
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $filter Filter the entries must match.
|
||||
*
|
||||
* @return Bean[]
|
||||
*/
|
||||
function get(array $filter = array())
|
||||
{
|
||||
$entries = $this->_database->get(
|
||||
$this->_table,
|
||||
$filter
|
||||
);
|
||||
|
||||
$class = $this->_bean;
|
||||
foreach ($entries as &$entry)
|
||||
{
|
||||
$entry = new $class($entry, true);
|
||||
}
|
||||
return $entries;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function getArray($filter = null, $fields = null)
|
||||
{
|
||||
return $this->_database->get(
|
||||
$this->_table,
|
||||
$filter,
|
||||
$fields
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function save(\Rekodi\Bean $bean)
|
||||
{
|
||||
$dirty = $bean->getDirty();
|
||||
if (!$dirty)
|
||||
{
|
||||
// Nothing has changed.
|
||||
return;
|
||||
}
|
||||
|
||||
$n = $this->_database->update(
|
||||
$this->_table,
|
||||
array('id' => $bean->id),
|
||||
$bean->getDirty()
|
||||
);
|
||||
|
||||
if (1 !== $n)
|
||||
{
|
||||
trigger_error(
|
||||
'unexpected number of updated '.$this->_table.' ('.$n.')',
|
||||
E_USER_ERROR
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @var \Rekodi\Manager
|
||||
*/
|
||||
protected $_database;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $_table;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $_bean;
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is a part of Xen Orchestra Server.
|
||||
*
|
||||
* Xen Orchestra Server is free software: you can redistribute it
|
||||
* and/or modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* Xen Orchestra Server is distributed in the hope that it will be
|
||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Xen Orchestra Server. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Julien Fontanet <julien.fontanet@vates.fr>
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0-standalone.html GPLv3
|
||||
*
|
||||
* @package Xen Orchestra Server
|
||||
*/
|
||||
|
||||
namespace Manager;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
final class Messages extends XCPAbstract
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function __construct(\Rekodi\Manager $manager)
|
||||
{
|
||||
parent::__construct($manager, 'messages', '\Bean\Message');
|
||||
}
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is a part of Xen Orchestra Server.
|
||||
*
|
||||
* Xen Orchestra Server is free software: you can redistribute it
|
||||
* and/or modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* Xen Orchestra Server is distributed in the hope that it will be
|
||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Xen Orchestra Server. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Julien Fontanet <julien.fontanet@vates.fr>
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0-standalone.html GPLv3
|
||||
*
|
||||
* @package Xen Orchestra Server
|
||||
*/
|
||||
|
||||
namespace Manager;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
final class Networks extends XCPAbstract
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function __construct(\Rekodi\Manager $manager)
|
||||
{
|
||||
parent::__construct($manager, 'networks', '\Bean\Network');
|
||||
}
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is a part of Xen Orchestra Server.
|
||||
*
|
||||
* Xen Orchestra Server is free software: you can redistribute it
|
||||
* and/or modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* Xen Orchestra Server is distributed in the hope that it will be
|
||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Xen Orchestra Server. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Julien Fontanet <julien.fontanet@vates.fr>
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0-standalone.html GPLv3
|
||||
*
|
||||
* @package Xen Orchestra Server
|
||||
*/
|
||||
|
||||
namespace Manager;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
final class PBDs extends XCPAbstract
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function __construct(\Rekodi\Manager $manager)
|
||||
{
|
||||
parent::__construct($manager, 'pbds', '\Bean\PBD');
|
||||
}
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is a part of Xen Orchestra Server.
|
||||
*
|
||||
* Xen Orchestra Server is free software: you can redistribute it
|
||||
* and/or modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* Xen Orchestra Server is distributed in the hope that it will be
|
||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Xen Orchestra Server. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Julien Fontanet <julien.fontanet@vates.fr>
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0-standalone.html GPLv3
|
||||
*
|
||||
* @package Xen Orchestra Server
|
||||
*/
|
||||
|
||||
namespace Manager;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
final class PIFs extends XCPAbstract
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function __construct(\Rekodi\Manager $manager)
|
||||
{
|
||||
parent::__construct($manager, 'pifs', '\Bean\PIF');
|
||||
}
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is a part of Xen Orchestra Server.
|
||||
*
|
||||
* Xen Orchestra Server is free software: you can redistribute it
|
||||
* and/or modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* Xen Orchestra Server is distributed in the hope that it will be
|
||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Xen Orchestra Server. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Julien Fontanet <julien.fontanet@vates.fr>
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0-standalone.html GPLv3
|
||||
*
|
||||
* @package Xen Orchestra Server
|
||||
*/
|
||||
|
||||
namespace Manager;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
final class PIFsMetrics extends XCPAbstract
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function __construct(\Rekodi\Manager $manager)
|
||||
{
|
||||
parent::__construct($manager, 'pifs_metrics', '\Bean\PIFMetrics');
|
||||
}
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is a part of Xen Orchestra Server.
|
||||
*
|
||||
* Xen Orchestra Server is free software: you can redistribute it
|
||||
* and/or modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* Xen Orchestra Server is distributed in the hope that it will be
|
||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Xen Orchestra Server. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Julien Fontanet <julien.fontanet@vates.fr>
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0-standalone.html GPLv3
|
||||
*
|
||||
* @package Xen Orchestra Server
|
||||
*/
|
||||
|
||||
namespace Manager;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
final class Pools extends XCPAbstract
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function __construct(\Rekodi\Manager $manager)
|
||||
{
|
||||
parent::__construct($manager, 'pools', '\Bean\Pool');
|
||||
}
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is a part of Xen Orchestra Server.
|
||||
*
|
||||
* Xen Orchestra Server is free software: you can redistribute it
|
||||
* and/or modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* Xen Orchestra Server is distributed in the hope that it will be
|
||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Xen Orchestra Server. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Julien Fontanet <julien.fontanet@vates.fr>
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0-standalone.html GPLv3
|
||||
*
|
||||
* @package Xen Orchestra Server
|
||||
*/
|
||||
|
||||
namespace Manager;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
final class SRs extends XCPAbstract
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function __construct(\Rekodi\Manager $manager)
|
||||
{
|
||||
parent::__construct(
|
||||
$manager,
|
||||
'srs',
|
||||
'\Bean\SR'
|
||||
);
|
||||
}
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is a part of Xen Orchestra Server.
|
||||
*
|
||||
* Xen Orchestra Server is free software: you can redistribute it
|
||||
* and/or modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* Xen Orchestra Server is distributed in the hope that it will be
|
||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Xen Orchestra Server. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Julien Fontanet <julien.fontanet@vates.fr>
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0-standalone.html GPLv3
|
||||
*
|
||||
* @package Xen Orchestra Server
|
||||
*/
|
||||
|
||||
namespace Manager;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
final class Tokens extends ManagerAbstract
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function __construct(\Rekodi\Manager $manager)
|
||||
{
|
||||
parent::__construct($manager, 'tokens', '\Bean\Token');
|
||||
}
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is a part of Xen Orchestra Server.
|
||||
*
|
||||
* Xen Orchestra Server is free software: you can redistribute it
|
||||
* and/or modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* Xen Orchestra Server is distributed in the hope that it will be
|
||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Xen Orchestra Server. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Julien Fontanet <julien.fontanet@vates.fr>
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0-standalone.html GPLv3
|
||||
*
|
||||
* @package Xen Orchestra Server
|
||||
*/
|
||||
|
||||
namespace Manager;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
final class Users extends ManagerAbstract
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function __construct(\Rekodi\Manager $manager)
|
||||
{
|
||||
parent::__construct($manager, 'users', '\Bean\User');
|
||||
}
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is a part of Xen Orchestra Server.
|
||||
*
|
||||
* Xen Orchestra Server is free software: you can redistribute it
|
||||
* and/or modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* Xen Orchestra Server is distributed in the hope that it will be
|
||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Xen Orchestra Server. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Julien Fontanet <julien.fontanet@vates.fr>
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0-standalone.html GPLv3
|
||||
*
|
||||
* @package Xen Orchestra Server
|
||||
*/
|
||||
|
||||
namespace Manager;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
final class VBDs extends XCPAbstract
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function __construct(\Rekodi\Manager $manager)
|
||||
{
|
||||
parent::__construct($manager, 'vbds', '\Bean\VBD');
|
||||
}
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is a part of Xen Orchestra Server.
|
||||
*
|
||||
* Xen Orchestra Server is free software: you can redistribute it
|
||||
* and/or modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* Xen Orchestra Server is distributed in the hope that it will be
|
||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Xen Orchestra Server. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Julien Fontanet <julien.fontanet@vates.fr>
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0-standalone.html GPLv3
|
||||
*
|
||||
* @package Xen Orchestra Server
|
||||
*/
|
||||
|
||||
namespace Manager;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
final class VDIs extends XCPAbstract
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function __construct(\Rekodi\Manager $manager)
|
||||
{
|
||||
parent::__construct($manager, 'vdis', '\Bean\VDI');
|
||||
}
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is a part of Xen Orchestra Server.
|
||||
*
|
||||
* Xen Orchestra Server is free software: you can redistribute it
|
||||
* and/or modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* Xen Orchestra Server is distributed in the hope that it will be
|
||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Xen Orchestra Server. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Julien Fontanet <julien.fontanet@vates.fr>
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0-standalone.html GPLv3
|
||||
*
|
||||
* @package Xen Orchestra Server
|
||||
*/
|
||||
|
||||
namespace Manager;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
final class VIFs extends XCPAbstract
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function __construct(\Rekodi\Manager $manager)
|
||||
{
|
||||
parent::__construct($manager, 'vifs', '\Bean\VIF');
|
||||
}
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is a part of Xen Orchestra Server.
|
||||
*
|
||||
* Xen Orchestra Server is free software: you can redistribute it
|
||||
* and/or modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* Xen Orchestra Server is distributed in the hope that it will be
|
||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Xen Orchestra Server. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Julien Fontanet <julien.fontanet@vates.fr>
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0-standalone.html GPLv3
|
||||
*
|
||||
* @package Xen Orchestra Server
|
||||
*/
|
||||
|
||||
namespace Manager;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
final class VMs extends XCPAbstract
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function __construct(\Rekodi\Manager $manager)
|
||||
{
|
||||
parent::__construct($manager, 'vms', '\Bean\VM');
|
||||
}
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is a part of Xen Orchestra Server.
|
||||
*
|
||||
* Xen Orchestra Server is free software: you can redistribute it
|
||||
* and/or modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* Xen Orchestra Server is distributed in the hope that it will be
|
||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Xen Orchestra Server. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Julien Fontanet <julien.fontanet@vates.fr>
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0-standalone.html GPLv3
|
||||
*
|
||||
* @package Xen Orchestra Server
|
||||
*/
|
||||
|
||||
namespace Manager;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
final class VMsGuestMetrics extends XCPAbstract
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function __construct(\Rekodi\Manager $manager)
|
||||
{
|
||||
parent::__construct(
|
||||
$manager,
|
||||
'vms_guest_metrics',
|
||||
'\Bean\VMGuestMetrics'
|
||||
);
|
||||
}
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is a part of Xen Orchestra Server.
|
||||
*
|
||||
* Xen Orchestra Server is free software: you can redistribute it
|
||||
* and/or modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* Xen Orchestra Server is distributed in the hope that it will be
|
||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Xen Orchestra Server. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Julien Fontanet <julien.fontanet@vates.fr>
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0-standalone.html GPLv3
|
||||
*
|
||||
* @package Xen Orchestra Server
|
||||
*/
|
||||
|
||||
namespace Manager;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
final class VMsMetrics extends XCPAbstract
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function __construct(\Rekodi\Manager $manager)
|
||||
{
|
||||
parent::__construct(
|
||||
$manager,
|
||||
'vms_metrics',
|
||||
'\Bean\VMMetrics'
|
||||
);
|
||||
}
|
||||
}
|
@ -1,82 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is a part of Xen Orchestra Server.
|
||||
*
|
||||
* Xen Orchestra Server is free software: you can redistribute it
|
||||
* and/or modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* Xen Orchestra Server is distributed in the hope that it will be
|
||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Xen Orchestra Server. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Julien Fontanet <julien.fontanet@vates.fr>
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0-standalone.html GPLv3
|
||||
*
|
||||
* @package Xen Orchestra Server
|
||||
*/
|
||||
|
||||
namespace Manager;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
abstract class XCPAbstract extends ManagerAbstract
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function batchImport(array $objects)
|
||||
{
|
||||
// Used for development to print bean's attributes.
|
||||
// $object = reset($objects);
|
||||
// ksort($object);
|
||||
// foreach ($object as $field => $value)
|
||||
// {
|
||||
// var_export($field);
|
||||
// if (is_array($value) || is_object($value))
|
||||
// {
|
||||
// echo ' => true';
|
||||
// }
|
||||
// echo ",\n";
|
||||
// }
|
||||
|
||||
foreach ($objects as $ref => $properties)
|
||||
{
|
||||
$properties['id'] = $ref;
|
||||
|
||||
$n = $this->_database->update(
|
||||
$this->_table,
|
||||
array('id' => $ref),
|
||||
$properties
|
||||
);
|
||||
|
||||
if (1 === $n)
|
||||
{
|
||||
echo $this->_table.': updated ('.$ref.')', PHP_EOL;
|
||||
}
|
||||
elseif (0 === $n)
|
||||
{
|
||||
$this->_database->create(
|
||||
$this->_table,
|
||||
array($properties)
|
||||
);
|
||||
|
||||
echo $this->_table.': new ('.$ref.')', PHP_EOL;
|
||||
}
|
||||
else
|
||||
{
|
||||
trigger_error(
|
||||
'unexpected number of updated '.$this->_table.' ('.$n.')',
|
||||
E_USER_ERROR
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
205
lib/XCP.php
205
lib/XCP.php
@ -1,205 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is a part of Xen Orchestra Server.
|
||||
*
|
||||
* Xen Orchestra Server is free software: you can redistribute it
|
||||
* and/or modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* Xen Orchestra Server is distributed in the hope that it will be
|
||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Xen Orchestra Server. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Julien Fontanet <julien.fontanet@vates.fr>
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0-standalone.html GPLv3
|
||||
*
|
||||
* @package Xen Orchestra Server
|
||||
*/
|
||||
|
||||
/**
|
||||
* @todo Implements buffering as in Client.
|
||||
*/
|
||||
final class XCP extends Base
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function __construct(Loop $loop, $url, $user, $password)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->_loop = $loop;
|
||||
$this->_url = $url;
|
||||
|
||||
$this->_queue[] = array(
|
||||
array($this, '_setToken'),
|
||||
'session.login_with_password',
|
||||
array($user, $password)
|
||||
);
|
||||
$this->_next();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function queue($method, array $params = null, $callback = null)
|
||||
{
|
||||
($params !== null)
|
||||
or $params = array();
|
||||
|
||||
$this->_queue[] = array($callback, $method, $params);
|
||||
|
||||
if (count($this->_queue) === 1)
|
||||
{
|
||||
$this->_next();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function onData($handle)
|
||||
{
|
||||
$this->_buf .= stream_get_contents($handle);
|
||||
|
||||
if (!feof($handle))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Reads the response.
|
||||
list(, $response) = explode("\r\n\r\n", $this->_buf, 2);
|
||||
$this->_buf = '';
|
||||
|
||||
$_ = xmlrpc_decode($response);
|
||||
if (null === $_)
|
||||
{
|
||||
trigger_error(
|
||||
'invalid XML-RPC: '.$response,
|
||||
E_USER_ERROR
|
||||
);
|
||||
}
|
||||
|
||||
if (!isset($_['Value']))
|
||||
{
|
||||
trigger_error(
|
||||
'Invalid response: '.var_export($_, true),
|
||||
E_USER_ERROR
|
||||
);
|
||||
}
|
||||
$response = $_['Value'];
|
||||
|
||||
// Notifies.
|
||||
$request = array_shift($this->_queue);
|
||||
if ($request[0] !== null)
|
||||
{
|
||||
$result = call_user_func($request[0], $response, $this);
|
||||
if ($result === true)
|
||||
{
|
||||
$this->_queue[] = $request;
|
||||
}
|
||||
}
|
||||
|
||||
// Sends the next request if any.
|
||||
if ($this->_queue)
|
||||
{
|
||||
$this->_next();
|
||||
}
|
||||
|
||||
// Stops reading this socket.
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private function _next()
|
||||
{
|
||||
$_ = parse_url($this->_url);
|
||||
$https = isset($_['scheme']) && !strcasecmp($_['scheme'], 'https');
|
||||
$port = isset($_['port']) ? $_['port'] : ($https ? 443 : 80);
|
||||
$host = isset($_['host']) ? $_['host'] : '127.0.0.1';
|
||||
$query = isset($_['query']) ? '?'.$_['query'] : '';
|
||||
$path = isset($_['path']) ? $_['path'] : '/';
|
||||
|
||||
list(, $method, $params) = reset($this->_queue);
|
||||
isset($this->_tok)
|
||||
and array_unshift($params, $this->_tok);
|
||||
|
||||
$data = xmlrpc_encode_request($method, $params, array(
|
||||
'verbosity' => 'no_white_space',
|
||||
'encoding' => 'UTF-8',
|
||||
));
|
||||
|
||||
$request = implode("\r\n", array(
|
||||
"POST $path HTTP/1.1",
|
||||
"Host: $host:$port",
|
||||
'Connection: close',
|
||||
'Content-Type: text/xml; charset=UTF-8',
|
||||
'Content-Length: '.strlen($data),
|
||||
'',
|
||||
$data
|
||||
));
|
||||
|
||||
$hdl = @stream_socket_client(
|
||||
($https ? 'tls' : 'tcp')."://$host:$port",
|
||||
/* out */ $errno,
|
||||
/* out */ $errstr,
|
||||
ini_get('default_socket_timeout'), // Default value.
|
||||
STREAM_CLIENT_CONNECT
|
||||
);
|
||||
if (!$hdl)
|
||||
{
|
||||
trigger_error(
|
||||
"cannot connect to {$this->_url}: $errno - $errstr",
|
||||
E_USER_ERROR
|
||||
);
|
||||
}
|
||||
|
||||
stream_set_blocking($hdl, false);
|
||||
fwrite($hdl, $request);
|
||||
|
||||
$this->_loop->addRead($hdl, array($this, 'onData'));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private function _setToken($token)
|
||||
{
|
||||
$this->_tok = $token;
|
||||
}
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $_buf = '';
|
||||
|
||||
/**
|
||||
* @var Loop
|
||||
*/
|
||||
private $_loop;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $_url;
|
||||
|
||||
/**
|
||||
* Session token.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_tok;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $_queue = array();
|
||||
}
|
@ -264,7 +264,7 @@ Api.fn.user = {
|
||||
return this.checkPermission(session, 'admin').then(function () {
|
||||
return users.create(p_email, p_pass, p_perm);
|
||||
}).then(function (user) {
|
||||
return (''+ user.get('id'));
|
||||
return (''+ user.id);
|
||||
});
|
||||
},
|
||||
|
||||
@ -439,7 +439,7 @@ Api.fn.token = {
|
||||
// @todo Token permission.
|
||||
|
||||
return this.xo.tokens.generate(user_id).then(function (token) {
|
||||
return token.get('id');
|
||||
return token.id;
|
||||
});
|
||||
},
|
||||
|
||||
|
194
src/main.js
194
src/main.js
@ -13,7 +13,9 @@ var Api = require('./api');
|
||||
var api = new Api(xo);
|
||||
|
||||
// @todo Port should be configurable.
|
||||
var http_serv = require('http').createServer().listen(8080);
|
||||
var http_serv = require('http').createServer().listen(8080).on('listening', function () {
|
||||
console.log('XO-Server Web server is listening on port '+ 8080 +'.');
|
||||
});
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -113,56 +115,56 @@ xo.on('started', function () {
|
||||
// be encoded using Base64.
|
||||
|
||||
// @todo Avoid Base64 encoding and directly use binary streams.
|
||||
xo.on('started', function () {
|
||||
var server = new WSServer({
|
||||
'server': http_serv,
|
||||
'path': '/websockify',
|
||||
});
|
||||
// xo.on('started', function () {
|
||||
// var server = new WSServer({
|
||||
// 'server': http_serv,
|
||||
// 'path': '/websockify',
|
||||
// });
|
||||
|
||||
server.on('connection', function (socket) {
|
||||
// Parses the first message which SHOULD contains the host and
|
||||
// port of the host to connect to.
|
||||
socket.once('message', function (message) {
|
||||
try
|
||||
{
|
||||
message = JSON.parse(message);
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
socket.close();
|
||||
return;
|
||||
}
|
||||
// server.on('connection', function (socket) {
|
||||
// // Parses the first message which SHOULD contains the host and
|
||||
// // port of the host to connect to.
|
||||
// socket.once('message', function (message) {
|
||||
// try
|
||||
// {
|
||||
// message = JSON.parse(message);
|
||||
// }
|
||||
// catch (e)
|
||||
// {
|
||||
// socket.close();
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (!message.host && !message.port)
|
||||
{
|
||||
socket.close();
|
||||
return;
|
||||
}
|
||||
// if (!message.host && !message.port)
|
||||
// {
|
||||
// socket.close();
|
||||
// return;
|
||||
// }
|
||||
|
||||
var target = tcp.createConnection(message.port, message.host);
|
||||
target.on('data', function (data) {
|
||||
socket.send(data.toString('base64'));
|
||||
});
|
||||
target.on('end', function () {
|
||||
socket.close();
|
||||
});
|
||||
target.on('error', function () {
|
||||
target.end();
|
||||
});
|
||||
// var target = tcp.createConnection(message.port, message.host);
|
||||
// target.on('data', function (data) {
|
||||
// socket.send(data.toString('base64'));
|
||||
// });
|
||||
// target.on('end', function () {
|
||||
// socket.close();
|
||||
// });
|
||||
// target.on('error', function () {
|
||||
// target.end();
|
||||
// });
|
||||
|
||||
socket.on('message', function (message) {
|
||||
target.write(new Buffer(message, 'base64'));
|
||||
});
|
||||
socket.on('close', function () {
|
||||
target.end();
|
||||
});
|
||||
});
|
||||
// socket.on('message', function (message) {
|
||||
// target.write(new Buffer(message, 'base64'));
|
||||
// });
|
||||
// socket.on('close', function () {
|
||||
// target.end();
|
||||
// });
|
||||
// });
|
||||
|
||||
socket.on('error', function () {
|
||||
socket.close();
|
||||
});
|
||||
});
|
||||
});
|
||||
// socket.on('error', function () {
|
||||
// socket.close();
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// JSON-RPC over WebSocket.
|
||||
@ -201,66 +203,66 @@ xo.on('started', function () {
|
||||
// JSON-RPC over TCP.
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
xo.on('started', function () {
|
||||
require('net').createServer(function (socket) {
|
||||
var session = new Session(xo);
|
||||
session.on('close', function () {
|
||||
socket.end(); // @todo Check it is enough.
|
||||
});
|
||||
// xo.on('started', function () {
|
||||
// require('net').createServer(function (socket) {
|
||||
// var session = new Session(xo);
|
||||
// session.on('close', function () {
|
||||
// socket.end(); // @todo Check it is enough.
|
||||
// });
|
||||
|
||||
var length = null; // Expected message length.
|
||||
var buffer = new Buffer(1024); // @todo I hate hardcoded values!
|
||||
socket.on('data', function (data) {
|
||||
data.copy(buffer);
|
||||
// var length = null; // Expected message length.
|
||||
// var buffer = new Buffer(1024); // @todo I hate hardcoded values!
|
||||
// socket.on('data', function (data) {
|
||||
// data.copy(buffer);
|
||||
|
||||
// Read the message length.
|
||||
if (!length)
|
||||
{
|
||||
var i = _.indexOf(buffer, 10);
|
||||
if (-1 === i)
|
||||
{
|
||||
return;
|
||||
}
|
||||
// // Read the message length.
|
||||
// if (!length)
|
||||
// {
|
||||
// var i = _.indexOf(buffer, 10);
|
||||
// if (-1 === i)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
|
||||
length = +(buffer.toString('ascii', 0, i));
|
||||
// length = +(buffer.toString('ascii', 0, i));
|
||||
|
||||
// If the length is NaN, we cannot do anything except
|
||||
// closing the connection.
|
||||
if (length !== length)
|
||||
{
|
||||
session.close();
|
||||
return;
|
||||
}
|
||||
// // If the length is NaN, we cannot do anything except
|
||||
// // closing the connection.
|
||||
// if (length !== length)
|
||||
// {
|
||||
// session.close();
|
||||
// return;
|
||||
// }
|
||||
|
||||
buffer = buffer.slice(i + 1);
|
||||
}
|
||||
// buffer = buffer.slice(i + 1);
|
||||
// }
|
||||
|
||||
// We do not have received everything.
|
||||
if (buffer.length < length)
|
||||
{
|
||||
return;
|
||||
}
|
||||
// // We do not have received everything.
|
||||
// if (buffer.length < length)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
|
||||
json_api_call(
|
||||
session,
|
||||
buffer.slice(0, length).toString()
|
||||
).then(function (response) {
|
||||
// @todo Handle long messages.
|
||||
socket.write(response.length +'\n'+ response);
|
||||
}).done();
|
||||
// json_api_call(
|
||||
// session,
|
||||
// buffer.slice(0, length).toString()
|
||||
// ).then(function (response) {
|
||||
// // @todo Handle long messages.
|
||||
// socket.write(response.length +'\n'+ response);
|
||||
// }).done();
|
||||
|
||||
// @todo Check it frees the memory.
|
||||
buffer = buffer.slice(length);
|
||||
// // @todo Check it frees the memory.
|
||||
// buffer = buffer.slice(length);
|
||||
|
||||
length = null;
|
||||
});
|
||||
// length = null;
|
||||
// });
|
||||
|
||||
// @todo Ugly inter dependency.
|
||||
socket.once('close', function () {
|
||||
session.close();
|
||||
});
|
||||
}).listen(1024); // @todo Should be configurable.
|
||||
});
|
||||
// // @todo Ugly inter dependency.
|
||||
// socket.once('close', function () {
|
||||
// session.close();
|
||||
// });
|
||||
// }).listen(1024); // @todo Should be configurable.
|
||||
// });
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user