Package org.apache.cloudstack.api

Examples of org.apache.cloudstack.api.BaseCmd


                    paramMap.put(key, value[0]);
                }

                Class<?> cmdClass = getCmdClass(command[0]);
                if (cmdClass != null) {
                    BaseCmd cmdObj = (BaseCmd) cmdClass.newInstance();
                    cmdObj = ComponentContext.inject(cmdObj);
                    cmdObj.configure();
                    cmdObj.setFullUrlParams(paramMap);
                    cmdObj.setResponseType(responseType);
                    cmdObj.setHttpMethod(paramMap.get("httpmethod").toString());

                    // This is where the command is either serialized, or directly dispatched
                    response = queueCommand(cmdObj, paramMap);
                    buildAuditTrail(auditTrailSb, command[0], response);
                } else {
View Full Code Here


        _hostId = host.getId();
    }

    private void createPublicVlanIpRange() {
        CreateVlanIpRangeCmd cmd = new CreateVlanIpRangeCmd();
        BaseCmd proxy = ComponentContext.inject(cmd);
        Long public_net_id = null;

        List<NetworkVO> nets = _networksDao.listByZoneAndTrafficType(_zone.getId(), TrafficType.Public);
        if (nets != null && !nets.isEmpty()) {
            NetworkVO public_net = nets.get(0);
View Full Code Here

    }

    @Test
    public void testHandle() throws ResourceAllocationException {
        // Prepare
        final BaseCmd cmd = new FakeCmd();
        final Map<String, String> params = new HashMap<String, String>();
        params.put(ApiConstants.COMMAND, "");
        params.put(ApiConstants.ACCOUNT_ID, "");
        params.put(ApiConstants.CTX_START_EVENT_ID, "");
        params.put(ApiConstants.COMMAND, "");
View Full Code Here

    @Test
    public void testHandleWithUnknownParams() throws ResourceAllocationException {
        // Prepare
        final String unknownParamKey = "unknownParam";
        final BaseCmd cmd = new FakeCmd();
        final Map<String, String> params = new HashMap<String, String>();
        params.put(ApiConstants.COMMAND, "");
        params.put("addedParam", "");
        params.put(unknownParamKey, "");
View Full Code Here

    }

    protected void driveAuthTest(final short type) {

        // Prepare
        final BaseCmd cmd = new FakeCmdWithRoleAdmin();
        final Account account = mock(Account.class);
        ((FakeCmdWithRoleAdmin)cmd).account = account;
        when(account.getType()).thenReturn(type);
        User user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString());
        CallContext.register(user, account);
View Full Code Here

public class SpecificCmdValidationWorkerTest {

    @Test
    public void testHandle() throws ResourceAllocationException {
        // Prepare
        final BaseCmd cmd = mock(BaseCmd.class);
        final Map<String, String> params = new HashMap<String, String>();

        // Execute
        final SpecificCmdValidationWorker worker = new SpecificCmdValidationWorker();
View Full Code Here

        }
        _server.deleteVM(vm, network);
    }

    public void deleteFloatingIp(IPAddressVO ip) throws Exception {
        BaseCmd cmd = new DisableStaticNatCmd();
        BaseCmd proxy = ComponentContext.inject(cmd);
        ManagementServerMock.setParameter(proxy, "ipAddressId", BaseCmd.CommandType.LONG, ip.getId());
        try {
            proxy.execute();
        } catch (Exception e) {
            s_logger.debug("DisableStaticNatCmd exception: " + e);
            e.printStackTrace();
            throw e;
        }
View Full Code Here

            throw e;
        }
    }

    public IPAddressVO createFloatingIp(Network network, UserVm vm) throws Exception {
        BaseCmd cmd = new AssociateIPAddrCmd();
        BaseCmd proxy = ComponentContext.inject(cmd);
        Account system = _accountMgr.getSystemAccount();
        DataCenter zone = _server.getZone();

        ManagementServerMock.setParameter(proxy, "accountName", BaseCmd.CommandType.STRING, system.getAccountName());
        ManagementServerMock.setParameter(proxy, "domainId", BaseCmd.CommandType.LONG, Domain.ROOT_DOMAIN);
        ManagementServerMock.setParameter(proxy, "zoneId", BaseCmd.CommandType.LONG, zone.getId());
        ManagementServerMock.setParameter(proxy, "networkId", BaseCmd.CommandType.LONG, network.getId());
        try {
            ((AssociateIPAddrCmd)cmd).create();
            ((AssociateIPAddrCmd)cmd).execute();
        } catch (Exception e) {
            s_logger.debug("AssociateIPAddrCmd exception: " + e);
            e.printStackTrace();
            throw e;
        }

        SearchBuilder<IPAddressVO> searchBuilder = _ipAddressDao.createSearchBuilder();
        searchBuilder.and("sourceNat", searchBuilder.entity().isSourceNat(), Op.EQ);
        searchBuilder.and("network", searchBuilder.entity().getAssociatedWithNetworkId(), Op.EQ);
        searchBuilder.and("dataCenterId", searchBuilder.entity().getDataCenterId(), Op.EQ);
        searchBuilder.and("associatedWithVmId", searchBuilder.entity().getAssociatedWithVmId(), Op.NULL);
        SearchCriteria<IPAddressVO> sc = searchBuilder.create();
        sc.setParameters("sourceNat", false);
        sc.setParameters("network", network.getId());

        List<IPAddressVO> publicIps = _ipAddressDao.search(sc, null);
        assertNotNull(publicIps);

        cmd = new EnableStaticNatCmd();
        proxy = ComponentContext.inject(cmd);
        ManagementServerMock.setParameter(proxy, "ipAddressId", BaseCmd.CommandType.LONG, publicIps.get(0).getId());
        ManagementServerMock.setParameter(proxy, "networkId", BaseCmd.CommandType.LONG, network.getId());
        ManagementServerMock.setParameter(proxy, "virtualMachineId", BaseCmd.CommandType.LONG, vm.getId());

        try {
            proxy.execute();
        } catch (Exception e) {
            s_logger.debug("EnableStaticNatCmd exception: " + e);
            e.printStackTrace();
            throw e;
        }
View Full Code Here

        }
        return publicIps.get(0);
    }

    public void createProject(String name) {
        BaseCmd cmd = new CreateProjectCmd();
        BaseCmd proxy = ComponentContext.inject(cmd);
        Account system = _accountMgr.getSystemAccount();

        ManagementServerMock.setParameter(proxy, "accountName", BaseCmd.CommandType.STRING, system.getAccountName());
        ManagementServerMock.setParameter(proxy, "domainId", BaseCmd.CommandType.LONG, Domain.ROOT_DOMAIN);
        ManagementServerMock.setParameter(proxy, "name", BaseCmd.CommandType.STRING, name);
View Full Code Here

            fail("Exception while creating a project in vnc");
        }
    }

    public void deleteProject(String name) {
        BaseCmd cmd = new DeleteProjectCmd();
        BaseCmd proxy = ComponentContext.inject(cmd);

        ProjectVO project = _projectDao.findByNameAndDomain(name, Domain.ROOT_DOMAIN);
        try {
            ManagementServerMock.setParameter(proxy, "id", BaseCmd.CommandType.LONG, project.getId());
            ((DeleteProjectCmd)proxy).execute();
View Full Code Here

TOP

Related Classes of org.apache.cloudstack.api.BaseCmd

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.