moved all agent commands to api.

This commit is contained in:
Alex Huang 2011-01-20 09:52:32 -08:00
parent 3a9d6884ce
commit 57def20cf6
159 changed files with 378 additions and 989 deletions

View File

@ -104,7 +104,6 @@ import com.cloud.agent.api.ManageSnapshotAnswer;
import com.cloud.agent.api.ManageSnapshotCommand;
import com.cloud.agent.api.MigrateAnswer;
import com.cloud.agent.api.MigrateCommand;
import com.cloud.agent.api.MirrorCommand;
import com.cloud.agent.api.ModifySshKeysCommand;
import com.cloud.agent.api.ModifyStoragePoolAnswer;
import com.cloud.agent.api.ModifyStoragePoolCommand;
@ -165,8 +164,8 @@ import com.cloud.agent.resource.virtualnetwork.VirtualRoutingResource;
import com.cloud.exception.InternalErrorException;
import com.cloud.host.Host.Type;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.network.NetworkEnums.RouterPrivateIpStrategy;
import com.cloud.network.Networks.BroadcastDomainType;
import com.cloud.network.Networks.RouterPrivateIpStrategy;
import com.cloud.network.Networks.TrafficType;
import com.cloud.resource.ServerResource;
import com.cloud.resource.ServerResourceBase;
@ -798,8 +797,6 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
return execute((GetHostStatsCommand)cmd);
} else if (cmd instanceof CheckStateCommand) {
return executeRequest(cmd);
} else if (cmd instanceof MirrorCommand) {
return executeRequest(cmd);
} else if (cmd instanceof CheckHealthCommand) {
return execute((CheckHealthCommand)cmd);
} else if (cmd instanceof PrepareForMigrationCommand) {
@ -887,7 +884,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
}
KVMHABase.NfsStoragePool sp = new KVMHABase.NfsStoragePool(cmd.getPool().getUuid(),
cmd.getPool().getHostAddress(),
cmd.getPool().getHost(),
cmd.getPool().getPath(),
_mountPoint + File.separator + cmd.getPool().getUuid(),
PoolType.PrimaryStorage);
@ -2220,8 +2217,9 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
return new StartAnswer(cmd);
} catch (Exception e) {
s_logger.warn("Exception ", e);
if (conn != null)
handleVmStartFailure(conn, vmName, vm);
if (conn != null) {
handleVmStartFailure(conn, vmName, vm);
}
return new StartAnswer(cmd, e.getMessage());
} finally {
synchronized (_vms) {

View File

@ -18,7 +18,7 @@
package com.cloud.agent.api;
import com.cloud.agent.api.to.HostTO;
import com.cloud.host.HostVO;
import com.cloud.host.Host;
public class CheckOnHostCommand extends Command {
HostTO host;
@ -27,7 +27,7 @@ public class CheckOnHostCommand extends Command {
}
public CheckOnHostCommand(HostVO host) {
public CheckOnHostCommand(Host host) {
this.host = new HostTO(host);
}

View File

@ -21,34 +21,34 @@ package com.cloud.agent.api;
import java.io.File;
import java.util.UUID;
import com.cloud.storage.StoragePoolVO;
import com.cloud.agent.api.to.StorageFilerTO;
import com.cloud.storage.StoragePool;
public class DeleteStoragePoolCommand extends Command {
StoragePoolVO pool;
StorageFilerTO pool;
public static final String LOCAL_PATH_PREFIX="/mnt/";
String localPath;
public DeleteStoragePoolCommand() {
}
public DeleteStoragePoolCommand(StoragePoolVO pool, String localPath) {
this.pool = new StoragePoolVO(pool);
public DeleteStoragePoolCommand(StoragePool pool, String localPath) {
this.pool = new StorageFilerTO(pool);
this.localPath = localPath;
}
public DeleteStoragePoolCommand(StoragePoolVO pool) {
this(new StoragePoolVO(pool), LOCAL_PATH_PREFIX + File.separator + UUID.nameUUIDFromBytes((pool.getHostAddress() + pool.getPath()).getBytes()));
public DeleteStoragePoolCommand(StoragePool pool) {
this(pool, LOCAL_PATH_PREFIX + File.separator + UUID.nameUUIDFromBytes((pool.getHostAddress() + pool.getPath()).getBytes()));
}
public StoragePoolVO getPool() {
public StorageFilerTO getPool() {
return pool;
}
public void setPool(StoragePoolVO pool) {
this.pool = new StoragePoolVO(pool);
public void setPool(StoragePool pool) {
this.pool = new StorageFilerTO(pool);
}
@Override

View File

@ -17,8 +17,8 @@
*/
package com.cloud.agent.api;
import com.cloud.host.HostVO;
import com.cloud.vm.VMInstanceVO;
import com.cloud.host.Host;
import com.cloud.vm.VirtualMachine;
public class FenceCommand extends Command {
@ -30,7 +30,7 @@ public class FenceCommand extends Command {
String hostGuid;
String hostIp;
public FenceCommand(VMInstanceVO vm, HostVO host) {
public FenceCommand(VirtualMachine vm, Host host) {
super();
vmName = vm.getInstanceName();
hostGuid = host.getGuid();

View File

@ -0,0 +1,48 @@
/**
* Copyright (C) 2010 Cloud.com. All rights reserved.
*
* This software is licensed under the GNU General Public License v3 or later.
*
* It is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or any later
version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.cloud.agent.api;
import java.util.HashMap;
import java.util.Map;
import com.cloud.host.Host;
import com.cloud.utils.Pair;
import com.cloud.vm.VirtualMachine.State;
public class PingRoutingWithNwGroupsCommand extends PingRoutingCommand {
HashMap<String, Pair<Long, Long>> newGroupStates;
protected PingRoutingWithNwGroupsCommand() {
super();
}
public PingRoutingWithNwGroupsCommand(Host.Type type, long id, Map<String, State> states, HashMap<String, Pair<Long, Long>> nwGrpStates) {
super(type, id, states);
newGroupStates = nwGrpStates;
}
public HashMap<String, Pair<Long, Long>> getNewGroupStates() {
return newGroupStates;
}
public void setNewGroupStates(HashMap<String, Pair<Long, Long>> newGroupStates) {
this.newGroupStates = newGroupStates;
}
}

View File

@ -17,10 +17,7 @@
*/
package com.cloud.agent.api;
import java.util.List;
import com.cloud.agent.api.to.VirtualMachineTO;
import com.cloud.storage.VolumeVO;
public class PrepareForMigrationCommand extends StartCommand {
@ -31,10 +28,6 @@ public class PrepareForMigrationCommand extends StartCommand {
super(vm);
}
public PrepareForMigrationCommand(String vmName, String vnet, String[] storageHosts, List<VolumeVO> vols, boolean mirrored) {
//super(vmName, storageHosts, vols, mirrored);
}
@Override
public boolean executeInSequence() {
return true;

View File

@ -18,74 +18,17 @@
package com.cloud.agent.api;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.apache.log4j.Logger;
import com.cloud.agent.transport.Request;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonArray;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonNull;
import com.google.gson.JsonParseException;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import com.google.gson.annotations.Expose;
import com.google.gson.reflect.TypeToken;
public class SecStorageFirewallCfgCommand extends Command {
private static final Logger s_logger = Logger.getLogger(SecStorageFirewallCfgCommand.class);
public static class PortConfigListTypeAdaptor implements JsonDeserializer<List<PortConfig>>, JsonSerializer<List<PortConfig>> {
static final GsonBuilder s_gBuilder;
static {
s_gBuilder = Request.initBuilder();
}
static final Type listType = new TypeToken<List<PortConfig>>() {}.getType();
public PortConfigListTypeAdaptor() {
}
public JsonElement serialize(List<PortConfig> src, Type typeOfSrc, JsonSerializationContext context) {
if (src.size() == 0) {
s_logger.info("Returning JsonNull");
return new JsonNull();
}
Gson json = s_gBuilder.create();
s_logger.debug("Returning gson tree");
JsonArray array = new JsonArray();
for (PortConfig pc : src) {
array.add(json.toJsonTree(pc));
}
return array;
}
public List<PortConfig> deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
throws JsonParseException {
if (json.isJsonNull()) {
return new ArrayList<PortConfig>();
}
Gson jsonp = s_gBuilder.create();
List<PortConfig> pcs = new ArrayList<PortConfig>();
JsonArray array = json.getAsJsonArray();
Iterator<JsonElement> it = array.iterator();
while (it.hasNext()) {
JsonElement element = it.next();
pcs.add(jsonp.fromJson(element, PortConfig.class));
}
return pcs;
}
}
public static class PortConfig {
@Expose boolean add;
@Expose String sourceIp;

View File

@ -20,7 +20,7 @@ import java.util.HashMap;
import java.util.Map;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.network.NetworkEnums.RouterPrivateIpStrategy;
import com.cloud.network.Networks.RouterPrivateIpStrategy;
import com.cloud.vm.VirtualMachine.State;
public class StartupRoutingCommand extends StartupCommand {

Some files were not shown because too many files have changed in this diff Show More