本文整理汇总了PHP中resource::get_instance_by_id方法的典型用法代码示例。如果您正苦于以下问题:PHP resource::get_instance_by_id方法的具体用法?PHP resource::get_instance_by_id怎么用?PHP resource::get_instance_by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类resource
的用法示例。
在下文中一共展示了resource::get_instance_by_id方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: 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;
}
}
示例3: 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;
}
示例4: 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;
}
}
示例5: 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;
}
示例6: 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;
}
}
示例7: 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;
}
示例8: 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;
}
示例9: 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;
}
示例10: 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;
}
}
示例11: get_nagios3_appliance_edit
function get_nagios3_appliance_edit($appliance_id, $openqrm, $response)
{
$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);
if ($p_resource->id !== '') {
$a = $response->html->a();
$a->label = '<img title="Service monitoring" alt="Service monitoring" height="24" width="24" src="' . $openqrm->get('baseurl') . '/plugins/nagios3/img/plugin.png" border=0>';
$a->href = $openqrm->get('baseurl') . '/index.php?base=appliance&appliance_action=load_edit&aplugin=nagios3&appliance_id=' . $appliance_id . '&nagios3_action=edit';
return $a;
}
}
示例12: action
function action()
{
$resource = new resource();
$resource->get_instance_by_id(0);
$t = $this->response->html->template($this->tpldir . '/local-server-about-usage.tpl.php');
$t->add($this->response->html->thisfile, "thisfile");
$t->add($this->lang['label'], 'label');
$t->add($this->lang['usage_integrate_title'], 'usage_integrate_title');
$t->add($this->lang['usage_remove_title'], 'usage_remove_title');
$t->add(sprintf($this->lang['usage_integrate_content'], $this->basedir, $resource->ip), 'usage_integrate_content');
$t->add(sprintf($this->lang['usage_remove_content'], $resource->ip), 'usage_remove_content');
$t->add($this->openqrm->get('baseurl'), 'baseurl');
return $t;
}
示例13: appliance
function __construct($openqrm, $response)
{
$this->response = $response;
$this->openqrm = $openqrm;
$this->file = $openqrm->file();
$this->user = $openqrm->user();
$id = $this->response->html->request()->get('appliance_id');
$this->response->add('appliance_id', $id);
$this->response->add($this->identifier_name . '[]', '');
$appliance = new appliance();
$this->appliance = $appliance->get_instance_by_id($id);
$resource = new resource();
$this->resource = $resource->get_instance_by_id($this->appliance->resources);
$this->statfile = $this->openqrm->get('basedir') . '/plugins/network-manager/web/storage/' . $this->resource->id . '.network_stat';
}
示例14: storage
function __construct($openqrm, $response)
{
$this->response = $response;
$this->openqrm = $openqrm;
$this->file = $this->openqrm->file();
$this->openqrm = $openqrm;
$this->user = $openqrm->user();
$storage_id = $this->response->html->request()->get('storage_id');
$storage = new storage();
$resource = new resource();
$deployment = new deployment();
$this->storage = $storage->get_instance_by_id($storage_id);
$this->resource = $resource->get_instance_by_id($storage->resource_id);
$this->deployment = $deployment->get_instance_by_id($storage->type);
$this->response->add('storage_id', $storage_id);
}
示例15: storage
function __construct($openqrm, $response)
{
$this->openqrm = $openqrm;
$this->user = $this->openqrm->user();
$this->rootdir = $this->openqrm->get('webdir');
$this->response = $response;
$this->file = $this->openqrm->file();
$this->tpldir = $this->rootdir . '/plugins/device-manager/tpl';
$id = $this->response->html->request()->get('storage_id');
$this->response->add('storage_id', $id);
$this->response->add('volgroup', $this->response->html->request()->get('volgroup'));
$storage = new storage();
$this->storage = $storage->get_instance_by_id($id);
$resource = new resource();
$this->resource = $resource->get_instance_by_id($this->storage->resource_id);
$this->statfile = $this->openqrm->get('basedir') . '/plugins/device-manager/web/storage/' . $this->resource->id . '.device.stat';
}