function add()
 {
     $response = $this->get_response();
     $form = $response->form;
     if (!$form->get_errors() && $this->response->submit()) {
         $fi = $form->get_request();
         $hc_account_name = $fi['hybrid_cloud_account_name'];
         $hc_account_type = $form->get_static('type');
         $hc_account_type = $hc_account_type['0'];
         $fi['hybrid_cloud_account_type'] = $hc_account_type;
         $hc_authentication = '';
         if ($hc_account_type == 'aws' || $hc_account_type == 'euca') {
             $hc_access_key = $fi['hybrid_cloud_access_key'];
             $hc_secret_key = $fi['hybrid_cloud_secret_key'];
             $hc_authentication = ' -O ' . $hc_access_key . ' -W ' . $hc_secret_key;
         }
         if ($hc_account_type == 'lc-openstack') {
             $hc_username = $fi['hybrid_cloud_username'];
             $hc_password = $fi['hybrid_cloud_password'];
             $hc_host = $fi['hybrid_cloud_host'];
             $hc_port = $fi['hybrid_cloud_port'];
             $hc_tenant = $fi['hybrid_cloud_tenant'];
             $hc_endpoint = $fi['hybrid_cloud_endpoint'];
             $hc_authentication = ' -u ' . $hc_username . ' -p ' . $hc_password . ' -q ' . $hc_host . ' -x ' . $hc_port . ' -g ' . $hc_tenant . ' -e ' . $hc_endpoint;
         }
         // check if account data is valid and working
         $file = $this->openqrm->get('basedir') . '/plugins/hybrid-cloud/web/hybrid-cloud-stat/' . $hc_account_name . '.acl_check.log';
         if ($this->file->exists($file)) {
             $this->file->remove($file);
         }
         $command = $this->openqrm->get('basedir') . '/plugins/hybrid-cloud/bin/openqrm-hybrid-cloud-account check';
         $command .= ' -n ' . $hc_account_name;
         $command .= ' -t ' . $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);
         $pos = strpos($content, "success");
         if ($pos === false) {
             $response->msg = sprintf($this->lang['msg_add_fail'], $fi['hybrid_cloud_account_name']);
         } else {
             require_once $this->openqrm->get('basedir') . '/plugins/hybrid-cloud/web/class/hybrid-cloud.class.php';
             $hc = new hybrid_cloud();
             $fi['hybrid_cloud_id'] = (int) str_replace(".", "", str_pad(microtime(true), 15, "0"));
             $hc->add($fi);
             $response->msg = sprintf($this->lang['msg_added'], $fi['hybrid_cloud_account_name']);
         }
         $this->file->remove($file);
     }
     return $response;
 }