Exemplo n.º 1
0
 function VirtualizationGetList($method_parameters)
 {
     global $event;
     $parameter_array = explode(',', $method_parameters);
     $mode = $parameter_array[0];
     $username = $parameter_array[1];
     $password = $parameter_array[2];
     // check all user input
     for ($i = 0; $i <= 2; $i++) {
         if (!$this->check_param($parameter_array[$i])) {
             $event->log("cloudsoap->VirtualizationGetList", $_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 != 3) {
         $event->log("cloudsoap->VirtualizationGetList", $_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->VirtualizationGetList", $_SERVER['REQUEST_TIME'], 2, "cloud-soap-server.php", "User authentication failed (mode {$mode})", "", "", 0, 0, 0);
         return;
     }
     $event->log("cloudsoap->VirtualizationGetList", $_SERVER['REQUEST_TIME'], 5, "cloud-soap-server.php", "Providing list of available virtualizations", "", "", 0, 0, 0);
     $virtualization = new virtualization();
     $virtualization_list = $virtualization->get_list();
     $virtualization_name_list = array();
     $virtualization_return_list = array();
     foreach ($virtualization_list as $virtualizations) {
         $virtualization_name_list[] = $virtualizations['label'];
     }
     // check if to show physical system type
     $cc_conf = new cloudconfig();
     $cc_request_physical_systems = $cc_conf->get_value(4);
     // request_physical_systems
     if (!strcmp($cc_request_physical_systems, "false")) {
         array_shift($virtualization_name_list);
     }
     // filter out the virtualization hosts
     $cloudselector = new cloudselector();
     $cloud_selector_enabled = $cc_conf->get_value(22);
     // cloudselector
     foreach ($virtualization_name_list as $virt) {
         if (!strstr($virt, "Host")) {
             // check cloudselector
             if (!strcmp($cloud_selector_enabled, "true")) {
                 // virtualization
                 $cs_virt_type = new virtualization();
                 $cs_virt_type->get_instance_by_name($virt);
                 if ($cloudselector->product_exists_enabled("resource", $cs_virt_type->id)) {
                     $virtualization_return_list[] = $virt;
                 }
             } else {
                 $virtualization_return_list[] = $virt;
             }
         }
     }
     return $virtualization_return_list;
 }