本文整理汇总了PHP中resource类的典型用法代码示例。如果您正苦于以下问题:PHP resource类的具体用法?PHP resource怎么用?PHP resource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了resource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: openqrm_dhcpd_appliance
function openqrm_dhcpd_appliance($cmd, $appliance_fields)
{
global $OPENQRM_SERVER_BASE_DIR;
global $OPENQRM_EXEC_PORT;
$openqrm_server = new openqrm_server();
$OPENQRM_SERVER_IP_ADDRESS = $openqrm_server->get_ip_address();
$event = new event();
$appliance_id = $appliance_fields["appliance_id"];
$appliance_name = $appliance_fields["appliance_name"];
$resource = new resource();
$resource->get_instance_by_id($appliance_fields["appliance_resources"]);
$resource_mac = $resource->mac;
$resource_ip = $resource->ip;
$appliance = new appliance();
$appliance->get_instance_by_id($appliance_id);
if ($resource->id == "-1" || $resource->id == "") {
return;
}
$event->log("openqrm_dhcpd_appliance", $_SERVER['REQUEST_TIME'], 5, "openqrm-dhcpd-appliance-hook.php", "Handling {$cmd} event {$appliance_id}/{$appliance_name}/{$resource_ip}/{$resource_mac}", "", "", 0, 0, $resource->id);
switch ($cmd) {
case "start":
$event->log("openqrm_dhcpd_appliance", $_SERVER['REQUEST_TIME'], 5, "openqrm-dhcpd-appliance-hook.php", "Adding hostname " . $appliance->name . " from resource " . $resource->id . ".", "", "", 0, 0, $resource->id);
$dhcpd_command = $OPENQRM_SERVER_BASE_DIR . "/openqrm/plugins/dhcpd/bin/openqrm-dhcpd-appliance add_hostname -m " . $resource_mac . " -n " . $appliance->name . " -d " . $resource->id . " --openqrm-cmd-mode background";
$openqrm_server->send_command($dhcpd_command);
break;
case "stop":
$event->log("openqrm_dhcpd_appliance", $_SERVER['REQUEST_TIME'], 5, "openqrm-dhcpd-appliance-hook.php", "Removing hostname " . $appliance->name . " from resource " . $resource->id . ".", "", "", 0, 0, $resource->id);
$dhcpd_command = $OPENQRM_SERVER_BASE_DIR . "/openqrm/plugins/dhcpd/bin/openqrm-dhcpd-appliance remove_hostname -m " . $resource_mac . " -n " . $appliance->name . " -d " . $resource->id . " --openqrm-cmd-mode background";
$openqrm_server->send_command($dhcpd_command);
break;
}
}
示例2: get_lvm_iscsi_deployment_image_rootdevice_identifier
function get_lvm_iscsi_deployment_image_rootdevice_identifier($lvm_iscsi_storage_id)
{
global $OPENQRM_SERVER_BASE_DIR;
global $OPENQRM_ADMIN;
global $event;
// place for the storage stat files
$StorageDir = $_SERVER["DOCUMENT_ROOT"] . '/openqrm/base/plugins/lvm-storage/storage';
$rootdevice_identifier_array = array();
$storage = new storage();
$storage->get_instance_by_id($lvm_iscsi_storage_id);
$storage_resource = new resource();
$storage_resource->get_instance_by_id($storage->resource_id);
$storage_resource_id = $storage_resource->id;
$ident_file = "{$StorageDir}/{$storage_resource_id}.lv.lvm-iscsi-deployment.ident";
if (file_exists($ident_file)) {
unlink($ident_file);
}
// send command
$resource_command = "{$OPENQRM_SERVER_BASE_DIR}/openqrm/plugins/lvm-storage/bin/openqrm-lvm-storage post_identifier -t lvm-iscsi-deployment -u {$OPENQRM_ADMIN->name} -p {$OPENQRM_ADMIN->password}";
$storage_resource->send_command($storage_resource->ip, $resource_command);
if (!lvm_iscsi_deployment_wait_for_identfile($ident_file)) {
$event->log("get_image_rootdevice_identifier", $_SERVER['REQUEST_TIME'], 2, "image.lvm-iscsi-deployment", "Timeout while requesting image identifier from storage id {$storage->id}", "", "", 0, 0, 0);
return;
}
$fcontent = file($ident_file);
foreach ($fcontent as $lun_info) {
$tpos = strpos($lun_info, ",");
$timage_name = trim(substr($lun_info, 0, $tpos));
$troot_device = trim(substr($lun_info, $tpos + 1));
$rootdevice_identifier_array[] = array("value" => "{$troot_device}", "label" => "{$timage_name}");
}
return $rootdevice_identifier_array;
}
示例3: get_nagios3_appliance_link
function get_nagios3_appliance_link($appliance_id)
{
global $event;
global $OPENQRM_SERVER_BASE_DIR;
global $OPENQRM_SERVER_IP_ADDRESS;
global $OPENQRM_EXEC_PORT;
$p_appliance = new appliance();
$p_appliance->get_instance_by_id($appliance_id);
$p_resource = new resource();
$p_resource->get_instance_by_id($p_appliance->resources);
$nagios_link = "/openqrm/base/index.php?name=Nagios3&iframe=/cgi-bin/nagios3/status.cgi?host=" . $p_appliance->name;
$html = new htmlobject($OPENQRM_SERVER_BASE_DIR . '/openqrm/web/base/class/htmlobjects');
$a = $html->a();
// $a->label = '<img title="Service monitoring" alt="Service monitoring" height="24" width="24" src="/openqrm/base/plugins/nagios3/img/plugin.png" border=0>';
$a->label = 'nagios';
$a->css = 'badge';
$a->href = $nagios_link;
$a->handler = '';
$plugin_link = $a;
if ($p_resource->id == 0) {
$plugin_link = $a;
}
if ($p_resource->id == '') {
$plugin_link = "";
}
return $plugin_link;
}
示例4: get_novnc_appliance_link
function get_novnc_appliance_link($appliance_id)
{
global $event;
global $OPENQRM_SERVER_BASE_DIR;
global $OPENQRM_SERVER_IP_ADDRESS;
global $OPENQRM_EXEC_PORT;
$p_appliance = new appliance();
$p_appliance->get_instance_by_id($appliance_id);
$p_resource = new resource();
$p_resource->get_instance_by_id($p_appliance->resources);
$virtualization = new virtualization();
$virtualization->get_instance_by_id($p_appliance->virtualization);
$html = new htmlobject($OPENQRM_SERVER_BASE_DIR . '/openqrm/web/base/class/htmlobjects');
$a = $html->a();
$a->label = 'noVNC';
$a->css = 'badge';
$a->handler = 'onclick="wait();"';
$plugin_link = '';
if (strstr($p_appliance->state, "active")) {
if (strstr($virtualization->type, '-vm-')) {
$a->href = '/openqrm/base/index.php?plugin=novnc&controller=novnc&novnc_action=console&appliance_id=' . $p_appliance->id;
} else {
$a->href = '/openqrm/base/index.php?plugin=novnc&controller=novnc&novnc_action=login&appliance_id=' . $p_appliance->id;
}
$plugin_link = $a;
} else {
if ($p_resource->id === '0') {
$a->href = '/openqrm/base/index.php?plugin=novnc&controller=novnc&novnc_action=login&appliance_id=' . $p_appliance->id;
$plugin_link = $a;
}
}
return $plugin_link;
}
示例5: get_sshterm_appliance_link
function get_sshterm_appliance_link($appliance_id)
{
global $event;
global $OPENQRM_SERVER_BASE_DIR;
global $OPENQRM_SERVER_IP_ADDRESS;
global $OPENQRM_EXEC_PORT;
$p_appliance = new appliance();
$p_appliance->get_instance_by_id($appliance_id);
$p_resource = new resource();
$p_resource->get_instance_by_id($p_appliance->resources);
// get the parameters from the plugin config file
$OPENQRM_PLUGIN_SSHTERM_CONFIG_FILE = "{$OPENQRM_SERVER_BASE_DIR}/openqrm/plugins/sshterm/etc/openqrm-plugin-sshterm.conf";
$store = openqrm_parse_conf($OPENQRM_PLUGIN_SSHTERM_CONFIG_FILE);
extract($store);
$sshterm_login_ip = $p_resource->ip;
$sshterm_window = 'window' . str_replace('.', '', $sshterm_login_ip);
$sshterm_login_url = "https://{$sshterm_login_ip}:{$OPENQRM_PLUGIN_WEBSHELL_PORT}";
$html = new htmlobject($OPENQRM_SERVER_BASE_DIR . '/openqrm/web/base/class/htmlobjects');
$a = $html->a();
$a->label = 'SSHTerm';
$a->css = 'badge';
$a->href = '#';
$a->handler = 'onclick="sshwindow = window.open(\'' . $sshterm_login_url . '\',\'' . $sshterm_window . '\', \'location=0,status=0,scrollbars=yes,resizable=yes,width=972,height=500,left=100,top=100,screenX=400,screenY=100\'); sshwindow.focus(); return false;"';
$plugin_link = '';
if (strstr($p_appliance->state, "active")) {
$plugin_link = $a;
}
if ($p_resource->id == 0) {
$plugin_link = $a;
}
if ($p_resource->id == '') {
$plugin_link = "";
}
return $plugin_link;
}
示例6: get_lcmc_appliance_link
function get_lcmc_appliance_link($appliance_id)
{
global $event;
global $OPENQRM_SERVER_BASE_DIR;
global $OPENQRM_SERVER_IP_ADDRESS;
global $OPENQRM_EXEC_PORT;
$p_appliance = new appliance();
$p_appliance->get_instance_by_id($appliance_id);
$p_resource = new resource();
$p_resource->get_instance_by_id($p_appliance->resources);
$lcmc_gui = "/openqrm/base/plugins/lcmc/lcmc-gui.php";
$icon_size = "width='24' height='24'";
$icon_title = "Configure appliaction highavailability";
$html = new htmlobject($OPENQRM_SERVER_BASE_DIR . '/openqrm/web/base/class/htmlobjects');
$a = $html->a();
$a->label = 'LCMC';
//'<img title="'.$icon_title.'" alt="'.$icon_title.'" $icon_size src="/openqrm/base/plugins/lcmc/img/plugin.png" border=0>';
$a->css = 'badge';
$a->href = '#';
$a->handler = 'onclick="window.open(\'' . $lcmc_gui . '\',\'\', \'location=0,status=0,scrollbars=1,width=1150,height=800,left=50,top=50,screenX=50,screenY=50\');return false;"';
$plugin_link = '';
if (strstr($p_appliance->state, "active")) {
$plugin_link = $a;
}
if ($p_resource->id == 0) {
$plugin_link = $a;
}
if ($p_resource->id == '') {
$plugin_link = "";
}
return $plugin_link;
}
示例7: openqrm_template_deployment_resource_virtual_command
function openqrm_template_deployment_resource_virtual_command($cmd, $resource_fields)
{
global $event;
global $OPENQRM_SERVER_BASE_DIR;
global $OPENQRM_SERVER_IP_ADDRESS;
global $OPENQRM_EXEC_PORT;
$resource_id = $resource_fields["resource_id"];
$resource = new resource();
$resource->get_instance_by_id($resource_id);
$host_resource = new resource();
$host_resource->get_instance_by_id($resource->vhostid);
$event->log("openqrm_template_deployment_resource_virtual_command", $_SERVER['REQUEST_TIME'], 5, "openqrm-template_deployment-resource-virtual-command-hook.php", "Handling {$cmd} command of resource {$resource->id} on host {$host_resource->id}", "", "", 0, 0, 0);
switch ($cmd) {
case "reboot":
$event->log("openqrm_template_deployment_resource_virtual_command", $_SERVER['REQUEST_TIME'], 5, "openqrm-template_deployment-resource-virtual-command-hook.php", "Handling {$cmd} command", "", "", 0, 0, 0);
$virtual_command = $OPENQRM_SERVER_BASE_DIR . "/openqrm/plugins/template_deployment/bin/openqrm-template_deployment-vm restart_by_mac -m " . $resource->mac . " -d noop --openqrm-cmd-mode background";
// reboot conflicts with appliance stop, commented out for now
//$host_resource->send_command($host_resource->ip, $virtual_command);
break;
case "halt":
$event->log("openqrm_template_deployment_resource_virtual_command", $_SERVER['REQUEST_TIME'], 5, "openqrm-template_deployment-resource-virtual-command-hook.php", "Handling {$cmd} command", "", "", 0, 0, 0);
$virtual_command = $OPENQRM_SERVER_BASE_DIR . "/openqrm/plugins/template_deployment/bin/openqrm-template_deployment-vm stop_by_mac -m " . $resource->mac . " --openqrm-cmd-mode background";
$host_resource->send_command($host_resource->ip, $virtual_command);
break;
}
}
示例8: get_template_appliance_link
function get_template_appliance_link($appliance_id)
{
global $event;
global $OPENQRM_SERVER_BASE_DIR;
global $OPENQRM_SERVER_IP_ADDRESS;
global $OPENQRM_EXEC_PORT;
$p_appliance = new appliance();
$p_appliance->get_instance_by_id($appliance_id);
$p_resource = new resource();
$p_resource->get_instance_by_id($p_appliance->resources);
$html = new htmlobject($OPENQRM_SERVER_BASE_DIR . '/openqrm/web/base/class/htmlobjects');
$a = $html->a();
$a->label = 'Template';
$a->css = 'badge';
$a->href = '#';
$a->handler = 'onclick="window.open(\'Template-URL\',\'\', \'location=0,status=0,scrollbars=1,width=1150,height=800,left=50,top=50,screenX=50,screenY=50\');return false;"';
$plugin_link = '';
if (strstr($p_appliance->state, "active")) {
$plugin_link = $a;
}
if ($p_resource->id == 0) {
$plugin_link = $a;
}
if ($p_resource->id == '') {
$plugin_link = "";
}
return $plugin_link;
}
示例9: openqrm_template_appliance
function openqrm_template_appliance($cmd, $appliance_fields)
{
global $event;
global $OPENQRM_SERVER_BASE_DIR;
global $OPENQRM_SERVER_IP_ADDRESS;
global $OPENQRM_EXEC_PORT;
$appliance_id = $appliance_fields["appliance_id"];
$appliance_name = $appliance_fields["appliance_name"];
$resource = new resource();
$resource->get_instance_by_id($appliance_fields["appliance_resources"]);
$appliance_ip = $resource->ip;
// check appliance values, maybe we are in update and they are incomplete
if ($resource->id == "-1" || $resource->id == "") {
return;
}
$event->log("openqrm_new_appliance", $_SERVER['REQUEST_TIME'], 5, "openqrm-template-appliance-hook.php", "Handling {$cmd} event {$appliance_id}/{$appliance_name}/{$appliance_ip}", "", "", 0, 0, $appliance_id);
switch ($cmd) {
case "start":
$openqrm_server = new openqrm_server();
$openqrm_server->send_command($OPENQRM_SERVER_BASE_DIR . "/openqrm/plugins/template/bin/openqrm-template-manager start " . $appliance_id . " " . $appliance_name . " " . $appliance_ip . " --openqrm-cmd-mode background");
break;
case "stop":
$openqrm_server = new openqrm_server();
$openqrm_server->send_command($OPENQRM_SERVER_BASE_DIR . "/openqrm/plugins/template/bin/openqrm-template-manager stop " . $appliance_id . " " . $appliance_name . " " . $appliance_ip . " --openqrm-cmd-mode background");
break;
}
}
示例10: processJobData
/**
* 处理任务数据的回调方法
* @param function $callback
* @param resource $vendorInstance
* @param array $option
* @throws MyRuntimeException
*/
public static function processJobData($callback, $vendorInstance, $option = array())
{
$option += array('decode' => TRUE, 'delete' => TRUE, 'release' => FALSE, 'delay' => 10, 'priority' => 1024, 'timeout' => NULL);
$retData = NULL;
//echo 'proceed job data'.PHP_EOL;
//var_dump($vendorInstance);
$job = $vendorInstance->reserve($option['timeout']);
//var_dump($job);
if ($job) {
if ($option['decode'] == TRUE) {
$arg = self::decodeData($job->getData());
} else {
$arg = $job->getData();
}
if (!is_callable($callback)) {
throw new RuntimeException('process data error');
}
$retData = call_user_func($callback, $arg);
if (!$retData) {
if ($option['release'] == TRUE) {
$vendorInstance->release($job, $option['priority'], $option['delay']);
}
throw new RuntimeException('process data error');
}
if ($option['delete'] == TRUE) {
$vendorInstance->delete($job);
}
} else {
$arg = $job;
}
return $retData;
}
示例11: query
/**
* query
* @param string $sql
* @param resource $connResource
* @return array
*/
public function query($sql, $connResource)
{
$rows = array();
$result = $connResource->query($sql);
while ($row = $result->fetch_assoc()) {
$rows[] = $row;
}
return $rows;
}
示例12: __construct
/**
* Creates a new OCI8Statement that uses the given connection handle and SQL statement.
*
* @param resource $dbh The connection handle.
* @param string $statement The SQL statement.
*/
public function __construct($dbh, $statement, SQLite3Connection $conn)
{
list($statement, $paramMap) = self::convertPositionalToNamedPlaceholders($statement);
$this->_sth = $dbh->prepare($statement);
$this->_dbh = $dbh;
$this->_ret = null;
$this->_paramMap = $paramMap;
$this->_conn = $conn;
}
示例13: openqrm_nagios3_appliance
function openqrm_nagios3_appliance($cmd, $appliance_fields)
{
global $event;
global $OPENQRM_SERVER_BASE_DIR;
global $OPENQRM_SERVER_IP_ADDRESS;
global $OPENQRM_EXEC_PORT;
$appliance_id = $appliance_fields["appliance_id"];
$appliance = new appliance();
$appliance->get_instance_by_id($appliance_id);
$appliance_name = $appliance_fields["appliance_name"];
$resource = new resource();
$resource->get_instance_by_id($appliance_fields["appliance_resources"]);
$appliance_ip = $resource->ip;
// check appliance values, maybe we are in update and they are incomplete
if ($appliance->imageid == 1) {
return;
}
if ($resource->id == "-1" || $resource->id == "") {
return;
}
// get the nagios service checks
$nagios_host = new nagios3_host();
$nagios_host->get_instance_by_appliance_id($appliance_id);
$active_nagios_services = explode(',', $nagios_host->appliance_services);
$nagios_service_list = '';
foreach ($active_nagios_services as $service_id) {
$nagios_service = new nagios3_service();
$nagios_service->get_instance_by_id($service_id);
$nagios_service_list = $nagios_service_list . "," . $nagios_service->port;
}
$nagios_service_list = substr($nagios_service_list, 1);
if (!strlen($nagios_service_list)) {
$event->log("openqrm_new_appliance", $_SERVER['REQUEST_TIME'], 5, "openqrm-nagios3-appliance-hook.php", "Appliance {$appliance_id} has no configured nagios services, skipping...", "", "", 0, 0, $appliance_id);
return 0;
}
$event->log("openqrm_new_appliance", $_SERVER['REQUEST_TIME'], 5, "openqrm-nagios3-appliance-hook.php", "Handling {$cmd} event {$appliance_id}/{$appliance_name}/{$appliance_ip}", "", "", 0, 0, $appliance_id);
switch ($cmd) {
case "start":
$nagios_appliance_start_cmd = $OPENQRM_SERVER_BASE_DIR . "/openqrm/plugins/nagios3/bin/openqrm-nagios-manager add -n " . $appliance_name . " -i " . $resource->ip . " -p " . $nagios_service_list . " --openqrm-cmd-mode background";
$openqrm_server = new openqrm_server();
$openqrm_server->send_command($nagios_appliance_start_cmd, NULL, true);
break;
case "stop":
$nagios_appliance_stop_cmd = "{$OPENQRM_SERVER_BASE_DIR}/openqrm/plugins/nagios3/bin/openqrm-nagios-manager remove_host -n " . $appliance_name . " --openqrm-cmd-mode background";
$openqrm_server = new openqrm_server();
$openqrm_server->send_command($nagios_appliance_stop_cmd, NULL, true);
break;
case "remove":
$nagios_appliance_stop_cmd = "{$OPENQRM_SERVER_BASE_DIR}/openqrm/plugins/nagios3/bin/openqrm-nagios-manager remove_host -n " . $appliance_name . " --openqrm-cmd-mode background";
$openqrm_server = new openqrm_server();
$openqrm_server->send_command($nagios_appliance_stop_cmd, NULL, true);
// remove nagios_host from the db
$nagios_host->remove_by_appliance_id($appliance_id);
break;
}
}
示例14: getDeviceIp
/**
* @param $phoneArray
* @return bool|\Exception|\SoapFault
*/
public function getDeviceIp($phoneArray)
{
try {
$response = $this->client->SelectCmDevice('', ['MaxReturnedDevices' => '1000', 'Class' => 'Phone', 'Model' => '255', 'Status' => 'Any', 'NodeName' => '', 'SelectBy' => 'Name', 'SelectItems' => $phoneArray]);
} catch (SoapFault $E) {
// Loop if we get a RISPort error for exceeding maximum calls in 1 minute
if (preg_match('/^AxisFault: Exceeded allowed rate for Reatime information/', $E->faultstring)) {
sleep(30);
$this->getDeviceIp($phoneArray);
}
return $E;
}
/*
* No Errors
* Process Results
*/
return $response["SelectCmDeviceResult"];
$SelectCmDeviceResult = $response["SelectCmDeviceResult"];
/*
* Return results if they exist
* Or return false
*/
if ($SelectCmDeviceResult->CmNodes) {
return $SelectCmDeviceResult->CmNodes;
}
return false;
}
示例15: select
public function select($sql)
{
$result = $this->pdo->query($sql);
$result->setFetchMode(\PDO::FETCH_ASSOC);
$data = $result->fetchAll();
return $data;
}