Merge branch '3.0.x' of ssh://git.cloud.com/var/lib/git/cloudstack-oss into 3.0.x

This commit is contained in:
Vijayendra Bhamidipati 2012-07-27 15:11:14 -07:00
commit b8211728e1
7 changed files with 39 additions and 42 deletions

View File

@ -13,19 +13,14 @@
package com.cloud.agent.api;
import com.cloud.agent.api.to.NicTO;
import com.cloud.agent.api.to.VirtualMachineTO;
/**
* @author Alena Prokharchyk
*/
public class PlugNicCommand extends Command {
VirtualMachineTO vm;
NicTO nic;
public VirtualMachineTO getVirtualMachine() {
return vm;
}
NicTO nic;
String instanceName;
public NicTO getNic() {
return nic;
@ -39,9 +34,12 @@ public class PlugNicCommand extends Command {
protected PlugNicCommand() {
}
public PlugNicCommand(VirtualMachineTO vm, NicTO nic) {
this.vm = vm;
public PlugNicCommand(NicTO nic, String instanceName) {
this.nic = nic;
this.instanceName = instanceName;
}
public String getVmName() {
return instanceName;
}
}

View File

@ -13,18 +13,13 @@
package com.cloud.agent.api;
import com.cloud.agent.api.to.NicTO;
import com.cloud.agent.api.to.VirtualMachineTO;
/**
* @author Alena Prokharchyk
*/
public class UnPlugNicCommand extends Command{
VirtualMachineTO vm;
NicTO nic;
public VirtualMachineTO getVirtualMachine() {
return vm;
}
String instanceName;
public NicTO getNic() {
return nic;
@ -38,8 +33,12 @@ public class UnPlugNicCommand extends Command{
protected UnPlugNicCommand() {
}
public UnPlugNicCommand(VirtualMachineTO vm, NicTO nic) {
this.vm = vm;
public UnPlugNicCommand(NicTO nic, String instanceName) {
this.nic = nic;
this.instanceName = instanceName;
}
public String getInstanceName() {
return instanceName;
}
}

View File

@ -1105,7 +1105,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
try {
VmwareHypervisorHost hyperHost = getHyperHost(context);
String vmName = cmd.getVirtualMachine().getName();
String vmName = cmd.getVmName();
VirtualMachineMO vmMo = hyperHost.findVmOnHyperHost(vmName);
if(vmMo == null) {
@ -1179,7 +1179,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
try {
VmwareHypervisorHost hyperHost = getHyperHost(context);
String vmName = cmd.getVirtualMachine().getName();
String vmName = cmd.getInstanceName();
VirtualMachineMO vmMo = hyperHost.findVmOnHyperHost(vmName);
if(vmMo == null) {

View File

@ -7223,8 +7223,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
*/
private UnPlugNicAnswer execute(UnPlugNicCommand cmd) {
Connection conn = getConnection();
VirtualMachineTO vmto = cmd.getVirtualMachine();
String vmName = vmto.getName();
String vmName = cmd.getInstanceName();
try {
Set<VM> vms = VM.getByNameLabel(conn, vmName);
if ( vms == null || vms.isEmpty() ) {
@ -7259,8 +7258,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
*/
private PlugNicAnswer execute(PlugNicCommand cmd) {
Connection conn = getConnection();
VirtualMachineTO vmto = cmd.getVirtualMachine();
String vmName = vmto.getName();
String vmName = cmd.getVmName();
try {
Set<VM> vms = VM.getByNameLabel(conn, vmName);
if ( vms == null || vms.isEmpty() ) {

View File

@ -3400,9 +3400,10 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
sc.addAnd("systemOnly", SearchCriteria.Op.EQ, false);
// if networkId is specified, list offerings available for upgrade only (for this network)
Network network = null;
if (networkId != null) {
// check if network exists and the caller can operate with it
Network network = _networkMgr.getNetwork(networkId);
network = _networkMgr.getNetwork(networkId);
if (network == null) {
throw new InvalidParameterValueException("Unable to find the network by id", null);
}
@ -3462,7 +3463,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
boolean listBySupportedServices = (supportedServicesStr != null && !supportedServicesStr.isEmpty() && !offerings.isEmpty());
boolean checkIfProvidersAreEnabled = (zoneId != null);
boolean parseOfferings = (listBySupportedServices || sourceNatSupported != null || checkIfProvidersAreEnabled
|| forVpc != null);
|| forVpc != null || network != null);
if (parseOfferings) {
List<NetworkOfferingVO> supportedOfferings = new ArrayList<NetworkOfferingVO>();
@ -3511,7 +3512,9 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
}
if (forVpc != null) {
addOffering = addOffering && (isOfferingForVpc(offering) == forVpc.booleanValue());
addOffering = addOffering && (isOfferingForVpc(offering) == forVpc.booleanValue());
} else if (network != null){
addOffering = addOffering && (isOfferingForVpc(offering) == (network.getVpcId() != null));
}
if (addOffering) {

View File

@ -2528,17 +2528,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
_nicDao.expunge(nic.getId());
}
}
private String getCidrAddress(String cidr) {
String[] cidrPair = cidr.split("\\/");
return cidrPair[0];
}
private int getCidrSize(String cidr) {
String[] cidrPair = cidr.split("\\/");
return Integer.parseInt(cidrPair[1]);
}
@Override
public void checkVirtualNetworkCidrOverlap(Long zoneId, String cidr) {
if (zoneId == null) {
@ -4677,6 +4668,14 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
idList.add(new IdentityProxy(networkOffering, networkOfferingId, "networkOfferingId"));
throw new InvalidParameterValueException("Network offering with specified id is not in " + NetworkOffering.State.Enabled + " state, can't upgrade to it", idList);
}
//can't update from vpc to non-vpc network offering
boolean forVpcNew = _configMgr.isOfferingForVpc(networkOffering);
boolean vorVpcOriginal = _configMgr.isOfferingForVpc(_configMgr.getNetworkOffering(oldNetworkOfferingId));
if (forVpcNew != vorVpcOriginal) {
String errMsg = forVpcNew ? "a vpc offering " : "not a vpc offering";
throw new InvalidParameterValueException("Can't update as the new offering is " + errMsg);
}
//perform below validation if the network is vpc network
if (network.getVpcId() != null) {
@ -4739,7 +4738,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
ReservationContext context = new ReservationContextImpl(null, null, callerUser, callerAccount);
// 1) Shutdown all the elements and cleanup all the rules. Don't allow to shutdown network in intermediate
// states - Shutdown and Implementing
// states - Shutdown and Implementing
boolean validStateToShutdown = (network.getState() == Network.State.Implemented || network.getState() == Network.State.Setup || network.getState() == Network.State.Allocated);
if (restartNetwork) {
if (validStateToShutdown) {

View File

@ -326,7 +326,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
DomainRouterVO router = _routerDao.findById(vm.getId());
if (router.getState() == State.Running) {
try {
PlugNicCommand plugNicCmd = new PlugNicCommand(vm, nic);
PlugNicCommand plugNicCmd = new PlugNicCommand(nic, vm.getName());
Commands cmds = new Commands(OnError.Stop);
cmds.addCommand("plugnic", plugNicCmd);
@ -361,7 +361,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
if (router.getState() == State.Running) {
try {
UnPlugNicCommand unplugNicCmd = new UnPlugNicCommand(vm, nic);
UnPlugNicCommand unplugNicCmd = new UnPlugNicCommand(nic, vm.getName());
Commands cmds = new Commands(OnError.Stop);
cmds.addCommand("unplugnic", unplugNicCmd);
_agentMgr.send(dest.getHost().getId(), cmds);
@ -794,7 +794,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
}
}
PlugNicCommand plugNicCmd = new PlugNicCommand(_itMgr.toVmTO(profile), getNicTO(router, publicNic.getNetworkId(), publicNic.getBroadcastUri().toString()));
PlugNicCommand plugNicCmd = new PlugNicCommand(getNicTO(router, publicNic.getNetworkId(), publicNic.getBroadcastUri().toString()), router.getInstanceName());
cmds.addCommand(plugNicCmd);
}
@ -807,7 +807,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
for (Pair<Nic, Network> nicNtwk : guestNics) {
Nic guestNic = nicNtwk.first();
//plug guest nic
PlugNicCommand plugNicCmd = new PlugNicCommand(_itMgr.toVmTO(profile), getNicTO(router, guestNic.getNetworkId(), null));
PlugNicCommand plugNicCmd = new PlugNicCommand(getNicTO(router, guestNic.getNetworkId(), null), router.getInstanceName());
cmds.addCommand(plugNicCmd);
if (!_networkMgr.isPrivateGateway(guestNic)) {