Ejemplo n.º 1
0
 public function initialize_credential($task)
 {
     $target_hostname = $task->target_host_spec->getHost_name();
     $target_host_ip = $task->target_host_spec->getIp();
     $storage_ip = $task->target_host_spec->getBackup_dest_ip();
     //
     $am = new AuthenticationManager();
     if ($task->target_host_credential->getType() == CREDENTIAL_TYPE0) {
         //echo "\nPlease Input\033[31m Source Host\033[0m :$target_hostname($target_host_ip) credential information:" . "\n";
         $auth = $am->querryAuthByIp($target_host_ip);
         $username = $auth->username;
         $password = $auth->password;
         $task->target_host_credential->setUser($username);
         $task->target_host_credential->setPassword($password);
     }
     //echo "\nplease input \033[31mStorage host\033[0m ($storage_ip) credential information\n";
     if ($task->storage_credential->getType() == CREDENTIAL_TYPE0) {
         $auth2 = $am->querryAuthByIp($storage_ip);
         $username = $auth2->username;
         $password = $auth2->password;
         $task->storage_credential->setUser($username);
         $task->storage_credential->setPassword($password);
     }
     return $task;
     //print_r($task);
 }