当前位置: 首页>>代码示例>>PHP>>正文


PHP resource::remove方法代码示例

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


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

示例1: remove

 /**
  * 执行remove操作
  *
  * @param array $query            
  * @return array boolean
  */
 public function remove(array $query)
 {
     try {
         return $this->result($this->_client->remove(serialize($query)));
     } catch (SoapFault $e) {
         $this->soapFaultMsg($e);
         return false;
     }
 }
开发者ID:im286er,项目名称:ent,代码行数:15,代码来源:iDatabase.php

示例2: remove

 function remove()
 {
     $response = $this->get_response();
     $instance_name = $response->html->request()->get('instance_name');
     $form = $response->form;
     $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');
     $d['param_f']['label'] = $instance_name;
     $d['param_f']['object']['type'] = 'htmlobject_input';
     $d['param_f']['object']['attrib']['type'] = 'checkbox';
     $d['param_f']['object']['attrib']['name'] = 'instance_name';
     $d['param_f']['object']['attrib']['value'] = $instance_name;
     $d['param_f']['object']['attrib']['checked'] = true;
     $form->add($d);
     if (!$form->get_errors() && $response->submit()) {
         $errors = array();
         $message = array();
         $resource = new resource();
         $resource->get_instance_by_mac($this->instance_mac);
         $appliance = new appliance();
         $appliances_using_resource = $appliance->get_ids_per_resource($resource->id);
         if (count($appliances_using_resource) > 0) {
             $appliances_using_resource_str = implode(",", $appliances_using_resource[0]);
             $errors[] = sprintf($this->lang['msg_vm_resource_still_in_use'], $instance_name, $resource->id, $appliances_using_resource_str);
         } else {
             $resource->remove($resource->id, $this->instance_mac);
             $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 remove';
             $command .= ' -i ' . $this->hc->id;
             $command .= ' -n ' . $this->hc->account_name;
             $command .= ' -t ' . $this->hc->account_type;
             $command .= ' -in ' . $instance_name;
             $command .= $hc_authentication;
             $command .= ' --openqrm-ui-user ' . $this->user->name;
             $command .= ' --openqrm-cmd-mode background';
             $openqrm = new openqrm_server();
             $openqrm->send_command($command, NULL, true);
             $message[] = sprintf($this->lang['msg_removed'], $instance_name);
         }
         if (count($errors) === 0) {
             $response->msg = join('<br>', $message);
         } else {
             $msg = array_merge($errors, $message);
             $response->error = join('<br>', $msg);
         }
     }
     return $response;
 }
开发者ID:kelubo,项目名称:OpenQRM,代码行数:65,代码来源:hybrid-cloud-vm.remove.class.php

示例3: remove

 function remove($resource_id, $virtualization_type, $name, $mac)
 {
     global $OPENQRM_SERVER_BASE_DIR;
     global $OPENQRM_SERVER_IP_ADDRESS;
     global $OPENQRM_EXEC_PORT;
     global $RESOURCE_INFO_TABLE;
     global $RootDir;
     global $event;
     // never remove the openQRM server resource
     if ($resource_id == 0) {
         return;
     }
     $vtype = new virtualization();
     $vtype->get_instance_by_id($virtualization_type);
     $virtualization_plugin_name = $vtype->get_plugin_name();
     // remove the VM from host
     $auto_resource = new resource();
     $auto_resource->get_instance_by_id($resource_id);
     $host_resource = new resource();
     $host_resource->get_instance_by_id($auto_resource->vhostid);
     $event->log("remove", $_SERVER['REQUEST_TIME'], 5, "cloudvm.class.php", "Trying to remove resource {$resource_id} type {$virtualization_plugin_name} on host {$host_resource->id} ({$mac})", "", "", 0, 0, 0);
     // we need to have an openQRM server object too since some of the
     // virtualization commands are sent from openQRM directly
     $openqrm = new openqrm_server();
     // 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("remove", $_SERVER['REQUEST_TIME'], 5, "cloudvm.class", "Found plugin {$virtualization_plugin_name} handling to remove the VM.", "", "", 0, 0, $resource_id);
         require_once "{$virtualization_cloud_hook}";
         $virtualization_method = "remove_" . $vtype->type;
         $virtualization_method = str_replace("-", "_", $virtualization_method);
         $virtualization_method($host_resource->id, $name, $mac);
     } else {
         $event->log("cloud", $_SERVER['REQUEST_TIME'], 5, "cloudvm.class", "Do not know how to remove VM from type {$virtualization_plugin_name}.", "", "", 0, 0, 0);
         return false;
     }
     // let plugin hooks settle
     sleep(2);
     // remove VM from hostlimit current_vms
     $res_hostlimit = new cloudhostlimit();
     $res_hostlimit->get_instance_by_resource($host_resource->id);
     if (strlen($res_hostlimit->id)) {
         if ($res_hostlimit->current_vms > 0) {
             $current_vms = $res_hostlimit->current_vms - 1;
             $cloud_hostlimit_fields["hl_current_vms"] = $current_vms;
             $res_hostlimit->update($res_hostlimit->id, $cloud_hostlimit_fields);
         }
     }
     // resource object remove
     $auto_resource->remove($auto_resource->id, $auto_resource->mac);
     $event->log("remove", $_SERVER['REQUEST_TIME'], 5, "cloudvm.class.php", "Removed resource {$resource_id}", "", "", 0, 0, 0);
 }
开发者ID:kelubo,项目名称:OpenQRM,代码行数:52,代码来源:cloudvm.class.php

示例4: resource

     $resource->add($resource_fields);
     // set lastgood to -1 to prevent automatic checking the state
     $resource_fields["resource_lastgood"] = -1;
     $resource->update_info($new_resource_id, $resource_fields);
     // $resource->get_parameter($new_resource_id);
     break;
     // remove requires :
     // resource_id
     // resource_mac
 // remove requires :
 // resource_id
 // resource_mac
 case 'remove':
     // remove from openQRM database
     $resource = new resource();
     $resource->remove($resource_id, $resource_mac);
     break;
     // localboot requires :
     // resource_id
     // resource_mac
     // resource_ip
 // localboot requires :
 // resource_id
 // resource_mac
 // resource_ip
 case 'localboot':
     $openqrm_server->send_command("openqrm_server_set_boot local {$resource_id} {$resource_mac} {$resource_ip}");
     // update db
     $resource = new resource();
     $resource->set_localboot($resource_id, 1);
     break;
开发者ID:kelubo,项目名称:OpenQRM,代码行数:31,代码来源:resource-action.php

示例5: remove

 function remove()
 {
     $response = $this->get_response();
     $vms = $response->html->request()->get($this->identifier_name);
     $form = $response->form;
     if ($vms !== '') {
         $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 ($vms as $ex) {
             $d['param_f' . $i]['label'] = $ex;
             $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'] = $ex;
             $d['param_f' . $i]['object']['attrib']['checked'] = true;
             $i++;
         }
         $form->add($d);
         if (!$form->get_errors() && $response->submit()) {
             $appliance_id = $this->response->html->request()->get('appliance_id');
             $appliance = new appliance();
             $resource = new resource();
             $errors = array();
             $message = array();
             foreach ($vms as $key => $vm) {
                 $appliance->get_instance_by_id($appliance_id);
                 $resource->get_instance_by_id($appliance->resources);
                 $file = $this->openqrm->get('basedir') . '/plugins/kvm/web/kvm-stat/' . $resource->id . '.vm_list';
                 if ($this->file->exists($file)) {
                     $lines = explode("\n", $this->file->get_contents($file));
                     if (count($lines) >= 1) {
                         foreach ($lines as $line) {
                             if ($line !== '') {
                                 $line = explode('@', $line);
                                 if ($vm === $line[1]) {
                                     $kvm = new resource();
                                     $kvm->get_instance_by_mac($line[2]);
                                     // check if it is still in use
                                     $appliances_using_resource = $appliance->get_ids_per_resource($kvm->id);
                                     if (count($appliances_using_resource) > 0) {
                                         $appliances_using_resource_str = implode(",", $appliances_using_resource[0]);
                                         $errors[] = sprintf($this->lang['msg_vm_resource_still_in_use'], $vm, $kvm->id, $appliances_using_resource_str);
                                     } else {
                                         $kvm->remove($kvm->id, $line[2]);
                                         $command = $this->openqrm->get('basedir') . '/plugins/kvm/bin/openqrm-kvm-vm delete -n ' . $vm;
                                         $command .= ' -u ' . $this->openqrm->admin()->name . ' -p ' . $this->openqrm->admin()->password;
                                         $command .= ' --openqrm-ui-user ' . $this->user->name;
                                         $command .= ' --openqrm-cmd-mode background';
                                         $resource->send_command($resource->ip, $command);
                                         $form->remove($this->identifier_name . '[' . $key . ']');
                                         $message[] = sprintf($this->lang['msg_removed'], $vm);
                                         // stop remote console
                                         $tmp = explode(':', $line[5]);
                                         $server = $tmp[0];
                                         $port = $tmp[1];
                                         $mac = $line[2];
                                         $rid = $kvm->id;
                                         $event = new event();
                                         $plugin = new plugin();
                                         $enabled = $plugin->enabled();
                                         foreach ($enabled as $index => $name) {
                                             $running = $this->openqrm->get('webdir') . '/plugins/' . $name . '/.running';
                                             $hook = $this->openqrm->get('webdir') . '/plugins/' . $name . '/openqrm-' . $name . '-remote-console-hook.php';
                                             if (file_exists($hook)) {
                                                 if (file_exists($running)) {
                                                     $event->log("console", $_SERVER['REQUEST_TIME'], 5, "kvm-storge-vm.remove.class.php", 'Stopping ' . $name . ' remote console.', "", "", 0, 0, $kvm->id);
                                                     require_once $hook;
                                                     $console_function = 'openqrm_' . $name . '_disable_remote_console';
                                                     $console_function = str_replace("-", "_", $console_function);
                                                     $console_function($server, $port, $rid, $mac, $vm);
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
             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;
 }
开发者ID:kelubo,项目名称:OpenQRM,代码行数:97,代码来源:kvm-vm.remove.class.php


注:本文中的resource::remove方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。