• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP openqrm_server类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中openqrm_server的典型用法代码示例。如果您正苦于以下问题:PHP openqrm_server类的具体用法?PHP openqrm_server怎么用?PHP openqrm_server使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了openqrm_server类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: action

 function action()
 {
     $external_portal_name = $this->cloud_config->get_value(3);
     // 3 is the external name;
     if (!strlen($external_portal_name)) {
         $openqrm_server = new openqrm_server();
         $openqrm_server_ip = $openqrm_server->get_ip_address();
         $external_portal_name = "http://" . $openqrm_server_ip . "/cloud-portal";
     }
     $template = $this->response->html->template($this->tpldir . "/cloud-documentation-about.tpl.php");
     $template->add($this->lang['cloud_documentation_title'], 'title');
     $template->add($this->lang['cloud_documentation_intro'], 'cloud_documentation_intro');
     $template->add($this->lang['cloud_documentation_label'], 'cloud_documentation_label');
     $template->add($this->lang['cloud_documentation_setup'], 'cloud_documentation_setup');
     $template->add($this->lang['cloud_documentation_setup_title'], 'cloud_documentation_setup_title');
     $template->add($this->lang['cloud_documentation_setup_steps'], 'cloud_documentation_setup_steps');
     $template->add($this->lang['cloud_documentation_users'], 'cloud_documentation_users');
     $template->add($this->lang['cloud_documentation_create_user'], 'cloud_documentation_create_user');
     $template->add($this->lang['cloud_documentation_ip_management'], 'cloud_documentation_ip_management');
     $template->add($this->lang['cloud_documentation_ip_management_setup'], 'cloud_documentation_ip_management_setup');
     $template->add($this->lang['cloud_documentation_type_title'], 'cloud_documentation_type_title');
     $template->add($this->lang['cloud_documentation_type_content'], 'cloud_documentation_type_content');
     $template->add($this->lang['cloud_documentation_tested_title'], 'cloud_documentation_tested_title');
     $template->add($this->lang['cloud_documentation_tested_content'], 'cloud_documentation_tested_content');
     $template->add($this->lang['cloud_documentation_api'], 'cloud_documentation_api');
     $template->add($this->lang['cloud_documentation_soap'], 'cloud_documentation_soap');
     $template->add($this->lang['cloud_documentation_lockfile'], 'cloud_documentation_lockfile');
     $template->add(sprintf($this->lang['cloud_documentation_lockfile_details'], $this->rootdir . "/web/action/cloud-conf/cloud-monitor.lock"), 'cloud_documentation_lockfile_details');
     $template->add($this->baseurl, 'baseurl');
     $template->add($external_portal_name, 'external_portal_name');
     $template->add($this->response->html->thisfile, "thisfile");
     $template->group_elements(array('param_' => 'form'));
     return $template;
 }
开发者ID:kelubo,项目名称:OpenQRM,代码行数:34,代码来源:cloud-about.documentation.class.php


示例2: 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;
    }
}
开发者ID:kelubo,项目名称:OpenQRM,代码行数:32,代码来源:openqrm-dhcpd-appliance-hook.php


示例3: openqrm_dhcpd_resource

function openqrm_dhcpd_resource($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_ip = $resource_fields["resource_ip"];
    $resource_mac = $resource_fields["resource_mac"];
    if (isset($resource_fields["resource_subnet"])) {
        $resource_subnet = $resource_fields["resource_subnet"];
    } else {
        $resource_subnet = "0.0.0.0";
    }
    $openqrm_admin_user = new user("openqrm");
    $openqrm_admin_user->set_user();
    $openqrm_server = new openqrm_server();
    $event->log("openqrm_new_resource", $_SERVER['REQUEST_TIME'], 5, "openqrm-dhcpd-resource-hook.php", "Handling {$cmd} event {$resource_id}/{$resource_ip}/{$resource_subnet}/{$resource_mac}", "", "", 0, 0, $resource_id);
    switch ($cmd) {
        case "add":
            $openqrm_server->send_command($OPENQRM_SERVER_BASE_DIR . "/openqrm/plugins/dhcpd/bin/openqrm-dhcpd-manager add -d " . $resource_id . " -m " . $resource_mac . " -i " . $resource_ip . " -s " . $resource_subnet . " -u " . $openqrm_admin_user->name . " -p " . $openqrm_admin_user->password . " --openqrm-cmd-mode background");
            break;
        case "remove":
            $openqrm_server->send_command("{$OPENQRM_SERVER_BASE_DIR}/openqrm/plugins/dhcpd/bin/openqrm-dhcpd-manager remove -d " . $resource_id . " -m " . $resource_mac . " -i " . $resource_ip . " -s " . $resource_subnet . " -u " . $openqrm_admin_user->name . " -p " . $openqrm_admin_user->password . " --openqrm-cmd-mode background");
            break;
    }
}
开发者ID:kelubo,项目名称:OpenQRM,代码行数:27,代码来源:openqrm-dhcpd-resource-hook.php


