You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by bf...@apache.org on 2012/12/27 22:48:17 UTC
[13/32] Simulator: moving hypervisor simulator into plugin
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d6083ce5/agent-simulator/src/com/cloud/agent/manager/SimulatorManagerImpl.java
----------------------------------------------------------------------
diff --git a/agent-simulator/src/com/cloud/agent/manager/SimulatorManagerImpl.java b/agent-simulator/src/com/cloud/agent/manager/SimulatorManagerImpl.java
deleted file mode 100644
index 9a81ea6..0000000
--- a/agent-simulator/src/com/cloud/agent/manager/SimulatorManagerImpl.java
+++ /dev/null
@@ -1,336 +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.agent.manager;
-
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.ejb.Local;
-import javax.naming.ConfigurationException;
-
-import com.cloud.agent.api.*;
-import org.apache.log4j.Logger;
-
-import com.cloud.agent.api.check.CheckSshCommand;
-import com.cloud.agent.api.proxy.CheckConsoleProxyLoadCommand;
-import com.cloud.agent.api.proxy.WatchConsoleProxyLoadCommand;
-import com.cloud.agent.api.routing.DhcpEntryCommand;
-import com.cloud.agent.api.routing.IpAssocCommand;
-import com.cloud.agent.api.routing.LoadBalancerConfigCommand;
-import com.cloud.agent.api.routing.SavePasswordCommand;
-import com.cloud.agent.api.routing.SetFirewallRulesCommand;
-import com.cloud.agent.api.routing.SetPortForwardingRulesCommand;
-import com.cloud.agent.api.routing.SetStaticNatRulesCommand;
-import com.cloud.agent.api.routing.VmDataCommand;
-import com.cloud.agent.api.storage.CopyVolumeCommand;
-import com.cloud.agent.api.storage.CreateCommand;
-import com.cloud.agent.api.storage.DeleteTemplateCommand;
-import com.cloud.agent.api.storage.DestroyCommand;
-import com.cloud.agent.api.storage.DownloadCommand;
-import com.cloud.agent.api.storage.DownloadProgressCommand;
-import com.cloud.agent.api.storage.ListTemplateCommand;
-import com.cloud.agent.api.storage.PrimaryStorageDownloadCommand;
-import com.cloud.simulator.MockConfigurationVO;
-import com.cloud.simulator.MockHost;
-import com.cloud.simulator.MockVMVO;
-import com.cloud.simulator.dao.MockConfigurationDao;
-import com.cloud.simulator.dao.MockHostDao;
-import com.cloud.utils.Pair;
-import com.cloud.utils.component.Inject;
-import com.cloud.utils.db.ConnectionConcierge;
-import com.cloud.utils.db.DB;
-import com.cloud.utils.db.Transaction;
-import com.cloud.utils.exception.CloudRuntimeException;
-import com.cloud.vm.VirtualMachine.State;
-@Local(value = { SimulatorManager.class })
-public class SimulatorManagerImpl implements SimulatorManager {
- private static final Logger s_logger = Logger.getLogger(SimulatorManagerImpl.class);
- @Inject
- MockVmManager _mockVmMgr = null;
- @Inject
- MockStorageManager _mockStorageMgr = null;
- @Inject
- MockAgentManager _mockAgentMgr = null;
- @Inject
- MockConfigurationDao _mockConfigDao = null;
- @Inject
- MockHostDao _mockHost = null;
- private ConnectionConcierge _concierge;
- @Override
- public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
- /*
- try {
- Connection conn = Transaction.getStandaloneSimulatorConnection();
- conn.setAutoCommit(true);
- _concierge = new ConnectionConcierge("SimulatorConnection", conn, true);
- } catch (SQLException e) {
- throw new CloudRuntimeException("Unable to get a db connection to simulator", e);
- }
- */
- return true;
- }
-
- @Override
- public boolean start() {
- return true;
- }
-
- @Override
- public boolean stop() {
- return true;
- }
-
- @Override
- public String getName() {
- return this.getClass().getSimpleName();
- }
-
- @Override
- public MockVmManager getVmMgr() {
- return _mockVmMgr;
- }
-
- @Override
- public MockStorageManager getStorageMgr() {
- return _mockStorageMgr;
- }
-
- @Override
- public MockAgentManager getAgentMgr() {
- return _mockAgentMgr;
- }
-
- @DB
- @Override
- public Answer simulate(Command cmd, String hostGuid) {
- Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
- // txn.transitToUserManagedConnection(_concierge.conn());
-
- try {
- MockHost host = _mockHost.findByGuid(hostGuid);
- String cmdName = cmd.toString();
- int index = cmdName.lastIndexOf(".");
- if (index != -1) {
- cmdName = cmdName.substring(index + 1);
- }
- MockConfigurationVO config = _mockConfigDao.findByNameBottomUP(host.getDataCenterId(), host.getPodId(), host.getClusterId(), host.getId(), cmdName);
-
- SimulatorInfo info = new SimulatorInfo();
- info.setHostUuid(hostGuid);
-
- if (config != null) {
- Map<String, String> configParameters = config.getParameters();
- for (Map.Entry<String, String> entry : configParameters.entrySet()) {
- if (entry.getKey().equalsIgnoreCase("enabled")) {
- info.setEnabled(Boolean.parseBoolean(entry.getValue()));
- } else if (entry.getKey().equalsIgnoreCase("timeout")) {
- try {
- info.setTimeout(Integer.valueOf(entry.getValue()));
- } catch (NumberFormatException e) {
- s_logger.debug("invalid timeout parameter: " + e.toString());
- }
- } else if (entry.getKey().equalsIgnoreCase("wait")) {
- try {
- int wait = Integer.valueOf(entry.getValue());
- Thread.sleep(wait * 1000);
- } catch (NumberFormatException e) {
- s_logger.debug("invalid timeout parameter: " + e.toString());
- } catch (InterruptedException e) {
- s_logger.debug("thread is interrupted: " + e.toString());
- }
- }
- }
- }
-
- if (cmd instanceof GetHostStatsCommand) {
- return _mockAgentMgr.getHostStatistic((GetHostStatsCommand)cmd);
- } else if (cmd instanceof CheckHealthCommand) {
- return _mockAgentMgr.checkHealth((CheckHealthCommand)cmd);
- } else if (cmd instanceof PingTestCommand) {
- return _mockAgentMgr.pingTest((PingTestCommand)cmd);
- } else if (cmd instanceof PrepareForMigrationCommand) {
- return _mockAgentMgr.prepareForMigrate((PrepareForMigrationCommand)cmd);
- } else if (cmd instanceof MigrateCommand) {
- return _mockVmMgr.Migrate((MigrateCommand)cmd, info);
- } else if (cmd instanceof StartCommand) {
- return _mockVmMgr.startVM((StartCommand)cmd, info);
- } else if (cmd instanceof CheckSshCommand) {
- return _mockVmMgr.checkSshCommand((CheckSshCommand)cmd);
- } else if (cmd instanceof CheckVirtualMachineCommand) {
- return _mockVmMgr.checkVmState((CheckVirtualMachineCommand)cmd);
- } else if (cmd instanceof SetStaticNatRulesCommand) {
- return _mockVmMgr.SetStaticNatRules((SetStaticNatRulesCommand)cmd);
- } else if (cmd instanceof SetFirewallRulesCommand) {
- return _mockVmMgr.SetFirewallRules((SetFirewallRulesCommand)cmd);
- } else if (cmd instanceof SetPortForwardingRulesCommand) {
- return _mockVmMgr.SetPortForwardingRules((SetPortForwardingRulesCommand)cmd);
- } else if (cmd instanceof NetworkUsageCommand) {
- return _mockVmMgr.getNetworkUsage((NetworkUsageCommand)cmd);
- } else if (cmd instanceof IpAssocCommand) {
- return _mockVmMgr.IpAssoc((IpAssocCommand)cmd);
- } else if (cmd instanceof LoadBalancerConfigCommand) {
- return _mockVmMgr.LoadBalancerConfig((LoadBalancerConfigCommand)cmd);
- } else if (cmd instanceof DhcpEntryCommand) {
- return _mockVmMgr.AddDhcpEntry((DhcpEntryCommand)cmd);
- } else if (cmd instanceof VmDataCommand) {
- return _mockVmMgr.setVmData((VmDataCommand)cmd);
- } else if (cmd instanceof CleanupNetworkRulesCmd) {
- return _mockVmMgr.CleanupNetworkRules((CleanupNetworkRulesCmd)cmd, info);
- } else if (cmd instanceof CheckNetworkCommand) {
- return _mockAgentMgr.checkNetworkCommand((CheckNetworkCommand) cmd);
- }else if (cmd instanceof StopCommand) {
- return _mockVmMgr.stopVM((StopCommand)cmd);
- } else if (cmd instanceof RebootCommand) {
- return _mockVmMgr.rebootVM((RebootCommand)cmd);
- } else if (cmd instanceof GetVncPortCommand) {
- return _mockVmMgr.getVncPort((GetVncPortCommand)cmd);
- } else if (cmd instanceof CheckConsoleProxyLoadCommand) {
- return _mockVmMgr.CheckConsoleProxyLoad((CheckConsoleProxyLoadCommand)cmd);
- } else if (cmd instanceof WatchConsoleProxyLoadCommand) {
- return _mockVmMgr.WatchConsoleProxyLoad((WatchConsoleProxyLoadCommand)cmd);
- } else if (cmd instanceof SecurityGroupRulesCmd) {
- return _mockVmMgr.AddSecurityGroupRules((SecurityGroupRulesCmd)cmd, info);
- } else if (cmd instanceof SavePasswordCommand) {
- return _mockVmMgr.SavePassword((SavePasswordCommand)cmd);
- } else if (cmd instanceof PrimaryStorageDownloadCommand) {
- return _mockStorageMgr.primaryStorageDownload((PrimaryStorageDownloadCommand)cmd);
- } else if (cmd instanceof CreateCommand) {
- return _mockStorageMgr.createVolume((CreateCommand)cmd);
- } else if (cmd instanceof AttachVolumeCommand) {
- return _mockStorageMgr.AttachVolume((AttachVolumeCommand)cmd);
- } else if (cmd instanceof AttachIsoCommand) {
- return _mockStorageMgr.AttachIso((AttachIsoCommand)cmd);
- } else if (cmd instanceof DeleteStoragePoolCommand) {
- return _mockStorageMgr.DeleteStoragePool((DeleteStoragePoolCommand)cmd);
- } else if (cmd instanceof ModifyStoragePoolCommand) {
- return _mockStorageMgr.ModifyStoragePool((ModifyStoragePoolCommand)cmd);
- } else if (cmd instanceof CreateStoragePoolCommand) {
- return _mockStorageMgr.CreateStoragePool((CreateStoragePoolCommand)cmd);
- } else if (cmd instanceof SecStorageSetupCommand) {
- return _mockStorageMgr.SecStorageSetup((SecStorageSetupCommand)cmd);
- } else if (cmd instanceof ListTemplateCommand) {
- return _mockStorageMgr.ListTemplates((ListTemplateCommand)cmd);
- } else if (cmd instanceof DestroyCommand) {
- return _mockStorageMgr.Destroy((DestroyCommand)cmd);
- } else if (cmd instanceof DownloadProgressCommand) {
- return _mockStorageMgr.DownloadProcess((DownloadProgressCommand)cmd);
- } else if (cmd instanceof DownloadCommand) {
- return _mockStorageMgr.Download((DownloadCommand)cmd);
- } else if (cmd instanceof GetStorageStatsCommand) {
- return _mockStorageMgr.GetStorageStats((GetStorageStatsCommand)cmd);
- } else if (cmd instanceof ManageSnapshotCommand) {
- return _mockStorageMgr.ManageSnapshot((ManageSnapshotCommand)cmd);
- } else if (cmd instanceof BackupSnapshotCommand) {
- return _mockStorageMgr.BackupSnapshot((BackupSnapshotCommand)cmd, info);
- } else if (cmd instanceof DeleteSnapshotBackupCommand) {
- return _mockStorageMgr.DeleteSnapshotBackup((DeleteSnapshotBackupCommand)cmd);
- } else if (cmd instanceof CreateVolumeFromSnapshotCommand) {
- return _mockStorageMgr.CreateVolumeFromSnapshot((CreateVolumeFromSnapshotCommand)cmd);
- } else if (cmd instanceof DeleteTemplateCommand) {
- return _mockStorageMgr.DeleteTemplate((DeleteTemplateCommand)cmd);
- } else if (cmd instanceof SecStorageVMSetupCommand) {
- return _mockStorageMgr.SecStorageVMSetup((SecStorageVMSetupCommand)cmd);
- } else if (cmd instanceof CreatePrivateTemplateFromSnapshotCommand) {
- return _mockStorageMgr.CreatePrivateTemplateFromSnapshot((CreatePrivateTemplateFromSnapshotCommand)cmd);
- } else if (cmd instanceof ComputeChecksumCommand) {
- return _mockStorageMgr.ComputeChecksum((ComputeChecksumCommand)cmd);
- } else if (cmd instanceof CreatePrivateTemplateFromVolumeCommand) {
- return _mockStorageMgr.CreatePrivateTemplateFromVolume((CreatePrivateTemplateFromVolumeCommand)cmd);
- } else if (cmd instanceof MaintainCommand) {
- return _mockAgentMgr.maintain((MaintainCommand)cmd);
- } else if (cmd instanceof GetVmStatsCommand) {
- return _mockVmMgr.getVmStats((GetVmStatsCommand)cmd);
- } else if (cmd instanceof CheckRouterCommand) {
- return _mockVmMgr.checkRouter((CheckRouterCommand) cmd);
- } else if (cmd instanceof BumpUpPriorityCommand) {
- return _mockVmMgr.bumpPriority((BumpUpPriorityCommand) cmd);
- } else if (cmd instanceof GetDomRVersionCmd) {
- return _mockVmMgr.getDomRVersion((GetDomRVersionCmd) cmd);
- } else if (cmd instanceof ClusterSyncCommand) {
- return new Answer(cmd);
- //return new ClusterSyncAnswer(((ClusterSyncCommand) cmd).getClusterId(), this.getVmStates(hostGuid));
- } else if (cmd instanceof CopyVolumeCommand) {
- return _mockStorageMgr.CopyVolume((CopyVolumeCommand) cmd);
- } else {
- return Answer.createUnsupportedCommandAnswer(cmd);
- }
- } catch(Exception e) {
- s_logger.error("Failed execute cmd: " + e.toString());
- txn.rollback();
- return new Answer(cmd, false, e.toString());
- } finally {
- txn.close();
- txn = Transaction.open(Transaction.CLOUD_DB);
- txn.close();
- }
- }
-
- @Override
- public StoragePoolInfo getLocalStorage(String hostGuid) {
- return _mockStorageMgr.getLocalStorage(hostGuid);
- }
-
- @Override
- public Map<String, State> getVmStates(String hostGuid) {
- return _mockVmMgr.getVmStates(hostGuid);
- }
-
- @Override
- public Map<String, MockVMVO> getVms(String hostGuid) {
- return _mockVmMgr.getVms(hostGuid);
- }
-
- @Override
- public HashMap<String, Pair<Long, Long>> syncNetworkGroups(String hostGuid) {
- SimulatorInfo info = new SimulatorInfo();
- info.setHostUuid(hostGuid);
- return _mockVmMgr.syncNetworkGroups(info);
- }
-
- @Override
- public boolean configureSimulator(Long zoneId, Long podId, Long clusterId, Long hostId, String command,
- String values) {
- Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
- try {
- txn.start();
- MockConfigurationVO config = _mockConfigDao.findByCommand(zoneId, podId, clusterId, hostId, command);
- if (config == null) {
- config = new MockConfigurationVO();
- config.setClusterId(clusterId);
- config.setDataCenterId(zoneId);
- config.setPodId(podId);
- config.setHostId(hostId);
- config.setName(command);
- config.setValues(values);
- _mockConfigDao.persist(config);
- txn.commit();
- } else {
- config.setValues(values);
- _mockConfigDao.update(config.getId(), config);
- txn.commit();
- }
- } catch (Exception ex) {
- txn.rollback();
- throw new CloudRuntimeException("Unable to configure simulator because of " + ex.getMessage(), ex);
- } finally {
- txn.close();
- }
- return true;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d6083ce5/agent-simulator/src/com/cloud/api/commands/ConfigureSimulator.java
----------------------------------------------------------------------
diff --git a/agent-simulator/src/com/cloud/api/commands/ConfigureSimulator.java b/agent-simulator/src/com/cloud/api/commands/ConfigureSimulator.java
deleted file mode 100755
index 4147e3a..0000000
--- a/agent-simulator/src/com/cloud/api/commands/ConfigureSimulator.java
+++ /dev/null
@@ -1,82 +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.api.commands;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.agent.manager.SimulatorManager;
-import com.cloud.api.ApiConstants;
-import com.cloud.api.BaseCmd;
-import com.cloud.api.Implementation;
-import com.cloud.api.Parameter;
-import com.cloud.api.ServerApiException;
-import com.cloud.api.response.SuccessResponse;
-import com.cloud.exception.ConcurrentOperationException;
-import com.cloud.exception.InsufficientCapacityException;
-import com.cloud.exception.ResourceAllocationException;
-import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.server.ManagementService;
-import com.cloud.user.Account;
-import com.cloud.utils.component.ComponentLocator;
-
-@Implementation(description="configure simulator", responseObject=SuccessResponse.class)
-public class ConfigureSimulator extends BaseCmd {
- public static final Logger s_logger = Logger.getLogger(ConfigureSimulator.class.getName());
- private static final String s_name = "configuresimulatorresponse";
-
- @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, description="configure range: in a zone")
- private Long zoneId;
-
- @Parameter(name=ApiConstants.POD_ID, type=CommandType.LONG, description="configure range: in a pod")
- private Long podId;
-
- @Parameter(name=ApiConstants.CLUSTER_ID, type=CommandType.LONG, description="configure range: in a cluster")
- private Long clusterId;
-
- @Parameter(name=ApiConstants.HOST_ID, type=CommandType.LONG, description="configure range: in a host")
- private Long hostId;
-
- @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, required=true, description="which command needs to be configured")
- private String command;
-
- @Parameter(name=ApiConstants.VALUE, type=CommandType.STRING, required=true, description="configuration options for this command, which is seperated by ;")
- private String values;
-
- @Override
- public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
- ComponentLocator locator = ComponentLocator.getLocator(ManagementService.Name);
- SimulatorManager _simMgr = locator.getManager(SimulatorManager.class);
- boolean result = _simMgr.configureSimulator(zoneId, podId, clusterId, hostId, command, values);
- if (!result) {
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to configure simulator");
- }
-
- SuccessResponse response = new SuccessResponse(getCommandName());
- this.setResponseObject(response);
- }
-
- @Override
- public String getCommandName() {
- return s_name;
- }
-
- @Override
- public long getEntityOwnerId() {
- return Account.ACCOUNT_ID_SYSTEM;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d6083ce5/agent-simulator/src/com/cloud/configuration/SimulatorComponentLibrary.java
----------------------------------------------------------------------
diff --git a/agent-simulator/src/com/cloud/configuration/SimulatorComponentLibrary.java b/agent-simulator/src/com/cloud/configuration/SimulatorComponentLibrary.java
deleted file mode 100644
index 9fd5258..0000000
--- a/agent-simulator/src/com/cloud/configuration/SimulatorComponentLibrary.java
+++ /dev/null
@@ -1,50 +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.configuration;
-
-import com.cloud.agent.manager.MockAgentManagerImpl;
-import com.cloud.agent.manager.MockStorageManagerImpl;
-import com.cloud.agent.manager.MockVmManagerImpl;
-import com.cloud.agent.manager.SimulatorManagerImpl;
-import com.cloud.simulator.dao.MockConfigurationDaoImpl;
-import com.cloud.simulator.dao.MockHostDaoImpl;
-import com.cloud.simulator.dao.MockSecStorageDaoImpl;
-import com.cloud.simulator.dao.MockSecurityRulesDaoImpl;
-import com.cloud.simulator.dao.MockStoragePoolDaoImpl;
-import com.cloud.simulator.dao.MockVMDaoImpl;
-import com.cloud.simulator.dao.MockVolumeDaoImpl;
-
-public class SimulatorComponentLibrary extends PremiumComponentLibrary {
- @Override
- protected void populateManagers() {
- addManager("VM Manager", MockVmManagerImpl.class);
- addManager("agent manager", MockAgentManagerImpl.class);
- addManager("storage manager", MockStorageManagerImpl.class);
- addManager("SimulatorManager", SimulatorManagerImpl.class);
- }
-
- @Override
- protected void populateDaos() {
- addDao("mock Host", MockHostDaoImpl.class);
- addDao("mock secondary storage", MockSecStorageDaoImpl.class);
- addDao("mock storage pool", MockStoragePoolDaoImpl.class);
- addDao("mock vm", MockVMDaoImpl.class);
- addDao("mock volume", MockVolumeDaoImpl.class);
- addDao("mock config", MockConfigurationDaoImpl.class);
- addDao("mock security rules", MockSecurityRulesDaoImpl.class);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d6083ce5/agent-simulator/src/com/cloud/resource/AgentResourceBase.java
----------------------------------------------------------------------
diff --git a/agent-simulator/src/com/cloud/resource/AgentResourceBase.java b/agent-simulator/src/com/cloud/resource/AgentResourceBase.java
deleted file mode 100644
index 6261158..0000000
--- a/agent-simulator/src/com/cloud/resource/AgentResourceBase.java
+++ /dev/null
@@ -1,284 +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.resource;
-
-import java.io.File;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-import javax.naming.ConfigurationException;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.agent.IAgentControl;
-import com.cloud.agent.api.Answer;
-import com.cloud.agent.api.Command;
-import com.cloud.agent.api.PingCommand;
-import com.cloud.agent.api.StartupCommand;
-import com.cloud.agent.manager.MockAgentManager;
-import com.cloud.agent.manager.MockStorageManager;
-import com.cloud.agent.manager.MockVmManager;
-import com.cloud.agent.manager.SimulatorManager;
-import com.cloud.agent.manager.SimulatorManager.AgentType;
-import com.cloud.host.Host;
-import com.cloud.host.Host.Type;
-import com.cloud.simulator.MockHost;
-import com.cloud.utils.component.ComponentLocator;
-
-public class AgentResourceBase implements ServerResource {
- private static final Logger s_logger = Logger
- .getLogger(AgentResourceBase.class);
-
- protected String _name;
- private List<String> _warnings = new LinkedList<String>();
- private List<String> _errors = new LinkedList<String>();
-
- private transient IAgentControl _agentControl;
-
- protected long _instanceId;
-
- private Type _type;
-
- private transient ComponentLocator _locator = null;
- protected transient SimulatorManager _simMgr;
- protected MockHost agentHost = null;
- protected boolean stopped = false;
- protected String hostGuid = null;
-
-
- public AgentResourceBase(long instanceId, AgentType agentType, SimulatorManager simMgr, String hostGuid) {
- _instanceId = instanceId;
-
- if(s_logger.isDebugEnabled()) {
- s_logger.info("New Routing host instantiated with guid:" + hostGuid);
- }
-
- if (agentType == AgentType.Routing) {
- _type = Host.Type.Routing;
- } else {
- _type = Host.Type.Storage;
- }
-
- this.hostGuid = hostGuid;
- }
-
- protected MockVmManager getVmMgr() {
- return _simMgr.getVmMgr();
- }
-
- protected MockStorageManager getStorageMgr() {
- return _simMgr.getStorageMgr();
- }
-
- protected MockAgentManager getAgentMgr() {
- return _simMgr.getAgentMgr();
- }
-
- protected long getInstanceId() {
- return _instanceId;
- }
-
- public AgentResourceBase() {
- if(s_logger.isDebugEnabled()) {
- s_logger.debug("Deserializing simulated agent on reconnect");
- }
-
- }
-
- @Override
- public String getName() {
- return _name;
- }
-
- public void setName(String name) {
- _name = name;
- }
-
- @Override
- public boolean configure(String name, Map<String, Object> params)
- throws ConfigurationException {
- hostGuid = (String)params.get("guid");
- _locator = ComponentLocator.getLocator("management-server");
- _simMgr = _locator.getManager(SimulatorManager.class);
-
- agentHost = getAgentMgr().getHost(hostGuid);
- return true;
- }
-
-
- private void reconnect(MockHost host) {
- if(s_logger.isDebugEnabled()) {
- s_logger.debug("Reconfiguring existing simulated host w/ name: " + host.getName() + " and guid: " + host.getGuid());
- }
- this.agentHost = host;
- }
-
-
- @Override
- public void disconnected() {
- this.stopped = true;
- }
-
- protected void recordWarning(String msg, Throwable th) {
- String str = getLogStr(msg, th);
- synchronized (_warnings) {
- _warnings.add(str);
- }
- }
-
- protected void recordWarning(String msg) {
- recordWarning(msg, null);
- }
-
- protected List<String> getWarnings() {
- synchronized (this) {
- List<String> results = _warnings;
- _warnings = new ArrayList<String>();
- return results;
- }
- }
-
- protected List<String> getErrors() {
- synchronized (this) {
- List<String> result = _errors;
- _errors = new ArrayList<String>();
- return result;
- }
- }
-
- protected void recordError(String msg, Throwable th) {
- String str = getLogStr(msg, th);
- synchronized (_errors) {
- _errors.add(str);
- }
- }
-
- protected void recordError(String msg) {
- recordError(msg, null);
- }
-
- protected Answer createErrorAnswer(Command cmd, String msg, Throwable th) {
- StringWriter writer = new StringWriter();
- if (msg != null) {
- writer.append(msg);
- }
- writer.append("===>Stack<===");
- th.printStackTrace(new PrintWriter(writer));
- return new Answer(cmd, false, writer.toString());
- }
-
- protected String createErrorDetail(String msg, Throwable th) {
- StringWriter writer = new StringWriter();
- if (msg != null) {
- writer.append(msg);
- }
- writer.append("===>Stack<===");
- th.printStackTrace(new PrintWriter(writer));
- return writer.toString();
- }
-
- protected String getLogStr(String msg, Throwable th) {
- StringWriter writer = new StringWriter();
- writer.append(new Date().toString()).append(": ").append(msg);
- if (th != null) {
- writer.append("\n Exception: ");
- th.printStackTrace(new PrintWriter(writer));
- }
- return writer.toString();
- }
-
- @Override
- public boolean start() {
- return true;
- }
-
- @Override
- public boolean stop() {
- this.stopped = true;
- return true;
- }
-
- @Override
- public IAgentControl getAgentControl() {
- return _agentControl;
- }
-
- @Override
- public void setAgentControl(IAgentControl agentControl) {
- _agentControl = agentControl;
- }
-
- protected String findScript(String script) {
- s_logger.debug("Looking for " + script + " in the classpath");
- URL url = ClassLoader.getSystemResource(script);
- File file = null;
- if (url == null) {
- file = new File("./" + script);
- s_logger.debug("Looking for " + script + " in "
- + file.getAbsolutePath());
- if (!file.exists()) {
- return null;
- }
- } else {
- file = new File(url.getFile());
- }
- return file.getAbsolutePath();
- }
-
-
- @Override
- public Answer executeRequest(Command cmd) {
- return null;
- }
-
- @Override
- public PingCommand getCurrentStatus(long id) {
- return null;
- }
-
- @Override
- public Type getType() {
- return _type;
- }
-
- public void setType(Host.Type _type) {
- this._type = _type;
- }
-
- @Override
- public StartupCommand[] initialize() {
- return null;
- }
-
- public SimulatorManager getSimulatorManager() {
- return _simMgr;
- }
-
- public void setSimulatorManager(SimulatorManager simMgr) {
- _simMgr = simMgr;
- }
-
- public boolean isStopped() {
- return this.stopped;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d6083ce5/agent-simulator/src/com/cloud/resource/AgentRoutingResource.java
----------------------------------------------------------------------
diff --git a/agent-simulator/src/com/cloud/resource/AgentRoutingResource.java b/agent-simulator/src/com/cloud/resource/AgentRoutingResource.java
deleted file mode 100644
index f10713d..0000000
--- a/agent-simulator/src/com/cloud/resource/AgentRoutingResource.java
+++ /dev/null
@@ -1,363 +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.resource;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-
-import javax.naming.ConfigurationException;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.agent.api.Answer;
-import com.cloud.agent.api.CheckVirtualMachineAnswer;
-import com.cloud.agent.api.CheckVirtualMachineCommand;
-import com.cloud.agent.api.Command;
-import com.cloud.agent.api.PingCommand;
-import com.cloud.agent.api.PingRoutingWithNwGroupsCommand;
-import com.cloud.agent.api.PrepareForMigrationAnswer;
-import com.cloud.agent.api.PrepareForMigrationCommand;
-import com.cloud.agent.api.ReadyAnswer;
-import com.cloud.agent.api.ReadyCommand;
-import com.cloud.agent.api.ShutdownCommand;
-import com.cloud.agent.api.StartAnswer;
-import com.cloud.agent.api.StartCommand;
-import com.cloud.agent.api.StartupCommand;
-import com.cloud.agent.api.StartupRoutingCommand;
-import com.cloud.agent.api.StartupStorageCommand;
-import com.cloud.agent.api.StopAnswer;
-import com.cloud.agent.api.StopCommand;
-import com.cloud.agent.api.StoragePoolInfo;
-import com.cloud.agent.api.to.VirtualMachineTO;
-import com.cloud.agent.manager.SimulatorManager;
-import com.cloud.agent.manager.SimulatorManager.AgentType;
-import com.cloud.host.Host;
-import com.cloud.host.Host.Type;
-import com.cloud.hypervisor.Hypervisor.HypervisorType;
-import com.cloud.network.Networks.RouterPrivateIpStrategy;
-import com.cloud.simulator.MockVMVO;
-import com.cloud.storage.Storage.StorageResourceType;
-import com.cloud.storage.template.TemplateInfo;
-import com.cloud.utils.Pair;
-import com.cloud.vm.VirtualMachine.State;
-
-public class AgentRoutingResource extends AgentStorageResource {
- private static final Logger s_logger = Logger.getLogger(AgentRoutingResource.class);
-
- protected Map<String, State> _vms = new HashMap<String, State>();
- private Map<String, Pair<Long, Long>> _runningVms = new HashMap<String, Pair<Long, Long>>();
- long usedCpu = 0;
- long usedMem = 0;
- long totalCpu;
- long totalMem;
- protected String _mountParent;
-
-
- public AgentRoutingResource(long instanceId, AgentType agentType, SimulatorManager simMgr, String hostGuid) {
- super(instanceId, agentType, simMgr, hostGuid);
- }
-
- public AgentRoutingResource() {
- setType(Host.Type.Routing);
- }
-
- @Override
- public Answer executeRequest(Command cmd) {
- try {
- if (cmd instanceof StartCommand) {
- return execute((StartCommand) cmd);
- } else if (cmd instanceof StopCommand) {
- return execute((StopCommand) cmd);
- } else if (cmd instanceof CheckVirtualMachineCommand) {
- return execute((CheckVirtualMachineCommand) cmd);
- } else if (cmd instanceof ReadyCommand) {
- return new ReadyAnswer((ReadyCommand)cmd);
- } else if (cmd instanceof ShutdownCommand) {
- return execute((ShutdownCommand)cmd);
- } else {
- return _simMgr.simulate(cmd, hostGuid);
- }
- } catch (IllegalArgumentException e) {
- return new Answer(cmd, false, e.getMessage());
- }
- }
-
- @Override
- public Type getType() {
- return Host.Type.Routing;
- }
-
- @Override
- public PingCommand getCurrentStatus(long id) {
- if (isStopped()) {
- return null;
- }
- synchronized (_vms) {
- if (_vms.size() == 0) {
- //load vms state from database
- _vms.putAll(_simMgr.getVmStates(hostGuid));
- }
- }
- final HashMap<String, State> newStates = sync();
- HashMap<String, Pair<Long, Long>> nwGrpStates = _simMgr.syncNetworkGroups(hostGuid);
- return new PingRoutingWithNwGroupsCommand(getType(), id, newStates, nwGrpStates);
- }
-
- @Override
- public StartupCommand[] initialize() {
- synchronized (_vms) {
- _vms.clear();
- }
- Map<String, State> changes = _simMgr.getVmStates(this.hostGuid);
- Map<String, MockVMVO> vmsMaps = _simMgr.getVms(this.hostGuid);
- totalCpu = agentHost.getCpuCount() * agentHost.getCpuSpeed();
- totalMem = agentHost.getMemorySize();
- for (Map.Entry<String, MockVMVO> entry : vmsMaps.entrySet()) {
- MockVMVO vm = entry.getValue();
- usedCpu += vm.getCpu();
- usedMem += vm.getMemory();
- _runningVms.put(entry.getKey(), new Pair<Long, Long>(Long.valueOf(vm.getCpu()), vm.getMemory()));
- }
-
- List<Object> info = getHostInfo();
-
- StartupRoutingCommand cmd = new StartupRoutingCommand((Integer) info.get(0), (Long) info.get(1), (Long) info.get(2), (Long) info.get(4), (String) info.get(3), HypervisorType.Simulator,
- RouterPrivateIpStrategy.HostLocal);
- cmd.setStateChanges(changes);
-
- Map<String, String> hostDetails = new HashMap<String, String>();
- hostDetails.put(RouterPrivateIpStrategy.class.getCanonicalName(), RouterPrivateIpStrategy.DcGlobal.toString());
-
- cmd.setHostDetails(hostDetails);
- cmd.setAgentTag("agent-simulator");
- cmd.setPrivateIpAddress(agentHost.getPrivateIpAddress());
- cmd.setPrivateNetmask(agentHost.getPrivateNetMask());
- cmd.setPrivateMacAddress(agentHost.getPrivateMacAddress());
- cmd.setStorageIpAddress(agentHost.getStorageIpAddress());
- cmd.setStorageNetmask(agentHost.getStorageNetMask());
- cmd.setStorageMacAddress(agentHost.getStorageMacAddress());
- cmd.setStorageIpAddressDeux(agentHost.getStorageIpAddress());
- cmd.setStorageNetmaskDeux(agentHost.getStorageNetMask());
- cmd.setStorageMacAddressDeux(agentHost.getStorageIpAddress());
-
- cmd.setName(agentHost.getName());
- cmd.setGuid(agentHost.getGuid());
- cmd.setVersion(agentHost.getVersion());
- cmd.setAgentTag("agent-simulator");
- cmd.setDataCenter(String.valueOf(agentHost.getDataCenterId()));
- cmd.setPod(String.valueOf(agentHost.getPodId()));
- cmd.setCluster(String.valueOf(agentHost.getClusterId()));
-
- StartupStorageCommand ssCmd = initializeLocalSR();
-
- return new StartupCommand[] { cmd, ssCmd };
- }
-
- private StartupStorageCommand initializeLocalSR() {
- Map<String, TemplateInfo> tInfo = new HashMap<String, TemplateInfo>();
-
- StoragePoolInfo poolInfo = _simMgr.getLocalStorage(hostGuid);
-
- StartupStorageCommand cmd = new StartupStorageCommand(poolInfo.getHostPath(), poolInfo.getPoolType(), poolInfo.getCapacityBytes(), tInfo);
-
- cmd.setPoolInfo(poolInfo);
- cmd.setGuid(agentHost.getGuid());
- cmd.setResourceType(StorageResourceType.STORAGE_POOL);
- return cmd;
- }
-
- protected synchronized Answer execute(StartCommand cmd)
- throws IllegalArgumentException {
- VirtualMachineTO vmSpec = cmd.getVirtualMachine();
- String vmName = vmSpec.getName();
- if (this.totalCpu < (vmSpec.getCpus() * vmSpec.getSpeed() + this.usedCpu) ||
- this.totalMem < (vmSpec.getMaxRam() + this.usedMem)) {
- return new StartAnswer(cmd, "Not enough resource to start the vm");
- }
- State state = State.Stopped;
- synchronized (_vms) {
- _vms.put(vmName, State.Starting);
- }
-
- try {
- Answer result = _simMgr.simulate(cmd, hostGuid);
- if (!result.getResult()) {
- return new StartAnswer(cmd, result.getDetails());
- }
-
- this.usedCpu += vmSpec.getCpus() * vmSpec.getSpeed();
- this.usedMem += vmSpec.getMaxRam();
- _runningVms.put(vmName, new Pair<Long, Long>(Long.valueOf(vmSpec.getCpus() * vmSpec.getSpeed()), vmSpec.getMaxRam()));
- state = State.Running;
-
- } finally {
- synchronized (_vms) {
- _vms.put(vmName, state);
- }
- }
-
- return new StartAnswer(cmd);
-
- }
-
- protected synchronized StopAnswer execute(StopCommand cmd) {
-
- StopAnswer answer = null;
- String vmName = cmd.getVmName();
-
- State state = null;
- synchronized (_vms) {
- state = _vms.get(vmName);
- _vms.put(vmName, State.Stopping);
- }
- try {
- Answer result = _simMgr.simulate(cmd, hostGuid);
-
- if (!result.getResult()) {
- return new StopAnswer(cmd, result.getDetails(), false);
- }
-
- answer = new StopAnswer(cmd, null, 0, true);
- Pair<Long, Long> data = _runningVms.get(vmName);
- if (data != null) {
- this.usedCpu -= data.first();
- this.usedMem -= data.second();
- }
- state = State.Stopped;
-
- } finally {
- synchronized (_vms) {
- _vms.put(vmName, state);
- }
- }
-
- return answer;
- }
-
- protected CheckVirtualMachineAnswer execute(final CheckVirtualMachineCommand cmd) {
- final String vmName = cmd.getVmName();
- CheckVirtualMachineAnswer result = (CheckVirtualMachineAnswer)_simMgr.simulate(cmd, hostGuid);
- State state = result.getState();
- if (state == State.Running) {
- synchronized (_vms) {
- _vms.put(vmName, State.Running);
- }
- }
- return result;
- }
-
- protected List<Object> getHostInfo() {
- ArrayList<Object> info = new ArrayList<Object>();
- long speed = agentHost.getCpuSpeed();
- long cpus = agentHost.getCpuCount();
- long ram = agentHost.getMemorySize();
- long dom0Ram = agentHost.getMemorySize()/10;
-
- info.add((int) cpus);
- info.add(speed);
- info.add(ram);
- info.add(agentHost.getCapabilities());
- info.add(dom0Ram);
-
- return info;
- }
-
- protected HashMap<String, State> sync() {
- Map<String, State> newStates;
- Map<String, State> oldStates = null;
-
- HashMap<String, State> changes = new HashMap<String, State>();
-
- synchronized (_vms) {
- oldStates = new HashMap<String, State>(_vms.size());
- oldStates.putAll(_vms);
- newStates = new HashMap<String, State>(_vms.size());
- newStates.putAll(_vms);
-
- for (Map.Entry<String, State> entry : newStates.entrySet()) {
- String vm = entry.getKey();
-
- State newState = entry.getValue();
- State oldState = oldStates.remove(vm);
-
- if (s_logger.isTraceEnabled()) {
- s_logger.trace("VM " + vm + ": has state " + newState + " and we have state " + (oldState != null ? oldState.toString() : "null"));
- }
-
- if (oldState == null) {
- _vms.put(vm, newState);
- changes.put(vm, newState);
- } else if (oldState == State.Starting) {
- if (newState == State.Running) {
- _vms.put(vm, newState);
- } else if (newState == State.Stopped) {
- s_logger.debug("Ignoring vm " + vm + " because of a lag in starting the vm.");
- }
- } else if (oldState == State.Stopping) {
- if (newState == State.Stopped) {
- _vms.put(vm, newState);
- } else if (newState == State.Running) {
- s_logger.debug("Ignoring vm " + vm + " because of a lag in stopping the vm. ");
- }
- } else if (oldState != newState) {
- _vms.put(vm, newState);
- changes.put(vm, newState);
- }
- }
-
- for (Map.Entry<String, State> entry : oldStates.entrySet()) {
- String vm = entry.getKey();
- State oldState = entry.getValue();
-
- if (s_logger.isTraceEnabled()) {
- s_logger.trace("VM " + vm + " is now missing from simulator agent so reporting stopped");
- }
-
- if (oldState == State.Stopping) {
- s_logger.debug("Ignoring VM " + vm + " in transition state stopping.");
- _vms.remove(vm);
- } else if (oldState == State.Starting) {
- s_logger.debug("Ignoring VM " + vm + " in transition state starting.");
- } else if (oldState == State.Stopped) {
- _vms.remove(vm);
- } else {
- changes.put(entry.getKey(), State.Stopped);
- }
- }
- }
-
- return changes;
- }
-
- private Answer execute(ShutdownCommand cmd) {
- this.stopped = true;
- return new Answer(cmd);
- }
-
- @Override
- public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
- if (!super.configure(name, params)) {
- s_logger.warn("Base class was unable to configure");
- return false;
- }
- return true;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d6083ce5/agent-simulator/src/com/cloud/resource/AgentStorageResource.java
----------------------------------------------------------------------
diff --git a/agent-simulator/src/com/cloud/resource/AgentStorageResource.java b/agent-simulator/src/com/cloud/resource/AgentStorageResource.java
deleted file mode 100644
index 2751b87..0000000
--- a/agent-simulator/src/com/cloud/resource/AgentStorageResource.java
+++ /dev/null
@@ -1,117 +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.resource;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.naming.ConfigurationException;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.agent.api.Answer;
-import com.cloud.agent.api.Command;
-import com.cloud.agent.api.PingCommand;
-import com.cloud.agent.api.PingStorageCommand;
-import com.cloud.agent.api.ReadyAnswer;
-import com.cloud.agent.api.ReadyCommand;
-import com.cloud.agent.api.StartupCommand;
-import com.cloud.agent.api.StartupSecondaryStorageCommand;
-import com.cloud.agent.api.StartupStorageCommand;
-import com.cloud.agent.api.storage.ssCommand;
-import com.cloud.agent.manager.SimulatorManager;
-import com.cloud.agent.manager.SimulatorManager.AgentType;
-import com.cloud.host.Host;
-import com.cloud.host.Host.Type;
-import com.cloud.storage.resource.SecondaryStorageResource;
-import com.cloud.vm.SecondaryStorageVm;
-
-
-public class AgentStorageResource extends AgentResourceBase implements SecondaryStorageResource {
- private static final Logger s_logger = Logger.getLogger(AgentStorageResource.class);
-
- final protected String _parent = "/mnt/SecStorage";
- protected String _role;
-
- public AgentStorageResource(long instanceId, AgentType agentType, SimulatorManager simMgr, String hostGuid) {
- super(instanceId, agentType, simMgr, hostGuid);
- }
-
- public AgentStorageResource() {
- setType(Host.Type.SecondaryStorage);
- }
-
- @Override
- public Answer executeRequest(Command cmd) {
- if (cmd instanceof ReadyCommand) {
- return new ReadyAnswer((ReadyCommand)cmd);
- } else {
- return _simMgr.simulate(cmd, hostGuid);
- }
- }
-
- @Override
- public PingCommand getCurrentStatus(long id) {
- if (isStopped()) {
- return null;
- }
- return new PingStorageCommand(Host.Type.Storage, id, new HashMap<String, Boolean>());
- }
-
- @Override
- public Type getType() {
- if(SecondaryStorageVm.Role.templateProcessor.toString().equals(_role))
- return Host.Type.SecondaryStorage;
- return Host.Type.SecondaryStorageCmdExecutor;
- }
-
- @Override
- public StartupCommand[] initialize() {
- StartupSecondaryStorageCommand cmd = new StartupSecondaryStorageCommand();
-
- cmd.setPrivateIpAddress(agentHost.getPrivateIpAddress());
- cmd.setPrivateNetmask(agentHost.getPrivateNetMask());
- cmd.setPrivateMacAddress(agentHost.getPrivateMacAddress());
- cmd.setStorageIpAddress(agentHost.getStorageIpAddress());
- cmd.setStorageNetmask(agentHost.getStorageNetMask());
- cmd.setStorageMacAddress(agentHost.getStorageMacAddress());
- cmd.setPublicIpAddress(agentHost.getPublicIpAddress());
-
- cmd.setName(agentHost.getName());
- cmd.setAgentTag("agent-simulator");
- cmd.setVersion(agentHost.getVersion());
- cmd.setDataCenter(String.valueOf(agentHost.getDataCenterId()));
- cmd.setPod(String.valueOf(agentHost.getPodId()));
- cmd.setGuid(agentHost.getGuid());
- return new StartupCommand[] { cmd };
- }
-
- @Override
- public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
- if (!super.configure(name, params)) {
- s_logger.warn("Base class was unable to configure");
- return false;
- }
-
- return true;
- }
-
- @Override
- public String getRootDir(ssCommand cmd) {
- // TODO Auto-generated method stub
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d6083ce5/agent-simulator/src/com/cloud/resource/SimulatorDiscoverer.java
----------------------------------------------------------------------
diff --git a/agent-simulator/src/com/cloud/resource/SimulatorDiscoverer.java b/agent-simulator/src/com/cloud/resource/SimulatorDiscoverer.java
deleted file mode 100755
index 729d4b0..0000000
--- a/agent-simulator/src/com/cloud/resource/SimulatorDiscoverer.java
+++ /dev/null
@@ -1,336 +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.resource;
-
-import java.net.URI;
-import java.net.URLDecoder;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
-import javax.ejb.Local;
-import javax.naming.ConfigurationException;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.agent.AgentManager;
-import com.cloud.agent.Listener;
-import com.cloud.agent.api.AgentControlAnswer;
-import com.cloud.agent.api.AgentControlCommand;
-import com.cloud.agent.api.Answer;
-import com.cloud.agent.api.Command;
-import com.cloud.agent.api.StartupCommand;
-import com.cloud.agent.api.StartupRoutingCommand;
-import com.cloud.agent.manager.MockAgentManager;
-import com.cloud.agent.manager.MockStorageManager;
-import com.cloud.dc.ClusterVO;
-import com.cloud.dc.dao.ClusterDao;
-import com.cloud.exception.ConnectionException;
-import com.cloud.exception.DiscoveryException;
-import com.cloud.host.Host;
-import com.cloud.host.HostVO;
-import com.cloud.host.Status;
-import com.cloud.host.dao.HostDao;
-import com.cloud.hypervisor.Hypervisor.HypervisorType;
-import com.cloud.storage.VMTemplateHostVO;
-import com.cloud.storage.VMTemplateVO;
-import com.cloud.storage.VMTemplateZoneVO;
-import com.cloud.storage.dao.VMTemplateDao;
-import com.cloud.storage.dao.VMTemplateHostDao;
-import com.cloud.storage.dao.VMTemplateZoneDao;
-import com.cloud.utils.component.Inject;
-
-@Local(value = Discoverer.class)
-public class SimulatorDiscoverer extends DiscovererBase implements Discoverer, Listener, ResourceStateAdapter {
- private static final Logger s_logger = Logger
- .getLogger(SimulatorDiscoverer.class);
-
- @Inject HostDao _hostDao;
- @Inject VMTemplateDao _vmTemplateDao;
- @Inject VMTemplateHostDao _vmTemplateHostDao;
- @Inject VMTemplateZoneDao _vmTemplateZoneDao;
- @Inject ClusterDao _clusterDao;
- @Inject AgentManager _agentMgr = null;
- @Inject MockAgentManager _mockAgentMgr = null;
- @Inject MockStorageManager _mockStorageMgr = null;
- @Inject ResourceManager _resourceMgr;
-
- /**
- * Finds ServerResources of an in-process simulator
- *
- * @see com.cloud.resource.Discoverer#find(long, java.lang.Long,
- * java.lang.Long, java.net.URI, java.lang.String, java.lang.String)
- */
- @Override
- public Map<? extends ServerResource, Map<String, String>> find(long dcId,
- Long podId, Long clusterId, URI uri, String username,
- String password, List<String> hostTags) throws DiscoveryException {
- Map<AgentResourceBase, Map<String, String>> resources;
-
- try {
- //http://sim/count=$count, it will add $count number of hosts into the cluster
- String scheme = uri.getScheme();
- String host = uri.getAuthority();
- String commands = URLDecoder.decode(uri.getPath());
-
- long cpuSpeed = _mockAgentMgr.DEFAULT_HOST_SPEED_MHZ;
- long cpuCores = _mockAgentMgr.DEFAULT_HOST_CPU_CORES;
- long memory = _mockAgentMgr.DEFAULT_HOST_MEM_SIZE;
- long localstorageSize = _mockStorageMgr.DEFAULT_HOST_STORAGE_SIZE;
- if (scheme.equals("http")) {
- if (host == null || !host.startsWith("sim")) {
- String msg = "uri is not of simulator type so we're not taking care of the discovery for this: "
- + uri;
- if(s_logger.isDebugEnabled()) {
- s_logger.debug(msg);
- }
- return null;
- }
- if (commands != null) {
- int index = commands.lastIndexOf("/");
- if (index != -1) {
- commands = commands.substring(index+1);
-
- String[] cmds = commands.split("&");
- for (String cmd : cmds) {
- String[] parameter = cmd.split("=");
- if (parameter[0].equalsIgnoreCase("cpuspeed") && parameter[1] != null) {
- cpuSpeed = Long.parseLong(parameter[1]);
- } else if (parameter[0].equalsIgnoreCase("cpucore") && parameter[1] != null) {
- cpuCores = Long.parseLong(parameter[1]);
- } else if (parameter[0].equalsIgnoreCase("memory") && parameter[1] != null) {
- memory = Long.parseLong(parameter[1]);
- } else if (parameter[0].equalsIgnoreCase("localstorage") && parameter[1] != null) {
- localstorageSize = Long.parseLong(parameter[1]);
- }
- }
- }
- }
- } else {
- String msg = "uriString is not http so we're not taking care of the discovery for this: "
- + uri;
- if(s_logger.isDebugEnabled()) {
- s_logger.debug(msg);
- }
- return null;
- }
-
- String cluster = null;
- if (clusterId == null) {
- String msg = "must specify cluster Id when adding host";
- if(s_logger.isDebugEnabled()) {
- s_logger.debug(msg);
- }
- throw new RuntimeException(msg);
- } else {
- ClusterVO clu = _clusterDao.findById(clusterId);
- if (clu == null
- || (clu.getHypervisorType() != HypervisorType.Simulator)) {
- if (s_logger.isInfoEnabled())
- s_logger.info("invalid cluster id or cluster is not for Simulator hypervisors");
- return null;
- }
- cluster = Long.toString(clusterId);
- if(clu.getGuid() == null) {
- clu.setGuid(UUID.randomUUID().toString());
- }
- _clusterDao.update(clusterId, clu);
- }
-
- String pod;
- if (podId == null) {
- String msg = "must specify pod Id when adding host";
- if(s_logger.isDebugEnabled()) {
- s_logger.debug(msg);
- }
- throw new RuntimeException(msg);
- } else {
- pod = Long.toString(podId);
- }
-
- Map<String, String> details = new HashMap<String, String>();
- Map<String, Object> params = new HashMap<String, Object>();
- details.put("username", username);
- params.put("username", username);
- details.put("password", password);
- params.put("password", password);
- params.put("zone", Long.toString(dcId));
- params.put("pod", pod);
- params.put("cluster", cluster);
- params.put("cpuspeed", Long.toString(cpuSpeed));
- params.put("cpucore", Long.toString(cpuCores));
- params.put("memory", Long.toString(memory));
- params.put("localstorage", Long.toString(localstorageSize));
-
- resources = createAgentResources(params);
- return resources;
- } catch (Exception ex) {
- s_logger.error("Exception when discovering simulator hosts: "
- + ex.getMessage());
- }
- return null;
- }
-
- private Map<AgentResourceBase, Map<String, String>> createAgentResources(
- Map<String, Object> params) {
- try {
- s_logger.info("Creating Simulator Resources");
- return _mockAgentMgr.createServerResources(params);
- } catch (Exception ex) {
- s_logger.warn("Caught exception at agent resource creation: "
- + ex.getMessage(), ex);
- }
- return null;
- }
-
- @Override
- public void postDiscovery(List<HostVO> hosts, long msId) {
-
- for (HostVO h : hosts) {
- associateTemplatesToZone(h.getId(), h.getDataCenterId());
- }
- }
-
- private void associateTemplatesToZone(long hostId, long dcId){
- VMTemplateZoneVO tmpltZone;
-
- List<VMTemplateVO> allTemplates = _vmTemplateDao.listAll();
- for (VMTemplateVO vt: allTemplates){
- if (vt.isCrossZones()) {
- tmpltZone = _vmTemplateZoneDao.findByZoneTemplate(dcId, vt.getId());
- if (tmpltZone == null) {
- VMTemplateZoneVO vmTemplateZone = new VMTemplateZoneVO(dcId, vt.getId(), new Date());
- _vmTemplateZoneDao.persist(vmTemplateZone);
- }
- }
- }
- }
-
- @Override
- public HypervisorType getHypervisorType() {
- return HypervisorType.Simulator;
- }
-
- @Override
- public boolean matchHypervisor(String hypervisor) {
- return hypervisor.equalsIgnoreCase(HypervisorType.Simulator.toString());
- }
-
- @Override
- public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
- super.configure(name, params);
- _agentMgr.registerForHostEvents(this, true, false, false);
- _resourceMgr.registerResourceStateAdapter(this.getClass().getSimpleName(), this);
- return true;
- }
-
- @Override
- public boolean processAnswers(long agentId, long seq, Answer[] answers) {
- return false;
- }
-
- @Override
- public boolean processCommands(long agentId, long seq, Command[] commands) {
- return false;
- }
-
- @Override
- public AgentControlAnswer processControlCommand(long agentId, AgentControlCommand cmd) {
- return null;
- }
-
- @Override
- public void processConnect(HostVO host, StartupCommand cmd, boolean forRebalance) throws ConnectionException {
-
- /*if(forRebalance)
- return;
- if ( Host.Type.SecondaryStorage == host.getType() ) {
- List<VMTemplateVO> tmplts = _vmTemplateDao.listAll();
- for( VMTemplateVO tmplt : tmplts ) {
- VMTemplateHostVO vmTemplateHost = _vmTemplateHostDao.findByHostTemplate(host.getId(), tmplt.getId());
- if (vmTemplateHost == null) {
- vmTemplateHost = new VMTemplateHostVO(host.getId(), tmplt.getId(), new Date(), 100,
- com.cloud.storage.VMTemplateStorageResourceAssoc.Status.DOWNLOADED, null, null, null, null, tmplt.getUrl());
- _vmTemplateHostDao.persist(vmTemplateHost);
- } else {
- vmTemplateHost.setDownloadState(com.cloud.storage.VMTemplateStorageResourceAssoc.Status.DOWNLOADED);
- vmTemplateHost.setDownloadPercent(100);
- _vmTemplateHostDao.update(vmTemplateHost.getId(), vmTemplateHost);
- }
- }
- }*/
-
- }
-
- @Override
- public boolean processDisconnect(long agentId, Status state) {
- return false;
- }
-
- @Override
- public boolean isRecurring() {
- return false;
- }
-
- @Override
- public int getTimeout() {
- return 0;
- }
-
- @Override
- public boolean processTimeout(long agentId, long seq) {
- return false;
- }
-
- @Override
- public HostVO createHostVOForConnectedAgent(HostVO host,
- StartupCommand[] cmd) {
- return null;
- }
-
- @Override
- public HostVO createHostVOForDirectConnectAgent(HostVO host,
- StartupCommand[] startup, ServerResource resource,
- Map<String, String> details, List<String> hostTags) {
- StartupCommand firstCmd = startup[0];
- if (!(firstCmd instanceof StartupRoutingCommand)) {
- return null;
- }
-
- StartupRoutingCommand ssCmd = ((StartupRoutingCommand) firstCmd);
- if (ssCmd.getHypervisorType() != HypervisorType.Simulator) {
- return null;
- }
-
- return _resourceMgr.fillRoutingHostVO(host, ssCmd, HypervisorType.Simulator, details, hostTags);
- }
-
- @Override
- public DeleteHostAnswer deleteHost(HostVO host, boolean isForced,
- boolean isForceDeleteStorage) throws UnableDeleteHostException {
- return null;
- }
-
- @Override
- public boolean stop() {
- _resourceMgr.unregisterResourceStateAdapter(this.getClass().getSimpleName());
- return super.stop();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d6083ce5/agent-simulator/src/com/cloud/resource/SimulatorSecondaryDiscoverer.java
----------------------------------------------------------------------
diff --git a/agent-simulator/src/com/cloud/resource/SimulatorSecondaryDiscoverer.java b/agent-simulator/src/com/cloud/resource/SimulatorSecondaryDiscoverer.java
deleted file mode 100644
index f828bc8..0000000
--- a/agent-simulator/src/com/cloud/resource/SimulatorSecondaryDiscoverer.java
+++ /dev/null
@@ -1,151 +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.resource;
-
-import java.util.List;
-import java.util.Map;
-
-import javax.ejb.Local;
-import javax.naming.ConfigurationException;
-
-import com.cloud.agent.AgentManager;
-import com.cloud.agent.Listener;
-import com.cloud.agent.api.AgentControlAnswer;
-import com.cloud.agent.api.AgentControlCommand;
-import com.cloud.agent.api.Answer;
-import com.cloud.agent.api.Command;
-import com.cloud.agent.api.StartupCommand;
-import com.cloud.agent.api.StartupSecondaryStorageCommand;
-import com.cloud.agent.manager.MockStorageManager;
-import com.cloud.exception.ConnectionException;
-import com.cloud.host.HostVO;
-import com.cloud.host.Status;
-import com.cloud.storage.SnapshotVO;
-import com.cloud.storage.dao.SnapshotDao;
-import com.cloud.storage.secondary.SecondaryStorageDiscoverer;
-import com.cloud.utils.component.Inject;
-import com.cloud.utils.exception.CloudRuntimeException;
-@Local(value=Discoverer.class)
-public class SimulatorSecondaryDiscoverer extends SecondaryStorageDiscoverer implements ResourceStateAdapter, Listener {
- @Inject MockStorageManager _mockStorageMgr = null;
- @Inject AgentManager _agentMgr;
- @Inject ResourceManager _resourceMgr;
- @Inject SnapshotDao _snapshotDao;
-
- @Override
- public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
- _agentMgr.registerForHostEvents(this, true, false, false);
- _resourceMgr.registerResourceStateAdapter(this.getClass().getSimpleName(), this);
- return super.configure(name, params);
- }
-
- @Override
- public void postDiscovery(List<HostVO> hosts, long msId) {
- super.postDiscovery(hosts, msId);
- for (HostVO host: hosts) {
- _mockStorageMgr.preinstallTemplates(host.getStorageUrl(), host.getDataCenterId());
- }
- }
-
- @Override
- public HostVO createHostVOForConnectedAgent(HostVO host,
- StartupCommand[] cmd) {
- return null;
- }
-
- @Override
- public HostVO createHostVOForDirectConnectAgent(HostVO host,
- StartupCommand[] startup, ServerResource resource,
- Map<String, String> details, List<String> hostTags) {
- //for detecting SSVM dispatch
- StartupCommand firstCmd = startup[0];
- if (!(firstCmd instanceof StartupSecondaryStorageCommand)) {
- return null;
- }
-
- host.setType(com.cloud.host.Host.Type.SecondaryStorageVM);
- return host;
- }
-
- @Override
- public DeleteHostAnswer deleteHost(HostVO host, boolean isForced,
- boolean isForceDeleteStorage) throws UnableDeleteHostException {
- long hostId = host.getId();
- List<SnapshotVO> snapshots = _snapshotDao.listByHostId(hostId);
- if (snapshots != null && !snapshots.isEmpty()) {
- throw new CloudRuntimeException("Cannot delete this secondary storage because there are still snapshots on it ");
- }
- _vmTemplateHostDao.deleteByHost(hostId);
- host.setGuid(null);
- _hostDao.update(hostId, host);
- _hostDao.remove(hostId);
- return new DeleteHostAnswer(true);
- }
-
- @Override
- public boolean start() {
- return true;
- }
-
- @Override
- public boolean stop() {
- _resourceMgr.unregisterResourceStateAdapter(this.getClass().getSimpleName());
- return true;
- }
-
- @Override
- public int getTimeout() {
- return 0;
- }
-
- @Override
- public boolean isRecurring() {
- return false;
- }
-
- @Override
- public boolean processAnswers(long agentId, long seq, Answer[] answers) {
- return false;
- }
-
- @Override
- public boolean processCommands(long agentId, long seq, Command[] commands) {
- return false;
- }
-
- @Override
- public void processConnect(HostVO host, StartupCommand cmd,
- boolean forRebalance) throws ConnectionException {
-
- }
-
- @Override
- public AgentControlAnswer processControlCommand(long agentId,
- AgentControlCommand cmd) {
- return null;
- }
-
- @Override
- public boolean processDisconnect(long agentId, Status state) {
- return false;
- }
-
- @Override
- public boolean processTimeout(long agentId, long seq) {
- return false;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d6083ce5/agent-simulator/src/com/cloud/server/ManagementServerSimulatorImpl.java
----------------------------------------------------------------------
diff --git a/agent-simulator/src/com/cloud/server/ManagementServerSimulatorImpl.java b/agent-simulator/src/com/cloud/server/ManagementServerSimulatorImpl.java
deleted file mode 100644
index 1c69b54..0000000
--- a/agent-simulator/src/com/cloud/server/ManagementServerSimulatorImpl.java
+++ /dev/null
@@ -1,32 +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;
-
-
-public class ManagementServerSimulatorImpl extends ManagementServerExtImpl {
- @Override
- public String[] getApiConfig() {
- String[] apis = super.getApiConfig();
- String[] newapis = new String[apis.length + 1];
- for (int i = 0; i < apis.length; i++) {
- newapis[i] = apis[i];
- }
-
- newapis[apis.length] = "commands-simulator.properties";
- return newapis;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d6083ce5/agent-simulator/src/com/cloud/simulator/MockConfigurationVO.java
----------------------------------------------------------------------
diff --git a/agent-simulator/src/com/cloud/simulator/MockConfigurationVO.java b/agent-simulator/src/com/cloud/simulator/MockConfigurationVO.java
deleted file mode 100644
index dfea227..0000000
--- a/agent-simulator/src/com/cloud/simulator/MockConfigurationVO.java
+++ /dev/null
@@ -1,121 +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.simulator;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.Table;
-
-@Entity
-@Table(name="mockconfiguration")
-public class MockConfigurationVO {
- @Id
- @GeneratedValue(strategy=GenerationType.IDENTITY)
- @Column(name="id")
- private long id;
-
- @Column(name="data_center_id", nullable=false)
- private Long dataCenterId;
-
- @Column(name="pod_id")
- private Long podId;
-
- @Column(name="cluster_id")
- private Long clusterId;
-
- @Column(name="host_id")
- private Long hostId;
-
- @Column(name="name")
- private String name;
-
- @Column(name="values")
- private String values;
-
- public long getId() {
- return this.id;
- }
-
- public Long getDataCenterId() {
- return this.dataCenterId;
- }
-
- public void setDataCenterId(Long dcId) {
- this.dataCenterId = dcId;
- }
-
- public Long getPodId() {
- return this.podId;
- }
-
- public void setPodId(Long podId) {
- this.podId = podId;
- }
-
- public Long getClusterId() {
- return this.clusterId;
- }
-
- public void setClusterId(Long clusterId) {
- this.clusterId = clusterId;
- }
-
- public Long getHostId() {
- return this.hostId;
- }
-
- public void setHostId(Long hostId) {
- this.hostId = hostId;
- }
-
- public String getName() {
- return this.name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getValues() {
- return this.values;
- }
-
- public Map<String, String> getParameters() {
- Map<String, String> maps = new HashMap<String, String>();
- if (this.values == null) {
- return maps;
- }
-
- String[] vals = this.values.split("\\|");
- for (String val : vals) {
- String[] paras = val.split(":");
- maps.put(paras[0], paras[1]);
- }
- return maps;
- }
-
- public void setValues(String values) {
- this.values = values;
- }
-}
-
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d6083ce5/agent-simulator/src/com/cloud/simulator/MockHost.java
----------------------------------------------------------------------
diff --git a/agent-simulator/src/com/cloud/simulator/MockHost.java b/agent-simulator/src/com/cloud/simulator/MockHost.java
deleted file mode 100644
index d20e825..0000000
--- a/agent-simulator/src/com/cloud/simulator/MockHost.java
+++ /dev/null
@@ -1,62 +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.simulator;
-
-public interface MockHost {
- public long getCpuSpeed();
- public long getCpuCount();
-
-
- public long getMemorySize();
-
- public String getCapabilities();
-
- public long getId();
-
- public String getName();
-
- public String getGuid();
-
-
- public String getVersion();
-
- public Long getDataCenterId();
-
- public Long getPodId();
-
- public Long getClusterId();
-
- public String getPrivateIpAddress();
-
- public String getPrivateNetMask();
-
- public String getPrivateMacAddress();
-
-
- public String getPublicIpAddress();
-
- public String getPublicNetMask();
-
- public String getPublicMacAddress();
-
- public String getStorageIpAddress();
-
- public String getStorageNetMask();
-
- public String getStorageMacAddress();
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d6083ce5/agent-simulator/src/com/cloud/simulator/MockHostVO.java
----------------------------------------------------------------------
diff --git a/agent-simulator/src/com/cloud/simulator/MockHostVO.java b/agent-simulator/src/com/cloud/simulator/MockHostVO.java
deleted file mode 100644
index 59b7e8d..0000000
--- a/agent-simulator/src/com/cloud/simulator/MockHostVO.java
+++ /dev/null
@@ -1,276 +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.simulator;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.Table;
-
-@Entity
-@Table(name="mockhost")
-
-public class MockHostVO implements MockHost {
- @Id
- @GeneratedValue(strategy=GenerationType.IDENTITY)
- @Column(name="id")
- private long id;
-
- @Column(name="name", nullable=false)
- private String name = null;
-
- @Column(name="private_ip_address", nullable=false)
- private String privateIpAddress;
-
- @Column(name="private_mac_address", nullable=false)
- private String privateMacAddress;
-
- @Column(name="private_netmask", nullable=false)
- private String privateNetmask;
-
- @Column(name="public_netmask")
- private String publicNetmask;
-
- @Column(name="public_ip_address")
- private String publicIpAddress;
-
- @Column(name="public_mac_address")
- private String publicMacAddress;
-
- @Column(name="storage_ip_address")
- private String storageIpAddress;
-
- @Column(name="storage_mac_address")
- private String storageMacAddress;
-
- @Column(name="storage_netmask")
- private String storageNetMask;
-
- @Column(name="guid")
- private String guid;
-
- @Column(name="version")
- private String version;
-
- @Column(name="data_center_id", nullable=false)
- private long dataCenterId;
-
- @Column(name="pod_id")
- private Long podId;
-
- @Column(name="cluster_id")
- private Long clusterId;
-
- @Column(name="speed")
- private long cpuSpeed;
-
- @Column(name="cpus")
- private long cpuCount;
-
- @Column(name="ram")
- private long memorySize;
-
- @Column(name="capabilities")
- private String capabilities;
-
- @Column(name="vm_id")
- private long vmId;
-
- @Column(name="resource")
- private String resource;
-
-
-
- public MockHostVO() {
-
- }
-
-
- public long getVmId() {
- return vmId;
- }
-
- public void setVmId(long vmId) {
- this.vmId = vmId;
- }
-
- public String getResource() {
- return this.resource;
- }
-
- public void setResource(String resource) {
- this.resource = resource;
- }
-
- public long getCpuSpeed() {
- return this.cpuSpeed;
- }
-
- public void setCpuSpeed(long cpuSpeed) {
- this.cpuSpeed = cpuSpeed;
- }
-
- public long getCpuCount() {
- return this.cpuCount;
- }
-
- public void setCpuCount(long cpuCount) {
- this.cpuCount = cpuCount;
- }
-
- public long getMemorySize() {
- return this.memorySize;
- }
-
- public void setMemorySize(long memorySize) {
- this.memorySize = memorySize;
- }
-
- public String getCapabilities() {
- return this.capabilities;
- }
-
- public void setCapabilities(String capabilities) {
- this.capabilities = capabilities;
- }
-
- public long getId() {
- return id;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getGuid() {
- return this.guid;
- }
-
- public void setGuid(String guid) {
- this.guid = guid;
- }
-
- public String getVersion() {
- return this.version;
- }
-
- public void setVersion(String version) {
- this.version = version;
- }
-
- public Long getDataCenterId() {
- return this.dataCenterId;
- }
-
- public void setDataCenterId(Long dataCenterId) {
- this.dataCenterId = dataCenterId;
- }
-
- public Long getPodId() {
- return this.podId;
- }
-
- public void setPodId(long podId) {
- this.podId = podId;
- }
-
- public Long getClusterId() {
- return this.clusterId;
- }
-
- public void setClusterId(Long clusterId) {
- this.clusterId = clusterId;
- }
-
- public String getPrivateIpAddress() {
- return privateIpAddress;
- }
-
- public void setPrivateIpAddress(String privateIpAddress) {
- this.privateIpAddress = privateIpAddress;
- }
-
- public String getPrivateNetMask() {
- return this.privateNetmask;
- }
-
- public void setPrivateNetMask(String privateNetmask) {
- this.privateNetmask = privateNetmask;
- }
-
- public String getPrivateMacAddress() {
- return this.privateMacAddress;
- }
-
- public void setPrivateMacAddress(String privateMacAddress) {
- this.privateMacAddress = privateMacAddress;
- }
-
- public String getPublicIpAddress() {
- return this.publicIpAddress;
- }
-
- public void setPublicIpAddress(String publicIpAddress) {
- this.publicIpAddress = publicIpAddress;
- }
-
- public String getPublicNetMask() {
- return this.publicNetmask;
- }
-
- public void setPublicNetMask(String publicNetMask) {
- this.publicNetmask = publicNetMask;
- }
-
- public String getPublicMacAddress() {
- return this.publicMacAddress;
- }
-
- public void setPublicMacAddress(String publicMacAddress) {
- this.publicMacAddress = publicMacAddress;
- }
-
- public String getStorageIpAddress() {
- return this.storageIpAddress;
- }
-
- public void setStorageIpAddress(String storageIpAddress) {
- this.storageIpAddress = storageIpAddress;
- }
-
- public String getStorageNetMask() {
- return this.storageNetMask;
- }
-
- public void setStorageNetMask(String storageNetMask) {
- this.storageNetMask = storageNetMask;
- }
-
- public String getStorageMacAddress() {
- return this.storageMacAddress;
- }
-
- public void setStorageMacAddress(String storageMacAddress) {
- this.storageMacAddress = storageMacAddress;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d6083ce5/agent-simulator/src/com/cloud/simulator/MockSecStorageVO.java
----------------------------------------------------------------------
diff --git a/agent-simulator/src/com/cloud/simulator/MockSecStorageVO.java b/agent-simulator/src/com/cloud/simulator/MockSecStorageVO.java
deleted file mode 100644
index c503cc2..0000000
--- a/agent-simulator/src/com/cloud/simulator/MockSecStorageVO.java
+++ /dev/null
@@ -1,76 +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.simulator;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.Table;
-
-@Entity
-@Table(name="mocksecstorage")
-
-public class MockSecStorageVO {
- @Id
- @GeneratedValue(strategy=GenerationType.IDENTITY)
- @Column(name="id")
- private long id;
-
- @Column(name="url")
- private String url;
-
- @Column(name="capacity")
- private long capacity;
-
- @Column(name="mount_point")
- private String mountPoint;
-
-
- public MockSecStorageVO() {
-
- }
-
- public long getId() {
- return this.id;
- }
-
- public String getMountPoint() {
- return this.mountPoint;
- }
-
- public void setMountPoint(String mountPoint) {
- this.mountPoint = mountPoint;
- }
-
- public String getUrl() {
- return url;
- }
-
- public void setUrl(String url) {
- this.url = url;
- }
-
- public long getCapacity() {
- return this.capacity;
- }
-
- public void setCapacity(long capacity) {
- this.capacity = capacity;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d6083ce5/agent-simulator/src/com/cloud/simulator/MockSecurityRulesVO.java
----------------------------------------------------------------------
diff --git a/agent-simulator/src/com/cloud/simulator/MockSecurityRulesVO.java b/agent-simulator/src/com/cloud/simulator/MockSecurityRulesVO.java
deleted file mode 100644
index 3036ea9..0000000
--- a/agent-simulator/src/com/cloud/simulator/MockSecurityRulesVO.java
+++ /dev/null
@@ -1,104 +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.simulator;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.Table;
-
-
-@Entity
-@Table(name="mocksecurityrules")
-public class MockSecurityRulesVO {
- @Id
- @GeneratedValue(strategy=GenerationType.IDENTITY)
- @Column(name="id")
- private long id;
-
- @Column(name="vmid")
- private Long vmId;
-
- @Column(name="signature")
- private String signature;
-
- @Column(name="seqnum")
- private Long seqNum;
-
- @Column(name="ruleset")
- private String ruleSet;
-
- @Column(name="hostid")
- private String hostId;
-
- @Column(name="vmname")
- public String vmName;
-
- public String getVmName() {
- return this.vmName;
- }
-
- public void setVmName(String vmName) {
- this.vmName = vmName;
- }
-
- public String getHostId() {
- return this.hostId;
- }
-
- public void setHostId(String hostId) {
- this.hostId = hostId;
- }
-
- public long getId() {
- return this.id;
- }
-
- public Long getVmId() {
- return this.vmId;
- }
-
- public void setVmId(Long vmId) {
- this.vmId = vmId;
- }
-
- public String getSignature() {
- return this.signature;
- }
-
- public void setSignature(String sig) {
- this.signature = sig;
- }
-
- public Long getSeqNum() {
- return this.seqNum;
- }
-
- public void setSeqNum(Long seqNum) {
- this.seqNum = seqNum;
- }
-
- public String getRuleSet() {
- return this.ruleSet;
- }
-
- public void setRuleSet(String ruleset) {
- this.ruleSet = ruleset;
- }
-}