Package com.cloud.stack.models

Examples of com.cloud.stack.models.CloudStackAccount


     */
    public EC2Address allocateAddress() {
        EC2Address ec2Address = new EC2Address();
        try {
            // this gets our networkId
            CloudStackAccount caller = getCurrentAccount();

            CloudStackZone zone = findZone();
            //CloudStackNetwork net = findNetwork(zone);
//      CloudStackIpAddress resp = getApi().associateIpAddress(null, null, null, "0036952d-48df-4422-9fd0-94b0885e18cb");
            CloudStackIpAddress resp = getApi().associateIpAddress(zone.getId(), caller.getName(), caller.getDomainId(), null);
            ec2Address.setAssociatedInstanceId(resp.getId());

            if (resp.getIpAddress() == null) {
                List<CloudStackIpAddress> addrList = getApi().listPublicIpAddresses(null, null, null, null, null, null, null, null, null);
                if (addrList != null && addrList.size() > 0) {
View Full Code Here


     *         the user can create.
     */
    private int calculateAllowedInstances() throws Exception {
        int maxAllowed = -1;

        CloudStackAccount ourAccount = getCurrentAccount();

        if (ourAccount == null) {
            // This should never happen, but
            // we will return -99999 if this happens...
            return -99999;
        }

        // if accountType is Admin == 1, then let's return -1
        if (ourAccount.getAccountType() == 1) return -1;

        // -> get the user limits on instances
        // "0" represents instances:
        // http://download.cloud.com/releases/2.2.0/api_2.2.8/user/listResourceLimits.html
        List<CloudStackResourceLimit> limits = getApi().listResourceLimits(null, null, null, null, "0");
View Full Code Here

     * @return
     * @throws Exception
     */
    private CloudStackNetwork getNetworksWithoutSecurityGroupEnabled(String zoneId) throws Exception {
        // grab current account
        CloudStackAccount caller = getCurrentAccount();

        //check if account has any networks in the system
        List<CloudStackNetwork> networks = getApi().listNetworks(caller.getName(), caller.getDomainId(), null, true, null, null, null, null, null, zoneId);

        //listRequired offerings in the system - the network created from this offering has to be specified in deployVm command
        List<CloudStackNetworkOffering> reuquiredOfferings = getApi().listNetworkOfferings("Required", null, null, null, true,  null, null, null, null, null, zoneId);
        if (reuquiredOfferings != null && !reuquiredOfferings.isEmpty()) {
            if (networks != null && !networks.isEmpty()) {
View Full Code Here

            return getNetworksWithoutSecurityGroupEnabled(zone.getId());
        }
    }

    private CloudStackZone findZone() throws Exception {
        CloudStackAccount caller = getCurrentAccount();
        List<CloudStackZone> cloudZones;

        String defaultZoneId = getDefaultZoneId(caller.getId());
        if (defaultZoneId != null) {
            cloudZones = getApi().listZones(true, null, defaultZoneId, null);
        } else {
            // caller.getDomainId doesn't work in user mode
            // List<CloudStackZone> cloudZones = getApi().listZones(true, caller.getDomainId(), null, null);
View Full Code Here

            return;
        }

        // validate account is admin level
        try {
            CloudStackAccount currentAccount = ServiceProvider.getInstance().getEC2Engine().getCurrentAccount();

            if (currentAccount.getAccountType() != 1) {
                logger.debug("SetOfferMapping called by non-admin user!");
                response.setStatus(500);
                endResponse(response, "Permission denied for non-admin user to setOfferMapping!");
                return;
            }
View Full Code Here

            return;
        }

        // validate account is admin level
        try {
            CloudStackAccount currentAccount = ServiceProvider.getInstance().getEC2Engine().getCurrentAccount();

            if (currentAccount.getAccountType() != 1) {
                logger.debug("deleteOfferMapping called by non-admin user!");
                response.setStatus(500);
                endResponse(response, "Permission denied for non-admin user to deleteOfferMapping!");
                return;
            }
View Full Code Here

     */
    public EC2Address allocateAddress() {
        EC2Address ec2Address = new EC2Address();
        try {
            // this gets our networkId
            CloudStackAccount caller = getCurrentAccount();

            CloudStackZone zone = findZone();
            //CloudStackNetwork net = findNetwork(zone);
            //CloudStackIpAddress resp = getApi().associateIpAddress(null, null, null, "0036952d-48df-4422-9fd0-94b0885e18cb");
            CloudStackIpAddress resp = getApi().associateIpAddress(zone.getId(), caller.getName(), caller.getDomainId(), null);
            ec2Address.setAssociatedInstanceId(resp.getId());

            if (resp.getIpAddress() == null) {
                List<CloudStackIpAddress> addrList = getApi().listPublicIpAddresses(null, null, null, null, null, null, null, null, null);
                if (addrList != null && addrList.size() > 0) {
View Full Code Here

     *         the user can create.
     */
    private int calculateAllowedInstances() throws Exception {
        int maxAllowed = -1;

        CloudStackAccount ourAccount = getCurrentAccount();

        if (ourAccount == null) {
            // This should never happen, but
            // we will return -99999 if this happens...
            return -99999;
        }

        // if accountType is Admin == 1, then let's return -1
        if (ourAccount.getAccountType() == 1)
            return -1;

        // -> get the user limits on instances
        // "0" represents instances:
        // http://download.cloud.com/releases/2.2.0/api_2.2.8/user/listResourceLimits.html
View Full Code Here

     * @return
     * @throws Exception
     */
    private CloudStackNetwork getNetworksWithoutSecurityGroupEnabled(String zoneId) throws Exception {
        // grab current account
        CloudStackAccount caller = getCurrentAccount();

        //check if account has any networks in the system
        List<CloudStackNetwork> networks = getApi().listNetworks(caller.getName(), caller.getDomainId(), null, true, null, null, null, null, null, zoneId);

        //listRequired offerings in the system - the network created from this offering has to be specified in deployVm command
        List<CloudStackNetworkOffering> reuquiredOfferings = getApi().listNetworkOfferings("Required", null, null, null, true, null, null, null, null, null, zoneId);
        if (reuquiredOfferings != null && !reuquiredOfferings.isEmpty()) {
            if (networks != null && !networks.isEmpty()) {
View Full Code Here

            return getNetworksWithoutSecurityGroupEnabled(zone.getId());
        }
    }

    private CloudStackZone findZone() throws Exception {
        CloudStackAccount caller = getCurrentAccount();
        List<CloudStackZone> cloudZones;

        String defaultZoneId = getDefaultZoneId(caller.getId());
        if (defaultZoneId != null) {
            cloudZones = getApi().listZones(true, null, defaultZoneId, null);
        } else {
            // caller.getDomainId doesn't work in user mode
            // List<CloudStackZone> cloudZones = getApi().listZones(true, caller.getDomainId(), null, null);
View Full Code Here

TOP

Related Classes of com.cloud.stack.models.CloudStackAccount

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.