示例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;
    }
}
开发者ID:kelubo,项目名称:OpenQRM,代码行数:27,代码来源:openqrm-template-appliance-hook.php


示例5: 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;
    }
}
开发者ID:kelubo,项目名称:OpenQRM,代码行数:56,代码来源:openqrm-nagios3-appliance-hook.php


示例6: action

 function action()
 {
     $msg = '';
     $event = new event();
     $server = new openqrm_server();
     $plugin = new plugin();
     $identifier = $this->response->html->request()->get($this->identifier_name);
     $enabled = $plugin->enabled();
     if ($identifier !== '') {
         foreach ($identifier as $id) {
             if (in_array($id, $enabled)) {
                 $return = $server->send_command("openqrm_server_plugin_command {$id} start");
                 if ($return === true) {
                     if ($this->__check($id)) {
                         $msg .= sprintf($this->lang['msg'], $id) . '<br>';
                     } else {
                         $msg .= sprintf($this->lang['error_timeout'], $id) . '<br>';
                     }
                 } else {
                     $msg .= sprintf($this->lang['error_start'], $id) . '<br>';
                 }
             }
         }
     }
     $this->response->redirect($this->response->get_url($this->actions_name, 'select', $this->message_param, $msg));
 }
开发者ID:kelubo,项目名称:OpenQRM,代码行数:26,代码来源:aa_plugins.start.class.php


示例7: action

 function action()
 {
     $msg = '';
     $event = new event();
     $server = new openqrm_server();
     $plugin = new plugin();
     $identifier = $this->response->html->request()->get($this->identifier_name);
     $enabled = $plugin->enabled();
     if ($identifier !== '') {
         foreach ($identifier as $id) {
             if (in_array($id, $enabled)) {
                 $error = false;
                 // check dependencies
                 foreach ($enabled as $v) {
                     if ($v !== $id) {
                         $tmp = $plugin->get_dependencies($v);
                         if ($tmp !== '' && isset($tmp['dependencies']) && $tmp['dependencies'] !== '') {
                             if (strpos($tmp['dependencies'], $id) !== false) {
                                 $msg .= sprintf($this->lang['error_dependencies'], $id, $v) . '<br>';
                                 $error = true;
                             }
                         }
                     }
                 }
                 // handle plugin type
                 if ($error === false) {
                     $tmp = $plugin->get_config($id);
                     switch ($tmp['type']) {
                         case 'storage':
                             $storage = new storage();
                             $types = $storage->get_storage_types();
                             $deployment = new deployment();
                             $dep = $deployment->get_id_by_storagetype($id);
                             foreach ($dep as $val) {
                                 if (in_array($val['value'], $types)) {
                                     $msg .= sprintf($this->lang['error_in_use'], $id) . '<br>';
                                     $error = true;
                                 }
                             }
                             break;
                     }
                 }
                 if ($error === false) {
                     $return = $server->send_command("openqrm_server_plugin_command " . $id . " uninstall " . $GLOBALS['OPENQRM_ADMIN']->name . ' ' . $GLOBALS['OPENQRM_ADMIN']->password);
                     if ($return === true) {
                         if ($this->__check($id)) {
                             $msg .= sprintf($this->lang['msg'], $id) . '<br>';
                         } else {
                             $msg .= sprintf($this->lang['error_timeout'], $id) . '<br>';
                         }
                     } else {
                         $msg .= sprintf($this->lang['error_disable'], $id) . '<br>';
                     }
                 }
             }
         }
     }
     $this->response->redirect($this->response->get_url($this->actions_name, 'select', $this->message_param, $msg));
 }
