mirror of
				https://github.com/apache/cloudstack.git
				synced 2025-11-04 00:02:37 +01:00 
			
		
		
		
	UserContext switched to CallContext. Added generic storage mechanism for other code to carry information throughout a call. Made the calling User and Account a must have. Added an interface to carry entities in error. Fixed up the code. Part of the vmsync branch
This commit is contained in:
		
							parent
							
								
									fa9ca72f36
								
							
						
					
					
						commit
						11e1e585b1
					
				@ -1,163 +0,0 @@
 | 
			
		||||
// Licensed to the Apache Software Foundation (ASF) under one
 | 
			
		||||
// or more contributor license agreements.  See the NOTICE file
 | 
			
		||||
// distributed with this work for additional information
 | 
			
		||||
// regarding copyright ownership.  The ASF licenses this file
 | 
			
		||||
// to you under the Apache License, Version 2.0 (the
 | 
			
		||||
// "License"); you may not use this file except in compliance
 | 
			
		||||
// with the License.  You may obtain a copy of the License at
 | 
			
		||||
//
 | 
			
		||||
//   http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
//
 | 
			
		||||
// Unless required by applicable law or agreed to in writing,
 | 
			
		||||
// software distributed under the License is distributed on an
 | 
			
		||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 | 
			
		||||
// KIND, either express or implied.  See the License for the
 | 
			
		||||
// specific language governing permissions and limitations
 | 
			
		||||
// under the License.
 | 
			
		||||
package com.cloud.user;
 | 
			
		||||
 | 
			
		||||
import com.cloud.utils.component.ComponentContext;
 | 
			
		||||
import javax.inject.Inject;
 | 
			
		||||
 | 
			
		||||
public class UserContext {
 | 
			
		||||
    private static ThreadLocal<UserContext> s_currentContext = new ThreadLocal<UserContext>();
 | 
			
		||||
 | 
			
		||||
    private long userId;
 | 
			
		||||
    private String sessionId;
 | 
			
		||||
    private Account account;
 | 
			
		||||
    private long startEventId = 0;
 | 
			
		||||
    private long accountId;
 | 
			
		||||
    private String eventDetails;
 | 
			
		||||
    private boolean apiServer;
 | 
			
		||||
    private Class entityType;
 | 
			
		||||
    private String entityUUID;
 | 
			
		||||
 | 
			
		||||
    @Inject private AccountService _accountMgr = null;
 | 
			
		||||
 | 
			
