Search in sources :

Example 6 with SSHKeyPair

use of com.cloud.user.SSHKeyPair in project cloudstack by apache.

the class CreateSSHKeyPairCmd method execute.

@Override
public void execute() {
    SSHKeyPair r = _mgr.createSSHKeyPair(this);
    CreateSSHKeyPairResponse response = (CreateSSHKeyPairResponse) _responseGenerator.createSSHKeyPairResponse(r, true);
    response.setResponseName(getCommandName());
    response.setObjectName("keypair");
    setResponseObject(response);
}
Also used : SSHKeyPair(com.cloud.user.SSHKeyPair) CreateSSHKeyPairResponse(org.apache.cloudstack.api.response.CreateSSHKeyPairResponse)

Example 7 with SSHKeyPair

use of com.cloud.user.SSHKeyPair in project cosmic by MissionCriticalCloud.

the class CreateSSHKeyPairCmd method execute.

@Override
public void execute() {
    final SSHKeyPair r = _mgr.createSSHKeyPair(this);
    final CreateSSHKeyPairResponse response = (CreateSSHKeyPairResponse) _responseGenerator.createSSHKeyPairResponse(r, true);
    response.setResponseName(getCommandName());
    response.setObjectName("keypair");
    setResponseObject(response);
}
Also used : SSHKeyPair(com.cloud.user.SSHKeyPair) CreateSSHKeyPairResponse(com.cloud.api.response.CreateSSHKeyPairResponse)

Example 8 with SSHKeyPair

use of com.cloud.user.SSHKeyPair 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 9 with SSHKeyPair

use of com.cloud.user.SSHKeyPair 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)

Example 10 with SSHKeyPair

use of com.cloud.user.SSHKeyPair in project cosmic by MissionCriticalCloud.

the class ManagementServerImpl method listSSHKeyPairs.

@Override
public Pair<List<? extends SSHKeyPair>, Integer> listSSHKeyPairs(final ListSSHKeyPairsCmd cmd) {
    final String name = cmd.getName();
    final String fingerPrint = cmd.getFingerprint();
    final Account caller = getCaller();
    final List<Long> permittedAccounts = new ArrayList<>();
    final Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject = new Ternary<>(cmd.getDomainId(), cmd.isRecursive(), null);
    _accountMgr.buildACLSearchParameters(caller, null, cmd.getAccountName(), cmd.getProjectId(), permittedAccounts, domainIdRecursiveListProject, cmd.listAll(), false);
    final Long domainId = domainIdRecursiveListProject.first();
    final Boolean isRecursive = domainIdRecursiveListProject.second();
    final ListProjectResourcesCriteria listProjectResourcesCriteria = domainIdRecursiveListProject.third();
    final SearchBuilder<SSHKeyPairVO> sb = _sshKeyPairDao.createSearchBuilder();
    _accountMgr.buildACLSearchBuilder(sb, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria);
    final Filter searchFilter = new Filter(SSHKeyPairVO.class, "id", false, cmd.getStartIndex(), cmd.getPageSizeVal());
    final SearchCriteria<SSHKeyPairVO> sc = sb.create();
    _accountMgr.buildACLSearchCriteria(sc, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria);
    if (name != null) {
        sc.addAnd("name", SearchCriteria.Op.EQ, name);
    }
    if (fingerPrint != null) {
        sc.addAnd("fingerprint", SearchCriteria.Op.EQ, fingerPrint);
    }
    final Pair<List<SSHKeyPairVO>, Integer> result = _sshKeyPairDao.searchAndCount(sc, searchFilter);
    return new Pair<>(result.first(), result.second());
}
Also used : Account(com.cloud.user.Account) Ternary(com.cloud.utils.Ternary) ArrayList(java.util.ArrayList) SSHKeyPairVO(com.cloud.user.SSHKeyPairVO) ListProjectResourcesCriteria(com.cloud.projects.Project.ListProjectResourcesCriteria) Filter(com.cloud.utils.db.Filter) ArrayList(java.util.ArrayList) ExcludeList(com.cloud.deploy.DeploymentPlanner.ExcludeList) List(java.util.List) Pair(com.cloud.utils.Pair) SSHKeyPair(com.cloud.user.SSHKeyPair)

Aggregations

SSHKeyPair (com.cloud.user.SSHKeyPair)14 ArrayList (java.util.ArrayList)8 SSHKeyPairResponse (com.cloud.api.response.SSHKeyPairResponse)5 Pair (com.cloud.utils.Pair)4 List (java.util.List)4 DedicatedResourceVO (com.cloud.dc.DedicatedResourceVO)3 ExcludeList (com.cloud.deploy.DeploymentPlanner.ExcludeList)3 DomainVO (com.cloud.domain.DomainVO)3 AgentUnavailableException (com.cloud.exception.AgentUnavailableException)3 CloudException (com.cloud.exception.CloudException)3 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)3 InsufficientAddressCapacityException (com.cloud.exception.InsufficientAddressCapacityException)3 InsufficientCapacityException (com.cloud.exception.InsufficientCapacityException)3 ManagementServerException (com.cloud.exception.ManagementServerException)3 OperationTimedoutException (com.cloud.exception.OperationTimedoutException)3 PermissionDeniedException (com.cloud.exception.PermissionDeniedException)3 ResourceAllocationException (com.cloud.exception.ResourceAllocationException)3 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)3 StorageUnavailableException (com.cloud.exception.StorageUnavailableException)3 VirtualMachineMigrationException (com.cloud.exception.VirtualMachineMigrationException)3