开发者ID:kelubo,项目名称:OpenQRM,代码行数:59,代码来源:aa_plugins.disable.class.php


示例8: openqrm_tftpd_resource

function openqrm_tftpd_resource($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_ip = $resource_fields["resource_ip"];
    $resource_mac = $resource_fields["resource_mac"];
    $event->log("openqrm_new_resource", $_SERVER['REQUEST_TIME'], 5, "openqrm-tftpd-resource-hook.php", "Handling {$cmd} event {$resource_id}/{$resource_ip}/{$resource_mac}", "", "", 0, 0, $resource_id);
    switch ($cmd) {
        case "remove":
            // we remove the pxe config file; the database removal is handled in the resource class
            $openqrm_server = new openqrm_server();
            $openqrm_server->send_command("openqrm_remove_resource {$resource_id} {$resource_mac}");
            break;
    }
}
开发者ID:kelubo,项目名称:OpenQRM,代码行数:18,代码来源:openqrm-tftpd-resource-hook.php


示例9: openqrm_puppet_resource

function openqrm_puppet_resource($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);
    $resource_ip = $resource->ip;
    $resource_name = $resource->hostname;
    $event->log("openqrm_puppet_resource", $_SERVER['REQUEST_TIME'], 5, "openqrm-puppet-resource-hook.php", "Handling {$cmd} event {$resource_id}/{$resource_name}/{$resource_ip}", "", "", 0, 0, $resource_id);
    // we do only care if we serving an appliance
    $appliance = new appliance();
    $appliance_record_set = array();
    $appliance_id_array = array();
    $appliance_record_set = $appliance->get_all_ids();
    // the appliance_array from getlist is a 2-dimensional array
    foreach ($appliance_record_set as $index => $appliance_id_array) {
        foreach ($appliance_id_array as $index => $id) {
            $tapp = new appliance();
            $tapp->get_instance_by_id($id);
            $tapp_state = $tapp->state;
            $tapp_resources = $tapp->resources;
            if (!strcmp($tapp_state, "active")) {
                if ($tapp_resources == $resource_id) {
                    // we found the resources active appliance, running the cmd
                    $appliance_name = $tapp->name;
                    switch ($cmd) {
                        case "start":
                            $openqrm_server = new openqrm_server();
                            $openqrm_server->send_command("{$OPENQRM_SERVER_BASE_DIR}/openqrm/plugins/puppet/bin/openqrm-puppet-manager start {$id} {$appliance_name} {$resource_ip} --openqrm-cmd-mode background");
                            break;
                        case "stop":
                            $openqrm_server = new openqrm_server();
                            $openqrm_server->send_command("{$OPENQRM_SERVER_BASE_DIR}/openqrm/plugins/puppet/bin/openqrm-puppet-manager stop {$id} {$appliance_name} {$resource_ip} --openqrm-cmd-mode background");
                            break;
                    }
                }
            }
        }
    }
}
开发者ID:kelubo,项目名称:OpenQRM,代码行数:43,代码来源:openqrm-puppet-resource-hook.php


示例10: action

 function action()
 {
     $response = $this->update();
     if (isset($response->error)) {
         $_REQUEST[$this->message_param] = $response->error;
     }
     if (isset($response->msg)) {
         $this->response->redirect($this->response->get_url($this->actions_name, 'select', $this->message_param, $response->msg));
     }
     $external_portal_name = $this->cloud_config->get_value_by_key('external_portal_url');
     if (!strlen($external_portal_name)) {
         $openqrm_server = new openqrm_server();
         $openqrm_server_ip = $openqrm_server->get_ip_address();
         $external_portal_name = "http://" . $openqrm_server_ip . "/cloud-portal";
     }
     $template = $response->html->template($this->tpldir . "/cloud-usergroup-update.tpl.php");
     $template->add(sprintf($this->lang['cloud_usergroup_update_title'], $response->name), 'title');
     $template->add($external_portal_name, 'external_portal_name');
     $template->add($response->form->get_elements());
     $template->add($response->html->thisfile, "thisfile");
     $template->group_elements(array('param_' => 'form'));
     return $template;
 }
开发者ID:kelubo,项目名称:OpenQRM,代码行数:23,代码来源:cloud-usergroup.update.class.php


示例11: openqrm_collectd_appliance

function openqrm_collectd_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;
    $event->log("openqrm_new_appliance", $_SERVER['REQUEST_TIME'], 5, "openqrm-collectd-appliance-hook.php", "Handling {$cmd} event {$appliance_id}/{$appliance_name}/{$appliance_ip}", "", "", 0, 0, $appliance_id);
    // we remove the stats on add and remove
    switch ($cmd) {
        case "add":
            $openqrm_server = new openqrm_server();
            $openqrm_server->send_command($OPENQRM_SERVER_BASE_DIR . "/openqrm/plugins/collectd/bin/openqrm-collectd-manager remove " . $appliance_name . " now --openqrm-cmd-mode background");
            break;
        case "remove":
            $openqrm_server = new openqrm_server();
            $openqrm_server->send_command($OPENQRM_SERVER_BASE_DIR . "/openqrm/plugins/collectd/bin/openqrm-collectd-manager remove " . $appliance_name . " now --openqrm-cmd-mode background");
            break;
    }
}
开发者ID:kelubo,项目名称:OpenQRM,代码行数:24,代码来源:openqrm-collectd-appliance-hook.php


示例12: select

 function select()
 {
     $response = $this->get_response();
     $form = $response->form;
     if (!$form->get_errors() && $this->response->submit()) {
         $request = $form->get_request();
         $hc = $response->hc;
         $image = $response->image;
         $storage = new storage();
         $storage->get_instance_by_id($image->storageid);
         $resource = new resource();
         $resource->get_instance_by_id($storage->resource_id);
         $command = $this->openqrm->get('basedir') . '/plugins/hybrid-cloud/bin/openqrm-hybrid-cloud-migration export_image';
         $command .= ' -i ' . $hc->id;
         $command .= ' -n ' . $hc->account_name;
         $command .= ' -O ' . $hc->access_key;
         $command .= ' -W ' . $hc->secret_key;
         $command .= ' -t ' . $hc->account_type;
         $command .= ' -s ' . $resource->ip . ":" . $image->rootdevice;
         $command .= ' -m ' . $request['size'];
         $command .= ' -a ' . $request['name'];
         $command .= ' -r ' . $request['arch'];
         $command .= ' -u ' . $request['user_id'];
         $command .= ' -y ' . $request['private_key_file'];
         $command .= ' -z ' . $request['public_key_file'];
         $command .= ' -l ' . $this->region;
         $command .= ' --openqrm-ui-user ' . $this->user->name;
         $command .= ' --openqrm-cmd-mode background';
         $server = new openqrm_server();
         $server->send_command($command, NULL, true);
         $response->msg = sprintf($this->lang['msg_exported'], $image->name, $hc->account_name);
         // $ev = new event();
         // $ev->log("hybrid_cloud_monitor", $_SERVER['REQUEST_TIME'], 2, "hybrid-cloud-monitor-hook", $command, "", "", 0, 0, 0);
     }
     return $response;
 }
开发者ID:kelubo,项目名称:OpenQRM,代码行数:36,代码来源:hybrid-cloud.extarget.class.php


示例13: add

 function add()
 {
     $response = $this->get_response();
     $form = $response->form;
     $errors = array();
     if (!$form->get_errors() && $this->response->submit()) {
         $group_name = $form->get_request('name');
         if (!strlen($group_name)) {
             $errors[] = $this->lang['error_name'];
         }
         $group_description = $form->get_request('description');
         if (!strlen($group_description)) {
             $errors[] = $this->lang['error_description'];
         }
         $group_vpc_parameter = '';
         $group_vpc = $form->get_request('vpc');
         if (strlen($group_vpc)) {
             $group_vpc_parameter = ' -c ' . $group_vpc;
         }
         if (count($errors) > 0 || $form->get_errors()) {
             $response->error = join('<br>', $errors);
         } else {
             require_once $this->openqrm->get('basedir') . '/plugins/hybrid-cloud/web/class/hybrid-cloud.class.php';
             $hc = new hybrid_cloud();
             $hc->get_instance_by_id($this->id);
             $openqrm = new openqrm_server();
             $command = $this->openqrm->get('basedir') . '/plugins/hybrid-cloud/bin/openqrm-hybrid-cloud-group create';
             $command .= ' -i ' . $hc->id;
             $command .= ' -n ' . $hc->account_name;
             $command .= ' -O ' . $hc->access_key;
             $command .= ' -W ' . $hc->secret_key;
             $command .= ' -t ' . $hc->account_type;
             $command .= ' -ar ' . $this->region;
             $command .= ' -gn ' . $group_name;
             $command .= ' -gd ' . $group_description;
             $command .= $group_vpc_parameter;
             $command .= ' --openqrm-ui-user ' . $this->user->name;
             $command .= ' --openqrm-cmd-mode background';
             $openqrm->send_command($command, NULL, true);
             sleep(4);
             $response->msg = sprintf($this->lang['msg_added_group'], $group_name);
             //$ev = new event();
             //$ev->log("hybrid_cloud_monitor", $_SERVER['REQUEST_TIME'], 2, "hybrid-cloud-monitor-hook", $command, "", "", 0, 0, 0);
         }
     }
     return $response;
 }
开发者ID:kelubo,项目名称:OpenQRM,代码行数:47,代码来源:hybrid-cloud-group.add.class.php


示例14: create


