CLOUDSTACK-4285: configure simulator API not discovered

- ManagementServerSimulatorImpl is not injected by default context.
configureSimulatorCmd API was loaded as part of it. Use
SimulatorManagerImpl as PluggableService to inject configureSimulator
API.
- Remove unused ManagementServerSimulatorImpl.
- Rename ConfigureSimulator to ConfigureSimulatorCmd for uniformity with
  all API Cmds

Signed-off-by: Prasanna Santhanam <tsp@apache.org>
(cherry picked from commit 0c294a50a8a926580ca724dee137488ea6242bf7)
This commit is contained in:
Prasanna Santhanam 2013-08-13 17:59:45 +05:30
parent b4464d88d3
commit 9cc74429bd
4 changed files with 23 additions and 43 deletions

View File

@ -16,4 +16,4 @@
# under the License.
configureSimulator=com.cloud.api.commands.ConfigureSimulator;1
configureSimulator=com.cloud.api.commands.ConfigureSimulatorCmd;1

View File

@ -86,6 +86,7 @@ import com.cloud.agent.api.storage.DestroyCommand;
import com.cloud.agent.api.storage.ListTemplateCommand;
import com.cloud.agent.api.storage.ListVolumeCommand;
import com.cloud.agent.api.storage.PrimaryStorageDownloadCommand;
import com.cloud.api.commands.ConfigureSimulatorCmd;
import com.cloud.resource.SimulatorStorageProcessor;
import com.cloud.simulator.MockConfigurationVO;
import com.cloud.simulator.MockHost;
@ -96,6 +97,7 @@ import com.cloud.storage.resource.StorageSubsystemCommandHandler;
import com.cloud.storage.resource.StorageSubsystemCommandHandlerBase;
import com.cloud.utils.Pair;
import com.cloud.utils.component.ManagerBase;
import com.cloud.utils.component.PluggableService;
import com.cloud.utils.db.DB;
import com.cloud.utils.db.Transaction;
import com.cloud.utils.exception.CloudRuntimeException;
@ -110,12 +112,14 @@ import org.springframework.stereotype.Component;
import javax.ejb.Local;
import javax.inject.Inject;
import javax.naming.ConfigurationException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Component
@Local(value = { SimulatorManager.class })
public class SimulatorManagerImpl extends ManagerBase implements SimulatorManager {
public class SimulatorManagerImpl extends ManagerBase implements SimulatorManager, PluggableService {
private static final Logger s_logger = Logger.getLogger(SimulatorManagerImpl.class);
@Inject
MockVmManager _mockVmMgr;
@ -168,6 +172,13 @@ public class SimulatorManagerImpl extends ManagerBase implements SimulatorManage
return _mockAgentMgr;
}
@Override
public List<Class<?>> getCommands() {
List<Class<?>> cmdList = new ArrayList<Class<?>>();
cmdList.add(ConfigureSimulatorCmd.class);
return cmdList;
}
@DB
@Override
public Answer simulate(Command cmd, String hostGuid) {

View File

@ -16,8 +16,12 @@
// under the License.
package com.cloud.api.commands;
import javax.inject.Inject;
import com.cloud.agent.manager.SimulatorManager;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.user.Account;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
@ -27,17 +31,12 @@ import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.SuccessResponse;
import org.apache.log4j.Logger;
import com.cloud.agent.manager.SimulatorManager;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.user.Account;
import javax.inject.Inject;
@APICommand(name = "configureSimulator", description="configure simulator", responseObject=SuccessResponse.class)
public class ConfigureSimulator extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(ConfigureSimulator.class.getName());
public class ConfigureSimulatorCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(ConfigureSimulatorCmd.class.getName());
private static final String s_name = "configuresimulatorresponse";
@Inject SimulatorManager _simMgr;
@ -81,4 +80,5 @@ public class ConfigureSimulator extends BaseCmd {
return Account.ACCOUNT_ID_SYSTEM;
}
}

View File

@ -1,31 +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.server;
import java.util.List;
import com.cloud.api.commands.ConfigureSimulator;
public class ManagementServerSimulatorImpl extends ManagementServerImpl {
@Override
public List<Class<?>> getCommands() {
List<Class<?>> cmdList = super.getCommands();
cmdList.add(ConfigureSimulator.class);
return cmdList;
}
}