mirror of https://github.com/apache/cloudstack.git
Merge branch 'master' into ui-restyle
This commit is contained in:
commit
06ccb8473e
|
|
@ -1,4 +1,4 @@
|
|||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
G# 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
|
||||
|
|
@ -83,3 +83,5 @@ build-indep-stamp
|
|||
configure-stamp
|
||||
*_flymake.js
|
||||
engine/storage/integration-test/test-output
|
||||
tools/apidoc/log/
|
||||
log/
|
||||
|
|
|
|||
|
|
@ -169,7 +169,7 @@ public class DummyResource implements ServerResource {
|
|||
final 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.KVM,
|
||||
RouterPrivateIpStrategy.HostLocal, changes);
|
||||
RouterPrivateIpStrategy.HostLocal, changes, null);
|
||||
fillNetworkInformation(cmd);
|
||||
cmd.getHostDetails().putAll(getVersionStrings());
|
||||
cmd.setCluster(getConfiguredProperty("cluster", "1"));
|
||||
|
|
|
|||
|
|
@ -19,16 +19,29 @@ package com.cloud.agent.api;
|
|||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.VirtualMachine.PowerState;
|
||||
|
||||
//
|
||||
// TODO vmsync
|
||||
// We should also have a HostVmStateReport class instead of using raw Map<> data structure,
|
||||
// for now, we store host-specific info at each VM entry and host fields are fixed
|
||||
//
|
||||
// This needs to be refactor-ed afterwards
|
||||
//
|
||||
public class HostVmStateReportEntry {
|
||||
VirtualMachine.PowerState state;
|
||||
|
||||
// host name or host uuid
|
||||
String host;
|
||||
|
||||
// XS needs Xen Tools version info
|
||||
String hostToolsVersion;
|
||||
|
||||
public HostVmStateReportEntry() {
|
||||
}
|
||||
|
||||
public HostVmStateReportEntry(PowerState state, String host) {
|
||||
public HostVmStateReportEntry(PowerState state, String host, String hostToolsVersion) {
|
||||
this.state = state;
|
||||
this.host = host;
|
||||
this.hostToolsVersion = hostToolsVersion;
|
||||
}
|
||||
|
||||
public PowerState getState() {
|
||||
|
|
@ -38,4 +51,8 @@ public class HostVmStateReportEntry {
|
|||
public String getHost() {
|
||||
return host;
|
||||
}
|
||||
|
||||
public String getHostToolsVersion() {
|
||||
return hostToolsVersion;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,10 +20,20 @@ import java.util.List;
|
|||
|
||||
import com.cloud.exception.InsufficientServerCapacityException;
|
||||
import com.cloud.vm.VirtualMachineProfile;
|
||||
import org.apache.cloudstack.framework.config.ConfigKey;
|
||||
|
||||
/**
|
||||
*/
|
||||
public interface DeploymentClusterPlanner extends DeploymentPlanner {
|
||||
|
||||
static final String ClusterCPUCapacityDisableThresholdCK = "cluster.cpu.allocated.capacity.disablethreshold";
|
||||
static final String ClusterMemoryCapacityDisableThresholdCK = "cluster.memory.allocated.capacity.disablethreshold";
|
||||
|
||||
static final ConfigKey<Float> ClusterCPUCapacityDisableThreshold = new ConfigKey<Float>(Float.class, ClusterCPUCapacityDisableThresholdCK, "Alert", "0.85",
|
||||
"Percentage (as a value between 0 and 1) of cpu utilization above which allocators will disable using the cluster for low cpu available. Keep the corresponding notification threshold lower than this to be notified beforehand.", true, ConfigKey.Scope.Cluster, null);
|
||||
static final ConfigKey<Float> ClusterMemoryCapacityDisableThreshold = new ConfigKey<Float>(Float.class, ClusterMemoryCapacityDisableThresholdCK, "Alert", "0.85",
|
||||
"Percentage (as a value between 0 and 1) of memory utilization above which allocators will disable using the cluster for low memory available. Keep the corresponding notification threshold lower than this to be notified beforehand.", true, ConfigKey.Scope.Cluster, null);
|
||||
|
||||
/**
|
||||
* This is called to determine list of possible clusters where a virtual
|
||||
* machine can be deployed.
|
||||
|
|
|
|||
|
|
@ -1,3 +1,19 @@
|
|||
// 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.network.lb;
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -31,17 +31,17 @@ public interface ResourceTag extends ControlledEntity, Identity, InternalIdentit
|
|||
Snapshot (true, false),
|
||||
Network (true, true),
|
||||
Nic (false, true),
|
||||
LoadBalancer (true, false),
|
||||
PortForwardingRule (true, false),
|
||||
LoadBalancer (true, true),
|
||||
PortForwardingRule (true, true),
|
||||
FirewallRule (true, true),
|
||||
SecurityGroup (true, false),
|
||||
PublicIpAddress (true, false),
|
||||
PublicIpAddress (true, true),
|
||||
Project (true, false),
|
||||
Vpc (true, false),
|
||||
NetworkACL (true, false),
|
||||
StaticRoute (true, false),
|
||||
VMSnapshot (true, false),
|
||||
RemoteAccessVpn (true, false),
|
||||
RemoteAccessVpn (true, true),
|
||||
Zone (false, true),
|
||||
ServiceOffering (false, true),
|
||||
Storage(false, true);
|
||||
|
|
|
|||
|
|
@ -223,6 +223,7 @@ public class ApiConstants {
|
|||
public static final String STATUS = "status";
|
||||
public static final String STORAGE_TYPE = "storagetype";
|
||||
public static final String STORAGE_MOTION_ENABLED = "storagemotionenabled";
|
||||
public static final String STORAGE_CAPABILITIES = "storagecapabilities";
|
||||
public static final String SYSTEM_VM_TYPE = "systemvmtype";
|
||||
public static final String TAGS = "tags";
|
||||
public static final String TARGET_IQN = "targetiqn";
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import org.apache.cloudstack.api.response.FirewallResponse;
|
|||
import org.apache.cloudstack.api.response.FirewallRuleResponse;
|
||||
import org.apache.cloudstack.api.response.IPAddressResponse;
|
||||
import org.apache.cloudstack.api.response.ListResponse;
|
||||
import org.apache.cloudstack.api.response.NetworkResponse;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.network.rules.FirewallRule;
|
||||
|
|
@ -47,6 +48,10 @@ public class ListFirewallRulesCmd extends BaseListTaggedResourcesCmd {
|
|||
@Parameter(name=ApiConstants.IP_ADDRESS_ID, type=CommandType.UUID, entityType = IPAddressResponse.class,
|
||||
description="the id of IP address of the firwall services")
|
||||
private Long ipAddressId;
|
||||
|
||||
@Parameter(name=ApiConstants.NETWORK_ID, type=CommandType.UUID, entityType = NetworkResponse.class,
|
||||
description="list firewall rules for ceratin network", since="4.3")
|
||||
private Long networkId;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
|
|
@ -63,6 +68,10 @@ public class ListFirewallRulesCmd extends BaseListTaggedResourcesCmd {
|
|||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public Long getNetworkId() {
|
||||
return networkId;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import org.apache.cloudstack.api.Parameter;
|
|||
import org.apache.cloudstack.api.response.FirewallRuleResponse;
|
||||
import org.apache.cloudstack.api.response.IPAddressResponse;
|
||||
import org.apache.cloudstack.api.response.ListResponse;
|
||||
import org.apache.cloudstack.api.response.NetworkResponse;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.network.rules.PortForwardingRule;
|
||||
|
|
@ -48,6 +49,10 @@ public class ListPortForwardingRulesCmd extends BaseListTaggedResourcesCmd {
|
|||
@Parameter(name=ApiConstants.IP_ADDRESS_ID, type=CommandType.UUID, entityType = IPAddressResponse.class,
|
||||
description="the id of IP address of the port forwarding services")
|
||||
private Long ipAddressId;
|
||||
|
||||
@Parameter(name=ApiConstants.NETWORK_ID, type=CommandType.UUID, entityType = NetworkResponse.class,
|
||||
description="list port forwarding rules for ceratin network", since="4.3")
|
||||
private Long networkId;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
|
|
@ -60,6 +65,10 @@ public class ListPortForwardingRulesCmd extends BaseListTaggedResourcesCmd {
|
|||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public Long getNetworkId() {
|
||||
return networkId;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import org.apache.cloudstack.api.BaseListProjectAndAccountResourcesCmd;
|
|||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.response.IPAddressResponse;
|
||||
import org.apache.cloudstack.api.response.ListResponse;
|
||||
import org.apache.cloudstack.api.response.NetworkResponse;
|
||||
import org.apache.cloudstack.api.response.RemoteAccessVpnResponse;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
|
|
@ -41,8 +42,16 @@ public class ListRemoteAccessVpnsCmd extends BaseListProjectAndAccountResourcesC
|
|||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@Parameter(name=ApiConstants.PUBLIC_IP_ID, type=CommandType.UUID, entityType=IPAddressResponse.class,
|
||||
required=true, description="public ip address id of the vpn server")
|
||||
description="public ip address id of the vpn server")
|
||||
private Long publicIpId;
|
||||
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType = RemoteAccessVpnResponse.class,
|
||||
description="Lists remote access vpn rule with the specified ID", since="4.3")
|
||||
private Long id;
|
||||
|
||||
@Parameter(name=ApiConstants.NETWORK_ID, type=CommandType.UUID, entityType = NetworkResponse.class,
|
||||
description="list remote access VPNs for ceratin network", since="4.3")
|
||||
private Long networkId;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
|
|
@ -52,6 +61,14 @@ public class ListRemoteAccessVpnsCmd extends BaseListProjectAndAccountResourcesC
|
|||
public Long getPublicIpId() {
|
||||
return publicIpId;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public Long getNetworkId() {
|
||||
return networkId;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
|
|
|
|||
|
|
@ -73,6 +73,9 @@ public class FirewallRuleResponse extends BaseResponse {
|
|||
|
||||
@SerializedName(ApiConstants.VM_GUEST_IP) @Param(description="the vm ip address for the port forwarding rule")
|
||||
private String destNatVmIp;
|
||||
|
||||
@SerializedName(ApiConstants.NETWORK_ID) @Param(description="the id of the guest network the port forwarding rule belongs to")
|
||||
private String networkId;
|
||||
|
||||
|
||||
public String getDestNatVmIp() {
|
||||
|
|
@ -196,4 +199,8 @@ public class FirewallRuleResponse extends BaseResponse {
|
|||
public void setTags(List<ResourceTagResponse> tags) {
|
||||
this.tags = tags;
|
||||
}
|
||||
|
||||
public void setNetworkId(String networkId) {
|
||||
this.networkId = networkId;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import org.apache.cloudstack.api.BaseResponse;
|
|||
import org.apache.cloudstack.api.EntityReference;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
@EntityReference(value=StoragePool.class)
|
||||
public class StoragePoolResponse extends BaseResponse {
|
||||
|
|
@ -93,6 +94,16 @@ public class StoragePoolResponse extends BaseResponse {
|
|||
" false otherwise")
|
||||
private Boolean suitableForMigration;
|
||||
|
||||
@SerializedName(ApiConstants.STORAGE_CAPABILITIES) @Param(description="the storage pool capabilities")
|
||||
private Map<String, String> caps;
|
||||
|
||||
public Map<String, String> getCaps() {
|
||||
return caps;
|
||||
}
|
||||
|
||||
public void setCaps(Map<String, String> cap) {
|
||||
this.caps = cap;
|
||||
}
|
||||
/**
|
||||
* @return the scope
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -85,6 +85,7 @@ db.simulator.autoReconnect=true
|
|||
|
||||
# High Availability And Cluster Properties
|
||||
db.ha.enabled=false
|
||||
db.ha.loadBalanceStrategy=com.cloud.utils.db.StaticStrategy
|
||||
# cloud stack Database
|
||||
db.cloud.slaves=localhost,localhost
|
||||
db.cloud.autoReconnect=true
|
||||
|
|
|
|||
|
|
@ -213,6 +213,16 @@
|
|||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="remoteAccessVPNServiceProviderRegistry"
|
||||
class="org.apache.cloudstack.spring.lifecycle.registry.ExtensionRegistry">
|
||||
<property name="excludeKey" value="remote.access.vpn.service.provider.exclude" />
|
||||
<property name="preRegistered">
|
||||
<list>
|
||||
<ref bean="VpcVirtualRouter" />
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="affinityProcessorsRegistry"
|
||||
class="org.apache.cloudstack.spring.lifecycle.registry.ExtensionRegistry">
|
||||
|
|
|
|||
|
|
@ -90,5 +90,11 @@
|
|||
<property name="typeClass"
|
||||
value="com.cloud.network.element.Site2SiteVpnServiceProvider" />
|
||||
</bean>
|
||||
|
||||
<bean class="org.apache.cloudstack.spring.lifecycle.registry.RegistryLifecycle">
|
||||
<property name="registry" ref="remoteAccessVPNServiceProviderRegistry" />
|
||||
<property name="typeClass"
|
||||
value="com.cloud.network.element.RemoteAccessVPNServiceProvider" />
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
|
|
@ -22,21 +22,33 @@ import com.cloud.host.Host;
|
|||
import com.cloud.vm.VirtualMachine.State;
|
||||
|
||||
public class PingRoutingCommand extends PingCommand {
|
||||
Map<String, State> newStates;
|
||||
|
||||
// TODO vmsync {
|
||||
Map<String, State> newStates;
|
||||
// TODO vmsync }
|
||||
|
||||
Map<String, HostVmStateReportEntry> _hostVmStateReport;
|
||||
|
||||
boolean _gatewayAccessible = true;
|
||||
boolean _vnetAccessible = true;
|
||||
|
||||
protected PingRoutingCommand() {
|
||||
}
|
||||
|
||||
public PingRoutingCommand(Host.Type type, long id, Map<String, State> states) {
|
||||
public PingRoutingCommand(Host.Type type, long id, Map<String, State> states,
|
||||
Map<String, HostVmStateReportEntry> hostVmStateReport) {
|
||||
super(type, id);
|
||||
this.newStates = states;
|
||||
this._hostVmStateReport = hostVmStateReport;
|
||||
}
|
||||
|
||||
public Map<String, State> getNewStates() {
|
||||
return newStates;
|
||||
}
|
||||
|
||||
public Map<String, HostVmStateReportEntry> getHostVmStateReport() {
|
||||
return this._hostVmStateReport;
|
||||
}
|
||||
|
||||
public boolean isGatewayAccessible() {
|
||||
return _gatewayAccessible;
|
||||
|
|
|
|||
|
|
@ -31,8 +31,10 @@ public class PingRoutingWithNwGroupsCommand extends PingRoutingCommand {
|
|||
super();
|
||||
}
|
||||
|
||||
public PingRoutingWithNwGroupsCommand(Host.Type type, long id, Map<String, State> states, HashMap<String, Pair<Long, Long>> nwGrpStates) {
|
||||
super(type, id, states);
|
||||
public PingRoutingWithNwGroupsCommand(Host.Type type, long id,
|
||||
Map<String, State> states, Map<String, HostVmStateReportEntry> hostVmStateReport,
|
||||
HashMap<String, Pair<Long, Long>> nwGrpStates) {
|
||||
super(type, id, states, hostVmStateReport);
|
||||
newGroupStates = nwGrpStates;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,8 +31,10 @@ public class PingRoutingWithOvsCommand extends PingRoutingCommand {
|
|||
}
|
||||
|
||||
public PingRoutingWithOvsCommand(Host.Type type, long id,
|
||||
Map<String, State> states, List<Pair<String, Long>> ovsStates) {
|
||||
super(type, id, states);
|
||||
Map<String, State> states, Map<String, HostVmStateReportEntry> hostVmStateReport,
|
||||
List<Pair<String, Long>> ovsStates) {
|
||||
super(type, id, states, hostVmStateReport);
|
||||
|
||||
this.states = ovsStates;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -48,8 +48,18 @@ public class StartupRoutingCommand extends StartupCommand {
|
|||
long memory;
|
||||
long dom0MinMemory;
|
||||
boolean poolSync;
|
||||
|
||||
// VM power state report is added in a side-by-side way as old VM state report
|
||||
// this is to allow a graceful migration from the old VM state sync model to the new model
|
||||
//
|
||||
// side-by-side addition of power state sync
|
||||
Map<String, HostVmStateReportEntry> _hostVmStateReport;
|
||||
|
||||
// TODO vmsync
|
||||
// deprecated, will delete after full replacement
|
||||
Map<String, VmState> vms;
|
||||
HashMap<String, Ternary<String, State, String>> _clusterVMStates;
|
||||
|
||||
String caps;
|
||||
String pool;
|
||||
HypervisorType hypervisorType;
|
||||
|
|
@ -70,8 +80,10 @@ public class StartupRoutingCommand extends StartupCommand {
|
|||
String caps,
|
||||
HypervisorType hypervisorType,
|
||||
RouterPrivateIpStrategy privIpStrategy,
|
||||
Map<String, VmState> vms) {
|
||||
this(cpus, speed, memory, dom0MinMemory, caps, hypervisorType, vms);
|
||||
Map<String, VmState> vms,
|
||||
Map<String, HostVmStateReportEntry> hostVmStateReport
|
||||
) {
|
||||
this(cpus, speed, memory, dom0MinMemory, caps, hypervisorType, vms, hostVmStateReport);
|
||||
getHostDetails().put(RouterPrivateIpStrategy.class.getCanonicalName(), privIpStrategy.toString());
|
||||
}
|
||||
|
||||
|
|
@ -82,9 +94,11 @@ public class StartupRoutingCommand extends StartupCommand {
|
|||
String caps,
|
||||
HypervisorType hypervisorType,
|
||||
RouterPrivateIpStrategy privIpStrategy) {
|
||||
this(cpus, speed, memory, dom0MinMemory, caps, hypervisorType, new HashMap<String,String>(), new HashMap<String, VmState>());
|
||||
getHostDetails().put(RouterPrivateIpStrategy.class.getCanonicalName(), privIpStrategy.toString());
|
||||
}
|
||||
this(cpus, speed, memory, dom0MinMemory, caps, hypervisorType, new HashMap<String,String>(),
|
||||
new HashMap<String, VmState>(), new HashMap<String, HostVmStateReportEntry>());
|
||||
|
||||
getHostDetails().put(RouterPrivateIpStrategy.class.getCanonicalName(), privIpStrategy.toString());
|
||||
}
|
||||
|
||||
public StartupRoutingCommand(int cpus,
|
||||
long speed,
|
||||
|
|
@ -93,13 +107,15 @@ getHostDetails().put(RouterPrivateIpStrategy.class.getCanonicalName(), privIpStr
|
|||
final String caps,
|
||||
final HypervisorType hypervisorType,
|
||||
final Map<String, String> hostDetails,
|
||||
Map<String, VmState> vms) {
|
||||
Map<String, VmState> vms,
|
||||
Map<String, HostVmStateReportEntry> hostVmStateReport) {
|
||||
super(Host.Type.Routing);
|
||||
this.cpus = cpus;
|
||||
this.speed = speed;
|
||||
this.memory = memory;
|
||||
this.dom0MinMemory = dom0MinMemory;
|
||||
this.vms = vms;
|
||||
this._hostVmStateReport = hostVmStateReport;
|
||||
this.hypervisorType = hypervisorType;
|
||||
this.hostDetails = hostDetails;
|
||||
this.caps = caps;
|
||||
|
|
@ -108,12 +124,14 @@ getHostDetails().put(RouterPrivateIpStrategy.class.getCanonicalName(), privIpStr
|
|||
|
||||
public StartupRoutingCommand(int cpus2, long speed2, long memory2,
|
||||
long dom0MinMemory2, String caps2, HypervisorType hypervisorType2,
|
||||
Map<String, VmState> vms2) {
|
||||
this(cpus2, speed2, memory2, dom0MinMemory2, caps2, hypervisorType2, new HashMap<String,String>(), vms2);
|
||||
Map<String, VmState> vms2, Map<String, HostVmStateReportEntry> hostVmStateReport
|
||||
) {
|
||||
this(cpus2, speed2, memory2, dom0MinMemory2, caps2, hypervisorType2, new HashMap<String,String>(), vms2, hostVmStateReport);
|
||||
}
|
||||
|
||||
public StartupRoutingCommand(int cpus, long speed, long memory, long dom0MinMemory, final String caps, final HypervisorType hypervisorType, final Map<String, String> hostDetails, Map<String, VmState> vms, String hypervisorVersion) {
|
||||
this(cpus, speed, memory, dom0MinMemory, caps, hypervisorType, hostDetails, vms);
|
||||
public StartupRoutingCommand(int cpus, long speed, long memory, long dom0MinMemory, final String caps, final HypervisorType hypervisorType, final Map<String, String> hostDetails,
|
||||
Map<String, VmState> vms, Map<String, HostVmStateReportEntry> vmPowerStates, String hypervisorVersion) {
|
||||
this(cpus, speed, memory, dom0MinMemory, caps, hypervisorType, hostDetails, vms, vmPowerStates);
|
||||
this.hypervisorVersion = hypervisorVersion;
|
||||
}
|
||||
|
||||
|
|
@ -229,5 +247,13 @@ getHostDetails().put(RouterPrivateIpStrategy.class.getCanonicalName(), privIpStr
|
|||
public void setHypervisorVersion(String hypervisorVersion) {
|
||||
this.hypervisorVersion = hypervisorVersion;
|
||||
}
|
||||
|
||||
public Map<String, HostVmStateReportEntry> getHostVmStateReport() {
|
||||
return this._hostVmStateReport;
|
||||
}
|
||||
|
||||
public void setHostVmStateReport(Map<String, HostVmStateReportEntry> hostVmStateReport) {
|
||||
this._hostVmStateReport = hostVmStateReport;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ public class VMSnapshotTO {
|
|||
private String description;
|
||||
private VMSnapshotTO parent;
|
||||
private List<VolumeObjectTO> volumes;
|
||||
private boolean quiescevm;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
|
|
@ -40,7 +41,8 @@ public class VMSnapshotTO {
|
|||
}
|
||||
public VMSnapshotTO(Long id, String snapshotName,
|
||||
VMSnapshot.Type type, Long createTime,
|
||||
String description, Boolean current, VMSnapshotTO parent) {
|
||||
String description, Boolean current, VMSnapshotTO parent,
|
||||
boolean quiescevm) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.snapshotName = snapshotName;
|
||||
|
|
@ -49,9 +51,10 @@ public class VMSnapshotTO {
|
|||
this.current = current;
|
||||
this.description = description;
|
||||
this.parent = parent;
|
||||
this.quiescevm = quiescevm;
|
||||
}
|
||||
public VMSnapshotTO() {
|
||||
|
||||
this.quiescevm = true;
|
||||
}
|
||||
public String getDescription() {
|
||||
return description;
|
||||
|
|
@ -99,4 +102,12 @@ public class VMSnapshotTO {
|
|||
public void setVolumes(List<VolumeObjectTO> volumes) {
|
||||
this.volumes = volumes;
|
||||
}
|
||||
|
||||
public boolean getQuiescevm() {
|
||||
return this.quiescevm;
|
||||
}
|
||||
|
||||
public void setQuiescevm(boolean quiescevm) {
|
||||
this.quiescevm = quiescevm;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@
|
|||
|
||||
/etc/cloudstack/management/catalina.policy
|
||||
/etc/cloudstack/management/catalina.properties
|
||||
/etc/cloudstack/management/cloudmanagementserver.keystore
|
||||
/etc/cloudstack/management/logging.properties
|
||||
/etc/cloudstack/management/commands.properties
|
||||
/etc/cloudstack/management/ehcache.xml
|
||||
|
|
|
|||
|
|
@ -201,6 +201,7 @@
|
|||
<!-- simulator sql files -->
|
||||
<argument>${basedir}/target/db/create-schema-simulator.sql</argument>
|
||||
<argument>${basedir}/target/db/templates.simulator.sql</argument>
|
||||
<argument>${basedir}/target/db/hypervisor_capabilities.simulator.sql</argument>
|
||||
<!-- upgrade -->
|
||||
<argument>com.cloud.upgrade.DatabaseUpgradeChecker</argument>
|
||||
<argument>--database=simulator</argument>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* 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 org.apache.cloudstack.engine.subsystem.api.storage;
|
||||
|
||||
public enum DataStoreCapabilities {
|
||||
VOLUME_SNAPSHOT_QUIESCEVM
|
||||
}
|
||||
|
|
@ -23,7 +23,10 @@ import com.cloud.agent.api.to.DataTO;
|
|||
import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
|
||||
import org.apache.cloudstack.storage.command.CommandResult;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface DataStoreDriver {
|
||||
Map<String, String> getCapabilities();
|
||||
DataTO getTO(DataObject data);
|
||||
DataStoreTO getStoreTO(DataStore store);
|
||||
void createAsync(DataStore store, DataObject data, AsyncCompletionCallback<CreateCmdResult> callback);
|
||||
|
|
|
|||
|
|
@ -258,7 +258,7 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl
|
|||
_creationMonitors.add(0, new Pair<Integer, StartupCommandProcessor>(
|
||||
_monitorId, creator));
|
||||
} else {
|
||||
_creationMonitors.add(0, new Pair<Integer, StartupCommandProcessor>(
|
||||
_creationMonitors.add(new Pair<Integer, StartupCommandProcessor>(
|
||||
_monitorId, creator));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -738,6 +738,16 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati
|
|||
} catch (NoTransitionException e) {
|
||||
s_logger.debug("Unable to destroy existing volume: " + e.toString());
|
||||
}
|
||||
// In case of VMware VM will continue to use the old root disk until expunged, so force expunge old root disk
|
||||
if (vm.getHypervisorType() == HypervisorType.VMware) {
|
||||
s_logger.info("Expunging volume " + existingVolume.getId() + " from primary data store");
|
||||
AsyncCallFuture<VolumeApiResult> future = volService.expungeVolumeAsync(volFactory.getVolume(existingVolume.getId()));
|
||||
try {
|
||||
future.get();
|
||||
} catch (Exception e) {
|
||||
s_logger.debug("Failed to expunge volume:" + existingVolume.getId(), e);
|
||||
}
|
||||
}
|
||||
|
||||
return newVolume;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -321,6 +321,8 @@
|
|||
<bean id="AffinityGroupVMMapDaoImpl" class="org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDaoImpl" />
|
||||
<bean id="AffinityGroupDomainMapDaoImpl" class="org.apache.cloudstack.affinity.dao.AffinityGroupDomainMapDaoImpl" />
|
||||
<bean id="FirewallRuleDetailsDaoImpl" class="org.apache.cloudstack.resourcedetail.dao.FirewallRuleDetailsDaoImpl" />
|
||||
<bean id="UserIpAddressDetailsDaoImpl" class="org.apache.cloudstack.resourcedetail.dao.UserIpAddressDetailsDaoImpl" />
|
||||
<bean id="RemoteAccessVpnDetailsDaoImpl" class="org.apache.cloudstack.resourcedetail.dao.RemoteAccessVpnDetailsDaoImpl" />
|
||||
|
||||
<bean id="databaseIntegrityChecker" class="com.cloud.upgrade.DatabaseIntegrityChecker" />
|
||||
|
||||
|
|
|
|||
|
|
@ -189,7 +189,7 @@ public class NetworkVO implements Network {
|
|||
this.dataCenterId = dataCenterId;
|
||||
this.physicalNetworkId = physicalNetworkId;
|
||||
if (state == null) {
|
||||
state = State.Allocated;
|
||||
this.state = State.Allocated;
|
||||
} else {
|
||||
this.state = state;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,19 @@
|
|||
// 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.network.dao;
|
||||
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* 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.storage.dao;
|
||||
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
import org.apache.cloudstack.resourcedetail.ResourceDetailsDao;
|
||||
|
||||
public interface SnapshotDetailsDao extends GenericDao<SnapshotDetailsVO, Long>, ResourceDetailsDao<SnapshotDetailsVO> {
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* 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.storage.dao;
|
||||
|
||||
import org.apache.cloudstack.resourcedetail.ResourceDetailsDaoBase;
|
||||
|
||||
public class SnapshotDetailsDaoImpl extends ResourceDetailsDaoBase<SnapshotDetailsVO> implements SnapshotDetailsDao {
|
||||
@Override
|
||||
public void addDetail(long resourceId, String key, String value) {
|
||||
super.addDetail(new SnapshotDetailsVO(resourceId, key, value));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
* 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.storage.dao;
|
||||
|
||||
import org.apache.cloudstack.api.ResourceDetail;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
||||
@Entity
|
||||
@Table(name = "snapshot_details")
|
||||
public class SnapshotDetailsVO implements ResourceDetail {
|
||||
@Id
|
||||
@GeneratedValue(strategy= GenerationType.IDENTITY)
|
||||
@Column(name = "id")
|
||||
private long id;
|
||||
|
||||
@Column(name = "snapshot_id")
|
||||
private long resourceId;
|
||||
|
||||
@Column(name = "name")
|
||||
String name;
|
||||
|
||||
@Column(name = "value")
|
||||
String value;
|
||||
|
||||
public SnapshotDetailsVO(Long resourceId, String name, String value) {
|
||||
this.resourceId = resourceId;
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getResourceId() {
|
||||
return resourceId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDisplay() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
|
@ -37,6 +37,8 @@ public interface VolumeDao extends GenericDao<VolumeVO, Long>, StateDao<Volume.S
|
|||
|
||||
Pair<Long, Long> getNonDestroyedCountAndTotalByPool(long poolId);
|
||||
|
||||
long getVMSnapshotSizeByPool(long poolId);
|
||||
|
||||
List<VolumeVO> findByInstance(long id);
|
||||
|
||||
List<VolumeVO> findByInstanceAndType(long id, Volume.Type vType);
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol
|
|||
protected final SearchBuilder<VolumeVO> DetachedAccountIdSearch;
|
||||
protected final SearchBuilder<VolumeVO> TemplateZoneSearch;
|
||||
protected final GenericSearchBuilder<VolumeVO, SumCount> TotalSizeByPoolSearch;
|
||||
protected final GenericSearchBuilder<VolumeVO, SumCount> TotalVMSnapshotSizeByPoolSearch;
|
||||
protected final GenericSearchBuilder<VolumeVO, Long> ActiveTemplateSearch;
|
||||
protected final SearchBuilder<VolumeVO> InstanceStatesSearch;
|
||||
protected final SearchBuilder<VolumeVO> AllFieldsSearch;
|
||||
|
|
@ -316,6 +317,15 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol
|
|||
TotalSizeByPoolSearch.and("state", TotalSizeByPoolSearch.entity().getState(), Op.NEQ);
|
||||
TotalSizeByPoolSearch.done();
|
||||
|
||||
TotalVMSnapshotSizeByPoolSearch = createSearchBuilder(SumCount.class);
|
||||
TotalVMSnapshotSizeByPoolSearch.select("sum", Func.SUM, TotalVMSnapshotSizeByPoolSearch.entity().getVmSnapshotChainSize());
|
||||
TotalVMSnapshotSizeByPoolSearch.and("poolId", TotalVMSnapshotSizeByPoolSearch.entity().getPoolId(), Op.EQ);
|
||||
TotalVMSnapshotSizeByPoolSearch.and("removed", TotalVMSnapshotSizeByPoolSearch.entity().getRemoved(), Op.NULL);
|
||||
TotalVMSnapshotSizeByPoolSearch.and("state", TotalVMSnapshotSizeByPoolSearch.entity().getState(), Op.NEQ);
|
||||
TotalVMSnapshotSizeByPoolSearch.and("vType", TotalVMSnapshotSizeByPoolSearch.entity().getVolumeType(), Op.EQ);
|
||||
TotalVMSnapshotSizeByPoolSearch.and("instanceId", TotalVMSnapshotSizeByPoolSearch.entity().getInstanceId(), Op.NNULL);
|
||||
TotalVMSnapshotSizeByPoolSearch.done();
|
||||
|
||||
ActiveTemplateSearch = createSearchBuilder(Long.class);
|
||||
ActiveTemplateSearch.and("pool", ActiveTemplateSearch.entity().getPoolId(), Op.EQ);
|
||||
ActiveTemplateSearch.and("template", ActiveTemplateSearch.entity().getTemplateId(), Op.EQ);
|
||||
|
|
@ -516,6 +526,20 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol
|
|||
return new Pair<Long, Long>(sumCount.count, sumCount.sum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getVMSnapshotSizeByPool(long poolId) {
|
||||
SearchCriteria<SumCount> sc = TotalVMSnapshotSizeByPoolSearch.create();
|
||||
sc.setParameters("poolId", poolId);
|
||||
sc.setParameters("state", State.Destroy);
|
||||
sc.setParameters("vType", Volume.Type.ROOT.toString());
|
||||
List<SumCount> results = customSearch(sc, null);
|
||||
if (results != null) {
|
||||
return results.get(0).sum;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@DB
|
||||
public boolean remove(Long id) {
|
||||
|
|
|
|||
|
|
@ -28,53 +28,53 @@ import org.apache.cloudstack.api.ResourceDetail;
|
|||
@Entity
|
||||
@Table(name="firewall_rule_details")
|
||||
public class FirewallRuleDetailVO implements ResourceDetail{
|
||||
@Id
|
||||
@GeneratedValue(strategy= GenerationType.IDENTITY)
|
||||
@Column(name="id")
|
||||
private long id;
|
||||
@Id
|
||||
@GeneratedValue(strategy= GenerationType.IDENTITY)
|
||||
@Column(name="id")
|
||||
private long id;
|
||||
|
||||
@Column(name="firewall_rule_id")
|
||||
private long resourceId;
|
||||
@Column(name="firewall_rule_id")
|
||||
private long resourceId;
|
||||
|
||||
@Column(name="name")
|
||||
private String name;
|
||||
@Column(name="name")
|
||||
private String name;
|
||||
|
||||
@Column(name="value", length=1024)
|
||||
private String value;
|
||||
|
||||
@Column(name="display")
|
||||
private boolean display;
|
||||
@Column(name="value", length=1024)
|
||||
private String value;
|
||||
|
||||
@Column(name="display")
|
||||
private boolean display;
|
||||
|
||||
public FirewallRuleDetailVO() {}
|
||||
public FirewallRuleDetailVO() {}
|
||||
|
||||
public FirewallRuleDetailVO(long networkId, String name, String value) {
|
||||
this.resourceId = networkId;
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
}
|
||||
public FirewallRuleDetailVO(long id, String name, String value) {
|
||||
this.resourceId = id;
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
@Override
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
@Override
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getResourceId() {
|
||||
return resourceId;
|
||||
}
|
||||
@Override
|
||||
public long getResourceId() {
|
||||
return resourceId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDisplay() {
|
||||
return display;
|
||||
}
|
||||
@Override
|
||||
public boolean isDisplay() {
|
||||
return display;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,80 @@
|
|||
// 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 org.apache.cloudstack.resourcedetail;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.apache.cloudstack.api.ResourceDetail;
|
||||
|
||||
@Entity
|
||||
@Table(name="remote_access_vpn_details")
|
||||
public class RemoteAccessVpnDetailVO implements ResourceDetail{
|
||||
@Id
|
||||
@GeneratedValue(strategy= GenerationType.IDENTITY)
|
||||
@Column(name="id")
|
||||
private long id;
|
||||
|
||||
@Column(name="remote_access_vpn_id")
|
||||
private long resourceId;
|
||||
|
||||
@Column(name="name")
|
||||
private String name;
|
||||
|
||||
@Column(name="value", length=1024)
|
||||
private String value;
|
||||
|
||||
@Column(name="display")
|
||||
private boolean display;
|
||||
|
||||
public RemoteAccessVpnDetailVO() {}
|
||||
|
||||
public RemoteAccessVpnDetailVO(long id, String name, String value) {
|
||||
this.resourceId = id;
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getResourceId() {
|
||||
return resourceId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDisplay() {
|
||||
return display;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,80 @@
|
|||
// 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 org.apache.cloudstack.resourcedetail;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.apache.cloudstack.api.ResourceDetail;
|
||||
|
||||
@Entity
|
||||
@Table(name="user_ip_address_details")
|
||||
public class UserIpAddressDetailVO implements ResourceDetail{
|
||||
@Id
|
||||
@GeneratedValue(strategy= GenerationType.IDENTITY)
|
||||
@Column(name="id")
|
||||
private long id;
|
||||
|
||||
@Column(name="user_ip_address_id")
|
||||
private long resourceId;
|
||||
|
||||
@Column(name="name")
|
||||
private String name;
|
||||
|
||||
@Column(name="value", length=1024)
|
||||
private String value;
|
||||
|
||||
@Column(name="display")
|
||||
private boolean display;
|
||||
|
||||
public UserIpAddressDetailVO() {}
|
||||
|
||||
public UserIpAddressDetailVO(long id, String name, String value) {
|
||||
this.resourceId = id;
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getResourceId() {
|
||||
return resourceId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDisplay() {
|
||||
return display;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
// 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 org.apache.cloudstack.resourcedetail.dao;
|
||||
|
||||
import org.apache.cloudstack.resourcedetail.RemoteAccessVpnDetailVO;
|
||||
import org.apache.cloudstack.resourcedetail.ResourceDetailsDao;
|
||||
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
public interface RemoteAccessVpnDetailsDao extends GenericDao<RemoteAccessVpnDetailVO, Long>, ResourceDetailsDao<RemoteAccessVpnDetailVO>{
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
// 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 org.apache.cloudstack.resourcedetail.dao;
|
||||
|
||||
import javax.ejb.Local;
|
||||
|
||||
import org.apache.cloudstack.resourcedetail.RemoteAccessVpnDetailVO;
|
||||
import org.apache.cloudstack.resourcedetail.ResourceDetailsDaoBase;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
@Component
|
||||
@Local (value={RemoteAccessVpnDetailsDao.class})
|
||||
public class RemoteAccessVpnDetailsDaoImpl extends ResourceDetailsDaoBase<RemoteAccessVpnDetailVO> implements RemoteAccessVpnDetailsDao {
|
||||
|
||||
@Override
|
||||
public void addDetail(long resourceId, String key, String value) {
|
||||
super.addDetail(new RemoteAccessVpnDetailVO(resourceId, key, value));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
// 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 org.apache.cloudstack.resourcedetail.dao;
|
||||
|
||||
import org.apache.cloudstack.resourcedetail.ResourceDetailsDao;
|
||||
import org.apache.cloudstack.resourcedetail.UserIpAddressDetailVO;
|
||||
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
public interface UserIpAddressDetailsDao extends GenericDao<UserIpAddressDetailVO, Long>, ResourceDetailsDao<UserIpAddressDetailVO>{
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
// 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 org.apache.cloudstack.resourcedetail.dao;
|
||||
|
||||
import javax.ejb.Local;
|
||||
|
||||
import org.apache.cloudstack.resourcedetail.ResourceDetailsDaoBase;
|
||||
import org.apache.cloudstack.resourcedetail.UserIpAddressDetailVO;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
@Component
|
||||
@Local (value={UserIpAddressDetailsDao.class})
|
||||
public class UserIpAddressDetailsDaoImpl extends ResourceDetailsDaoBase<UserIpAddressDetailVO> implements UserIpAddressDetailsDao {
|
||||
|
||||
@Override
|
||||
public void addDetail(long resourceId, String key, String value) {
|
||||
super.addDetail(new UserIpAddressDetailVO(resourceId, key, value));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -21,6 +21,7 @@ import java.util.List;
|
|||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import com.cloud.storage.*;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
|
@ -41,10 +42,6 @@ import org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreVO;
|
|||
import org.apache.cloudstack.storage.to.SnapshotObjectTO;
|
||||
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.storage.DataStoreRole;
|
||||
import com.cloud.storage.Snapshot;
|
||||
import com.cloud.storage.SnapshotVO;
|
||||
import com.cloud.storage.Volume;
|
||||
import com.cloud.storage.dao.SnapshotDao;
|
||||
import com.cloud.storage.snapshot.SnapshotManager;
|
||||
import com.cloud.utils.NumbersUtil;
|
||||
|
|
@ -260,6 +257,14 @@ public class XenserverSnapshotStrategy extends SnapshotStrategyBase {
|
|||
@Override
|
||||
@DB
|
||||
public SnapshotInfo takeSnapshot(SnapshotInfo snapshot) {
|
||||
Object payload = snapshot.getPayload();
|
||||
if (payload != null) {
|
||||
CreateSnapshotPayload createSnapshotPayload = (CreateSnapshotPayload)payload;
|
||||
if (createSnapshotPayload.getQuiescevm()) {
|
||||
throw new InvalidParameterValueException("can't handle quiescevm equal true for volume snapshot");
|
||||
}
|
||||
}
|
||||
|
||||
SnapshotVO snapshotVO = snapshotDao.acquireInLockTable(snapshot.getId());
|
||||
if (snapshotVO == null) {
|
||||
throw new CloudRuntimeException("Failed to get lock on snapshot:" + snapshot.getId());
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import javax.inject.Inject;
|
|||
import javax.naming.ConfigurationException;
|
||||
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.StrategyPriority;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.VMSnapshotOptions;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.VMSnapshotStrategy;
|
||||
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
|
||||
import org.apache.cloudstack.storage.to.VolumeObjectTO;
|
||||
|
|
@ -111,8 +112,12 @@ public class DefaultVMSnapshotStrategy extends ManagerBase implements VMSnapshot
|
|||
VMSnapshotVO currentSnapshot = vmSnapshotDao.findCurrentSnapshotByVmId(userVm.getId());
|
||||
if (currentSnapshot != null)
|
||||
current = vmSnapshotHelper.getSnapshotWithParents(currentSnapshot);
|
||||
VMSnapshotOptions options = ((VMSnapshotVO) vmSnapshot).getOptions();
|
||||
boolean quiescevm = true;
|
||||
if (options != null)
|
||||
quiescevm = options.needQuiesceVM();
|
||||
VMSnapshotTO target = new VMSnapshotTO(vmSnapshot.getId(), vmSnapshot.getName(), vmSnapshot.getType(), null, vmSnapshot.getDescription(), false,
|
||||
current);
|
||||
current, quiescevm);
|
||||
if (current == null)
|
||||
vmSnapshotVO.setParent(null);
|
||||
else
|
||||
|
|
@ -174,7 +179,7 @@ public class DefaultVMSnapshotStrategy extends ManagerBase implements VMSnapshot
|
|||
String vmInstanceName = userVm.getInstanceName();
|
||||
VMSnapshotTO parent = vmSnapshotHelper.getSnapshotWithParents(vmSnapshotVO).getParent();
|
||||
VMSnapshotTO vmSnapshotTO = new VMSnapshotTO(vmSnapshot.getId(), vmSnapshot.getName(), vmSnapshot.getType(),
|
||||
vmSnapshot.getCreated().getTime(), vmSnapshot.getDescription(), vmSnapshot.getCurrent(), parent);
|
||||
vmSnapshot.getCreated().getTime(), vmSnapshot.getDescription(), vmSnapshot.getCurrent(), parent, true);
|
||||
GuestOSVO guestOS = guestOSDao.findById(userVm.getGuestOSId());
|
||||
DeleteVMSnapshotCommand deleteSnapshotCommand = new DeleteVMSnapshotCommand(vmInstanceName, vmSnapshotTO, volumeTOs,guestOS.getDisplayName());
|
||||
|
||||
|
|
@ -330,7 +335,7 @@ public class DefaultVMSnapshotStrategy extends ManagerBase implements VMSnapshot
|
|||
VMSnapshotTO parent = vmSnapshotHelper.getSnapshotWithParents(snapshot).getParent();
|
||||
|
||||
VMSnapshotTO vmSnapshotTO = new VMSnapshotTO(snapshot.getId(), snapshot.getName(), snapshot.getType(),
|
||||
snapshot.getCreated().getTime(), snapshot.getDescription(), snapshot.getCurrent(), parent);
|
||||
snapshot.getCreated().getTime(), snapshot.getDescription(), snapshot.getCurrent(), parent, true);
|
||||
Long hostId = vmSnapshotHelper.pickRunningHost(vmSnapshot.getVmId());
|
||||
GuestOSVO guestOS = guestOSDao.findById(userVm.getGuestOSId());
|
||||
RevertToVMSnapshotCommand revertToSnapshotCommand = new RevertToVMSnapshotCommand(vmInstanceName, vmSnapshotTO, volumeTOs, guestOS.getDisplayName());
|
||||
|
|
|
|||
|
|
@ -86,6 +86,7 @@ public class ObjectInDataStoreManagerImpl implements ObjectInDataStoreManager {
|
|||
public ObjectInDataStoreManagerImpl() {
|
||||
stateMachines = new StateMachine2<State, Event, DataObjectInStore>();
|
||||
stateMachines.addTransition(State.Allocated, Event.CreateOnlyRequested, State.Creating);
|
||||
stateMachines.addTransition(State.Allocated, Event.DestroyRequested, State.Destroying);
|
||||
stateMachines.addTransition(State.Creating, Event.OperationFailed, State.Allocated);
|
||||
stateMachines.addTransition(State.Creating, Event.OperationSuccessed, State.Ready);
|
||||
stateMachines.addTransition(State.Ready, Event.CopyingRequested, State.Copying);
|
||||
|
|
@ -256,13 +257,7 @@ public class ObjectInDataStoreManagerImpl implements ObjectInDataStoreManager {
|
|||
// Image store
|
||||
switch (dataObj.getType()) {
|
||||
case TEMPLATE:
|
||||
TemplateDataStoreVO destTmpltStore = templateDataStoreDao.findByStoreTemplate(dataStore.getId(), objId);
|
||||
if (destTmpltStore != null && destTmpltStore.getState() != ObjectInDataStoreStateMachine.State.Ready) {
|
||||
return templateDataStoreDao.remove(destTmpltStore.getId());
|
||||
} else {
|
||||
s_logger.warn("Template " + objId + " is not found on image store " + dataStore.getId() + ", so no need to delete");
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
case SNAPSHOT:
|
||||
SnapshotDataStoreVO destSnapshotStore = snapshotDataStoreDao.findByStoreSnapshot(dataStore.getRole(), dataStore.getId(), objId);
|
||||
if (destSnapshotStore != null && destSnapshotStore.getState() != ObjectInDataStoreStateMachine.State.Ready) {
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ public class HypervisorHelperImpl implements HypervisorHelper {
|
|||
int wait = NumbersUtil.parseInt(value, 1800);
|
||||
Long hostId = vmSnapshotHelper.pickRunningHost(virtualMachine.getId());
|
||||
VMSnapshotTO vmSnapshotTO = new VMSnapshotTO(1L, UUID.randomUUID().toString(), VMSnapshot.Type.DiskAndMemory, null, null, false,
|
||||
null);
|
||||
null, true);
|
||||
GuestOSVO guestOS = guestOSDao.findById(virtualMachine.getGuestOSId());
|
||||
List<VolumeObjectTO> volumeTOs = vmSnapshotHelper.getVolumeTOList(virtualMachine.getId());
|
||||
CreateVMSnapshotCommand ccmd = new CreateVMSnapshotCommand(virtualMachine.getInstanceName(),vmSnapshotTO ,volumeTOs, guestOS.getDisplayName(),virtualMachine.getState());
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ public class VMSnapshotHelperImpl implements VMSnapshotHelper {
|
|||
|
||||
private VMSnapshotTO convert2VMSnapshotTO(VMSnapshotVO vo) {
|
||||
return new VMSnapshotTO(vo.getId(), vo.getName(), vo.getType(), vo.getCreated().getTime(), vo.getDescription(),
|
||||
vo.getCurrent(), null);
|
||||
vo.getCurrent(), null, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -21,17 +21,14 @@ package org.apache.cloudstack.storage.image;
|
|||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.*;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.EndPointSelector;
|
||||
import org.apache.cloudstack.framework.async.AsyncCallbackDispatcher;
|
||||
import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
|
||||
import org.apache.cloudstack.framework.async.AsyncRpcContext;
|
||||
|
|
@ -86,6 +83,11 @@ public abstract class BaseImageStoreDriverImpl implements ImageStoreDriver {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getCapabilities() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataTO getTO(DataObject data) {
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@
|
|||
// under the License.
|
||||
package org.apache.cloudstack.framework.config;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ConfigDepot is a repository of configurations.
|
||||
*
|
||||
|
|
@ -23,4 +25,6 @@ package org.apache.cloudstack.framework.config;
|
|||
public interface ConfigDepot {
|
||||
|
||||
ConfigKey<?> get(String paramName);
|
||||
|
||||
List<ConfigKey<?>> getConfigListByScope(String scope);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,8 +76,14 @@ public class ConfigDepotImpl implements ConfigDepot, ConfigDepotAdmin {
|
|||
|
||||
HashMap<String, Pair<String, ConfigKey<?>>> _allKeys = new HashMap<String, Pair<String, ConfigKey<?>>>(1007);
|
||||
|
||||
HashMap<ConfigKey.Scope, List<ConfigKey<?>>> _scopeLevelConfigsMap = new HashMap<ConfigKey.Scope, List<ConfigKey<?>>>();
|
||||
|
||||
public ConfigDepotImpl() {
|
||||
ConfigKey.init(this);
|
||||
_scopeLevelConfigsMap.put(ConfigKey.Scope.Zone, new ArrayList<ConfigKey<?>>());
|
||||
_scopeLevelConfigsMap.put(ConfigKey.Scope.Cluster, new ArrayList<ConfigKey<?>>());
|
||||
_scopeLevelConfigsMap.put(ConfigKey.Scope.StoragePool, new ArrayList<ConfigKey<?>>());
|
||||
_scopeLevelConfigsMap.put(ConfigKey.Scope.Account, new ArrayList<ConfigKey<?>>());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -108,7 +114,7 @@ public class ConfigDepotImpl implements ConfigDepot, ConfigDepotAdmin {
|
|||
": " + key.toString());
|
||||
}
|
||||
_allKeys.put(key.key(), new Pair<String, ConfigKey<?>>(configurable.getConfigComponentName(), key));
|
||||
|
||||
|
||||
ConfigurationVO vo = _configDao.findById(key.key());
|
||||
if (vo == null) {
|
||||
vo = new ConfigurationVO(configurable.getConfigComponentName(), key);
|
||||
|
|
@ -125,6 +131,10 @@ public class ConfigDepotImpl implements ConfigDepot, ConfigDepotAdmin {
|
|||
_configDao.persist(vo);
|
||||
}
|
||||
}
|
||||
if (key.scope() != ConfigKey.Scope.Global) {
|
||||
List<ConfigKey<?>> currentConfigs = _scopeLevelConfigsMap.get(key.scope());
|
||||
currentConfigs.add(key);
|
||||
}
|
||||
}
|
||||
|
||||
_configured.add(configurable);
|
||||
|
|
@ -172,4 +182,9 @@ public class ConfigDepotImpl implements ConfigDepot, ConfigDepotAdmin {
|
|||
this._configurables = configurables;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ConfigKey<?>> getConfigListByScope(String scope) {
|
||||
return _scopeLevelConfigsMap.get(ConfigKey.Scope.valueOf(scope));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,6 +44,11 @@
|
|||
<artifactId>cloud-utils</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,130 @@
|
|||
// 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
|
||||
// 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.utils.db;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import com.mysql.jdbc.BalanceStrategy;
|
||||
import com.mysql.jdbc.Connection;
|
||||
import com.mysql.jdbc.ConnectionImpl;
|
||||
import com.mysql.jdbc.LoadBalancingConnectionProxy;
|
||||
import com.mysql.jdbc.SQLError;
|
||||
|
||||
public class StaticStrategy implements BalanceStrategy {
|
||||
|
||||
public StaticStrategy() {
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
// we don't have anything to clean up
|
||||
}
|
||||
|
||||
public void init(Connection conn, Properties props) throws SQLException {
|
||||
// we don't have anything to initialize
|
||||
}
|
||||
|
||||
public ConnectionImpl pickConnection(LoadBalancingConnectionProxy proxy,
|
||||
List<String> configuredHosts, Map<String, ConnectionImpl> liveConnections, long[] responseTimes,
|
||||
int numRetries) throws SQLException {
|
||||
int numHosts = configuredHosts.size();
|
||||
|
||||
SQLException ex = null;
|
||||
|
||||
List<String> whiteList = new ArrayList<String>(numHosts);
|
||||
whiteList.addAll(configuredHosts);
|
||||
|
||||
Map<String, Long> blackList = proxy.getGlobalBlacklist();
|
||||
|
||||
whiteList.removeAll(blackList.keySet());
|
||||
|
||||
Map<String, Integer> whiteListMap = this.getArrayIndexMap(whiteList);
|
||||
|
||||
|
||||
for (int attempts = 0; attempts < numRetries;) {
|
||||
if(whiteList.size() == 0){
|
||||
throw SQLError.createSQLException("No hosts configured", null);
|
||||
}
|
||||
|
||||
String hostPortSpec = whiteList.get(0); //Always take the first host
|
||||
|
||||
ConnectionImpl conn = liveConnections.get(hostPortSpec);
|
||||
|
||||
if (conn == null) {
|
||||
try {
|
||||
conn = proxy.createConnectionForHost(hostPortSpec);
|
||||
} catch (SQLException sqlEx) {
|
||||
ex = sqlEx;
|
||||
|
||||
if (proxy.shouldExceptionTriggerFailover(sqlEx)) {
|
||||
|
||||
Integer whiteListIndex = whiteListMap.get(hostPortSpec);
|
||||
|
||||
// exclude this host from being picked again
|
||||
if (whiteListIndex != null) {
|
||||
whiteList.remove(whiteListIndex.intValue());
|
||||
whiteListMap = this.getArrayIndexMap(whiteList);
|
||||
}
|
||||
proxy.addToGlobalBlacklist( hostPortSpec );
|
||||
|
||||
if (whiteList.size() == 0) {
|
||||
attempts++;
|
||||
try {
|
||||
Thread.sleep(250);
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
|
||||
// start fresh
|
||||
whiteListMap = new HashMap<String, Integer>(numHosts);
|
||||
whiteList.addAll(configuredHosts);
|
||||
blackList = proxy.getGlobalBlacklist();
|
||||
|
||||
whiteList.removeAll(blackList.keySet());
|
||||
whiteListMap = this.getArrayIndexMap(whiteList);
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
throw sqlEx;
|
||||
}
|
||||
}
|
||||
|
||||
return conn;
|
||||
}
|
||||
|
||||
if (ex != null) {
|
||||
throw ex;
|
||||
}
|
||||
|
||||
return null; // we won't get here, compiler can't tell
|
||||
}
|
||||
|
||||
private Map<String, Integer> getArrayIndexMap(List<String> l) {
|
||||
Map<String, Integer> m = new HashMap<String, Integer>(l.size());
|
||||
for (int i = 0; i < l.size(); i++) {
|
||||
m.put(l.get(i), Integer.valueOf(i));
|
||||
}
|
||||
return m;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1034,7 +1034,7 @@ public class TransactionLegacy {
|
|||
|
||||
s_dbHAEnabled = Boolean.valueOf(dbProps.getProperty("db.ha.enabled"));
|
||||
s_logger.info("Is Data Base High Availiability enabled? Ans : " + s_dbHAEnabled);
|
||||
|
||||
String loadBalanceStrategy = dbProps.getProperty("db.ha.loadBalanceStrategy");
|
||||
// FIXME: If params are missing...default them????
|
||||
final int cloudMaxActive = Integer.parseInt(dbProps.getProperty("db.cloud.maxActive"));
|
||||
final int cloudMaxIdle = Integer.parseInt(dbProps.getProperty("db.cloud.maxIdle"));
|
||||
|
|
@ -1090,7 +1090,7 @@ public class TransactionLegacy {
|
|||
cloudMaxWait, cloudMaxIdle, cloudTestOnBorrow, false, cloudTimeBtwEvictionRunsMillis, 1, cloudMinEvcitableIdleTimeMillis, cloudTestWhileIdle);
|
||||
|
||||
final ConnectionFactory cloudConnectionFactory = new DriverManagerConnectionFactory("jdbc:mysql://" + cloudHost + (s_dbHAEnabled ? "," + cloudSlaves : "") + ":" + cloudPort + "/" + cloudDbName +
|
||||
"?autoReconnect=" + cloudAutoReconnect + (url != null ? "&" + url : "") + (useSSL ? "&useSSL=true" : "") + (s_dbHAEnabled ? "&" + cloudDbHAParams : ""), cloudUsername, cloudPassword);
|
||||
"?autoReconnect=" + cloudAutoReconnect + (url != null ? "&" + url : "") + (useSSL ? "&useSSL=true" : "") + (s_dbHAEnabled ? "&" + cloudDbHAParams : "") + (s_dbHAEnabled ? "&loadBalanceStrategy=" + loadBalanceStrategy : ""), cloudUsername, cloudPassword);
|
||||
|
||||
final KeyedObjectPoolFactory poolableObjFactory = (cloudPoolPreparedStatements ? new StackKeyedObjectPoolFactory() : null);
|
||||
|
||||
|
|
@ -1116,7 +1116,7 @@ public class TransactionLegacy {
|
|||
usageMaxWait, usageMaxIdle);
|
||||
|
||||
final ConnectionFactory usageConnectionFactory = new DriverManagerConnectionFactory("jdbc:mysql://" + usageHost + (s_dbHAEnabled ? "," + dbProps.getProperty("db.cloud.slaves") : "") + ":" + usagePort + "/" + usageDbName +
|
||||
"?autoReconnect=" + usageAutoReconnect + (usageUrl != null ? "&" + usageUrl : "") + (s_dbHAEnabled ? "&" + getDBHAParams("usage", dbProps) : ""), usageUsername, usagePassword);
|
||||
"?autoReconnect=" + usageAutoReconnect + (usageUrl != null ? "&" + usageUrl : "") + (s_dbHAEnabled ? "&" + getDBHAParams("usage", dbProps) : "") + (s_dbHAEnabled ? "&loadBalanceStrategy=" + loadBalanceStrategy : ""), usageUsername, usagePassword);
|
||||
|
||||
final PoolableConnectionFactory usagePoolableConnectionFactory = new PoolableConnectionFactory(usageConnectionFactory, usageConnectionPool,
|
||||
new StackKeyedObjectPoolFactory(), null, false, false);
|
||||
|
|
@ -1129,7 +1129,7 @@ public class TransactionLegacy {
|
|||
final GenericObjectPool awsapiConnectionPool = new GenericObjectPool(null, usageMaxActive, GenericObjectPool.DEFAULT_WHEN_EXHAUSTED_ACTION,
|
||||
usageMaxWait, usageMaxIdle);
|
||||
final ConnectionFactory awsapiConnectionFactory = new DriverManagerConnectionFactory("jdbc:mysql://" + cloudHost + (s_dbHAEnabled ? "," + cloudSlaves : "") + ":" + cloudPort + "/" + awsapiDbName +
|
||||
"?autoReconnect=" + cloudAutoReconnect + (s_dbHAEnabled ? "&" + cloudDbHAParams : ""), cloudUsername, cloudPassword);
|
||||
"?autoReconnect=" + cloudAutoReconnect + (s_dbHAEnabled ? "&" + cloudDbHAParams : "") + (s_dbHAEnabled ? "&loadBalanceStrategy=" + loadBalanceStrategy : ""), cloudUsername, cloudPassword);
|
||||
final PoolableConnectionFactory awsapiPoolableConnectionFactory = new PoolableConnectionFactory(awsapiConnectionFactory, awsapiConnectionPool,
|
||||
new StackKeyedObjectPoolFactory(), null, false, false);
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,81 @@
|
|||
// 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
|
||||
// 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.utils;
|
||||
|
||||
import javax.persistence.Column;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.cloud.utils.db.DbUtil;
|
||||
|
||||
public class DbUtilTest {
|
||||
|
||||
static class Testbean {
|
||||
String noAnnotation;
|
||||
@Column()
|
||||
String withAnnotation;
|
||||
@Column(name = "surprise")
|
||||
String withAnnotationAndName;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getColumnName() throws SecurityException, NoSuchFieldException {
|
||||
// if no annotation, then the field name
|
||||
Assert.assertEquals("noAnnotation", DbUtil.getColumnName(Testbean.class
|
||||
.getDeclaredField("noAnnotation")));
|
||||
// there is annotation with name, take the name
|
||||
Assert.assertEquals("surprise", DbUtil.getColumnName(Testbean.class
|
||||
.getDeclaredField("withAnnotationAndName")));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void getColumnNameWithAnnotationButWithoutNameAttribute()
|
||||
throws SecurityException, NoSuchFieldException {
|
||||
// there is annotation, but no name defined, fallback to field name
|
||||
// this does not work this way, it probably should
|
||||
Assert.assertEquals("withAnnotation", DbUtil
|
||||
.getColumnName(Testbean.class
|
||||
.getDeclaredField("withAnnotation")));
|
||||
|
||||
}
|
||||
|
||||
static class IsPersistableTestBean {
|
||||
static final String staticFinal = "no";
|
||||
final String justFinal = "no";
|
||||
transient String transientField;
|
||||
transient static String strange = "";
|
||||
String instanceField;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isPersistable() throws SecurityException, NoSuchFieldException {
|
||||
Assert.assertFalse(DbUtil.isPersistable(IsPersistableTestBean.class
|
||||
.getDeclaredField("staticFinal")));
|
||||
Assert.assertFalse(DbUtil.isPersistable(IsPersistableTestBean.class
|
||||
.getDeclaredField("justFinal")));
|
||||
Assert.assertFalse(DbUtil.isPersistable(IsPersistableTestBean.class
|
||||
.getDeclaredField("transientField")));
|
||||
Assert.assertFalse(DbUtil.isPersistable(IsPersistableTestBean.class
|
||||
.getDeclaredField("strange")));
|
||||
Assert.assertTrue(DbUtil.isPersistable(IsPersistableTestBean.class
|
||||
.getDeclaredField("instanceField")));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -252,7 +252,7 @@ rm -rf ${RPM_BUILD_ROOT}%{_datadir}/%{name}-management/webapps/client/WEB-INF/cl
|
|||
rm -rf ${RPM_BUILD_ROOT}%{_datadir}/%{name}-management/webapps/client/WEB-INF/classes/vms
|
||||
|
||||
for name in db.properties log4j-cloud.xml tomcat6-nonssl.conf tomcat6-ssl.conf server-ssl.xml server-nonssl.xml \
|
||||
catalina.policy catalina.properties classpath.conf tomcat-users.xml web.xml environment.properties cloudmanagementserver.keystore ; do
|
||||
catalina.policy catalina.properties classpath.conf tomcat-users.xml web.xml environment.properties ; do
|
||||
mv ${RPM_BUILD_ROOT}%{_datadir}/%{name}-management/webapps/client/WEB-INF/classes/$name \
|
||||
${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/management/$name
|
||||
done
|
||||
|
|
@ -451,7 +451,6 @@ else
|
|||
fi
|
||||
|
||||
if [ -f "%{_sysconfdir}/cloud.rpmsave/management/cloud.keystore" ]; then
|
||||
mv %{_sysconfdir}/%{name}/management/cloudmanagementserver.keystore %{_sysconfdir}/%{name}/management/cloudmanagementserver.keystore.rpmnew
|
||||
cp -p %{_sysconfdir}/cloud.rpmsave/management/cloud.keystore %{_sysconfdir}/%{name}/management/cloudmanagementserver.keystore
|
||||
# make sure we only do this on the first install of this RPM, don't want to overwrite on a reinstall
|
||||
mv %{_sysconfdir}/cloud.rpmsave/management/cloud.keystore %{_sysconfdir}/cloud.rpmsave/management/cloud.keystore.rpmsave
|
||||
|
|
@ -546,7 +545,6 @@ fi
|
|||
%config(noreplace) %{_sysconfdir}/%{name}/management/cloud-bridge.properties
|
||||
%config(noreplace) %{_sysconfdir}/%{name}/management/commons-logging.properties
|
||||
%config(noreplace) %{_sysconfdir}/%{name}/management/ec2-service.properties
|
||||
%config(noreplace) %{_sysconfdir}/%{name}/management/cloudmanagementserver.keystore
|
||||
%attr(0755,root,root) %{_initrddir}/%{name}-management
|
||||
%attr(0755,root,root) %{_bindir}/%{name}-setup-management
|
||||
%attr(0755,root,root) %{_bindir}/%{name}-update-xenserver-licenses
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ import javax.ejb.Local;
|
|||
import javax.naming.ConfigurationException;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
|
||||
import com.cloud.agent.IAgentControl;
|
||||
|
|
@ -41,6 +40,7 @@ import com.cloud.agent.api.CheckNetworkCommand;
|
|||
import com.cloud.agent.api.CheckVirtualMachineAnswer;
|
||||
import com.cloud.agent.api.CheckVirtualMachineCommand;
|
||||
import com.cloud.agent.api.Command;
|
||||
import com.cloud.agent.api.HostVmStateReportEntry;
|
||||
import com.cloud.agent.api.MaintainAnswer;
|
||||
import com.cloud.agent.api.MaintainCommand;
|
||||
import com.cloud.agent.api.MigrateAnswer;
|
||||
|
|
@ -77,6 +77,7 @@ import com.cloud.utils.script.Script2;
|
|||
import com.cloud.utils.script.Script2.ParamType;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.VirtualMachine.PowerState;
|
||||
import com.cloud.vm.VirtualMachine.State;
|
||||
import com.cloud.vm.dao.VMInstanceDao;
|
||||
|
||||
|
|
@ -332,10 +333,36 @@ public class BareMetalResourceBase extends ManagerBase implements ServerResource
|
|||
|
||||
return states;
|
||||
}
|
||||
|
||||
protected Map<String, HostVmStateReportEntry> getHostVmStateReport() {
|
||||
Map<String, HostVmStateReportEntry> states = new HashMap<String, HostVmStateReportEntry>();
|
||||
if (hostId != null) {
|
||||
vmDao = ComponentContext.getComponent(VMInstanceDao.class);
|
||||
final List<? extends VMInstanceVO> vms = vmDao.listByHostId(hostId);
|
||||
for (VMInstanceVO vm : vms) {
|
||||
states.put(
|
||||
vm.getInstanceName(),
|
||||
new HostVmStateReportEntry(
|
||||
vm.getState() == State.Running ? PowerState.PowerOn : PowerState.PowerOff, "host-" + hostId, null
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Map<String, State> changes = new HashMap<String, State>();
|
||||
*
|
||||
* if (_vmName != null) { State state = getVmState(); if (state != null)
|
||||
* { changes.put(_vmName, state); } }
|
||||
*/
|
||||
|
||||
return states;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StartupCommand[] initialize() {
|
||||
StartupRoutingCommand cmd = new StartupRoutingCommand(0, 0, 0, 0, null, Hypervisor.HypervisorType.BareMetal, new HashMap<String, String>(), null);
|
||||
StartupRoutingCommand cmd = new StartupRoutingCommand(0, 0, 0, 0, null, Hypervisor.HypervisorType.BareMetal,
|
||||
new HashMap<String, String>(), null, null);
|
||||
|
||||
cmd.setDataCenter(_zone);
|
||||
cmd.setPod(_pod);
|
||||
cmd.setCluster(_cluster);
|
||||
|
|
@ -372,7 +399,7 @@ public class BareMetalResourceBase extends ManagerBase implements ServerResource
|
|||
return null;
|
||||
}
|
||||
|
||||
return new PingRoutingCommand(getType(), id, deltaSync());
|
||||
return new PingRoutingCommand(getType(), id, deltaSync(), getHostVmStateReport());
|
||||
}
|
||||
|
||||
protected Answer execute(IpmISetBootDevCommand cmd) {
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ 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.HostVmStateReportEntry;
|
||||
import com.cloud.agent.api.PingCommand;
|
||||
import com.cloud.agent.api.PingRoutingCommand;
|
||||
import com.cloud.agent.api.ReadyAnswer;
|
||||
|
|
@ -129,7 +130,8 @@ public class BaremetalDhcpResourceBase extends ManagerBase implements ServerReso
|
|||
@Override
|
||||
public PingCommand getCurrentStatus(long id) {
|
||||
//TODO: check server
|
||||
return new PingRoutingCommand(getType(), id, new HashMap<String, State>());
|
||||
return new PingRoutingCommand(getType(), id, new HashMap<String, State>(),
|
||||
new HashMap<String, HostVmStateReportEntry>());
|
||||
}
|
||||
|
||||
protected ReadyAnswer execute(ReadyCommand cmd) {
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ import org.apache.log4j.Logger;
|
|||
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.agent.api.Command;
|
||||
import com.cloud.agent.api.HostVmStateReportEntry;
|
||||
import com.cloud.agent.api.PingCommand;
|
||||
import com.cloud.agent.api.PingRoutingCommand;
|
||||
import com.cloud.agent.api.routing.DhcpEntryCommand;
|
||||
|
|
@ -105,7 +106,8 @@ public class BaremetalDhcpdResource extends BaremetalDhcpResourceBase {
|
|||
return null;
|
||||
} else {
|
||||
SSHCmdHelper.releaseSshConnection(sshConnection);
|
||||
return new PingRoutingCommand(getType(), id, new HashMap<String, State>());
|
||||
return new PingRoutingCommand(getType(), id, new HashMap<String, State>(),
|
||||
new HashMap<String, HostVmStateReportEntry>());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ import org.apache.log4j.Logger;
|
|||
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.agent.api.Command;
|
||||
import com.cloud.agent.api.HostVmStateReportEntry;
|
||||
import com.cloud.agent.api.PingCommand;
|
||||
import com.cloud.agent.api.PingRoutingCommand;
|
||||
import com.cloud.agent.api.routing.DhcpEntryCommand;
|
||||
|
|
@ -98,7 +99,8 @@ public class BaremetalDnsmasqResource extends BaremetalDhcpResourceBase {
|
|||
return null;
|
||||
} else {
|
||||
SSHCmdHelper.releaseSshConnection(sshConnection);
|
||||
return new PingRoutingCommand(getType(), id, new HashMap<String, State>());
|
||||
return new PingRoutingCommand(getType(), id, new HashMap<String, State>(),
|
||||
new HashMap<String, HostVmStateReportEntry>());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ import org.apache.log4j.Logger;
|
|||
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.agent.api.Command;
|
||||
import com.cloud.agent.api.HostVmStateReportEntry;
|
||||
import com.cloud.agent.api.PingCommand;
|
||||
import com.cloud.agent.api.PingRoutingCommand;
|
||||
import com.cloud.agent.api.routing.VmDataCommand;
|
||||
|
|
@ -106,7 +107,8 @@ public class BaremetalKickStartPxeResource extends BaremetalPxeResourceBase {
|
|||
return null;
|
||||
} else {
|
||||
SSHCmdHelper.releaseSshConnection(sshConnection);
|
||||
return new PingRoutingCommand(getType(), id, new HashMap<String, State>());
|
||||
return new PingRoutingCommand(getType(), id, new HashMap<String, State>(),
|
||||
new HashMap<String, HostVmStateReportEntry>());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ import org.apache.log4j.Logger;
|
|||
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.agent.api.Command;
|
||||
import com.cloud.agent.api.HostVmStateReportEntry;
|
||||
import com.cloud.agent.api.PingCommand;
|
||||
import com.cloud.agent.api.PingRoutingCommand;
|
||||
import com.cloud.agent.api.baremetal.PreparePxeServerAnswer;
|
||||
|
|
@ -142,7 +143,8 @@ public class BaremetalPingPxeResource extends BaremetalPxeResourceBase {
|
|||
return null;
|
||||
} else {
|
||||
SSHCmdHelper.releaseSshConnection(sshConnection);
|
||||
return new PingRoutingCommand(getType(), id, new HashMap<String, State>());
|
||||
return new PingRoutingCommand(getType(), id, new HashMap<String, State>(),
|
||||
new HashMap<String, HostVmStateReportEntry>());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,7 +42,6 @@ import org.apache.http.util.EntityUtils;
|
|||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.agent.api.CheckRouterAnswer;
|
||||
import com.cloud.agent.api.CheckRouterCommand;
|
||||
|
|
@ -51,6 +50,7 @@ import com.cloud.agent.api.CheckS2SVpnConnectionsCommand;
|
|||
import com.cloud.agent.api.Command;
|
||||
import com.cloud.agent.api.GetDomRVersionAnswer;
|
||||
import com.cloud.agent.api.GetDomRVersionCmd;
|
||||
import com.cloud.agent.api.HostVmStateReportEntry;
|
||||
import com.cloud.agent.api.NetworkUsageAnswer;
|
||||
import com.cloud.agent.api.NetworkUsageCommand;
|
||||
import com.cloud.agent.api.PingCommand;
|
||||
|
|
@ -158,7 +158,8 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S
|
|||
new StartupRoutingCommand(0, 0, 0, 0, null,
|
||||
Hypervisor.HypervisorType.Hyperv,
|
||||
RouterPrivateIpStrategy.HostLocal,
|
||||
new HashMap<String, VmState>());
|
||||
new HashMap<String, VmState>(),
|
||||
new HashMap<String, HostVmStateReportEntry>());
|
||||
|
||||
// Identity within the data centre is decided by CloudStack kernel,
|
||||
// and passed via ServerResource.configure()
|
||||
|
|
@ -293,7 +294,8 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S
|
|||
|
||||
@Override
|
||||
public final PingCommand getCurrentStatus(final long id) {
|
||||
PingCommand pingCmd = new PingRoutingCommand(getType(), id, null);
|
||||
// TODO, need to report VM states on host
|
||||
PingCommand pingCmd = new PingRoutingCommand(getType(), id, null, null);
|
||||
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Ping host " + _name + " (IP " + _agentIp + ")");
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ import com.cloud.agent.api.GetStorageStatsAnswer;
|
|||
import com.cloud.agent.api.GetStorageStatsCommand;
|
||||
import com.cloud.agent.api.GetVmStatsAnswer;
|
||||
import com.cloud.agent.api.GetVmStatsCommand;
|
||||
import com.cloud.agent.api.HostVmStateReportEntry;
|
||||
import com.cloud.agent.api.ModifyStoragePoolCommand;
|
||||
import com.cloud.agent.api.StartAnswer;
|
||||
import com.cloud.agent.api.StartCommand;
|
||||
|
|
@ -298,7 +299,8 @@ public class HypervDirectConnectResourceTest {
|
|||
StartupRoutingCommand defaultStartRoutCmd = new StartupRoutingCommand(
|
||||
0, 0, 0, 0, null, Hypervisor.HypervisorType.Hyperv,
|
||||
RouterPrivateIpStrategy.HostLocal,
|
||||
new HashMap<String, VmState>());
|
||||
new HashMap<String, VmState>(),
|
||||
new HashMap<String, HostVmStateReportEntry>());
|
||||
|
||||
// Identity within the data centre is decided by CloudStack kernel,
|
||||
// and passed via ServerResource.configure()
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@ import javax.naming.ConfigurationException;
|
|||
|
||||
import com.cloud.agent.api.CheckOnHostCommand;
|
||||
import com.cloud.agent.api.routing.*;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.libvirt.Connect;
|
||||
|
|
@ -69,7 +70,6 @@ import org.libvirt.DomainInterfaceStats;
|
|||
import org.libvirt.DomainSnapshot;
|
||||
import org.libvirt.LibvirtException;
|
||||
import org.libvirt.NodeInfo;
|
||||
|
||||
import org.apache.cloudstack.storage.command.StorageSubSystemCommand;
|
||||
import org.apache.cloudstack.storage.to.PrimaryDataStoreTO;
|
||||
import org.apache.cloudstack.storage.to.VolumeObjectTO;
|
||||
|
|
@ -112,6 +112,7 @@ import com.cloud.agent.api.GetVmStatsCommand;
|
|||
import com.cloud.agent.api.GetVncPortAnswer;
|
||||
import com.cloud.agent.api.GetVncPortCommand;
|
||||
import com.cloud.agent.api.HostStatsEntry;
|
||||
import com.cloud.agent.api.HostVmStateReportEntry;
|
||||
import com.cloud.agent.api.MaintainAnswer;
|
||||
import com.cloud.agent.api.MaintainCommand;
|
||||
import com.cloud.agent.api.ManageSnapshotAnswer;
|
||||
|
|
@ -236,8 +237,8 @@ import com.cloud.utils.script.OutputInterpreter;
|
|||
import com.cloud.utils.script.Script;
|
||||
import com.cloud.vm.DiskProfile;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.VirtualMachine.PowerState;
|
||||
import com.cloud.vm.VirtualMachine.State;
|
||||
|
||||
import com.ceph.rados.Rados;
|
||||
import com.ceph.rados.RadosException;
|
||||
import com.ceph.rados.IoCTX;
|
||||
|
|
@ -373,6 +374,8 @@ ServerResource {
|
|||
protected int _timeout;
|
||||
protected int _cmdsTimeout;
|
||||
protected int _stopTimeout;
|
||||
|
||||
// TODO vmsync {
|
||||
protected static HashMap<DomainInfo.DomainState, State> s_statesTable;
|
||||
static {
|
||||
s_statesTable = new HashMap<DomainInfo.DomainState, State>();
|
||||
|
|
@ -389,6 +392,24 @@ ServerResource {
|
|||
s_statesTable.put(DomainInfo.DomainState.VIR_DOMAIN_SHUTDOWN,
|
||||
State.Stopping);
|
||||
}
|
||||
// TODO vmsync }
|
||||
|
||||
protected static HashMap<DomainInfo.DomainState, PowerState> s_powerStatesTable;
|
||||
static {
|
||||
s_powerStatesTable = new HashMap<DomainInfo.DomainState, PowerState>();
|
||||
s_powerStatesTable.put(DomainInfo.DomainState.VIR_DOMAIN_SHUTOFF,
|
||||
PowerState.PowerOff);
|
||||
s_powerStatesTable.put(DomainInfo.DomainState.VIR_DOMAIN_PAUSED,
|
||||
PowerState.PowerOn);
|
||||
s_powerStatesTable.put(DomainInfo.DomainState.VIR_DOMAIN_RUNNING,
|
||||
PowerState.PowerOn);
|
||||
s_powerStatesTable.put(DomainInfo.DomainState.VIR_DOMAIN_BLOCKED,
|
||||
PowerState.PowerOn);
|
||||
s_powerStatesTable.put(DomainInfo.DomainState.VIR_DOMAIN_NOSTATE,
|
||||
PowerState.PowerUnknown);
|
||||
s_powerStatesTable.put(DomainInfo.DomainState.VIR_DOMAIN_SHUTDOWN,
|
||||
PowerState.PowerOff);
|
||||
}
|
||||
|
||||
protected HashMap<String, State> _vms = new HashMap<String, State>(20);
|
||||
protected List<String> _vmsKilled = new ArrayList<String>();
|
||||
|
|
@ -2812,6 +2833,11 @@ ServerResource {
|
|||
final State state = s_statesTable.get(ps);
|
||||
return state == null ? State.Unknown : state;
|
||||
}
|
||||
|
||||
protected PowerState convertToPowerState(DomainInfo.DomainState ps) {
|
||||
final PowerState state = s_powerStatesTable.get(ps);
|
||||
return state == null ? PowerState.PowerUnknown : state;
|
||||
}
|
||||
|
||||
protected State getVmState(Connect conn, final String vmName) {
|
||||
int retry = 3;
|
||||
|
|
@ -3960,10 +3986,10 @@ ServerResource {
|
|||
|
||||
if (!_can_bridge_firewall) {
|
||||
return new PingRoutingCommand(com.cloud.host.Host.Type.Routing, id,
|
||||
newStates);
|
||||
newStates, this.getHostVmStateReport());
|
||||
} else {
|
||||
HashMap<String, Pair<Long, Long>> nwGrpStates = syncNetworkGroups(id);
|
||||
return new PingRoutingWithNwGroupsCommand(getType(), id, newStates,
|
||||
return new PingRoutingWithNwGroupsCommand(getType(), id, newStates, this.getHostVmStateReport(),
|
||||
nwGrpStates);
|
||||
}
|
||||
}
|
||||
|
|
@ -4008,6 +4034,7 @@ ServerResource {
|
|||
cmd.setPool(_pool);
|
||||
cmd.setCluster(_clusterId);
|
||||
cmd.setGatewayIpAddress(_localGateway);
|
||||
cmd.setHostVmStateReport(getHostVmStateReport());
|
||||
|
||||
StartupStorageCommand sscmd = null;
|
||||
try {
|
||||
|
|
@ -4321,6 +4348,104 @@ ServerResource {
|
|||
|
||||
return vmStates;
|
||||
}
|
||||
|
||||
private HashMap<String, HostVmStateReportEntry> getHostVmStateReport() {
|
||||
final HashMap<String, HostVmStateReportEntry> vmStates = new HashMap<String, HostVmStateReportEntry>();
|
||||
Connect conn = null;
|
||||
|
||||
if (_hypervisorType == HypervisorType.LXC) {
|
||||
try {
|
||||
conn = LibvirtConnection.getConnectionByType(HypervisorType.LXC.toString());
|
||||
vmStates.putAll(getHostVmStateReport(conn));
|
||||
} catch (LibvirtException e) {
|
||||
s_logger.debug("Failed to get connection: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
if (_hypervisorType == HypervisorType.KVM) {
|
||||
try {
|
||||
conn = LibvirtConnection.getConnectionByType(HypervisorType.KVM.toString());
|
||||
vmStates.putAll(getHostVmStateReport(conn));
|
||||
} catch (LibvirtException e) {
|
||||
s_logger.debug("Failed to get connection: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
return vmStates;
|
||||
}
|
||||
|
||||
private HashMap<String, HostVmStateReportEntry> getHostVmStateReport(Connect conn) {
|
||||
final HashMap<String, HostVmStateReportEntry> vmStates = new HashMap<String, HostVmStateReportEntry>();
|
||||
|
||||
String[] vms = null;
|
||||
int[] ids = null;
|
||||
|
||||
try {
|
||||
ids = conn.listDomains();
|
||||
} catch (final LibvirtException e) {
|
||||
s_logger.warn("Unable to listDomains", e);
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
vms = conn.listDefinedDomains();
|
||||
} catch (final LibvirtException e) {
|
||||
s_logger.warn("Unable to listDomains", e);
|
||||
return null;
|
||||
}
|
||||
|
||||
Domain dm = null;
|
||||
for (int i = 0; i < ids.length; i++) {
|
||||
try {
|
||||
dm = conn.domainLookupByID(ids[i]);
|
||||
|
||||
DomainInfo.DomainState ps = dm.getInfo().state;
|
||||
|
||||
final PowerState state = convertToPowerState(ps);
|
||||
|
||||
s_logger.trace("VM " + dm.getName() + ": powerstate = " + ps
|
||||
+ "; vm state=" + state.toString());
|
||||
String vmName = dm.getName();
|
||||
vmStates.put(vmName, new HostVmStateReportEntry(state, conn.getHostName(), null));
|
||||
} catch (final LibvirtException e) {
|
||||
s_logger.warn("Unable to get vms", e);
|
||||
} finally {
|
||||
try {
|
||||
if (dm != null) {
|
||||
dm.free();
|
||||
}
|
||||
} catch (LibvirtException e) {
|
||||
s_logger.trace("Ignoring libvirt error.", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < vms.length; i++) {
|
||||
try {
|
||||
|
||||
dm = conn.domainLookupByName(vms[i]);
|
||||
|
||||
DomainInfo.DomainState ps = dm.getInfo().state;
|
||||
final PowerState state = convertToPowerState(ps);
|
||||
String vmName = dm.getName();
|
||||
s_logger.trace("VM " + vmName + ": powerstate = " + ps
|
||||
+ "; vm state=" + state.toString());
|
||||
|
||||
vmStates.put(vmName, new HostVmStateReportEntry(state, conn.getHostName(), null));
|
||||
} catch (final LibvirtException e) {
|
||||
s_logger.warn("Unable to get vms", e);
|
||||
} finally {
|
||||
try {
|
||||
if (dm != null) {
|
||||
dm.free();
|
||||
}
|
||||
} catch (LibvirtException e) {
|
||||
s_logger.trace("Ignoring libvirt error.", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return vmStates;
|
||||
}
|
||||
|
||||
protected List<Object> getHostInfo() {
|
||||
final ArrayList<Object> info = new ArrayList<Object>();
|
||||
|
|
@ -4776,7 +4901,7 @@ ServerResource {
|
|||
Calendar _timestamp;
|
||||
}
|
||||
|
||||
private VmStatsEntry getVmStat(Connect conn, String vmName)
|
||||
VmStatsEntry getVmStat(Connect conn, String vmName)
|
||||
throws LibvirtException {
|
||||
Domain dm = null;
|
||||
try {
|
||||
|
|
@ -4821,10 +4946,10 @@ ServerResource {
|
|||
}
|
||||
|
||||
if (oldStats != null) {
|
||||
long deltarx = rx - oldStats._rx;
|
||||
double deltarx = rx - oldStats._rx;
|
||||
if (deltarx > 0)
|
||||
stats.setNetworkReadKBs(deltarx / 1024);
|
||||
long deltatx = tx - oldStats._tx;
|
||||
double deltatx = tx - oldStats._tx;
|
||||
if (deltatx > 0)
|
||||
stats.setNetworkWriteKBs(deltatx / 1024);
|
||||
}
|
||||
|
|
@ -4850,10 +4975,10 @@ ServerResource {
|
|||
long deltaiowr = io_wr - oldStats._io_wr;
|
||||
if (deltaiowr > 0)
|
||||
stats.setDiskWriteIOs(deltaiowr);
|
||||
long deltabytesrd = bytes_rd - oldStats._bytes_rd;
|
||||
double deltabytesrd = bytes_rd - oldStats._bytes_rd;
|
||||
if (deltabytesrd > 0)
|
||||
stats.setDiskReadKBs(deltabytesrd / 1024);
|
||||
long deltabyteswr = bytes_wr - oldStats._bytes_wr;
|
||||
double deltabyteswr = bytes_wr - oldStats._bytes_wr;
|
||||
if (deltabyteswr > 0)
|
||||
stats.setDiskWriteKBs(deltabyteswr / 1024);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,21 +19,37 @@
|
|||
|
||||
package com.cloud.hypervisor.kvm.resource;
|
||||
|
||||
import com.cloud.agent.api.to.VirtualMachineTO;
|
||||
import com.cloud.template.VirtualMachineTemplate.BootloaderType;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import org.apache.commons.lang.SystemUtils;
|
||||
import org.junit.Assume;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.apache.commons.lang.SystemUtils;
|
||||
import org.junit.Assume;
|
||||
import org.junit.Test;
|
||||
import org.libvirt.Connect;
|
||||
import org.libvirt.Domain;
|
||||
import org.libvirt.DomainBlockStats;
|
||||
import org.libvirt.DomainInfo;
|
||||
import org.libvirt.DomainInterfaceStats;
|
||||
import org.libvirt.LibvirtException;
|
||||
import org.libvirt.NodeInfo;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
import org.mockito.stubbing.Answer;
|
||||
|
||||
import com.cloud.agent.api.VmStatsEntry;
|
||||
import com.cloud.agent.api.to.VirtualMachineTO;
|
||||
import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.DiskDef;
|
||||
import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.InterfaceDef;
|
||||
import com.cloud.template.VirtualMachineTemplate.BootloaderType;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
|
||||
public class LibvirtComputingResourceTest {
|
||||
|
||||
|
|
@ -210,4 +226,79 @@ public class LibvirtComputingResourceTest {
|
|||
uuid = lcr.getUuid(uuid);
|
||||
Assert.assertTrue(uuid.equals(oldUuid));
|
||||
}
|
||||
|
||||
private static final String VMNAME = "test";
|
||||
|
||||
@Test
|
||||
public void testGetVmStat() throws LibvirtException {
|
||||
Connect connect = Mockito.mock(Connect.class);
|
||||
Domain domain = Mockito.mock(Domain.class);
|
||||
DomainInfo domainInfo = new DomainInfo();
|
||||
Mockito.when(domain.getInfo()).thenReturn(domainInfo);
|
||||
Mockito.when(connect.domainLookupByName(VMNAME)).thenReturn(domain);
|
||||
NodeInfo nodeInfo = new NodeInfo();
|
||||
nodeInfo.cpus = 8;
|
||||
nodeInfo.memory = 8 * 1024 * 1024;
|
||||
nodeInfo.sockets = 2;
|
||||
nodeInfo.threads = 2;
|
||||
nodeInfo.model = "Foo processor";
|
||||
Mockito.when(connect.nodeInfo()).thenReturn(nodeInfo);
|
||||
// this is testing the interface stats, returns an increasing number of sent and received bytes
|
||||
Mockito.when(domain.interfaceStats(Mockito.anyString())).thenAnswer(new Answer<DomainInterfaceStats>() {
|
||||
// increment with less than a KB, so this should be less than 1 KB
|
||||
final static int increment = 1000;
|
||||
int rx_bytes = 1000;
|
||||
int tx_bytes = 1000;
|
||||
|
||||
@Override
|
||||
public DomainInterfaceStats answer(InvocationOnMock invocation) throws Throwable {
|
||||
DomainInterfaceStats domainInterfaceStats = new DomainInterfaceStats();
|
||||
domainInterfaceStats.rx_bytes = (this.rx_bytes += increment);
|
||||
domainInterfaceStats.tx_bytes = (this.tx_bytes += increment);
|
||||
return domainInterfaceStats;
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Mockito.when(domain.blockStats(Mockito.anyString())).thenAnswer(new Answer<DomainBlockStats>() {
|
||||
// a little less than a KB
|
||||
final static int increment = 1000;
|
||||
|
||||
int rd_bytes = 0;
|
||||
int wr_bytes = 1024;
|
||||
@Override
|
||||
public DomainBlockStats answer(InvocationOnMock invocation) throws Throwable {
|
||||
DomainBlockStats domainBlockStats = new DomainBlockStats();
|
||||
|
||||
domainBlockStats.rd_bytes = (rd_bytes += increment);
|
||||
domainBlockStats.wr_bytes = (wr_bytes += increment);
|
||||
return domainBlockStats;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
LibvirtComputingResource libvirtComputingResource = new LibvirtComputingResource() {
|
||||
@Override
|
||||
protected List<InterfaceDef> getInterfaces(Connect conn, String vmName) {
|
||||
InterfaceDef interfaceDef = new InterfaceDef();
|
||||
return Arrays.asList(interfaceDef);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DiskDef> getDisks(Connect conn, String vmName) {
|
||||
DiskDef diskDef = new DiskDef();
|
||||
return Arrays.asList(diskDef);
|
||||
}
|
||||
|
||||
};
|
||||
libvirtComputingResource.getVmStat(connect, VMNAME);
|
||||
VmStatsEntry vmStat = libvirtComputingResource.getVmStat(connect, VMNAME);
|
||||
// network traffic as generated by the logic above, must be greater than zero
|
||||
Assert.assertTrue(vmStat.getNetworkReadKBs() > 0);
|
||||
Assert.assertTrue(vmStat.getNetworkWriteKBs() > 0);
|
||||
// IO traffic as generated by the logic above, must be greater than zero
|
||||
Assert.assertTrue(vmStat.getDiskReadKBs() > 0);
|
||||
Assert.assertTrue(vmStat.getDiskWriteKBs() > 0);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@ import org.apache.log4j.Logger;
|
|||
import org.apache.xmlrpc.XmlRpcException;
|
||||
|
||||
import com.trilead.ssh2.SCPClient;
|
||||
|
||||
import com.cloud.agent.IAgentControl;
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.agent.api.AttachIsoCommand;
|
||||
|
|
@ -61,6 +60,7 @@ import com.cloud.agent.api.GetVmStatsCommand;
|
|||
import com.cloud.agent.api.GetVncPortAnswer;
|
||||
import com.cloud.agent.api.GetVncPortCommand;
|
||||
import com.cloud.agent.api.HostStatsEntry;
|
||||
import com.cloud.agent.api.HostVmStateReportEntry;
|
||||
import com.cloud.agent.api.MaintainAnswer;
|
||||
import com.cloud.agent.api.MaintainCommand;
|
||||
import com.cloud.agent.api.MigrateAnswer;
|
||||
|
|
@ -131,6 +131,7 @@ import com.cloud.utils.script.Script;
|
|||
import com.cloud.utils.ssh.SSHCmdHelper;
|
||||
import com.cloud.vm.DiskProfile;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.VirtualMachine.PowerState;
|
||||
import com.cloud.vm.VirtualMachine.State;
|
||||
import com.trilead.ssh2.SCPClient;
|
||||
|
||||
|
|
@ -153,11 +154,12 @@ public class OvmResourceBase implements ServerResource, HypervisorResource {
|
|||
boolean _canBridgeFirewall;
|
||||
static boolean _isHeartBeat = false;
|
||||
List<String> _bridges = null;
|
||||
protected HashMap<String, State> _vms = new HashMap<String, State>(50);
|
||||
static HashMap<String, State> _stateMaps;
|
||||
private final Map<String, Pair<Long, Long>> _vmNetworkStats= new ConcurrentHashMap<String, Pair<Long, Long>>();
|
||||
private static String _ovsAgentPath = "/opt/ovs-agent-latest";
|
||||
|
||||
|
||||
// TODO vmsync {
|
||||
static HashMap<String, State> _stateMaps;
|
||||
protected HashMap<String, State> _vms = new HashMap<String, State>(50);
|
||||
static {
|
||||
_stateMaps = new HashMap<String, State>();
|
||||
_stateMaps.put("RUNNING", State.Running);
|
||||
|
|
@ -165,6 +167,16 @@ public class OvmResourceBase implements ServerResource, HypervisorResource {
|
|||
_stateMaps.put("ERROR", State.Error);
|
||||
_stateMaps.put("SUSPEND", State.Stopped);
|
||||
}
|
||||
// TODO vmsync }
|
||||
|
||||
static HashMap<String, PowerState> _powerStateMaps;
|
||||
static {
|
||||
_powerStateMaps = new HashMap<String, PowerState>();
|
||||
_powerStateMaps.put("RUNNING", PowerState.PowerOn);
|
||||
_powerStateMaps.put("DOWN", PowerState.PowerOff);
|
||||
_powerStateMaps.put("ERROR", PowerState.PowerUnknown);
|
||||
_powerStateMaps.put("SUSPEND", PowerState.PowerOff);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean configure(String name, Map<String, Object> params)
|
||||
|
|
@ -303,6 +315,7 @@ public class OvmResourceBase implements ServerResource, HypervisorResource {
|
|||
//TODO: introudce PIF
|
||||
cmd.setPrivateIpAddress(_ip);
|
||||
cmd.setStorageIpAddress(_ip);
|
||||
cmd.setHostVmStateReport(getHostVmStateReport());
|
||||
|
||||
String defaultBridge = OvmBridge.getBridgeByIp(_conn, _ip);
|
||||
if (_publicNetworkName == null) {
|
||||
|
|
@ -397,7 +410,7 @@ public class OvmResourceBase implements ServerResource, HypervisorResource {
|
|||
try {
|
||||
OvmHost.ping(_conn);
|
||||
HashMap<String, State> newStates = sync();
|
||||
return new PingRoutingCommand(getType(), id, newStates);
|
||||
return new PingRoutingCommand(getType(), id, newStates, this.getHostVmStateReport());
|
||||
} catch (XmlRpcException e) {
|
||||
s_logger.debug("Check agent status failed", e);
|
||||
return null;
|
||||
|
|
@ -785,6 +798,25 @@ public class OvmResourceBase implements ServerResource, HypervisorResource {
|
|||
return state;
|
||||
}
|
||||
|
||||
private PowerState toPowerState(String vmName, String s) {
|
||||
PowerState state = _powerStateMaps.get(s);
|
||||
if (state == null) {
|
||||
s_logger.debug("Unkown state " + s + " for " + vmName);
|
||||
state = PowerState.PowerUnknown;
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
protected HashMap<String, HostVmStateReportEntry> getHostVmStateReport() throws XmlRpcException {
|
||||
final HashMap<String, HostVmStateReportEntry> vmStates = new HashMap<String, HostVmStateReportEntry>();
|
||||
Map<String, String> vms = OvmHost.getAllVms(_conn);
|
||||
for (final Map.Entry<String, String> entry : vms.entrySet()) {
|
||||
PowerState state = toPowerState(entry.getKey(), entry.getValue());
|
||||
vmStates.put(entry.getKey(), new HostVmStateReportEntry(state, _conn.getIp(), null));
|
||||
}
|
||||
return vmStates;
|
||||
}
|
||||
|
||||
protected HashMap<String, State> getAllVms() throws XmlRpcException {
|
||||
final HashMap<String, State> vmStates = new HashMap<String, State>();
|
||||
Map<String, String> vms = OvmHost.getAllVms(_conn);
|
||||
|
|
|
|||
|
|
@ -84,6 +84,7 @@ import javax.naming.ConfigurationException;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@Component
|
||||
|
|
@ -567,7 +568,7 @@ public class MockVmManagerImpl extends ManagerBase implements MockVmManager {
|
|||
|
||||
@Override
|
||||
public GetDomRVersionAnswer getDomRVersion(GetDomRVersionCmd cmd) {
|
||||
return new GetDomRVersionAnswer(cmd, null, null, null);
|
||||
return new GetDomRVersionAnswer(cmd, null, "CloudStack Release 4.2.0", UUID.randomUUID().toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ 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.HostVmStateReportEntry;
|
||||
import com.cloud.agent.api.PingCommand;
|
||||
import com.cloud.agent.api.PingRoutingWithNwGroupsCommand;
|
||||
import com.cloud.agent.api.ReadyAnswer;
|
||||
|
|
@ -53,6 +54,7 @@ import com.cloud.simulator.MockVMVO;
|
|||
import com.cloud.storage.Storage.StorageResourceType;
|
||||
import com.cloud.storage.template.TemplateProp;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.vm.VirtualMachine.PowerState;
|
||||
import com.cloud.vm.VirtualMachine.State;
|
||||
|
||||
public class AgentRoutingResource extends AgentStorageResource {
|
||||
|
|
@ -114,7 +116,7 @@ public class AgentRoutingResource extends AgentStorageResource {
|
|||
}
|
||||
final HashMap<String, State> newStates = sync();
|
||||
HashMap<String, Pair<Long, Long>> nwGrpStates = _simMgr.syncNetworkGroups(hostGuid);
|
||||
return new PingRoutingWithNwGroupsCommand(getType(), id, newStates, nwGrpStates);
|
||||
return new PingRoutingWithNwGroupsCommand(getType(), id, newStates, getHostVmStateReport(), nwGrpStates);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -275,6 +277,18 @@ public class AgentRoutingResource extends AgentStorageResource {
|
|||
|
||||
return info;
|
||||
}
|
||||
|
||||
protected HashMap<String, HostVmStateReportEntry> getHostVmStateReport() {
|
||||
HashMap<String, HostVmStateReportEntry> report = new HashMap<String, HostVmStateReportEntry>();
|
||||
|
||||
for(String vmName : _runningVms.keySet()) {
|
||||
report.put(vmName, new HostVmStateReportEntry(PowerState.PowerOn, agentHost.getName(), null));
|
||||
}
|
||||
|
||||
|
||||
|
||||
return report;
|
||||
}
|
||||
|
||||
protected HashMap<String, State> sync() {
|
||||
Map<String, State> newStates;
|
||||
|
|
|
|||
|
|
@ -1275,6 +1275,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
|||
String vmSnapshotName = cmd.getTarget().getSnapshotName();
|
||||
String vmSnapshotDesc = cmd.getTarget().getDescription();
|
||||
boolean snapshotMemory = cmd.getTarget().getType() == VMSnapshot.Type.DiskAndMemory;
|
||||
boolean quiescevm = cmd.getTarget().getQuiescevm();
|
||||
VirtualMachineMO vmMo = null;
|
||||
VmwareContext context = hostService.getServiceContext(cmd);
|
||||
Map<String, String> mapNewDisk = new HashMap<String, String>();
|
||||
|
|
@ -1303,7 +1304,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
|||
} else {
|
||||
if (vmMo.getSnapshotMor(vmSnapshotName) != null){
|
||||
s_logger.debug("VM snapshot " + vmSnapshotName + " already exists");
|
||||
}else if (!vmMo.createSnapshot(vmSnapshotName, vmSnapshotDesc, snapshotMemory, true)) {
|
||||
}else if (!vmMo.createSnapshot(vmSnapshotName, vmSnapshotDesc, snapshotMemory, quiescevm)) {
|
||||
return new CreateVMSnapshotAnswer(cmd, false,
|
||||
"Unable to create snapshot due to esxi internal failed");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ import javax.inject.Inject;
|
|||
import javax.naming.ConfigurationException;
|
||||
|
||||
import com.cloud.agent.api.routing.*;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.log4j.NDC;
|
||||
|
||||
|
|
@ -161,6 +162,7 @@ import com.cloud.agent.api.GetVmStatsCommand;
|
|||
import com.cloud.agent.api.GetVncPortAnswer;
|
||||
import com.cloud.agent.api.GetVncPortCommand;
|
||||
import com.cloud.agent.api.HostStatsEntry;
|
||||
import com.cloud.agent.api.HostVmStateReportEntry;
|
||||
import com.cloud.agent.api.MaintainAnswer;
|
||||
import com.cloud.agent.api.MaintainCommand;
|
||||
import com.cloud.agent.api.ManageSnapshotAnswer;
|
||||
|
|
@ -301,6 +303,7 @@ import com.cloud.utils.net.NetUtils;
|
|||
import com.cloud.utils.ssh.SshHelper;
|
||||
import com.cloud.vm.DiskProfile;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.VirtualMachine.PowerState;
|
||||
import com.cloud.vm.VirtualMachine.State;
|
||||
import com.cloud.vm.VirtualMachineName;
|
||||
import com.cloud.vm.VmDetailConstants;
|
||||
|
|
@ -358,6 +361,17 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||
|
||||
protected StorageSubsystemCommandHandler storageHandler;
|
||||
|
||||
protected static HashMap<VirtualMachinePowerState, PowerState> s_powerStatesTable;
|
||||
static {
|
||||
s_powerStatesTable = new HashMap<VirtualMachinePowerState, PowerState>();
|
||||
s_powerStatesTable.put(VirtualMachinePowerState.POWERED_ON, PowerState.PowerOn);
|
||||
s_powerStatesTable.put(VirtualMachinePowerState.POWERED_OFF, PowerState.PowerOff);
|
||||
s_powerStatesTable.put(VirtualMachinePowerState.SUSPENDED, PowerState.PowerOn);
|
||||
}
|
||||
|
||||
// TODO vmsync {
|
||||
// deprecated, will delete after full replacement
|
||||
//
|
||||
protected static HashMap<VirtualMachinePowerState, State> s_statesTable;
|
||||
static {
|
||||
s_statesTable = new HashMap<VirtualMachinePowerState, State>();
|
||||
|
|
@ -365,6 +379,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||
s_statesTable.put(VirtualMachinePowerState.POWERED_OFF, State.Stopped);
|
||||
s_statesTable.put(VirtualMachinePowerState.SUSPENDED, State.Stopped);
|
||||
}
|
||||
// TODO vmsync }
|
||||
|
||||
public Gson getGson() {
|
||||
return _gson;
|
||||
|
|
@ -2559,7 +2574,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||
long requestedMaxMemoryInMb = vmSpec.getMaxRam() / (1024 * 1024);
|
||||
|
||||
// Check if VM is really running on hypervisor host
|
||||
if (getVmState(vmMo) != State.Running) {
|
||||
if (getVmPowerState(vmMo) != PowerState.PowerOn) {
|
||||
throw new CloudRuntimeException("Found that the VM " + vmMo.getVmName() + " is not running. Unable to scale-up this VM");
|
||||
}
|
||||
|
||||
|
|
@ -2609,7 +2624,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||
try {
|
||||
VmwareManager mgr = context.getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
|
||||
|
||||
// mark VM as starting state so that sync() can know not to report stopped too early
|
||||
// mark VM as starting state so that sync can know not to report stopped too early
|
||||
synchronized (_vms) {
|
||||
_vms.put(vmInternalCSName, State.Starting);
|
||||
}
|
||||
|
|
@ -2639,7 +2654,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||
boolean hasSnapshot = false;
|
||||
if (vmMo != null) {
|
||||
s_logger.info("VM " + vmInternalCSName + " already exists, tear down devices for reconfiguration");
|
||||
if (getVmState(vmMo) != State.Stopped)
|
||||
if (getVmPowerState(vmMo) != PowerState.PowerOff)
|
||||
vmMo.safePowerOff(_shutdown_waitMs);
|
||||
|
||||
// retrieve disk information before we tear down
|
||||
|
|
@ -2662,7 +2677,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||
|
||||
takeVmFromOtherHyperHost(hyperHost, vmInternalCSName);
|
||||
|
||||
if (getVmState(vmMo) != State.Stopped)
|
||||
if (getVmPowerState(vmMo) != PowerState.PowerOff)
|
||||
vmMo.safePowerOff(_shutdown_waitMs);
|
||||
|
||||
diskInfoBuilder = vmMo.getDiskInfoBuilder();
|
||||
|
|
@ -3885,7 +3900,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||
try {
|
||||
vmMo.setCustomFieldValue(CustomFieldConstants.CLOUD_NIC_MASK, "0");
|
||||
|
||||
if (getVmState(vmMo) != State.Stopped) {
|
||||
if (getVmPowerState(vmMo) != PowerState.PowerOff) {
|
||||
if (vmMo.safePowerOff(_shutdown_waitMs)) {
|
||||
state = State.Stopped;
|
||||
return new StopAnswer(cmd, "Stop VM " + cmd.getVmName() + " Succeed", true);
|
||||
|
|
@ -5488,7 +5503,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||
List<NetworkDetails> networks = vmMo.getNetworksWithDetails();
|
||||
|
||||
// tear down all devices first before we destroy the VM to avoid accidently delete disk backing files
|
||||
if (getVmState(vmMo) != State.Stopped)
|
||||
if (getVmPowerState(vmMo) != PowerState.PowerOff)
|
||||
vmMo.safePowerOff(_shutdown_waitMs);
|
||||
vmMo.tearDownDevices(new Class<?>[] { /* VirtualDisk.class, */ VirtualEthernetCard.class });
|
||||
vmMo.destroy();
|
||||
|
|
@ -5813,86 +5828,85 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||
|
||||
@Override
|
||||
public PingCommand getCurrentStatus(long id) {
|
||||
try {
|
||||
HashMap<String, State> newStates = sync();
|
||||
if (newStates == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
// take the chance to do left-over dummy VM cleanup from previous run
|
||||
VmwareContext context = getServiceContext();
|
||||
VmwareHypervisorHost hyperHost = getHyperHost(context);
|
||||
VmwareManager mgr = hyperHost.getContext().getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
|
||||
|
||||
if(hyperHost.isHyperHostConnected()) {
|
||||
mgr.gcLeftOverVMs(context);
|
||||
|
||||
s_logger.info("Scan hung worker VM to recycle");
|
||||
|
||||
int workerKey = ((HostMO)hyperHost).getCustomFieldKey("VirtualMachine", CustomFieldConstants.CLOUD_WORKER);
|
||||
int workerTagKey = ((HostMO)hyperHost).getCustomFieldKey("VirtualMachine", CustomFieldConstants.CLOUD_WORKER_TAG);
|
||||
String workerPropName = String.format("value[%d]", workerKey);
|
||||
String workerTagPropName = String.format("value[%d]", workerTagKey);
|
||||
gcAndKillHungWorkerVMs();
|
||||
|
||||
HashMap<String, State> newStates = sync();
|
||||
if (newStates == null) {
|
||||
return null;
|
||||
}
|
||||
return new PingRoutingCommand(getType(), id, newStates, syncHostVmStates());
|
||||
}
|
||||
|
||||
private void gcAndKillHungWorkerVMs() {
|
||||
try {
|
||||
// take the chance to do left-over dummy VM cleanup from previous run
|
||||
VmwareContext context = getServiceContext();
|
||||
VmwareHypervisorHost hyperHost = getHyperHost(context);
|
||||
VmwareManager mgr = hyperHost.getContext().getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
|
||||
|
||||
// GC worker that has been running for too long
|
||||
ObjectContent[] ocs = hyperHost.getVmPropertiesOnHyperHost(
|
||||
new String[] {"name", "config.template", workerPropName, workerTagPropName,
|
||||
});
|
||||
if(ocs != null) {
|
||||
for(ObjectContent oc : ocs) {
|
||||
List<DynamicProperty> props = oc.getPropSet();
|
||||
if(props != null) {
|
||||
boolean template = false;
|
||||
boolean isWorker = false;
|
||||
String workerTag = null;
|
||||
if(hyperHost.isHyperHostConnected()) {
|
||||
mgr.gcLeftOverVMs(context);
|
||||
|
||||
for(DynamicProperty prop : props) {
|
||||
if(prop.getName().equals("config.template")) {
|
||||
template = (Boolean)prop.getVal();
|
||||
} else if(prop.getName().equals(workerPropName)) {
|
||||
CustomFieldStringValue val = (CustomFieldStringValue)prop.getVal();
|
||||
if(val != null && val.getValue() != null && val.getValue().equalsIgnoreCase("true"))
|
||||
isWorker = true;
|
||||
}
|
||||
else if(prop.getName().equals(workerTagPropName)) {
|
||||
CustomFieldStringValue val = (CustomFieldStringValue)prop.getVal();
|
||||
workerTag = val.getValue();
|
||||
}
|
||||
s_logger.info("Scan hung worker VM to recycle");
|
||||
|
||||
int workerKey = ((HostMO)hyperHost).getCustomFieldKey("VirtualMachine", CustomFieldConstants.CLOUD_WORKER);
|
||||
int workerTagKey = ((HostMO)hyperHost).getCustomFieldKey("VirtualMachine", CustomFieldConstants.CLOUD_WORKER_TAG);
|
||||
String workerPropName = String.format("value[%d]", workerKey);
|
||||
String workerTagPropName = String.format("value[%d]", workerTagKey);
|
||||
|
||||
// GC worker that has been running for too long
|
||||
ObjectContent[] ocs = hyperHost.getVmPropertiesOnHyperHost(
|
||||
new String[] {"name", "config.template", workerPropName, workerTagPropName,
|
||||
});
|
||||
if(ocs != null) {
|
||||
for(ObjectContent oc : ocs) {
|
||||
List<DynamicProperty> props = oc.getPropSet();
|
||||
if(props != null) {
|
||||
boolean template = false;
|
||||
boolean isWorker = false;
|
||||
String workerTag = null;
|
||||
|
||||
for(DynamicProperty prop : props) {
|
||||
if(prop.getName().equals("config.template")) {
|
||||
template = (Boolean)prop.getVal();
|
||||
} else if(prop.getName().equals(workerPropName)) {
|
||||
CustomFieldStringValue val = (CustomFieldStringValue)prop.getVal();
|
||||
if(val != null && val.getValue() != null && val.getValue().equalsIgnoreCase("true"))
|
||||
isWorker = true;
|
||||
}
|
||||
else if(prop.getName().equals(workerTagPropName)) {
|
||||
CustomFieldStringValue val = (CustomFieldStringValue)prop.getVal();
|
||||
workerTag = val.getValue();
|
||||
}
|
||||
}
|
||||
|
||||
VirtualMachineMO vmMo = new VirtualMachineMO(hyperHost.getContext(), oc.getObj());
|
||||
if(!template && isWorker) {
|
||||
boolean recycle = false;
|
||||
recycle = mgr.needRecycle(workerTag);
|
||||
VirtualMachineMO vmMo = new VirtualMachineMO(hyperHost.getContext(), oc.getObj());
|
||||
if(!template && isWorker) {
|
||||
boolean recycle = false;
|
||||
recycle = mgr.needRecycle(workerTag);
|
||||
|
||||
if(recycle) {
|
||||
s_logger.info("Recycle pending worker VM: " + vmMo.getName());
|
||||
if(recycle) {
|
||||
s_logger.info("Recycle pending worker VM: " + vmMo.getName());
|
||||
|
||||
vmMo.powerOff();
|
||||
vmMo.destroy();
|
||||
}
|
||||
vmMo.powerOff();
|
||||
vmMo.destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
s_logger.error("Host is no longer connected.");
|
||||
return null;
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
if (e instanceof RemoteException) {
|
||||
s_logger.warn("Encounter remote exception to vCenter, invalidate VMware session context");
|
||||
invalidateServiceContext();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return new PingRoutingCommand(getType(), id, newStates);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
s_logger.error("Host is no longer connected.");
|
||||
}
|
||||
|
||||
} finally {
|
||||
recycleServiceContext();
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
if (e instanceof RemoteException) {
|
||||
s_logger.warn("Encounter remote exception to vCenter, invalidate VMware session context");
|
||||
invalidateServiceContext();
|
||||
}
|
||||
} finally {
|
||||
recycleServiceContext();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -5935,7 +5949,14 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||
}
|
||||
|
||||
cmd.setHypervisorType(HypervisorType.VMware);
|
||||
|
||||
// TODO vmsync {
|
||||
// deprecated after full replacement
|
||||
cmd.setStateChanges(changes);
|
||||
// TODO vmsync}
|
||||
|
||||
cmd.setHostVmStateReport(syncHostVmStates());
|
||||
|
||||
cmd.setCluster(_cluster);
|
||||
cmd.setHypervisorVersion(hostApiVersion);
|
||||
|
||||
|
|
@ -6091,6 +6112,14 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||
}
|
||||
}
|
||||
|
||||
protected HashMap<String, HostVmStateReportEntry> syncHostVmStates() {
|
||||
try {
|
||||
return getHostVmStateReport();
|
||||
} catch(Exception e) {
|
||||
return new HashMap<String, HostVmStateReportEntry>();
|
||||
}
|
||||
}
|
||||
|
||||
protected HashMap<String, State> sync() {
|
||||
HashMap<String, State> changes = new HashMap<String, State>();
|
||||
HashMap<String, State> oldStates = null;
|
||||
|
|
@ -6295,6 +6324,65 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||
return VirtualMachineGuestOsIdentifier.OTHER_GUEST;
|
||||
}
|
||||
|
||||
private HashMap<String, HostVmStateReportEntry> getHostVmStateReport() throws Exception {
|
||||
VmwareHypervisorHost hyperHost = getHyperHost(getServiceContext());
|
||||
|
||||
int key = ((HostMO)hyperHost).getCustomFieldKey("VirtualMachine", CustomFieldConstants.CLOUD_VM_INTERNAL_NAME);
|
||||
if(key == 0) {
|
||||
s_logger.warn("Custom field " + CustomFieldConstants.CLOUD_VM_INTERNAL_NAME + " is not registered ?!");
|
||||
}
|
||||
String instanceNameCustomField = "value[" + key + "]";
|
||||
|
||||
// CLOUD_VM_INTERNAL_NAME stores the internal CS generated vm name. This was earlier stored in name. Now, name can be either the hostname or
|
||||
// the internal CS name, but the custom field CLOUD_VM_INTERNAL_NAME always stores the internal CS name.
|
||||
ObjectContent[] ocs = hyperHost.getVmPropertiesOnHyperHost(
|
||||
new String[] { "name", "runtime.powerState", "config.template", instanceNameCustomField }
|
||||
);
|
||||
|
||||
HashMap<String, HostVmStateReportEntry> newStates = new HashMap<String, HostVmStateReportEntry>();
|
||||
if (ocs != null && ocs.length > 0) {
|
||||
for (ObjectContent oc : ocs) {
|
||||
List<DynamicProperty> objProps = oc.getPropSet();
|
||||
if (objProps != null) {
|
||||
|
||||
boolean isTemplate = false;
|
||||
String name = null;
|
||||
String VMInternalCSName = null;
|
||||
VirtualMachinePowerState powerState = VirtualMachinePowerState.POWERED_OFF;
|
||||
for (DynamicProperty objProp : objProps) {
|
||||
if (objProp.getName().equals("config.template")) {
|
||||
if (objProp.getVal().toString().equalsIgnoreCase("true")) {
|
||||
isTemplate = true;
|
||||
}
|
||||
} else if (objProp.getName().equals("runtime.powerState")) {
|
||||
powerState = (VirtualMachinePowerState) objProp.getVal();
|
||||
} else if (objProp.getName().equals("name")) {
|
||||
name = (String) objProp.getVal();
|
||||
} else if(objProp.getName().contains(instanceNameCustomField)) {
|
||||
if(objProp.getVal() != null)
|
||||
VMInternalCSName = ((CustomFieldStringValue)objProp.getVal()).getValue();
|
||||
}
|
||||
else {
|
||||
assert (false);
|
||||
}
|
||||
}
|
||||
|
||||
if (VMInternalCSName != null)
|
||||
name = VMInternalCSName;
|
||||
|
||||
if (!isTemplate) {
|
||||
newStates.put(
|
||||
name,
|
||||
new HostVmStateReportEntry(convertPowerState(powerState), hyperHost.getHyperHostName(), null)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return newStates;
|
||||
}
|
||||
|
||||
// TODO vmsync {
|
||||
private HashMap<String, State> getVmStates() throws Exception {
|
||||
VmwareHypervisorHost hyperHost = getHyperHost(getServiceContext());
|
||||
|
||||
|
|
@ -6462,6 +6550,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||
}
|
||||
return vmResponseMap;
|
||||
}
|
||||
// TODO vmsync }
|
||||
|
||||
protected String networkUsage(final String privateIpAddress, final String option, final String ethName) {
|
||||
String args = null;
|
||||
|
|
@ -6572,6 +6661,8 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||
return connect(vmname, ipAddress, 3922);
|
||||
}
|
||||
|
||||
// TODO vmsync {
|
||||
// deprecated after full replacement
|
||||
private static State convertState(VirtualMachinePowerState powerState) {
|
||||
return s_statesTable.get(powerState);
|
||||
}
|
||||
|
|
@ -6580,7 +6671,17 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||
VirtualMachineRuntimeInfo runtimeInfo = vmMo.getRuntimeInfo();
|
||||
return convertState(runtimeInfo.getPowerState());
|
||||
}
|
||||
// TODO vmsync }
|
||||
|
||||
private static PowerState convertPowerState(VirtualMachinePowerState powerState) {
|
||||
return s_powerStatesTable.get(powerState);
|
||||
}
|
||||
|
||||
public static PowerState getVmPowerState(VirtualMachineMO vmMo) throws Exception {
|
||||
VirtualMachineRuntimeInfo runtimeInfo = vmMo.getRuntimeInfo();
|
||||
return convertPowerState(runtimeInfo.getPowerState());
|
||||
}
|
||||
|
||||
private static HostStatsEntry getHyperHostStats(VmwareHypervisorHost hyperHost) throws Exception {
|
||||
ComputeResourceSummary hardwareSummary = hyperHost.getHyperHostHardwareSummary();
|
||||
if(hardwareSummary == null)
|
||||
|
|
|
|||
|
|
@ -383,9 +383,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
|
|||
// restoreVM - move the new ROOT disk into corresponding VM folder
|
||||
String vmInternalCSName = volume.getVmName();
|
||||
if (dsMo.folderExists(String.format("[%s]", dsMo.getName()), vmInternalCSName)) {
|
||||
String oldRootDisk = VmwareStorageLayoutHelper.getVmwareDatastorePathFromVmdkFileName(dsMo, vmInternalCSName, vmdkName);
|
||||
if (oldRootDisk != null)
|
||||
VmwareStorageLayoutHelper.syncVolumeToVmDefaultFolder(dcMo, vmInternalCSName, dsMo, vmdkName);
|
||||
VmwareStorageLayoutHelper.syncVolumeToVmDefaultFolder(dcMo, vmInternalCSName, dsMo, vmdkName);
|
||||
}
|
||||
|
||||
VolumeObjectTO newVol = new VolumeObjectTO();
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ import com.cloud.agent.api.GetVmStatsCommand;
|
|||
import com.cloud.agent.api.GetVncPortAnswer;
|
||||
import com.cloud.agent.api.GetVncPortCommand;
|
||||
import com.cloud.agent.api.HostStatsEntry;
|
||||
import com.cloud.agent.api.HostVmStateReportEntry;
|
||||
import com.cloud.agent.api.MaintainAnswer;
|
||||
import com.cloud.agent.api.MaintainCommand;
|
||||
import com.cloud.agent.api.ManageSnapshotAnswer;
|
||||
|
|
@ -188,6 +189,7 @@ import com.cloud.utils.exception.CloudRuntimeException;
|
|||
import com.cloud.utils.net.NetUtils;
|
||||
import com.cloud.vm.DiskProfile;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.VirtualMachine.PowerState;
|
||||
import com.cloud.vm.VirtualMachine.State;
|
||||
import com.cloud.vm.snapshot.VMSnapshot;
|
||||
import com.google.gson.Gson;
|
||||
|
|
@ -225,6 +227,7 @@ import com.xensource.xenapi.VLAN;
|
|||
import com.xensource.xenapi.VM;
|
||||
import com.xensource.xenapi.VMGuestMetrics;
|
||||
import com.xensource.xenapi.XenAPIObject;
|
||||
|
||||
import org.apache.cloudstack.storage.command.StorageSubSystemCommand;
|
||||
import org.apache.cloudstack.storage.to.TemplateObjectTO;
|
||||
import org.apache.cloudstack.storage.to.VolumeObjectTO;
|
||||
|
|
@ -239,6 +242,7 @@ import org.xml.sax.InputSource;
|
|||
import javax.ejb.Local;
|
||||
import javax.naming.ConfigurationException;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
|
|
@ -347,6 +351,17 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
}
|
||||
}
|
||||
|
||||
protected static HashMap<Types.VmPowerState, PowerState> s_powerStatesTable;
|
||||
static {
|
||||
s_powerStatesTable = new HashMap<Types.VmPowerState, PowerState>();
|
||||
s_powerStatesTable.put(Types.VmPowerState.HALTED, PowerState.PowerOff);
|
||||
s_powerStatesTable.put(Types.VmPowerState.PAUSED, PowerState.PowerOn);
|
||||
s_powerStatesTable.put(Types.VmPowerState.RUNNING, PowerState.PowerOn);
|
||||
s_powerStatesTable.put(Types.VmPowerState.SUSPENDED, PowerState.PowerOn);
|
||||
s_powerStatesTable.put(Types.VmPowerState.UNRECOGNIZED, PowerState.PowerUnknown);
|
||||
}
|
||||
|
||||
// TODO vmsync {
|
||||
protected static HashMap<Types.VmPowerState, State> s_statesTable;
|
||||
static {
|
||||
s_statesTable = new HashMap<Types.VmPowerState, State>();
|
||||
|
|
@ -356,6 +371,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
s_statesTable.put(Types.VmPowerState.SUSPENDED, State.Running);
|
||||
s_statesTable.put(Types.VmPowerState.UNRECOGNIZED, State.Unknown);
|
||||
}
|
||||
// TODO vmsync }
|
||||
|
||||
public XsHost getHost() {
|
||||
return _host;
|
||||
|
|
@ -2975,7 +2991,61 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
final State state = s_statesTable.get(ps);
|
||||
return state == null ? State.Unknown : state;
|
||||
}
|
||||
|
||||
private static PowerState convertPowerState(Types.VmPowerState powerState) {
|
||||
return s_powerStatesTable.get(powerState);
|
||||
}
|
||||
|
||||
protected HashMap<String, HostVmStateReportEntry> getHostVmStateReport(Connection conn) {
|
||||
final HashMap<String, HostVmStateReportEntry> vmStates = new HashMap<String, HostVmStateReportEntry>();
|
||||
Map<VM, VM.Record> vm_map = null;
|
||||
for (int i = 0; i < 2; i++) {
|
||||
try {
|
||||
vm_map = VM.getAllRecords(conn); //USE THIS TO GET ALL VMS FROM A CLUSTER
|
||||
break;
|
||||
} catch (final Throwable e) {
|
||||
s_logger.warn("Unable to get vms", e);
|
||||
}
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (final InterruptedException ex) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (vm_map == null) {
|
||||
return null;
|
||||
}
|
||||
for (VM.Record record: vm_map.values()) {
|
||||
if (record.isControlDomain || record.isASnapshot || record.isATemplate) {
|
||||
continue; // Skip DOM0
|
||||
}
|
||||
|
||||
VmPowerState ps = record.powerState;
|
||||
Host host = record.residentOn;
|
||||
String xstoolsversion = getVMXenToolsVersion(record.platform);
|
||||
String host_uuid = null;
|
||||
if( ! isRefNull(host) ) {
|
||||
try {
|
||||
host_uuid = host.getUuid(conn);
|
||||
} catch (BadServerResponse e) {
|
||||
s_logger.error("Failed to get host uuid for host " + host.toWireString(), e);
|
||||
} catch (XenAPIException e) {
|
||||
s_logger.error("Failed to get host uuid for host " + host.toWireString(), e);
|
||||
} catch (XmlRpcException e) {
|
||||
s_logger.error("Failed to get host uuid for host " + host.toWireString(), e);
|
||||
}
|
||||
vmStates.put(
|
||||
record.nameLabel,
|
||||
new HostVmStateReportEntry(convertPowerState(ps), host_uuid, xstoolsversion)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return vmStates;
|
||||
}
|
||||
|
||||
// TODO vmsync {
|
||||
protected HashMap<String, Ternary<String, State, String>> getAllVms(Connection conn) {
|
||||
final HashMap<String, Ternary<String, State, String>> vmStates = new HashMap<String, Ternary<String, State, String>>();
|
||||
Map<VM, VM.Record> vm_map = null;
|
||||
|
|
@ -3025,6 +3095,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
|
||||
return vmStates;
|
||||
}
|
||||
// TODO vmsync }
|
||||
|
||||
protected State getVmState(Connection conn, final String vmName) {
|
||||
int retry = 3;
|
||||
|
|
@ -4749,13 +4820,13 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
}
|
||||
Connection conn = getConnection();
|
||||
if (!_canBridgeFirewall && !_isOvs) {
|
||||
return new PingRoutingCommand(getType(), id, null);
|
||||
return new PingRoutingCommand(getType(), id, null, getHostVmStateReport(conn));
|
||||
} else if (_isOvs) {
|
||||
List<Pair<String, Long>>ovsStates = ovsFullSyncStates();
|
||||
return new PingRoutingWithOvsCommand(getType(), id, null, ovsStates);
|
||||
return new PingRoutingWithOvsCommand(getType(), id, null, getHostVmStateReport(conn), ovsStates);
|
||||
}else {
|
||||
HashMap<String, Pair<Long, Long>> nwGrpStates = syncNetworkGroups(conn, id);
|
||||
return new PingRoutingWithNwGroupsCommand(getType(), id, null, nwGrpStates);
|
||||
return new PingRoutingWithNwGroupsCommand(getType(), id, null, getHostVmStateReport(conn), nwGrpStates);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
s_logger.warn("Unable to get current status", e);
|
||||
|
|
@ -5010,6 +5081,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
cmd.setHypervisorType(HypervisorType.XenServer);
|
||||
cmd.setCluster(_cluster);
|
||||
cmd.setPoolSync(false);
|
||||
cmd.setHostVmStateReport(this.getHostVmStateReport(conn));
|
||||
|
||||
Pool pool;
|
||||
try {
|
||||
|
|
@ -5963,7 +6035,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
Set<VM> vms = host.getResidentVMs(conn);
|
||||
for (VM vm : vms) {
|
||||
if (vm.getIsControlDomain(conn)) {
|
||||
dom0Ram = vm.getMemoryDynamicMax(conn);
|
||||
dom0Ram = vm.getMemoryStaticMax(conn);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,16 +18,15 @@
|
|||
*/
|
||||
package org.apache.cloudstack.storage.datastore.driver;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.*;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.EndPointSelector;
|
||||
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
|
||||
import org.apache.cloudstack.storage.image.BaseImageStoreDriverImpl;
|
||||
import org.apache.cloudstack.storage.image.datastore.ImageStoreEntity;
|
||||
|
|
@ -49,7 +48,6 @@ public class CloudStackImageStoreDriverImpl extends BaseImageStoreDriverImpl {
|
|||
@Inject
|
||||
EndPointSelector _epSelector;
|
||||
|
||||
|
||||
@Override
|
||||
public DataStoreTO getStoreTO(DataStore store) {
|
||||
ImageStoreImpl nfsStore = (ImageStoreImpl) store;
|
||||
|
|
|
|||
|
|
@ -18,26 +18,18 @@
|
|||
*/
|
||||
package org.apache.cloudstack.storage.datastore.driver;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import com.cloud.storage.*;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.*;
|
||||
import org.apache.cloudstack.storage.to.SnapshotObjectTO;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.engine.orchestration.service.VolumeOrchestrationService;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.ChapInfo;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.EndPointSelector;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreDriver;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateDataFactory;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
|
||||
import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
|
||||
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
|
||||
import org.apache.cloudstack.storage.command.CommandResult;
|
||||
|
|
@ -70,6 +62,13 @@ import com.cloud.utils.NumbersUtil;
|
|||
import com.cloud.vm.dao.VMInstanceDao;
|
||||
|
||||
public class CloudStackPrimaryDataStoreDriverImpl implements PrimaryDataStoreDriver {
|
||||
@Override
|
||||
public Map<String, String> getCapabilities() {
|
||||
Map<String, String> caps = new HashMap<String, String>();
|
||||
caps.put(DataStoreCapabilities.VOLUME_SNAPSHOT_QUIESCEVM.toString(), "false");
|
||||
return caps;
|
||||
}
|
||||
|
||||
private static final Logger s_logger = Logger.getLogger(CloudStackPrimaryDataStoreDriverImpl.class);
|
||||
@Inject
|
||||
DiskOfferingDao diskOfferingDao;
|
||||
|
|
|
|||
|
|
@ -43,6 +43,9 @@ import com.cloud.agent.api.to.DataTO;
|
|||
import com.cloud.storage.dao.StoragePoolHostDao;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class SamplePrimaryDataStoreDriverImpl implements PrimaryDataStoreDriver {
|
||||
private static final Logger s_logger = Logger.getLogger(SamplePrimaryDataStoreDriverImpl.class);
|
||||
@Inject
|
||||
|
|
@ -56,6 +59,11 @@ public class SamplePrimaryDataStoreDriverImpl implements PrimaryDataStoreDriver
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getCapabilities() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataTO getTO(DataObject data) {
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -17,18 +17,13 @@
|
|||
package org.apache.cloudstack.storage.datastore.driver;
|
||||
|
||||
import java.text.NumberFormat;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.ChapInfo;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreDriver;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.*;
|
||||
import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
|
||||
import org.apache.cloudstack.storage.command.CommandResult;
|
||||
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
|
||||
|
|
@ -61,6 +56,11 @@ public class SolidfirePrimaryDataStoreDriver implements PrimaryDataStoreDriver {
|
|||
@Inject private AccountDao _accountDao;
|
||||
@Inject private AccountDetailsDao _accountDetailsDao;
|
||||
|
||||
@Override
|
||||
public Map<String, String> getCapabilities() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataTO getTO(DataObject data) {
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -144,7 +144,9 @@
|
|||
|
||||
<bean id="regionServiceImpl" class="org.apache.cloudstack.region.RegionServiceImpl" />
|
||||
|
||||
<bean id="remoteAccessVpnManagerImpl" class="com.cloud.network.vpn.RemoteAccessVpnManagerImpl" />
|
||||
<bean id="remoteAccessVpnManagerImpl" class="com.cloud.network.vpn.RemoteAccessVpnManagerImpl" >
|
||||
<property name="vpnServiceProviders" value="#{remoteAccessVPNServiceProviderRegistry.registered}" />
|
||||
</bean>
|
||||
|
||||
<bean id="resourceLimitManagerImpl" class="com.cloud.resourcelimit.ResourceLimitManagerImpl" />
|
||||
|
||||
|
|
|
|||
|
|
@ -1023,6 +1023,9 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||
response.setPublicEndPort(Integer.toString(fwRule.getSourcePortEnd()));
|
||||
List<String> cidrs = ApiDBUtils.findFirewallSourceCidrs(fwRule.getId());
|
||||
response.setCidrList(StringUtils.join(cidrs, ","));
|
||||
|
||||
Network guestNtwk = ApiDBUtils.findNetworkById(fwRule.getNetworkId());
|
||||
response.setNetworkId(guestNtwk.getUuid());
|
||||
|
||||
IpAddress ip = ApiDBUtils.findIpAddressById(fwRule.getSourceIpAddressId());
|
||||
response.setPublicIpAddressId(ip.getUuid());
|
||||
|
|
@ -2371,12 +2374,11 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||
IpAddress ip = ApiDBUtils.findIpAddressById(fwRule.getSourceIpAddressId());
|
||||
response.setPublicIpAddressId(ip.getUuid());
|
||||
response.setPublicIpAddress(ip.getAddress().addr());
|
||||
} else if (fwRule.getTrafficType() == FirewallRule.TrafficType.Egress) {
|
||||
response.setPublicIpAddress(null);
|
||||
Network network = ApiDBUtils.findNetworkById(fwRule.getNetworkId());
|
||||
response.setNetworkId(network.getUuid());
|
||||
}
|
||||
|
||||
|
||||
Network network = ApiDBUtils.findNetworkById(fwRule.getNetworkId());
|
||||
response.setNetworkId(network.getUuid());
|
||||
|
||||
FirewallRule.State state = fwRule.getState();
|
||||
String stateToSet = state.toString();
|
||||
if (state.equals(FirewallRule.State.Revoke)) {
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import javax.ejb.Local;
|
|||
import javax.inject.Inject;
|
||||
|
||||
import com.cloud.hypervisor.Hypervisor;
|
||||
import com.cloud.storage.DiskOfferingVO;
|
||||
import org.apache.cloudstack.acl.ControlledEntity.ACLType;
|
||||
import org.apache.cloudstack.affinity.AffinityGroupDomainMapVO;
|
||||
import org.apache.cloudstack.affinity.AffinityGroupResponse;
|
||||
|
|
@ -82,6 +83,9 @@ import org.apache.cloudstack.api.response.UserVmResponse;
|
|||
import org.apache.cloudstack.api.response.VolumeResponse;
|
||||
import org.apache.cloudstack.api.response.ZoneResponse;
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreDriver;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateState;
|
||||
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
|
||||
import org.apache.cloudstack.query.QueryService;
|
||||
|
|
@ -341,6 +345,8 @@ public class QueryManagerImpl extends ManagerBase implements QueryService {
|
|||
|
||||
@Inject
|
||||
ResourceTagDao _resourceTagDao;
|
||||
@Inject
|
||||
DataStoreManager dataStoreManager;
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
|
|
@ -1993,6 +1999,16 @@ public class QueryManagerImpl extends ManagerBase implements QueryService {
|
|||
|
||||
List<StoragePoolResponse> poolResponses = ViewResponseHelper.createStoragePoolResponse(result.first().toArray(
|
||||
new StoragePoolJoinVO[result.first().size()]));
|
||||
for(StoragePoolResponse poolResponse : poolResponses) {
|
||||
DataStore store = dataStoreManager.getPrimaryDataStore(Integer.parseInt(poolResponse.getId()));
|
||||
if (store != null) {
|
||||
DataStoreDriver driver = store.getDriver();
|
||||
if (driver != null && driver.getCapabilities() != null) {
|
||||
poolResponse.setCaps(driver.getCapabilities());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
response.setResponses(poolResponses, result.second());
|
||||
return response;
|
||||
}
|
||||
|
|
@ -2273,6 +2289,7 @@ public class QueryManagerImpl extends ManagerBase implements QueryService {
|
|||
Filter searchFilter = new Filter(DiskOfferingJoinVO.class, "sortKey", isAscending, cmd.getStartIndex(),
|
||||
cmd.getPageSizeVal());
|
||||
SearchCriteria<DiskOfferingJoinVO> sc = _diskOfferingJoinDao.createSearchCriteria();
|
||||
sc.addAnd("type", Op.EQ, DiskOfferingVO.Type.Disk);
|
||||
|
||||
Account account = CallContext.current().getCallingAccount();
|
||||
Object name = cmd.getDiskOfferingName();
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import javax.inject.Inject;
|
|||
import javax.naming.ConfigurationException;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.framework.config.ConfigDepot;
|
||||
import org.apache.cloudstack.framework.config.ConfigKey;
|
||||
import org.apache.cloudstack.framework.config.Configurable;
|
||||
|
|
@ -69,7 +70,6 @@ import com.cloud.service.dao.ServiceOfferingDao;
|
|||
import com.cloud.storage.StorageManager;
|
||||
import com.cloud.storage.VMTemplateStoragePoolVO;
|
||||
import com.cloud.storage.VMTemplateVO;
|
||||
import com.cloud.storage.VolumeVO;
|
||||
import com.cloud.storage.dao.VMTemplatePoolDao;
|
||||
import com.cloud.storage.dao.VolumeDao;
|
||||
import com.cloud.utils.DateUtil;
|
||||
|
|
@ -474,19 +474,6 @@ public class CapacityManagerImpl extends ManagerBase implements CapacityManager,
|
|||
|
||||
}
|
||||
|
||||
private long getVMSnapshotAllocatedCapacity(StoragePoolVO pool){
|
||||
List<VolumeVO> volumes = _volumeDao.findByPoolId(pool.getId());
|
||||
long totalSize = 0;
|
||||
for (VolumeVO volume : volumes) {
|
||||
if(volume.getInstanceId() == null)
|
||||
continue;
|
||||
Long chainSize = volume.getVmSnapshotChainSize();
|
||||
if(chainSize != null)
|
||||
totalSize += chainSize;
|
||||
}
|
||||
return totalSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getAllocatedPoolCapacity(StoragePoolVO pool, VMTemplateVO templateForVmCreation){
|
||||
|
||||
|
|
@ -495,7 +482,7 @@ public class CapacityManagerImpl extends ManagerBase implements CapacityManager,
|
|||
long totalAllocatedSize = sizes.second() + sizes.first() * _extraBytesPerVolume;
|
||||
|
||||
// Get size for VM Snapshots
|
||||
totalAllocatedSize = totalAllocatedSize + getVMSnapshotAllocatedCapacity(pool);
|
||||
totalAllocatedSize = totalAllocatedSize + _volumeDao.getVMSnapshotSizeByPool(pool.getId());
|
||||
|
||||
// Iterate through all templates on this storage pool
|
||||
boolean tmpinstalled = false;
|
||||
|
|
@ -602,9 +589,10 @@ public class CapacityManagerImpl extends ManagerBase implements CapacityManager,
|
|||
|
||||
CapacityVO cpuCap = _capacityDao.findByHostIdType(host.getId(), CapacityVO.CAPACITY_TYPE_CPU);
|
||||
CapacityVO memCap = _capacityDao.findByHostIdType(host.getId(), CapacityVO.CAPACITY_TYPE_MEMORY);
|
||||
|
||||
if (cpuCap != null && memCap != null){
|
||||
|
||||
if ( host.getTotalMemory() != null ) {
|
||||
memCap.setTotalCapacity(host.getTotalMemory());
|
||||
}
|
||||
long hostTotalCpu = host.getCpus().longValue() * host.getSpeed().longValue();
|
||||
|
||||
if (cpuCap.getTotalCapacity() != hostTotalCpu) {
|
||||
|
|
@ -976,6 +964,6 @@ public class CapacityManagerImpl extends ManagerBase implements CapacityManager,
|
|||
|
||||
@Override
|
||||
public ConfigKey<?>[] getConfigKeys() {
|
||||
return new ConfigKey<?>[] {CpuOverprovisioningFactor, MemOverprovisioningFactor};
|
||||
return new ConfigKey<?>[] {CpuOverprovisioningFactor, MemOverprovisioningFactor, StorageCapacityDisableThreshold, StorageOverprovisioningFactor, StorageAllocatedCapacityDisableThreshold};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,8 +57,6 @@ public enum Config {
|
|||
VlanCapacityThreshold("Alert", ManagementServer.class, Float.class, "zone.vlan.capacity.notificationthreshold", "0.75", "Percentage (as a value between 0 and 1) of Zone Vlan utilization above which alerts will be sent about low number of Zone Vlans.", null),
|
||||
DirectNetworkPublicIpCapacityThreshold("Alert", ManagementServer.class, Float.class, "zone.directnetwork.publicip.capacity.notificationthreshold", "0.75", "Percentage (as a value between 0 and 1) of Direct Network Public Ip Utilization above which alerts will be sent about low number of direct network public ips.", null),
|
||||
LocalStorageCapacityThreshold("Alert", ManagementServer.class, Float.class, "cluster.localStorage.capacity.notificationthreshold", "0.75", "Percentage (as a value between 0 and 1) of local storage utilization above which alerts will be sent about low local storage available.", null),
|
||||
CPUCapacityDisableThreshold("Alert", ManagementServer.class, Float.class, "cluster.cpu.allocated.capacity.disablethreshold", "0.85", "Percentage (as a value between 0 and 1) of cpu utilization above which allocators will disable using the cluster for low cpu available. Keep the corresponding notification threshold lower than this to be notified beforehand.", null, ConfigKey.Scope.Cluster.toString()),
|
||||
MemoryCapacityDisableThreshold("Alert", ManagementServer.class, Float.class, "cluster.memory.allocated.capacity.disablethreshold", "0.85", "Percentage (as a value between 0 and 1) of memory utilization above which allocators will disable using the cluster for low memory available. Keep the corresponding notification threshold lower than this to be notified beforehand.", null, ConfigKey.Scope.Cluster.toString()),
|
||||
|
||||
|
||||
// Storage
|
||||
|
|
|
|||
|
|
@ -36,6 +36,8 @@ import javax.ejb.Local;
|
|||
import javax.inject.Inject;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import com.cloud.deploy.DeploymentClusterPlanner;
|
||||
import org.apache.cloudstack.framework.config.ConfigDepot;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.acl.SecurityChecker;
|
||||
|
|
@ -117,6 +119,7 @@ import com.cloud.dc.dao.HostPodDao;
|
|||
import com.cloud.dc.dao.PodVlanMapDao;
|
||||
import com.cloud.dc.dao.VlanDao;
|
||||
import com.cloud.deploy.DataCenterDeployment;
|
||||
import com.cloud.deploy.DeploymentPlanner;
|
||||
import com.cloud.domain.Domain;
|
||||
import com.cloud.domain.DomainVO;
|
||||
import com.cloud.domain.dao.DomainDao;
|
||||
|
|
@ -215,6 +218,8 @@ ConfigurationManagerImpl extends ManagerBase implements ConfigurationManager, Co
|
|||
@Inject
|
||||
ConfigurationDao _configDao;
|
||||
@Inject
|
||||
ConfigDepot _configDepot;
|
||||
@Inject
|
||||
HostPodDao _podDao;
|
||||
@Inject
|
||||
AccountVlanMapDao _accountVlanMapDao;
|
||||
|
|
@ -372,8 +377,8 @@ ConfigurationManagerImpl extends ManagerBase implements ConfigurationManager, Co
|
|||
weightBasedParametersForValidation.add(Config.LocalStorageCapacityThreshold.key());
|
||||
weightBasedParametersForValidation.add(CapacityManager.StorageAllocatedCapacityDisableThreshold.key());
|
||||
weightBasedParametersForValidation.add(CapacityManager.StorageCapacityDisableThreshold.key());
|
||||
weightBasedParametersForValidation.add(Config.CPUCapacityDisableThreshold.key());
|
||||
weightBasedParametersForValidation.add(Config.MemoryCapacityDisableThreshold.key());
|
||||
weightBasedParametersForValidation.add(DeploymentClusterPlanner.ClusterCPUCapacityDisableThreshold.key());
|
||||
weightBasedParametersForValidation.add(DeploymentClusterPlanner.ClusterMemoryCapacityDisableThreshold.key());
|
||||
weightBasedParametersForValidation.add(Config.AgentLoadThreshold.key());
|
||||
weightBasedParametersForValidation.add(Config.VmUserDispersionWeight.key());
|
||||
|
||||
|
|
@ -625,8 +630,17 @@ ConfigurationManagerImpl extends ManagerBase implements ConfigurationManager, Co
|
|||
+ (((name.toLowerCase()).contains("password")) ? "*****" : (((value == null) ? "" : value))));
|
||||
// check if config value exists
|
||||
ConfigurationVO config = _configDao.findByName(name);
|
||||
String catergory = null;
|
||||
|
||||
// FIX ME - All configuration parameters are not moved from config.java to configKey
|
||||
if (config == null) {
|
||||
throw new InvalidParameterValueException("Config parameter with name " + name + " doesn't exist");
|
||||
if ( _configDepot.get(name) == null ) {
|
||||
s_logger.warn("Probably the component manager where configuration variable " + name + " is defined needs to implement Configurable interface");
|
||||
throw new InvalidParameterValueException("Config parameter with name " + name + " doesn't exist");
|
||||
}
|
||||
catergory = _configDepot.get(name).category();
|
||||
} else {
|
||||
catergory = config.getCategory();
|
||||
}
|
||||
|
||||
if (value == null) {
|
||||
|
|
@ -667,7 +681,7 @@ ConfigurationManagerImpl extends ManagerBase implements ConfigurationManager, Co
|
|||
"cannot handle multiple IDs, provide only one ID corresponding to the scope");
|
||||
}
|
||||
|
||||
String updatedValue = updateConfiguration(userId, name, config.getCategory(), value, scope, id);
|
||||
String updatedValue = updateConfiguration(userId, name, catergory, value, scope, id);
|
||||
if ((value == null && updatedValue == null) || updatedValue.equalsIgnoreCase(value)) {
|
||||
return _configDao.findByName(name);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@ import javax.naming.ConfigurationException;
|
|||
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.StoragePoolAllocator;
|
||||
import org.apache.cloudstack.framework.config.ConfigKey;
|
||||
import org.apache.cloudstack.framework.config.Configurable;
|
||||
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
|
||||
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
|
||||
|
||||
|
|
@ -83,7 +85,7 @@ import com.cloud.vm.dao.UserVmDao;
|
|||
import com.cloud.vm.dao.VMInstanceDao;
|
||||
|
||||
@Local(value=DeploymentPlanner.class)
|
||||
public class FirstFitPlanner extends PlannerBase implements DeploymentClusterPlanner {
|
||||
public class FirstFitPlanner extends PlannerBase implements DeploymentClusterPlanner, Configurable{
|
||||
private static final Logger s_logger = Logger.getLogger(FirstFitPlanner.class);
|
||||
@Inject protected HostDao _hostDao;
|
||||
@Inject protected DataCenterDao _dcDao;
|
||||
|
|
@ -246,11 +248,11 @@ public class FirstFitPlanner extends PlannerBase implements DeploymentClusterPla
|
|||
// if he changes these values
|
||||
Map<Short, Float> disableThresholdMap = new HashMap<Short, Float>();
|
||||
|
||||
String cpuDisableThresholdString = _configDao.getValue(Config.CPUCapacityDisableThreshold.key());
|
||||
String cpuDisableThresholdString = ClusterCPUCapacityDisableThreshold.value().toString();
|
||||
float cpuDisableThreshold = NumbersUtil.parseFloat(cpuDisableThresholdString, 0.85F);
|
||||
disableThresholdMap.put(Capacity.CAPACITY_TYPE_CPU, cpuDisableThreshold);
|
||||
|
||||
String memoryDisableThresholdString = _configDao.getValue(Config.MemoryCapacityDisableThreshold.key());
|
||||
String memoryDisableThresholdString = ClusterMemoryCapacityDisableThreshold.value().toString();
|
||||
float memoryDisableThreshold = NumbersUtil.parseFloat(memoryDisableThresholdString, 0.85F);
|
||||
disableThresholdMap.put(Capacity.CAPACITY_TYPE_MEMORY, memoryDisableThreshold);
|
||||
|
||||
|
|
@ -283,10 +285,10 @@ public class FirstFitPlanner extends PlannerBase implements DeploymentClusterPla
|
|||
}
|
||||
if (capacity == Capacity.CAPACITY_TYPE_CPU) {
|
||||
clustersCrossingThreshold = _capacityDao.listClustersCrossingThreshold(capacity,
|
||||
plan.getDataCenterId(), Config.CPUCapacityDisableThreshold.key(), cpu_requested);
|
||||
plan.getDataCenterId(), ClusterCPUCapacityDisableThreshold.key(), cpu_requested);
|
||||
} else if (capacity == Capacity.CAPACITY_TYPE_MEMORY) {
|
||||
clustersCrossingThreshold = _capacityDao.listClustersCrossingThreshold(capacity,
|
||||
plan.getDataCenterId(), Config.MemoryCapacityDisableThreshold.key(), ram_requested);
|
||||
plan.getDataCenterId(), ClusterMemoryCapacityDisableThreshold.key(), ram_requested);
|
||||
}
|
||||
|
||||
if (clustersCrossingThreshold != null && clustersCrossingThreshold.size() != 0) {
|
||||
|
|
@ -522,4 +524,14 @@ public class FirstFitPlanner extends PlannerBase implements DeploymentClusterPla
|
|||
DeploymentPlan plan, ExcludeList avoid) throws InsufficientServerCapacityException {
|
||||
return PlannerResourceUsage.Shared;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getConfigComponentName() {
|
||||
return DeploymentClusterPlanner.class.getSimpleName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigKey<?>[] getConfigKeys() {
|
||||
return new ConfigKey<?>[] {ClusterCPUCapacityDisableThreshold, ClusterMemoryCapacityDisableThreshold};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import javax.naming.ConfigurationException;
|
|||
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.agent.api.Command;
|
||||
import com.cloud.agent.api.HostVmStateReportEntry;
|
||||
import com.cloud.agent.api.PingCommand;
|
||||
import com.cloud.agent.api.StartupCommand;
|
||||
import com.cloud.agent.api.StartupRoutingCommand;
|
||||
|
|
@ -46,7 +47,9 @@ public class KvmDummyResourceBase extends ServerResourceBase implements ServerRe
|
|||
|
||||
@Override
|
||||
public StartupCommand[] initialize() {
|
||||
StartupRoutingCommand cmd = new StartupRoutingCommand(0, 0, 0, 0, null, Hypervisor.HypervisorType.KVM, new HashMap<String, String>(), new HashMap<String, VmState>());
|
||||
StartupRoutingCommand cmd = new StartupRoutingCommand(0, 0, 0, 0, null, Hypervisor.HypervisorType.KVM,
|
||||
new HashMap<String, String>(), new HashMap<String, VmState>(),
|
||||
new HashMap<String, HostVmStateReportEntry>());
|
||||
cmd.setDataCenter(_zoneId);
|
||||
cmd.setPod(_podId);
|
||||
cmd.setCluster(_clusterId);
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@ import javax.naming.ConfigurationException;
|
|||
import org.apache.cloudstack.api.ResourceDetail;
|
||||
import org.apache.cloudstack.resourcedetail.ResourceDetailsDao;
|
||||
import org.apache.cloudstack.resourcedetail.dao.FirewallRuleDetailsDao;
|
||||
import org.apache.cloudstack.resourcedetail.dao.RemoteAccessVpnDetailsDao;
|
||||
import org.apache.cloudstack.resourcedetail.dao.UserIpAddressDetailsDao;
|
||||
import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailsDao;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
|
@ -75,6 +77,10 @@ public class ResourceMetaDataManagerImpl extends ManagerBase implements Resource
|
|||
StoragePoolDetailsDao _storageDetailsDao;
|
||||
@Inject
|
||||
FirewallRuleDetailsDao _firewallRuleDetailsDao;
|
||||
@Inject
|
||||
UserIpAddressDetailsDao _userIpAddressDetailsDao;
|
||||
@Inject
|
||||
RemoteAccessVpnDetailsDao _vpnDetailsDao;
|
||||
|
||||
private static Map<ResourceObjectType, ResourceDetailsDao<? extends ResourceDetail>> _daoMap=
|
||||
new HashMap<ResourceObjectType, ResourceDetailsDao<? extends ResourceDetail>>();
|
||||
|
|
@ -91,7 +97,11 @@ public class ResourceMetaDataManagerImpl extends ManagerBase implements Resource
|
|||
_daoMap.put(ResourceObjectType.Zone, _dcDetailsDao);
|
||||
_daoMap.put(ResourceObjectType.Storage, _storageDetailsDao);
|
||||
_daoMap.put(ResourceObjectType.FirewallRule, _firewallRuleDetailsDao);
|
||||
|
||||
_daoMap.put(ResourceObjectType.PublicIpAddress, _userIpAddressDetailsDao);
|
||||
_daoMap.put(ResourceObjectType.PortForwardingRule, _firewallRuleDetailsDao);
|
||||
_daoMap.put(ResourceObjectType.LoadBalancer, _firewallRuleDetailsDao);
|
||||
_daoMap.put(ResourceObjectType.RemoteAccessVpn, _vpnDetailsDao);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -778,7 +778,20 @@ public abstract class ExternalLoadBalancerDeviceManagerImpl extends AdapterBase
|
|||
String loadBalancingIpAddress = existedGuestIp;
|
||||
|
||||
if (loadBalancingIpAddress == null) {
|
||||
loadBalancingIpAddress = _ipAddrMgr.acquireGuestIpAddress(network, null);
|
||||
if (network.getGuestType() == Network.GuestType.Isolated) {
|
||||
loadBalancingIpAddress = _ipAddrMgr.acquireGuestIpAddress(network, null);
|
||||
} else if (network.getGuestType() == Network.GuestType.Shared) {
|
||||
try {
|
||||
PublicIp directIp = _ipAddrMgr.assignPublicIpAddress(network.getDataCenterId(),
|
||||
null, _accountDao.findById(network.getAccountId()), VlanType.DirectAttached, network.getId(),
|
||||
null, true);
|
||||
loadBalancingIpAddress = directIp.getAddress().addr();
|
||||
} catch (InsufficientCapacityException capException) {
|
||||
String msg = "Ran out of guest IP addresses from the shared network.";
|
||||
s_logger.error(msg);
|
||||
throw new ResourceUnavailableException(msg, DataCenter.class, network.getDataCenterId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (loadBalancingIpAddress == null) {
|
||||
|
|
|
|||
|
|
@ -27,13 +27,12 @@ import javax.ejb.Local;
|
|||
import javax.inject.Inject;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.apache.cloudstack.api.command.user.firewall.ListEgressFirewallRulesCmd;
|
||||
import org.apache.cloudstack.api.command.user.firewall.ListFirewallRulesCmd;
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
|
||||
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.configuration.Config;
|
||||
import com.cloud.domain.dao.DomainDao;
|
||||
|
|
@ -70,7 +69,6 @@ import com.cloud.network.rules.FirewallRule.State;
|
|||
import com.cloud.network.rules.FirewallRuleVO;
|
||||
import com.cloud.network.rules.PortForwardingRule;
|
||||
import com.cloud.network.rules.PortForwardingRuleVO;
|
||||
import com.cloud.network.rules.StaticNat;
|
||||
import com.cloud.network.rules.dao.PortForwardingRulesDao;
|
||||
import com.cloud.network.vpc.VpcManager;
|
||||
import com.cloud.projects.Project.ListProjectResourcesCriteria;
|
||||
|
|
@ -88,11 +86,11 @@ import com.cloud.utils.db.Filter;
|
|||
import com.cloud.utils.db.JoinBuilder;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.SearchCriteria.Op;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.db.TransactionCallbackNoReturn;
|
||||
import com.cloud.utils.db.TransactionCallbackWithException;
|
||||
import com.cloud.utils.db.TransactionStatus;
|
||||
import com.cloud.utils.db.SearchCriteria.Op;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.utils.net.NetUtils;
|
||||
import com.cloud.vm.UserVmVO;
|
||||
|
|
@ -256,7 +254,7 @@ public class FirewallManagerImpl extends ManagerBase implements FirewallService,
|
|||
public Pair<List<? extends FirewallRule>, Integer> listFirewallRules(ListFirewallRulesCmd cmd) {
|
||||
Long ipId = cmd.getIpAddressId();
|
||||
Long id = cmd.getId();
|
||||
Long networkId = null;
|
||||
Long networkId = cmd.getNetworkId();
|
||||
Map<String, String> tags = cmd.getTags();
|
||||
FirewallRule.TrafficType trafficType = cmd.getTrafficType();
|
||||
|
||||
|
|
@ -283,15 +281,10 @@ public class FirewallManagerImpl extends ManagerBase implements FirewallService,
|
|||
|
||||
sb.and("id", sb.entity().getId(), Op.EQ);
|
||||
sb.and("trafficType", sb.entity().getTrafficType(), Op.EQ);
|
||||
if (cmd instanceof ListEgressFirewallRulesCmd ) {
|
||||
networkId =((ListEgressFirewallRulesCmd)cmd).getNetworkId();
|
||||
sb.and("networkId", sb.entity().getNetworkId(), Op.EQ);
|
||||
} else {
|
||||
sb.and("networkId", sb.entity().getNetworkId(), Op.EQ);
|
||||
sb.and("ip", sb.entity().getSourceIpAddressId(), Op.EQ);
|
||||
}
|
||||
sb.and("purpose", sb.entity().getPurpose(), Op.EQ);
|
||||
|
||||
|
||||
if (tags != null && !tags.isEmpty()) {
|
||||
SearchBuilder<ResourceTagVO> tagSearch = _resourceTagDao.createSearchBuilder();
|
||||
for (int count=0; count < tags.size(); count++) {
|
||||
|
|
@ -323,10 +316,10 @@ public class FirewallManagerImpl extends ManagerBase implements FirewallService,
|
|||
|
||||
if (ipId != null) {
|
||||
sc.setParameters("ip", ipId);
|
||||
} else if (cmd instanceof ListEgressFirewallRulesCmd) {
|
||||
if (networkId != null) {
|
||||
sc.setParameters("networkId", networkId);
|
||||
}
|
||||
}
|
||||
|
||||
if (networkId != null) {
|
||||
sc.setParameters("networkId", networkId);
|
||||
}
|
||||
|
||||
sc.setParameters("purpose", Purpose.Firewall);
|
||||
|
|
|
|||
|
|
@ -17,104 +17,26 @@
|
|||
|
||||
package com.cloud.network.router;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TimeZone;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.ejb.Local;
|
||||
import javax.inject.Inject;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import com.cloud.agent.AgentManager;
|
||||
import com.cloud.agent.Listener;
|
||||
import com.cloud.agent.api.*;
|
||||
import com.cloud.agent.api.check.CheckSshAnswer;
|
||||
import com.cloud.agent.api.check.CheckSshCommand;
|
||||
import com.cloud.agent.api.routing.*;
|
||||
import com.cloud.agent.api.to.*;
|
||||
import com.cloud.agent.manager.Commands;
|
||||
import com.cloud.alert.AlertManager;
|
||||
import com.cloud.api.ApiAsyncJobDispatcher;
|
||||
import com.cloud.api.ApiDispatcher;
|
||||
import com.cloud.api.ApiGsonHelper;
|
||||
import com.cloud.maint.Version;
|
||||
import com.cloud.utils.component.ComponentContext;
|
||||
import org.apache.cloudstack.api.command.admin.router.RebootRouterCmd;
|
||||
import org.apache.cloudstack.api.command.admin.router.UpgradeRouterCmd;
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
|
||||
import org.apache.cloudstack.framework.config.ConfigDepot;
|
||||
import org.apache.cloudstack.framework.config.ConfigKey;
|
||||
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
|
||||
import org.apache.cloudstack.framework.jobs.AsyncJobManager;
|
||||
import org.apache.cloudstack.framework.jobs.impl.AsyncJobVO;
|
||||
import org.apache.cloudstack.managed.context.ManagedContextRunnable;
|
||||
import org.apache.cloudstack.utils.identity.ManagementServerNode;
|
||||
import org.apache.cloudstack.api.command.admin.router.UpgradeRouterTemplateCmd;
|
||||
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.BumpUpPriorityCommand;
|
||||
import com.cloud.agent.api.CheckRouterAnswer;
|
||||
import com.cloud.agent.api.CheckRouterCommand;
|
||||
import com.cloud.agent.api.CheckS2SVpnConnectionsAnswer;
|
||||
import com.cloud.agent.api.CheckS2SVpnConnectionsCommand;
|
||||
import com.cloud.agent.api.Command;
|
||||
import com.cloud.agent.api.GetDomRVersionAnswer;
|
||||
import com.cloud.agent.api.GetDomRVersionCmd;
|
||||
import com.cloud.agent.api.ModifySshKeysCommand;
|
||||
import com.cloud.agent.api.NetworkUsageAnswer;
|
||||
import com.cloud.agent.api.NetworkUsageCommand;
|
||||
import com.cloud.agent.api.PvlanSetupCommand;
|
||||
import com.cloud.agent.api.StartupCommand;
|
||||
import com.cloud.agent.api.check.CheckSshAnswer;
|
||||
import com.cloud.agent.api.check.CheckSshCommand;
|
||||
import com.cloud.agent.api.routing.CreateIpAliasCommand;
|
||||
import com.cloud.agent.api.routing.DeleteIpAliasCommand;
|
||||
import com.cloud.agent.api.routing.DhcpEntryCommand;
|
||||
import com.cloud.agent.api.routing.DnsMasqConfigCommand;
|
||||
import com.cloud.agent.api.routing.IpAliasTO;
|
||||
import com.cloud.agent.api.routing.IpAssocCommand;
|
||||
import com.cloud.agent.api.routing.LoadBalancerConfigCommand;
|
||||
import com.cloud.agent.api.routing.NetworkElementCommand;
|
||||
import com.cloud.agent.api.routing.RemoteAccessVpnCfgCommand;
|
||||
import com.cloud.agent.api.routing.SavePasswordCommand;
|
||||
import com.cloud.agent.api.routing.SetFirewallRulesCommand;
|
||||
import com.cloud.agent.api.routing.SetMonitorServiceCommand;
|
||||
import com.cloud.agent.api.routing.SetPortForwardingRulesCommand;
|
||||
import com.cloud.agent.api.routing.SetPortForwardingRulesVpcCommand;
|
||||
import com.cloud.agent.api.routing.SetStaticNatRulesCommand;
|
||||
import com.cloud.agent.api.routing.VmDataCommand;
|
||||
import com.cloud.agent.api.routing.VpnUsersCfgCommand;
|
||||
import com.cloud.agent.manager.Commands;
|
||||
import com.cloud.alert.AlertManager;
|
||||
import com.cloud.cluster.ClusterManager;
|
||||
import com.cloud.cluster.ManagementServerHostVO;
|
||||
import com.cloud.cluster.dao.ManagementServerHostDao;
|
||||
import com.cloud.configuration.Config;
|
||||
import com.cloud.configuration.ConfigurationManager;
|
||||
import com.cloud.configuration.ZoneConfig;
|
||||
import com.cloud.dc.ClusterVO;
|
||||
import com.cloud.dc.DataCenter;
|
||||
import com.cloud.dc.*;
|
||||
import com.cloud.dc.DataCenter.NetworkType;
|
||||
import com.cloud.dc.DataCenterVO;
|
||||
import com.cloud.dc.HostPodVO;
|
||||
import com.cloud.dc.Pod;
|
||||
import com.cloud.dc.Vlan;
|
||||
import com.cloud.dc.VlanVO;
|
||||
import com.cloud.dc.dao.ClusterDao;
|
||||
import com.cloud.dc.dao.DataCenterDao;
|
||||
import com.cloud.dc.dao.HostPodDao;
|
||||
|
|
@ -125,81 +47,34 @@ import com.cloud.deploy.DeploymentPlan;
|
|||
import com.cloud.deploy.DeploymentPlanner.ExcludeList;
|
||||
import com.cloud.event.ActionEvent;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.AgentUnavailableException;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.ConnectionException;
|
||||
import com.cloud.exception.InsufficientAddressCapacityException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.InsufficientServerCapacityException;
|
||||
import com.cloud.exception.InsufficientVirtualNetworkCapcityException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.OperationTimedoutException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.exception.StorageUnavailableException;
|
||||
import com.cloud.exception.*;
|
||||
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.network.IpAddress;
|
||||
import com.cloud.network.IpAddressManager;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.maint.Version;
|
||||
import com.cloud.network.*;
|
||||
import com.cloud.network.Network.GuestType;
|
||||
import com.cloud.network.Network.Provider;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.NetworkService;
|
||||
import com.cloud.network.Networks.BroadcastDomainType;
|
||||
import com.cloud.network.Networks.IsolationType;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.PhysicalNetworkServiceProvider;
|
||||
import com.cloud.network.PublicIpAddress;
|
||||
import com.cloud.network.RemoteAccessVpn;
|
||||
import com.cloud.network.Site2SiteCustomerGateway;
|
||||
import com.cloud.network.Site2SiteVpnConnection;
|
||||
import com.cloud.network.SshKeysDistriMonitor;
|
||||
import com.cloud.network.VirtualNetworkApplianceService;
|
||||
import com.cloud.network.VirtualRouterProvider;
|
||||
import com.cloud.network.VirtualRouterProvider.Type;
|
||||
import com.cloud.network.VpnUser;
|
||||
import com.cloud.network.VpnUserVO;
|
||||
import com.cloud.network.addr.PublicIp;
|
||||
import com.cloud.network.dao.FirewallRulesDao;
|
||||
import com.cloud.network.dao.IPAddressDao;
|
||||
import com.cloud.network.dao.IPAddressVO;
|
||||
import com.cloud.network.dao.LoadBalancerDao;
|
||||
import com.cloud.network.dao.LoadBalancerVMMapDao;
|
||||
import com.cloud.network.dao.LoadBalancerVO;
|
||||
import com.cloud.network.dao.MonitoringServiceVO;
|
||||
import com.cloud.network.dao.NetworkDao;
|
||||
import com.cloud.network.dao.NetworkVO;
|
||||
import com.cloud.network.dao.PhysicalNetworkServiceProviderDao;
|
||||
import com.cloud.network.dao.RemoteAccessVpnDao;
|
||||
import com.cloud.network.dao.Site2SiteCustomerGatewayDao;
|
||||
import com.cloud.network.dao.Site2SiteVpnConnectionDao;
|
||||
import com.cloud.network.dao.Site2SiteVpnConnectionVO;
|
||||
import com.cloud.network.dao.Site2SiteVpnGatewayDao;
|
||||
import com.cloud.network.dao.UserIpv6AddressDao;
|
||||
import com.cloud.network.dao.VirtualRouterProviderDao;
|
||||
import com.cloud.network.dao.VpnUserDao;
|
||||
import com.cloud.network.dao.MonitoringServiceDao;
|
||||
import com.cloud.network.dao.*;
|
||||
import com.cloud.network.lb.LoadBalancingRule;
|
||||
import com.cloud.network.lb.LoadBalancingRule.LbDestination;
|
||||
import com.cloud.network.lb.LoadBalancingRule.LbHealthCheckPolicy;
|
||||
import com.cloud.network.lb.LoadBalancingRule.LbStickinessPolicy;
|
||||
import com.cloud.network.lb.LoadBalancingRule.LbSslCert;
|
||||
import com.cloud.network.lb.LoadBalancingRule.LbStickinessPolicy;
|
||||
import com.cloud.network.lb.LoadBalancingRulesManager;
|
||||
import com.cloud.network.router.VirtualRouter.RedundantState;
|
||||
import com.cloud.network.router.VirtualRouter.Role;
|
||||
import com.cloud.network.rules.FirewallRule;
|
||||
import com.cloud.network.MonitoringService;
|
||||
import com.cloud.network.rules.*;
|
||||
import com.cloud.network.rules.FirewallRule.Purpose;
|
||||
import com.cloud.network.rules.LoadBalancerContainer.Scheme;
|
||||
import com.cloud.network.rules.PortForwardingRule;
|
||||
import com.cloud.network.rules.RulesManager;
|
||||
import com.cloud.network.rules.StaticNat;
|
||||
import com.cloud.network.rules.StaticNatImpl;
|
||||
import com.cloud.network.rules.StaticNatRule;
|
||||
import com.cloud.network.rules.dao.PortForwardingRulesDao;
|
||||
import com.cloud.network.vpn.Site2SiteVpnManager;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
|
|
@ -216,12 +91,7 @@ import com.cloud.storage.VolumeVO;
|
|||
import com.cloud.storage.dao.GuestOSDao;
|
||||
import com.cloud.storage.dao.VMTemplateDao;
|
||||
import com.cloud.storage.dao.VolumeDao;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.AccountManager;
|
||||
import com.cloud.user.User;
|
||||
import com.cloud.user.UserStatisticsVO;
|
||||
import com.cloud.user.UserStatsLogVO;
|
||||
import com.cloud.user.UserVO;
|
||||
import com.cloud.user.*;
|
||||
import com.cloud.user.dao.UserDao;
|
||||
import com.cloud.user.dao.UserStatisticsDao;
|
||||
import com.cloud.user.dao.UserStatsLogDao;
|
||||
|
|
@ -230,52 +100,45 @@ import com.cloud.utils.NumbersUtil;
|
|||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.PasswordGenerator;
|
||||
import com.cloud.utils.StringUtils;
|
||||
import com.cloud.utils.component.ComponentContext;
|
||||
import com.cloud.utils.component.ManagerBase;
|
||||
import com.cloud.utils.concurrency.NamedThreadFactory;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.db.EntityManager;
|
||||
import com.cloud.utils.db.Filter;
|
||||
import com.cloud.utils.db.GlobalLock;
|
||||
import com.cloud.utils.db.JoinBuilder;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.db.TransactionCallbackNoReturn;
|
||||
import com.cloud.utils.db.TransactionStatus;
|
||||
import com.cloud.utils.db.*;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.utils.net.Ip;
|
||||
import com.cloud.utils.net.MacAddress;
|
||||
import com.cloud.utils.net.NetUtils;
|
||||
import com.cloud.vm.DomainRouterVO;
|
||||
import com.cloud.vm.Nic;
|
||||
import com.cloud.vm.NicIpAlias;
|
||||
import com.cloud.vm.NicProfile;
|
||||
import com.cloud.vm.NicVO;
|
||||
import com.cloud.vm.ReservationContext;
|
||||
import com.cloud.vm.ReservationContextImpl;
|
||||
import com.cloud.vm.UserVmVO;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.*;
|
||||
import com.cloud.vm.VirtualMachine.State;
|
||||
import com.cloud.vm.VirtualMachineGuru;
|
||||
import com.cloud.vm.VirtualMachineManager;
|
||||
import com.cloud.vm.VirtualMachineName;
|
||||
import com.cloud.vm.VirtualMachineProfile;
|
||||
import com.cloud.vm.VirtualMachineProfile.Param;
|
||||
import com.cloud.vm.dao.DomainRouterDao;
|
||||
import com.cloud.vm.dao.NicDao;
|
||||
import com.cloud.vm.dao.NicIpAliasDao;
|
||||
import com.cloud.vm.dao.NicIpAliasVO;
|
||||
import com.cloud.vm.dao.UserVmDao;
|
||||
import com.cloud.vm.dao.UserVmDetailsDao;
|
||||
import com.cloud.vm.dao.VMInstanceDao;
|
||||
import com.cloud.vm.dao.*;
|
||||
import org.apache.cloudstack.api.command.admin.router.RebootRouterCmd;
|
||||
import org.apache.cloudstack.api.command.admin.router.UpgradeRouterCmd;
|
||||
import org.apache.cloudstack.api.command.admin.router.UpgradeRouterTemplateCmd;
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
|
||||
import org.apache.cloudstack.framework.config.ConfigDepot;
|
||||
import org.apache.cloudstack.framework.config.ConfigKey;
|
||||
import org.apache.cloudstack.framework.config.Configurable;
|
||||
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
|
||||
import org.apache.cloudstack.framework.jobs.AsyncJobManager;
|
||||
import org.apache.cloudstack.framework.jobs.impl.AsyncJobVO;
|
||||
import org.apache.cloudstack.managed.context.ManagedContextRunnable;
|
||||
import org.apache.cloudstack.utils.identity.ManagementServerNode;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import javax.ejb.Local;
|
||||
import javax.inject.Inject;
|
||||
import javax.naming.ConfigurationException;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
|
||||
/**
|
||||
* VirtualNetworkApplianceManagerImpl manages the different types of virtual network appliances available in the Cloud Stack.
|
||||
*/
|
||||
@Local(value = { VirtualNetworkApplianceManager.class, VirtualNetworkApplianceService.class })
|
||||
public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements VirtualNetworkApplianceManager, VirtualNetworkApplianceService,
|
||||
VirtualMachineGuru, Listener {
|
||||
VirtualMachineGuru, Listener, Configurable {
|
||||
private static final Logger s_logger = Logger.getLogger(VirtualNetworkApplianceManagerImpl.class);
|
||||
|
||||
@Inject
|
||||
|
|
@ -2198,6 +2061,7 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
|
|||
try {
|
||||
int priority = getUpdatedPriority(guestNetwork, routers, router);
|
||||
router.setPriority(priority);
|
||||
router = _routerDao.persist(router);
|
||||
} catch (InsufficientVirtualNetworkCapcityException e) {
|
||||
s_logger.error("Failed to get update priority!", e);
|
||||
throw new CloudRuntimeException("Failed to get update priority!");
|
||||
|
|
@ -2347,12 +2211,12 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
|
|||
|
||||
finalizeUserDataAndDhcpOnStart(cmds, router, provider, guestNetworkId);
|
||||
}
|
||||
finalizeMonitorServiceOnStrat(cmds, router, provider, routerGuestNtwkIds.get(0));
|
||||
finalizeMonitorServiceOnStrat(cmds, profile, router, provider, routerGuestNtwkIds.get(0));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void finalizeMonitorServiceOnStrat(Commands cmds, DomainRouterVO router, Provider provider, long networkId) {
|
||||
private void finalizeMonitorServiceOnStrat(Commands cmds, VirtualMachineProfile profile, DomainRouterVO router, Provider provider, long networkId) {
|
||||
|
||||
NetworkVO network = _networkDao.findById(networkId);
|
||||
|
||||
|
|
@ -2385,18 +2249,18 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
|
|||
servicesTO.add(serviceTO);
|
||||
}
|
||||
|
||||
// TODO : This is a hacking fix
|
||||
// at VR startup time, information in VirtualMachineProfile may not updated to DB yet,
|
||||
// getRouterControlIp() may give wrong IP under basic network mode in VMware environment
|
||||
NicProfile controlNic = getControlNic(profile);
|
||||
SetMonitorServiceCommand command = new SetMonitorServiceCommand(servicesTO);
|
||||
command.setAccessDetail(NetworkElementCommand.ROUTER_IP, getRouterControlIp(router.getId()));
|
||||
command.setAccessDetail(NetworkElementCommand.ROUTER_IP, controlNic.getIp4Address());
|
||||
command.setAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP, getRouterIpInNetwork(networkId, router.getId()));
|
||||
command.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName());
|
||||
|
||||
cmds.addCommand("monitor", command);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
protected NicProfile getControlNic(VirtualMachineProfile profile) {
|
||||
DomainRouterVO router = _routerDao.findById(profile.getId());
|
||||
DataCenterVO dcVo = _dcDao.findById(router.getDataCenterId());
|
||||
|
|
@ -2799,7 +2663,11 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
|
|||
throws StorageUnavailableException, InsufficientCapacityException,
|
||||
ConcurrentOperationException, ResourceUnavailableException {
|
||||
s_logger.debug("Starting router " + router);
|
||||
_itMgr.start(router.getUuid(), params, planToDeploy);
|
||||
try {
|
||||
_itMgr.advanceStart(router.getUuid(), params, planToDeploy);
|
||||
} catch (OperationTimedoutException e) {
|
||||
throw new ResourceUnavailableException("Starting router " + router + " failed! " + e.toString(), DataCenter.class, router.getDataCenterId());
|
||||
}
|
||||
if (router.isStopPending()) {
|
||||
s_logger.info("Clear the stop pending flag of router " + router.getHostName() + " after start router successfully!");
|
||||
router.setStopPending(false);
|
||||
|
|
@ -4230,4 +4098,14 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
|
|||
}
|
||||
return jobIds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getConfigComponentName() {
|
||||
return VirtualNetworkApplianceManagerImpl.class.getSimpleName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigKey<?>[] getConfigKeys() {
|
||||
return new ConfigKey<?>[] {UseExternalDnsServers};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1361,6 +1361,16 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
|||
public List<DomainRouterVO> getVpcRouters(long vpcId) {
|
||||
return _routerDao.listByVpcId(vpcId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean start() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean stop() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] applyVpnUsers(RemoteAccessVpn vpn, List<? extends VpnUser> users, VirtualRouter router) throws ResourceUnavailableException {
|
||||
|
|
|
|||
|
|
@ -25,10 +25,10 @@ import java.util.Set;
|
|||
import javax.ejb.Local;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.cloudstack.api.command.user.firewall.ListPortForwardingRulesCmd;
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.configuration.ConfigurationManager;
|
||||
import com.cloud.domain.dao.DomainDao;
|
||||
|
|
@ -75,10 +75,10 @@ import com.cloud.utils.db.Filter;
|
|||
import com.cloud.utils.db.JoinBuilder;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.TransactionCallbackNoReturn;
|
||||
import com.cloud.utils.db.TransactionCallbackWithException;
|
||||
import com.cloud.utils.db.SearchCriteria.Op;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.db.TransactionCallbackNoReturn;
|
||||
import com.cloud.utils.db.TransactionCallbackWithException;
|
||||
import com.cloud.utils.db.TransactionCallbackWithExceptionNoReturn;
|
||||
import com.cloud.utils.db.TransactionStatus;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
|
@ -783,6 +783,7 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager, Rules
|
|||
Long ipId = cmd.getIpAddressId();
|
||||
Long id = cmd.getId();
|
||||
Map<String, String> tags = cmd.getTags();
|
||||
Long networkId = cmd.getNetworkId();
|
||||
|
||||
Account caller = CallContext.current().getCallingAccount();
|
||||
List<Long> permittedAccounts = new ArrayList<Long>();
|
||||
|
|
@ -808,6 +809,7 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager, Rules
|
|||
sb.and("id", sb.entity().getId(), Op.EQ);
|
||||
sb.and("ip", sb.entity().getSourceIpAddressId(), Op.EQ);
|
||||
sb.and("purpose", sb.entity().getPurpose(), Op.EQ);
|
||||
sb.and("networkId", sb.entity().getNetworkId(), Op.EQ);
|
||||
|
||||
if (tags != null && !tags.isEmpty()) {
|
||||
SearchBuilder<ResourceTagVO> tagSearch = _resourceTagDao.createSearchBuilder();
|
||||
|
|
@ -842,6 +844,10 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager, Rules
|
|||
if (ipId != null) {
|
||||
sc.setParameters("ip", ipId);
|
||||
}
|
||||
|
||||
if (networkId != null) {
|
||||
sc.setParameters("networkId", networkId);
|
||||
}
|
||||
|
||||
sc.setParameters("purpose", Purpose.PortForwarding);
|
||||
|
||||
|
|
|
|||
|
|
@ -1420,10 +1420,9 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
|
|||
Network privateNtwk = null;
|
||||
if (BroadcastDomainType.getSchemeValue(BroadcastDomainType.fromString(broadcastUri)) == BroadcastDomainType.Lswitch) {
|
||||
String cidr = NetUtils.ipAndNetMaskToCidr(gateway, netmask);
|
||||
|
||||
privateNtwk = _ntwkDao.getPrivateNetwork(broadcastUri, cidr,
|
||||
gatewayOwnerId, dcId, networkOfferingId);
|
||||
s_logger.info("found and using existing network for vpc " + vpc + ": " + broadcastUri);
|
||||
// if the dcid is different we get no network so next we try to create it
|
||||
}
|
||||
if (privateNtwk == null) {
|
||||
s_logger.info("creating new network for vpc " + vpc + " using broadcast uri: " + broadcastUri);
|
||||
|
|
@ -1431,6 +1430,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
|
|||
privateNtwk = _ntwkSvc.createPrivateNetwork(networkName, networkName, physicalNetworkIdFinal,
|
||||
broadcastUri, ipAddress, null, gateway, netmask, gatewayOwnerId, vpcId, isSourceNat, networkOfferingId);
|
||||
} else { // create the nic/ip as createPrivateNetwork doesn''t do that work for us now
|
||||
s_logger.info("found and using existing network for vpc " + vpc + ": " + broadcastUri);
|
||||
DataCenterVO dc = _dcDao.lockRow(physNetFinal.getDataCenterId(), true);
|
||||
|
||||
//add entry to private_ip_address table
|
||||
|
|
|
|||
|
|
@ -25,13 +25,13 @@ import javax.ejb.Local;
|
|||
import javax.inject.Inject;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.cloudstack.api.command.user.vpn.ListRemoteAccessVpnsCmd;
|
||||
import org.apache.cloudstack.api.command.user.vpn.ListVpnUsersCmd;
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
import org.apache.cloudstack.framework.config.ConfigKey;
|
||||
import org.apache.cloudstack.framework.config.Configurable;
|
||||
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.configuration.Config;
|
||||
import com.cloud.domain.DomainVO;
|
||||
|
|
@ -81,10 +81,10 @@ import com.cloud.utils.db.Filter;
|
|||
import com.cloud.utils.db.JoinBuilder;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.TransactionCallback;
|
||||
import com.cloud.utils.db.TransactionCallbackNoReturn;
|
||||
import com.cloud.utils.db.SearchCriteria.Op;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.db.TransactionCallback;
|
||||
import com.cloud.utils.db.TransactionCallbackNoReturn;
|
||||
import com.cloud.utils.db.TransactionCallbackWithException;
|
||||
import com.cloud.utils.db.TransactionStatus;
|
||||
import com.cloud.utils.net.NetUtils;
|
||||
|
|
@ -109,8 +109,9 @@ public class RemoteAccessVpnManagerImpl extends ManagerBase implements RemoteAcc
|
|||
@Inject FirewallManager _firewallMgr;
|
||||
@Inject UsageEventDao _usageEventDao;
|
||||
@Inject ConfigurationDao _configDao;
|
||||
@Inject List<RemoteAccessVPNServiceProvider> _vpnServiceProviders;
|
||||
@Inject ConfigurationServer _configServer;
|
||||
List<RemoteAccessVPNServiceProvider> _vpnServiceProviders;
|
||||
|
||||
@Inject ConfigurationServer _configServer;
|
||||
@Inject VpcDao _vpcDao;
|
||||
|
||||
int _userLimit;
|
||||
|
|
@ -592,6 +593,8 @@ public class RemoteAccessVpnManagerImpl extends ManagerBase implements RemoteAcc
|
|||
// do some parameter validation
|
||||
Account caller = CallContext.current().getCallingAccount();
|
||||
Long ipAddressId = cmd.getPublicIpId();
|
||||
Long vpnId = cmd.getId();
|
||||
Long networkId = cmd.getNetworkId();
|
||||
List<Long> permittedAccounts = new ArrayList<Long>();
|
||||
|
||||
if (ipAddressId != null) {
|
||||
|
|
@ -619,6 +622,8 @@ public class RemoteAccessVpnManagerImpl extends ManagerBase implements RemoteAcc
|
|||
_accountMgr.buildACLSearchBuilder(sb, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria);
|
||||
|
||||
sb.and("serverAddressId", sb.entity().getServerAddressId(), Op.EQ);
|
||||
sb.and("id", sb.entity().getId(), Op.EQ);
|
||||
sb.and("networkId", sb.entity().getNetworkId(), Op.EQ);
|
||||
sb.and("state", sb.entity().getState(), Op.EQ);
|
||||
|
||||
SearchCriteria<RemoteAccessVpnVO> sc = sb.create();
|
||||
|
|
@ -630,6 +635,14 @@ public class RemoteAccessVpnManagerImpl extends ManagerBase implements RemoteAcc
|
|||
if (ipAddressId != null) {
|
||||
sc.setParameters("serverAddressId", ipAddressId);
|
||||
}
|
||||
|
||||
if (vpnId != null) {
|
||||
sc.setParameters("id", vpnId);
|
||||
}
|
||||
|
||||
if (networkId != null) {
|
||||
sc.setParameters("networkId", networkId);
|
||||
}
|
||||
|
||||
Pair<List<RemoteAccessVpnVO>, Integer> result = _remoteAccessVpnDao.searchAndCount(sc, filter);
|
||||
return new Pair<List<? extends RemoteAccessVpn>, Integer> (result.first(), result.second());
|
||||
|
|
@ -683,4 +696,14 @@ public class RemoteAccessVpnManagerImpl extends ManagerBase implements RemoteAcc
|
|||
public ConfigKey<?>[] getConfigKeys() {
|
||||
return new ConfigKey<?>[] {RemoteAccessVpnClientIpRange};
|
||||
}
|
||||
|
||||
public List<RemoteAccessVPNServiceProvider> getVpnServiceProviders() {
|
||||
return _vpnServiceProviders;
|
||||
}
|
||||
|
||||
public void setVpnServiceProviders(
|
||||
List<RemoteAccessVPNServiceProvider> vpnServiceProviders) {
|
||||
this._vpnServiceProviders = vpnServiceProviders;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import javax.naming.ConfigurationException;
|
|||
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.agent.api.Command;
|
||||
import com.cloud.agent.api.HostVmStateReportEntry;
|
||||
import com.cloud.agent.api.PingCommand;
|
||||
import com.cloud.agent.api.PingRoutingCommand;
|
||||
import com.cloud.agent.api.StartupCommand;
|
||||
|
|
@ -57,7 +58,8 @@ public class DummyHostServerResource extends ServerResourceBase {
|
|||
@Override
|
||||
public PingCommand getCurrentStatus(long id) {
|
||||
HashMap<String, VirtualMachine.State> newStates = new HashMap<String, VirtualMachine.State>();
|
||||
return new PingRoutingCommand(com.cloud.host.Host.Type.Routing, id, newStates);
|
||||
return new PingRoutingCommand(com.cloud.host.Host.Type.Routing, id, newStates,
|
||||
new HashMap<String, HostVmStateReportEntry>());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ import javax.naming.ConfigurationException;
|
|||
|
||||
import org.apache.cloudstack.framework.config.ConfigDepot;
|
||||
import org.apache.cloudstack.framework.config.ConfigDepotAdmin;
|
||||
import org.apache.cloudstack.framework.config.ConfigKey;
|
||||
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
|
||||
import org.apache.cloudstack.framework.config.impl.ConfigurationVO;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
|
|
@ -771,9 +772,9 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio
|
|||
public List<ConfigurationVO> getConfigListByScope(String scope, Long resourceId) {
|
||||
|
||||
// Getting the list of parameters defined at the scope
|
||||
List<Config> configList = Config.getConfigListByScope(scope);
|
||||
List<ConfigKey<?>> configList = _configDepot.getConfigListByScope(scope);
|
||||
List<ConfigurationVO> configVOList = new ArrayList<ConfigurationVO>();
|
||||
for (Config param:configList){
|
||||
for (ConfigKey<?> param:configList){
|
||||
ConfigurationVO configVo = _configDao.findByName(param.toString());
|
||||
configVo.setValue(_configDepot.get(param.toString()).valueIn(resourceId).toString());
|
||||
configVOList.add(configVo);
|
||||
|
|
|
|||
|
|
@ -233,11 +233,7 @@ public class HypervisorTemplateAdapter extends TemplateAdapterBase {
|
|||
CreateTemplateContext<TemplateApiResult> context) {
|
||||
TemplateApiResult result = callback.getResult();
|
||||
TemplateInfo template = context.template;
|
||||
if (result.isFailed()) {
|
||||
// failed in creating template, we need to remove those already
|
||||
// populated template entry
|
||||
_tmpltDao.remove(template.getId());
|
||||
} else {
|
||||
if (result.isSuccess()) {
|
||||
VMTemplateVO tmplt = _tmpltDao.findById(template.getId());
|
||||
long accountId = tmplt.getAccountId();
|
||||
if (template.getSize() != null) {
|
||||
|
|
|
|||
|
|
@ -24,16 +24,20 @@ import com.cloud.network.rules.LoadBalancer;
|
|||
import com.cloud.user.dao.AccountDao;
|
||||
import com.cloud.utils.db.EntityManager;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
||||
import org.apache.cloudstack.api.command.user.loadbalancer.DeleteSslCertCmd;
|
||||
import org.apache.cloudstack.api.command.user.loadbalancer.ListSslCertsCmd;
|
||||
import org.apache.cloudstack.api.command.user.loadbalancer.UploadSslCertCmd;
|
||||
import org.apache.cloudstack.api.response.SslCertResponse;
|
||||
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.AccountManager;
|
||||
import com.cloud.utils.db.DB;
|
||||
|
||||
import org.apache.cloudstack.acl.SecurityChecker;
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
||||
import org.bouncycastle.openssl.PEMReader;
|
||||
|
|
@ -45,6 +49,7 @@ import javax.crypto.IllegalBlockSizeException;
|
|||
import javax.crypto.NoSuchPaddingException;
|
||||
import javax.ejb.Local;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.StringReader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
|
@ -228,7 +233,7 @@ public class CertServiceImpl implements CertService {
|
|||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
throw new IllegalArgumentException("Parsing certificate/key failed: " + e.getMessage());
|
||||
throw new IllegalArgumentException("Parsing certificate/key failed: " + e.getMessage(), e);
|
||||
}
|
||||
|
||||
validateCert(cert, _chain != null? true: false);
|
||||
|
|
@ -273,7 +278,7 @@ public class CertServiceImpl implements CertService {
|
|||
try {
|
||||
((X509Certificate)cert).checkValidity();
|
||||
} catch (Exception e) {
|
||||
throw new IllegalArgumentException("Certificate expired or not valid");
|
||||
throw new IllegalArgumentException("Certificate expired or not valid", e);
|
||||
}
|
||||
|
||||
if( !chain_present ) {
|
||||
|
|
@ -281,7 +286,7 @@ public class CertServiceImpl implements CertService {
|
|||
try {
|
||||
cert.verify(pubKey);
|
||||
} catch (Exception e) {
|
||||
throw new IllegalArgumentException("No chain given and certificate not self signed");
|
||||
throw new IllegalArgumentException("No chain given and certificate not self signed", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -309,15 +314,15 @@ public class CertServiceImpl implements CertService {
|
|||
throw new IllegalArgumentException("Bad public-private key");
|
||||
|
||||
} catch (BadPaddingException e) {
|
||||
throw new IllegalArgumentException("Bad public-private key");
|
||||
throw new IllegalArgumentException("Bad public-private key", e);
|
||||
} catch (IllegalBlockSizeException e) {
|
||||
throw new IllegalArgumentException("Bad public-private key");
|
||||
throw new IllegalArgumentException("Bad public-private key", e);
|
||||
} catch (NoSuchPaddingException e) {
|
||||
throw new IllegalArgumentException("Bad public-private key");
|
||||
throw new IllegalArgumentException("Bad public-private key", e);
|
||||
} catch (InvalidKeyException e) {
|
||||
throw new IllegalArgumentException("Invalid public-private key");
|
||||
throw new IllegalArgumentException("Invalid public-private key", e);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new IllegalArgumentException("Invalid algorithm for public-private key");
|
||||
throw new IllegalArgumentException("Invalid algorithm for public-private key", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -363,11 +368,11 @@ public class CertServiceImpl implements CertService {
|
|||
CertPathBuilder builder = CertPathBuilder.getInstance("PKIX");
|
||||
builder.build(params);
|
||||
} catch (InvalidAlgorithmParameterException e) {
|
||||
throw new IllegalArgumentException("Invalid certificate chain",null);
|
||||
throw new IllegalArgumentException("Invalid certificate chain", e);
|
||||
} catch (CertPathBuilderException e) {
|
||||
throw new IllegalArgumentException("Invalid certificate chain",null);
|
||||
throw new IllegalArgumentException("Invalid certificate chain", e);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new IllegalArgumentException("Invalid certificate chain",null);
|
||||
throw new IllegalArgumentException("Invalid certificate chain", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -380,7 +385,12 @@ public class CertServiceImpl implements CertService {
|
|||
pGet = new KeyPassword(password.toCharArray());
|
||||
|
||||
PEMReader privateKey = new PEMReader(new StringReader(key), pGet);
|
||||
Object obj = privateKey.readObject();
|
||||
Object obj = null;
|
||||
try {
|
||||
obj = privateKey.readObject();
|
||||
} finally {
|
||||
IOUtils.closeQuietly(privateKey);
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
|
|
@ -389,9 +399,8 @@ public class CertServiceImpl implements CertService {
|
|||
|
||||
return (PrivateKey) obj;
|
||||
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
throw new IOException("Invalid Key format or invalid password.");
|
||||
} catch (Exception e){
|
||||
throw new IOException("Invalid Key format or invalid password.", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -402,6 +411,8 @@ public class CertServiceImpl implements CertService {
|
|||
return (Certificate) certPem.readObject();
|
||||
} catch (Exception e) {
|
||||
throw new InvalidParameterValueException("Invalid Certificate format. Expected X509 certificate");
|
||||
} finally {
|
||||
IOUtils.closeQuietly(certPem);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -419,7 +430,7 @@ public class CertServiceImpl implements CertService {
|
|||
}
|
||||
}
|
||||
if ( certs.size() == 0 )
|
||||
throw new IllegalArgumentException("Unable to decode certificate chain",null);
|
||||
throw new IllegalArgumentException("Unable to decode certificate chain");
|
||||
|
||||
return certs;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,43 +16,46 @@
|
|||
// under the License.
|
||||
package org.apache.cloudstack.network.lb;
|
||||
|
||||
import com.cloud.network.dao.*;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.AccountManager;
|
||||
import com.cloud.user.AccountVO;
|
||||
import com.cloud.user.UserVO;
|
||||
import com.cloud.user.dao.AccountDao;
|
||||
import com.cloud.utils.db.EntityManager;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.db.TransactionLegacy;
|
||||
import junit.framework.TestCase;
|
||||
import org.apache.cloudstack.api.command.user.loadbalancer.DeleteSslCertCmd;
|
||||
import org.apache.cloudstack.api.command.user.loadbalancer.UploadSslCertCmd;
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
import static org.apache.commons.io.FileUtils.readFileToString;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.anyLong;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.apache.commons.io.FileUtils.readFileToString;
|
||||
import static org.mockito.Matchers.*;
|
||||
import static org.mockito.Mockito.when;
|
||||
import org.apache.cloudstack.api.command.user.loadbalancer.DeleteSslCertCmd;
|
||||
import org.apache.cloudstack.api.command.user.loadbalancer.UploadSslCertCmd;
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
import org.junit.After;
|
||||
import org.junit.Assume;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
public class CertServiceTest extends TestCase {
|
||||
import com.cloud.network.dao.LoadBalancerCertMapDao;
|
||||
import com.cloud.network.dao.LoadBalancerCertMapVO;
|
||||
import com.cloud.network.dao.LoadBalancerVO;
|
||||
import com.cloud.network.dao.SslCertDao;
|
||||
import com.cloud.network.dao.SslCertVO;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.AccountManager;
|
||||
import com.cloud.user.AccountVO;
|
||||
import com.cloud.user.UserVO;
|
||||
import com.cloud.user.dao.AccountDao;
|
||||
import com.cloud.utils.db.EntityManager;
|
||||
import com.cloud.utils.db.TransactionLegacy;
|
||||
|
||||
private static final Logger s_logger = Logger.getLogger( CertServiceTest.class);
|
||||
public class CertServiceTest {
|
||||
|
||||
@Override
|
||||
@Before
|
||||
public void setUp() {
|
||||
Account account = new AccountVO("testaccount", 1, "networkdomain", (short)0, UUID.randomUUID().toString());
|
||||
|
|
@ -60,59 +63,35 @@ public class CertServiceTest extends TestCase {
|
|||
CallContext.register(user, account);
|
||||
}
|
||||
|
||||
@Override
|
||||
@After
|
||||
public void tearDown() {
|
||||
CallContext.unregister();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUploadSslCert() throws Exception {
|
||||
|
||||
/* Test1 : Given a Certificate in bad format (Not PEM), upload should fail */
|
||||
runUploadSslCertBadFormat();
|
||||
|
||||
/* Test2: Given a Certificate which is not X509, upload should fail */
|
||||
runUploadSslCertNotX509();
|
||||
|
||||
/* Test3: Given an expired certificate, upload should fail */
|
||||
runUploadSslCertExpiredCert();
|
||||
|
||||
/* Test4: Given a private key which has a different algorithm than the certificate,
|
||||
upload should fail.
|
||||
*/
|
||||
runUploadSslCertBadkeyAlgo();
|
||||
|
||||
/* Test5: Given a private key which does not match the public key in the certificate,
|
||||
upload should fail
|
||||
*/
|
||||
runUploadSslCertBadkeyPair();
|
||||
|
||||
/* Test6: Given an encrypted private key with a bad password. Upload should fail. */
|
||||
runUploadSslCertBadPassword();
|
||||
|
||||
/* Test7: If no chain is given, the certificate should be self signed. Else, uploadShould Fail */
|
||||
runUploadSslCertNoChain();
|
||||
|
||||
/* Test8: Chain is given but does not have root certificate */
|
||||
runUploadSslCertNoRootCert();
|
||||
|
||||
/* Test9: The chain given is not the correct chain for the certificate */
|
||||
runUploadSslCertBadChain();
|
||||
|
||||
/* Test10: Given a Self-signed Certificate with encrypted key, upload should succeed */
|
||||
runUploadSslCertSelfSignedNoPassword();
|
||||
|
||||
/* Test11: Given a Self-signed Certificate with non-encrypted key, upload should succeed */
|
||||
runUploadSslCertSelfSignedWithPassword();
|
||||
|
||||
/* Test12: Given a certificate signed by a CA and a valid CA chain, upload should succeed */
|
||||
runUploadSslCertWithCAChain();
|
||||
|
||||
/**
|
||||
* JCE is known to be working fine without additional configuration in OpenJDK.
|
||||
* This checks if the tests are running in OpenJDK;
|
||||
* @return true if openjdk environment
|
||||
*/
|
||||
static boolean isOpenJdk() {
|
||||
//TODO: find a better way for OpenJDK detection
|
||||
return System.getProperty("java.home").toLowerCase().contains("openjdk");
|
||||
}
|
||||
|
||||
private void runUploadSslCertWithCAChain() throws Exception {
|
||||
//To change body of created methods use File | Settings | File Templates.
|
||||
/**
|
||||
* One can run the tests on Oracle JDK after installing JCE by specifying -Dcloudstack.jce.enabled=true
|
||||
* @return true if the jce enable property was set to true
|
||||
*/
|
||||
static boolean isJCEInstalled() {
|
||||
return Boolean.getBoolean("cloudstack.jce.enabled");
|
||||
}
|
||||
|
||||
@Test
|
||||
/**
|
||||
* Given a certificate signed by a CA and a valid CA chain, upload should succeed
|
||||
*/
|
||||
public void runUploadSslCertWithCAChain() throws Exception {
|
||||
Assume.assumeTrue(isOpenJdk() || isJCEInstalled());
|
||||
|
||||
TransactionLegacy txn = TransactionLegacy.open("runUploadSslCertWithCAChain");
|
||||
|
||||
|
|
@ -165,7 +144,11 @@ public class CertServiceTest extends TestCase {
|
|||
certService.uploadSslCert(uploadCmd);
|
||||
}
|
||||
|
||||
private void runUploadSslCertSelfSignedWithPassword() throws Exception {
|
||||
@Test
|
||||
/**
|
||||
* Given a Self-signed Certificate with non-encrypted key, upload should succeed
|
||||
*/
|
||||
public void runUploadSslCertSelfSignedWithPassword() throws Exception {
|
||||
|
||||
TransactionLegacy txn = TransactionLegacy.open("runUploadSslCertSelfSignedWithPassword");
|
||||
|
||||
|
|
@ -212,7 +195,11 @@ public class CertServiceTest extends TestCase {
|
|||
certService.uploadSslCert(uploadCmd);
|
||||
}
|
||||
|
||||
private void runUploadSslCertSelfSignedNoPassword() throws Exception {
|
||||
@Test
|
||||
/**
|
||||
* Given a Self-signed Certificate with encrypted key, upload should succeed
|
||||
*/
|
||||
public void runUploadSslCertSelfSignedNoPassword() throws Exception {
|
||||
|
||||
TransactionLegacy txn = TransactionLegacy.open("runUploadSslCertSelfSignedNoPassword");
|
||||
|
||||
|
|
@ -255,8 +242,10 @@ public class CertServiceTest extends TestCase {
|
|||
}
|
||||
|
||||
|
||||
private void runUploadSslCertBadChain() throws IOException, IllegalAccessException, NoSuchFieldException {
|
||||
//To change body of created methods use File | Settings | File Templates.
|
||||
@Test
|
||||
public void runUploadSslCertBadChain() throws IOException, IllegalAccessException, NoSuchFieldException {
|
||||
Assume.assumeTrue(isOpenJdk() || isJCEInstalled());
|
||||
|
||||
String certFile = getClass().getResource("/certs/rsa_ca_signed.crt").getFile();
|
||||
String keyFile = getClass().getResource("/certs/rsa_ca_signed.key").getFile();
|
||||
String chainFile = getClass().getResource("/certs/rsa_self_signed.crt").getFile();
|
||||
|
|
@ -300,14 +289,17 @@ public class CertServiceTest extends TestCase {
|
|||
|
||||
try {
|
||||
certService.uploadSslCert(uploadCmd);
|
||||
fail("The chain given is not the correct chain for the certificate");
|
||||
} catch (Exception e) {
|
||||
assertTrue(e.getMessage().contains("Invalid certificate chain"));
|
||||
}
|
||||
}
|
||||
|
||||
private void runUploadSslCertNoRootCert() throws IOException, IllegalAccessException, NoSuchFieldException {
|
||||
@Test
|
||||
public void runUploadSslCertNoRootCert() throws IOException, IllegalAccessException, NoSuchFieldException {
|
||||
|
||||
Assume.assumeTrue(isOpenJdk() || isJCEInstalled());
|
||||
|
||||
//To change body of created methods use File | Settings | File Templates.
|
||||
String certFile = getClass().getResource("/certs/rsa_ca_signed.crt").getFile();
|
||||
String keyFile = getClass().getResource("/certs/rsa_ca_signed.key").getFile();
|
||||
String chainFile = getClass().getResource("/certs/rsa_ca_signed2.crt").getFile();
|
||||
|
|
@ -351,14 +343,18 @@ public class CertServiceTest extends TestCase {
|
|||
|
||||
try {
|
||||
certService.uploadSslCert(uploadCmd);
|
||||
fail("Chain is given but does not have root certificate");
|
||||
} catch (Exception e) {
|
||||
assertTrue(e.getMessage().contains("No root certificates found"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void runUploadSslCertNoChain() throws IOException, IllegalAccessException, NoSuchFieldException {
|
||||
@Test
|
||||
public void runUploadSslCertNoChain() throws IOException, IllegalAccessException, NoSuchFieldException {
|
||||
|
||||
Assume.assumeTrue(isOpenJdk() || isJCEInstalled());
|
||||
|
||||
String certFile = getClass().getResource("/certs/rsa_ca_signed.crt").getFile();
|
||||
String keyFile = getClass().getResource("/certs/rsa_ca_signed.key").getFile();
|
||||
String password = "user";
|
||||
|
|
@ -394,16 +390,17 @@ public class CertServiceTest extends TestCase {
|
|||
passField.setAccessible(true);
|
||||
passField.set(uploadCmd, password);
|
||||
|
||||
|
||||
try {
|
||||
certService.uploadSslCert(uploadCmd);
|
||||
fail("If no chain is given, the certificate should be self signed. Else, uploadShould Fail");
|
||||
} catch (Exception e) {
|
||||
assertTrue(e.getMessage().contains("No chain given and certificate not self signed"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void runUploadSslCertBadPassword() throws IOException, IllegalAccessException, NoSuchFieldException {
|
||||
@Test
|
||||
public void runUploadSslCertBadPassword() throws IOException, IllegalAccessException, NoSuchFieldException {
|
||||
|
||||
String certFile = getClass().getResource("/certs/rsa_self_signed_with_pwd.crt").getFile();
|
||||
String keyFile = getClass().getResource("/certs/rsa_self_signed_with_pwd.key").getFile();
|
||||
|
|
@ -443,13 +440,15 @@ public class CertServiceTest extends TestCase {
|
|||
|
||||
try {
|
||||
certService.uploadSslCert(uploadCmd);
|
||||
fail("Given an encrypted private key with a bad password. Upload should fail.");
|
||||
} catch (Exception e) {
|
||||
assertTrue(e.getMessage().contains("please check password and data"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void runUploadSslCertBadkeyPair() throws IOException, IllegalAccessException, NoSuchFieldException {
|
||||
@Test
|
||||
public void runUploadSslCertBadkeyPair() throws IOException, IllegalAccessException, NoSuchFieldException {
|
||||
// Reading appropritate files
|
||||
String certFile = getClass().getResource("/certs/rsa_self_signed.crt").getFile();
|
||||
String keyFile = getClass().getResource("/certs/rsa_random_pkey.key").getFile();
|
||||
|
|
@ -487,7 +486,8 @@ public class CertServiceTest extends TestCase {
|
|||
}
|
||||
}
|
||||
|
||||
private void runUploadSslCertBadkeyAlgo() throws IOException, IllegalAccessException, NoSuchFieldException {
|
||||
@Test
|
||||
public void runUploadSslCertBadkeyAlgo() throws IOException, IllegalAccessException, NoSuchFieldException {
|
||||
|
||||
// Reading appropritate files
|
||||
String certFile = getClass().getResource("/certs/rsa_self_signed.crt").getFile();
|
||||
|
|
@ -521,12 +521,14 @@ public class CertServiceTest extends TestCase {
|
|||
|
||||
try {
|
||||
certService.uploadSslCert(uploadCmd);
|
||||
fail("Given a private key which has a different algorithm than the certificate, upload should fail");
|
||||
} catch (Exception e) {
|
||||
assertTrue(e.getMessage().contains("Public and private key have different algorithms"));
|
||||
}
|
||||
}
|
||||
|
||||
private void runUploadSslCertExpiredCert() throws IOException, IllegalAccessException, NoSuchFieldException {
|
||||
@Test
|
||||
public void runUploadSslCertExpiredCert() throws IOException, IllegalAccessException, NoSuchFieldException {
|
||||
|
||||
// Reading appropritate files
|
||||
String certFile = getClass().getResource("/certs/expired_cert.crt").getFile();
|
||||
|
|
@ -560,12 +562,14 @@ public class CertServiceTest extends TestCase {
|
|||
|
||||
try {
|
||||
certService.uploadSslCert(uploadCmd);
|
||||
fail("Given an expired certificate, upload should fail");
|
||||
} catch (Exception e) {
|
||||
assertTrue(e.getMessage().contains("Certificate expired"));
|
||||
}
|
||||
}
|
||||
|
||||
private void runUploadSslCertNotX509() throws IOException, IllegalAccessException, NoSuchFieldException {
|
||||
@Test
|
||||
public void runUploadSslCertNotX509() throws IOException, IllegalAccessException, NoSuchFieldException {
|
||||
// Reading appropritate files
|
||||
String certFile = getClass().getResource("/certs/non_x509_pem.crt").getFile();
|
||||
String keyFile = getClass().getResource("/certs/rsa_self_signed.key").getFile();
|
||||
|
|
@ -598,12 +602,14 @@ public class CertServiceTest extends TestCase {
|
|||
|
||||
try {
|
||||
certService.uploadSslCert(uploadCmd);
|
||||
fail("Given a Certificate which is not X509, upload should fail");
|
||||
} catch (Exception e) {
|
||||
assertTrue(e.getMessage().contains("Expected X509 certificate"));
|
||||
}
|
||||
}
|
||||
|
||||
private void runUploadSslCertBadFormat() throws IOException, IllegalAccessException, NoSuchFieldException {
|
||||
@Test
|
||||
public void runUploadSslCertBadFormat() throws IOException, IllegalAccessException, NoSuchFieldException {
|
||||
|
||||
// Reading appropritate files
|
||||
String certFile = getClass().getResource("/certs/bad_format_cert.crt").getFile();
|
||||
|
|
@ -637,6 +643,7 @@ public class CertServiceTest extends TestCase {
|
|||
|
||||
try {
|
||||
certService.uploadSslCert(uploadCmd);
|
||||
fail("Given a Certificate in bad format (Not PEM), upload should fail");
|
||||
} catch (Exception e) {
|
||||
assertTrue(e.getMessage().contains("Invalid certificate format"));
|
||||
}
|
||||
|
|
@ -644,20 +651,10 @@ public class CertServiceTest extends TestCase {
|
|||
|
||||
|
||||
@Test
|
||||
public void testDeleteSslCert() throws Exception {
|
||||
/* Test1: Delete with an invalid ID should fail */
|
||||
runDeleteSslCertInvalidId();
|
||||
|
||||
/* Test2: Delete with a cert id bound to a lb should fail */
|
||||
runDeleteSslCertBoundCert();
|
||||
|
||||
/* Test3: Delete with a valid Id should succeed */
|
||||
runDeleteSslCertValid();
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void runDeleteSslCertValid() throws Exception {
|
||||
/**
|
||||
* Delete with a valid Id should succeed
|
||||
*/
|
||||
public void runDeleteSslCertValid() throws Exception {
|
||||
|
||||
TransactionLegacy txn = TransactionLegacy.open("runDeleteSslCertValid");
|
||||
|
||||
|
|
@ -690,7 +687,8 @@ public class CertServiceTest extends TestCase {
|
|||
certService.deleteSslCert(deleteCmd);
|
||||
}
|
||||
|
||||
private void runDeleteSslCertBoundCert() throws NoSuchFieldException, IllegalAccessException {
|
||||
@Test
|
||||
public void runDeleteSslCertBoundCert() throws NoSuchFieldException, IllegalAccessException {
|
||||
|
||||
TransactionLegacy txn = TransactionLegacy.open("runDeleteSslCertBoundCert");
|
||||
|
||||
|
|
@ -731,6 +729,7 @@ public class CertServiceTest extends TestCase {
|
|||
|
||||
try {
|
||||
certService.deleteSslCert(deleteCmd);
|
||||
fail("Delete with a cert id bound to a lb should fail");
|
||||
}catch (Exception e){
|
||||
assertTrue(e.getMessage().contains("Certificate in use by a loadbalancer"));
|
||||
}
|
||||
|
|
@ -738,7 +737,8 @@ public class CertServiceTest extends TestCase {
|
|||
|
||||
}
|
||||
|
||||
private void runDeleteSslCertInvalidId() throws NoSuchFieldException, IllegalAccessException {
|
||||
@Test
|
||||
public void runDeleteSslCertInvalidId() throws NoSuchFieldException, IllegalAccessException {
|
||||
|
||||
TransactionLegacy txn = TransactionLegacy.open("runDeleteSslCertInvalidId");
|
||||
|
||||
|
|
@ -768,6 +768,7 @@ public class CertServiceTest extends TestCase {
|
|||
|
||||
try {
|
||||
certService.deleteSslCert(deleteCmd);
|
||||
fail("Delete with an invalid ID should fail");
|
||||
}catch (Exception e){
|
||||
assertTrue(e.getMessage().contains("Invalid certificate id"));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import javax.inject.Inject;
|
|||
import org.apache.cloudstack.acl.SecurityChecker;
|
||||
import org.apache.cloudstack.affinity.AffinityGroupService;
|
||||
import org.apache.cloudstack.affinity.dao.AffinityGroupDao;
|
||||
import org.apache.cloudstack.framework.config.ConfigDepot;
|
||||
import org.apache.cloudstack.region.PortableIpDaoImpl;
|
||||
import org.apache.cloudstack.region.dao.RegionDaoImpl;
|
||||
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDaoImpl;
|
||||
|
|
@ -308,6 +309,11 @@ public class ChildTestConfiguration {
|
|||
return Mockito.mock(ConfigurationDao.class);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ConfigDepot configDepot() {
|
||||
return Mockito.mock(ConfigDepot.class);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public CallContext userContext() {
|
||||
return Mockito.mock(CallContext.class);
|
||||
|
|
|
|||
|
|
@ -21,16 +21,39 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>rdpclient</groupId>
|
||||
<artifactId>cloudstack-service-console-proxy-rdpclient</artifactId>
|
||||
<version>4.3.0-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>Apache CloudStack Console Proxy - RDP Client</name>
|
||||
<url>http://maven.apache.org</url>
|
||||
|
||||
<parent>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloudstack-services</artifactId>
|
||||
<version>4.3.0-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<!-- not parenting to the maven-default pom, as we want this in services -->
|
||||
<build>
|
||||
<sourceDirectory>${basedir}/src/main/java</sourceDirectory>
|
||||
<scriptSourceDirectory>${basedir}/src/main/scripts</scriptSourceDirectory>
|
||||
<testSourceDirectory>${basedir}/src/test/java</testSourceDirectory>
|
||||
<outputDirectory>${basedir}/target/classes</outputDirectory>
|
||||
<testOutputDirectory>${basedir}/target/test-classes</testOutputDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>${basedir}/src/main/resources</directory>
|
||||
</resource>
|
||||
</resources>
|
||||
<testResources>
|
||||
<testResource>
|
||||
<directory>${basedir}/src/test/resources</directory>
|
||||
</testResource>
|
||||
</testResources>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ public class SocketWrapper extends PipelineImpl {
|
|||
sslContext.init(null, new TrustManager[] { new TrustAllX509TrustManager() }, null);
|
||||
|
||||
SSLSocketFactory sslSocketFactory = sslContext.getSocketFactory();
|
||||
sslSocket = (SSLSocket) sslSocketFactory.createSocket(socket, address.getHostString(), address.getPort(), true);
|
||||
sslSocket = (SSLSocket) sslSocketFactory.createSocket(socket, address.getHostName(), address.getPort(), true);
|
||||
sslSocket.startHandshake();
|
||||
|
||||
InputStream sis = sslSocket.getInputStream();
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ public class MockServerTest extends TestCase {
|
|||
//System.setProperty("javax.net.debug", "ssl");
|
||||
|
||||
final SSLSocketFactory sslSocketFactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
|
||||
SSLSocket sslSocket = (SSLSocket) sslSocketFactory.createSocket(socket, address.getHostString(), address.getPort(), true);
|
||||
SSLSocket sslSocket = (SSLSocket) sslSocketFactory.createSocket(socket, address.getHostName(), address.getPort(), true);
|
||||
sslSocket.setEnabledCipherSuites(sslSocket.getSupportedCipherSuites());
|
||||
sslSocket.startHandshake();
|
||||
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue