本文整理汇总了PHP中kernel::get_instance_by_id方法的典型用法代码示例。如果您正苦于以下问题:PHP kernel::get_instance_by_id方法的具体用法?PHP kernel::get_instance_by_id怎么用?PHP kernel::get_instance_by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kernel
的用法示例。
在下文中一共展示了kernel::get_instance_by_id方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: resource
$appliance->add($appliance_fields);
// set start time, reset stoptime, set state
$now = $_SERVER['REQUEST_TIME'];
$appliance_fields["appliance_starttime"] = $now;
$appliance_fields["appliance_stoptime"] = 0;
$appliance_fields['appliance_state'] = 'active';
// set resource type to physical
$appliance_fields['appliance_virtualization'] = 1;
$appliance->update($next_appliance_id, $appliance_fields);
// set resource to localboot
$resource = new resource();
$resource->get_instance_by_id($local_server_id);
$openqrm_server->send_command("openqrm_server_set_boot local {$local_server_id} {$resource->mac} 0.0.0.0");
$resource->set_localboot($local_server_id, 1);
// update resource fields with kernel + image
$kernel->get_instance_by_id($kernel_fields["kernel_id"]);
$resource_fields["resource_kernel"] = $kernel->name;
$resource_fields["resource_kernelid"] = $kernel_fields["kernel_id"];
$image->get_instance_by_id($image_fields["image_id"]);
$resource_fields["resource_image"] = $image->name;
$resource_fields["resource_imageid"] = $image_fields["image_id"];
// set capabilites
$resource_fields["resource_capabilities"] = 'TYPE=local-server';
$resource->update_info($local_server_id, $resource_fields);
// add + start hook
$appliance->get_instance_by_id($next_appliance_id);
$now = $_SERVER['REQUEST_TIME'];
$appliance_fields = array();
$appliance_fields['appliance_stoptime'] = $now;
$appliance_fields['appliance_state'] = 'stopped';
// fill in the rest of the appliance info in the array for the plugin hook
示例2: select
function select()
{
$head['cr_status']['title'] = $this->lang['cloud_ui_request_status'];
$head['cr_id']['title'] = $this->lang['cloud_ui_request_id'];
$head['cr_id']['hidden'] = true;
$head['cr_appliance_hostname']['title'] = $this->lang['cloud_ui_request_appliance_name'];
$head['cr_appliance_hostname']['hidden'] = true;
#$head['cr_start']['title'] = $this->lang['cloud_ui_request_start'];
#$head['cr_stop']['title'] = $this->lang['cloud_ui_request_stop'];
#$head['cr_kernel_id']['title'] = $this->lang['cloud_ui_request_os'];
#$head['cr_image_id']['title'] = $this->lang['cloud_ui_request_template'];
#$head['cr_resource_type_req']['title'] = $this->lang['cloud_ui_request_system_type'];
$head['cr_req']['title'] = ' ';
$head['cr_req']['sortable'] = false;
#$head['cr_appliance_id']['title'] = $this->lang['cloud_ui_request_appliance_id'];
$head['cr_details']['title'] = $this->lang['cloud_ui_request_details'];
$head['cr_details']['sortable'] = false;
$table = $this->response->html->tablebuilder('cloud_request_table', $this->response->get_array($this->actions_name, 'requests'));
$table->css = 'htmlobject_table';
$table->border = 0;
$table->id = 'cloud_requests';
$table->head = $head;
$table->sort = 'cr_id';
$table->order = 'DESC';
$table->limit = 5;
$table->sort_link = false;
$table->autosort = false;
$table->max = $this->cloudrequest->get_count_per_user($this->clouduser->id);
$table->identifier = 'cr_id';
$table->identifier_name = $this->identifier_name;
$table->actions = array('deprovision');
$table->actions_name = $this->actions_name;
$table->form_action = $this->response->html->thisfile;
$table->limit_select = array(array("value" => 5, "text" => 5), array("value" => 10, "text" => 10), array("value" => 20, "text" => 20), array("value" => 30, "text" => 30), array("value" => 40, "text" => 40), array("value" => 50, "text" => 50));
// $table->form_action = $this->response->html->thisfile;
$table->init();
$kernel = new kernel();
$image = new image();
$virtualization = new virtualization();
$cloud_request_array = $this->cloudrequest->display_overview_per_user($this->clouduser->id, $table->offset, $table->limit, $table->sort, $table->order);
$ta = '';
foreach ($cloud_request_array as $index => $cz) {
$this->cloudrequest->get_instance_by_id($cz['cr_id']);
$cr_status = $this->cloudrequest->getstatus($this->cloudrequest->id);
if (isset($this->cloudrequest->kernel_id)) {
$kernel->get_instance_by_id($this->cloudrequest->kernel_id);
}
if (isset($this->cloudrequest->image_id)) {
$image->get_instance_by_id($this->cloudrequest->image_id);
}
if (isset($this->cloudrequest->resource_type_req)) {
$virtualization->get_instance_by_id($this->cloudrequest->resource_type_req);
}
#echo '<pre>';
#print_r($this->cloudrequest);
#echo '</pre>';
// hostname
$appliance_hostname = '-';
if (strlen($this->cloudrequest->appliance_hostname)) {
$appliance_hostname = $this->cloudrequest->appliance_hostname;
}
$cr_req = '<b>' . $this->lang['cloud_ui_request_id'] . '</b>: ' . $this->cloudrequest->id . "<br>";
$cr_req .= '<b>' . $this->lang['cloud_ui_request_appliance_name'] . '</b>: ' . $appliance_hostname . "<br>";
$cr_req .= '<b>' . $this->lang['cloud_ui_request_start'] . '</b>: ' . date("d-m-Y H:i", $this->cloudrequest->start) . "<br>";
$cr_req .= '<b>' . $this->lang['cloud_ui_request_stop'] . '</b>: ' . date("d-m-Y H:i", $this->cloudrequest->stop) . "<br>";
$cr_req .= '<b>' . $this->lang['cloud_ui_request_cpu'] . '</b>: ' . $this->cloudrequest->cpu_req . "<br>";
$cr_req .= '<b>' . $this->lang['cloud_ui_request_memory'] . '</b>: ' . $this->cloudrequest->ram_req . " MB<br>";
$cr_req .= '<b>' . $this->lang['cloud_ui_request_disk'] . '</b>: ' . $this->cloudrequest->disk_req . " MB<br>";
$cr_req .= '<b>' . $this->lang['cloud_ui_request_network'] . '</b>: ' . $this->cloudrequest->network_req . "<br>";
// details action
$a = $this->response->html->a();
$a->title = $this->lang['cloud_ui_request_components_details'];
$a->label = $this->lang['cloud_ui_request_components_details'];
$a->handler = 'onclick="javascript:cloudopenPopup(' . $this->cloudrequest->id . ');"';
$a->css = 'edit';
$a->href = '#';
$ta[] = array('cr_status' => $cr_status, 'cr_id' => $this->cloudrequest->id, 'cr_appliance_hostname' => $appliance_hostname, 'cr_req' => $cr_req, 'cr_details' => $a->get_string());
}
$table->body = $ta;
return $table;
}
示例3: edit
function edit()
{
$resource_icon_default = "/img/resource.png";
$storage_icon = "/plugins/kvm/img/plugin.png";
//$state_icon = $this->openqrm->get('baseurl')."/img/".$this->resource->state.".png";
if ($this->file->exists($this->openqrm->get('webdir') . $storage_icon)) {
$resource_icon_default = $storage_icon;
}
$resource_icon_default = $this->openqrm->get('baseurl') . $resource_icon_default;
// check if we have a plugin implementing the remote console
$remote_console = false;
$plugin = new plugin();
$enabled_plugins = $plugin->enabled();
foreach ($enabled_plugins as $index => $plugin_name) {
//$plugin_remote_console_running = $this->openqrm->get('webdir')."/plugins/".$plugin_name."/.running";
$plugin_remote_console_hook = $this->openqrm->get('webdir') . "/plugins/" . $plugin_name . "/openqrm-" . $plugin_name . "-remote-console-hook.php";
if ($this->file->exists($plugin_remote_console_hook)) {
require_once "{$plugin_remote_console_hook}";
$link_function = str_replace("-", "_", "openqrm_" . "{$plugin_name}" . "_remote_console");
if (function_exists($link_function)) {
$remote_functions[] = $link_function;
$remote_console = true;
}
}
}
// prepare list of all Host resource id for the migration select
// we need a select with the ids/ips from all resources which
// are used by appliances with kvm capabilities
$kvm_hosts = array();
$appliance_list = new appliance();
$appliance_list_array = $appliance_list->get_list();
foreach ($appliance_list_array as $index => $app) {
$appliance_kvm_host_check = new appliance();
$appliance_kvm_host_check->get_instance_by_id($app["value"]);
// only active appliances
if (!strcmp($appliance_kvm_host_check->state, "active") || $appliance_kvm_host_check->resources == 0) {
$virtualization = new virtualization();
$virtualization->get_instance_by_id($appliance_kvm_host_check->virtualization);
if (!strcmp($virtualization->type, "kvm") && !strstr($virtualization->type, "kvm-vm")) {
$kvm_host_resource = new resource();
$kvm_host_resource->get_instance_by_id($appliance_kvm_host_check->resources);
// exclude source host
#if ($kvm_host_resource->id == $this->resource->id) {
# continue;
#}
// only active appliances
if (!strcmp($kvm_host_resource->state, "active")) {
$migration_select_label = "Res. " . $kvm_host_resource->id . "/" . $kvm_host_resource->ip;
$kvm_hosts[] = array("value" => $kvm_host_resource->id, "label" => $migration_select_label);
}
}
}
}
$d['state'] = '<span class="pill ' . $this->resource->state . '">' . $this->resource->state . '</span>';
$d['resource'] = $this->resource->id . ' / ' . $this->resource->ip;
$d['name'] = $this->appliance->name;
$d['id'] = $this->appliance->id;
$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") . '&vmtype=kvm-vm-local';
$d['add_local_vm'] = $a->get_string();
$a = $this->response->html->a();
$a->label = $this->lang['action_add_network_vm'];
$a->css = 'add';
$a->handler = 'onclick="wait();"';
$a->href = $this->response->get_url($this->actions_name, "add") . '&vmtype=kvm-vm-net';
$d['add_network_vm'] = $a->get_string();
$body = array();
$identifier_disabled = array();
$file = $this->statfile;
if ($this->file->exists($file)) {
$lines = explode("\n", $this->file->get_contents($file));
if (count($lines) >= 1) {
$i = 0;
foreach ($lines as $line) {
if ($line !== '') {
$line = explode('@', $line);
$state = $line[0];
$name = $line[1];
$mac = $line[2];
$resource = new resource();
$resource->get_instance_by_mac($mac);
if ($resource->vhostid != $this->resource->id) {
continue;
}
$res_virtualization = new virtualization();
$res_virtualization->get_instance_by_id($resource->vtype);
$update = '';
$a = $this->response->html->a();
$a->title = $this->lang['action_update'];
$a->label = $this->lang['action_update'];
$a->handler = 'onclick="wait();"';
$a->css = 'edit';
$a->href = $this->response->get_url($this->actions_name, "update") . '&vm=' . $name . '&vmtype=' . $res_virtualization->type;
$update_link = $a->get_string();
$clone = '';
$a = $this->response->html->a();
$a->title = $this->lang['action_clone'];
//.........这里部分代码省略.........
示例4: openqrm_cloud_monitor
function openqrm_cloud_monitor()
{
global $event;
global $APPLIANCE_INFO_TABLE;
global $IMAGE_INFO_TABLE;
global $CLOUD_IMAGE_TABLE;
global $CLOUD_APPLIANCE_TABLE;
global $OPENQRM_SERVER_BASE_DIR;
global $OPENQRM_SERVER_IP_ADDRESS;
global $OPENQRM_EXEC_PORT;
global $openqrm_server;
global $BaseDir;
global $RootDir;
global $vm_create_timout;
$vmware_mac_address_space = "00:50:56";
$cloud_monitor_lock = "{$OPENQRM_SERVER_BASE_DIR}/openqrm/web/action/cloud-conf/cloud-monitor.lock";
$cloud_monitor_timeout = "600";
$cloud_volume_clone_timeout = "4800";
// lock to prevent running multiple times in parallel
if (file_exists($cloud_monitor_lock)) {
// check from when it is, if it is too old we remove it and start
$cloud_monitor_lock_date = file_get_contents($cloud_monitor_lock);
$now = $_SERVER['REQUEST_TIME'];
if ($now - $cloud_monitor_lock_date > $cloud_monitor_timeout) {
$event->log("cloud", $_SERVER['REQUEST_TIME'], 2, "monitor-hook", "Timeout for the cloud-monitor-lock reached, creating new lock", "", "", 0, 0, 0);
$cloud_lock_fp = fopen($cloud_monitor_lock, 'w');
fwrite($cloud_lock_fp, $now);
fclose($cloud_lock_fp);
} else {
return 0;
}
} else {
$now = $_SERVER['REQUEST_TIME'];
$cloud_lock_fp = fopen($cloud_monitor_lock, 'w');
fwrite($cloud_lock_fp, $now);
fclose($cloud_lock_fp);
}
// prepare performance parameter
$cloud_performance_config = new cloudconfig();
$max_parallel_phase_one_actions = $cloud_performance_config->get_value(27);
// 27 max-parallel-phase-one-actions
$max_parallel_phase_two_actions = $cloud_performance_config->get_value(28);
// 28 max-parallel-phase-two-actions
$max_parallel_phase_three_actions = $cloud_performance_config->get_value(29);
// 29 max-parallel-phase-three-actions
$max_parallel_phase_four_actions = $cloud_performance_config->get_value(30);
// 30 max-parallel-phase-four-actions
$max_parallel_phase_five_actions = $cloud_performance_config->get_value(31);
// 31 max-parallel-phase-five-actions
$max_parallel_phase_six_actions = $cloud_performance_config->get_value(32);
// 32 max-parallel-phase-six-actions
$max_parallel_phase_seven_actions = $cloud_performance_config->get_value(33);
// 33 max-parallel-phase-seven-actions
$parallel_phase_one_actions = 0;
$parallel_phase_two_actions = 0;
$parallel_phase_three_actions = 0;
$parallel_phase_four_actions = 0;
$parallel_phase_five_actions = 0;
$parallel_phase_six_actions = 0;
$parallel_phase_seven_actions = 0;
// appliance hostname
$cloud_appliance_hostname_enabled = $cloud_performance_config->get_value(34);
// 34 appliance-hostname
// $event->log("cloud", $_SERVER['REQUEST_TIME'], 5, "monitor-hook", "Cloud Phase I - Image actions, VM-removal", "", "", 0, 0, 0);
// #################### clone-on-deploy image resize / remove ################################
// here we check if we have any clone-on-deploy images to resize or to remove
// get cloudimage ids
$cil = new cloudimage();
$cloud_image_list = $cil->get_all_ids();
foreach ($cloud_image_list as $ci_list) {
$phase_one_actions = 0;
$ci_id = $ci_list['ci_id'];
$ci = new cloudimage();
$ci->get_instance_by_id($ci_id);
$ci_state = $ci->state;
$ci_image_id = $ci->image_id;
$ci_appliance_id = $ci->appliance_id;
$ci_resource_id = $ci->resource_id;
$ci_cr_id = $ci->cr_id;
$ci_resource = new resource();
$ci_resource->get_instance_by_id($ci_resource_id);
$ci_appliance = new appliance();
$ci_appliance->get_instance_by_id($ci->appliance_id);
// not the openQRM server resource, accept 0 only for private image remove
if ($ci_cr_id != 0) {
if ($ci_resource_id == 0) {
continue;
}
// not when the cr is in starting phase
$ci_request = new cloudrequest();
$ci_request->get_instance_by_id($ci_cr_id);
if ($ci_request->status == 8) {
continue;
}
}
// image still in use ?
if ($ci_state == 1) {
// its resource its active with the idle image ? sounds like pause
if (!strcmp($ci_resource->state, "active") && $ci_resource->imageid == 1) {
// ####################### remove auto createed vm #################
//.........这里部分代码省略.........
示例5: edit
function edit()
{
$response = $this->get_response();
$form = $response->form;
if (!$form->get_errors() && $response->submit()) {
$errors = array();
$message = array();
$kernel_id = $this->response->html->request()->get($this->identifier_name);
$kernel_comment = $this->response->html->request()->get('kernel_comment');
$kernel = new kernel();
$kernel->get_instance_by_id($kernel_id);
$kernel_comment = $response->html->request()->get('kernel_comment');
$fields['kernel_comment'] = htmlspecialchars($kernel_comment);
$kernel->update($kernel_id, $fields);
$response->msg = sprintf($this->lang['msg'], $kernel->name);
}
return $response;
}
示例6: resource
function get_response()
{
$response = $this->response;
$form = $response->get_form($this->actions_name, 'step4');
$resource = new resource();
$resource->get_instance_by_id($this->appliance->resources);
// if not openQRM resource
if ($resource->id != 0) {
$virtualization = new virtualization();
$virtualization->get_instance_by_id($resource->vtype);
}
$image = new image();
$image->get_instance_by_id($this->appliance->imageid);
$deployment = new deployment();
$deployment->get_instance_by_type($image->type);
$submit = $form->get_elements('submit');
$submit->handler = 'onclick="wait();"';
$form->add($submit, 'submit');
$submit = $form->get_elements('cancel');
$submit->handler = 'onclick="cancel();"';
$form->add($submit, 'cancel');
$kernel = new kernel();
$list = $kernel->get_list();
unset($list[0]);
$kernels = array();
if ($resource->id == 0) {
$kernels[] = array(0, 'openQRM');
} else {
if (strstr($resource->capabilities, "TYPE=local-server")) {
$local_kernel = new kernel();
$local_kernel->get_instance_by_name("resource" . $resource->id);
$kernels[] = array($local_kernel->id, 'Local OS Installation');
// local-deployment VMs
} else {
if (strstr($virtualization->type, "-vm-local")) {
$kernels[] = array(1, 'Local OS Installation');
// network-deployment - show only network-boot images
} else {
if (strstr($virtualization->type, "-vm-net")) {
foreach ($list as $value) {
$id = $value['value'];
$kernel->get_instance_by_id($id);
if (!strstr($kernel->capabilities, "TYPE=local-server")) {
$kernels[] = array($id, $kernel->id . ' / ' . $kernel->name . ' (' . $kernel->version . ')');
}
}
// network deployment - physical systems - show only network-boot images
} else {
foreach ($list as $value) {
$id = $value['value'];
$kernel->get_instance_by_id($id);
if (!strstr($kernel->capabilities, "TYPE=local-server")) {
$kernels[] = array($id, $kernel->id . ' / ' . $kernel->name . ' (' . $kernel->version . ')');
}
}
}
}
}
}
$d['kernel']['label'] = $this->lang['form_kernel'];
$d['kernel']['required'] = true;
$d['kernel']['object']['type'] = 'htmlobject_select';
$d['kernel']['object']['attrib']['index'] = array(0, 1);
$d['kernel']['object']['attrib']['id'] = 'kernel';
$d['kernel']['object']['attrib']['name'] = 'kernel';
$d['kernel']['object']['attrib']['options'] = $kernels;
$form->add($d);
$response->form = $form;
return $response;
}
示例7: CloudApplianceGetDetails
function CloudApplianceGetDetails($method_parameters)
{
global $event;
global $RootDir;
$parameter_array = explode(',', $method_parameters);
$mode = $parameter_array[0];
$username = $parameter_array[1];
$password = $parameter_array[2];
$ca_id = $parameter_array[3];
// check all user input
for ($i = 0; $i <= 3; $i++) {
if (!$this->check_param($parameter_array[$i])) {
$event->log("cloudsoap->CloudApplianceGetDetails", $_SERVER['REQUEST_TIME'], 2, "cloud-soap-server.php", "Not allowing user-intput with special-characters : {$parameter_array[$i]}", "", "", 0, 0, 0);
return;
}
}
// check parameter count
$parameter_count = count($parameter_array);
if ($parameter_count != 4) {
$event->log("cloudsoap->CloudApplianceGetDetails", $_SERVER['REQUEST_TIME'], 2, "cloud-soap-server.php", "Wrong parameter count {$parameter_count} ! Exiting.", "", "", 0, 0, 0);
return;
}
// check authentication
if (!$this->check_user($mode, $username, $password)) {
$event->log("cloudsoap->CloudApplianceGetDetails", $_SERVER['REQUEST_TIME'], 2, "cloud-soap-server.php", "User authentication failed (mode {$mode})", "", "", 0, 0, 0);
return;
}
$cr_appliance = new cloudappliance();
$cr_appliance->get_instance_by_id($ca_id);
// get the request to check for the user
$cr = new cloudrequest();
$cr->get_instance_by_id($cr_appliance->cr_id);
$cl_user = new clouduser();
$cl_user->get_instance_by_id($cr->cu_id);
switch ($mode) {
case 'user':
if (strcmp($username, $cl_user->name)) {
$event->log("cloudsoap->CloudApplianceGetDetails", $_SERVER['REQUEST_TIME'], 2, "cloud-soap-server.php", "Cloud User {$username} is trying to get Details of Cloud User {$cl_user->name}!", "", "", 0, 0, 0);
return;
}
break;
}
$event->log("cloudsoap->CloudApplianceGetDetails", $_SERVER['REQUEST_TIME'], 5, "cloud-soap-server.php", "Providing details for Cloud appliance {$ca_id}", "", "", 0, 0, 0);
$cloudappliance_details = array();
// create the array to return
$cloudappliance_details['id'] = $ca_id;
// appliance details
$appliance = new appliance();
$appliance->get_instance_by_id($cr_appliance->appliance_id);
$cloudappliance_details['appliance_name'] = $appliance->name;
$cloudappliance_details['appliance_state'] = $appliance->state;
$cloudappliance_details['appliance_comment'] = $appliance->comment;
// resource details
$resource = new resource();
$resource->get_instance_by_id($appliance->resources);
$cloudappliance_details['resource_id'] = $resource->id;
$cloudappliance_details['resource_type'] = $resource->capabilities;
$cloudappliance_details['resource_int_ip'] = $resource->ip;
$cloudappliance_details['resource_uptime'] = $resource->uptime;
$cloudappliance_details['resource_cpumodel'] = $resource->cpumodel;
$cloudappliance_details['resource_cpunumber'] = $resource->cpunumber;
$cloudappliance_details['resource_cpuspeed'] = $resource->cpuspeed;
$cloudappliance_details['resource_load'] = $resource->load;
$cloudappliance_details['resource_memtotal'] = $resource->memtotal;
$cloudappliance_details['resource_memused'] = $resource->memused;
$cloudappliance_details['resource_swaptotal'] = $resource->swaptotal;
$cloudappliance_details['resource_swapused'] = $resource->swapused;
// image details
$image = new image();
$image->get_instance_by_id($appliance->imageid);
$cloudappliance_details['image_name'] = $image->name;
$cloud_image = new cloudimage();
$cloud_image->get_instance_by_image_id($image->id);
$cloudappliance_details['disk_size'] = $cloud_image->disk_size;
// kernel details
$kernel = new kernel();
$kernel->get_instance_by_id($appliance->kernelid);
$cloudappliance_details['kernel_name'] = $kernel->name;
// cloud-appliance details
$cloudappliance_details['cloud_appliance_state'] = $cr_appliance->state;
$cloudappliance_details['cloud_appliance_cr_id'] = $cr_appliance->cr_id;
// finding the external ip
$appliance_resources = $appliance->resources;
if ($appliance_resources >= 0) {
// an appliance with a pre-selected resource
// ip-mgmt enabled ? if yes try to get the external ip
$cloud_ip_mgmt_config = new cloudconfig();
$cloud_ip_mgmt = $cloud_ip_mgmt_config->get_value(26);
// ip-mgmt enabled ?
if (!strcmp($cloud_ip_mgmt, "true")) {
if (file_exists($RootDir . "/plugins/ip-mgmt/.running")) {
require_once $RootDir . "/plugins/ip-mgmt/class/ip-mgmt.class.php";
$ip_mgmt = new ip_mgmt();
$ip_mgmt_id = $ip_mgmt->get_id_by_appliance($cr_appliance->appliance_id, 1);
if ($ip_mgmt_id > 0) {
$ipmgmt_config_arr = $ip_mgmt->get_config_by_id($ip_mgmt_id);
if (!strlen($ipmgmt_config_arr[0]['ip_mgmt_address'])) {
$event->log("cloudsoap->CloudApplianceGetDetails", $_SERVER['REQUEST_TIME'], 2, "cloud-soap-server.php", "Failed to get the external ip address for appliance id " . $cr_appliance->appliance_id . ". Falling back to internal ip!", "", "", 0, 0, 0);
} else {
$appliance_ip = $ipmgmt_config_arr[0]['ip_mgmt_address'];
//.........这里部分代码省略.........
示例8: stop
function stop()
{
$response = $this->get_response();
$appliances = $response->html->request()->get($this->identifier_name);
$form = $response->form;
$appliance = new appliance();
if ($appliances !== '') {
$submit = $form->get_elements('submit');
$submit->handler = 'onclick="wait();"';
$form->add($submit, 'submit');
$submit = $form->get_elements('cancel');
$submit->handler = 'onclick="cancel();"';
$form->add($submit, 'cancel');
$i = 0;
foreach ($appliances as $id) {
$appliance = $appliance->get_instance_by_id($id);
$d['param_f' . $i]['label'] = $appliance->name;
$d['param_f' . $i]['object']['type'] = 'htmlobject_input';
$d['param_f' . $i]['object']['attrib']['type'] = 'checkbox';
$d['param_f' . $i]['object']['attrib']['name'] = $this->identifier_name . '[' . $i . ']';
$d['param_f' . $i]['object']['attrib']['value'] = $id;
$d['param_f' . $i]['object']['attrib']['checked'] = true;
$i++;
}
$form->add($d);
if (!$form->get_errors() && $response->submit()) {
$errors = array();
$message = array();
foreach ($appliances as $key => $id) {
$appliance = $appliance->get_instance_by_id($id);
$resource = new resource();
$resource->get_instance_by_id($appliance->resources);
if ($appliance->resources == 0) {
$errors[] = sprintf($this->lang['msg_always_active'], $id);
continue;
}
// if no errors then we stop the appliance
$kernel = new kernel();
$kernel->get_instance_by_id($appliance->kernelid);
// send command to the openQRM-server
$resource->send_command("127.0.0.1", "openqrm_assign_kernel " . $resource->id . " " . $resource->mac . " default");
$appliance->stop();
$form->remove($this->identifier_name . '[' . $key . ']');
$message[] = sprintf($this->lang['msg'], $id);
}
if (count($errors) === 0) {
$response->msg = join('<br>', $message);
} else {
$msg = array_merge($errors, $message);
$response->error = join('<br>', $msg);
}
}
} else {
$response->msg = '';
}
return $response;
}
示例9: VALUES
$create_default_cloudselector_config = "insert into cloud_selector VALUES (" . $cloud_product_id . ",'network',2,'3',3,'3','3 Network Cards',1);";
$recordSet = $db->Execute($create_default_cloudselector_config);
$cloud_product_id = (int) str_replace(".", "", str_pad(microtime(true), 15, "0"));
$create_default_cloudselector_config = "insert into cloud_selector VALUES (" . $cloud_product_id . ",'network',3,'4',4,'4','4 Network Cards',1);";
$recordSet = $db->Execute($create_default_cloudselector_config);
$cloud_product_id = (int) str_replace(".", "", str_pad(microtime(true), 15, "0"));
$create_default_cloudselector_config = "insert into cloud_selector VALUES (" . $cloud_product_id . ",'quantity',0,'1',1,'1','1 CloudAppliance',1);";
$recordSet = $db->Execute($create_default_cloudselector_config);
// create kernel products
$next_sort_id = 0;
$kernel = new kernel();
$kernel_id_ar = $kernel->get_list();
unset($kernel_id_ar[0]);
foreach ($kernel_id_ar as $key => $value) {
$id = $value['value'];
$kernel->get_instance_by_id($id);
$pos = strpos($kernel->name, 'resource');
if ($pos === false) {
$cloud_product_id = (int) str_replace(".", "", str_pad(microtime(true), 15, "0"));
$create_kernel_cloudselector_config = "insert into cloud_selector (id, type, sort_id, quantity, price, name, description, state) VALUES (" . $cloud_product_id . ", 'kernel', " . $next_sort_id . ", '" . $kernel->id . "', 1, '" . $kernel->name . "', '" . $kernel->version . "', 1);";
$recordSet = $db->Execute($create_kernel_cloudselector_config);
$next_sort_id++;
}
}
// create default projects
$cloud_hook_config = array();
$cloud_id = (int) str_replace(".", "", str_pad(microtime(true), 15, "0"));
$create_default_usergroup = "insert into cloud_usergroups VALUES (" . $cloud_id . ",'Default'," . $cloud_id . ",'The Default Cloud Project');";
$recordSet = $db->Execute($create_default_usergroup);
$cloud_admin_usergroup_id = (int) str_replace(".", "", str_pad(microtime(true), 15, "0"));
$create_default_usergroup = "insert into cloud_usergroups VALUES (" . $cloud_admin_usergroup_id . ",'Admin'," . $cloud_admin_usergroup_id . ",'The Admin Cloud Project');";
示例10: select
function select()
{
$h = array();
$h['appliance_state']['title'] = ' ';
$h['appliance_state']['sortable'] = false;
/*
$h['appliance_icon']['title'] =' ';
$h['appliance_icon']['sortable'] = false;
*/
$h['appliance_id']['title'] = $this->lang['table_id'];
$h['appliance_name']['title'] = $this->lang['table_name'];
$h['appliance_values']['title'] = ' ';
$h['appliance_values']['sortable'] = false;
$h['login']['title'] = ' ';
$h['login']['sortable'] = false;
// use the appliance link hook
require_once $this->openqrm->get('webdir') . "/plugins/sshterm/openqrm-sshterm-appliance-link-hook.php";
$appliance = new appliance();
$params = $this->response->get_array($this->actions_name, 'select');
$b = array();
$table = $this->response->html->tablebuilder('login', $params);
$table->offset = 0;
$table->sort = 'appliance_id';
$table->limit = 10;
$table->order = 'ASC';
$table->init();
$appliances = $appliance->display_overview($table->offset, 100000, $table->sort, $table->order);
foreach ($appliances as $index => $appliance_db) {
$appliance = new appliance();
$appliance->get_instance_by_id($appliance_db["appliance_id"]);
$resource = new resource();
$resource->get_instance_by_id($appliance->resources);
$kernel = new kernel();
$kernel->get_instance_by_id($appliance_db["appliance_kernelid"]);
$image = new image();
$image->get_instance_by_id($appliance_db["appliance_imageid"]);
$virtualization = new virtualization();
$virtualization->get_instance_by_id($appliance_db["appliance_virtualization"]);
$resource_icon_default = "/openqrm/base/img/appliance.png";
$active_state_icon = "active";
$inactive_state_icon = "inactive";
$login = '';
if ($appliance->stoptime == 0 || $appliance->resources == 0) {
$state_icon = $active_state_icon;
// login
$login = get_sshterm_appliance_link($appliance->id);
if (is_object($login)) {
$login = $login->get_string();
}
} else {
$state_icon = $inactive_state_icon;
$login = '';
}
$str = '<strong>Kernel:</strong> ' . $kernel->name . '<br>
<strong>Image:</strong> ' . $image->name . '<br>
<strong>Resource:</strong> ' . $resource->id . " / " . $resource->ip . '<br>
<strong>Type:</strong> <span class="pill">' . $virtualization->name . "</span>";
$state_pill = $this->response->html->span();
$state_pill->css = "pill";
$state_pill->add($state_icon);
$b[] = array('appliance_state' => $state_pill->get_string(), 'appliance_id' => $appliance->id, 'appliance_name' => $appliance->name, 'appliance_values' => $str, 'login' => $login);
}
$table->id = 'Tabelle';
$table->css = 'htmlobject_table';
$table->border = 1;
$table->cellspacing = 0;
$table->cellpadding = 3;
$table->form_action = $this->response->html->thisfile;
$table->autosort = true;
$table->sort_link = false;
$table->max = count($b);
$table->head = $h;
$table->body = $b;
$table->limit_select = array(array("value" => 5, "text" => 5), array("value" => 10, "text" => 10), array("value" => 20, "text" => 20), array("value" => 30, "text" => 30), array("value" => 50, "text" => 50), array("value" => 100, "text" => 100));
$d = array();
$d['table'] = $table;
return $d;
}
示例11: start
function start()
{
$response = $this->get_response();
$appliances = $response->html->request()->get($this->identifier_name);
$form = $response->form;
$appliance = new appliance();
if ($appliances !== '') {
// auto submit
// $_REQUEST[$response->id]['submit'] = true;
$submit = $form->get_elements('submit');
$submit->handler = 'onclick="wait();"';
$form->add($submit, 'submit');
$submit = $form->get_elements('cancel');
$submit->handler = 'onclick="cancel();"';
$form->add($submit, 'cancel');
$i = 0;
foreach ($appliances as $id) {
$appliance = $appliance->get_instance_by_id($id);
$d['param_f' . $i]['label'] = $appliance->name;
$d['param_f' . $i]['object']['type'] = 'htmlobject_input';
$d['param_f' . $i]['object']['attrib']['type'] = 'checkbox';
$d['param_f' . $i]['object']['attrib']['name'] = $this->identifier_name . '[' . $i . ']';
$d['param_f' . $i]['object']['attrib']['value'] = $id;
$d['param_f' . $i]['object']['attrib']['checked'] = true;
$i++;
}
$form->add($d);
if (!$form->get_errors() && $response->submit()) {
$errors = array();
$message = array();
foreach ($appliances as $key => $id) {
$appliance = $appliance->get_instance_by_id($id);
$resource = new resource();
if ($appliance->resources < 0) {
// an appliance with resource auto-select enabled
$appliance_virtualization = $appliance->virtualization;
$appliance->find_resource($appliance_virtualization);
$appliance->get_instance_by_id($id);
if ($appliance->resources < 0) {
$errors[] = sprintf($this->lang['msg_no_resource'], $id);
continue;
}
}
$resource->get_instance_by_id($appliance->resources);
if ($appliance->resources == 0) {
$errors[] = sprintf($this->lang['msg_always_active'], $id);
continue;
}
if (!strcmp($appliance->state, "active")) {
$errors[] = sprintf($this->lang['msg_already_active'], $id);
continue;
}
// check that resource is idle
$app_resource = new resource();
$app_resource->get_instance_by_id($appliance->resources);
// resource has ip ?
if (!strcmp($app_resource->ip, "0.0.0.0")) {
$errors[] = sprintf($this->lang['msg_already_active'], $appliance->resources, $id);
continue;
}
// resource assinged to imageid 1 ?
if ($app_resource->imageid != 1) {
$errors[] = sprintf($this->lang['msg_already_active'], $appliance->resources, $id);
continue;
}
// resource active
if (strcmp($app_resource->state, "active")) {
$app_resource_virtualization = new virtualization();
$app_resource_virtualization->get_instance_by_id($app_resource->vtype);
// allow waking up physical systems via out-of-band-management plugins
if (!strstr($app_resource_virtualization->name, "Host")) {
if ($app_resource_virtualization->id != 1) {
$errors[] = sprintf($this->lang['msg_already_active'], $appliance->resources, $id);
continue;
}
}
}
// if no errors then we start the appliance
$kernel = new kernel();
$kernel->get_instance_by_id($appliance->kernelid);
// send command to the openQRM-server
$resource->send_command("127.0.0.1", "openqrm_assign_kernel " . $resource->id . " " . $resource->mac . " " . $kernel->name);
$appliance->start();
$form->remove($this->identifier_name . '[' . $key . ']');
$message[] = sprintf($this->lang['msg'], $id);
}
if (count($errors) === 0) {
$response->msg = join('<br>', $message);
} else {
$msg = array_merge($errors, $message);
$response->error = join('<br>', $msg);
}
}
} else {
$response->msg = '';
}
return $response;
}
示例12: select
function select()
{
$d = array();
$h = array();
/*
$h['kernel_icon']['title'] =' ';
$h['kernel_icon']['sortable'] = false;
*/
$h['kernel_id']['title'] = $this->lang['table_id'];
$h['kernel_name']['title'] = $this->lang['table_name'];
$h['kernel_version']['title'] = $this->lang['table_version'];
$h['kernel_comment']['title'] = $this->lang['table_comment'];
$h['kernel_comment']['sortable'] = false;
$h['edit']['title'] = ' ';
$h['edit']['sortable'] = false;
$h['default']['title'] = ' ';
$h['default']['sortable'] = false;
$kernel = new kernel();
$params = $this->response->get_array($this->actions_name, 'select');
$b = array();
$table = $this->response->html->tablebuilder('kernel', $params);
$table->offset = 0;
$table->sort = 'kernel_id';
$table->limit = 10;
$table->order = 'ASC';
$table->max = $kernel->get_count();
$table->init();
// handle table params
$tps = $table->get_params();
$tp = '';
foreach ($tps['kernel'] as $k => $v) {
$tp .= '&kernel[' . $k . ']=' . $v;
}
$kernel_arr = $kernel->display_overview($table->offset, $table->limit, $table->sort, $table->order);
$kernel_icon = "/openqrm/base/img/kernel.png";
foreach ($kernel_arr as $index => $kernel_db) {
// prepare the values for the array
$kernel = new kernel();
$kernel->get_instance_by_id($kernel_db["kernel_id"]);
$kernel_comment = $kernel_db["kernel_comment"];
if (!strlen($kernel_comment)) {
$kernel_comment = " ";
}
$default = '';
// setdefault
if ($kernel_db["kernel_id"] != 1) {
if (strncmp($kernel->name, "resource", 7) && !strstr($kernel->capabilities, "local-server")) {
$a = $this->response->html->a();
$a->title = sprintf($this->lang['action_setdefault'], $kernel_db["kernel_id"]);
$a->handler = 'onclick="wait();"';
$a->css = 'default';
$a->href = $this->response->get_url($this->actions_name, 'setdefault') . '&' . $this->identifier_name . '[]=' . $kernel->id . '' . $tp;
$default = $a->get_string();
}
}
// edit
$a = $this->response->html->a();
$a->label = $this->lang['action_edit'];
$a->handler = 'onclick="wait();"';
$a->css = 'edit';
$a->href = $this->response->get_url($this->actions_name, 'edit') . '&' . $this->identifier_name . '=' . $kernel->id . '' . $tp;
$edit = $a->get_string();
$b[] = array('kernel_id' => $kernel_db["kernel_id"], 'kernel_name' => $kernel_db["kernel_name"], 'kernel_version' => $kernel_db["kernel_version"], 'kernel_comment' => $kernel_comment, 'edit' => $edit, 'default' => $default);
}
$add = $this->response->html->a();
$add->title = $this->lang['action_add'];
$add->label = $this->lang['action_add'];
$add->handler = 'onclick="wait();"';
$add->css = 'add';
$add->href = $this->response->get_url($this->actions_name, "add") . '' . $tp;
$table->id = 'Tabelle';
$table->css = 'htmlobject_table';
$table->border = 1;
$table->cellspacing = 0;
$table->cellpadding = 3;
$table->autosort = false;
$table->sort_link = false;
$table->max = $kernel->get_count() - 1;
$table->head = $h;
$table->body = $b;
$table->form_action = $this->response->html->thisfile;
$table->actions_name = $this->actions_name;
$table->actions = array(array('remove' => $this->lang['action_remove']));
$table->identifier = 'kernel_id';
$table->identifier_name = $this->identifier_name;
$table->identifier_disabled = array(0);
$table->limit_select = array(array("value" => 10, "text" => 10), array("value" => 20, "text" => 20), array("value" => 30, "text" => 30), array("value" => 50, "text" => 50), array("value" => 100, "text" => 100));
$d['add'] = $add->get_string();
$d['table'] = $table;
return $d;
}
示例13: start
function start($storage_authentication = NULL)
{
global $event;
global $RootDir;
$appliance_start_timeout = 360;
if ($this->resources < 1) {
$event->log("start", $_SERVER['REQUEST_TIME'], 1, "appliance.class.php", "No resource available for appliance " . $this->id, "", "", 0, 0, 0);
return;
}
$start_with_authblocker = true;
if (isset($storage_authentication)) {
$start_with_authblocker = $storage_authentication;
}
$resource = new resource();
$resource->get_instance_by_id($this->resources);
$kernel = new kernel();
$kernel->get_instance_by_id($this->kernelid);
$image = new image();
$image->get_instance_by_id($this->imageid);
// set image to active
$image->set_active(1);
// update resource state to transition early
$resource_fields = array();
$resource_fields["resource_state"] = "transition";
$resource_fields["resource_event"] = "reboot";
$resource->update_info($resource->id, $resource_fields);
// assign resource, wait a bit for the kernel to be assigned
$resource->assign($resource->id, $kernel->id, $kernel->name, $image->id, $image->name);
sleep(2);
// storage authentication hook
if ($start_with_authblocker) {
$deployment = new deployment();
$deployment->get_instance_by_type($image->type);
$deployment_type = $deployment->type;
$deployment_plugin_name = $deployment->storagetype;
$storage_auth_hook = $RootDir . "/plugins/" . $deployment_plugin_name . "/openqrm-" . $deployment_type . "-auth-hook.php";
if (file_exists($storage_auth_hook)) {
$event->log("start", $_SERVER['REQUEST_TIME'], 5, "appliance.class.php", "Found deployment type " . $deployment_type . " handling the start auth hook.", "", "", 0, 0, $this->resources);
// create storage_auth_blocker if not existing already
$authblocker = new authblocker();
$authblocker->get_instance_by_image_name($image->name);
if (!strlen($authblocker->id)) {
$event->log("start", $_SERVER['REQUEST_TIME'], 5, "appliance.class.php", "Creating new authblocker for image " . $image->name . " / app id " . $this->id . ".", "", "", 0, 0, $this->resources);
$ab_start_time = $_SERVER['REQUEST_TIME'];
$ab_create_fields['ab_image_id'] = $this->imageid;
$ab_create_fields['ab_image_name'] = $image->name;
$ab_create_fields['ab_start_time'] = $ab_start_time;
// get a new id
$ab_create_fields['ab_id'] = (int) str_replace(".", "", str_pad(microtime(true), 15, "0"));
$authblocker->add($ab_create_fields);
}
$storage_auth_blocker_created = true;
// run the auth hook
require_once "{$storage_auth_hook}";
storage_auth_function("start", $this->id);
} else {
$event->log("start", $_SERVER['REQUEST_TIME'], 5, "appliance.class.php", "No storage-auth hook (" . $storage_auth_hook . ") available for deployment type " . $deployment_type . " for start auth hook.", "", "", 0, 0, $this->resources);
$storage_auth_blocker_created = false;
}
// delay to be sure to have the storage hook run before the reboot
if ($storage_auth_blocker_created) {
$wait_for_storage_auth_loop = 0;
while (true) {
unset($check_authblocker);
$check_authblocker = new authblocker();
$check_authblocker->get_instance_by_image_name($image->name);
if (strlen($check_authblocker->id)) {
// ab still existing, check timeout
if ($wait_for_storage_auth_loop > $appliance_start_timeout) {
// remove authblocker
$check_authblocker->remove($check_authblocker->id);
// set appliance to stopped
$image->set_active(0);
$resource_fields = array();
$resource_fields["resource_state"] = "active";
$resource_fields["resource_event"] = "noop";
$resource->update_info($resource->id, $resource_fields);
$resource->assign($resource->id, "1", "default", "1", "idle");
$event->log("start", $_SERVER['REQUEST_TIME'], 2, "appliance.class.php", "Failed starting server " . $this->id . ". Storage-authentication timed out!", "", "", 0, 0, $this->resources);
sleep(2);
break;
}
sleep(1);
$wait_for_storage_auth_loop++;
} else {
// here we got the remove-auth-blocker message from the storage-auth hook
// now we can be sure that storage auth ran before rebooting the resource
$event->log("start", $_SERVER['REQUEST_TIME'], 5, "appliance.class.php", "Storage authentication for image " . $image->name . " succeeded, assigning the resource now.", "", "", 0, 0, $this->resources);
break;
}
}
}
} else {
$event->log("start", $_SERVER['REQUEST_TIME'], 5, "appliance.class.php", "Starting without storage authentication for image " . $image->name . ".", "", "", 0, 0, $this->resources);
}
// unset stoptime + update starttime + state
$now = $_SERVER['REQUEST_TIME'];
$appliance_fields = array();
$appliance_fields['appliance_stoptime'] = '';
$appliance_fields['appliance_starttime'] = $now;
//.........这里部分代码省略.........
示例14: details
function details()
{
$this->response->add($this->identifier_name, $this->response->html->request()->get($this->identifier_name));
$kernel = new kernel();
$kernel->get_instance_by_id($this->cloud_request->kernel_id);
$image = new image();
$image->get_instance_by_id($this->cloud_request->image_id);
$virtualization = new virtualization();
$virtualization->get_instance_by_id($this->cloud_request->resource_type_req);
$cr_status = $this->cloud_request->getstatus($this->cloud_request->id);
$ha_req = '';
if (isset($this->cloud_request->ha_req) && $this->cloud_request->ha_req == 1) {
$ha_req = $this->lang['cloud_request_enabled'];
} else {
$ha_req = $this->lang['cloud_request_disabled'];
}
$appliance_hostname = '';
if (strlen($this->cloud_request->appliance_hostname)) {
$appliance_hostname = $this->cloud_request->appliance_hostname;
} else {
$appliance_hostname = '-';
}
$appliance_applications = '';
if (strlen($this->cloud_request->puppet_groups)) {
$appliance_applications = $this->cloud_request->puppet_groups;
} else {
$appliance_applications = '-';
}
$appliance_ip_config = '';
if (strlen($this->cloud_request->ip_mgmt)) {
$ip_config_arr = explode(',', $this->cloud_request->ip_mgmt);
foreach ($ip_config_arr as $ip) {
$single_ip_config_arr = explode(':', $ip);
$nic_no = $single_ip_config_arr[0];
switch ($single_ip_config_arr[1]) {
case '-2':
$appliance_ip_config .= $this->lang['cloud_request_network_req'] . ' ' . $nic_no . ':auto<br>';
break;
default:
$appliance_ip_config .= $this->lang['cloud_request_network_req'] . ' ' . $nic_no . ':custom<br>';
break;
}
}
} else {
$appliance_ip_config = '-';
}
$table = $this->response->html->table();
$table->css = 'htmlobject_table';
$table->border = 0;
$table->id = 'cloud_request_details';
$ta[] = array('cr_key' => $this->lang['cloud_request_id'], 'cr_value' => $this->cloud_request->id);
$ta[] = array('cr_key' => $this->lang['cloud_request_status'], 'cr_value' => $cr_status);
$ta[] = array('cr_key' => $this->lang['cloud_request_time'], 'cr_value' => date("Y-m-d H:i:s", $this->cloud_request->request_time));
$ta[] = array('cr_key' => $this->lang['cloud_request_start_time'], 'cr_value' => date("Y-m-d H:i:s", $this->cloud_request->start));
$ta[] = array('cr_key' => $this->lang['cloud_request_stop_time'], 'cr_value' => date("Y-m-d H:i:s", $this->cloud_request->stop));
$ta[] = array('cr_key' => $this->lang['cloud_request_kernel'], 'cr_value' => $kernel->name);
$ta[] = array('cr_key' => $this->lang['cloud_request_image'], 'cr_value' => $image->name);
$ta[] = array('cr_key' => $this->lang['cloud_request_cpu_req'], 'cr_value' => $this->cloud_request->cpu_req);
$ta[] = array('cr_key' => $this->lang['cloud_request_ram_req'], 'cr_value' => $this->cloud_request->ram_req . " MB");
$ta[] = array('cr_key' => $this->lang['cloud_request_disk_req'], 'cr_value' => $this->cloud_request->disk_req . " MB");
$ta[] = array('cr_key' => $this->lang['cloud_request_network_req'], 'cr_value' => $this->cloud_request->network_req);
$ta[] = array('cr_key' => $this->lang['cloud_request_app_id'], 'cr_value' => $this->cloud_request->appliance_id);
$ta[] = array('cr_key' => $this->lang['cloud_request_resource_req'], 'cr_value' => $virtualization->name);
$ta[] = array('cr_key' => $this->lang['cloud_request_ha_req'], 'cr_value' => $ha_req);
$ta[] = array('cr_key' => $this->lang['cloud_request_name'], 'cr_value' => $appliance_hostname);
$ta[] = array('cr_key' => $this->lang['cloud_request_applications'], 'cr_value' => $appliance_applications);
$ta[] = array('cr_key' => $this->lang['cloud_request_ipconfig'], 'cr_value' => $appliance_ip_config);
$table->add($ta);
return $table;
}
示例15: cloudselector
function cloud_cost_calculator()
{
require_once $this->rootdir . "/plugins/cloud/class/cloudselector.class.php";
$cloudselector = new cloudselector();
$virtualization_id = $this->response->html->request()->get('virtualization');
$kernel_id = $this->response->html->request()->get('kernel');
$memory_val = $this->response->html->request()->get('memory');
$cpu_val = $this->response->html->request()->get('cpu');
$disk_val = $this->response->html->request()->get('disk');
$network_val = $this->response->html->request()->get('network');
$ha_val = $this->response->html->request()->get('ha');
$apps_val = $this->response->html->request()->get('apps');
// resource type
$cost_virtualization = 0;
if (strlen($virtualization_id)) {
$virtualization = new virtualization();
$virtualization->get_instance_by_id($virtualization_id);
$cost_virtualization = $cloudselector->get_price($virtualization->id, "resource");
}
// kernel
$cost_kernel = 0;
if (strlen($kernel_id)) {
$kernel = new kernel();
$kernel->get_instance_by_id($kernel_id);
$cost_kernel = $cloudselector->get_price($kernel->id, "kernel");
}
// memory
$cost_memory = 0;
if (strlen($memory_val)) {
$cost_memory = $cloudselector->get_price($memory_val, "memory");
}
// cpu
$cost_cpu = 0;
if (strlen($cpu_val)) {
$cost_cpu = $cloudselector->get_price($cpu_val, "cpu");
}
// disk
$cost_disk = 0;
if (strlen($disk_val)) {
$cost_disk = $cloudselector->get_price($disk_val, "disk");
}
// network
$cost_network = 0;
if (strlen($network_val)) {
$cost_network = $cloudselector->get_price($network_val, "network");
}
// ha
$cost_ha = 0;
if ($ha_val == 1) {
$cost_ha = $cloudselector->get_price($ha_val, "ha");
}
// puppet apps
$cost_app_total = 0;
if (strlen($apps_val)) {
$apps_val = trim($apps_val, ',');
$application_array = explode(",", $apps_val);
foreach ($application_array as $cloud_app) {
$cost_app = $cloudselector->get_price($cloud_app, "application");
$cost_app_total = $cost_app_total + $cost_app;
}
}
// get cloud currency
$currency = $this->cloudconfig->get_value_by_key('cloud_currency');
// 23 is cloud_currency
$ccus_value = $this->cloudconfig->get_value_by_key('cloud_1000_ccus');
// 24 is cloud_1000_ccus
// summary
$per_appliance = $cost_virtualization + $cost_kernel + $cost_memory + $cost_cpu + $cost_disk + $cost_network + $cost_app_total + $cost_ha;
$real_currency = $ccus_value / 1000;
$per_hour = $per_appliance * $real_currency;
$per_day = $per_hour * 24;
$per_month = $per_day * 31;
$per_hour = number_format($per_hour, 2, ",", "");
$per_day = number_format($per_day, 2, ",", "");
$per_month = number_format($per_month, 2, ",", "");
$costs = 'summary=' . $per_appliance . ';';
$costs .= 'total=' . $cost_app_total . ' ' . $currency . ';';
$costs .= 'hour=' . $per_hour . ' ' . $currency . ';';
$costs .= 'day=' . $per_day . ' ' . $currency . ';';
$costs .= 'month=' . $per_month . ' ' . $currency . ';';
echo $costs;
}