//.........这里部分代码省略.........
                 $less_load_resource_id = $this->vm_balance_load($active_appliance_list);
                 break;
         }
     }
     if ($less_load_resource_id >= 0) {
         $event->log("create", $_SERVER['REQUEST_TIME'], 5, "cloudvm.class.php", "Found Virtualization host resource {$less_load_resource_id} as the target for the new VM ", "", "", 0, 0, 0);
     }
     // additional network cards
     if ($additional_nics > 0) {
         $anic = 1;
         $additional_nic_str = "";
         $mac_gen_res = new resource();
         while ($anic <= $additional_nics) {
             $mac_gen_res->generate_mac();
             switch ($virtualization_plugin_name) {
                 # VMware VMs need to get special macs
                 case 'vmware-esx':
                     $nic_nr = $anic;
                     $suggested_mac = $mac_gen_res->mac;
                     $new_forth_byte_first_bit = rand(1, 3);
                     $mac_gen_res_vmw = strtolower($vmware_mac_address_space . ":" . substr($suggested_mac, 9));
                     $mac_gen_res_vmw = substr_replace($mac_gen_res_vmw, $new_forth_byte_first_bit, 9, 1);
                     $additional_nic_str .= " -m" . $nic_nr . " " . $mac_gen_res_vmw;
                     break;
                     # VMs network parameter starts with -m1
                 # VMs network parameter starts with -m1
                 default:
                     $nic_nr = $anic;
                     $additional_nic_str .= " -m" . $nic_nr . " " . $mac_gen_res->mac;
                     break;
             }
             $anic++;
         }
     }
     // swap, for the cloud VMs we simply calculate memory * 2
     $swap = $memory * 2;
     // start the VM on the appliance resource
     $host_resource = new resource();
     $host_resource->get_instance_by_id($less_load_resource_id);
     $host_resource_ip = $host_resource->ip;
     // we need to have an openQRM server object too since some of the
     // virtualization commands are sent from openQRM directly
     $openqrm = new openqrm_server();
     // create the new resource + setting the virtualization type
     $vm_resource_ip = "0.0.0.0";
     // add to openQRM database
     $vm_resource_fields["resource_ip"] = $vm_resource_ip;
     $vm_resource_fields["resource_mac"] = $mac;
     $vm_resource_fields["resource_localboot"] = 0;
     $vm_resource_fields["resource_vtype"] = $vtype->id;
     $vm_resource_fields["resource_vhostid"] = $less_load_resource_id;
     $vm_resource_fields["resource_vname"] = $name;
     $new_resource_id = (int) str_replace(".", "", str_pad(microtime(true), 15, "0"));
     $vm_resource_fields["resource_id"] = $new_resource_id;
     $host_resource->add($vm_resource_fields);
     // send new-resource command now after the resource is created logically
     $openqrm->send_command("openqrm_server_add_resource {$new_resource_id} {$mac} {$vm_resource_ip}");
     // let the new resource commands settle
     sleep(10);
     // plug in the virtualization cloud hook
     $virtualization_cloud_hook = "{$RootDir}/plugins/{$virtualization_plugin_name}/openqrm-{$virtualization_plugin_name}-cloud-hook.php";
     if (file_exists($virtualization_cloud_hook)) {
         $event->log("create", $_SERVER['REQUEST_TIME'], 5, "cloudvm.class", "Found plugin {$virtualization_plugin_name} handling to create the VM.", "", "", 0, 0, $new_resource_id);
         require_once "{$virtualization_cloud_hook}";
         $virtualization_method = "create_" . $vtype->type;
         $virtualization_method = str_replace("-", "_", $virtualization_method);
         $virtualization_method($less_load_resource_id, $name, $mac, $memory, $cpu, $swap, $additional_nic_str, $vncpassword, $source_image_id);
     } else {
         $event->log("cloud", $_SERVER['REQUEST_TIME'], 5, "cloudvm.class", "Do not know how to create VM from type {$virtualization_plugin_name}.", "", "", 0, 0, 0);
         // remove resource object
         $vm_resource = new resource();
         $vm_resource->get_instance_by_id($new_resource_id);
         $vm_resource->remove($new_resource_id, $mac);
         return false;
     }
     // update hostlimits quite early to avoid overloading a Host with non-starting VMs
     // add or update hostlimits
     $res_hostlimit = new cloudhostlimit();
     $res_hostlimit->get_instance_by_resource($host_resource->id);
     if (strlen($res_hostlimit->id)) {
         // update
         $current_vms = $res_hostlimit->current_vms + 1;
         $cloud_hostlimit_fields["hl_current_vms"] = $current_vms;
         $res_hostlimit->update($res_hostlimit->id, $cloud_hostlimit_fields);
     } else {
         // add
         $cloud_hostlimit_fields["hl_id"] = (int) str_replace(".", "", str_pad(microtime(true), 15, "0"));
         $cloud_hostlimit_fields["hl_resource_id"] = $host_resource->id;
         $cloud_hostlimit_fields["hl_max_vms"] = -1;
         $cloud_hostlimit_fields["hl_current_vms"] = 1;
         $res_hostlimit->add($cloud_hostlimit_fields);
     }
     $event->log("create", $_SERVER['REQUEST_TIME'], 5, "cloudvm.class.php", "New VM created with resource id " . $new_resource_id . " and started. Waiting now until it is active/idle", "", "", 0, 0, 0);
     if ($vm_provision_delay > 0) {
         $event->log("create", $_SERVER['REQUEST_TIME'], 5, "cloudvm.class.php", "Delaying the provisioning of resource id " . $new_resource_id . " for " . $vm_provision_delay . " seconds.", "", "", 0, 0, 0);
         sleep($vm_provision_delay);
     }
     // setting this object resource id as return state
     $this->resource_id = $new_resource_id;
 }
开发者ID:kelubo,项目名称:OpenQRM,代码行数:101,代码来源:cloudvm.class.php