		||||
    public UserContext() {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public UserContext(long userId, Account accountObject, String sessionId, boolean apiServer) {
 | 
			
		||||
        this.userId = userId;
 | 
			
		||||
        this.account = accountObject;
 | 
			
		||||
        this.sessionId = sessionId;
 | 
			
		||||
        this.apiServer = apiServer;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public long getCallerUserId() {
 | 
			
		||||
        return userId;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public User getCallerUser() {
 | 
			
		||||
        if (_accountMgr == null) {
 | 
			
		||||
            _accountMgr = ComponentContext.getComponent(AccountService.class);
 | 
			
		||||
        }
 | 
			
		||||
        return _accountMgr.getActiveUser(userId);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setCallerUserId(long userId) {
 | 
			
		||||
        this.userId = userId;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getSessionId() {
 | 
			
		||||
        return sessionId;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Account getCaller() {
 | 
			
		||||
        return account;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setCaller(Account accountObject) {
 | 
			
		||||
        this.account = accountObject;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setSessionKey(String sessionId) {
 | 
			
		||||
        this.sessionId = sessionId;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public boolean isApiServer() {
 | 
			
		||||
        return apiServer;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setApiServer(boolean apiServer) {
 | 
			
		||||
        this.apiServer = apiServer;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static UserContext current() {
 | 
			
		||||
        UserContext context = s_currentContext.get();
 | 
			
		||||
        if (context == null) {
 | 
			
		||||
            //
 | 
			
		||||
            // TODO: we should enforce explicit UserContext setup at major entry-points for security concerns,
 | 
			
		||||
            // however, there are many places that run background jobs assume the system context.
 | 
			
		||||
            //
 | 
			
		||||
            // If there is a security concern, all entry points from user (including the front end that takes HTTP
 | 
			
		||||
            // request in and
 | 
			
		||||
            // the core async-job manager that runs commands from user) have explicitly setup the UserContext.
 | 
			
		||||
            //
 | 
			
		||||
            return UserContextInitializer.getInstance().getAdminContext();
 | 
			
		||||
        }
 | 
			
		||||
        return context;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static void updateContext(long userId, Account accountObject, String sessionId) {
 | 
			
		||||
        UserContext context = current();
 | 
			
		||||
        assert (context != null) : "Context should be already setup before you can call this one";
 | 
			
		||||
 | 
			
		||||
        context.setCallerUserId(userId);
 | 
			
		||||
        context.setCaller(accountObject);
 | 
			
		||||
        context.setSessionKey(sessionId);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static void registerContext(long userId, Account accountObject, String sessionId, boolean apiServer) {
 | 
			
		||||
        s_currentContext.set(new UserContext(userId, accountObject, sessionId, apiServer));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static void unregisterContext() {
 | 
			
		||||
        s_currentContext.set(null);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setStartEventId(long startEventId) {
 | 
			
		||||
        this.startEventId = startEventId;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public long getStartEventId() {
 | 
			
		||||
        return startEventId;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public long getAccountId() {
 | 
			
		||||
        return accountId;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setAccountId(long accountId) {
 | 
			
		||||
        this.accountId = accountId;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setEventDetails(String eventDetails) {
 | 
			
		||||
        this.eventDetails = eventDetails;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getEventDetails() {
 | 
			
		||||
        return eventDetails;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setEntityDetails(Class entityType, String uuid) {
 | 
			
		||||
        this.entityType = entityType;
 | 
			
		||||
        this.entityUUID = uuid;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getEntityType() {
 | 
			
		||||
        return (entityType != null) ? entityType.getName() : null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setEntityType(Class entityType) {
 | 
			
		||||
        this.entityType = entityType;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getEntityUUID() {
 | 
			
		||||
        return entityUUID;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setEntityUUID(String entityUUID) {
 | 
			
		||||
        this.entityUUID = entityUUID;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@ -1,40 +0,0 @@
 | 
			
		||||
// Licensed to the Apache Software Foundation (ASF) under one
 | 
			
		||||
// or more contributor license agreements.  See the NOTICE file
 | 
			
		||||
// distributed with this work for additional information
 | 
			
		||||
// regarding copyright ownership.  The ASF licenses this file
 | 
			
		||||
// to you under the Apache License, Version 2.0 (the
 | 
			
		||||
// "License"); you may not use this file except in compliance
 | 
			
		||||
// with the License.  You may obtain a copy of the License at
 | 
			
		||||
//
 | 
			
		||||
//   http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
//
 | 
			
		||||
// Unless required by applicable law or agreed to in writing,
 | 
			
		||||
// software distributed under the License is distributed on an
 | 
			
		||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 | 
			
		||||
// KIND, either express or implied.  See the License for the
 | 
			
		||||
// specific language governing permissions and limitations
 | 
			
		||||
// under the License.
 | 
			
		||||
package com.cloud.user;
 | 
			
		||||
 | 
			
		||||
import javax.inject.Inject;
 | 
			
		||||
 | 
			
		||||
import org.springframework.stereotype.Component;
 | 
			
		||||
 | 
			
		||||
@Component
 | 
			
		||||
public class UserContextInitializer {
 | 
			
		||||
	@Inject private AccountService _accountMgr;
 | 
			
		||||
 | 
			
		||||
    private static UserContextInitializer s_instance;
 | 
			
		||||
    
 | 
			
		||||
    public UserContextInitializer() {
 | 
			
		||||
    	s_instance = this;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public static UserContextInitializer getInstance() {
 | 
			
		||||
    	return s_instance;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public UserContext getAdminContext() {
 | 
			
		||||
    	return new UserContext(_accountMgr.getSystemUser().getId(), _accountMgr.getSystemAccount(), null, false);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@ -17,10 +17,10 @@
 | 
			
		||||
package org.apache.cloudstack.api;
 | 
			
		||||
 | 
			
		||||
import org.apache.cloudstack.api.response.AsyncJobResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import com.cloud.async.AsyncJob;
 | 
			
		||||
import com.cloud.user.User;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * queryAsyncJobResult API command.
 | 
			
		||||
@ -109,8 +109,8 @@ public abstract class BaseAsyncCmd extends BaseCmd {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected long saveStartedEvent(String eventType, String description, Long startEventId) {
 | 
			
		||||
        UserContext ctx = UserContext.current();
 | 
			
		||||
        Long userId = ctx.getCallerUserId();
 | 
			
		||||
        CallContext ctx = CallContext.current();
 | 
			
		||||
        Long userId = ctx.getCallingUserId();
 | 
			
		||||
        userId = (userId == null) ? User.UID_SYSTEM : userId;
 | 
			
		||||
        Long startEvent = startEventId;
 | 
			
		||||
        if (startEvent == null) {
 | 
			
		||||
@ -124,8 +124,8 @@ public abstract class BaseAsyncCmd extends BaseCmd {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected long saveCompletedEvent(String level, String eventType, String description, Long startEventId) {
 | 
			
		||||
        UserContext ctx = UserContext.current();
 | 
			
		||||
        Long userId = ctx.getCallerUserId();
 | 
			
		||||
        CallContext ctx = CallContext.current();
 | 
			
		||||
        Long userId = ctx.getCallingUserId();
 | 
			
		||||
        userId = (userId == null) ? User.UID_SYSTEM : userId;
 | 
			
		||||
        Long startEvent = startEventId;
 | 
			
		||||
        if (startEvent == null) {
 | 
			
		||||
 | 
			
		||||
@ -19,11 +19,12 @@ package org.apache.cloudstack.api;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
import org.apache.cloudstack.api.response.TemplatePermissionsResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.template.VirtualMachineTemplate;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
public class BaseListTemplateOrIsoPermissionsCmd extends BaseCmd {
 | 
			
		||||
    public Logger s_logger = getLogger();
 | 
			
		||||
@ -79,7 +80,7 @@ public class BaseListTemplateOrIsoPermissionsCmd extends BaseCmd {
 | 
			
		||||
    public void execute(){
 | 
			
		||||
        List<String> accountNames = _templateService.listTemplatePermissions(this);
 | 
			
		||||
 | 
			
		||||
        Account account = UserContext.current().getCaller();
 | 
			
		||||
        Account account = CallContext.current().getCallingAccount();
 | 
			
		||||
        boolean isAdmin = (isAdmin(account.getType()));
 | 
			
		||||
 | 
			
		||||
        TemplatePermissionsResponse response = _responseGenerator.createTemplatePermissionsResponse(accountNames, id, isAdmin);
 | 
			
		||||
 | 
			
		||||
@ -18,7 +18,7 @@ package org.apache.cloudstack.api.command.admin.account;
 | 
			
		||||
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserAccount;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.cloudstack.api.APICommand;
 | 
			
		||||
import org.apache.cloudstack.api.ApiConstants;
 | 
			
		||||
import org.apache.cloudstack.api.ApiErrorCode;
 | 
			
		||||
@ -27,6 +27,8 @@ import org.apache.cloudstack.api.Parameter;
 | 
			
		||||
import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.AccountResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.DomainResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import java.util.Collection;
 | 
			
		||||
@ -160,7 +162,7 @@ public class CreateAccountCmd extends BaseCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void execute(){
 | 
			
		||||
        UserContext.current().setEventDetails("Account Name: "+getAccountName()+", Domain Id:"+getDomainId());
 | 
			
		||||
        CallContext.current().setEventDetails("Account Name: "+getAccountName()+", Domain Id:"+getDomainId());
 | 
			
		||||
        UserAccount userAccount = _accountService.createUserAccount(getUsername(), getPassword(), getFirstName(), getLastName(), getEmail(), getTimeZone(), getAccountName(), getAccountType(),
 | 
			
		||||
                getDomainId(), getNetworkDomain(), getDetails(), getAccountUUID(), getUserUUID());
 | 
			
		||||
        if (userAccount != null) {
 | 
			
		||||
 | 
			
		||||
@ -27,13 +27,14 @@ import org.apache.cloudstack.api.Parameter;
 | 
			
		||||
import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.AccountResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.SuccessResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
import org.apache.cloudstack.region.RegionService;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.event.EventTypes;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.User;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "deleteAccount", description="Deletes a account, and all users associated with this account", responseObject=SuccessResponse.class)
 | 
			
		||||
public class DeleteAccountCmd extends BaseAsyncCmd {
 | 
			
		||||
@ -74,7 +75,7 @@ public class DeleteAccountCmd extends BaseAsyncCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public long getEntityOwnerId() {
 | 
			
		||||
        Account account = UserContext.current().getCaller();// Let's give the caller here for event logging.
 | 
			
		||||
        Account account = CallContext.current().getCallingAccount();// Let's give the caller here for event logging.
 | 
			
		||||
        if (account != null) {
 | 
			
		||||
            return account.getAccountId();
 | 
			
		||||
        }
 | 
			
		||||
@ -95,7 +96,7 @@ public class DeleteAccountCmd extends BaseAsyncCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void execute(){
 | 
			
		||||
        UserContext.current().setEventDetails("Account Id: "+getId());
 | 
			
		||||
        CallContext.current().setEventDetails("Account Id: "+getId());
 | 
			
		||||
 | 
			
		||||
        boolean	result = _regionService.deleteUserAccount(this);
 | 
			
		||||
        if (result) {
 | 
			
		||||
 | 
			
		||||
@ -27,14 +27,15 @@ import org.apache.cloudstack.api.Parameter;
 | 
			
		||||
import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.AccountResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.DomainResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
import org.apache.cloudstack.region.RegionService;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.event.EventTypes;
 | 
			
		||||
import com.cloud.exception.ConcurrentOperationException;
 | 
			
		||||
import com.cloud.exception.ResourceUnavailableException;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "disableAccount", description="Disables an account", responseObject=AccountResponse.class)
 | 
			
		||||
public class DisableAccountCmd extends BaseAsyncCmd {
 | 
			
		||||
@ -116,7 +117,7 @@ public class DisableAccountCmd extends BaseAsyncCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void execute() throws ConcurrentOperationException, ResourceUnavailableException{
 | 
			
		||||
        UserContext.current().setEventDetails("Account Name: "+getAccountName()+", Domain Id:"+getDomainId());
 | 
			
		||||
        CallContext.current().setEventDetails("Account Name: "+getAccountName()+", Domain Id:"+getDomainId());
 | 
			
		||||
        Account result = _regionService.disableAccount(this);
 | 
			
		||||
        if (result != null){
 | 
			
		||||
            AccountResponse response = _responseGenerator.createAccountResponse(result);
 | 
			
		||||
 | 
			
		||||
@ -23,11 +23,12 @@ import org.apache.cloudstack.api.BaseCmd;
 | 
			
		||||
import org.apache.cloudstack.api.Parameter;
 | 
			
		||||
import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.DomainResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.domain.Domain;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "createDomain", description="Creates a domain", responseObject=DomainResponse.class)
 | 
			
		||||
public class CreateDomainCmd extends BaseCmd {
 | 
			
		||||
@ -88,7 +89,7 @@ public class CreateDomainCmd extends BaseCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void execute(){
 | 
			
		||||
        UserContext.current().setEventDetails("Domain Name: "+getDomainName()+((getParentDomainId()!=null)?", Parent DomainId :"+getParentDomainId():""));
 | 
			
		||||
        CallContext.current().setEventDetails("Domain Name: "+getDomainName()+((getParentDomainId()!=null)?", Parent DomainId :"+getParentDomainId():""));
 | 
			
		||||
        Domain domain = _domainService.createDomain(getDomainName(), getParentDomainId(), getNetworkDomain(), getDomainUUID());
 | 
			
		||||
        if (domain != null) {
 | 
			
		||||
            DomainResponse response = _responseGenerator.createDomainResponse(domain);
 | 
			
		||||
 | 
			
		||||
@ -26,13 +26,14 @@ import org.apache.cloudstack.api.Parameter;
 | 
			
		||||
import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.DomainResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.SuccessResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
import org.apache.cloudstack.region.RegionService;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.domain.Domain;
 | 
			
		||||
import com.cloud.event.EventTypes;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "deleteDomain", description="Deletes a specified domain", responseObject=SuccessResponse.class)
 | 
			
		||||
public class DeleteDomainCmd extends BaseAsyncCmd {
 | 
			
		||||
@ -95,7 +96,7 @@ public class DeleteDomainCmd extends BaseAsyncCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void execute(){
 | 
			
		||||
        UserContext.current().setEventDetails("Domain Id: "+getId());
 | 
			
		||||
        CallContext.current().setEventDetails("Domain Id: "+getId());
 | 
			
		||||
        boolean result = _regionService.deleteDomain(this);
 | 
			
		||||
        if (result) {
 | 
			
		||||
            SuccessResponse response = new SuccessResponse(getCommandName());
 | 
			
		||||
 | 
			
		||||
@ -25,13 +25,14 @@ import org.apache.cloudstack.api.BaseCmd;
 | 
			
		||||
import org.apache.cloudstack.api.Parameter;
 | 
			
		||||
import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.DomainResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
import org.apache.cloudstack.region.RegionService;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.domain.Domain;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserAccount;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "updateDomain", description="Updates a domain with a new name", responseObject=DomainResponse.class)
 | 
			
		||||
public class UpdateDomainCmd extends BaseCmd {
 | 
			
		||||
@ -86,7 +87,7 @@ public class UpdateDomainCmd extends BaseCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void execute(){
 | 
			
		||||
        UserContext.current().setEventDetails("Domain Id: "+getId());
 | 
			
		||||
        CallContext.current().setEventDetails("Domain Id: "+getId());
 | 
			
		||||
        Domain domain =  _regionService.updateDomain(this);
 | 
			
		||||
 | 
			
		||||
        if (domain != null) {
 | 
			
		||||
 | 
			
		||||
@ -24,12 +24,13 @@ import org.apache.cloudstack.api.BaseAsyncCmd;
 | 
			
		||||
import org.apache.cloudstack.api.Parameter;
 | 
			
		||||
import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.HostResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.event.EventTypes;
 | 
			
		||||
import com.cloud.host.Host;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "cancelHostMaintenance", description="Cancels host maintenance.", responseObject=HostResponse.class)
 | 
			
		||||
public class CancelMaintenanceCmd extends BaseAsyncCmd  {
 | 
			
		||||
@ -68,7 +69,7 @@ public class CancelMaintenanceCmd extends BaseAsyncCmd  {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public long getEntityOwnerId() {
 | 
			
		||||
        Account account = UserContext.current().getCaller();
 | 
			
		||||
        Account account = CallContext.current().getCallingAccount();
 | 
			
		||||
        if (account != null) {
 | 
			
		||||
            return account.getId();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@ -24,12 +24,13 @@ import org.apache.cloudstack.api.BaseAsyncCmd;
 | 
			
		||||
import org.apache.cloudstack.api.Parameter;
 | 
			
		||||
import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.HostResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.event.EventTypes;
 | 
			
		||||
import com.cloud.host.Host;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "prepareHostForMaintenance", description="Prepares a host for maintenance.", responseObject=HostResponse.class)
 | 
			
		||||
public class PrepareForMaintenanceCmd extends BaseAsyncCmd {
 | 
			
		||||
@ -68,7 +69,7 @@ public class PrepareForMaintenanceCmd extends BaseAsyncCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public long getEntityOwnerId() {
 | 
			
		||||
        Account account = UserContext.current().getCaller();
 | 
			
		||||
        Account account = CallContext.current().getCallingAccount();
 | 
			
		||||
        if (account != null) {
 | 
			
		||||
            return account.getId();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@ -24,12 +24,13 @@ import org.apache.cloudstack.api.BaseAsyncCmd;
 | 
			
		||||
import org.apache.cloudstack.api.Parameter;
 | 
			
		||||
import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.HostResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.event.EventTypes;
 | 
			
		||||
import com.cloud.host.Host;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "reconnectHost", description="Reconnects a host.", responseObject=HostResponse.class)
 | 
			
		||||
public class ReconnectHostCmd extends BaseAsyncCmd {
 | 
			
		||||
@ -68,7 +69,7 @@ public class ReconnectHostCmd extends BaseAsyncCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public long getEntityOwnerId() {
 | 
			
		||||
        Account account = UserContext.current().getCaller();
 | 
			
		||||
        Account account = CallContext.current().getCallingAccount();
 | 
			
		||||
        if (account != null) {
 | 
			
		||||
            return account.getId();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@ -25,11 +25,12 @@ import org.apache.cloudstack.api.Parameter;
 | 
			
		||||
import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.HostResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.SuccessResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.event.EventTypes;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "releaseHostReservation", description = "Releases host reservation.", responseObject = SuccessResponse.class)
 | 
			
		||||
public class ReleaseHostReservationCmd extends BaseAsyncCmd {
 | 
			
		||||
@ -64,7 +65,7 @@ public class ReleaseHostReservationCmd extends BaseAsyncCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public long getEntityOwnerId() {
 | 
			
		||||
        Account account = UserContext.current().getCaller();
 | 
			
		||||
        Account account = CallContext.current().getCallingAccount();
 | 
			
		||||
        if (account != null) {
 | 
			
		||||
            return account.getId();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@ -23,7 +23,7 @@ import com.cloud.exception.InsufficientCapacityException;
 | 
			
		||||
import com.cloud.exception.ResourceUnavailableException;
 | 
			
		||||
import com.cloud.network.VirtualRouterProvider;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.cloudstack.api.APICommand;
 | 
			
		||||
import org.apache.cloudstack.api.ApiConstants;
 | 
			
		||||
import org.apache.cloudstack.api.ApiErrorCode;
 | 
			
		||||
@ -31,10 +31,13 @@ import org.apache.cloudstack.api.BaseAsyncCmd;
 | 
			
		||||
import org.apache.cloudstack.api.Parameter;
 | 
			
		||||
import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.InternalLoadBalancerElementResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
import org.apache.cloudstack.network.element.InternalLoadBalancerElementService;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import javax.inject.Inject;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "configureInternalLoadBalancerElement", responseObject=InternalLoadBalancerElementResponse.class,
 | 
			
		||||
@ -96,7 +99,7 @@ public class ConfigureInternalLoadBalancerElementCmd extends BaseAsyncCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void execute() throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException{
 | 
			
		||||
        UserContext.current().setEventDetails("Internal load balancer element: " + id);
 | 
			
		||||
        CallContext.current().setEventDetails("Internal load balancer element: " + id);
 | 
			
		||||
        VirtualRouterProvider result = _service.get(0).configureInternalLoadBalancerElement(getId(), getEnabled());
 | 
			
		||||
        if (result != null){
 | 
			
		||||
            InternalLoadBalancerElementResponse routerResponse = _responseGenerator.createInternalLbElementResponse(result);
 | 
			
		||||
 | 
			
		||||
@ -28,14 +28,15 @@ import org.apache.cloudstack.api.Parameter;
 | 
			
		||||
import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.InternalLoadBalancerElementResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.ProviderResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
import org.apache.cloudstack.network.element.InternalLoadBalancerElementService;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.event.EventTypes;
 | 
			
		||||
import com.cloud.exception.ResourceAllocationException;
 | 
			
		||||
import com.cloud.network.VirtualRouterProvider;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "createInternalLoadBalancerElement", responseObject=InternalLoadBalancerElementResponse.class, description="Create an Internal Load Balancer element.",since="4.2.0")
 | 
			
		||||
public class CreateInternalLoadBalancerElementCmd extends BaseAsyncCreateCmd {
 | 
			
		||||
@ -82,7 +83,7 @@ public class CreateInternalLoadBalancerElementCmd extends BaseAsyncCreateCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void execute(){
 | 
			
		||||
        UserContext.current().setEventDetails("Virtual router element Id: "+getEntityId());
 | 
			
		||||
        CallContext.current().setEventDetails("Virtual router element Id: "+getEntityId());
 | 
			
		||||
        VirtualRouterProvider result = _service.get(0).getInternalLoadBalancerElement(getEntityId());
 | 
			
		||||
        if (result != null) {
 | 
			
		||||
            InternalLoadBalancerElementResponse response = _responseGenerator.createInternalLbElementResponse(result);
 | 
			
		||||
 | 
			
		||||
@ -24,6 +24,8 @@ import org.apache.cloudstack.api.BaseAsyncCmd;
 | 
			
		||||
import org.apache.cloudstack.api.Parameter;
 | 
			
		||||
import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.DomainRouterResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.event.EventTypes;
 | 
			
		||||
@ -33,7 +35,6 @@ import com.cloud.exception.InvalidParameterValueException;
 | 
			
		||||
import com.cloud.exception.ResourceUnavailableException;
 | 
			
		||||
import com.cloud.network.router.VirtualRouter;
 | 
			
		||||
import com.cloud.network.router.VirtualRouter.Role;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "startInternalLoadBalancerVM", responseObject=DomainRouterResponse.class, description="Starts an existing internal lb vm.")
 | 
			
		||||
public class StartInternalLBVMCmd extends BaseAsyncCmd {
 | 
			
		||||
@ -100,13 +101,13 @@ public class StartInternalLBVMCmd extends BaseAsyncCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void execute() throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException{
 | 
			
		||||
        UserContext.current().setEventDetails("Internal Lb Vm Id: "+getId());
 | 
			
		||||
        CallContext.current().setEventDetails("Internal Lb Vm Id: "+getId());
 | 
			
		||||
        VirtualRouter result = null;
 | 
			
		||||
        VirtualRouter router = _routerService.findRouter(getId());
 | 
			
		||||
        if (router == null || router.getRole() != Role.INTERNAL_LB_VM) {
 | 
			
		||||
            throw new InvalidParameterValueException("Can't find internal lb vm by id");
 | 
			
		||||
        } else {
 | 
			
		||||
            result = _internalLbSvc.startInternalLbVm(getId(), UserContext.current().getCaller(), UserContext.current().getCallerUserId());
 | 
			
		||||
            result = _internalLbSvc.startInternalLbVm(getId(), CallContext.current().getCallingAccount(), CallContext.current().getCallingUserId());
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (result != null){
 | 
			
		||||
 | 
			
		||||
@ -24,6 +24,8 @@ import org.apache.cloudstack.api.BaseAsyncCmd;
 | 
			
		||||
import org.apache.cloudstack.api.Parameter;
 | 
			
		||||
import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.DomainRouterResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.event.EventTypes;
 | 
			
		||||
@ -32,7 +34,6 @@ import com.cloud.exception.InvalidParameterValueException;
 | 
			
		||||
import com.cloud.exception.ResourceUnavailableException;
 | 
			
		||||
import com.cloud.network.router.VirtualRouter;
 | 
			
		||||
import com.cloud.network.router.VirtualRouter.Role;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "stopInternalLoadBalancerVM", description = "Stops an Internal LB vm.", responseObject = DomainRouterResponse.class)
 | 
			
		||||
public class StopInternalLBVMCmd extends BaseAsyncCmd {
 | 
			
		||||
@ -103,13 +104,13 @@ public class StopInternalLBVMCmd extends BaseAsyncCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void execute() throws ConcurrentOperationException, ResourceUnavailableException {
 | 
			
		||||
        UserContext.current().setEventDetails("Internal lb vm Id: "+getId());
 | 
			
		||||
        CallContext.current().setEventDetails("Internal lb vm Id: "+getId());
 | 
			
		||||
        VirtualRouter result = null;
 | 
			
		||||
        VirtualRouter vm = _routerService.findRouter(getId());
 | 
			
		||||
        if (vm == null || vm.getRole() != Role.INTERNAL_LB_VM) {
 | 
			
		||||
            throw new InvalidParameterValueException("Can't find internal lb vm by id");
 | 
			
		||||
        } else {
 | 
			
		||||
            result = _internalLbSvc.stopInternalLbVm(getId(), isForced(), UserContext.current().getCaller(), UserContext.current().getCallerUserId());
 | 
			
		||||
            result = _internalLbSvc.stopInternalLbVm(getId(), isForced(), CallContext.current().getCallingAccount(), CallContext.current().getCallingUserId());
 | 
			
		||||
        } 
 | 
			
		||||
        
 | 
			
		||||
        if (result != null) {
 | 
			
		||||
 | 
			
		||||
@ -27,13 +27,14 @@ import org.apache.cloudstack.api.Parameter;
 | 
			
		||||
import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.PhysicalNetworkResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.ProviderResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.event.EventTypes;
 | 
			
		||||
import com.cloud.exception.ResourceAllocationException;
 | 
			
		||||
import com.cloud.network.PhysicalNetworkServiceProvider;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "addNetworkServiceProvider", description="Adds a network serviceProvider to a physical network", responseObject=ProviderResponse.class, since="3.0.0")
 | 
			
		||||
public class AddNetworkServiceProviderCmd extends BaseAsyncCreateCmd {
 | 
			
		||||
@ -96,7 +97,7 @@ public class AddNetworkServiceProviderCmd extends BaseAsyncCreateCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void execute(){
 | 
			
		||||
        UserContext.current().setEventDetails("Network ServiceProvider Id: "+getEntityId());
 | 
			
		||||
        CallContext.current().setEventDetails("Network ServiceProvider Id: "+getEntityId());
 | 
			
		||||
        PhysicalNetworkServiceProvider result = _networkService.getCreatedPhysicalNetworkServiceProvider(getEntityId());
 | 
			
		||||
        if (result != null) {
 | 
			
		||||
            ProviderResponse response = _responseGenerator.createNetworkServiceProviderResponse(result);
 | 
			
		||||
 | 
			
		||||
@ -28,13 +28,14 @@ import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.DomainResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.PhysicalNetworkResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.ZoneResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.event.EventTypes;
 | 
			
		||||
import com.cloud.exception.ResourceAllocationException;
 | 
			
		||||
import com.cloud.network.PhysicalNetwork;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "createPhysicalNetwork", description="Creates a physical network", responseObject=PhysicalNetworkResponse.class, since="3.0.0")
 | 
			
		||||
public class CreatePhysicalNetworkCmd extends BaseAsyncCreateCmd {
 | 
			
		||||
@ -144,7 +145,7 @@ public class CreatePhysicalNetworkCmd extends BaseAsyncCreateCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void execute(){
 | 
			
		||||
        UserContext.current().setEventDetails("Physical Network Id: "+getEntityId());
 | 
			
		||||
        CallContext.current().setEventDetails("Physical Network Id: "+getEntityId());
 | 
			
		||||
        PhysicalNetwork result = _networkService.getCreatedPhysicalNetwork(getEntityId());
 | 
			
		||||
        if (result != null) {
 | 
			
		||||
            PhysicalNetworkResponse response = _responseGenerator.createPhysicalNetworkResponse(result);
 | 
			
		||||
 | 
			
		||||
@ -25,11 +25,12 @@ import org.apache.cloudstack.api.Parameter;
 | 
			
		||||
import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.PhysicalNetworkResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.SuccessResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.event.EventTypes;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "deletePhysicalNetwork", description="Deletes a Physical Network.", responseObject=SuccessResponse.class, since="3.0.0")
 | 
			
		||||
public class DeletePhysicalNetworkCmd extends BaseAsyncCmd {
 | 
			
		||||
@ -68,7 +69,7 @@ public class DeletePhysicalNetworkCmd extends BaseAsyncCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void execute(){
 | 
			
		||||
        UserContext.current().setEventDetails("Physical Network Id: " + id);
 | 
			
		||||
        CallContext.current().setEventDetails("Physical Network Id: " + id);
 | 
			
		||||
        boolean result = _networkService.deletePhysicalNetwork(getId());
 | 
			
		||||
        if (result) {
 | 
			
		||||
            SuccessResponse response = new SuccessResponse(getCommandName());
 | 
			
		||||
 | 
			
		||||
@ -20,11 +20,13 @@ package org.apache.cloudstack.api.command.admin.network;
 | 
			
		||||
import com.cloud.event.EventTypes;
 | 
			
		||||
import com.cloud.exception.ResourceInUseException;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.cloudstack.api.*;
 | 
			
		||||
import org.apache.cloudstack.api.response.CounterResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.GuestVlanRangeResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.SuccessResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "releaseDedicatedGuestVlanRange", description = "Releases a dedicated guest vlan range to the system", responseObject = SuccessResponse.class)
 | 
			
		||||
@ -80,7 +82,7 @@ public class ReleaseDedicatedGuestVlanRangeCmd extends BaseAsyncCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void execute(){
 | 
			
		||||
        UserContext.current().setEventDetails("Dedicated guest vlan range Id: " + id);
 | 
			
		||||
        CallContext.current().setEventDetails("Dedicated guest vlan range Id: " + id);
 | 
			
		||||
        boolean result = _networkService.releaseDedicatedGuestVlanRange(getId());
 | 
			
		||||
        if (result) {
 | 
			
		||||
            SuccessResponse response = new SuccessResponse(getCommandName());
 | 
			
		||||
 | 
			
		||||
@ -28,6 +28,8 @@ import org.apache.cloudstack.api.BaseAsyncCmd;
 | 
			
		||||
import org.apache.cloudstack.api.Parameter;
 | 
			
		||||
import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.VirtualRouterProviderResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.event.EventTypes;
 | 
			
		||||
@ -37,7 +39,6 @@ import com.cloud.exception.ResourceUnavailableException;
 | 
			
		||||
import com.cloud.network.VirtualRouterProvider;
 | 
			
		||||
import com.cloud.network.element.VirtualRouterElementService;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "configureVirtualRouterElement", responseObject=VirtualRouterProviderResponse.class, description="Configures a virtual router element.")
 | 
			
		||||
public class ConfigureVirtualRouterElementCmd extends BaseAsyncCmd {
 | 
			
		||||
@ -116,7 +117,7 @@ public class ConfigureVirtualRouterElementCmd extends BaseAsyncCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void execute() throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException{
 | 
			
		||||
        UserContext.current().setEventDetails("Virtual router element: " + id);
 | 
			
		||||
        CallContext.current().setEventDetails("Virtual router element: " + id);
 | 
			
		||||
        VirtualRouterProvider result = _service.get(0).configure(this);
 | 
			
		||||
        if (result != null){
 | 
			
		||||
            VirtualRouterProviderResponse routerResponse = _responseGenerator.createVirtualRouterProviderResponse(result);
 | 
			
		||||
 | 
			
		||||
@ -28,6 +28,8 @@ import org.apache.cloudstack.api.Parameter;
 | 
			
		||||
import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.ProviderResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.VirtualRouterProviderResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.event.EventTypes;
 | 
			
		||||
@ -37,7 +39,6 @@ import com.cloud.network.VirtualRouterProvider;
 | 
			
		||||
import com.cloud.network.VirtualRouterProvider.VirtualRouterProviderType;
 | 
			
		||||
import com.cloud.network.element.VirtualRouterElementService;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "createVirtualRouterElement", responseObject=VirtualRouterProviderResponse.class, description="Create a virtual router element.")
 | 
			
		||||
public class CreateVirtualRouterElementCmd extends BaseAsyncCreateCmd {
 | 
			
		||||
@ -98,7 +99,7 @@ public class CreateVirtualRouterElementCmd extends BaseAsyncCreateCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void execute(){
 | 
			
		||||
        UserContext.current().setEventDetails("Virtual router element Id: "+getEntityId());
 | 
			
		||||
        CallContext.current().setEventDetails("Virtual router element Id: "+getEntityId());
 | 
			
		||||
        VirtualRouterProvider result = _service.get(0).getCreatedElement(getEntityId());
 | 
			
		||||
        if (result != null) {
 | 
			
		||||
            VirtualRouterProviderResponse response = _responseGenerator.createVirtualRouterProviderResponse(result);
 | 
			
		||||
 | 
			
		||||
@ -24,6 +24,8 @@ import org.apache.cloudstack.api.BaseAsyncCmd;
 | 
			
		||||
import org.apache.cloudstack.api.Parameter;
 | 
			
		||||
import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.DomainRouterResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.event.EventTypes;
 | 
			
		||||
@ -31,7 +33,6 @@ import com.cloud.exception.ConcurrentOperationException;
 | 
			
		||||
import com.cloud.exception.ResourceUnavailableException;
 | 
			
		||||
import com.cloud.network.router.VirtualRouter;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "destroyRouter", description = "Destroys a router.", responseObject = DomainRouterResponse.class)
 | 
			
		||||
public class DestroyRouterCmd extends BaseAsyncCmd {
 | 
			
		||||
@ -95,10 +96,10 @@ public class DestroyRouterCmd extends BaseAsyncCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void execute() throws ConcurrentOperationException, ResourceUnavailableException {
 | 
			
		||||
        UserContext ctx = UserContext.current();
 | 
			
		||||
        CallContext ctx = CallContext.current();
 | 
			
		||||
        ctx.setEventDetails("Router Id: "+getId());
 | 
			
		||||
 | 
			
		||||
        VirtualRouter result = _routerService.destroyRouter(getId(), ctx.getCaller(), ctx.getCallerUserId());
 | 
			
		||||
        VirtualRouter result = _routerService.destroyRouter(getId(), ctx.getCallingAccount(), ctx.getCallingUserId());
 | 
			
		||||
        if (result != null) {
 | 
			
		||||
            DomainRouterResponse response = _responseGenerator.createDomainRouterResponse(result);
 | 
			
		||||
            response.setResponseName(getCommandName());
 | 
			
		||||
 | 
			
		||||
@ -24,6 +24,8 @@ import org.apache.cloudstack.api.BaseAsyncCmd;
 | 
			
		||||
import org.apache.cloudstack.api.Parameter;
 | 
			
		||||
import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.DomainRouterResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.event.EventTypes;
 | 
			
		||||
@ -32,7 +34,6 @@ import com.cloud.exception.InsufficientCapacityException;
 | 
			
		||||
import com.cloud.exception.ResourceUnavailableException;
 | 
			
		||||
import com.cloud.network.router.VirtualRouter;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "rebootRouter", description="Starts a router.", responseObject=DomainRouterResponse.class)
 | 
			
		||||
public class RebootRouterCmd extends BaseAsyncCmd {
 | 
			
		||||
@ -95,7 +96,7 @@ public class RebootRouterCmd extends BaseAsyncCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void execute() throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException{
 | 
			
		||||
        UserContext.current().setEventDetails("Router Id: "+getId());
 | 
			
		||||
        CallContext.current().setEventDetails("Router Id: "+getId());
 | 
			
		||||
        VirtualRouter result = _routerService.rebootRouter(this.getId(), true);
 | 
			
		||||
        if (result != null){
 | 
			
		||||
            DomainRouterResponse response = _responseGenerator.createDomainRouterResponse(result);
 | 
			
		||||
 | 
			
		||||
@ -24,6 +24,8 @@ import org.apache.cloudstack.api.BaseAsyncCmd;
 | 
			
		||||
import org.apache.cloudstack.api.Parameter;
 | 
			
		||||
import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.DomainRouterResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.event.EventTypes;
 | 
			
		||||
@ -34,7 +36,6 @@ import com.cloud.exception.ResourceUnavailableException;
 | 
			
		||||
import com.cloud.network.router.VirtualRouter;
 | 
			
		||||
import com.cloud.network.router.VirtualRouter.Role;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "startRouter", responseObject=DomainRouterResponse.class, description="Starts a router.")
 | 
			
		||||
public class StartRouterCmd extends BaseAsyncCmd {
 | 
			
		||||
@ -101,7 +102,7 @@ public class StartRouterCmd extends BaseAsyncCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void execute() throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException{
 | 
			
		||||
        UserContext.current().setEventDetails("Router Id: "+getId());
 | 
			
		||||
        CallContext.current().setEventDetails("Router Id: "+getId());
 | 
			
		||||
        VirtualRouter result = null;
 | 
			
		||||
        VirtualRouter router = _routerService.findRouter(getId());
 | 
			
		||||
        if (router == null || router.getRole() != Role.VIRTUAL_ROUTER) {
 | 
			
		||||
 | 
			
		||||
@ -24,6 +24,8 @@ import org.apache.cloudstack.api.BaseAsyncCmd;
 | 
			
		||||
import org.apache.cloudstack.api.Parameter;
 | 
			
		||||
import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.DomainRouterResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.event.EventTypes;
 | 
			
		||||
@ -33,7 +35,6 @@ import com.cloud.exception.ResourceUnavailableException;
 | 
			
		||||
import com.cloud.network.router.VirtualRouter;
 | 
			
		||||
import com.cloud.network.router.VirtualRouter.Role;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "stopRouter", description = "Stops a router.", responseObject = DomainRouterResponse.class)
 | 
			
		||||
public class StopRouterCmd extends BaseAsyncCmd {
 | 
			
		||||
@ -104,7 +105,7 @@ public class StopRouterCmd extends BaseAsyncCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void execute() throws ConcurrentOperationException, ResourceUnavailableException {
 | 
			
		||||
        UserContext.current().setEventDetails("Router Id: "+getId());
 | 
			
		||||
        CallContext.current().setEventDetails("Router Id: "+getId());
 | 
			
		||||
        VirtualRouter result = null;
 | 
			
		||||
        VirtualRouter router = _routerService.findRouter(getId());
 | 
			
		||||
        if (router == null || router.getRole() != Role.VIRTUAL_ROUTER) {
 | 
			
		||||
 | 
			
		||||
@ -24,13 +24,14 @@ import org.apache.cloudstack.api.BaseAsyncCmd;
 | 
			
		||||
import org.apache.cloudstack.api.Parameter;
 | 
			
		||||
import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.StoragePoolResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.event.EventTypes;
 | 
			
		||||
import com.cloud.exception.ResourceUnavailableException;
 | 
			
		||||
import com.cloud.storage.StoragePool;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "cancelStorageMaintenance", description="Cancels maintenance for primary storage", responseObject=StoragePoolResponse.class)
 | 
			
		||||
public class CancelPrimaryStorageMaintenanceCmd extends BaseAsyncCmd {
 | 
			
		||||
@ -81,7 +82,7 @@ public class CancelPrimaryStorageMaintenanceCmd extends BaseAsyncCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public long getEntityOwnerId() {
 | 
			
		||||
        Account account = UserContext.current().getCaller();
 | 
			
		||||
        Account account = CallContext.current().getCallingAccount();
 | 
			
		||||
        if (account != null) {
 | 
			
		||||
            return account.getId();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@ -24,6 +24,8 @@ import org.apache.cloudstack.api.BaseAsyncCmd;
 | 
			
		||||
import org.apache.cloudstack.api.Parameter;
 | 
			
		||||
import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.StoragePoolResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.event.EventTypes;
 | 
			
		||||
@ -31,7 +33,6 @@ import com.cloud.exception.InsufficientCapacityException;
 | 
			
		||||
import com.cloud.exception.ResourceUnavailableException;
 | 
			
		||||
import com.cloud.storage.StoragePool;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "enableStorageMaintenance", description="Puts storage pool into maintenance state", responseObject=StoragePoolResponse.class)
 | 
			
		||||
public class PreparePrimaryStorageForMaintenanceCmd extends BaseAsyncCmd {
 | 
			
		||||
@ -79,7 +80,7 @@ public class PreparePrimaryStorageForMaintenanceCmd extends BaseAsyncCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public long getEntityOwnerId() {
 | 
			
		||||
        Account account = UserContext.current().getCaller();
 | 
			
		||||
        Account account = CallContext.current().getCallingAccount();
 | 
			
		||||
        if (account != null) {
 | 
			
		||||
            return account.getId();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@ -24,11 +24,12 @@ import org.apache.cloudstack.api.BaseAsyncCmd;
 | 
			
		||||
import org.apache.cloudstack.api.Parameter;
 | 
			
		||||
import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.SystemVmResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.event.EventTypes;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
import com.cloud.vm.VirtualMachine;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "destroySystemVm", responseObject=SystemVmResponse.class, description="Destroyes a system virtual machine.")
 | 
			
		||||
@ -56,7 +57,7 @@ public class DestroySystemVmCmd extends BaseAsyncCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public long getEntityOwnerId() {
 | 
			
		||||
        Account account = UserContext.current().getCaller();
 | 
			
		||||
        Account account = CallContext.current().getCallingAccount();
 | 
			
		||||
        if (account != null) {
 | 
			
		||||
            return account.getId();
 | 
			
		||||
        }
 | 
			
		||||
@ -92,7 +93,7 @@ public class DestroySystemVmCmd extends BaseAsyncCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void execute(){
 | 
			
		||||
        UserContext.current().setEventDetails("Vm Id: "+getId());
 | 
			
		||||
        CallContext.current().setEventDetails("Vm Id: "+getId());
 | 
			
		||||
        VirtualMachine instance = _mgr.destroySystemVM(this);
 | 
			
		||||
        if (instance != null) {
 | 
			
		||||
            SystemVmResponse response = _responseGenerator.createSystemVmResponse(instance);
 | 
			
		||||
 | 
			
		||||
@ -25,6 +25,8 @@ import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.HostResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.SystemVmInstanceResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.SystemVmResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.event.EventTypes;
 | 
			
		||||
@ -35,7 +37,6 @@ import com.cloud.exception.ResourceUnavailableException;
 | 
			
		||||
import com.cloud.exception.VirtualMachineMigrationException;
 | 
			
		||||
import com.cloud.host.Host;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
import com.cloud.vm.VirtualMachine;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "migrateSystemVm", description="Attempts Migration of a system virtual machine to the host specified.", responseObject=SystemVmInstanceResponse.class)
 | 
			
		||||
@ -81,7 +82,7 @@ public class MigrateSystemVMCmd extends BaseAsyncCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public long getEntityOwnerId() {
 | 
			
		||||
        Account account = UserContext.current().getCaller();
 | 
			
		||||
        Account account = CallContext.current().getCallingAccount();
 | 
			
		||||
        if (account != null) {
 | 
			
		||||
            return account.getId();
 | 
			
		||||
        }
 | 
			
		||||
@ -107,7 +108,7 @@ public class MigrateSystemVMCmd extends BaseAsyncCmd {
 | 
			
		||||
            throw new InvalidParameterValueException("Unable to find the host to migrate the VM, host id=" + getHostId());
 | 
			
		||||
        }
 | 
			
		||||
        try{
 | 
			
		||||
            UserContext.current().setEventDetails("VM Id: " + getVirtualMachineId() + " to host Id: "+ getHostId());
 | 
			
		||||
            CallContext.current().setEventDetails("VM Id: " + getVirtualMachineId() + " to host Id: "+ getHostId());
 | 
			
		||||
            //FIXME : Should not be calling UserVmService to migrate all types of VMs - need a generic VM layer
 | 
			
		||||
            VirtualMachine migratedVm = _userVmService.migrateVirtualMachine(getVirtualMachineId(), destinationHost);
 | 
			
		||||
            if (migratedVm != null) {
 | 
			
		||||
 | 
			
		||||
@ -24,11 +24,12 @@ import org.apache.cloudstack.api.BaseAsyncCmd;
 | 
			
		||||
import org.apache.cloudstack.api.Parameter;
 | 
			
		||||
import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.SystemVmResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.event.EventTypes;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
import com.cloud.vm.VirtualMachine;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "rebootSystemVm", description="Reboots a system VM.", responseObject=SystemVmResponse.class)
 | 
			
		||||
@ -64,7 +65,7 @@ public class RebootSystemVmCmd extends BaseAsyncCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public long getEntityOwnerId() {
 | 
			
		||||
        Account account = UserContext.current().getCaller();
 | 
			
		||||
        Account account = CallContext.current().getCallingAccount();
 | 
			
		||||
        if (account != null) {
 | 
			
		||||
            return account.getId();
 | 
			
		||||
        }
 | 
			
		||||
@ -98,7 +99,7 @@ public class RebootSystemVmCmd extends BaseAsyncCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void execute(){
 | 
			
		||||
        UserContext.current().setEventDetails("Vm Id: "+getId());
 | 
			
		||||
        CallContext.current().setEventDetails("Vm Id: "+getId());
 | 
			
		||||
        VirtualMachine result = _mgr.rebootSystemVM(this);
 | 
			
		||||
        if (result != null) {
 | 
			
		||||
            SystemVmResponse response = _responseGenerator.createSystemVmResponse(result);
 | 
			
		||||
 | 
			
		||||
@ -18,15 +18,17 @@ package org.apache.cloudstack.api.command.admin.systemvm;
 | 
			
		||||
 | 
			
		||||
import com.cloud.event.EventTypes;
 | 
			
		||||
import com.cloud.exception.*;
 | 
			
		||||
 | 
			
		||||
import org.apache.cloudstack.api.*;
 | 
			
		||||
import org.apache.cloudstack.api.command.user.vm.UpgradeVMCmd;
 | 
			
		||||
import org.apache.cloudstack.api.response.ServiceOfferingResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.SystemVmResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.offering.ServiceOffering;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
import com.cloud.vm.VirtualMachine;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "scaleSystemVm", responseObject=SystemVmResponse.class, description="Scale the service offering for a system vm (console proxy or secondary storage). " +
 | 
			
		||||
@ -71,7 +73,7 @@ public class ScaleSystemVMCmd extends BaseAsyncCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public long getEntityOwnerId() {
 | 
			
		||||
        Account account = UserContext.current().getCaller();
 | 
			
		||||
        Account account = CallContext.current().getCallingAccount();
 | 
			
		||||
        if (account != null) {
 | 
			
		||||
            return account.getId();
 | 
			
		||||
        }
 | 
			
		||||
@ -81,7 +83,7 @@ public class ScaleSystemVMCmd extends BaseAsyncCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void execute(){
 | 
			
		||||
        UserContext.current().setEventDetails("SystemVm Id: "+getId());
 | 
			
		||||
        CallContext.current().setEventDetails("SystemVm Id: "+getId());
 | 
			
		||||
 | 
			
		||||
        ServiceOffering serviceOffering = _configService.getServiceOffering(serviceOfferingId);
 | 
			
		||||
        if (serviceOffering == null) {
 | 
			
		||||
 | 
			
		||||
@ -24,11 +24,12 @@ import org.apache.cloudstack.api.BaseAsyncCmd;
 | 
			
		||||
import org.apache.cloudstack.api.Parameter;
 | 
			
		||||
import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.SystemVmResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.event.EventTypes;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
import com.cloud.vm.VirtualMachine;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "startSystemVm", responseObject=SystemVmResponse.class, description="Starts a system virtual machine.")
 | 
			
		||||
@ -68,7 +69,7 @@ public class StartSystemVMCmd extends BaseAsyncCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public long getEntityOwnerId() {
 | 
			
		||||
        Account account = UserContext.current().getCaller();
 | 
			
		||||
        Account account = CallContext.current().getCallingAccount();
 | 
			
		||||
        if (account != null) {
 | 
			
		||||
            return account.getId();
 | 
			
		||||
        }
 | 
			
		||||
@ -102,7 +103,7 @@ public class StartSystemVMCmd extends BaseAsyncCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void execute(){
 | 
			
		||||
        UserContext.current().setEventDetails("Vm Id: "+getId());
 | 
			
		||||
        CallContext.current().setEventDetails("Vm Id: "+getId());
 | 
			
		||||
        VirtualMachine instance = _mgr.startSystemVM(getId());
 | 
			
		||||
        if (instance != null) {
 | 
			
		||||
            SystemVmResponse response = _responseGenerator.createSystemVmResponse(instance);
 | 
			
		||||
 | 
			
		||||
@ -24,13 +24,14 @@ import org.apache.cloudstack.api.BaseAsyncCmd;
 | 
			
		||||
import org.apache.cloudstack.api.Parameter;
 | 
			
		||||
import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.SystemVmResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.event.EventTypes;
 | 
			
		||||
import com.cloud.exception.ConcurrentOperationException;
 | 
			
		||||
import com.cloud.exception.ResourceUnavailableException;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
import com.cloud.vm.VirtualMachine;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "stopSystemVm", description="Stops a system VM.", responseObject=SystemVmResponse.class)
 | 
			
		||||
@ -69,7 +70,7 @@ public class StopSystemVmCmd extends BaseAsyncCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public long getEntityOwnerId() {
 | 
			
		||||
        Account account = UserContext.current().getCaller();
 | 
			
		||||
        Account account = CallContext.current().getCallingAccount();
 | 
			
		||||
        if (account != null) {
 | 
			
		||||
            return account.getId();
 | 
			
		||||
        }
 | 
			
		||||
@ -109,7 +110,7 @@ public class StopSystemVmCmd extends BaseAsyncCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void execute() throws ResourceUnavailableException, ConcurrentOperationException {
 | 
			
		||||
        UserContext.current().setEventDetails("Vm Id: "+getId());
 | 
			
		||||
        CallContext.current().setEventDetails("Vm Id: "+getId());
 | 
			
		||||
        VirtualMachine result = _mgr.stopSystemVM(this);
 | 
			
		||||
        if (result != null) {
 | 
			
		||||
            SystemVmResponse response = _responseGenerator.createSystemVmResponse(result);
 | 
			
		||||
 | 
			
		||||
@ -25,12 +25,13 @@ import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.command.user.vm.UpgradeVMCmd;
 | 
			
		||||
import org.apache.cloudstack.api.response.ServiceOfferingResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.SystemVmResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.exception.InvalidParameterValueException;
 | 
			
		||||
import com.cloud.offering.ServiceOffering;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
import com.cloud.vm.VirtualMachine;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "changeServiceForSystemVm", responseObject=SystemVmResponse.class, description="Changes the service offering for a system vm (console proxy or secondary storage). " +
 | 
			
		||||
@ -75,7 +76,7 @@ public class UpgradeSystemVMCmd extends BaseCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public long getEntityOwnerId() {
 | 
			
		||||
        Account account = UserContext.current().getCaller();
 | 
			
		||||
        Account account = CallContext.current().getCallingAccount();
 | 
			
		||||
        if (account != null) {
 | 
			
		||||
            return account.getId();
 | 
			
		||||
        }
 | 
			
		||||
@ -85,7 +86,7 @@ public class UpgradeSystemVMCmd extends BaseCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void execute(){
 | 
			
		||||
        UserContext.current().setEventDetails("Vm Id: "+getId());
 | 
			
		||||
        CallContext.current().setEventDetails("Vm Id: "+getId());
 | 
			
		||||
 | 
			
		||||
        ServiceOffering serviceOffering = _configService.getServiceOffering(serviceOfferingId);
 | 
			
		||||
        if (serviceOffering == null) {
 | 
			
		||||
 | 
			
		||||
@ -25,13 +25,14 @@ import org.apache.cloudstack.api.Parameter;
 | 
			
		||||
import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.PhysicalNetworkResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.TrafficTypeResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.event.EventTypes;
 | 
			
		||||
import com.cloud.exception.ResourceAllocationException;
 | 
			
		||||
import com.cloud.network.PhysicalNetworkTrafficType;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "addTrafficType", description="Adds traffic type to a physical network", responseObject=TrafficTypeResponse.class, since="3.0.0")
 | 
			
		||||
public class AddTrafficTypeCmd extends BaseAsyncCreateCmd {
 | 
			
		||||
@ -116,7 +117,7 @@ public class AddTrafficTypeCmd extends BaseAsyncCreateCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void execute(){
 | 
			
		||||
        UserContext.current().setEventDetails("TrafficType Id: "+getEntityId());
 | 
			
		||||
        CallContext.current().setEventDetails("TrafficType Id: "+getEntityId());
 | 
			
		||||
        PhysicalNetworkTrafficType result = _networkService.getPhysicalNetworkTrafficType(getEntityId());
 | 
			
		||||
        if (result != null) {
 | 
			
		||||
            TrafficTypeResponse response = _responseGenerator.createTrafficTypeResponse(result);
 | 
			
		||||
 | 
			
		||||
@ -24,11 +24,12 @@ import org.apache.cloudstack.api.Parameter;
 | 
			
		||||
import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.DomainResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.UserResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.User;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "createUser", description="Creates a user for an account that already exists", responseObject=UserResponse.class)
 | 
			
		||||
public class CreateUserCmd extends BaseCmd {
 | 
			
		||||
@ -119,7 +120,7 @@ public class CreateUserCmd extends BaseCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public long getEntityOwnerId() {
 | 
			
		||||
        Account account = UserContext.current().getCaller();
 | 
			
		||||
        Account account = CallContext.current().getCallingAccount();
 | 
			
		||||
        if ((account == null) || isAdmin(account.getType())) {
 | 
			
		||||
            if ((domainId != null) && (accountName != null)) {
 | 
			
		||||
                Account userAccount = _responseGenerator.findAccountByNameDomain(accountName, domainId);
 | 
			
		||||
@ -138,7 +139,7 @@ public class CreateUserCmd extends BaseCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void execute(){
 | 
			
		||||
        UserContext.current().setEventDetails("UserName: "+getUserName()+", FirstName :"+getFirstName()+", LastName: "+getLastName());
 | 
			
		||||
        CallContext.current().setEventDetails("UserName: "+getUserName()+", FirstName :"+getFirstName()+", LastName: "+getLastName());
 | 
			
		||||
        User user = _accountService.createUser(getUserName(), getPassword(), getFirstName(), getLastName(), getEmail(), getTimezone(), getAccountName(), getDomainId(), getUserUUID());
 | 
			
		||||
        if (user != null) {
 | 
			
		||||
            UserResponse response = _responseGenerator.createUserResponse(user);
 | 
			
		||||
 | 
			
		||||
@ -26,12 +26,13 @@ import org.apache.cloudstack.api.Parameter;
 | 
			
		||||
import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.SuccessResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.UserResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
import org.apache.cloudstack.region.RegionService;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.User;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "deleteUser", description="Deletes a user for an account", responseObject=SuccessResponse.class)
 | 
			
		||||
public class DeleteUserCmd extends BaseCmd {
 | 
			
		||||
@ -76,7 +77,7 @@ public class DeleteUserCmd extends BaseCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void execute(){
 | 
			
		||||
        UserContext.current().setEventDetails("UserId: "+getId());
 | 
			
		||||
        CallContext.current().setEventDetails("UserId: "+getId());
 | 
			
		||||
        boolean result = _regionService.deleteUser(this);
 | 
			
		||||
        if (result) {
 | 
			
		||||
            SuccessResponse response = new SuccessResponse(getCommandName());
 | 
			
		||||
 | 
			
		||||
@ -27,14 +27,15 @@ import org.apache.cloudstack.api.APICommand;
 | 
			
		||||
import org.apache.cloudstack.api.Parameter;
 | 
			
		||||
import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.UserResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
import org.apache.cloudstack.region.RegionService;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.event.EventTypes;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.User;
 | 
			
		||||
import com.cloud.user.UserAccount;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "disableUser", description="Disables a user account", responseObject=UserResponse.class)
 | 
			
		||||
public class DisableUserCmd extends BaseAsyncCmd {
 | 
			
		||||
@ -91,7 +92,7 @@ public class DisableUserCmd extends BaseAsyncCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void execute(){
 | 
			
		||||
        UserContext.current().setEventDetails("UserId: "+getId());
 | 
			
		||||
        CallContext.current().setEventDetails("UserId: "+getId());
 | 
			
		||||
        UserAccount user = _regionService.disableUser(this);
 | 
			
		||||
 | 
			
		||||
        if (user != null){
 | 
			
		||||
 | 
			
		||||
@ -25,13 +25,14 @@ import org.apache.cloudstack.api.BaseCmd;
 | 
			
		||||
import org.apache.cloudstack.api.Parameter;
 | 
			
		||||
import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.UserResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
import org.apache.cloudstack.region.RegionService;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.User;
 | 
			
		||||
import com.cloud.user.UserAccount;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "enableUser", description="Enables a user account", responseObject=UserResponse.class)
 | 
			
		||||
public class EnableUserCmd extends BaseCmd {
 | 
			
		||||
@ -77,7 +78,7 @@ public class EnableUserCmd extends BaseCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void execute(){
 | 
			
		||||
        UserContext.current().setEventDetails("UserId: "+getId());
 | 
			
		||||
        CallContext.current().setEventDetails("UserId: "+getId());
 | 
			
		||||
        UserAccount user = _regionService.enableUser(this);
 | 
			
		||||
 | 
			
		||||
        if (user != null){
 | 
			
		||||
 | 
			
		||||
@ -25,13 +25,14 @@ import org.apache.cloudstack.api.BaseCmd;
 | 
			
		||||
import org.apache.cloudstack.api.Parameter;
 | 
			
		||||
import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.UserResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
import org.apache.cloudstack.region.RegionService;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.User;
 | 
			
		||||
import com.cloud.user.UserAccount;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "updateUser", description="Updates a user account", responseObject=UserResponse.class)
 | 
			
		||||
public class UpdateUserCmd extends BaseCmd {
 | 
			
		||||
@ -134,7 +135,7 @@ public class UpdateUserCmd extends BaseCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void execute(){
 | 
			
		||||
        UserContext.current().setEventDetails("UserId: "+getId());
 | 
			
		||||
        CallContext.current().setEventDetails("UserId: "+getId());
 | 
			
		||||
        UserAccount user = _regionService.updateUser(this);
 | 
			
		||||
 | 
			
		||||
        if (user != null){
 | 
			
		||||
 | 
			
		||||
@ -25,6 +25,8 @@ import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.HostResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.StoragePoolResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.UserVmResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.event.EventTypes;
 | 
			
		||||
@ -36,7 +38,6 @@ import com.cloud.exception.VirtualMachineMigrationException;
 | 
			
		||||
import com.cloud.host.Host;
 | 
			
		||||
import com.cloud.storage.StoragePool;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
import com.cloud.uservm.UserVm;
 | 
			
		||||
import com.cloud.vm.VirtualMachine;
 | 
			
		||||
 | 
			
		||||
@ -129,7 +130,7 @@ public class MigrateVMCmd extends BaseAsyncCmd {
 | 
			
		||||
            if (destinationHost == null) {
 | 
			
		||||
                throw new InvalidParameterValueException("Unable to find the host to migrate the VM, host id=" + getHostId());
 | 
			
		||||
            }
 | 
			
		||||
            UserContext.current().setEventDetails("VM Id: " + getVirtualMachineId() + " to host Id: "+ getHostId());
 | 
			
		||||
            CallContext.current().setEventDetails("VM Id: " + getVirtualMachineId() + " to host Id: "+ getHostId());
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        StoragePool destStoragePool = null;
 | 
			
		||||
@ -138,7 +139,7 @@ public class MigrateVMCmd extends BaseAsyncCmd {
 | 
			
		||||
            if (destStoragePool == null) {
 | 
			
		||||
                throw new InvalidParameterValueException("Unable to find the storage pool to migrate the VM");
 | 
			
		||||
            }
 | 
			
		||||
            UserContext.current().setEventDetails("VM Id: " + getVirtualMachineId() + " to storage pool Id: "+ getStoragePoolId());
 | 
			
		||||
            CallContext.current().setEventDetails("VM Id: " + getVirtualMachineId() + " to storage pool Id: "+ getStoragePoolId());
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        try{
 | 
			
		||||
 | 
			
		||||
@ -22,14 +22,16 @@ import java.util.Iterator;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
import org.apache.cloudstack.api.*;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import org.apache.cloudstack.api.APICommand;
 | 
			
		||||
 | 
			
		||||
import org.apache.cloudstack.api.BaseCmd.CommandType;
 | 
			
		||||
import org.apache.cloudstack.api.response.HostResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.StoragePoolResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.UserVmResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import com.cloud.event.EventTypes;
 | 
			
		||||
import com.cloud.exception.ConcurrentOperationException;
 | 
			
		||||
import com.cloud.exception.InvalidParameterValueException;
 | 
			
		||||
@ -39,7 +41,6 @@ import com.cloud.exception.VirtualMachineMigrationException;
 | 
			
		||||
import com.cloud.host.Host;
 | 
			
		||||
import com.cloud.storage.StoragePool;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
import com.cloud.uservm.UserVm;
 | 
			
		||||
import com.cloud.vm.VirtualMachine;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -25,6 +25,8 @@ import org.apache.cloudstack.api.Parameter;
 | 
			
		||||
import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.PrivateGatewayResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.SuccessResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.event.EventTypes;
 | 
			
		||||
@ -33,7 +35,6 @@ import com.cloud.exception.InvalidParameterValueException;
 | 
			
		||||
import com.cloud.exception.ResourceUnavailableException;
 | 
			
		||||
import com.cloud.network.vpc.VpcGateway;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "deletePrivateGateway", description="Deletes a Private gateway", responseObject=SuccessResponse.class)
 | 
			
		||||
public class DeletePrivateGatewayCmd extends BaseAsyncCmd {
 | 
			
		||||
@ -81,7 +82,7 @@ public class DeletePrivateGatewayCmd extends BaseAsyncCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void execute() throws ResourceUnavailableException, ConcurrentOperationException {
 | 
			
		||||
        UserContext.current().setEventDetails("Network ACL Id: " + id);
 | 
			
		||||
        CallContext.current().setEventDetails("Network ACL Id: " + id);
 | 
			
		||||
        boolean result = _vpcService.deleteVpcPrivateGateway(id);
 | 
			
		||||
        if (result) {
 | 
			
		||||
            SuccessResponse response = new SuccessResponse(getCommandName());
 | 
			
		||||
 | 
			
		||||
@ -24,11 +24,12 @@ import org.apache.cloudstack.api.Parameter;
 | 
			
		||||
import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.DomainResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.ZoneResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.dc.DataCenter;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "createZone", description="Creates a Zone.", responseObject=ZoneResponse.class)
 | 
			
		||||
public class CreateZoneCmd extends BaseCmd {
 | 
			
		||||
@ -163,7 +164,7 @@ public class CreateZoneCmd extends BaseCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void execute(){
 | 
			
		||||
        UserContext.current().setEventDetails("Zone Name: "+getZoneName());
 | 
			
		||||
        CallContext.current().setEventDetails("Zone Name: "+getZoneName());
 | 
			
		||||
        DataCenter result = _configService.createZone(this);
 | 
			
		||||
        if (result != null){
 | 
			
		||||
            ZoneResponse response = _responseGenerator.createZoneResponse(result,false);
 | 
			
		||||
 | 
			
		||||
@ -24,10 +24,11 @@ import org.apache.cloudstack.api.Parameter;
 | 
			
		||||
import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.SuccessResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.ZoneResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "deleteZone", description="Deletes a Zone.", responseObject=SuccessResponse.class)
 | 
			
		||||
public class DeleteZoneCmd extends BaseCmd {
 | 
			
		||||
@ -69,7 +70,7 @@ public class DeleteZoneCmd extends BaseCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void execute(){
 | 
			
		||||
        UserContext.current().setEventDetails("Zone Id: "+getId());
 | 
			
		||||
        CallContext.current().setEventDetails("Zone Id: "+getId());
 | 
			
		||||
        boolean result = _configService.deleteZone(this);
 | 
			
		||||
        if (result) {
 | 
			
		||||
            SuccessResponse response = new SuccessResponse(getCommandName());
 | 
			
		||||
 | 
			
		||||
@ -26,11 +26,12 @@ import org.apache.cloudstack.api.BaseCmd;
 | 
			
		||||
import org.apache.cloudstack.api.Parameter;
 | 
			
		||||
import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.ZoneResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.dc.DataCenter;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "updateZone", description="Updates a Zone.", responseObject=ZoneResponse.class)
 | 
			
		||||
public class UpdateZoneCmd extends BaseCmd {
 | 
			
		||||
@ -175,7 +176,7 @@ public class UpdateZoneCmd extends BaseCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void execute(){
 | 
			
		||||
        UserContext.current().setEventDetails("Zone Id: "+getId());
 | 
			
		||||
        CallContext.current().setEventDetails("Zone Id: "+getId());
 | 
			
		||||
        DataCenter result = _configService.editZone(this);
 | 
			
		||||
        if (result != null) {
 | 
			
		||||
            ZoneResponse response = _responseGenerator.createZoneResponse(result, false);
 | 
			
		||||
 | 
			
		||||
@ -24,12 +24,13 @@ import org.apache.cloudstack.api.Parameter;
 | 
			
		||||
import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.ProjectResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.SuccessResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.event.EventTypes;
 | 
			
		||||
import com.cloud.exception.InvalidParameterValueException;
 | 
			
		||||
import com.cloud.projects.Project;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "addAccountToProject", description="Adds acoount to a project", responseObject=SuccessResponse.class, since="3.0.0")
 | 
			
		||||
@ -85,7 +86,7 @@ public class AddAccountToProjectCmd extends BaseAsyncCmd {
 | 
			
		||||
            throw new InvalidParameterValueException("Either accountName or email is required");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        UserContext.current().setEventDetails("Project id: "+ projectId + "; accountName " + accountName);
 | 
			
		||||
        CallContext.current().setEventDetails("Project id: "+ projectId + "; accountName " + accountName);
 | 
			
		||||
        boolean result = _projectService.addAccountToProject(getProjectId(), getAccountName(), getEmail());
 | 
			
		||||
        if (result) {
 | 
			
		||||
            SuccessResponse response = new SuccessResponse(getCommandName());
 | 
			
		||||
 | 
			
		||||
@ -25,12 +25,13 @@ import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.command.user.project.DeleteProjectCmd;
 | 
			
		||||
import org.apache.cloudstack.api.response.ProjectResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.SuccessResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.event.EventTypes;
 | 
			
		||||
import com.cloud.exception.InvalidParameterValueException;
 | 
			
		||||
import com.cloud.projects.Project;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "deleteAccountFromProject", description="Deletes account from the project", responseObject=SuccessResponse.class, since="3.0.0")
 | 
			
		||||
public class DeleteAccountFromProjectCmd extends BaseAsyncCmd {
 | 
			
		||||
@ -74,7 +75,7 @@ public class DeleteAccountFromProjectCmd extends BaseAsyncCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void execute(){
 | 
			
		||||
        UserContext.current().setEventDetails("Project id: "+ projectId + "; accountName " + accountName);
 | 
			
		||||
        CallContext.current().setEventDetails("Project id: "+ projectId + "; accountName " + accountName);
 | 
			
		||||
        boolean result = _projectService.deleteAccountFromProject(projectId, accountName);
 | 
			
		||||
        if (result) {
 | 
			
		||||
            SuccessResponse response = new SuccessResponse(getCommandName());
 | 
			
		||||
 | 
			
		||||
@ -34,6 +34,8 @@ import org.apache.cloudstack.api.response.ProjectResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.RegionResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.VpcResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.ZoneResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.dc.DataCenter;
 | 
			
		||||
@ -51,7 +53,6 @@ import com.cloud.network.Network;
 | 
			
		||||
import com.cloud.network.vpc.Vpc;
 | 
			
		||||
import com.cloud.projects.Project;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "associateIpAddress", description="Acquires and associates a public IP to an account.", responseObject=IPAddressResponse.class)
 | 
			
		||||
public class AssociateIPAddrCmd extends BaseAsyncCreateCmd {
 | 
			
		||||
@ -104,14 +105,14 @@ public class AssociateIPAddrCmd extends BaseAsyncCreateCmd {
 | 
			
		||||
        if (accountName != null) {
 | 
			
		||||
            return accountName;
 | 
			
		||||
        }
 | 
			
		||||
        return UserContext.current().getCaller().getAccountName();
 | 
			
		||||
        return CallContext.current().getCallingAccount().getAccountName();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public long getDomainId() {
 | 
			
		||||
        if (domainId != null) {
 | 
			
		||||
            return domainId;
 | 
			
		||||
        }
 | 
			
		||||
        return UserContext.current().getCaller().getDomainId();
 | 
			
		||||
        return CallContext.current().getCallingAccount().getDomainId();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private long getZoneId() {
 | 
			
		||||
@ -192,7 +193,7 @@ public class AssociateIPAddrCmd extends BaseAsyncCreateCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public long getEntityOwnerId() {
 | 
			
		||||
        Account caller = UserContext.current().getCaller();
 | 
			
		||||
        Account caller = CallContext.current().getCallingAccount();
 | 
			
		||||
        if (accountName != null && domainId != null) {
 | 
			
		||||
            Account account = _accountService.finalizeOwner(caller, accountName, domainId, projectId);
 | 
			
		||||
            return account.getId();
 | 
			
		||||
@ -280,7 +281,7 @@ public class AssociateIPAddrCmd extends BaseAsyncCreateCmd {
 | 
			
		||||
    @Override
 | 
			
		||||
    public void execute() throws ResourceUnavailableException, ResourceAllocationException,
 | 
			
		||||
                                    ConcurrentOperationException, InsufficientCapacityException {
 | 
			
		||||
        UserContext.current().setEventDetails("Ip Id: " + getEntityId());
 | 
			
		||||
        CallContext.current().setEventDetails("Ip Id: " + getEntityId());
 | 
			
		||||
 | 
			
		||||
        IpAddress result = null;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -26,6 +26,8 @@ import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.AccountResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.IPAddressResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.SuccessResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.event.EventTypes;
 | 
			
		||||
@ -33,7 +35,6 @@ import com.cloud.exception.InsufficientAddressCapacityException;
 | 
			
		||||
import com.cloud.exception.InvalidParameterValueException;
 | 
			
		||||
import com.cloud.network.IpAddress;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "disassociateIpAddress", description="Disassociates an ip address from the account.", responseObject=SuccessResponse.class)
 | 
			
		||||
public class DisassociateIPAddrCmd extends BaseAsyncCmd {
 | 
			
		||||
@ -73,7 +74,7 @@ public class DisassociateIPAddrCmd extends BaseAsyncCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void execute() throws InsufficientAddressCapacityException{
 | 
			
		||||
        UserContext.current().setEventDetails("Ip Id: " + getIpAddressId());
 | 
			
		||||
        CallContext.current().setEventDetails("Ip Id: " + getIpAddressId());
 | 
			
		||||
        boolean result = false;
 | 
			
		||||
        if (!isPortable(id)) {
 | 
			
		||||
            result = _networkService.releaseIpAddress(getIpAddressId());
 | 
			
		||||
 | 
			
		||||
@ -26,12 +26,13 @@ import org.apache.cloudstack.api.BaseAsyncCreateCmd;
 | 
			
		||||
import org.apache.cloudstack.api.Parameter;
 | 
			
		||||
import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.DomainResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.event.EventTypes;
 | 
			
		||||
import com.cloud.exception.ResourceAllocationException;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "createAffinityGroup", responseObject = AffinityGroupResponse.class, description = "Creates an affinity/anti-affinity group")
 | 
			
		||||
public class CreateAffinityGroupCmd extends BaseAsyncCreateCmd {
 | 
			
		||||
@ -94,7 +95,7 @@ public class CreateAffinityGroupCmd extends BaseAsyncCreateCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public long getEntityOwnerId() {
 | 
			
		||||
        Account account = UserContext.current().getCaller();
 | 
			
		||||
        Account account = CallContext.current().getCallingAccount();
 | 
			
		||||
        if ((account == null) || isAdmin(account.getType())) {
 | 
			
		||||
            if ((domainId != null) && (accountName != null)) {
 | 
			
		||||
                Account userAccount = _responseGenerator.findAccountByNameDomain(accountName, domainId);
 | 
			
		||||
 | 
			
		||||
@ -26,12 +26,13 @@ import org.apache.cloudstack.api.Parameter;
 | 
			
		||||
import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.DomainResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.SuccessResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.event.EventTypes;
 | 
			
		||||
import com.cloud.exception.InvalidParameterValueException;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "deleteAffinityGroup", description = "Deletes affinity group", responseObject = SuccessResponse.class)
 | 
			
		||||
public class DeleteAffinityGroupCmd extends BaseAsyncCmd {
 | 
			
		||||
@ -100,7 +101,7 @@ public class DeleteAffinityGroupCmd extends BaseAsyncCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public long getEntityOwnerId() {
 | 
			
		||||
        Account account = UserContext.current().getCaller();
 | 
			
		||||
        Account account = CallContext.current().getCallingAccount();
 | 
			
		||||
        if ((account == null) || isAdmin(account.getType())) {
 | 
			
		||||
            if ((domainId != null) && (accountName != null)) {
 | 
			
		||||
                Account userAccount = _responseGenerator.findAccountByNameDomain(accountName, domainId);
 | 
			
		||||
 | 
			
		||||
@ -31,6 +31,8 @@ import org.apache.cloudstack.api.Parameter;
 | 
			
		||||
import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.ApiConstants.VMDetails;
 | 
			
		||||
import org.apache.cloudstack.api.response.UserVmResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.event.EventTypes;
 | 
			
		||||
@ -38,7 +40,6 @@ import com.cloud.exception.InsufficientCapacityException;
 | 
			
		||||
import com.cloud.exception.InvalidParameterValueException;
 | 
			
		||||
import com.cloud.exception.ResourceUnavailableException;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
import com.cloud.uservm.UserVm;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -131,7 +132,7 @@ public class UpdateVMAffinityGroupCmd extends BaseAsyncCmd {
 | 
			
		||||
    @Override
 | 
			
		||||
    public void execute() throws ResourceUnavailableException,
 | 
			
		||||
            InsufficientCapacityException, ServerApiException {
 | 
			
		||||
        UserContext.current().setEventDetails("Vm Id: "+getId());
 | 
			
		||||
        CallContext.current().setEventDetails("Vm Id: "+getId());
 | 
			
		||||
        UserVm result = _affinityGroupService.updateVMAffinityGroups(getId(), getAffinityGroupIdList());
 | 
			
		||||
        ArrayList<VMDetails> dc = new ArrayList<VMDetails>();
 | 
			
		||||
        dc.add(VMDetails.valueOf("affgrp"));
 | 
			
		||||
 | 
			
		||||
@ -31,6 +31,8 @@ import org.apache.cloudstack.api.response.ServiceOfferingResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.TemplateResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.UserResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.ZoneResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.event.EventTypes;
 | 
			
		||||
@ -39,7 +41,6 @@ import com.cloud.exception.ResourceAllocationException;
 | 
			
		||||
import com.cloud.network.as.AutoScaleVmProfile;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.User;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "createAutoScaleVmProfile", description = "Creates a profile that contains information about the virtual machine which will be provisioned automatically by autoscale feature.", responseObject = AutoScaleVmProfileResponse.class)
 | 
			
		||||
@SuppressWarnings("rawtypes")
 | 
			
		||||
@ -119,7 +120,7 @@ public class CreateAutoScaleVmProfileCmd extends BaseAsyncCreateCmd {
 | 
			
		||||
        if (autoscaleUserId != null) {
 | 
			
		||||
            return autoscaleUserId;
 | 
			
		||||
        } else {
 | 
			
		||||
            return UserContext.current().getCaller().getId();
 | 
			
		||||
            return CallContext.current().getCallingAccount().getId();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -136,7 +137,7 @@ public class CreateAutoScaleVmProfileCmd extends BaseAsyncCreateCmd {
 | 
			
		||||
            User user = _entityMgr.findById(User.class, autoscaleUserId);
 | 
			
		||||
            account = _entityMgr.findById(Account.class, user.getAccountId());
 | 
			
		||||
        } else {
 | 
			
		||||
            account = UserContext.current().getCaller();
 | 
			
		||||
            account = CallContext.current().getCallingAccount();
 | 
			
		||||
        }
 | 
			
		||||
        accountId = account.getAccountId();
 | 
			
		||||
        domainId = account.getDomainId();
 | 
			
		||||
 | 
			
		||||
@ -27,12 +27,13 @@ import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.ConditionResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.CounterResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.DomainResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.event.EventTypes;
 | 
			
		||||
import com.cloud.exception.ResourceAllocationException;
 | 
			
		||||
import com.cloud.network.as.Condition;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "createCondition", description = "Creates a condition", responseObject = ConditionResponse.class)
 | 
			
		||||
public class CreateConditionCmd extends BaseAsyncCreateCmd {
 | 
			
		||||
@ -105,7 +106,7 @@ public class CreateConditionCmd extends BaseAsyncCreateCmd {
 | 
			
		||||
 | 
			
		||||
    public String getAccountName() {
 | 
			
		||||
        if (accountName == null) {
 | 
			
		||||
            return UserContext.current().getCaller().getAccountName();
 | 
			
		||||
            return CallContext.current().getCallingAccount().getAccountName();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return accountName;
 | 
			
		||||
@ -113,7 +114,7 @@ public class CreateConditionCmd extends BaseAsyncCreateCmd {
 | 
			
		||||
 | 
			
		||||
    public Long getDomainId() {
 | 
			
		||||
        if (domainId == null) {
 | 
			
		||||
            return UserContext.current().getCaller().getDomainId();
 | 
			
		||||
            return CallContext.current().getCallingAccount().getDomainId();
 | 
			
		||||
        }
 | 
			
		||||
        return domainId;
 | 
			
		||||
    }
 | 
			
		||||
@ -141,7 +142,7 @@ public class CreateConditionCmd extends BaseAsyncCreateCmd {
 | 
			
		||||
    public long getEntityOwnerId() {
 | 
			
		||||
        Long accountId = finalyzeAccountId(accountName, domainId, null, true);
 | 
			
		||||
        if (accountId == null) {
 | 
			
		||||
            return UserContext.current().getCaller().getId();
 | 
			
		||||
            return CallContext.current().getCallingAccount().getId();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return accountId;
 | 
			
		||||
 | 
			
		||||
@ -25,12 +25,13 @@ import org.apache.cloudstack.api.Parameter;
 | 
			
		||||
import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.AutoScalePolicyResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.SuccessResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.event.EventTypes;
 | 
			
		||||
import com.cloud.network.as.AutoScalePolicy;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "deleteAutoScalePolicy", description = "Deletes a autoscale policy.", responseObject = SuccessResponse.class)
 | 
			
		||||
public class DeleteAutoScalePolicyCmd extends BaseAsyncCmd {
 | 
			
		||||
@ -84,7 +85,7 @@ public class DeleteAutoScalePolicyCmd extends BaseAsyncCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void execute() {
 | 
			
		||||
        UserContext.current().setEventDetails("AutoScale Policy Id: " + getId());
 | 
			
		||||
        CallContext.current().setEventDetails("AutoScale Policy Id: " + getId());
 | 
			
		||||
        boolean result = _autoScaleService.deleteAutoScalePolicy(id);
 | 
			
		||||
 | 
			
		||||
        if (result) {
 | 
			
		||||
 | 
			
		||||
@ -25,12 +25,13 @@ import org.apache.cloudstack.api.Parameter;
 | 
			
		||||
import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.AutoScaleVmGroupResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.SuccessResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.event.EventTypes;
 | 
			
		||||
import com.cloud.network.as.AutoScaleVmGroup;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "deleteAutoScaleVmGroup", description = "Deletes a autoscale vm group.", responseObject = SuccessResponse.class)
 | 
			
		||||
public class DeleteAutoScaleVmGroupCmd extends BaseAsyncCmd {
 | 
			
		||||
@ -84,7 +85,7 @@ public class DeleteAutoScaleVmGroupCmd extends BaseAsyncCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void execute() {
 | 
			
		||||
        UserContext.current().setEventDetails("AutoScale Vm Group Id: " + getId());
 | 
			
		||||
        CallContext.current().setEventDetails("AutoScale Vm Group Id: " + getId());
 | 
			
		||||
        boolean result = _autoScaleService.deleteAutoScaleVmGroup(id);
 | 
			
		||||
 | 
			
		||||
        if (result) {
 | 
			
		||||
 | 
			
		||||
@ -25,12 +25,13 @@ import org.apache.cloudstack.api.Parameter;
 | 
			
		||||
import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.AutoScaleVmProfileResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.SuccessResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.event.EventTypes;
 | 
			
		||||
import com.cloud.network.as.AutoScaleVmProfile;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "deleteAutoScaleVmProfile", description = "Deletes a autoscale vm profile.", responseObject = SuccessResponse.class)
 | 
			
		||||
public class DeleteAutoScaleVmProfileCmd extends BaseAsyncCmd {
 | 
			
		||||
@ -84,7 +85,7 @@ public class DeleteAutoScaleVmProfileCmd extends BaseAsyncCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void execute() {
 | 
			
		||||
        UserContext.current().setEventDetails("AutoScale VM Profile Id: " + getId());
 | 
			
		||||
        CallContext.current().setEventDetails("AutoScale VM Profile Id: " + getId());
 | 
			
		||||
        boolean result = _autoScaleService.deleteAutoScaleVmProfile(id);
 | 
			
		||||
        if (result) {
 | 
			
		||||
            SuccessResponse response = new SuccessResponse(getCommandName());
 | 
			
		||||
 | 
			
		||||
@ -28,12 +28,13 @@ import org.apache.cloudstack.api.Parameter;
 | 
			
		||||
import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.AutoScalePolicyResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.ConditionResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.event.EventTypes;
 | 
			
		||||
import com.cloud.network.as.AutoScalePolicy;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "updateAutoScalePolicy", description = "Updates an existing autoscale policy.", responseObject = AutoScalePolicyResponse.class)
 | 
			
		||||
public class UpdateAutoScalePolicyCmd extends BaseAsyncCmd {
 | 
			
		||||
@ -61,7 +62,7 @@ public class UpdateAutoScalePolicyCmd extends BaseAsyncCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void execute() {
 | 
			
		||||
        UserContext.current().setEventDetails("AutoScale Policy Id: " + getId());
 | 
			
		||||
        CallContext.current().setEventDetails("AutoScale Policy Id: " + getId());
 | 
			
		||||
        AutoScalePolicy result = _autoScaleService.updateAutoScalePolicy(this);
 | 
			
		||||
        if (result != null) {
 | 
			
		||||
            AutoScalePolicyResponse response = _responseGenerator.createAutoScalePolicyResponse(result);
 | 
			
		||||
 | 
			
		||||
@ -28,12 +28,13 @@ import org.apache.cloudstack.api.Parameter;
 | 
			
		||||
import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.AutoScalePolicyResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.AutoScaleVmGroupResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.event.EventTypes;
 | 
			
		||||
import com.cloud.network.as.AutoScaleVmGroup;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "updateAutoScaleVmGroup", description = "Updates an existing autoscale vm group.", responseObject = AutoScaleVmGroupResponse.class)
 | 
			
		||||
public class UpdateAutoScaleVmGroupCmd extends BaseAsyncCmd {
 | 
			
		||||
@ -72,7 +73,7 @@ public class UpdateAutoScaleVmGroupCmd extends BaseAsyncCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void execute() {
 | 
			
		||||
        UserContext.current().setEventDetails("AutoScale Vm Group Id: " + getId());
 | 
			
		||||
        CallContext.current().setEventDetails("AutoScale Vm Group Id: " + getId());
 | 
			
		||||
        AutoScaleVmGroup result = _autoScaleService.updateAutoScaleVmGroup(this);
 | 
			
		||||
        if (result != null) {
 | 
			
		||||
            AutoScaleVmGroupResponse response = _responseGenerator.createAutoScaleVmGroupResponse(result);
 | 
			
		||||
 | 
			
		||||
@ -29,12 +29,13 @@ import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.AutoScaleVmProfileResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.TemplateResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.UserResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.event.EventTypes;
 | 
			
		||||
import com.cloud.network.as.AutoScaleVmProfile;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "updateAutoScaleVmProfile", description = "Updates an existing autoscale vm profile.", responseObject = AutoScaleVmProfileResponse.class)
 | 
			
		||||
public class UpdateAutoScaleVmProfileCmd extends BaseAsyncCmd {
 | 
			
		||||
@ -70,7 +71,7 @@ public class UpdateAutoScaleVmProfileCmd extends BaseAsyncCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void execute() {
 | 
			
		||||
        UserContext.current().setEventDetails("AutoScale Policy Id: " + getId());
 | 
			
		||||
        CallContext.current().setEventDetails("AutoScale Policy Id: " + getId());
 | 
			
		||||
        AutoScaleVmProfile result = _autoScaleService.updateAutoScaleVmProfile(this);
 | 
			
		||||
        if (result != null) {
 | 
			
		||||
            AutoScaleVmProfileResponse response = _responseGenerator.createAutoScaleVmProfileResponse(result);
 | 
			
		||||
 | 
			
		||||
@ -27,11 +27,12 @@ import org.apache.cloudstack.api.Parameter;
 | 
			
		||||
import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.EventResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.SuccessResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.exception.InvalidParameterValueException;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "archiveEvents", description = "Archive one or more events.", responseObject = SuccessResponse.class)
 | 
			
		||||
public class ArchiveEventsCmd extends BaseCmd {
 | 
			
		||||
@ -90,7 +91,7 @@ public class ArchiveEventsCmd extends BaseCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public long getEntityOwnerId() {
 | 
			
		||||
        Account account = UserContext.current().getCaller();
 | 
			
		||||
        Account account = CallContext.current().getCallingAccount();
 | 
			
		||||
        if (account != null) {
 | 
			
		||||
            return account.getId();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@ -27,11 +27,12 @@ import org.apache.cloudstack.api.Parameter;
 | 
			
		||||
import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.EventResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.SuccessResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.exception.InvalidParameterValueException;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "deleteEvents", description = "Delete one or more events.", responseObject = SuccessResponse.class)
 | 
			
		||||
public class DeleteEventsCmd extends BaseCmd {
 | 
			
		||||
@ -90,7 +91,7 @@ public class DeleteEventsCmd extends BaseCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public long getEntityOwnerId() {
 | 
			
		||||
        Account account = UserContext.current().getCaller();
 | 
			
		||||
        Account account = CallContext.current().getCallingAccount();
 | 
			
		||||
        if (account != null) {
 | 
			
		||||
            return account.getId();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@ -19,6 +19,7 @@ package org.apache.cloudstack.api.command.user.firewall;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import org.apache.cloudstack.api.APICommand;
 | 
			
		||||
@ -32,6 +33,7 @@ import org.apache.cloudstack.api.Parameter;
 | 
			
		||||
import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.FirewallResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.NetworkResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import com.cloud.event.EventTypes;
 | 
			
		||||
import com.cloud.exception.InvalidParameterValueException;
 | 
			
		||||
@ -40,7 +42,6 @@ import com.cloud.exception.ResourceUnavailableException;
 | 
			
		||||
import com.cloud.network.Network;
 | 
			
		||||
import com.cloud.network.rules.FirewallRule;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
import com.cloud.utils.net.NetUtils;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "createEgressFirewallRule", description = "Creates a egress firewall rule for a given network ", responseObject = FirewallResponse.class)
 | 
			
		||||
@ -128,12 +129,12 @@ public class CreateEgressFirewallRuleCmd extends BaseAsyncCreateCmd implements F
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void execute() throws ResourceUnavailableException {
 | 
			
		||||
        UserContext callerContext = UserContext.current();
 | 
			
		||||
        CallContext callerContext = CallContext.current();
 | 
			
		||||
        boolean success = false;
 | 
			
		||||
        FirewallRule rule = _entityMgr.findById(FirewallRule.class, getEntityId());
 | 
			
		||||
        try {
 | 
			
		||||
            UserContext.current().setEventDetails("Rule Id: " + getEntityId());
 | 
			
		||||
             success = _firewallService.applyEgressFirewallRules (rule, callerContext.getCaller());
 | 
			
		||||
            CallContext.current().setEventDetails("Rule Id: " + getEntityId());
 | 
			
		||||
             success = _firewallService.applyEgressFirewallRules (rule, callerContext.getCallingAccount());
 | 
			
		||||
            // State is different after the rule is applied, so get new object here
 | 
			
		||||
            rule = _entityMgr.findById(FirewallRule.class, getEntityId());
 | 
			
		||||
            FirewallResponse fwResponse = new FirewallResponse();
 | 
			
		||||
@ -204,7 +205,7 @@ public class CreateEgressFirewallRuleCmd extends BaseAsyncCreateCmd implements F
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public long getEntityOwnerId() {
 | 
			
		||||
        Account account = UserContext.current().getCaller();
 | 
			
		||||
        Account account = CallContext.current().getCallingAccount();
 | 
			
		||||
 | 
			
		||||
        if (account != null) {
 | 
			
		||||
            return account.getId();
 | 
			
		||||
 | 
			
		||||
@ -29,6 +29,8 @@ import org.apache.cloudstack.api.Parameter;
 | 
			
		||||
import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.FirewallResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.IPAddressResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.event.EventTypes;
 | 
			
		||||
@ -38,7 +40,6 @@ import com.cloud.exception.ResourceUnavailableException;
 | 
			
		||||
import com.cloud.network.IpAddress;
 | 
			
		||||
import com.cloud.network.rules.FirewallRule;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
import com.cloud.utils.net.NetUtils;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "createFirewallRule", description = "Creates a firewall rule for a given ip address", responseObject = FirewallResponse.class)
 | 
			
		||||
@ -116,12 +117,12 @@ public class CreateFirewallRuleCmd extends BaseAsyncCreateCmd implements Firewal
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void execute() throws ResourceUnavailableException {
 | 
			
		||||
        UserContext callerContext = UserContext.current();
 | 
			
		||||
        CallContext callerContext = CallContext.current();
 | 
			
		||||
        boolean success = false;
 | 
			
		||||
        FirewallRule rule = _entityMgr.findById(FirewallRule.class, getEntityId());
 | 
			
		||||
        try {
 | 
			
		||||
            UserContext.current().setEventDetails("Rule Id: " + getEntityId());
 | 
			
		||||
            success = _firewallService.applyIngressFirewallRules(rule.getSourceIpAddressId(), callerContext.getCaller());
 | 
			
		||||
            CallContext.current().setEventDetails("Rule Id: " + getEntityId());
 | 
			
		||||
            success = _firewallService.applyIngressFirewallRules(rule.getSourceIpAddressId(), callerContext.getCallingAccount());
 | 
			
		||||
 | 
			
		||||
            // State is different after the rule is applied, so get new object here
 | 
			
		||||
            rule = _entityMgr.findById(FirewallRule.class, getEntityId());
 | 
			
		||||
@ -211,7 +212,7 @@ public class CreateFirewallRuleCmd extends BaseAsyncCreateCmd implements Firewal
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public long getEntityOwnerId() {
 | 
			
		||||
        Account account = UserContext.current().getCaller();
 | 
			
		||||
        Account account = CallContext.current().getCallingAccount();
 | 
			
		||||
 | 
			
		||||
        if (account != null) {
 | 
			
		||||
            return account.getId();
 | 
			
		||||
 | 
			
		||||
@ -30,6 +30,8 @@ import org.apache.cloudstack.api.response.FirewallRuleResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.IPAddressResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.NetworkResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.UserVmResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.event.EventTypes;
 | 
			
		||||
@ -39,7 +41,6 @@ import com.cloud.exception.ResourceUnavailableException;
 | 
			
		||||
import com.cloud.network.IpAddress;
 | 
			
		||||
import com.cloud.network.rules.PortForwardingRule;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
import com.cloud.utils.net.Ip;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "createPortForwardingRule", description = "Creates a port forwarding rule", responseObject = FirewallRuleResponse.class)
 | 
			
		||||
@ -171,17 +172,17 @@ public class CreatePortForwardingRuleCmd extends BaseAsyncCreateCmd implements P
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void execute() throws ResourceUnavailableException {
 | 
			
		||||
        UserContext callerContext = UserContext.current();
 | 
			
		||||
        CallContext callerContext = CallContext.current();
 | 
			
		||||
        boolean success = true;
 | 
			
		||||
        PortForwardingRule rule = null;
 | 
			
		||||
        try {
 | 
			
		||||
            UserContext.current().setEventDetails("Rule Id: " + getEntityId());
 | 
			
		||||
            CallContext.current().setEventDetails("Rule Id: " + getEntityId());
 | 
			
		||||
 | 
			
		||||
            if (getOpenFirewall()) {
 | 
			
		||||
                success = success && _firewallService.applyIngressFirewallRules(ipAddressId, callerContext.getCaller());
 | 
			
		||||
                success = success && _firewallService.applyIngressFirewallRules(ipAddressId, callerContext.getCallingAccount());
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            success = success && _rulesService.applyPortForwardingRules(ipAddressId, callerContext.getCaller());
 | 
			
		||||
            success = success && _rulesService.applyPortForwardingRules(ipAddressId, callerContext.getCallingAccount());
 | 
			
		||||
 | 
			
		||||
            // State is different after the rule is applied, so get new object here
 | 
			
		||||
            rule = _entityMgr.findById(PortForwardingRule.class, getEntityId());
 | 
			
		||||
@ -271,7 +272,7 @@ public class CreatePortForwardingRuleCmd extends BaseAsyncCreateCmd implements P
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public long getEntityOwnerId() {
 | 
			
		||||
        Account account = UserContext.current().getCaller();
 | 
			
		||||
        Account account = CallContext.current().getCallingAccount();
 | 
			
		||||
 | 
			
		||||
        if (account != null) {
 | 
			
		||||
            return account.getId();
 | 
			
		||||
 | 
			
		||||
@ -18,6 +18,7 @@
 | 
			
		||||
package org.apache.cloudstack.api.command.user.firewall;
 | 
			
		||||
 | 
			
		||||
import org.apache.cloudstack.api.APICommand;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import org.apache.cloudstack.api.ApiCommandJobType;
 | 
			
		||||
@ -30,12 +31,12 @@ import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.AccountResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.FirewallRuleResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.SuccessResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import com.cloud.event.EventTypes;
 | 
			
		||||
import com.cloud.exception.InvalidParameterValueException;
 | 
			
		||||
import com.cloud.exception.ResourceUnavailableException;
 | 
			
		||||
import com.cloud.network.rules.FirewallRule;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "deleteEgressFirewallRule", description="Deletes an ggress firewall rule", responseObject=SuccessResponse.class)
 | 
			
		||||
public class DeleteEgressFirewallRuleCmd extends BaseAsyncCmd {
 | 
			
		||||
@ -94,7 +95,7 @@ public class DeleteEgressFirewallRuleCmd extends BaseAsyncCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void execute() throws ResourceUnavailableException {
 | 
			
		||||
        UserContext.current().setEventDetails("Rule Id: " + id);
 | 
			
		||||
        CallContext.current().setEventDetails("Rule Id: " + id);
 | 
			
		||||
        boolean result = _firewallService.revokeFirewallRule(id, true);
 | 
			
		||||
 | 
			
		||||
        if (result) {
 | 
			
		||||
 | 
			
		||||
@ -26,13 +26,14 @@ import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.AccountResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.FirewallRuleResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.SuccessResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.event.EventTypes;
 | 
			
		||||
import com.cloud.exception.InvalidParameterValueException;
 | 
			
		||||
import com.cloud.exception.ResourceUnavailableException;
 | 
			
		||||
import com.cloud.network.rules.FirewallRule;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "deleteFirewallRule", description="Deletes a firewall rule", responseObject=SuccessResponse.class)
 | 
			
		||||
public class DeleteFirewallRuleCmd extends BaseAsyncCmd {
 | 
			
		||||
@ -92,7 +93,7 @@ public class DeleteFirewallRuleCmd extends BaseAsyncCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void execute() throws ResourceUnavailableException {
 | 
			
		||||
        UserContext.current().setEventDetails("Rule Id: " + id);
 | 
			
		||||
        CallContext.current().setEventDetails("Rule Id: " + id);
 | 
			
		||||
        boolean result = _firewallService.revokeFirewallRule(id, true);
 | 
			
		||||
 | 
			
		||||
        if (result) {
 | 
			
		||||
 | 
			
		||||
@ -26,12 +26,13 @@ import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.AccountResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.FirewallRuleResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.SuccessResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.event.EventTypes;
 | 
			
		||||
import com.cloud.exception.InvalidParameterValueException;
 | 
			
		||||
import com.cloud.network.rules.PortForwardingRule;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "deletePortForwardingRule", description="Deletes a port forwarding rule", responseObject=SuccessResponse.class)
 | 
			
		||||
public class DeletePortForwardingRuleCmd extends BaseAsyncCmd {
 | 
			
		||||
@ -92,7 +93,7 @@ public class DeletePortForwardingRuleCmd extends BaseAsyncCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void execute(){
 | 
			
		||||
        UserContext.current().setEventDetails("Rule Id: "+id);
 | 
			
		||||
        CallContext.current().setEventDetails("Rule Id: "+id);
 | 
			
		||||
        //revoke corresponding firewall rule first
 | 
			
		||||
        boolean result  = _firewallService.revokeRelatedFirewallRule(id, true);
 | 
			
		||||
        result = result &&  _rulesService.revokePortForwardingRule(id, true);
 | 
			
		||||
 | 
			
		||||
@ -25,11 +25,12 @@ import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.command.user.vm.DeployVMCmd;
 | 
			
		||||
import org.apache.cloudstack.api.response.TemplateResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.UserVmResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.event.EventTypes;
 | 
			
		||||
import com.cloud.exception.InvalidParameterValueException;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
import com.cloud.uservm.UserVm;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "attachIso", description="Attaches an ISO to a virtual machine.", responseObject=UserVmResponse.class)
 | 
			
		||||
@ -95,7 +96,7 @@ public class AttachIsoCmd extends BaseAsyncCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void execute(){
 | 
			
		||||
        UserContext.current().setEventDetails("Vm Id: " +getVirtualMachineId()+ " ISO Id: "+getId());
 | 
			
		||||
        CallContext.current().setEventDetails("Vm Id: " +getVirtualMachineId()+ " ISO Id: "+getId());
 | 
			
		||||
        boolean result = _templateService.attachIso(id, virtualMachineId);
 | 
			
		||||
        if (result) {
 | 
			
		||||
            UserVm userVm = _responseGenerator.findUserVmById(virtualMachineId);
 | 
			
		||||
 | 
			
		||||
@ -26,12 +26,13 @@ import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.SuccessResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.TemplateResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.ZoneResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.event.EventTypes;
 | 
			
		||||
import com.cloud.template.VirtualMachineTemplate;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "deleteIso", description="Deletes an ISO file.", responseObject=SuccessResponse.class)
 | 
			
		||||
public class DeleteIsoCmd extends BaseAsyncCmd {
 | 
			
		||||
@ -106,7 +107,7 @@ public class DeleteIsoCmd extends BaseAsyncCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void execute(){
 | 
			
		||||
        UserContext.current().setEventDetails("ISO Id: "+getId());
 | 
			
		||||
        CallContext.current().setEventDetails("ISO Id: "+getId());
 | 
			
		||||
        boolean result = _templateService.deleteIso(this);
 | 
			
		||||
        if (result) {
 | 
			
		||||
            SuccessResponse response = new SuccessResponse(getCommandName());
 | 
			
		||||
 | 
			
		||||
@ -26,13 +26,14 @@ import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.ExtractResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.TemplateResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.ZoneResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.event.EventTypes;
 | 
			
		||||
import com.cloud.exception.InternalErrorException;
 | 
			
		||||
import com.cloud.template.VirtualMachineTemplate;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
import com.cloud.utils.Pair;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "extractIso", description="Extracts an ISO", responseObject=ExtractResponse.class)
 | 
			
		||||
@ -123,7 +124,7 @@ public class ExtractIsoCmd extends BaseAsyncCmd {
 | 
			
		||||
    @Override
 | 
			
		||||
    public void execute(){
 | 
			
		||||
        try {
 | 
			
		||||
            UserContext.current().setEventDetails(getEventDescription());
 | 
			
		||||
            CallContext.current().setEventDetails(getEventDescription());
 | 
			
		||||
            String uploadUrl = _templateService.extract(this);
 | 
			
		||||
            if (uploadUrl != null) {
 | 
			
		||||
                ExtractResponse response = _responseGenerator.createExtractResponse(id, zoneId, getEntityOwnerId(), mode, uploadUrl);
 | 
			
		||||
 | 
			
		||||
@ -28,11 +28,12 @@ import org.apache.cloudstack.api.Parameter;
 | 
			
		||||
import org.apache.cloudstack.api.response.ListResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.TemplateResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.ZoneResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.template.VirtualMachineTemplate.TemplateFilter;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
import com.cloud.utils.Pair;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "listIsos", description="Lists all available ISO files.", responseObject=TemplateResponse.class)
 | 
			
		||||
@ -116,7 +117,7 @@ public class ListIsosCmd extends BaseListTaggedResourcesCmd {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public boolean listInReadyState() {
 | 
			
		||||
        Account account = UserContext.current().getCaller();
 | 
			
		||||
        Account account = CallContext.current().getCallingAccount();
 | 
			
		||||
        // It is account specific if account is admin type and domainId and accountName are not null
 | 
			
		||||
        boolean isAccountSpecific = (account == null || isAdmin(account.getType())) && (getAccountName() != null) && (getDomainId() != null);
 | 
			
		||||
        // Show only those that are downloaded.
 | 
			
		||||
 | 
			
		||||
@ -30,11 +30,12 @@ import org.apache.cloudstack.api.response.ListResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.ProjectResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.TemplateResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.ZoneResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.exception.ResourceAllocationException;
 | 
			
		||||
import com.cloud.template.VirtualMachineTemplate;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "registerIso", responseObject=TemplateResponse.class, description="Registers an existing ISO into the CloudStack Cloud.")
 | 
			
		||||
public class RegisterIsoCmd extends BaseCmd {
 | 
			
		||||
@ -169,7 +170,7 @@ public class RegisterIsoCmd extends BaseCmd {
 | 
			
		||||
    public long getEntityOwnerId() {
 | 
			
		||||
        Long accountId = finalyzeAccountId(accountName, domainId, projectId, true);
 | 
			
		||||
        if (accountId == null) {
 | 
			
		||||
            return UserContext.current().getCaller().getId();
 | 
			
		||||
            return CallContext.current().getCallingAccount().getId();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return accountId;
 | 
			
		||||
 | 
			
		||||
@ -27,13 +27,14 @@ import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.FirewallRuleResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.SuccessResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.UserVmResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.event.EventTypes;
 | 
			
		||||
import com.cloud.exception.InvalidParameterValueException;
 | 
			
		||||
import com.cloud.network.rules.LoadBalancer;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
import com.cloud.utils.StringUtils;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "assignToLoadBalancerRule", description="Assigns virtual machine or a list of virtual machines to a load balancer rule.", responseObject=SuccessResponse.class)
 | 
			
		||||
@ -96,7 +97,7 @@ public class AssignToLoadBalancerRuleCmd extends BaseAsyncCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void execute(){
 | 
			
		||||
        UserContext.current().setEventDetails("Load balancer Id: "+getLoadBalancerId()+" VmIds: "+StringUtils.join(getVirtualMachineIds(), ","));
 | 
			
		||||
        CallContext.current().setEventDetails("Load balancer Id: "+getLoadBalancerId()+" VmIds: "+StringUtils.join(getVirtualMachineIds(), ","));
 | 
			
		||||
        boolean result = _lbService.assignToLoadBalancer(getLoadBalancerId(), virtualMachineIds);
 | 
			
		||||
        if (result) {
 | 
			
		||||
            SuccessResponse response = new SuccessResponse(getCommandName());
 | 
			
		||||
 | 
			
		||||
@ -25,7 +25,9 @@ import org.apache.cloudstack.api.Parameter;
 | 
			
		||||
import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.ApplicationLoadBalancerResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.NetworkResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
import org.apache.cloudstack.network.lb.ApplicationLoadBalancerRule;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.event.EventTypes;
 | 
			
		||||
@ -37,7 +39,6 @@ import com.cloud.exception.ResourceAllocationException;
 | 
			
		||||
import com.cloud.exception.ResourceUnavailableException;
 | 
			
		||||
import com.cloud.network.Network;
 | 
			
		||||
import com.cloud.network.rules.LoadBalancerContainer.Scheme;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
import com.cloud.utils.net.NetUtils;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "createLoadBalancer", description="Creates a Load Balancer", responseObject=ApplicationLoadBalancerResponse.class, since="4.2.0")
 | 
			
		||||
@ -180,7 +181,7 @@ public class CreateApplicationLoadBalancerCmd extends BaseAsyncCreateCmd {
 | 
			
		||||
    public void execute() throws ResourceAllocationException, ResourceUnavailableException {
 | 
			
		||||
        ApplicationLoadBalancerRule rule = null;
 | 
			
		||||
        try {
 | 
			
		||||
            UserContext.current().setEventDetails("Load Balancer Id: " + getEntityId());
 | 
			
		||||
            CallContext.current().setEventDetails("Load Balancer Id: " + getEntityId());
 | 
			
		||||
            // State might be different after the rule is applied, so get new object here
 | 
			
		||||
            rule = _entityMgr.findById(ApplicationLoadBalancerRule.class, getEntityId());
 | 
			
		||||
            ApplicationLoadBalancerResponse lbResponse = _responseGenerator.createLoadBalancerContainerReponse(rule, _lbService.getLbInstances(getEntityId()));
 | 
			
		||||
 | 
			
		||||
@ -18,6 +18,7 @@ package org.apache.cloudstack.api.command.user.loadbalancer;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
import org.apache.cloudstack.api.response.FirewallRuleResponse;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import org.apache.cloudstack.api.ApiConstants;
 | 
			
		||||
@ -26,15 +27,18 @@ import org.apache.cloudstack.api.BaseAsyncCreateCmd;
 | 
			
		||||
import org.apache.cloudstack.api.APICommand;
 | 
			
		||||
import org.apache.cloudstack.api.Parameter;
 | 
			
		||||
import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
 | 
			
		||||
import com.cloud.event.EventTypes;
 | 
			
		||||
import com.cloud.exception.InvalidParameterValueException;
 | 
			
		||||
import com.cloud.exception.ResourceAllocationException;
 | 
			
		||||
import com.cloud.exception.ResourceUnavailableException;
 | 
			
		||||
import com.cloud.network.rules.HealthCheckPolicy;
 | 
			
		||||
 | 
			
		||||
import org.apache.cloudstack.api.response.LBHealthCheckResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import com.cloud.network.rules.LoadBalancer;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "createLBHealthCheckPolicy", description = "Creates a Load Balancer healthcheck policy ", responseObject = LBHealthCheckResponse.class, since="4.2.0")
 | 
			
		||||
@ -97,7 +101,7 @@ public class CreateLBHealthCheckPolicyCmd extends BaseAsyncCreateCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public long getEntityOwnerId() {
 | 
			
		||||
        Account account = UserContext.current().getCaller();
 | 
			
		||||
        Account account = CallContext.current().getCallingAccount();
 | 
			
		||||
        if (account != null) {
 | 
			
		||||
            return account.getId();
 | 
			
		||||
        }
 | 
			
		||||
@ -127,7 +131,7 @@ public class CreateLBHealthCheckPolicyCmd extends BaseAsyncCreateCmd {
 | 
			
		||||
        boolean success = false;
 | 
			
		||||
 | 
			
		||||
        try {
 | 
			
		||||
            UserContext.current().setEventDetails("Load balancer healthcheck policy Id : " + getEntityId());
 | 
			
		||||
            CallContext.current().setEventDetails("Load balancer healthcheck policy Id : " + getEntityId());
 | 
			
		||||
            success = _lbService.applyLBHealthCheckPolicy(this);
 | 
			
		||||
            if (success) {
 | 
			
		||||
                // State might be different after the rule is applied, so get new object here
 | 
			
		||||
 | 
			
		||||
@ -27,6 +27,8 @@ import org.apache.cloudstack.api.Parameter;
 | 
			
		||||
import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.FirewallRuleResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.LBStickinessResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.event.EventTypes;
 | 
			
		||||
@ -36,7 +38,6 @@ import com.cloud.exception.ResourceUnavailableException;
 | 
			
		||||
import com.cloud.network.rules.LoadBalancer;
 | 
			
		||||
import com.cloud.network.rules.StickinessPolicy;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "createLBStickinessPolicy", description = "Creates a Load Balancer stickiness policy ", responseObject = LBStickinessResponse.class, since="3.0.0")
 | 
			
		||||
@ -103,7 +104,7 @@ public class CreateLBStickinessPolicyCmd extends BaseAsyncCreateCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public long getEntityOwnerId() {
 | 
			
		||||
        Account account = UserContext.current().getCaller();
 | 
			
		||||
        Account account = CallContext.current().getCallingAccount();
 | 
			
		||||
        if (account != null) {
 | 
			
		||||
            return account.getId();
 | 
			
		||||
        }
 | 
			
		||||
@ -117,7 +118,7 @@ public class CreateLBStickinessPolicyCmd extends BaseAsyncCreateCmd {
 | 
			
		||||
        boolean success = false;
 | 
			
		||||
 | 
			
		||||
        try {
 | 
			
		||||
            UserContext.current().setEventDetails("Rule Id: " + getEntityId());
 | 
			
		||||
            CallContext.current().setEventDetails("Rule Id: " + getEntityId());
 | 
			
		||||
            success = _lbService.applyLBStickinessPolicy(this);
 | 
			
		||||
            if (success) {
 | 
			
		||||
                // State might be different after the rule is applied, so get new object here
 | 
			
		||||
 | 
			
		||||
@ -30,6 +30,8 @@ import org.apache.cloudstack.api.response.IPAddressResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.LoadBalancerResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.NetworkResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.ZoneResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.dc.DataCenter;
 | 
			
		||||
@ -44,7 +46,6 @@ import com.cloud.network.IpAddress;
 | 
			
		||||
import com.cloud.network.Network;
 | 
			
		||||
import com.cloud.network.rules.LoadBalancer;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
import com.cloud.utils.net.NetUtils;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "createLoadBalancerRule", description="Creates a load balancer rule", responseObject=LoadBalancerResponse.class)
 | 
			
		||||
@ -237,14 +238,14 @@ public class CreateLoadBalancerRuleCmd extends BaseAsyncCreateCmd  /*implements
 | 
			
		||||
    @Override
 | 
			
		||||
    public void execute() throws ResourceAllocationException, ResourceUnavailableException {
 | 
			
		||||
 | 
			
		||||
        UserContext callerContext = UserContext.current();
 | 
			
		||||
        CallContext callerContext = CallContext.current();
 | 
			
		||||
        boolean success = true;
 | 
			
		||||
        LoadBalancer rule = null;
 | 
			
		||||
        try {
 | 
			
		||||
            UserContext.current().setEventDetails("Rule Id: " + getEntityId());
 | 
			
		||||
            CallContext.current().setEventDetails("Rule Id: " + getEntityId());
 | 
			
		||||
 | 
			
		||||
            if (getOpenFirewall()) {
 | 
			
		||||
                success = success && _firewallService.applyIngressFirewallRules(getSourceIpAddressId(), callerContext.getCaller());
 | 
			
		||||
                success = success && _firewallService.applyIngressFirewallRules(getSourceIpAddressId(), callerContext.getCallingAccount());
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            // State might be different after the rule is applied, so get new object here
 | 
			
		||||
@ -327,7 +328,7 @@ public class CreateLoadBalancerRuleCmd extends BaseAsyncCreateCmd  /*implements
 | 
			
		||||
        if (domainId != null) {
 | 
			
		||||
            return domainId;
 | 
			
		||||
        }
 | 
			
		||||
        return UserContext.current().getCaller().getDomainId();
 | 
			
		||||
        return CallContext.current().getCallingAccount().getDomainId();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public int getDefaultPortStart() {
 | 
			
		||||
 | 
			
		||||
@ -25,12 +25,13 @@ import org.apache.cloudstack.api.Parameter;
 | 
			
		||||
import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.FirewallRuleResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.SuccessResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
import org.apache.cloudstack.network.lb.ApplicationLoadBalancerRule;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.event.EventTypes;
 | 
			
		||||
import com.cloud.exception.InvalidParameterValueException;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "deleteLoadBalancer", description="Deletes a load balancer", responseObject=SuccessResponse.class, since="4.2.0")
 | 
			
		||||
public class DeleteApplicationLoadBalancerCmd extends BaseAsyncCmd {
 | 
			
		||||
@ -84,7 +85,7 @@ public class DeleteApplicationLoadBalancerCmd extends BaseAsyncCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void execute(){
 | 
			
		||||
        UserContext.current().setEventDetails("Load balancer Id: " + getId());
 | 
			
		||||
        CallContext.current().setEventDetails("Load balancer Id: " + getId());
 | 
			
		||||
        boolean result = _appLbService.deleteApplicationLoadBalancer(getId());
 | 
			
		||||
 | 
			
		||||
        if (result) {
 | 
			
		||||
 | 
			
		||||
@ -17,6 +17,7 @@
 | 
			
		||||
package org.apache.cloudstack.api.command.user.loadbalancer;
 | 
			
		||||
 | 
			
		||||
import org.apache.cloudstack.api.response.LBHealthCheckResponse;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import org.apache.cloudstack.api.ApiConstants;
 | 
			
		||||
@ -26,12 +27,13 @@ import org.apache.cloudstack.api.APICommand;
 | 
			
		||||
import org.apache.cloudstack.api.Parameter;
 | 
			
		||||
import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.SuccessResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import com.cloud.event.EventTypes;
 | 
			
		||||
import com.cloud.exception.InvalidParameterValueException;
 | 
			
		||||
import com.cloud.network.rules.HealthCheckPolicy;
 | 
			
		||||
import com.cloud.network.rules.LoadBalancer;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "deleteLBHealthCheckPolicy", description = "Deletes a load balancer HealthCheck policy.", responseObject = SuccessResponse.class, since="4.2.0")
 | 
			
		||||
public class DeleteLBHealthCheckPolicyCmd extends BaseAsyncCmd {
 | 
			
		||||
@ -64,7 +66,7 @@ public class DeleteLBHealthCheckPolicyCmd extends BaseAsyncCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public long getEntityOwnerId() {
 | 
			
		||||
        Account account = UserContext.current().getCaller();
 | 
			
		||||
        Account account = CallContext.current().getCallingAccount();
 | 
			
		||||
        if (account != null) {
 | 
			
		||||
            return account.getId();
 | 
			
		||||
        }
 | 
			
		||||
@ -84,7 +86,7 @@ public class DeleteLBHealthCheckPolicyCmd extends BaseAsyncCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void execute() {
 | 
			
		||||
        UserContext.current().setEventDetails("Load balancer healthcheck policy Id: " + getId());
 | 
			
		||||
        CallContext.current().setEventDetails("Load balancer healthcheck policy Id: " + getId());
 | 
			
		||||
        boolean result = _lbService.deleteLBHealthCheckPolicy(getId() , true);
 | 
			
		||||
 | 
			
		||||
        if (result) {
 | 
			
		||||
 | 
			
		||||
@ -24,6 +24,8 @@ import org.apache.cloudstack.api.Parameter;
 | 
			
		||||
import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.LBStickinessResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.SuccessResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.event.EventTypes;
 | 
			
		||||
@ -31,7 +33,6 @@ import com.cloud.exception.InvalidParameterValueException;
 | 
			
		||||
import com.cloud.network.rules.LoadBalancer;
 | 
			
		||||
import com.cloud.network.rules.StickinessPolicy;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "deleteLBStickinessPolicy", description = "Deletes a LB stickiness policy.", responseObject = SuccessResponse.class, since="3.0.0")
 | 
			
		||||
public class DeleteLBStickinessPolicyCmd extends BaseAsyncCmd {
 | 
			
		||||
@ -64,7 +65,7 @@ public class DeleteLBStickinessPolicyCmd extends BaseAsyncCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public long getEntityOwnerId() {
 | 
			
		||||
        Account account = UserContext.current().getCaller();
 | 
			
		||||
        Account account = CallContext.current().getCallingAccount();
 | 
			
		||||
        if (account != null) {
 | 
			
		||||
            return account.getId();
 | 
			
		||||
        }
 | 
			
		||||
@ -84,7 +85,7 @@ public class DeleteLBStickinessPolicyCmd extends BaseAsyncCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void execute() {
 | 
			
		||||
        UserContext.current().setEventDetails("Load balancer stickiness policy Id: " + getId());
 | 
			
		||||
        CallContext.current().setEventDetails("Load balancer stickiness policy Id: " + getId());
 | 
			
		||||
        boolean result = _lbService.deleteLBStickinessPolicy(getId(), true);
 | 
			
		||||
 | 
			
		||||
        if (result) {
 | 
			
		||||
 | 
			
		||||
@ -25,13 +25,14 @@ import org.apache.cloudstack.api.Parameter;
 | 
			
		||||
import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.FirewallRuleResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.SuccessResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.event.EventTypes;
 | 
			
		||||
import com.cloud.exception.InvalidParameterValueException;
 | 
			
		||||
import com.cloud.network.rules.LoadBalancer;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "deleteLoadBalancerRule", description="Deletes a load balancer rule.", responseObject=SuccessResponse.class)
 | 
			
		||||
public class DeleteLoadBalancerRuleCmd extends BaseAsyncCmd {
 | 
			
		||||
@ -85,7 +86,7 @@ public class DeleteLoadBalancerRuleCmd extends BaseAsyncCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void execute(){
 | 
			
		||||
        UserContext.current().setEventDetails("Load balancer Id: "+getId());
 | 
			
		||||
        CallContext.current().setEventDetails("Load balancer Id: "+getId());
 | 
			
		||||
        boolean result = _firewallService.revokeRelatedFirewallRule(id, true);
 | 
			
		||||
        result = result && _lbService.deleteLoadBalancerRule(id, true);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -21,6 +21,7 @@ import java.util.List;
 | 
			
		||||
 | 
			
		||||
import org.apache.cloudstack.api.APICommand;
 | 
			
		||||
import org.apache.cloudstack.api.response.FirewallRuleResponse;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import org.apache.cloudstack.api.ApiConstants;
 | 
			
		||||
@ -29,11 +30,11 @@ import org.apache.cloudstack.api.Parameter;
 | 
			
		||||
import org.apache.cloudstack.api.response.LBHealthCheckResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.LBStickinessResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.ListResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import com.cloud.network.rules.HealthCheckPolicy;
 | 
			
		||||
import com.cloud.network.rules.LoadBalancer;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "listLBHealthCheckPolicies", description = "Lists load balancer HealthCheck policies.", responseObject = LBHealthCheckResponse.class, since="4.2.0")
 | 
			
		||||
public class ListLBHealthCheckPoliciesCmd extends BaseListCmd {
 | 
			
		||||
 | 
			
		||||
@ -26,12 +26,13 @@ import org.apache.cloudstack.api.Parameter;
 | 
			
		||||
import org.apache.cloudstack.api.response.FirewallRuleResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.LBStickinessResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.ListResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.network.rules.LoadBalancer;
 | 
			
		||||
import com.cloud.network.rules.StickinessPolicy;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "listLBStickinessPolicies", description = "Lists LBStickiness policies.", responseObject = LBStickinessResponse.class, since="3.0.0")
 | 
			
		||||
public class ListLBStickinessPoliciesCmd extends BaseListCmd {
 | 
			
		||||
@ -71,7 +72,7 @@ public class ListLBStickinessPoliciesCmd extends BaseListCmd {
 | 
			
		||||
 | 
			
		||||
        if (lb != null) {
 | 
			
		||||
            //check permissions
 | 
			
		||||
            Account caller = UserContext.current().getCaller();
 | 
			
		||||
            Account caller = CallContext.current().getCallingAccount();
 | 
			
		||||
            _accountService.checkAccess(caller, null, true, lb);
 | 
			
		||||
            List<? extends StickinessPolicy> stickinessPolicies = _lbService.searchForLBStickinessPolicies(this);
 | 
			
		||||
            LBStickinessResponse spResponse = _responseGenerator.createLBStickinessPolicyResponse(stickinessPolicies, lb);
 | 
			
		||||
 | 
			
		||||
@ -27,13 +27,14 @@ import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.FirewallRuleResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.SuccessResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.UserVmResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.event.EventTypes;
 | 
			
		||||
import com.cloud.exception.InvalidParameterValueException;
 | 
			
		||||
import com.cloud.network.rules.LoadBalancer;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
import com.cloud.utils.StringUtils;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "removeFromLoadBalancerRule", description="Removes a virtual machine or a list of virtual machines from a load balancer rule.", responseObject=SuccessResponse.class)
 | 
			
		||||
@ -96,7 +97,7 @@ public class RemoveFromLoadBalancerRuleCmd extends BaseAsyncCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void execute(){
 | 
			
		||||
        UserContext.current().setEventDetails("Load balancer Id: "+getId()+" VmIds: "+StringUtils.join(getVirtualMachineIds(), ","));
 | 
			
		||||
        CallContext.current().setEventDetails("Load balancer Id: "+getId()+" VmIds: "+StringUtils.join(getVirtualMachineIds(), ","));
 | 
			
		||||
        boolean result = _lbService.removeFromLoadBalancer(id, virtualMachineIds);
 | 
			
		||||
        if (result) {
 | 
			
		||||
            SuccessResponse response = new SuccessResponse(getCommandName());
 | 
			
		||||
 | 
			
		||||
@ -24,12 +24,13 @@ import org.apache.cloudstack.api.Parameter;
 | 
			
		||||
import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.FirewallRuleResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.LoadBalancerResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.event.EventTypes;
 | 
			
		||||
import com.cloud.network.rules.LoadBalancer;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "updateLoadBalancerRule", description="Updates load balancer", responseObject=LoadBalancerResponse.class)
 | 
			
		||||
public class UpdateLoadBalancerRuleCmd extends BaseAsyncCmd {
 | 
			
		||||
@ -103,7 +104,7 @@ public class UpdateLoadBalancerRuleCmd extends BaseAsyncCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void execute(){
 | 
			
		||||
        UserContext.current().setEventDetails("Load balancer Id: "+getId());
 | 
			
		||||
        CallContext.current().setEventDetails("Load balancer Id: "+getId());
 | 
			
		||||
        LoadBalancer result = _lbService.updateLoadBalancerRule(this);
 | 
			
		||||
        if (result != null){
 | 
			
		||||
            LoadBalancerResponse response = _responseGenerator.createLoadBalancerResponse(result);
 | 
			
		||||
 | 
			
		||||
@ -29,6 +29,8 @@ import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.FirewallRuleResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.IPAddressResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.IpForwardingRuleResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.event.EventTypes;
 | 
			
		||||
@ -39,7 +41,6 @@ import com.cloud.network.IpAddress;
 | 
			
		||||
import com.cloud.network.rules.FirewallRule;
 | 
			
		||||
import com.cloud.network.rules.StaticNatRule;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "createIpForwardingRule", description="Creates an ip forwarding rule", responseObject=FirewallRuleResponse.class)
 | 
			
		||||
public class CreateIpForwardingRuleCmd extends BaseAsyncCreateCmd implements StaticNatRule {
 | 
			
		||||
@ -111,13 +112,13 @@ public class CreateIpForwardingRuleCmd extends BaseAsyncCreateCmd implements Sta
 | 
			
		||||
        boolean result = true;
 | 
			
		||||
        FirewallRule rule = null;
 | 
			
		||||
        try {
 | 
			
		||||
            UserContext.current().setEventDetails("Rule Id: "+ getEntityId());
 | 
			
		||||
            CallContext.current().setEventDetails("Rule Id: "+ getEntityId());
 | 
			
		||||
 | 
			
		||||
            if (getOpenFirewall()) {
 | 
			
		||||
                result = result && _firewallService.applyIngressFirewallRules(ipAddressId, UserContext.current().getCaller());
 | 
			
		||||
                result = result && _firewallService.applyIngressFirewallRules(ipAddressId, CallContext.current().getCallingAccount());
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            result = result && _rulesService.applyStaticNatRules(ipAddressId, UserContext.current().getCaller());
 | 
			
		||||
            result = result && _rulesService.applyStaticNatRules(ipAddressId, CallContext.current().getCallingAccount());
 | 
			
		||||
            rule = _entityMgr.findById(FirewallRule.class, getEntityId());
 | 
			
		||||
            StaticNatRule staticNatRule = _rulesService.buildStaticNatRule(rule, false);
 | 
			
		||||
            IpForwardingRuleResponse fwResponse = _responseGenerator.createIpForwardingRuleResponse(staticNatRule);
 | 
			
		||||
@ -157,7 +158,7 @@ public class CreateIpForwardingRuleCmd extends BaseAsyncCreateCmd implements Sta
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public long getEntityOwnerId() {
 | 
			
		||||
        Account account = UserContext.current().getCaller();
 | 
			
		||||
        Account account = CallContext.current().getCallingAccount();
 | 
			
		||||
 | 
			
		||||
        if (account != null) {
 | 
			
		||||
            return account.getId();
 | 
			
		||||
 | 
			
		||||
@ -26,12 +26,13 @@ import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.AccountResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.FirewallRuleResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.SuccessResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.event.EventTypes;
 | 
			
		||||
import com.cloud.exception.InvalidParameterValueException;
 | 
			
		||||
import com.cloud.network.rules.FirewallRule;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "deleteIpForwardingRule", description="Deletes an ip forwarding rule", responseObject=SuccessResponse.class)
 | 
			
		||||
public class DeleteIpForwardingRuleCmd extends BaseAsyncCmd {
 | 
			
		||||
@ -70,7 +71,7 @@ public class DeleteIpForwardingRuleCmd extends BaseAsyncCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void execute(){
 | 
			
		||||
        UserContext.current().setEventDetails("Rule Id: "+id);
 | 
			
		||||
        CallContext.current().setEventDetails("Rule Id: "+id);
 | 
			
		||||
        boolean result = _firewallService.revokeRelatedFirewallRule(id, true);
 | 
			
		||||
        result = result && _rulesService.revokeStaticNatRule(id, true);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -21,6 +21,7 @@ import java.util.List;
 | 
			
		||||
 | 
			
		||||
import com.cloud.network.vpc.NetworkACL;
 | 
			
		||||
import com.cloud.network.vpc.NetworkACLItem;
 | 
			
		||||
 | 
			
		||||
import org.apache.cloudstack.api.APICommand;
 | 
			
		||||
import org.apache.cloudstack.api.ApiConstants;
 | 
			
		||||
import org.apache.cloudstack.api.ApiErrorCode;
 | 
			
		||||
@ -31,6 +32,8 @@ import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.NetworkACLItemResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.NetworkACLResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.NetworkResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.commons.lang.StringUtils;
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
@ -42,7 +45,6 @@ import com.cloud.exception.ResourceUnavailableException;
 | 
			
		||||
import com.cloud.network.Network;
 | 
			
		||||
import com.cloud.network.vpc.Vpc;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
import com.cloud.utils.net.NetUtils;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "createNetworkACL", description = "Creates a ACL rule in the given network (the network has to belong to VPC)",
 | 
			
		||||
@ -171,7 +173,7 @@ public class CreateNetworkACLCmd extends BaseAsyncCreateCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public long getEntityOwnerId() {
 | 
			
		||||
        Account caller = UserContext.current().getCaller();
 | 
			
		||||
        Account caller = CallContext.current().getCallingAccount();
 | 
			
		||||
        return caller.getAccountId();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -220,7 +222,7 @@ public class CreateNetworkACLCmd extends BaseAsyncCreateCmd {
 | 
			
		||||
        boolean success = false;
 | 
			
		||||
        NetworkACLItem rule = _networkACLService.getNetworkACLItem(getEntityId());
 | 
			
		||||
        try {
 | 
			
		||||
            UserContext.current().setEventDetails("Rule Id: " + getEntityId());
 | 
			
		||||
            CallContext.current().setEventDetails("Rule Id: " + getEntityId());
 | 
			
		||||
            success = _networkACLService.applyNetworkACL(rule.getAclId());
 | 
			
		||||
 | 
			
		||||
            // State is different after the rule is applied, so get new object here
 | 
			
		||||
 | 
			
		||||
@ -22,7 +22,7 @@ import com.cloud.exception.ResourceUnavailableException;
 | 
			
		||||
import com.cloud.network.vpc.NetworkACL;
 | 
			
		||||
import com.cloud.network.vpc.Vpc;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.cloudstack.api.APICommand;
 | 
			
		||||
import org.apache.cloudstack.api.ApiConstants;
 | 
			
		||||
import org.apache.cloudstack.api.ApiErrorCode;
 | 
			
		||||
@ -31,6 +31,8 @@ import org.apache.cloudstack.api.Parameter;
 | 
			
		||||
import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.NetworkACLResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.VpcResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "createNetworkACLList", description = "Creates a Network ACL for the given VPC",
 | 
			
		||||
 | 
			
		||||
@ -23,6 +23,8 @@ import org.apache.cloudstack.api.BaseCmd;
 | 
			
		||||
import org.apache.cloudstack.api.Parameter;
 | 
			
		||||
import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.response.*;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.exception.ConcurrentOperationException;
 | 
			
		||||
@ -32,7 +34,6 @@ import com.cloud.exception.ResourceAllocationException;
 | 
			
		||||
import com.cloud.network.Network;
 | 
			
		||||
import com.cloud.network.Network.GuestType;
 | 
			
		||||
import com.cloud.offering.NetworkOffering;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "createNetwork", description="Creates a network", responseObject=NetworkResponse.class)
 | 
			
		||||
public class CreateNetworkCmd extends BaseCmd {
 | 
			
		||||
@ -274,7 +275,7 @@ public class CreateNetworkCmd extends BaseCmd {
 | 
			
		||||
    public long getEntityOwnerId() {
 | 
			
		||||
        Long accountId = finalyzeAccountId(accountName, domainId, projectId, true);
 | 
			
		||||
        if (accountId == null) {
 | 
			
		||||
            return UserContext.current().getCaller().getId();
 | 
			
		||||
            return CallContext.current().getCallingAccount().getId();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return accountId;
 | 
			
		||||
 | 
			
		||||
@ -18,6 +18,7 @@ package org.apache.cloudstack.api.command.user.network;
 | 
			
		||||
 | 
			
		||||
import com.cloud.network.vpc.NetworkACLItem;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
 | 
			
		||||
import org.apache.cloudstack.api.APICommand;
 | 
			
		||||
import org.apache.cloudstack.api.ApiConstants;
 | 
			
		||||
import org.apache.cloudstack.api.ApiErrorCode;
 | 
			
		||||
@ -28,6 +29,8 @@ import org.apache.cloudstack.api.response.AccountResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.FirewallRuleResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.NetworkACLItemResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.SuccessResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.async.AsyncJob;
 | 
			
		||||
@ -35,7 +38,6 @@ import com.cloud.event.EventTypes;
 | 
			
		||||
import com.cloud.exception.InvalidParameterValueException;
 | 
			
		||||
import com.cloud.exception.ResourceUnavailableException;
 | 
			
		||||
import com.cloud.network.rules.FirewallRule;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "deleteNetworkACL", description="Deletes a Network ACL", responseObject=SuccessResponse.class)
 | 
			
		||||
public class DeleteNetworkACLCmd extends BaseAsyncCmd {
 | 
			
		||||
@ -78,13 +80,13 @@ public class DeleteNetworkACLCmd extends BaseAsyncCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public long getEntityOwnerId() {
 | 
			
		||||
        Account caller = UserContext.current().getCaller();
 | 
			
		||||
        Account caller = CallContext.current().getCallingAccount();
 | 
			
		||||
        return caller.getAccountId();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void execute() throws ResourceUnavailableException {
 | 
			
		||||
        UserContext.current().setEventDetails("Network ACL Item Id: " + id);
 | 
			
		||||
        CallContext.current().setEventDetails("Network ACL Item Id: " + id);
 | 
			
		||||
        boolean result = _networkACLService.revokeNetworkACLItem(id);
 | 
			
		||||
 | 
			
		||||
        if (result) {
 | 
			
		||||
 | 
			
		||||
@ -24,12 +24,14 @@ import com.cloud.network.rules.FirewallRule;
 | 
			
		||||
import com.cloud.network.vpc.NetworkACL;
 | 
			
		||||
import com.cloud.network.vpc.Vpc;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.cloudstack.api.*;
 | 
			
		||||
import org.apache.cloudstack.api.response.AccountResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.FirewallRuleResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.NetworkACLResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.SuccessResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "deleteNetworkACLList", description="Deletes a Network ACL", responseObject=SuccessResponse.class)
 | 
			
		||||
@ -73,13 +75,13 @@ public class DeleteNetworkACLListCmd extends BaseAsyncCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public long getEntityOwnerId() {
 | 
			
		||||
        Account caller = UserContext.current().getCaller();
 | 
			
		||||
        Account caller = CallContext.current().getCallingAccount();
 | 
			
		||||
        return caller.getAccountId();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void execute() throws ResourceUnavailableException {
 | 
			
		||||
        UserContext.current().setEventDetails("Network ACL Id: " + id);
 | 
			
		||||
        CallContext.current().setEventDetails("Network ACL Id: " + id);
 | 
			
		||||
        boolean result = _networkACLService.deleteNetworkACL(id);
 | 
			
		||||
 | 
			
		||||
        if (result) {
 | 
			
		||||
 | 
			
		||||
@ -25,12 +25,13 @@ import org.apache.cloudstack.api.ServerApiException;
 | 
			
		||||
import org.apache.cloudstack.api.command.admin.network.DeleteNetworkOfferingCmd;
 | 
			
		||||
import org.apache.cloudstack.api.response.NetworkResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.SuccessResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import com.cloud.event.EventTypes;
 | 
			
		||||
import com.cloud.exception.InvalidParameterValueException;
 | 
			
		||||
import com.cloud.network.Network;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "deleteNetwork", description="Deletes a network", responseObject=SuccessResponse.class)
 | 
			
		||||
public class DeleteNetworkCmd extends BaseAsyncCmd{
 | 
			
		||||
@ -66,7 +67,7 @@ public class DeleteNetworkCmd extends BaseAsyncCmd{
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void execute(){
 | 
			
		||||
        UserContext.current().setEventDetails("Network Id: " + id);
 | 
			
		||||
        CallContext.current().setEventDetails("Network Id: " + id);
 | 
			
		||||
        boolean result = _networkService.deleteNetwork(id);
 | 
			
		||||
        if (result) {
 | 
			
		||||
            SuccessResponse response = new SuccessResponse(getCommandName());
 | 
			
		||||
 | 
			
		||||
@ -22,12 +22,14 @@ import com.cloud.exception.ResourceUnavailableException;
 | 
			
		||||
import com.cloud.network.vpc.NetworkACL;
 | 
			
		||||
import com.cloud.network.vpc.Vpc;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.cloudstack.api.*;
 | 
			
		||||
import org.apache.cloudstack.api.response.NetworkACLResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.NetworkResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.PrivateGatewayResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.SuccessResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
@APICommand(name = "replaceNetworkACLList", description="Replaces ACL associated with a Network or private gateway", responseObject=SuccessResponse.class)
 | 
			
		||||
@ -87,7 +89,7 @@ public class ReplaceNetworkACLListCmd extends BaseAsyncCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public long getEntityOwnerId() {
 | 
			
		||||
        Account caller = UserContext.current().getCaller();
 | 
			
		||||
        Account caller = CallContext.current().getCallingAccount();
 | 
			
		||||
        return caller.getAccountId();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -101,7 +103,7 @@ public class ReplaceNetworkACLListCmd extends BaseAsyncCmd {
 | 
			
		||||
            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Network id and private gateway can't be passed  at  the same time");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        UserContext.current().setEventDetails("Network ACL Id: " + aclId);
 | 
			
		||||
        CallContext.current().setEventDetails("Network ACL Id: " + aclId);
 | 
			
		||||
        boolean result = false;
 | 
			
		||||
        if (getPrivateGatewayId() != null) {
 | 
			
		||||
            result = _networkACLService.replaceNetworkACLonPrivateGw(aclId, privateGatewayId);
 | 
			
		||||
 | 
			
		||||
@ -21,12 +21,14 @@ import com.cloud.exception.InvalidParameterValueException;
 | 
			
		||||
import com.cloud.exception.ResourceUnavailableException;
 | 
			
		||||
import com.cloud.network.vpc.NetworkACLItem;
 | 
			
		||||
import com.cloud.user.Account;
 | 
			
		||||
import com.cloud.user.UserContext;
 | 
			
		||||
import com.cloud.utils.net.NetUtils;
 | 
			
		||||
 | 
			
		||||
import org.apache.cloudstack.api.*;
 | 
			
		||||
import org.apache.cloudstack.api.response.NetworkACLItemResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.NetworkACLResponse;
 | 
			
		||||
import org.apache.cloudstack.api.response.NetworkResponse;
 | 
			
		||||
import org.apache.cloudstack.context.CallContext;
 | 
			
		||||
 | 
			
		||||
import org.apache.log4j.Logger;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
@ -134,7 +136,7 @@ public class UpdateNetworkACLItemCmd extends BaseAsyncCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public long getEntityOwnerId() {
 | 
			
		||||
        Account caller = UserContext.current().getCaller();
 | 
			
		||||
        Account caller = CallContext.current().getCallingAccount();
 | 
			
		||||
        return caller.getAccountId();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -158,7 +160,7 @@ public class UpdateNetworkACLItemCmd extends BaseAsyncCmd {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void execute() throws ResourceUnavailableException {
 | 
			
		||||
        UserContext.current().setEventDetails("Rule Id: " + getId());
 | 
			
		||||
        CallContext.current().setEventDetails("Rule Id: " + getId());
 | 
			
		||||
        NetworkACLItem aclItem = _networkACLService.updateNetworkACLItem(getId(), getProtocol(), getSourceCidrList(), getTrafficType(),
 | 
			
		||||
                getAction(), getNumber(), getSourcePortStart(), getSourcePortEnd(), getIcmpCode(), getIcmpType());
 | 
			
		||||
        if (aclItem == null) {
 | 
			
		||||
 | 
			
		||||
Some files were not shown because too many files have changed in this diff Show More
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user