mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-03 04:12:31 +01:00
Merge branch 'master' of ssh://git.cloud.com/var/lib/git/cloudstack-oss
This commit is contained in:
commit
a6fca4ee64
@ -2139,7 +2139,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
||||
|
||||
}
|
||||
|
||||
HostStatsEntry hostStats = new HostStatsEntry(cmd.getHostId(), cpuUtil, rx, tx, numCpus, "host", totMem, freeMem, 0, 0);
|
||||
HostStatsEntry hostStats = new HostStatsEntry(cmd.getHostId(), cpuUtil, rx, tx, "host", totMem, freeMem, 0, 0);
|
||||
return new GetHostStatsAnswer(cmd, hostStats);
|
||||
}
|
||||
|
||||
|
||||
47
api/src/com/cloud/api/response/CapabilityResponse.java
Normal file
47
api/src/com/cloud/api/response/CapabilityResponse.java
Normal file
@ -0,0 +1,47 @@
|
||||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.cloud.api.response;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.serializer.Param;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class CapabilityResponse extends BaseResponse {
|
||||
|
||||
@SerializedName(ApiConstants.NAME) @Param(description="the capability name")
|
||||
private String name;
|
||||
|
||||
@SerializedName(ApiConstants.VALUE) @Param(description="the capability value")
|
||||
private String value;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,7 @@
|
||||
package com.cloud.api.response;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.serializer.Param;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
@ -102,6 +104,9 @@ public class NetworkResponse extends BaseResponse{
|
||||
|
||||
@SerializedName(ApiConstants.DOMAIN) @Param(description="the domain associated with the network")
|
||||
private String domain;
|
||||
|
||||
@SerializedName("service") @Param(description="the list of services")
|
||||
private List<ServiceResponse> services;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
@ -310,6 +315,12 @@ public class NetworkResponse extends BaseResponse{
|
||||
public void setNetworkOfferingAvailability(String networkOfferingAvailability) {
|
||||
this.networkOfferingAvailability = networkOfferingAvailability;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public List<ServiceResponse> getServices() {
|
||||
return services;
|
||||
}
|
||||
|
||||
public void setServices(List<ServiceResponse> services) {
|
||||
this.services = services;
|
||||
}
|
||||
}
|
||||
|
||||
49
api/src/com/cloud/api/response/ServiceResponse.java
Normal file
49
api/src/com/cloud/api/response/ServiceResponse.java
Normal file
@ -0,0 +1,49 @@
|
||||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.cloud.api.response;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.serializer.Param;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class ServiceResponse extends BaseResponse {
|
||||
|
||||
@SerializedName(ApiConstants.NAME) @Param(description="the service name")
|
||||
private String name;
|
||||
|
||||
@SerializedName("capability") @Param(description="the list of capabilities")
|
||||
private List<CapabilityResponse> capabilities;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public List<CapabilityResponse> getCapabilities() {
|
||||
return capabilities;
|
||||
}
|
||||
|
||||
public void setCapabilities(List<CapabilityResponse> capabilities) {
|
||||
this.capabilities = capabilities;
|
||||
}
|
||||
}
|
||||
@ -142,12 +142,12 @@ public class UserVmResponse extends BaseResponse {
|
||||
@SerializedName("jobstatus") @Param(description="shows the current pending asynchronous job status")
|
||||
private Integer jobStatus;
|
||||
|
||||
@SerializedName("nic") @Param(description="the list of nics associated with vm")
|
||||
private List<NicResponse> nics;
|
||||
|
||||
public Long getObjectId() {
|
||||
return getId();
|
||||
}
|
||||
|
||||
@SerializedName("nic") @Param(description="the list of nics associated with vm")
|
||||
private List<NicResponse> nics;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
|
||||
@ -20,6 +20,73 @@ import com.cloud.utils.fsm.StateMachine;
|
||||
* owned by an account.
|
||||
*/
|
||||
public interface Network extends ControlledEntity {
|
||||
|
||||
public static class Service {
|
||||
|
||||
public static final Service Vpn = new Service("Vpn");
|
||||
public static final Service Dhcp = new Service("Dhcp");
|
||||
public static final Service Dns = new Service("Dns");
|
||||
public static final Service Gateway = new Service("Gateway");
|
||||
public static final Service Firewall = new Service("Firewall", Capability.PortForwarding, Capability.StaticNat);
|
||||
public static final Service Lb = new Service("Lb");
|
||||
public static final Service UserData = new Service("UserData");
|
||||
|
||||
private String name;
|
||||
private Capability[] caps;
|
||||
|
||||
public Service(String name, Capability... caps) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public Capability[] getCapabilities() {
|
||||
return caps;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Provider {
|
||||
|
||||
public static final Provider VirtualRouter = new Provider("VirtualRouter");
|
||||
public static final Provider DhcpServer = new Provider("DhcpServer");
|
||||
public static final Provider ExternalFirewall = new Provider("ExternalFirewall");
|
||||
public static final Provider ExternalLoadBalancer = new Provider("ExternalLoadBalancer");
|
||||
|
||||
private String name;
|
||||
|
||||
public Provider(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Capability {
|
||||
|
||||
public static final Capability PortForwarding = new Capability("PortForwarding");
|
||||
public static final Capability StaticNat = new Capability("StaticNat");
|
||||
public static final Capability SupportedProtocols = new Capability("SupportedProtocols");
|
||||
public static final Capability SupportedLBAlgorithms = new Capability("SupportedLBAlgorithms");
|
||||
public static final Capability Vpn = new Capability("VPN");
|
||||
public static final Capability MultipleIps = new Capability("MultipleIps");
|
||||
public static final Capability SupportedSourceNatTypes = new Capability("SupportedSourceNatTypes");
|
||||
public static final Capability SupportedVpnTypes = new Capability("SupportedVpnTypes");
|
||||
|
||||
private String name;
|
||||
|
||||
public Capability(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
enum Event {
|
||||
ImplementNetwork,
|
||||
DestroyNetwork,
|
||||
@ -114,4 +181,5 @@ public interface Network extends ControlledEntity {
|
||||
boolean isShared();
|
||||
|
||||
String getReservationId();
|
||||
|
||||
}
|
||||
|
||||
@ -90,4 +90,5 @@ public interface NetworkService {
|
||||
boolean restartNetwork(RestartNetworkCmd cmd) throws ConcurrentOperationException, ResourceUnavailableException;
|
||||
|
||||
int getActiveNicsInNetwork(long networkId);
|
||||
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
package com.cloud.network.element;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.cloud.deploy.DeployDestination;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
@ -11,6 +12,9 @@ import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.InsufficientNetworkCapacityException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.Network.Capability;
|
||||
import com.cloud.network.Network.Provider;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.PublicIpAddress;
|
||||
import com.cloud.network.rules.FirewallRule;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
@ -24,6 +28,11 @@ import com.cloud.vm.VirtualMachineProfile;
|
||||
* Represents one network element that exists in a network.
|
||||
*/
|
||||
public interface NetworkElement extends Adapter {
|
||||
|
||||
Map<Service, Map<Capability, String>> getCapabilities();
|
||||
|
||||
Provider getProvider();
|
||||
|
||||
/**
|
||||
* Implement the network configuration as specified.
|
||||
* @param config fully specified network configuration.
|
||||
|
||||
@ -29,7 +29,6 @@
|
||||
<param name="cache.size">50</param>
|
||||
<param name="cache.time.to.live">-1</param>
|
||||
</dao>
|
||||
<dao name="Events" class="com.cloud.event.dao.EventDaoImpl"/>
|
||||
<dao name="UserStats" class="com.cloud.user.dao.UserStatisticsDaoImpl"/>
|
||||
<dao name="IP Addresses" class="com.cloud.network.dao.IPAddressDaoImpl"/>
|
||||
<dao name="Usage" class="com.cloud.usage.dao.UsageDaoImpl"/>
|
||||
@ -41,6 +40,8 @@
|
||||
<dao name="Usage IPAddress" class="com.cloud.usage.dao.UsageIPAddressDaoImpl"/>
|
||||
<dao name="Usage Job" class="com.cloud.usage.dao.UsageJobDaoImpl"/>
|
||||
<dao name="Configuration" class="com.cloud.configuration.dao.ConfigurationDaoImpl"/>
|
||||
<dao name="Usage Event" class="com.cloud.event.dao.UsageEventDaoImpl"/>
|
||||
<manager name="Usage alert manager" class="com.cloud.usage.UsageAlertManagerImpl"/>
|
||||
<manager name="usage manager" class="com.cloud.usage.UsageManagerImpl">
|
||||
<param name="period">DAILY</param> <!-- DAILY, WEEKLY, MONTHLY; how often it creates usage records -->
|
||||
</manager>
|
||||
|
||||
@ -96,6 +96,6 @@
|
||||
<dao name="DomainDao" class="com.cloud.domain.dao.DomainDaoImpl" singleton="false"/>
|
||||
<dao name="NetworkOfferingDao" class="com.cloud.offerings.dao.NetworkOfferingDaoImpl" singleton="false"/>
|
||||
<dao name="DataCenterDao" class="com.cloud.dc.dao.DataCenterDaoImpl" singleton="false"/>
|
||||
<dao name="NetworkDao" class="com.cloud.network.dao.NetworkDaoImpl" singleton="false"/>
|
||||
<dao name="NetworkDao" class="com.cloud.network.dao.NetworkDaoImpl" singleton="false"/>
|
||||
</configuration-server>
|
||||
</components.xml>
|
||||
|
||||
@ -17,8 +17,6 @@
|
||||
*/
|
||||
package com.cloud.agent.api;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.cloud.host.HostStats;
|
||||
|
||||
/**
|
||||
@ -28,18 +26,9 @@ import com.cloud.host.HostStats;
|
||||
public class GetHostStatsAnswer extends Answer implements HostStats {
|
||||
|
||||
HostStatsEntry hostStats;
|
||||
|
||||
double cpuUtilization;
|
||||
double networkReadKBs;
|
||||
double networkWriteKBs;
|
||||
int numCPUs;
|
||||
String entityType;
|
||||
double totalMemoryKBs;
|
||||
double freeMemoryKBs;
|
||||
double xapiMemoryUsageKBs;
|
||||
double averageLoad;
|
||||
|
||||
|
||||
protected GetHostStatsAnswer() {
|
||||
hostStats = new HostStatsEntry();
|
||||
}
|
||||
|
||||
public GetHostStatsAnswer(GetHostStatsCommand cmd, HostStatsEntry hostStatistics) {
|
||||
@ -48,67 +37,51 @@ public class GetHostStatsAnswer extends Answer implements HostStats {
|
||||
}
|
||||
|
||||
public GetHostStatsAnswer(GetHostStatsCommand cmd, double cpuUtilization, double freeMemoryKBs, double totalMemoryKBs, double networkReadKBs,
|
||||
double networkWriteKBs, String entityType, double xapiMemoryUsageKBs, double averageLoad, int numCPUs) {
|
||||
double networkWriteKBs, String entityType) {
|
||||
super(cmd);
|
||||
|
||||
this.cpuUtilization = cpuUtilization;
|
||||
this.freeMemoryKBs = freeMemoryKBs;
|
||||
this.totalMemoryKBs = totalMemoryKBs;
|
||||
this.networkReadKBs = networkReadKBs;
|
||||
this.networkWriteKBs = networkWriteKBs;
|
||||
this.entityType = entityType;
|
||||
this.xapiMemoryUsageKBs = xapiMemoryUsageKBs;
|
||||
this.numCPUs = numCPUs;
|
||||
hostStats = new HostStatsEntry();
|
||||
|
||||
hostStats.setCpuUtilization(cpuUtilization);
|
||||
hostStats.setFreeMemoryKBs(freeMemoryKBs);
|
||||
hostStats.setTotalMemoryKBs(totalMemoryKBs);
|
||||
hostStats.setNetworkReadKBs(networkReadKBs);
|
||||
hostStats.setNetworkWriteKBs(networkWriteKBs);
|
||||
hostStats.setEntityType(entityType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getUsedMemory() {
|
||||
return (totalMemoryKBs - freeMemoryKBs);
|
||||
return hostStats.getUsedMemory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getFreeMemoryKBs() {
|
||||
return freeMemoryKBs;
|
||||
return hostStats.getFreeMemoryKBs();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getTotalMemoryKBs() {
|
||||
return totalMemoryKBs;
|
||||
return hostStats.getTotalMemoryKBs();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getCpuUtilization() {
|
||||
return cpuUtilization;
|
||||
return hostStats.getCpuUtilization();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getNetworkReadKBs() {
|
||||
return networkReadKBs;
|
||||
return hostStats.getNetworkReadKBs();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getNetworkWriteKBs() {
|
||||
return networkWriteKBs;
|
||||
return hostStats.getNetworkWriteKBs();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getAverageLoad() {
|
||||
return averageLoad;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEntityType() {
|
||||
return entityType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getXapiMemoryUsageKBs() {
|
||||
return xapiMemoryUsageKBs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNumCpus(){
|
||||
return numCPUs;
|
||||
return hostStats.getEntityType();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -26,43 +26,28 @@ import com.cloud.host.HostStats;
|
||||
public class HostStatsEntry implements HostStats {
|
||||
|
||||
long hostId;
|
||||
String entityType;
|
||||
double cpuUtilization;
|
||||
double networkReadKBs;
|
||||
double networkWriteKBs;
|
||||
int numCpus;
|
||||
String entityType;
|
||||
double totalMemoryKBs;
|
||||
double freeMemoryKBs;
|
||||
double xapiMemoryUsageKBs;
|
||||
double averageLoad;
|
||||
|
||||
public HostStatsEntry() {
|
||||
}
|
||||
|
||||
public HostStatsEntry(long hostId,double cpuUtilization, double networkReadKBs, double networkWriteKBs, int numCPUs, String entityType,
|
||||
double totalMemoryKBs, double freeMemoryKBs, double xapiMemoryUsageKBs, double averageLoad)
|
||||
public HostStatsEntry(long hostId,double cpuUtilization, double networkReadKBs, double networkWriteKBs, String entityType,
|
||||
double totalMemoryKBs, double freeMemoryKBs, double xapiMemoryUsageKBs, double averageLoad)
|
||||
{
|
||||
this.hostId = hostId;
|
||||
this.entityType = entityType;
|
||||
this.cpuUtilization = cpuUtilization;
|
||||
this.networkReadKBs = networkReadKBs;
|
||||
this.networkWriteKBs = networkWriteKBs;
|
||||
this.numCpus = numCPUs;
|
||||
this.entityType = entityType;
|
||||
this.totalMemoryKBs = totalMemoryKBs;
|
||||
this.freeMemoryKBs = freeMemoryKBs;
|
||||
this.xapiMemoryUsageKBs = xapiMemoryUsageKBs;
|
||||
this.averageLoad = averageLoad;
|
||||
this.hostId = hostId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getAverageLoad() {
|
||||
return averageLoad;
|
||||
}
|
||||
|
||||
public void setAverageLoad(double averageLoad) {
|
||||
this.averageLoad = averageLoad;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getNetworkReadKBs() {
|
||||
return networkReadKBs;
|
||||
@ -80,10 +65,6 @@ public class HostStatsEntry implements HostStats {
|
||||
public void setNetworkWriteKBs(double networkWriteKBs) {
|
||||
this.networkWriteKBs = networkWriteKBs;
|
||||
}
|
||||
|
||||
public void setNumCpus(int numCpus) {
|
||||
this.numCpus = numCpus;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEntityType(){
|
||||
@ -112,15 +93,6 @@ public class HostStatsEntry implements HostStats {
|
||||
this.freeMemoryKBs = freeMemoryKBs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getXapiMemoryUsageKBs(){
|
||||
return this.xapiMemoryUsageKBs;
|
||||
}
|
||||
|
||||
public void setXapiMemoryUsageKBs(double xapiMemoryUsageKBs){
|
||||
this.xapiMemoryUsageKBs = xapiMemoryUsageKBs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getCpuUtilization() {
|
||||
return this.cpuUtilization;
|
||||
@ -135,14 +107,12 @@ public class HostStatsEntry implements HostStats {
|
||||
return (totalMemoryKBs-freeMemoryKBs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNumCpus() {
|
||||
return numCpus;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HostStats getHostStats() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void setHostId(long hostId) {
|
||||
this.hostId = hostId;
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,17 +18,21 @@
|
||||
package com.cloud.agent.api;
|
||||
|
||||
public class SetupAnswer extends Answer {
|
||||
// indicate if agent reconnect is needed after setup command
|
||||
private boolean _reconnect;
|
||||
public SetupAnswer() {}
|
||||
|
||||
public SetupAnswer(SetupCommand cmd) {
|
||||
public SetupAnswer(SetupCommand cmd, boolean reconnect) {
|
||||
super(cmd, true, null);
|
||||
_reconnect = reconnect;
|
||||
}
|
||||
|
||||
public SetupAnswer(SetupCommand cmd, boolean result, String details) {
|
||||
super(cmd, result, details);
|
||||
}
|
||||
|
||||
|
||||
public SetupAnswer(SetupCommand cmd, String details) {
|
||||
super(cmd, false, details);
|
||||
_reconnect = true;
|
||||
}
|
||||
public boolean needReconnect() {
|
||||
return _reconnect;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -15,10 +15,19 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.cloud.network.service;
|
||||
package com.cloud.event;
|
||||
|
||||
public class Providers {
|
||||
public final static String VirtualRouter = "VirtualRouter";
|
||||
public final static String ExternalFirewall = "ExternalFirewall";
|
||||
public final static String ExternalLoadBalancer = "ExternalLoadBalancer";
|
||||
import java.util.Date;
|
||||
|
||||
public interface UsageEvent {
|
||||
long getId();
|
||||
String getType();
|
||||
|
||||
Date getCreateDate();
|
||||
long getAccountId();
|
||||
Long getSize();
|
||||
Long getTemplateId();
|
||||
Long getOfferingId();
|
||||
long getResourceId();
|
||||
long getZoneId();
|
||||
}
|
||||
169
core/src/com/cloud/event/UsageEventVO.java
Normal file
169
core/src/com/cloud/event/UsageEventVO.java
Normal file
@ -0,0 +1,169 @@
|
||||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.cloud.event;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.PrimaryKeyJoinColumn;
|
||||
import javax.persistence.SecondaryTable;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
@Entity
|
||||
@Table(name="usage_event")
|
||||
@SecondaryTable(name="account",
|
||||
pkJoinColumns={@PrimaryKeyJoinColumn(name="account_id", referencedColumnName="id")})
|
||||
public class UsageEventVO implements UsageEvent {
|
||||
@Id
|
||||
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
||||
@Column(name="id")
|
||||
private long id = -1;
|
||||
|
||||
@Column(name="type")
|
||||
private String type;
|
||||
|
||||
@Column(name=GenericDao.CREATED_COLUMN)
|
||||
private Date createDate;
|
||||
|
||||
@Column(name="account_id")
|
||||
private long accountId;
|
||||
|
||||
@Column(name="zone_id")
|
||||
private long zoneId;
|
||||
|
||||
@Column(name="resource_id")
|
||||
private long resourceId;
|
||||
|
||||
@Column(name="resource_name")
|
||||
private String resourceName;
|
||||
|
||||
@Column(name="offering_id")
|
||||
private Long offeringId;
|
||||
|
||||
@Column(name="template_id")
|
||||
private Long templateId;
|
||||
|
||||
@Column(name="size")
|
||||
private Long size;
|
||||
|
||||
|
||||
public UsageEventVO() {
|
||||
}
|
||||
|
||||
public UsageEventVO(String usageType, long accountId, long zoneId, long resourceId, String resourceName, Long offeringId, Long templateId, Long size) {
|
||||
this.type = usageType;
|
||||
this.accountId = accountId;
|
||||
this.zoneId = zoneId;
|
||||
this.resourceId = resourceId;
|
||||
this.resourceName = resourceName;
|
||||
this.offeringId = offeringId;
|
||||
this.templateId = templateId;
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
public UsageEventVO(String usageType, long accountId, long zoneId, long resourceId, String resourceName) {
|
||||
this.type = usageType;
|
||||
this.accountId = accountId;
|
||||
this.zoneId = zoneId;
|
||||
this.resourceId = resourceId;
|
||||
this.resourceName = resourceName;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
@Override
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Date getCreateDate() {
|
||||
return createDate;
|
||||
}
|
||||
public void setCreatedDate(Date createdDate) {
|
||||
createDate = createdDate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getAccountId() {
|
||||
return accountId;
|
||||
}
|
||||
public void setAccountId(long accountId) {
|
||||
this.accountId = accountId;
|
||||
}
|
||||
|
||||
public void setZoneId(long zoneId) {
|
||||
this.zoneId = zoneId;
|
||||
}
|
||||
@Override
|
||||
public long getZoneId() {
|
||||
return zoneId;
|
||||
}
|
||||
|
||||
public void setResourceId(long resourceId) {
|
||||
this.resourceId = resourceId;
|
||||
}
|
||||
@Override
|
||||
public long getResourceId() {
|
||||
return resourceId;
|
||||
}
|
||||
|
||||
public void setResourceName(String resourceName) {
|
||||
this.resourceName = resourceName;
|
||||
}
|
||||
|
||||
public String getResourceName() {
|
||||
return resourceName;
|
||||
}
|
||||
|
||||
public void setOfferingId(long offeringId) {
|
||||
this.offeringId = offeringId;
|
||||
}
|
||||
@Override
|
||||
public Long getOfferingId() {
|
||||
return offeringId;
|
||||
}
|
||||
|
||||
public void setTemplateId(long templateId) {
|
||||
this.templateId = templateId;
|
||||
}
|
||||
@Override
|
||||
public Long getTemplateId() {
|
||||
return templateId;
|
||||
}
|
||||
|
||||
public void setSize(long size) {
|
||||
this.size = size;
|
||||
}
|
||||
@Override
|
||||
public Long getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
}
|
||||
42
core/src/com/cloud/event/dao/UsageEventDao.java
Normal file
42
core/src/com/cloud/event/dao/UsageEventDao.java
Normal file
@ -0,0 +1,42 @@
|
||||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.cloud.event.dao;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.cloud.event.UsageEventVO;
|
||||
import com.cloud.exception.UsageServerException;
|
||||
import com.cloud.utils.db.Filter;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
|
||||
public interface UsageEventDao extends GenericDao<UsageEventVO, Long> {
|
||||
|
||||
public List<UsageEventVO> searchAllUsageEvents(SearchCriteria<UsageEventVO> sc, Filter filter);
|
||||
|
||||
public List<UsageEventVO> listLatestEvents(Date recentEventDate, Date endDate);
|
||||
|
||||
public List<UsageEventVO> listAllEvents(Date endDate);
|
||||
|
||||
public List<UsageEventVO> getLatestEventDate();
|
||||
|
||||
List<UsageEventVO> getRecentEvents(Date endDate) throws UsageServerException;
|
||||
|
||||
}
|
||||
163
core/src/com/cloud/event/dao/UsageEventDaoImpl.java
Normal file
163
core/src/com/cloud/event/dao/UsageEventDaoImpl.java
Normal file
@ -0,0 +1,163 @@
|
||||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.cloud.event.dao;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import javax.ejb.Local;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.event.UsageEventVO;
|
||||
import com.cloud.exception.UsageServerException;
|
||||
import com.cloud.utils.DateUtil;
|
||||
import com.cloud.utils.db.Filter;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
|
||||
@Local(value={UsageEventDao.class})
|
||||
public class UsageEventDaoImpl extends GenericDaoBase<UsageEventVO, Long> implements UsageEventDao {
|
||||
public static final Logger s_logger = Logger.getLogger(UsageEventDaoImpl.class.getName());
|
||||
|
||||
private final SearchBuilder<UsageEventVO> latestEventsSearch;
|
||||
private final SearchBuilder<UsageEventVO> allEventsSearch;
|
||||
private static final String GET_LATEST_EVENT_DATE = "SELECT created FROM usage_event ORDER BY created DESC LIMIT 1";
|
||||
private static final String COPY_EVENTS = "INSERT INTO cloud_usage.usage_event SELECT id, type, account_id, created, zone_id, resource_id, resource_name, offering_id, template_id, size FROM cloud.usage_event vmevt WHERE vmevt.created > ? and vmevt.created <= ? ";
|
||||
private static final String COPY_ALL_EVENTS = "INSERT INTO cloud_usage.usage_event SELECT id, type, account_id, created, zone_id, resource_id, resource_name, offering_id, template_id, size FROM cloud.usage_event where created <= ? ";
|
||||
|
||||
|
||||
public UsageEventDaoImpl () {
|
||||
latestEventsSearch = createSearchBuilder();
|
||||
latestEventsSearch.and("recentEventDate", latestEventsSearch.entity().getCreateDate(), SearchCriteria.Op.GT);
|
||||
latestEventsSearch.and("enddate", latestEventsSearch.entity().getCreateDate(), SearchCriteria.Op.LTEQ);
|
||||
latestEventsSearch.done();
|
||||
|
||||
allEventsSearch = createSearchBuilder();
|
||||
allEventsSearch.and("enddate", allEventsSearch.entity().getCreateDate(), SearchCriteria.Op.LTEQ);
|
||||
allEventsSearch.done();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UsageEventVO> listLatestEvents(Date recentEventDate, Date endDate) {
|
||||
Filter filter = new Filter(UsageEventVO.class, "createDate", Boolean.TRUE, null, null);
|
||||
SearchCriteria<UsageEventVO> sc = latestEventsSearch.create();
|
||||
sc.setParameters("recentEventDate", recentEventDate);
|
||||
sc.setParameters("enddate", endDate);
|
||||
return listBy(sc, filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UsageEventVO> listAllEvents(Date endDate) {
|
||||
Filter filter = new Filter(UsageEventVO.class, "createDate", Boolean.TRUE, null, null);
|
||||
SearchCriteria<UsageEventVO> sc = latestEventsSearch.create();
|
||||
sc.setParameters("enddate", endDate);
|
||||
return listBy(sc, filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UsageEventVO> getLatestEventDate() {
|
||||
Filter filter = new Filter(UsageEventVO.class, "createDate", Boolean.FALSE, null, 1L);
|
||||
return listAll(filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UsageEventVO> searchAllUsageEvents(SearchCriteria<UsageEventVO> sc, Filter filter) {
|
||||
return listIncludingRemovedBy(sc, filter);
|
||||
}
|
||||
|
||||
|
||||
public synchronized List<UsageEventVO> getRecentEvents(Date endDate) throws UsageServerException {
|
||||
Transaction txn = Transaction.open(Transaction.USAGE_DB);
|
||||
Date recentEventDate = getMostRecentEventDate();
|
||||
String sql = COPY_EVENTS;
|
||||
if (recentEventDate == null) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("no recent event date, copying all events");
|
||||
}
|
||||
sql = COPY_ALL_EVENTS;
|
||||
}
|
||||
|
||||
PreparedStatement pstmt = null;
|
||||
try {
|
||||
txn.start();
|
||||
pstmt = txn.prepareAutoCloseStatement(sql);
|
||||
int i = 1;
|
||||
if (recentEventDate != null) {
|
||||
pstmt.setString(i++, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), recentEventDate));
|
||||
}
|
||||
pstmt.setString(i, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), endDate));
|
||||
pstmt.executeUpdate();
|
||||
txn.commit();
|
||||
return findRecentEvents(recentEventDate, endDate);
|
||||
} catch (Exception ex) {
|
||||
txn.rollback();
|
||||
s_logger.error("error copying events from cloud db to usage db", ex);
|
||||
throw new UsageServerException(ex.getMessage());
|
||||
} finally {
|
||||
txn.close();
|
||||
}
|
||||
}
|
||||
|
||||
private Date getMostRecentEventDate() throws UsageServerException {
|
||||
Transaction txn = Transaction.open(Transaction.USAGE_DB);
|
||||
PreparedStatement pstmt = null;
|
||||
String sql = GET_LATEST_EVENT_DATE;
|
||||
try {
|
||||
pstmt = txn.prepareAutoCloseStatement(sql);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
if (rs.next()) {
|
||||
String mostRecentTimestampStr = rs.getString(1);
|
||||
if (mostRecentTimestampStr != null) {
|
||||
return DateUtil.parseDateString(s_gmtTimeZone, mostRecentTimestampStr);
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
s_logger.error("error getting most recent event date", ex);
|
||||
throw new UsageServerException(ex.getMessage());
|
||||
} finally {
|
||||
txn.close();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private List<UsageEventVO> findRecentEvents(Date recentEventDate, Date endDate) throws UsageServerException {
|
||||
Transaction txn = Transaction.open(Transaction.USAGE_DB);
|
||||
try {
|
||||
int i = 1;
|
||||
if (recentEventDate == null) {
|
||||
return listAllEvents(endDate);
|
||||
} else {
|
||||
return listLatestEvents(recentEventDate, endDate);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
s_logger.error("error getting most recent event date", ex);
|
||||
throw new UsageServerException(ex.getMessage());
|
||||
} finally {
|
||||
txn.close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -23,16 +23,16 @@ package com.cloud.host;
|
||||
*/
|
||||
public interface HostStats {
|
||||
|
||||
//host related stats
|
||||
public double getAverageLoad();
|
||||
// host related stats
|
||||
public double getCpuUtilization();
|
||||
public double getNetworkWriteKBs();
|
||||
public double getTotalMemoryKBs();
|
||||
public double getFreeMemoryKBs();
|
||||
public double getXapiMemoryUsageKBs();
|
||||
public double getNetworkReadKBs();
|
||||
public String getEntityType();
|
||||
public double getUsedMemory();
|
||||
public int getNumCpus();
|
||||
public HostStats getHostStats();
|
||||
|
||||
// public double getAverageLoad();
|
||||
// public double getXapiMemoryUsageKBs();
|
||||
}
|
||||
|
||||
@ -932,7 +932,7 @@ public abstract class CitrixResourceBase implements ServerResource {
|
||||
}
|
||||
|
||||
protected SetupAnswer execute(SetupCommand cmd) {
|
||||
return new SetupAnswer(cmd);
|
||||
return new SetupAnswer(cmd, false);
|
||||
}
|
||||
|
||||
protected SetPortForwardingRulesAnswer execute(SetPortForwardingRulesCommand cmd) {
|
||||
@ -1395,7 +1395,7 @@ public abstract class CitrixResourceBase implements ServerResource {
|
||||
|
||||
protected HostStatsEntry getHostStats(Connection conn, GetHostStatsCommand cmd, String hostGuid, long hostId) {
|
||||
|
||||
HostStatsEntry hostStats = new HostStatsEntry(hostId, 0, 0, 0, 0, "host", 0, 0, 0, 0);
|
||||
HostStatsEntry hostStats = new HostStatsEntry(hostId, 0, 0, 0, "host", 0, 0, 0, 0);
|
||||
Object[] rrdData = getRRDData(conn, 1); // call rrd method with 1 for host
|
||||
|
||||
if (rrdData == null) {
|
||||
@ -1448,21 +1448,25 @@ public abstract class CitrixResourceBase implements ServerResource {
|
||||
}
|
||||
|
||||
if (param.contains("cpu")) {
|
||||
hostStats.setNumCpus(hostStats.getNumCpus() + 1);
|
||||
// hostStats.setNumCpus(hostStats.getNumCpus() + 1);
|
||||
hostStats.setCpuUtilization(hostStats.getCpuUtilization() + getDataAverage(dataNode, col, numRows));
|
||||
}
|
||||
|
||||
/*
|
||||
if (param.contains("loadavg")) {
|
||||
hostStats.setAverageLoad((hostStats.getAverageLoad() + getDataAverage(dataNode, col, numRows)));
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
// add the host cpu utilization
|
||||
/*
|
||||
if (hostStats.getNumCpus() != 0) {
|
||||
hostStats.setCpuUtilization(hostStats.getCpuUtilization() / hostStats.getNumCpus());
|
||||
s_logger.debug("Host cpu utilization " + hostStats.getCpuUtilization());
|
||||
}
|
||||
*/
|
||||
|
||||
return hostStats;
|
||||
}
|
||||
|
||||
BIN
patches/systemvm/debian/config/bin/vhd-util
Executable file
BIN
patches/systemvm/debian/config/bin/vhd-util
Executable file
Binary file not shown.
@ -2,6 +2,7 @@ package com.cloud.api;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.cloud.agent.AgentManager;
|
||||
import com.cloud.async.AsyncJobManager;
|
||||
@ -32,6 +33,8 @@ import com.cloud.network.Network;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkRuleConfigVO;
|
||||
import com.cloud.network.NetworkVO;
|
||||
import com.cloud.network.Network.Capability;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.dao.IPAddressDao;
|
||||
import com.cloud.network.dao.LoadBalancerDao;
|
||||
import com.cloud.network.dao.NetworkDao;
|
||||
@ -508,4 +511,8 @@ public class ApiDBUtils {
|
||||
return _networkDao.findById(id);
|
||||
}
|
||||
|
||||
public static Map<Service, Map<Capability, String>> getZoneCapabilities(long zoneId) {
|
||||
return _networkMgr.getZoneCapabilities(zoneId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -34,6 +34,7 @@ import com.cloud.api.commands.QueryAsyncJobResultCmd;
|
||||
import com.cloud.api.response.AccountResponse;
|
||||
import com.cloud.api.response.ApiResponseSerializer;
|
||||
import com.cloud.api.response.AsyncJobResponse;
|
||||
import com.cloud.api.response.CapabilityResponse;
|
||||
import com.cloud.api.response.CapacityResponse;
|
||||
import com.cloud.api.response.ClusterResponse;
|
||||
import com.cloud.api.response.ConfigurationResponse;
|
||||
@ -60,6 +61,7 @@ import com.cloud.api.response.RemoteAccessVpnResponse;
|
||||
import com.cloud.api.response.ResourceLimitResponse;
|
||||
import com.cloud.api.response.SecurityGroupResponse;
|
||||
import com.cloud.api.response.ServiceOfferingResponse;
|
||||
import com.cloud.api.response.ServiceResponse;
|
||||
import com.cloud.api.response.SnapshotPolicyResponse;
|
||||
import com.cloud.api.response.SnapshotResponse;
|
||||
import com.cloud.api.response.StoragePoolResponse;
|
||||
@ -97,6 +99,8 @@ import com.cloud.host.HostStats;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.network.IpAddress;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.Network.Capability;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.RemoteAccessVpn;
|
||||
import com.cloud.network.VpnUser;
|
||||
@ -498,7 +502,7 @@ public class ApiResponseHelper implements ResponseGenerator {
|
||||
float cpuUtil = (float) hostStats.getCpuUtilization();
|
||||
cpuUsed = decimalFormat.format(cpuUtil) + "%";
|
||||
hostResponse.setCpuUsed(cpuUsed);
|
||||
hostResponse.setAverageLoad(Double.doubleToLongBits(hostStats.getAverageLoad()));
|
||||
// hostResponse.setAverageLoad(Double.doubleToLongBits(hostStats.getAverageLoad()));
|
||||
hostResponse.setNetworkKbsRead(Double.doubleToLongBits(hostStats.getNetworkReadKBs()));
|
||||
hostResponse.setNetworkKbsWrite(Double.doubleToLongBits(hostStats.getNetworkWriteKBs()));
|
||||
}
|
||||
@ -2209,7 +2213,36 @@ public class ApiResponseHelper implements ResponseGenerator {
|
||||
response.setRelated(network.getRelated());
|
||||
response.setDns1(network.getDns1());
|
||||
response.setDns2(network.getDns2());
|
||||
|
||||
|
||||
//populate capability
|
||||
Map<Service, Map<Capability, String>> serviceCapabilitiesMap = ApiDBUtils.getZoneCapabilities(network.getDataCenterId());
|
||||
List<ServiceResponse> serviceResponses = new ArrayList<ServiceResponse>();
|
||||
if (serviceCapabilitiesMap != null) {
|
||||
for (Service service : serviceCapabilitiesMap.keySet()) {
|
||||
ServiceResponse serviceResponse = new ServiceResponse();
|
||||
serviceResponse.setName(service.getName());
|
||||
|
||||
//set list of capabilities for the service
|
||||
List<CapabilityResponse> capabilityResponses = new ArrayList<CapabilityResponse>();
|
||||
Map<Capability, String> serviceCapabilities = serviceCapabilitiesMap.get(service);
|
||||
if (serviceCapabilities != null) {
|
||||
for (Capability capability : serviceCapabilities.keySet()) {
|
||||
CapabilityResponse capabilityResponse = new CapabilityResponse();
|
||||
String capabilityValue = serviceCapabilities.get(capability);
|
||||
capabilityResponse.setName(capability.getName());
|
||||
capabilityResponse.setValue(capabilityValue);
|
||||
capabilityResponse.setObjectName("capability");
|
||||
capabilityResponses.add(capabilityResponse);
|
||||
}
|
||||
serviceResponse.setCapabilities(capabilityResponses);
|
||||
}
|
||||
|
||||
serviceResponse.setObjectName("service");
|
||||
serviceResponses.add(serviceResponse);
|
||||
}
|
||||
}
|
||||
response.setServices(serviceResponses);
|
||||
|
||||
Account account = ApiDBUtils.findAccountById(network.getAccountId());
|
||||
if (account != null) {
|
||||
response.setAccountName(account.getAccountName());
|
||||
|
||||
@ -52,6 +52,7 @@ import com.cloud.dc.dao.PodVlanMapDaoImpl;
|
||||
import com.cloud.dc.dao.VlanDaoImpl;
|
||||
import com.cloud.domain.dao.DomainDaoImpl;
|
||||
import com.cloud.event.dao.EventDaoImpl;
|
||||
import com.cloud.event.dao.UsageEventDaoImpl;
|
||||
import com.cloud.ha.HighAvailabilityManagerImpl;
|
||||
import com.cloud.ha.dao.HighAvailabilityDaoImpl;
|
||||
import com.cloud.host.dao.DetailsDaoImpl;
|
||||
@ -113,12 +114,12 @@ import com.cloud.user.dao.UserStatisticsDaoImpl;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.component.Adapter;
|
||||
import com.cloud.utils.component.ComponentLibrary;
|
||||
import com.cloud.utils.component.ComponentLocator.ComponentInfo;
|
||||
import com.cloud.utils.component.Manager;
|
||||
import com.cloud.utils.component.ComponentLocator.ComponentInfo;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
import com.cloud.vm.ItWorkDaoImpl;
|
||||
import com.cloud.vm.VirtualMachineManagerImpl;
|
||||
import com.cloud.vm.UserVmManagerImpl;
|
||||
import com.cloud.vm.VirtualMachineManagerImpl;
|
||||
import com.cloud.vm.dao.ConsoleProxyDaoImpl;
|
||||
import com.cloud.vm.dao.DomainRouterDaoImpl;
|
||||
import com.cloud.vm.dao.InstanceGroupDaoImpl;
|
||||
@ -231,6 +232,7 @@ public class DefaultComponentLibrary implements ComponentLibrary {
|
||||
addDao("ItWorkDao", ItWorkDaoImpl.class);
|
||||
addDao("FirewallRulesDao", FirewallRulesDaoImpl.class);
|
||||
addDao("PortForwardingRulesDao", PortForwardingRulesDaoImpl.class);
|
||||
addDao("UsageEventDao", UsageEventDaoImpl.class);
|
||||
}
|
||||
|
||||
Map<String, ComponentInfo<Manager>> _managers = new HashMap<String, ComponentInfo<Manager>>();
|
||||
|
||||
@ -28,7 +28,7 @@ import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.TableGenerator;
|
||||
|
||||
import com.cloud.network.service.Providers;
|
||||
import com.cloud.network.Network.Provider;
|
||||
|
||||
@Entity
|
||||
@Table(name="data_center")
|
||||
@ -77,13 +77,13 @@ public class DataCenterVO implements DataCenter {
|
||||
NetworkType networkType;
|
||||
|
||||
@Column(name="dns_provider")
|
||||
private String dnsProvider = "VirtualRouter";
|
||||
private String dnsProvider = Provider.VirtualRouter.getName();
|
||||
|
||||
@Column(name="dhcp_provider")
|
||||
private String dhcpProvider = "VirtualRouter";
|
||||
private String dhcpProvider = Provider.VirtualRouter.getName();
|
||||
|
||||
@Column(name="gateway_provider")
|
||||
private String gatewayProvider = "VirtualRouter";
|
||||
private String gatewayProvider = Provider.VirtualRouter.getName();
|
||||
|
||||
@Column(name="vpn_provider")
|
||||
private String vpnProvider;
|
||||
@ -163,13 +163,13 @@ public class DataCenterVO implements DataCenter {
|
||||
this.domain = domain;
|
||||
this.domainId = domainId;
|
||||
this.networkType = zoneType;
|
||||
loadBalancerProvider = Providers.VirtualRouter;
|
||||
firewallProvider = Providers.VirtualRouter;
|
||||
dhcpProvider = Providers.VirtualRouter;
|
||||
dnsProvider = Providers.VirtualRouter;
|
||||
gatewayProvider = Providers.VirtualRouter;
|
||||
vpnProvider = Providers.VirtualRouter;
|
||||
userDataProvider = Providers.VirtualRouter;
|
||||
loadBalancerProvider = Provider.VirtualRouter.getName();
|
||||
firewallProvider = Provider.VirtualRouter.getName();
|
||||
dhcpProvider = Provider.VirtualRouter.getName();
|
||||
dnsProvider = Provider.VirtualRouter.getName();
|
||||
gatewayProvider = Provider.VirtualRouter.getName();
|
||||
vpnProvider = Provider.VirtualRouter.getName();
|
||||
userDataProvider = Provider.VirtualRouter.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
package com.cloud.network;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.cloud.dc.Vlan.VlanType;
|
||||
import com.cloud.deploy.DeployDestination;
|
||||
@ -26,6 +27,8 @@ import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientAddressCapacityException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.Network.Capability;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.addr.PublicIp;
|
||||
import com.cloud.network.rules.FirewallRule;
|
||||
import com.cloud.offerings.NetworkOfferingVO;
|
||||
@ -123,4 +126,6 @@ public interface NetworkManager extends NetworkService {
|
||||
String getNextAvailableMacAddressInNetwork(long networkConfigurationId) throws InsufficientAddressCapacityException;
|
||||
|
||||
boolean applyRules(List<? extends FirewallRule> rules, boolean continueOnError) throws ResourceUnavailableException;
|
||||
|
||||
Map<Service, Map<Capability, String>> getZoneCapabilities(long zoneId);
|
||||
}
|
||||
|
||||
@ -24,6 +24,7 @@ import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Executors;
|
||||
@ -74,7 +75,9 @@ import com.cloud.domain.dao.DomainDao;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.event.EventUtils;
|
||||
import com.cloud.event.EventVO;
|
||||
import com.cloud.event.UsageEventVO;
|
||||
import com.cloud.event.dao.EventDao;
|
||||
import com.cloud.event.dao.UsageEventDao;
|
||||
import com.cloud.exception.AccountLimitException;
|
||||
import com.cloud.exception.AgentUnavailableException;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
@ -85,6 +88,8 @@ import com.cloud.exception.OperationTimedoutException;
|
||||
import com.cloud.exception.PermissionDeniedException;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.Network.Capability;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.Networks.AddressFormat;
|
||||
import com.cloud.network.Networks.Availability;
|
||||
import com.cloud.network.Networks.BroadcastDomainType;
|
||||
@ -188,6 +193,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
@Inject FirewallRulesDao _firewallRulesDao;
|
||||
@Inject LoadBalancerDao _lbDao;
|
||||
@Inject PortForwardingRulesDao _pfRulesDao;
|
||||
@Inject UsageEventDao _usageEventDao;
|
||||
|
||||
@Inject(adapter=NetworkGuru.class)
|
||||
Adapters<NetworkGuru> _networkGurus;
|
||||
@ -251,6 +257,10 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
if (!_ipAddressDao.update(addr.getAddress(), addr)) {
|
||||
throw new CloudRuntimeException("Found address to allocate but unable to update: " + addr);
|
||||
}
|
||||
if(!sourceNat){
|
||||
UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_NET_IP_ASSIGN, owner.getAccountId(), dcId, 0, addr.getAddress());
|
||||
_usageEventDao.persist(usageEvent);
|
||||
}
|
||||
|
||||
txn.commit();
|
||||
long macAddress = NetUtils.createSequenceBasedMacAddress(addr.getMacAddress());
|
||||
@ -664,7 +674,11 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
|
||||
if (success) {
|
||||
_ipAddressDao.unassignIpAddress(ipAddress);
|
||||
s_logger.debug("released a public ip: " + ipAddress);
|
||||
s_logger.debug("released a public ip: " + ipAddress);
|
||||
if(!ip.isSourceNat()){
|
||||
UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_NET_IP_RELEASE, ownerId, ip.getDataCenterId(), 0, ipAddress);
|
||||
_usageEventDao.persist(usageEvent);
|
||||
}
|
||||
}
|
||||
|
||||
final EventVO event = new EventVO();
|
||||
@ -1770,7 +1784,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
throw new CloudRuntimeException("Failed to create a vlan");
|
||||
}
|
||||
}
|
||||
txn.commit();
|
||||
txn.commit();
|
||||
|
||||
return networks.get(0);
|
||||
} catch (Exception ex) {
|
||||
s_logger.warn("Unexpected exception while creating network ", ex);
|
||||
@ -1867,7 +1882,9 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
}
|
||||
sc.addAnd("accountId", SearchCriteria.Op.SC, ssc);
|
||||
|
||||
return _networksDao.search(sc, searchFilter);
|
||||
List<NetworkVO> networks = _networksDao.search(sc, searchFilter);
|
||||
|
||||
return networks;
|
||||
}
|
||||
|
||||
@Override @DB
|
||||
@ -2120,4 +2137,43 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
public int getActiveNicsInNetwork(long networkId) {
|
||||
return _networksDao.getActiveNicsIn(networkId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Service, Map<Capability, String>> getZoneCapabilities(long zoneId) {
|
||||
DataCenterVO dc = _dcDao.findById(zoneId);
|
||||
if (dc == null) {
|
||||
throw new InvalidParameterValueException("Zone id=" + dc.getId() + " doesn't exist in the system.");
|
||||
}
|
||||
|
||||
//Get all service providers from the datacenter
|
||||
Map<Service,String> providers = new HashMap<Service,String>();
|
||||
providers.put(Service.Firewall, dc.getFirewallProvider());
|
||||
providers.put(Service.Lb, dc.getLoadBalancerProvider());
|
||||
providers.put(Service.Vpn, dc.getVpnProvider());
|
||||
providers.put(Service.Dns, dc.getDnsProvider());
|
||||
providers.put(Service.Gateway, dc.getGatewayProvider());
|
||||
providers.put(Service.UserData, dc.getUserDataProvider());
|
||||
providers.put(Service.Dhcp, dc.getDhcpProvider());
|
||||
|
||||
Map<Service, Map<Capability, String>> networkCapabilities = new HashMap<Service, Map<Capability, String>>();
|
||||
|
||||
for (NetworkElement element : _networkElements) {
|
||||
if (providers.isEmpty()) {
|
||||
break;
|
||||
}
|
||||
Map<Service, Map<Capability, String>> elementCapabilities = element.getCapabilities();
|
||||
if (elementCapabilities != null) {
|
||||
Iterator<Service> it = providers.keySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
Service service = it.next();
|
||||
if (providers.get(service).equals(element.getProvider().getName())) {
|
||||
networkCapabilities.put(service, elementCapabilities.get(service));
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return networkCapabilities;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -130,7 +130,7 @@ public class NetworkVO implements Network {
|
||||
Date created;
|
||||
|
||||
@Column(name="reservation_id")
|
||||
String reservationId;
|
||||
String reservationId;
|
||||
|
||||
public NetworkVO() {
|
||||
}
|
||||
|
||||
@ -17,7 +17,9 @@
|
||||
*/
|
||||
package com.cloud.network.element;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.ejb.Local;
|
||||
|
||||
@ -29,12 +31,14 @@ import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.Network.Capability;
|
||||
import com.cloud.network.Network.Provider;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.PublicIpAddress;
|
||||
import com.cloud.network.dao.NetworkDao;
|
||||
import com.cloud.network.router.VirtualNetworkApplianceManager;
|
||||
import com.cloud.network.rules.FirewallRule;
|
||||
import com.cloud.network.service.Providers;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offering.NetworkOffering.GuestIpType;
|
||||
import com.cloud.uservm.UserVm;
|
||||
@ -51,9 +55,11 @@ import com.cloud.vm.dao.UserVmDao;
|
||||
|
||||
|
||||
@Local(value=NetworkElement.class)
|
||||
public class DhcpElement extends AdapterBase implements NetworkElement {
|
||||
public class DhcpElement extends AdapterBase implements NetworkElement{
|
||||
private static final Logger s_logger = Logger.getLogger(DhcpElement.class);
|
||||
|
||||
private static final Map<Service, Map<Capability, String>> capabilities = setCapabilities();
|
||||
|
||||
@Inject NetworkDao _networkConfigDao;
|
||||
@Inject NetworkManager _networkMgr;
|
||||
@Inject VirtualNetworkApplianceManager _routerMgr;
|
||||
@ -64,10 +70,10 @@ public class DhcpElement extends AdapterBase implements NetworkElement {
|
||||
private boolean canHandle(GuestIpType ipType, DeployDestination dest) {
|
||||
DataCenter dc = dest.getDataCenter();
|
||||
String provider = dc.getGatewayProvider();
|
||||
if (!dc.getDhcpProvider().equals(Providers.VirtualRouter)) {
|
||||
if (!dc.getDhcpProvider().equals(Provider.VirtualRouter.getName())) {
|
||||
return false;
|
||||
}
|
||||
return ((ipType == GuestIpType.Virtual && !provider.equals(Providers.VirtualRouter)) || (ipType == GuestIpType.Direct || ipType == GuestIpType.DirectPodBased));
|
||||
return ((ipType == GuestIpType.Virtual && !provider.equals(Provider.VirtualRouter.getName())) || (ipType == GuestIpType.Direct || ipType == GuestIpType.DirectPodBased));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -100,7 +106,7 @@ public class DhcpElement extends AdapterBase implements NetworkElement {
|
||||
public boolean release(Network config, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm, ReservationContext context) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean shutdown(Network config, ReservationContext context) throws ConcurrentOperationException {
|
||||
DomainRouterVO router = _routerDao.findByNetworkConfiguration(config.getId());
|
||||
@ -112,11 +118,33 @@ public class DhcpElement extends AdapterBase implements NetworkElement {
|
||||
|
||||
@Override
|
||||
public boolean applyRules(Network config, List<? extends FirewallRule> rules) throws ResourceUnavailableException {
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applyIps(Network network, List<? extends PublicIpAddress> ipAddress) throws ResourceUnavailableException {
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Provider getProvider() {
|
||||
return Provider.DhcpServer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Service, Map<Capability, String>> getCapabilities() {
|
||||
return capabilities;
|
||||
}
|
||||
|
||||
private static Map<Service, Map<Capability, String>> setCapabilities() {
|
||||
Map<Service, Map<Capability, String>> capabilities = new HashMap<Service, Map<Capability, String>>();
|
||||
|
||||
capabilities.put(Service.Dns, null);
|
||||
capabilities.put(Service.UserData, null);
|
||||
capabilities.put(Service.Dhcp, null);
|
||||
capabilities.put(Service.Gateway, null);
|
||||
|
||||
return capabilities;
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,7 +18,9 @@
|
||||
package com.cloud.network.element;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.ejb.Local;
|
||||
|
||||
@ -32,6 +34,9 @@ import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.LoadBalancerVO;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.Network.Capability;
|
||||
import com.cloud.network.Network.Provider;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.PublicIpAddress;
|
||||
import com.cloud.network.dao.LoadBalancerDao;
|
||||
@ -42,7 +47,6 @@ import com.cloud.network.lb.LoadBalancingRulesManager;
|
||||
import com.cloud.network.router.VirtualNetworkApplianceManager;
|
||||
import com.cloud.network.rules.FirewallRule;
|
||||
import com.cloud.network.rules.FirewallRule.Purpose;
|
||||
import com.cloud.network.service.Providers;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offering.NetworkOffering.GuestIpType;
|
||||
import com.cloud.offerings.dao.NetworkOfferingDao;
|
||||
@ -65,6 +69,8 @@ import com.cloud.vm.dao.UserVmDao;
|
||||
public class VirtualRouterElement extends AdapterBase implements NetworkElement {
|
||||
private static final Logger s_logger = Logger.getLogger(VirtualRouterElement.class);
|
||||
|
||||
private static final Map<Service, Map<Capability, String>> capabilities = setCapabilities();
|
||||
|
||||
@Inject NetworkDao _networkConfigDao;
|
||||
@Inject NetworkManager _networkMgr;
|
||||
@Inject LoadBalancingRulesManager _lbMgr;
|
||||
@ -76,10 +82,9 @@ public class VirtualRouterElement extends AdapterBase implements NetworkElement
|
||||
@Inject DataCenterDao _dataCenterDao;
|
||||
@Inject LoadBalancerDao _lbDao;
|
||||
|
||||
|
||||
private boolean canHandle(GuestIpType ipType, DataCenter dc) {
|
||||
String provider = dc.getGatewayProvider();
|
||||
return (ipType == GuestIpType.Virtual && provider.equals(Providers.VirtualRouter));
|
||||
return (ipType == GuestIpType.Virtual && provider.equals(Provider.VirtualRouter.getName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -174,5 +179,49 @@ public class VirtualRouterElement extends AdapterBase implements NetworkElement
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Provider getProvider() {
|
||||
return Provider.VirtualRouter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Service, Map<Capability, String>> getCapabilities() {
|
||||
return capabilities;
|
||||
}
|
||||
|
||||
private static Map<Service, Map<Capability, String>> setCapabilities() {
|
||||
Map<Service, Map<Capability, String>> capabilities = new HashMap<Service, Map<Capability, String>>();
|
||||
|
||||
//Set capabilities for LB service
|
||||
Map<Capability, String> lbCapabilities = new HashMap<Capability, String>();
|
||||
lbCapabilities.put(Capability.SupportedLBAlgorithms, "roundrobin,leastconn,sourceip");
|
||||
lbCapabilities.put(Capability.SupportedProtocols, "tcp, udp");
|
||||
|
||||
capabilities.put(Service.Lb, lbCapabilities);
|
||||
|
||||
//Set capabilities for Firewall service
|
||||
Map<Capability, String> firewallCapabilities = new HashMap<Capability, String>();
|
||||
firewallCapabilities.put(Capability.PortForwarding, "true");
|
||||
firewallCapabilities.put(Capability.StaticNat, "true");
|
||||
firewallCapabilities.put(Capability.SupportedProtocols, "tcp,udp");
|
||||
firewallCapabilities.put(Capability.MultipleIps, "true");
|
||||
firewallCapabilities.put(Capability.SupportedSourceNatTypes, "per account");
|
||||
|
||||
capabilities.put(Service.Firewall, firewallCapabilities);
|
||||
|
||||
//Set capabilities for vpn
|
||||
Map<Capability, String> vpnCapabilities = new HashMap<Capability, String>();
|
||||
vpnCapabilities.put(Capability.SupportedVpnTypes, "pptp,l2tp,ipsec");
|
||||
|
||||
capabilities.put(Service.Vpn, vpnCapabilities);
|
||||
capabilities.put(Service.Dns, null);
|
||||
capabilities.put(Service.UserData, null);
|
||||
capabilities.put(Service.Dhcp, null);
|
||||
capabilities.put(Service.Gateway, null);
|
||||
|
||||
return capabilities;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -99,7 +99,7 @@ public class ControlNetworkGuru extends PodBasedNetworkGuru implements NetworkGu
|
||||
return;
|
||||
}
|
||||
|
||||
String ip = _dcDao.allocateLinkLocalIpAddress(dest.getDataCenter().getId(), dest.getPod().getId(), vm.getId(), context.getReservationId());
|
||||
String ip = _dcDao.allocateLinkLocalIpAddress(dest.getDataCenter().getId(), dest.getPod().getId(), nic.getId(), context.getReservationId());
|
||||
nic.setIp4Address(ip);
|
||||
nic.setMacAddress(NetUtils.long2Mac(NetUtils.ip2Long(ip) | (14l << 40)));
|
||||
nic.setNetmask("255.255.0.0");
|
||||
|
||||
@ -36,7 +36,9 @@ import com.cloud.dc.dao.VlanDao;
|
||||
import com.cloud.domain.dao.DomainDao;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.event.EventVO;
|
||||
import com.cloud.event.UsageEventVO;
|
||||
import com.cloud.event.dao.EventDao;
|
||||
import com.cloud.event.dao.UsageEventDao;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.NetworkRuleConflictException;
|
||||
import com.cloud.exception.PermissionDeniedException;
|
||||
@ -105,6 +107,7 @@ public class LoadBalancingRulesManagerImpl implements LoadBalancingRulesManager,
|
||||
@Inject AccountDao _accountDao;
|
||||
@Inject DomainDao _domainDao;
|
||||
@Inject NicDao _nicDao;
|
||||
@Inject UsageEventDao _usageEventDao;
|
||||
|
||||
@Override @DB
|
||||
public boolean assignToLoadBalancer(long loadBalancerId, List<Long> instanceIds) {
|
||||
@ -241,6 +244,8 @@ public class LoadBalancingRulesManagerImpl implements LoadBalancingRulesManager,
|
||||
}
|
||||
|
||||
_rulesDao.remove(lb.getId());
|
||||
UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_LOAD_BALANCER_DELETE, lb.getAccountId(), 0 , lb.getId(), null);
|
||||
_usageEventDao.persist(usageEvent);
|
||||
s_logger.debug("Load balancer with id " + lb.getId() + " is removed successfully");
|
||||
return true;
|
||||
}
|
||||
@ -327,6 +332,8 @@ public class LoadBalancingRulesManagerImpl implements LoadBalancingRulesManager,
|
||||
String params = "id=" + newRule.getId() + "\ndcId=" + ipAddr.getDataCenterId();
|
||||
event.setParameters(params);
|
||||
event.setLevel(EventVO.LEVEL_INFO);
|
||||
UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_LOAD_BALANCER_CREATE, ipAddr.getAllocatedToAccountId(), ipAddr.getDataCenterId(), newRule.getId(), null);
|
||||
_usageEventDao.persist(usageEvent);
|
||||
}
|
||||
_eventDao.persist(event);
|
||||
}
|
||||
|
||||
@ -92,7 +92,9 @@ import com.cloud.domain.dao.DomainDao;
|
||||
import com.cloud.event.Event;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.event.EventVO;
|
||||
import com.cloud.event.UsageEventVO;
|
||||
import com.cloud.event.dao.EventDao;
|
||||
import com.cloud.event.dao.UsageEventDao;
|
||||
import com.cloud.exception.AgentUnavailableException;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.DiscoveryException;
|
||||
@ -211,6 +213,8 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
||||
@Inject protected UserDao _userDao;
|
||||
@Inject protected ClusterDao _clusterDao;
|
||||
@Inject protected VirtualNetworkApplianceManager _routerMgr;
|
||||
@Inject protected UsageEventDao _usageEventDao;
|
||||
|
||||
|
||||
@Inject(adapter=StoragePoolAllocator.class)
|
||||
protected Adapters<StoragePoolAllocator> _storagePoolAllocators;
|
||||
@ -696,6 +700,8 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
||||
if (createdVolume.getPath() != null) {
|
||||
event.setDescription("Created volume: "+ createdVolume.getName() + " with size: " + sizeMB + " MB in pool: " + poolName + " from snapshot id: " + snapshotId);
|
||||
event.setLevel(EventVO.LEVEL_INFO);
|
||||
UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_VOLUME_CREATE, volume.getAccountId(), volume.getDataCenterId(), volume.getId(), volume.getName(), diskOfferingId, templateId , sizeMB);
|
||||
_usageEventDao.persist(usageEvent);
|
||||
}
|
||||
else {
|
||||
details = "CreateVolume From Snapshot for snapshotId: " + snapshotId + " failed at the backend, reason " + details;
|
||||
@ -830,6 +836,9 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
||||
volume.setPodId(pod.getId());
|
||||
volume.setState(Volume.State.Ready);
|
||||
_volsDao.persist(volume);
|
||||
UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_VOLUME_CREATE, volume.getAccountId(), volume.getDataCenterId(), volume.getId(), volume.getName(), diskOffering.getId(), null , dskCh.getSize());
|
||||
_usageEventDao.persist(usageEvent);
|
||||
|
||||
}
|
||||
txn.commit();
|
||||
return volume;
|
||||
@ -1906,6 +1915,8 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
||||
event.setParameters(eventParams);
|
||||
event.setState(Event.State.Completed);
|
||||
_eventDao.persist(event);
|
||||
UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_VOLUME_CREATE, volume.getAccountId(), volume.getDataCenterId(), volume.getId(), volume.getName(), diskOffering.getId(), null , sizeMB);
|
||||
_usageEventDao.persist(usageEvent);
|
||||
/*
|
||||
} else {
|
||||
event.setDescription("Unable to create a volume for " + volume);
|
||||
@ -1943,6 +1954,9 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
||||
event.setDescription("Volume " +volume.getName()+ " deleted");
|
||||
event.setLevel(EventVO.LEVEL_INFO);
|
||||
_eventDao.persist(event);
|
||||
|
||||
UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_VOLUME_DELETE, volume.getAccountId(), volume.getDataCenterId(), volume.getId(), volume.getName(), null, null , null);
|
||||
_usageEventDao.persist(usageEvent);
|
||||
|
||||
// Delete the recurring snapshot policies for this volume.
|
||||
_snapshotMgr.deletePoliciesForVolume(volumeId);
|
||||
@ -2672,6 +2686,11 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
||||
|
||||
vol = _volsDao.persist(vol);
|
||||
|
||||
if(vm instanceof UserVm){
|
||||
long sizeMB = size / (1024 * 1024);
|
||||
UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_VOLUME_CREATE, vol.getAccountId(), vol.getDataCenterId(), vol.getId(), vol.getName(), offering.getId(), null , sizeMB);
|
||||
_usageEventDao.persist(usageEvent);
|
||||
}
|
||||
return toDiskProfile(vol, offering);
|
||||
}
|
||||
|
||||
@ -2704,6 +2723,11 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
||||
|
||||
vol = _volsDao.persist(vol);
|
||||
|
||||
if(vm instanceof UserVm){
|
||||
long sizeMB = vol.getSize() / (1024 * 1024);
|
||||
UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_VOLUME_CREATE, vol.getAccountId(), vol.getDataCenterId(), vol.getId(), vol.getName(), offering.getId(), template.getId() , sizeMB);
|
||||
_usageEventDao.persist(usageEvent);
|
||||
}
|
||||
return toDiskProfile(vol, offering);
|
||||
}
|
||||
|
||||
|
||||
@ -43,7 +43,9 @@ import com.cloud.dc.DataCenterVO;
|
||||
import com.cloud.dc.dao.DataCenterDao;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.event.EventVO;
|
||||
import com.cloud.event.UsageEventVO;
|
||||
import com.cloud.event.dao.EventDao;
|
||||
import com.cloud.event.dao.UsageEventDao;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.StorageUnavailableException;
|
||||
import com.cloud.host.Host;
|
||||
@ -103,6 +105,9 @@ public class DownloadMonitorImpl implements DownloadMonitor {
|
||||
private AgentManager _agentMgr;
|
||||
@Inject
|
||||
ConfigurationDao _configDao;
|
||||
|
||||
@Inject
|
||||
private UsageEventDao _usageEventDao;
|
||||
|
||||
private String _name;
|
||||
private Boolean _sslCopy = new Boolean(false);
|
||||
@ -374,6 +379,8 @@ public class DownloadMonitorImpl implements DownloadMonitor {
|
||||
event.setParameters(eventParams);
|
||||
event.setLevel(EventVO.LEVEL_INFO);
|
||||
_eventDao.persist(event);
|
||||
UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_TEMPLATE_CREATE, template.getAccountId(), host.getDataCenterId(), template.getId(), template.getName(), null, null , size);
|
||||
_usageEventDao.persist(usageEvent);
|
||||
}
|
||||
|
||||
if (vmTemplateHost != null) {
|
||||
|
||||
@ -59,7 +59,9 @@ import com.cloud.domain.dao.DomainDao;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.event.EventUtils;
|
||||
import com.cloud.event.EventVO;
|
||||
import com.cloud.event.UsageEventVO;
|
||||
import com.cloud.event.dao.EventDao;
|
||||
import com.cloud.event.dao.UsageEventDao;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.PermissionDeniedException;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
@ -138,6 +140,7 @@ public class SnapshotManagerImpl implements SnapshotManager, SnapshotService, Ma
|
||||
@Inject protected AsyncJobManager _asyncMgr;
|
||||
@Inject protected AccountManager _accountMgr;
|
||||
@Inject protected ClusterDao _clusterDao;
|
||||
@Inject private UsageEventDao _usageEventDao;
|
||||
String _name;
|
||||
private int _totalRetries;
|
||||
private int _pauseInterval;
|
||||
@ -524,6 +527,8 @@ public class SnapshotManagerImpl implements SnapshotManager, SnapshotService, Ma
|
||||
event.setDescription("Backed up snapshot id: " + snapshotId + " to secondary for volume:" + volumeId);
|
||||
event.setLevel(EventVO.LEVEL_INFO);
|
||||
event.setParameters(eventParams);
|
||||
UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_SNAPSHOT_CREATE, snapshot.getAccountId(), volume.getDataCenterId(), snapshotId, snapshotName, null, null, volume.getSize());
|
||||
_usageEventDao.persist(usageEvent);
|
||||
|
||||
}
|
||||
else {
|
||||
@ -769,6 +774,12 @@ public class SnapshotManagerImpl implements SnapshotManager, SnapshotService, Ma
|
||||
event.setLevel(success ? EventVO.LEVEL_INFO : EventVO.LEVEL_ERROR);
|
||||
_eventDao.persist(event);
|
||||
|
||||
if(success){
|
||||
UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_SNAPSHOT_DELETE, snapshot.getAccountId(), volume.getDataCenterId(), snapshotId, snapshot.getName(), null, null, volume.getSize());
|
||||
_usageEventDao.persist(usageEvent);
|
||||
}
|
||||
|
||||
|
||||
return success;
|
||||
|
||||
}
|
||||
@ -955,6 +966,8 @@ public class SnapshotManagerImpl implements SnapshotManager, SnapshotService, Ma
|
||||
event.setParameters(eventParams);
|
||||
event.setLevel(EventVO.LEVEL_INFO);
|
||||
_eventDao.persist(event);
|
||||
UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_SNAPSHOT_DELETE, snapshot.getAccountId(), volume.getDataCenterId(), snapshot.getId(), snapshot.getName(), null, null, volume.getSize());
|
||||
_usageEventDao.persist(usageEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -61,7 +61,9 @@ import com.cloud.event.Event;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.event.EventUtils;
|
||||
import com.cloud.event.EventVO;
|
||||
import com.cloud.event.UsageEventVO;
|
||||
import com.cloud.event.dao.EventDao;
|
||||
import com.cloud.event.dao.UsageEventDao;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.PermissionDeniedException;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
@ -127,6 +129,7 @@ import com.cloud.vm.VMInstanceVO;
|
||||
import com.cloud.vm.dao.UserVmDao;
|
||||
import com.cloud.vm.dao.VMInstanceDao;
|
||||
|
||||
|
||||
@Local(value={TemplateManager.class, TemplateService.class})
|
||||
public class TemplateManagerImpl implements TemplateManager, Manager, TemplateService {
|
||||
private final static Logger s_logger = Logger.getLogger(TemplateManagerImpl.class);
|
||||
@ -158,6 +161,7 @@ public class TemplateManagerImpl implements TemplateManager, Manager, TemplateSe
|
||||
@Inject AsyncJobManager _asyncMgr;
|
||||
@Inject UserVmManager _vmMgr;
|
||||
@Inject ConfigurationDao _configDao;
|
||||
@Inject UsageEventDao _usageEventDao;
|
||||
protected SearchBuilder<VMTemplateHostVO> HostTemplateStatesSearch;
|
||||
|
||||
@Override
|
||||
@ -338,9 +342,11 @@ public class TemplateManagerImpl implements TemplateManager, Manager, TemplateSe
|
||||
}
|
||||
|
||||
if((!url.toLowerCase().endsWith("vhd"))&&(!url.toLowerCase().endsWith("vhd.zip"))
|
||||
&&(!url.toLowerCase().endsWith("vhd.bz2"))&&(!url.toLowerCase().endsWith("vhd.gz")
|
||||
&&(!url.toLowerCase().endsWith("vhd.bz2"))&&(!url.toLowerCase().endsWith("vhd.gz"))
|
||||
&&(!url.toLowerCase().endsWith("qcow2"))&&(!url.toLowerCase().endsWith("qcow2.zip"))
|
||||
&&(!url.toLowerCase().endsWith("qcow2.bz2"))&&(!url.toLowerCase().endsWith("qcow2.gz")))){
|
||||
&&(!url.toLowerCase().endsWith("qcow2.bz2"))&&(!url.toLowerCase().endsWith("qcow2.gz"))
|
||||
&&(!url.toLowerCase().endsWith("ova"))&&(!url.toLowerCase().endsWith("ova.zip"))
|
||||
&&(!url.toLowerCase().endsWith("ova.bz2"))&&(!url.toLowerCase().endsWith("ova.gz"))){
|
||||
throw new ServerApiException(BaseCmd.PARAM_ERROR, "Please specify a valid "+format.toLowerCase());
|
||||
}
|
||||
|
||||
@ -814,6 +820,8 @@ public class TemplateManagerImpl implements TemplateManager, Manager, TemplateSe
|
||||
|
||||
_downloadMonitor.copyTemplate(vmTemplate, srcSecHost, dstSecHost);
|
||||
|
||||
UsageEventVO usageEvent = new UsageEventVO(copyEventType, account.getId(), destZoneId, templateId, null, null, null, srcTmpltHost.getSize());
|
||||
_usageEventDao.persist(usageEvent);
|
||||
saveEvent(userId, account.getId(), account.getDomainId(), copyEventType, copyEventDescription, EventVO.LEVEL_INFO, params, startEventId);
|
||||
return true;
|
||||
}
|
||||
@ -960,6 +968,8 @@ public class TemplateManagerImpl implements TemplateManager, Manager, TemplateSe
|
||||
|
||||
String zoneParams = params + "\ndcId=" + sZoneId;
|
||||
saveEvent(userId, account.getId(), account.getDomainId(), eventType, description + template.getName() + " succesfully deleted.", EventVO.LEVEL_INFO, zoneParams, 0);
|
||||
UsageEventVO usageEvent = new UsageEventVO(eventType, account.getId(), sZoneId, templateId, null, null, null, null);
|
||||
_usageEventDao.persist(usageEvent);
|
||||
} finally {
|
||||
if (lock != null) {
|
||||
_tmpltHostDao.releaseFromLockTable(lock.getId());
|
||||
|
||||
@ -103,7 +103,9 @@ import com.cloud.event.Event;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.event.EventUtils;
|
||||
import com.cloud.event.EventVO;
|
||||
import com.cloud.event.UsageEventVO;
|
||||
import com.cloud.event.dao.EventDao;
|
||||
import com.cloud.event.dao.UsageEventDao;
|
||||
import com.cloud.exception.AgentUnavailableException;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
@ -252,6 +254,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
||||
@Inject VirtualNetworkApplianceManager _routerMgr;
|
||||
@Inject NicDao _nicDao;
|
||||
@Inject RulesManager _rulesMgr;
|
||||
@Inject UsageEventDao _usageEventDao;
|
||||
|
||||
private IpAddrAllocator _IpAllocator;
|
||||
ScheduledExecutorService _executor = null;
|
||||
@ -1106,7 +1109,8 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
||||
if (!destroy(vm)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_VM_DESTROY, vm.getAccountId(), vm.getDataCenterId(), vm.getId(), vm.getName(), vm.getServiceOfferingId(), vm.getTemplateId(), null);
|
||||
_usageEventDao.persist(usageEvent);
|
||||
cleanNetworkRules(userId, vmId);
|
||||
|
||||
// Mark the VM's disks as destroyed
|
||||
@ -1234,6 +1238,8 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
||||
}
|
||||
_eventDao.persist(event);
|
||||
|
||||
UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_VM_CREATE, vm.getAccountId(), vm.getDataCenterId(), vm.getId(), vm.getName(), vm.getServiceOfferingId(), vm.getTemplateId(), null);
|
||||
_usageEventDao.persist(usageEvent);
|
||||
txn.commit();
|
||||
|
||||
return _vmDao.findById(vmId);
|
||||
@ -1384,6 +1390,9 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
||||
}
|
||||
_eventDao.persist(event);
|
||||
|
||||
UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_VM_STOP, vm.getAccountId(), vm.getDataCenterId(), vm.getId(), vm.getName(), vm.getServiceOfferingId(), vm.getTemplateId(), null);
|
||||
_usageEventDao.persist(usageEvent);
|
||||
|
||||
if (_storageMgr.unshare(vm, null) == null) {
|
||||
s_logger.warn("Unable to set share to false for " + vm.toString());
|
||||
}
|
||||
@ -2527,6 +2536,8 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Successfully allocated DB entry for " + vm);
|
||||
}
|
||||
UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_VM_CREATE, accountId, dc.getId(), vm.getId(), vm.getName(), offering.getId(), template.getId(), null);
|
||||
_usageEventDao.persist(usageEvent);
|
||||
return vm;
|
||||
}
|
||||
|
||||
@ -2718,6 +2729,8 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
||||
|
||||
if (status) {
|
||||
EventUtils.saveEvent(userId, vm.getAccountId(), EventTypes.EVENT_VM_DESTROY, "Successfully destroyed vm with id:"+vmId);
|
||||
UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_VM_DESTROY, vm.getAccountId(), vm.getDataCenterId(), vm.getId(), vm.getName(), vm.getServiceOfferingId(), vm.getTemplateId(), null);
|
||||
_usageEventDao.persist(usageEvent);
|
||||
return _vmDao.findById(vmId);
|
||||
} else {
|
||||
EventUtils.saveEvent(userId, vm.getAccountId(), EventTypes.EVENT_VM_DESTROY, "Failed to destroy vm with id:"+vmId);
|
||||
|
||||
@ -51,6 +51,8 @@ import com.cloud.deploy.DeploymentPlanner.ExcludeList;
|
||||
import com.cloud.domain.dao.DomainDao;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.event.EventVO;
|
||||
import com.cloud.event.UsageEventVO;
|
||||
import com.cloud.event.dao.UsageEventDao;
|
||||
import com.cloud.exception.AgentUnavailableException;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
@ -74,6 +76,7 @@ import com.cloud.user.Account;
|
||||
import com.cloud.user.User;
|
||||
import com.cloud.user.dao.AccountDao;
|
||||
import com.cloud.user.dao.UserDao;
|
||||
import com.cloud.uservm.UserVm;
|
||||
import com.cloud.utils.Journal;
|
||||
import com.cloud.utils.NumbersUtil;
|
||||
import com.cloud.utils.Pair;
|
||||
@ -113,6 +116,7 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Cluster
|
||||
@Inject private DomainRouterDao _routerDao;
|
||||
@Inject private ConsoleProxyDao _consoleDao;
|
||||
@Inject private SecondaryStorageVmDao _secondaryDao;
|
||||
@Inject private UsageEventDao _usageEventDao;
|
||||
|
||||
@Inject(adapter=DeploymentPlanner.class)
|
||||
private Adapters<DeploymentPlanner> _planners;
|
||||
@ -431,6 +435,10 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Cluster
|
||||
if (!stateTransitTo(vm, Event.OperationSucceeded, dest.getHost().getId())) {
|
||||
throw new CloudRuntimeException("Unable to transition to a new state.");
|
||||
}
|
||||
if(vm instanceof UserVm){
|
||||
UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_VM_START, vm.getAccountId(), vm.getDataCenterId(), vm.getId(), vm.getName(), vm.getServiceOfferingId(), vm.getTemplateId(), null);
|
||||
_usageEventDao.persist(usageEvent);
|
||||
}
|
||||
return vm;
|
||||
}
|
||||
s_logger.info("Unable to start VM on " + dest.getHost() + " due to " + answers[0].getDetails());
|
||||
@ -504,6 +512,9 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Cluster
|
||||
stopped = answer.getResult();
|
||||
if (!stopped) {
|
||||
throw new CloudRuntimeException("Unable to stop the virtual machine due to " + answer.getDetails());
|
||||
} else {
|
||||
UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_VM_STOP, vm.getAccountId(), vm.getDataCenterId(), vm.getId(), vm.getName(), vm.getServiceOfferingId(), vm.getTemplateId(), null);
|
||||
_usageEventDao.persist(usageEvent);
|
||||
}
|
||||
} finally {
|
||||
if (!stopped) {
|
||||
|
||||
@ -91,6 +91,7 @@ DROP TABLE IF EXISTS `cloud`.`load_balancing_ip_map`;
|
||||
DROP TABLE IF EXISTS `cloud`.`load_balancing_rules`;
|
||||
DROP TABLE IF EXISTS `cloud`.`port_forwarding_rules`;
|
||||
DROP TABLE IF EXISTS `cloud`.`firewall_rules`;
|
||||
DROP TABLE IF EXISTS `cloud`.`usage_event`;
|
||||
|
||||
CREATE TABLE `cloud`.`op_it_work` (
|
||||
`id` char(40) COMMENT 'id',
|
||||
@ -1252,4 +1253,18 @@ CREATE TABLE `cloud`.`instance_group_vm_map` (
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `cloud`.`usage_event` (
|
||||
`id` bigint unsigned NOT NULL auto_increment,
|
||||
`type` varchar(32) NOT NULL,
|
||||
`account_id` bigint unsigned NOT NULL,
|
||||
`created` datetime NOT NULL,
|
||||
`zone_id` bigint unsigned NOT NULL,
|
||||
`resource_id` bigint unsigned,
|
||||
`resource_name` varchar(255),
|
||||
`offering_id` bigint unsigned,
|
||||
`template_id` bigint unsigned,
|
||||
`size` bigint unsigned,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
SET foreign_key_checks = 1;
|
||||
|
||||
@ -13,7 +13,7 @@ INSERT INTO `cloud`.`vm_template` (id, unique_name, name, public, created, type,
|
||||
VALUES (7, 'centos53-x64', 'centos53-x64', 1, now(), 'builtin', 0, 64, 1, 'http://download.cloud.com/releases/2.2.0/CentOS5.3-x86_64.ova', 'f6f881b7f2292948d8494db837fe0f47', 0, 'centos53-x64', 'OVA', 12, 1, 1, 'VMware');
|
||||
|
||||
INSERT INTO `cloud`.`vm_template` (id, unique_name, name, public, created, type, hvm, bits, account_id, url, checksum, enable_password, display_text, format, guest_os_id, featured, cross_zones, hypervisor_type)
|
||||
VALUES (8, 'routing-8', 'SystemVM Template (VMWare)', 0, now(), 'system', 0, 32, 1, 'http://download.cloud.com/releases/2.2.0/systemvm.vmdk.bz2', '7ebe04f68583f30064d187069faf7b0f', 0, 'SystemVM Template VMWare', 'OVA', 15, 0, 1, 'VMware');
|
||||
VALUES (8, 'routing-8', 'SystemVM Template (VMWare)', 0, now(), 'system', 0, 32, 1, 'http://download.cloud.com/releases/2.2.0/systemvm.ova', 'ee3dc55e94e23a0490310bb78cf8cc76', 0, 'SystemVM Template VMWare', 'OVA', 15, 0, 1, 'VMware');
|
||||
|
||||
INSERT INTO `cloud`.`guest_os_category` (id, name) VALUES (1, 'CentOS');
|
||||
INSERT INTO `cloud`.`guest_os_category` (id, name) VALUES (2, 'Debian');
|
||||
|
||||
@ -3494,8 +3494,9 @@ a:hover.search_button {
|
||||
height:auto;
|
||||
float:left;
|
||||
position:absolute;
|
||||
background:#414141 repeat top left;
|
||||
border:1px solid #CCC;
|
||||
background:#444444 repeat top left;
|
||||
border-bottom:1px solid #666;
|
||||
border-left:1px solid #666;
|
||||
top:17px;
|
||||
right:0;
|
||||
margin:0;
|
||||
@ -3517,7 +3518,7 @@ a:hover.search_button {
|
||||
height:auto;
|
||||
float:left;
|
||||
text-align:left;
|
||||
background:#414141 repeat-x top left;
|
||||
background:#444444 repeat-x top left;
|
||||
color:#CCC;
|
||||
font-size:11px;
|
||||
font-weight:normal;
|
||||
|
||||
@ -374,7 +374,8 @@
|
||||
<fmt:message key="label.menu.ipaddresses"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!--
|
||||
<div class="leftmenu_expandedlist">
|
||||
<div class="leftmenu_content" id="leftmenu_security_group">
|
||||
<div class="leftmenu_secondindent">
|
||||
@ -383,7 +384,8 @@
|
||||
<fmt:message key="label.menu.security.groups"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
-->
|
||||
</div>
|
||||
</div>
|
||||
<div class="leftmenu_list">
|
||||
|
||||
@ -46,7 +46,7 @@
|
||||
<div class="grid_container">
|
||||
<div class="grid_header">
|
||||
<div id="grid_header_title" class="grid_header_title">Title</div>
|
||||
<div class="grid_actionbox" id="action_link">
|
||||
<div class="grid_actionbox" id="action_link"><p>Actions</p>
|
||||
<div class="grid_actionsdropdown_box" id="action_menu" style="display: none;">
|
||||
<ul class="actionsdropdown_boxlist" id="action_list">
|
||||
<li><%=t.t("no.available.actions")%></li>
|
||||
@ -281,7 +281,7 @@
|
||||
<div class="grid_container">
|
||||
<div class="grid_header">
|
||||
<div id="grid_header_title" class="grid_header_title">Title</div>
|
||||
<div class="grid_actionbox" id="action_link">
|
||||
<div class="grid_actionbox" id="action_link"><p>Actions</p>
|
||||
<div class="grid_actionsdropdown_box" id="action_menu" style="display: none;">
|
||||
<ul class="actionsdropdown_boxlist" id="action_list">
|
||||
<li><%=t.t("no.available.actions")%></li>
|
||||
@ -443,7 +443,7 @@
|
||||
<div class="grid_header">
|
||||
<div class="grid_header_title" id="grid_header_title">
|
||||
</div>
|
||||
<div class="grid_actionbox" id="firewall_action_link">
|
||||
<div class="grid_actionbox" id="firewall_action_link"><p>Actions</p>
|
||||
<div class="grid_actionsdropdown_box" id="firewall_action_menu" style="display: none;">
|
||||
<ul class="actionsdropdown_boxlist" id="action_list">
|
||||
</ul>
|
||||
@ -494,7 +494,7 @@
|
||||
<div class="grid_header">
|
||||
<div class="grid_header_title" id="grid_header_title">
|
||||
</div>
|
||||
<div class="grid_actionbox" id="loadbalancer_action_link">
|
||||
<div class="grid_actionbox" id="loadbalancer_action_link"><p>Actions</p>
|
||||
<div class="grid_actionsdropdown_box" id="loadbalancer_action_menu" style="display: none;">
|
||||
<ul class="actionsdropdown_boxlist" id="action_list">
|
||||
</ul>
|
||||
@ -544,7 +544,7 @@
|
||||
<div class="grid_header">
|
||||
<div class="grid_header_title" id="grid_header_title">
|
||||
</div>
|
||||
<div class="grid_actionbox" id="iprange_action_link">
|
||||
<div class="grid_actionbox" id="iprange_action_link"><p>Actions</p>
|
||||
<div class="grid_actionsdropdown_box" id="iprange_action_menu" style="display: none;">
|
||||
<ul class="actionsdropdown_boxlist" id="action_list">
|
||||
</ul>
|
||||
|
||||
@ -24,10 +24,10 @@ function alertGetSearchParams() {
|
||||
moreCriteria.push("&keyword="+todb(searchInput));
|
||||
}
|
||||
|
||||
var $advancedSearchPopup = $("#advanced_search_popup");
|
||||
if (lastSearchType == "advanced_search" && $advancedSearchPopup.length > 0) {
|
||||
var $advancedSearchPopup = $("#advanced_search_container").find("#advanced_search_popup");
|
||||
if ($advancedSearchPopup.length > 0 && $advancedSearchPopup.css("display") != "none" ) {
|
||||
var type = $advancedSearchPopup.find("#adv_search_type").val();
|
||||
if (type!=null && type.length > 0)
|
||||
if ($advancedSearchPopup.find("#adv_search_type").hasClass("textwatermark") == false && type!=null && type.length > 0)
|
||||
moreCriteria.push("&type="+todb(type));
|
||||
}
|
||||
|
||||
|
||||
@ -24,8 +24,8 @@ function eventGetSearchParams() {
|
||||
moreCriteria.push("&keyword="+todb(searchInput));
|
||||
}
|
||||
|
||||
var $advancedSearchPopup = $("#advanced_search_popup");
|
||||
if (lastSearchType == "advanced_search" && $advancedSearchPopup.length > 0) {
|
||||
var $advancedSearchPopup = $("#advanced_search_container").find("#advanced_search_popup");
|
||||
if ($advancedSearchPopup.length > 0 && $advancedSearchPopup.css("display") != "none" ) {
|
||||
var type = $advancedSearchPopup.find("#adv_search_type").val();
|
||||
if (type!=null && trim(type).length > 0)
|
||||
moreCriteria.push("&type="+todb(type));
|
||||
@ -40,18 +40,19 @@ function eventGetSearchParams() {
|
||||
moreCriteria.push("&domainid="+todb(domainId));
|
||||
}
|
||||
|
||||
if ($advancedSearchPopup.find("#adv_search_account_li").css("display") != "none") {
|
||||
if ($advancedSearchPopup.find("#adv_search_account_li").css("display") != "none"
|
||||
&& $advancedSearchPopup.find("#adv_search_account").hasClass("textwatermark") == false) {
|
||||
var account = $advancedSearchPopup.find("#adv_search_account").val();
|
||||
if (account!=null && account.length > 0)
|
||||
moreCriteria.push("&account="+todb(account));
|
||||
}
|
||||
|
||||
var startdate = $advancedSearchPopup.find("#adv_search_startdate").val();
|
||||
if (startdate!=null && startdate.length > 0)
|
||||
if ($advancedSearchPopup.find("#adv_search_startdate").hasClass("textwatermark") == false && startdate!=null && startdate.length > 0)
|
||||
moreCriteria.push("&startdate="+todb(startdate));
|
||||
|
||||
var enddate = $advancedSearchPopup.find("#adv_search_enddate").val();
|
||||
if (enddate!=null && enddate.length > 0)
|
||||
if ($advancedSearchPopup.find("#adv_search_enddate").hasClass("textwatermark") == false && enddate!=null && enddate.length > 0)
|
||||
moreCriteria.push("&enddate="+todb(enddate));
|
||||
}
|
||||
|
||||
|
||||
@ -263,39 +263,26 @@ $(document).ready(function() {
|
||||
|
||||
//advanced search
|
||||
$("#advanced_search_icon").unbind("click").bind("click", function(event) {
|
||||
if($(this).hasClass("up")) {
|
||||
$(this).removeClass("up");
|
||||
$("#advanced_search_container").find("#advanced_search_popup").hide();
|
||||
if($(this).hasClass("up")) { //clicking up-arrow
|
||||
$("#advanced_search_container").find("#advanced_search_popup").slideUp("500");
|
||||
$(this).removeClass("up"); //change arrow from up to down
|
||||
}
|
||||
else {
|
||||
$(this).addClass("up");
|
||||
else { //clicking down-arrow
|
||||
$(this).addClass("up"); //change arrow from down to up
|
||||
|
||||
if($("#advanced_search_container").find("#advanced_search_popup").length > 0) {
|
||||
$("#advanced_search_container").find("#advanced_search_popup").show();
|
||||
$("#advanced_search_container").find("#advanced_search_popup").slideDown("500");
|
||||
}
|
||||
else {
|
||||
var $advancedSearchPopup = $("#advanced_search_popup");
|
||||
|
||||
$advancedSearchPopup.unbind("click").bind("click", function(event) {
|
||||
var $target = $(event.target);
|
||||
var targetId = $target.attr("id");
|
||||
/*
|
||||
if(targetId == "advanced_search_close") {
|
||||
$(this).hide();
|
||||
return false;
|
||||
}
|
||||
else if(targetId == "adv_search_button") {
|
||||
var params = $("#middle_menu_pagination").data("params");
|
||||
if(params == null)
|
||||
return;
|
||||
lastSearchType = "advanced_search";
|
||||
//$("#basic_search").find("#search_input").val("");
|
||||
listMidMenuItems2(params.commandString, params.getSearchParamsFn, params.jsonResponse1, params.jsonResponse2, params.toMidmenuFn, params.toRightPanelFn, params.getMidmenuIdFn, params.isMultipleSelectionInMidMenu, 1);
|
||||
$("#advanced_search_icon").removeClass("up");
|
||||
$(this).hide();
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
var targetId = $target.attr("id");
|
||||
if($target.hasClass("textwatermark")) {
|
||||
$target.val("");
|
||||
$target.removeClass("textwatermark");
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
@ -404,7 +391,7 @@ $(document).ready(function() {
|
||||
|
||||
$advancedSearchPopup.find("#adv_search_startdate, #adv_search_enddate").datepicker({dateFormat: 'yy-mm-dd'});
|
||||
|
||||
$("#advanced_search_container").empty().append($advancedSearchPopup.show());
|
||||
$("#advanced_search_container").empty().append($advancedSearchPopup.slideDown("500"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -86,26 +86,25 @@ function networkPopulateMiddleMenu($leftmenuItem1) {
|
||||
//direct network
|
||||
listMidMenuItems2(("listNetworks&type=Direct&zoneId="+zoneObj.id), networkGetSearchParams, "listnetworksresponse", "network", directNetworkToMidmenu, directNetworkToRightPanel, directNetworkGetMidmenuId, false, 1);
|
||||
|
||||
//public network
|
||||
if(zoneObj.networktype == "Advanced") {
|
||||
$.ajax({
|
||||
data: createURL("command=listNetworks&isSystem=true&zoneId="+zoneObj.id),
|
||||
dataType: "json",
|
||||
async: false,
|
||||
success: function(json) {
|
||||
var items = json.listnetworksresponse.network;
|
||||
if(items != null && items.length > 0) {
|
||||
var item = items[0];
|
||||
var $midmenuItem1 = $("#midmenu_item").clone();
|
||||
$midmenuItem1.data("toRightPanelFn", publicNetworkToRightPanel);
|
||||
publicNetworkToMidmenu(item, $midmenuItem1);
|
||||
bindClickToMidMenu($midmenuItem1, publicNetworkToRightPanel, publicNetworkGetMidmenuId);
|
||||
$midmenuContainer.prepend($midmenuItem1.show()); //prepend public network on the top of middle menu
|
||||
$midmenuItem1.click();
|
||||
}
|
||||
//public network
|
||||
$midmenuContainer.find("#midmenu_container_no_items_available").remove(); //There is always at least one item (i.e. public network) in middle menu. So, "no items available" shouldn't be in middle menu even there is zero direct network item in middle menu.
|
||||
$.ajax({
|
||||
data: createURL("command=listNetworks&isSystem=true&zoneId="+zoneObj.id),
|
||||
dataType: "json",
|
||||
async: false,
|
||||
success: function(json) {
|
||||
var items = json.listnetworksresponse.network;
|
||||
if(items != null && items.length > 0) {
|
||||
var item = items[0];
|
||||
var $midmenuItem1 = $("#midmenu_item").clone();
|
||||
$midmenuItem1.data("toRightPanelFn", publicNetworkToRightPanel);
|
||||
publicNetworkToMidmenu(item, $midmenuItem1);
|
||||
bindClickToMidMenu($midmenuItem1, publicNetworkToRightPanel, publicNetworkGetMidmenuId);
|
||||
$midmenuContainer.prepend($midmenuItem1.show()); //prepend public network on the top of middle menu
|
||||
$midmenuItem1.click();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//***** Public Network (begin) ******************************************************************************************************
|
||||
|
||||
@ -324,6 +324,8 @@ function initAddPodShortcut() {
|
||||
|
||||
$zoneDropdown.bind("change", function(event) {
|
||||
var zoneId = $(this).val();
|
||||
if(zoneId == null)
|
||||
return;
|
||||
$.ajax({
|
||||
data: createURL("command=listZones&id="+zoneId),
|
||||
dataType: "json",
|
||||
@ -484,6 +486,8 @@ function initAddHostShortcut() {
|
||||
|
||||
$dialogAddHost.find("#zone_dropdown").bind("change", function(event) {
|
||||
var zoneId = $(this).val();
|
||||
if(zoneId == null)
|
||||
return;
|
||||
$.ajax({
|
||||
data: createURL("command=listPods&zoneId="+zoneId),
|
||||
dataType: "json",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user