示例15: edit

 function edit()
 {
     $h = array();
     $h['state']['title'] = $this->lang['table_state'];
     $h['state']['sortable'] = false;
     $h['name']['title'] = $this->lang['table_name'];
     $h['name']['hidden'] = true;
     $h['region']['title'] = $this->lang['table_region'];
     $h['region']['hidden'] = true;
     $h['ami']['title'] = $this->lang['table_ami'];
     $h['ami']['hidden'] = true;
     $h['type']['title'] = $this->lang['table_type'];
     $h['type']['hidden'] = true;
     $h['data']['title'] = '&#160;';
     $h['data']['sortable'] = false;
     $h['public']['title'] = $this->lang['table_public_ip'];
     $h['private']['title'] = $this->lang['table_private_ip'];
     $h['remove']['title'] = '&#160;';
     $h['remove']['sortable'] = false;
     $a = $this->response->html->a();
     $a->label = $this->lang['action_add_local_vm'];
     $a->css = 'add';
     $a->handler = 'onclick="wait();"';
     $a->href = $this->response->get_url($this->actions_name, "add");
     $d['add_local_vm'] = $a->get_string();
     $content = array();
     $file = $this->openqrm->get('basedir') . '/plugins/hybrid-cloud/web/hybrid-cloud-stat/' . $this->id . '.describe_instances.log';
     if ($this->file->exists($file)) {
         $this->file->remove($file);
     }
     $hc_authentication = '';
     if ($this->hc->account_type == 'aws' || $this->hc->account_type == 'euca') {
         $hc_authentication .= ' -O ' . $this->hc->access_key;
         $hc_authentication .= ' -W ' . $this->hc->secret_key;
         $hc_authentication .= ' -ir ' . $this->region;
     }
     if ($this->hc->account_type == 'lc-openstack') {
         $hc_authentication .= ' -u ' . $this->hc->username;
         $hc_authentication .= ' -p ' . $this->hc->password;
         $hc_authentication .= ' -q ' . $this->hc->host;
         $hc_authentication .= ' -x ' . $this->hc->port;
         $hc_authentication .= ' -g ' . $this->hc->tenant;
         $hc_authentication .= ' -e ' . $this->hc->endpoint;
     }
     $command = $this->openqrm->get('basedir') . '/plugins/hybrid-cloud/bin/openqrm-hybrid-cloud-vm describe';
     $command .= ' -i ' . $this->hc->id;
     $command .= ' -n ' . $this->hc->account_name;
     $command .= ' -t ' . $this->hc->account_type;
     $command .= $hc_authentication;
     $command .= ' --openqrm-ui-user ' . $this->user->name;
     $command .= ' --openqrm-cmd-mode background';
     $server = new openqrm_server();
     $server->send_command($command, NULL, true);
     while (!$this->file->exists($file)) {
         usleep(10000);
         // sleep 10ms to unload the CPU
         clearstatcache();
     }
     $content = $this->file->get_contents($file);
     $content = explode("\n", $content);
     $b = array();
     foreach ($content as $k => $v) {
         if ($v !== '') {
             // e.g. INSTANCE@i-ec3667a1@[email protected]@ip-10-234-109-57.eu-west-1.compute.internal@running@home@0@@m1.small@2013-06-25T16:58:30+0000@eu-west-1a@aki-71665e05@@@[email protected]@10.234.109.57@@@instance-store@@@@@paravirtual@xen@@sg-9d664de9@default@false@
             $tmp = explode('@', $v);
             $name = $tmp[1];
             $ami = $tmp[2];
             $public_hostname = $tmp[3];
             $private_hostname = $tmp[4];
             $state = $tmp[5];
             $keypair = $tmp[6];
             $unknown1 = $tmp[7];
             $unknown2 = $tmp[8];
             $type = $tmp[9];
             $date = $tmp[10];
             $region = $tmp[11];
             $unknown4 = $tmp[12];
             $unknown5 = $tmp[13];
             $unknown6 = $tmp[14];
             $monitoring = $tmp[15];
             $public_ip = $this->hc->format_ip_address($tmp[16]);
             $private_ip = $this->hc->format_ip_address($tmp[17]);
             $vpc = $tmp[18];
             $subnet = $tmp[19];
             $store = $tmp[20];
             $unknown9 = $tmp[21];
             $unknown10 = $tmp[22];
             $unknown11 = $tmp[23];
             $unknown12 = $tmp[24];
             $hvm = $tmp[25];
             $virt_type = $tmp[26];
             $mac = '';
             // remove
             $remove_instance = '';
             $import_str = '';
             if ($state == 'idle') {
                 $mac = $tmp[30];
                 $a = $this->response->html->a();
                 $a->label = $this->lang['action_remove_vm'];
                 $a->css = 'remove';
//.........这里部分代码省略.........
开发者ID:kelubo,项目名称:OpenQRM,代码行数:101,代码来源:hybrid-cloud-vm.edit.class.php


示例16: fence_hybrid_cloud_vm_local

function fence_hybrid_cloud_vm_local($host_resource_id, $mac)
{
    global $OPENQRM_SERVER_BASE_DIR;
    global $OPENQRM_SERVER_IP_ADDRESS;
    global $OPENQRM_EXEC_PORT;
    global $RESOURCE_INFO_TABLE;
    global $event;
    $event->log("fence_hybrid_cloud_vm_local", $_SERVER['REQUEST_TIME'], 5, "hybrid-cloud-ha-hook", "Fencing Cloud VM " . $mac, "", "", 0, 0, 0);
    $origin_resource = new resource();
    $origin_resource->get_instance_by_mac($mac);
    // get hybrid-cloud account from origin resource
    $hybrid_acl_id = $origin_resource->get_resource_capabilities("HCACL");
    $hc = new hybrid_cloud();
    $hc->get_instance_by_id($hybrid_acl_id);
    $hc_authentication = '';
    if ($hc->account_type == 'aws' || $hc->account_type == 'euca') {
        $hc_authentication .= ' -O ' . $hc->access_key;
        $hc_authentication .= ' -W ' . $hc->secret_key;
    }
    if ($hc->account_type == 'lc-openstack') {
        $hc_authentication .= ' -u ' . $hc->username;
        $hc_authentication .= ' -p ' . $hc->password;
        $hc_authentication .= ' -q ' . $hc->host;
        $hc_authentication .= ' -x ' . $hc->port;
        $hc_authentication .= ' -g ' . $hc->tenant;
        $hc_authentication .= ' -e ' . $hc->endpoint;
    }
    $openqrm = new openqrm_server();
    $command = $OPENQRM_SERVER_BASE_DIR . "/openqrm/plugins/hybrid-cloud/bin/openqrm-hybrid-cloud-vm fence ";
    $command .= ' -i ' . $hc->id;
    $command .= ' -n ' . $hc->account_name;
    $command .= ' -t ' . $hc->account_type;
    $command .= $hc_authentication;
    $command .= ' -im ' . $mac;
    $command .= ' --openqrm-cmd-mode background';
    $event->log("fence_hybrid_cloud_vm_local", $_SERVER['REQUEST_TIME'], 5, "hybrid-cloud-ha-hook", "Running {$command}", "", "", 0, 0, 0);
    $openqrm->send_command($command, NULL, true);
    $rufields["resource_hostname"] = $hc->account_type . $origin_resource->id;
    $origin_resource->update_info($origin_resource->id, $rufields);
    // debug
    // echo "1:".$command;
}
开发者ID:kelubo,项目名称:OpenQRM,代码行数:42,代码来源:openqrm-hybrid-cloud-ha-cmd-hook.php


示例17: __reload

 function __reload()
 {
     require_once $this->openqrm->get('basedir') . '/plugins/hybrid-cloud/web/class/hybrid-cloud.class.php';
     $hc = new hybrid_cloud();
     $hc->get_instance_by_id($this->response->html->request()->get('hybrid_cloud_id'));
     $command = $this->openqrm->get('basedir') . '/plugins/hybrid-cloud/bin/openqrm-hybrid-cloud-keypair describe';
     $command .= ' -i ' . $hc->id;
     $command .= ' -n ' . $hc->account_name;
     $command .= ' -c ' . $hc->rc_config;
     $command .= ' -t ' . $hc->account_type;
     $command .= ' -ir ' . $this->response-> 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP option类代码示例发布时间:2022-05-23
下一篇:
PHP open_flash_chart类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap