コード例 #1
0
 $found_hc = false;
 $found_hc_id = -1;
 foreach ($hc_id_list as $list) {
     foreach ($list as $hc_id) {
         $storage->get_instance_by_id($hc_id);
         if ($storage->resource_id == 0) {
             $found_hc = true;
             $found_hc_id = $storage->id;
             break;
         }
     }
 }
 if ($found_hc) {
     // remove all AMI Images, then the storage
     $image = new image();
     $hc_image_list = $image->get_ids_by_storage($found_hc_id);
     foreach ($hc_image_list as $list) {
         foreach ($list as $hc_image_id) {
             $image->remove($hc_image_id);
             $event->log("init", $_SERVER['REQUEST_TIME'], 5, "hybrid-cloud-ation", "Removed AMI Image Object " . $hc_image_id . ".", "", "", 0, 0, 0);
         }
     }
     $storage->remove($found_hc_id);
 }
 // remove cloud products
 if (file_exists($cloud_usergroup_class)) {
     require_once $cloud_usergroup_class;
     $cloud_project = new cloudusergroup();
     $cloud_project->get_instance_by_name('Admin');
     if (file_exists($cloud_selector_class)) {
         if (file_exists($cloud_product_hook)) {
コード例 #2
0
 function remove()
 {
     $response = $this->get_response();
     $storages = $response->html->request()->get($this->identifier_name);
     $form = $response->form;
     $storage = new storage();
     if ($storages !== '') {
         $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 ($storages as $id) {
             $storage = $storage->get_instance_by_id($id);
             $d['param_f' . $i]['label'] = $storage->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 ($storages as $key => $id) {
                 $storage = $storage->get_instance_by_id($id);
                 $storage_name = $storage->name;
                 $image_is_used_by_storage = "";
                 $remove_error = 0;
                 $image_remove_check = new image();
                 $image_remove_id_list = $image_remove_check->get_ids_by_storage($id);
                 foreach ($image_remove_id_list as $image_list) {
                     $image_id = $image_list['image_id'];
                     $image_is_used_by_storage .= $image_id . " ";
                     $remove_error = 1;
                 }
                 if ($remove_error == 1) {
                     $message[] = sprintf($this->lang['msg_not_removing_active'], $id, $image_is_used_by_storage);
                     continue;
                 }
                 $storage->remove($id);
                 $form->remove($this->identifier_name . '[' . $key . ']');
                 $message[] = sprintf($this->lang['msg_removed'], $storage_name);
             }
             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;
 }