Search in sources :

Example 1 with SSHKeyPairResponse

use of com.cloud.api.response.SSHKeyPairResponse in project CloudStack-archive by CloudStack-extras.

the class CreateSSHKeyPairCmd method execute.

@Override
public void execute() {
    SSHKeyPair r = _mgr.createSSHKeyPair(this);
    SSHKeyPairResponse response = new SSHKeyPairResponse(r.getName(), r.getFingerprint(), r.getPrivateKey());
    response.setResponseName(getCommandName());
    response.setObjectName("keypair");
    this.setResponseObject(response);
}
Also used : SSHKeyPairResponse(com.cloud.api.response.SSHKeyPairResponse) SSHKeyPair(com.cloud.user.SSHKeyPair)

Example 2 with SSHKeyPairResponse

use of com.cloud.api.response.SSHKeyPairResponse in project CloudStack-archive by CloudStack-extras.

the class RegisterSSHKeyPairCmd method execute.

@Override
public void execute() {
    SSHKeyPair result = _mgr.registerSSHKeyPair(this);
    SSHKeyPairResponse response = new SSHKeyPairResponse(result.getName(), result.getFingerprint());
    response.setResponseName(getCommandName());
    response.setObjectName("keypair");
    this.setResponseObject(response);
}
Also used : SSHKeyPairResponse(com.cloud.api.response.SSHKeyPairResponse) SSHKeyPair(com.cloud.user.SSHKeyPair)

Example 3 with SSHKeyPairResponse

use of com.cloud.api.response.SSHKeyPairResponse in project cosmic by MissionCriticalCloud.

the class RegisterSSHKeyPairCmd method execute.

// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() {
    final SSHKeyPair result = _mgr.registerSSHKeyPair(this);
    final SSHKeyPairResponse response = _responseGenerator.createSSHKeyPairResponse(result, false);
    response.setResponseName(getCommandName());
    response.setObjectName("keypair");
    setResponseObject(response);
}
Also used : SSHKeyPairResponse(com.cloud.api.response.SSHKeyPairResponse) SSHKeyPair(com.cloud.user.SSHKeyPair)

Example 4 with SSHKeyPairResponse

use of com.cloud.api.response.SSHKeyPairResponse in project cosmic by MissionCriticalCloud.

the class ApiResponseHelper method createSSHKeyPairResponse.

@Override
public SSHKeyPairResponse createSSHKeyPairResponse(final SSHKeyPair sshkeyPair, final boolean privatekey) {
    SSHKeyPairResponse response = new SSHKeyPairResponse(sshkeyPair.getName(), sshkeyPair.getFingerprint());
    if (privatekey) {
        response = new CreateSSHKeyPairResponse(sshkeyPair.getName(), sshkeyPair.getFingerprint(), sshkeyPair.getPrivateKey());
    }
    final Account account = ApiDBUtils.findAccountById(sshkeyPair.getAccountId());
    response.setAccountName(account.getAccountName());
    final Domain domain = ApiDBUtils.findDomainById(sshkeyPair.getDomainId());
    response.setDomainId(domain.getUuid());
    response.setDomainName(domain.getName());
    return response;
}
Also used : CreateSSHKeyPairResponse(com.cloud.api.response.CreateSSHKeyPairResponse) SSHKeyPairResponse(com.cloud.api.response.SSHKeyPairResponse) UserAccount(com.cloud.user.UserAccount) Account(com.cloud.user.Account) CreateSSHKeyPairResponse(com.cloud.api.response.CreateSSHKeyPairResponse) Domain(com.cloud.domain.Domain)

Example 5 with SSHKeyPairResponse

use of com.cloud.api.response.SSHKeyPairResponse in project CloudStack-archive by CloudStack-extras.

the class ListSSHKeyPairsCmd method execute.

/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public void execute() {
    List<? extends SSHKeyPair> resultList = _mgr.listSSHKeyPairs(this);
    List<SSHKeyPairResponse> responses = new ArrayList<SSHKeyPairResponse>();
    for (SSHKeyPair result : resultList) {
        SSHKeyPairResponse r = new SSHKeyPairResponse(result.getName(), result.getFingerprint());
        r.setObjectName("sshkeypair");
        responses.add(r);
    }
    ListResponse<SSHKeyPairResponse> response = new ListResponse<SSHKeyPairResponse>();
    response.setResponses(responses);
    response.setResponseName(getCommandName());
    this.setResponseObject(response);
}
Also used : SSHKeyPairResponse(com.cloud.api.response.SSHKeyPairResponse) SSHKeyPair(com.cloud.user.SSHKeyPair) ListResponse(com.cloud.api.response.ListResponse) ArrayList(java.util.ArrayList)

Aggregations

SSHKeyPairResponse (com.cloud.api.response.SSHKeyPairResponse)6 SSHKeyPair (com.cloud.user.SSHKeyPair)5 ListResponse (com.cloud.api.response.ListResponse)2 ArrayList (java.util.ArrayList)2 CreateSSHKeyPairResponse (com.cloud.api.response.CreateSSHKeyPairResponse)1 Domain (com.cloud.domain.Domain)1 Account (com.cloud.user.Account)1 UserAccount (com.cloud.user.UserAccount)1 List (java.util.List)1