mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 20:02:29 +01:00
Merge branch 'master' of ssh://git.cloud.com/var/lib/git/cloudstack-oss
This commit is contained in:
commit
58a80d57cc
@ -9,9 +9,6 @@ import java.lang.annotation.Target;
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({TYPE})
|
||||
public @interface Implementation {
|
||||
// String createMethod() default "";
|
||||
// String method() default "";
|
||||
// Class<?> manager() default ManagementServer.class;
|
||||
Class<?> responseObject();
|
||||
String description() default "";
|
||||
}
|
||||
|
||||
@ -73,6 +73,9 @@ public class CreateNetworkCmd extends BaseCmd {
|
||||
|
||||
@Parameter(name=ApiConstants.IS_SHARED, type=CommandType.BOOLEAN, description="true is network offering supports vlans")
|
||||
private Boolean isShared;
|
||||
|
||||
@Parameter(name=ApiConstants.IS_DEFAULT, type=CommandType.BOOLEAN, description="true if network is default, false otherwise")
|
||||
private Boolean isDefault;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
@ -124,6 +127,10 @@ public class CreateNetworkCmd extends BaseCmd {
|
||||
public boolean getIsShared() {
|
||||
return isShared == null ? false : isShared;
|
||||
}
|
||||
|
||||
public Boolean isDefault() {
|
||||
return isDefault;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
|
||||
@ -41,7 +41,7 @@ public class CreateUserCmd extends BaseCmd {
|
||||
@Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="Creates the user under the specified account. If no account is specified, the username will be used as the account name.")
|
||||
private String accountName;
|
||||
|
||||
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="Creates the user under the specified domain.")
|
||||
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="Creates the user under the specified domain. Has to be accompanied with the account parameter")
|
||||
private Long domainId;
|
||||
|
||||
@Parameter(name=ApiConstants.EMAIL, type=CommandType.STRING, required=true, description="email")
|
||||
|
||||
@ -26,6 +26,7 @@ import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.SuccessResponse;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
|
||||
@Implementation(description="Deletes a detached disk volume.", responseObject=SuccessResponse.class)
|
||||
public class DeleteVolumeCmd extends BaseCmd {
|
||||
@ -63,7 +64,7 @@ public class DeleteVolumeCmd extends BaseCmd {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
public void execute() throws ConcurrentOperationException {
|
||||
boolean result = _storageService.deleteVolume(this);
|
||||
if (result) {
|
||||
SuccessResponse response = new SuccessResponse(getCommandName());
|
||||
|
||||
@ -60,6 +60,12 @@ public class ListNetworksCmd extends BaseListCmd {
|
||||
|
||||
@Parameter(name=ApiConstants.IS_SHARED, type=CommandType.BOOLEAN, description="true if network is shared, false otherwise")
|
||||
private Boolean isShared;
|
||||
|
||||
@Parameter(name=ApiConstants.IS_DEFAULT, type=CommandType.BOOLEAN, description="true if network is default, false otherwise")
|
||||
private Boolean isDefault;
|
||||
|
||||
@Parameter(name=ApiConstants.TRAFFIC_TYPE, type=CommandType.STRING, description="type of the traffic")
|
||||
private String trafficType;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
@ -92,6 +98,14 @@ public class ListNetworksCmd extends BaseListCmd {
|
||||
public Boolean getIsShared() {
|
||||
return isShared;
|
||||
}
|
||||
|
||||
public Boolean isDefault() {
|
||||
return isDefault;
|
||||
}
|
||||
|
||||
public String getTrafficType() {
|
||||
return trafficType;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
|
||||
@ -30,7 +30,7 @@ import com.cloud.api.Parameter;
|
||||
import com.cloud.api.response.ListResponse;
|
||||
import com.cloud.api.response.PreallocatedLunResponse;
|
||||
|
||||
@Implementation(responseObject=PreallocatedLunResponse.class)
|
||||
@Implementation(description="List PreallocatedLuns",responseObject=PreallocatedLunResponse.class)
|
||||
public class ListPreallocatedLunsCmd extends BaseListCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(ListPreallocatedLunsCmd.class.getName());
|
||||
|
||||
|
||||
@ -24,8 +24,7 @@ import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.PreallocatedLunResponse;
|
||||
|
||||
//TODO - add description to @Implementation
|
||||
@Implementation(responseObject=PreallocatedLunResponse.class)
|
||||
@Implementation(description="Registers PreallocatedLun", responseObject=PreallocatedLunResponse.class)
|
||||
public class RegisterPreallocatedLunCmd extends BaseCmd {
|
||||
private static final String s_name = "registerPreallocatedLunsResponse";
|
||||
|
||||
|
||||
@ -29,44 +29,34 @@ public class RevokeSecurityGroupIngressCmd extends BaseAsyncCmd {
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
//FIXME - add description
|
||||
@Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING)
|
||||
@Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="an optional account for the security group. Must be used with domainId.")
|
||||
private String accountName;
|
||||
|
||||
//FIXME - add description
|
||||
@Parameter(name=ApiConstants.CIDR_LIST, type=CommandType.STRING)
|
||||
@Parameter(name=ApiConstants.CIDR_LIST, type=CommandType.STRING, description="the cidr list associated")
|
||||
private String cidrList;
|
||||
|
||||
//FIXME - add description
|
||||
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG)
|
||||
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="an optional domainId for the security group. If the account parameter is used, domainId must also be used.")
|
||||
private Long domainId;
|
||||
|
||||
//FIXME - add description
|
||||
@Parameter(name=ApiConstants.END_PORT, type=CommandType.INTEGER)
|
||||
@Parameter(name=ApiConstants.END_PORT, type=CommandType.INTEGER, description="end port for this ingress rule")
|
||||
private Integer endPort;
|
||||
|
||||
//FIXME - add description
|
||||
@Parameter(name=ApiConstants.ICMP_CODE, type=CommandType.INTEGER)
|
||||
@Parameter(name=ApiConstants.ICMP_CODE, type=CommandType.INTEGER, description="error code for this icmp message")
|
||||
private Integer icmpCode;
|
||||
|
||||
//FIXME - add description
|
||||
@Parameter(name=ApiConstants.ICMP_TYPE, type=CommandType.INTEGER)
|
||||
@Parameter(name=ApiConstants.ICMP_TYPE, type=CommandType.INTEGER, description="type for this icmp message")
|
||||
private Integer icmpType;
|
||||
|
||||
//FIXME - add description
|
||||
@Parameter(name=ApiConstants.SECURITY_GROUP_NAME, type=CommandType.STRING, required=true)
|
||||
@Parameter(name=ApiConstants.SECURITY_GROUP_NAME, type=CommandType.STRING, required=true, description="name of the security group")
|
||||
private String securityGroupName;
|
||||
|
||||
//FIXME - add description
|
||||
@Parameter(name=ApiConstants.PROTOCOL, type=CommandType.STRING)
|
||||
@Parameter(name=ApiConstants.PROTOCOL, type=CommandType.STRING, description="protocol used")
|
||||
private String protocol;
|
||||
|
||||
//FIXME - add description
|
||||
@Parameter(name=ApiConstants.START_PORT, type=CommandType.INTEGER)
|
||||
@Parameter(name=ApiConstants.START_PORT, type=CommandType.INTEGER,description="start port for this ingress rule")
|
||||
private Integer startPort;
|
||||
|
||||
//FIXME - add description
|
||||
@Parameter(name=ApiConstants.USER_SECURITY_GROUP_LIST, type=CommandType.MAP)
|
||||
@Parameter(name=ApiConstants.USER_SECURITY_GROUP_LIST, type=CommandType.MAP, description="user to security group mapping")
|
||||
private Map userSecurityGroupList;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@ -28,12 +28,10 @@ public class IngressRuleResponse extends BaseResponse {
|
||||
@SerializedName("protocol") @Param(description="the protocol of the ingress rule")
|
||||
private String protocol;
|
||||
|
||||
//FIXME - add description
|
||||
@SerializedName(ApiConstants.ICMP_TYPE)
|
||||
@SerializedName(ApiConstants.ICMP_TYPE) @Param(description="the type of the ICMP message response")
|
||||
private Integer icmpType;
|
||||
|
||||
//FIXME - add description
|
||||
@SerializedName(ApiConstants.ICMP_CODE)
|
||||
@SerializedName(ApiConstants.ICMP_CODE) @Param(description="the code for the ICMP message response")
|
||||
private Integer icmpCode;
|
||||
|
||||
@SerializedName(ApiConstants.START_PORT) @Param(description="the starting IP of the ingress rule")
|
||||
|
||||
@ -3,7 +3,6 @@ package com.cloud.api.response;
|
||||
import java.util.List;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.network.Networks;
|
||||
import com.cloud.serializer.Param;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
@ -54,14 +53,13 @@ public class NetworkResponse extends BaseResponse{
|
||||
@SerializedName("isshared") @Param(description="true if network is shared, false otherwise")
|
||||
private Boolean isShared;
|
||||
|
||||
@SerializedName("issystem") @Param(description="true if network is system, false otherwise")
|
||||
@SerializedName("issystem") @Param(description="true if network is system, false otherwise")
|
||||
private Boolean isSystem;
|
||||
|
||||
@SerializedName("state") @Param(description="state of the network")
|
||||
@SerializedName("state") @Param(description="state of the network")
|
||||
private String state;
|
||||
|
||||
//TODO - add description
|
||||
@SerializedName("related")
|
||||
|
||||
@SerializedName("related") @Param(description="related to what other network configuration")
|
||||
private Long related;
|
||||
|
||||
@SerializedName("broadcasturi") @Param(description="broadcast uri of the network")
|
||||
@ -88,7 +86,10 @@ 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")
|
||||
@SerializedName("isdefault") @Param(description="true if network is default, false otherwise")
|
||||
private Boolean isDefault;
|
||||
|
||||
@SerializedName("service") @Param(description="the list of services", responseObject = ServiceResponse.class)
|
||||
private List<ServiceResponse> services;
|
||||
|
||||
public Long getId() {
|
||||
@ -306,4 +307,12 @@ public class NetworkResponse extends BaseResponse{
|
||||
public void setServices(List<ServiceResponse> services) {
|
||||
this.services = services;
|
||||
}
|
||||
|
||||
public Boolean getIsDefault() {
|
||||
return isDefault;
|
||||
}
|
||||
|
||||
public void setIsDefault(Boolean isDefault) {
|
||||
this.isDefault = isDefault;
|
||||
}
|
||||
}
|
||||
|
||||
@ -43,13 +43,14 @@ public class NicResponse extends BaseResponse {
|
||||
@SerializedName("broadcasturi") @Param(description="the broadcast uri of the nic")
|
||||
private String broadcastUri;
|
||||
|
||||
//TODO - add description
|
||||
@SerializedName("traffictype")
|
||||
@SerializedName("traffictype") @Param(description="the traffic type of the nic")
|
||||
private String trafficType;
|
||||
|
||||
//TODO - add description
|
||||
@SerializedName("type")
|
||||
@SerializedName("type") @Param(description="the type of the nic")
|
||||
private String type;
|
||||
|
||||
@SerializedName("isdefault") @Param(description="true if nic is default, false otherwise")
|
||||
private Boolean isDefault;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
@ -122,4 +123,12 @@ public class NicResponse extends BaseResponse {
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public Boolean getIsDefault() {
|
||||
return isDefault;
|
||||
}
|
||||
|
||||
public void setIsDefault(Boolean isDefault) {
|
||||
this.isDefault = isDefault;
|
||||
}
|
||||
}
|
||||
|
||||
@ -41,7 +41,7 @@ public class SecurityGroupResponse extends BaseResponse {
|
||||
@SerializedName("domain") @Param(description="the domain name of the security group")
|
||||
private String domainName;
|
||||
|
||||
@SerializedName("ingressrule") @Param(description="the list of ingress rules associated with the security group")
|
||||
@SerializedName("ingressrule") @Param(description="the list of ingress rules associated with the security group", responseObject = IngressRuleResponse.class)
|
||||
private List<IngressRuleResponse> ingressRules;
|
||||
|
||||
public Long getId() {
|
||||
|
||||
@ -28,7 +28,7 @@ public class ServiceResponse extends BaseResponse {
|
||||
@SerializedName(ApiConstants.NAME) @Param(description="the service name")
|
||||
private String name;
|
||||
|
||||
@SerializedName("capability") @Param(description="the list of capabilities")
|
||||
@SerializedName("capability") @Param(description="the list of capabilities", responseObject = CapabilityResponse.class)
|
||||
private List<CapabilityResponse> capabilities;
|
||||
|
||||
public String getName() {
|
||||
|
||||
@ -142,7 +142,7 @@ 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")
|
||||
@SerializedName("nic") @Param(description="the list of nics associated with vm", responseObject = NicResponse.class)
|
||||
private List<NicResponse> nics;
|
||||
|
||||
public Long getObjectId() {
|
||||
|
||||
@ -10,6 +10,7 @@ import com.cloud.dc.DataCenter;
|
||||
import com.cloud.dc.Pod;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.InsufficientServerCapacityException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.org.Cluster;
|
||||
import com.cloud.storage.StoragePool;
|
||||
@ -50,11 +51,11 @@ public interface DeploymentPlanner extends Adapter {
|
||||
Set<Long> _hostIds;
|
||||
Set<Long> _poolIds;
|
||||
|
||||
public void add(InsufficientCapacityException e) {
|
||||
public boolean add(InsufficientCapacityException e) {
|
||||
Class<?> scope = e.getScope();
|
||||
|
||||
if (scope == null) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Host.class.isAssignableFrom(scope)) {
|
||||
@ -67,7 +68,35 @@ public interface DeploymentPlanner extends Adapter {
|
||||
addCluster(e.getId());
|
||||
} else if (StoragePool.class.isAssignableFrom(scope)) {
|
||||
addPool(e.getId());
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean add(ResourceUnavailableException e) {
|
||||
Class<?> scope = e.getScope();
|
||||
|
||||
if (scope == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Host.class.isAssignableFrom(scope)) {
|
||||
addHost(e.getResourceId());
|
||||
} else if (Pod.class.isAssignableFrom(scope)) {
|
||||
addPod(e.getResourceId());
|
||||
} else if (DataCenter.class.isAssignableFrom(scope)) {
|
||||
addDataCenter(e.getResourceId());
|
||||
} else if (Cluster.class.isAssignableFrom(scope)) {
|
||||
addCluster(e.getResourceId());
|
||||
} else if (StoragePool.class.isAssignableFrom(scope)) {
|
||||
addPool(e.getResourceId());
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void addPool(long poolId) {
|
||||
|
||||
@ -201,5 +201,7 @@ public interface Network extends ControlledEntity {
|
||||
boolean isShared();
|
||||
|
||||
String getReservationId();
|
||||
|
||||
boolean isDefault();
|
||||
|
||||
}
|
||||
|
||||
@ -18,13 +18,16 @@
|
||||
|
||||
package com.cloud.serializer;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Param {
|
||||
String name() default "";
|
||||
String propName() default "";
|
||||
String description() default "";
|
||||
boolean expose() default true;
|
||||
|
||||
// 2 parameters below are used by cloudstack api
|
||||
boolean expose() default true;
|
||||
Class<?> responseObject() default Object.class;
|
||||
}
|
||||
|
||||
@ -27,6 +27,7 @@ import com.cloud.api.commands.DeletePoolCmd;
|
||||
import com.cloud.api.commands.DeleteVolumeCmd;
|
||||
import com.cloud.api.commands.PreparePrimaryStorageForMaintenanceCmd;
|
||||
import com.cloud.api.commands.UpdateStoragePoolCmd;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.PermissionDeniedException;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
@ -60,7 +61,7 @@ public interface StorageService {
|
||||
*/
|
||||
Volume createVolume(CreateVolumeCmd cmd);
|
||||
|
||||
boolean deleteVolume(DeleteVolumeCmd cmd) throws InvalidParameterValueException;
|
||||
boolean deleteVolume(DeleteVolumeCmd cmd) throws ConcurrentOperationException;
|
||||
/**
|
||||
* Delete the storage pool
|
||||
* @param cmd - the command specifying poolId
|
||||
|
||||
@ -38,8 +38,7 @@ public interface Volume extends ControlledEntity, BasedOn {
|
||||
Creating("The volume is being created. getPoolId() should reflect the pool where it is being created."),
|
||||
Ready("The volume is ready to be used."),
|
||||
Used("The volume is used"),
|
||||
Destroy("The volume is set to be desctroyed but can be recovered."),
|
||||
Destroyed("The volume is destroyed. Should be removed.");
|
||||
Destroy("The volume is set to be destroyed but can be recovered.");
|
||||
|
||||
String _description;
|
||||
|
||||
@ -75,17 +74,13 @@ public interface Volume extends ControlledEntity, BasedOn {
|
||||
private final static StateMachine<State, Event> s_fsm = new StateMachine<State, Event>();
|
||||
static {
|
||||
s_fsm.addTransition(Allocated, Event.Create, Creating);
|
||||
s_fsm.addTransition(Allocated, Event.Destroy, Destroyed);
|
||||
s_fsm.addTransition(Allocated, Event.Destroy, Destroy);
|
||||
s_fsm.addTransition(Creating, Event.OperationRetry, Creating);
|
||||
s_fsm.addTransition(Creating, Event.OperationFailed, Allocated);
|
||||
s_fsm.addTransition(Creating, Event.OperationSucceeded, Ready);
|
||||
s_fsm.addTransition(Creating, Event.Destroy, Destroy);
|
||||
s_fsm.addTransition(Ready, Event.Destroy, Destroy);
|
||||
s_fsm.addTransition(Ready, Event.Start, Used);
|
||||
s_fsm.addTransition(Destroy, Event.OperationSucceeded, Destroyed);
|
||||
s_fsm.addTransition(Destroy, Event.OperationFailed, Destroy);
|
||||
s_fsm.addTransition(Destroy, Event.OperationRetry, Destroy);
|
||||
s_fsm.addTransition(Destroy, Event.Recover, Ready);
|
||||
}
|
||||
}
|
||||
|
||||
@ -95,8 +90,7 @@ public interface Volume extends ControlledEntity, BasedOn {
|
||||
OperationFailed,
|
||||
OperationSucceeded,
|
||||
OperationRetry,
|
||||
Destroy,
|
||||
Recover;
|
||||
Destroy;
|
||||
}
|
||||
|
||||
enum SourceType {
|
||||
|
||||
@ -22,6 +22,7 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.cloud.acl.ControlledEntity;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.utils.fsm.FiniteState;
|
||||
import com.cloud.utils.fsm.StateMachine;
|
||||
|
||||
@ -223,4 +224,6 @@ public interface VirtualMachine extends RunningOn, ControlledEntity {
|
||||
public long getServiceOfferingId();
|
||||
|
||||
Type getType();
|
||||
|
||||
HypervisorType getHypervisorType();
|
||||
}
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
#Titles
|
||||
label.cloud.console=Cloud Management Console[zh]
|
||||
|
||||
label.menu.dashboard=儀器板
|
||||
|
||||
#Labels
|
||||
|
||||
#Messages
|
||||
@ -63,6 +63,9 @@ public class UsageEventVO implements UsageEvent {
|
||||
|
||||
@Column(name="size")
|
||||
private Long size;
|
||||
|
||||
@Column(name="processed")
|
||||
boolean processed;
|
||||
|
||||
|
||||
public UsageEventVO() {
|
||||
@ -163,4 +166,12 @@ public class UsageEventVO implements UsageEvent {
|
||||
return size;
|
||||
}
|
||||
|
||||
public boolean isProcessed() {
|
||||
return processed;
|
||||
}
|
||||
|
||||
public void setProcessed(boolean processed) {
|
||||
this.processed = processed;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -29,13 +29,9 @@ 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 endDate);
|
||||
|
||||
public List<UsageEventVO> listLatestEvents(Date recentEventDate, Date endDate);
|
||||
|
||||
public List<UsageEventVO> listAllEvents(Date endDate);
|
||||
|
||||
public List<UsageEventVO> getLatestEventDate();
|
||||
public List<UsageEventVO> getLatestEvent();
|
||||
|
||||
List<UsageEventVO> getRecentEvents(Date endDate) throws UsageServerException;
|
||||
|
||||
|
||||
@ -19,7 +19,6 @@
|
||||
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;
|
||||
@ -31,6 +30,7 @@ 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.DB;
|
||||
import com.cloud.utils.db.Filter;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
@ -42,58 +42,40 @@ public class UsageEventDaoImpl extends GenericDaoBase<UsageEventVO, Long> implem
|
||||
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 <= ? ";
|
||||
private static final String COPY_EVENTS = "INSERT INTO cloud_usage.usage_event (id, type, account_id, created, zone_id, resource_id, resource_name, offering_id, template_id, size) " +
|
||||
"SELECT id, type, account_id, created, zone_id, resource_id, resource_name, offering_id, template_id, size FROM cloud.usage_event vmevt WHERE vmevt.id > ? and vmevt.created <= ? ";
|
||||
private static final String COPY_ALL_EVENTS = "INSERT INTO cloud_usage.usage_event (id, type, account_id, created, zone_id, resource_id, resource_name, offering_id, template_id, size) " +
|
||||
"SELECT id, type, account_id, created, zone_id, resource_id, resource_name, offering_id, template_id, size FROM cloud.usage_event where id <= ? ";
|
||||
|
||||
|
||||
public UsageEventDaoImpl () {
|
||||
latestEventsSearch = createSearchBuilder();
|
||||
latestEventsSearch.and("recentEventDate", latestEventsSearch.entity().getCreateDate(), SearchCriteria.Op.GT);
|
||||
latestEventsSearch.and("processed", latestEventsSearch.entity().isProcessed(), SearchCriteria.Op.EQ);
|
||||
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) {
|
||||
public List<UsageEventVO> listLatestEvents(Date endDate) {
|
||||
Filter filter = new Filter(UsageEventVO.class, "createDate", Boolean.TRUE, null, null);
|
||||
SearchCriteria<UsageEventVO> sc = latestEventsSearch.create();
|
||||
sc.setParameters("recentEventDate", recentEventDate);
|
||||
sc.setParameters("processed", false);
|
||||
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);
|
||||
public List<UsageEventVO> getLatestEvent() {
|
||||
Filter filter = new Filter(UsageEventVO.class, "id", Boolean.FALSE, Long.valueOf(0), Long.valueOf(1));
|
||||
return listAll(filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UsageEventVO> searchAllUsageEvents(SearchCriteria<UsageEventVO> sc, Filter filter) {
|
||||
return listIncludingRemovedBy(sc, filter);
|
||||
}
|
||||
|
||||
|
||||
@DB
|
||||
public synchronized List<UsageEventVO> getRecentEvents(Date endDate) throws UsageServerException {
|
||||
Transaction txn = Transaction.open(Transaction.USAGE_DB);
|
||||
Date recentEventDate = getMostRecentEventDate();
|
||||
long recentEventId = getMostRecentEventId();
|
||||
String sql = COPY_EVENTS;
|
||||
if (recentEventDate == null) {
|
||||
if (recentEventId == 0) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("no recent event date, copying all events");
|
||||
}
|
||||
@ -105,13 +87,13 @@ public class UsageEventDaoImpl extends GenericDaoBase<UsageEventVO, Long> implem
|
||||
txn.start();
|
||||
pstmt = txn.prepareAutoCloseStatement(sql);
|
||||
int i = 1;
|
||||
if (recentEventDate != null) {
|
||||
pstmt.setString(i++, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), recentEventDate));
|
||||
if (recentEventId != 0) {
|
||||
pstmt.setLong(i++, recentEventId);
|
||||
}
|
||||
pstmt.setString(i, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), endDate));
|
||||
pstmt.executeUpdate();
|
||||
txn.commit();
|
||||
return findRecentEvents(recentEventDate, endDate);
|
||||
return findRecentEvents(endDate);
|
||||
} catch (Exception ex) {
|
||||
txn.rollback();
|
||||
s_logger.error("error copying events from cloud db to usage db", ex);
|
||||
@ -121,37 +103,31 @@ public class UsageEventDaoImpl extends GenericDaoBase<UsageEventVO, Long> implem
|
||||
}
|
||||
}
|
||||
|
||||
private Date getMostRecentEventDate() throws UsageServerException {
|
||||
@DB
|
||||
private long getMostRecentEventId() 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);
|
||||
List<UsageEventVO> latestEvents = getLatestEvent();
|
||||
|
||||
if(latestEvents !=null && latestEvents.size() == 1){
|
||||
UsageEventVO latestEvent = latestEvents.get(0);
|
||||
if(latestEvent != null){
|
||||
return latestEvent.getId();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
} catch (Exception ex) {
|
||||
s_logger.error("error getting most recent event date", ex);
|
||||
s_logger.error("error getting most recent event id", ex);
|
||||
throw new UsageServerException(ex.getMessage());
|
||||
} finally {
|
||||
txn.close();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private List<UsageEventVO> findRecentEvents(Date recentEventDate, Date endDate) throws UsageServerException {
|
||||
private List<UsageEventVO> findRecentEvents(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);
|
||||
}
|
||||
return listLatestEvents(endDate);
|
||||
} catch (Exception ex) {
|
||||
s_logger.error("error getting most recent event date", ex);
|
||||
throw new UsageServerException(ex.getMessage());
|
||||
|
||||
@ -532,7 +532,7 @@ public abstract class CitrixResourceBase implements ServerResource {
|
||||
}
|
||||
}
|
||||
|
||||
private Network setupvSwitchNetwork(Connection conn) {
|
||||
private synchronized Network setupvSwitchNetwork(Connection conn) {
|
||||
try {
|
||||
if (_host.vswitchNetwork == null) {
|
||||
Network vswitchNw = null;
|
||||
@ -4035,7 +4035,8 @@ public abstract class CitrixResourceBase implements ServerResource {
|
||||
}
|
||||
}
|
||||
// assume the memory Virtualization overhead is 1/64
|
||||
ram = (ram - dom0Ram) * 63/64;
|
||||
// xen hypervisor used 128 M
|
||||
ram = (ram - dom0Ram - (128 * 1024 * 1024)) * 63/64;
|
||||
cmd.setMemory(ram);
|
||||
cmd.setDom0MinMemory(dom0Ram);
|
||||
|
||||
|
||||
@ -28,6 +28,8 @@ import javax.persistence.Table;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
import javax.persistence.Transient;
|
||||
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
|
||||
/**
|
||||
* ConsoleProxyVO domain object
|
||||
@ -97,64 +99,11 @@ public class ConsoleProxyVO extends VMInstanceVO implements ConsoleProxy {
|
||||
/**
|
||||
* Correct constructor to use.
|
||||
*/
|
||||
public ConsoleProxyVO(long id, long serviceOfferingId, String name, long templateId, long guestOSId, long dataCenterId, long domainId, long accountId, int activeSession) {
|
||||
super(id, serviceOfferingId, name, name, Type.ConsoleProxy, templateId, guestOSId, domainId, accountId, false);
|
||||
public ConsoleProxyVO(long id, long serviceOfferingId, String name, long templateId, HypervisorType hypervisorType, long guestOSId, long dataCenterId, long domainId, long accountId, int activeSession) {
|
||||
super(id, serviceOfferingId, name, name, Type.ConsoleProxy, templateId, hypervisorType, guestOSId, domainId, accountId, false);
|
||||
this.activeSession = activeSession;
|
||||
}
|
||||
|
||||
public ConsoleProxyVO(ConsoleProxyVO that) {
|
||||
this(that.id, that.serviceOfferingId, that.instanceName, that.guestMacAddress, that.guestIpAddress, that.guestNetmask, that.privateMacAddress, that.privateIpAddress, that.privateNetmask, that.templateId, that.guestOSId, that.publicMacAddress, that.publicIpAddress, that.publicNetmask, that.vlanDbId, that.vlanId, that.podId, that.dataCenterId, that.domainId, that.accountId, that.gateway, that.hostId, that.dns1, that.dns2, that.domain, that.ramSize, that.activeSession);
|
||||
this.vncPassword = that.vncPassword;
|
||||
this.sslEnabled = that.sslEnabled;
|
||||
this.sessionDetails = that.sessionDetails;
|
||||
}
|
||||
|
||||
public ConsoleProxyVO(
|
||||
long id,
|
||||
long serviceOfferingId,
|
||||
String name,
|
||||
String guestMacAddress,
|
||||
String guestIpAddress,
|
||||
String guestNetMask,
|
||||
String privateMacAddress,
|
||||
String privateIpAddress,
|
||||
String privateNetmask,
|
||||
long templateId,
|
||||
long guestOSId,
|
||||
String publicMacAddress,
|
||||
String publicIpAddress,
|
||||
String publicNetmask,
|
||||
Long vlanDbId,
|
||||
String vlanId,
|
||||
long podId,
|
||||
long dataCenterId,
|
||||
long domainId,
|
||||
long accountId,
|
||||
String gateway,
|
||||
Long hostId,
|
||||
String dns1,
|
||||
String dns2,
|
||||
String domain,
|
||||
int ramSize,
|
||||
int activeSession) {
|
||||
super(id, serviceOfferingId, name, name, Type.ConsoleProxy, templateId, guestOSId,
|
||||
privateMacAddress, privateIpAddress, privateNetmask, dataCenterId, podId, domainId, accountId, true, hostId);
|
||||
this.gateway = gateway;
|
||||
this.publicIpAddress = publicIpAddress;
|
||||
this.publicNetmask = publicNetmask;
|
||||
this.publicMacAddress = publicMacAddress;
|
||||
this.guestIpAddress = guestIpAddress;
|
||||
this.guestMacAddress = guestMacAddress;
|
||||
this.guestNetmask = guestNetMask;
|
||||
this.vlanDbId = vlanDbId;
|
||||
this.vlanId = vlanId;
|
||||
this.dns1 = dns1;
|
||||
this.dns2 = dns2;
|
||||
this.domain = domain;
|
||||
this.ramSize = ramSize;
|
||||
this.activeSession = activeSession;
|
||||
}
|
||||
|
||||
protected ConsoleProxyVO() {
|
||||
super();
|
||||
}
|
||||
|
||||
@ -26,6 +26,7 @@ import javax.persistence.Enumerated;
|
||||
import javax.persistence.PrimaryKeyJoinColumn;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.network.router.VirtualRouter;
|
||||
import com.cloud.utils.net.NetUtils;
|
||||
|
||||
@ -92,66 +93,17 @@ public class DomainRouterVO extends VMInstanceVO implements VirtualRouter {
|
||||
@Enumerated(EnumType.STRING)
|
||||
private Role role = Role.DHCP_FIREWALL_LB_PASSWD_USERDATA;
|
||||
|
||||
public DomainRouterVO(DomainRouterVO that) {
|
||||
this(that.id, that.serviceOfferingId, that.instanceName, that.privateMacAddress, that.privateIpAddress, that.privateNetmask, that.templateId, that.guestOSId, that.guestMacAddress, that.guestIpAddress, that.guestNetmask, that.accountId, that.domainId, that.publicMacAddress, that.publicIpAddress, that.publicNetmask, that.vlanDbId, that.vlanId, that.podId, that.dataCenterId, that.ramSize, that.gateway, that.domain, that.dns1, that.dns2);
|
||||
this.vnet = that.vnet;
|
||||
this.role = that.role;
|
||||
}
|
||||
|
||||
public DomainRouterVO(long id,
|
||||
long serviceOfferingId,
|
||||
String name,
|
||||
String privateMacAddress,
|
||||
String privateIpAddress,
|
||||
String privateNetmask,
|
||||
long templateId,
|
||||
long guestOSId,
|
||||
String guestMacAddress,
|
||||
String guestIpAddress,
|
||||
String guestNetmask,
|
||||
long accountId,
|
||||
long domainId,
|
||||
String publicMacAddress,
|
||||
String publicIpAddress,
|
||||
String publicNetMask,
|
||||
Long vlanDbId, String vlanId,
|
||||
long podId,
|
||||
long dataCenterId,
|
||||
int ramSize,
|
||||
String gateway,
|
||||
String domain,
|
||||
String dns1,
|
||||
String dns2) {
|
||||
super(id, serviceOfferingId, name, name, Type.DomainRouter, templateId, guestOSId, privateMacAddress, privateIpAddress, privateNetmask, dataCenterId, podId, domainId, accountId, true, null);
|
||||
this.privateMacAddress = privateMacAddress;
|
||||
this.guestMacAddress = guestMacAddress;
|
||||
this.guestIpAddress = guestIpAddress;
|
||||
this.publicIpAddress = publicIpAddress;
|
||||
this.publicMacAddress = publicMacAddress;
|
||||
this.publicNetmask = publicNetMask;
|
||||
this.vlanDbId = vlanDbId;
|
||||
this.vlanId = vlanId;
|
||||
this.ramSize = ramSize;
|
||||
this.gateway = gateway;
|
||||
this.domain = domain;
|
||||
this.dns1 = dns1;
|
||||
this.dns2 = dns2;
|
||||
this.dataCenterId = dataCenterId;
|
||||
this.accountId = accountId;
|
||||
this.domainId = domainId;
|
||||
this.guestNetmask = guestNetmask;
|
||||
}
|
||||
|
||||
public DomainRouterVO(long id,
|
||||
long serviceOfferingId,
|
||||
String name,
|
||||
long templateId,
|
||||
HypervisorType hypervisorType,
|
||||
long guestOSId,
|
||||
long domainId,
|
||||
long accountId,
|
||||
long networkConfigurationId,
|
||||
boolean haEnabled) {
|
||||
super(id, serviceOfferingId, name, name, Type.DomainRouter, templateId, guestOSId, domainId, accountId, haEnabled);
|
||||
super(id, serviceOfferingId, name, name, Type.DomainRouter, templateId, hypervisorType, guestOSId, domainId, accountId, haEnabled);
|
||||
this.networkId = networkConfigurationId;
|
||||
}
|
||||
|
||||
|
||||
@ -26,6 +26,8 @@ import javax.persistence.PrimaryKeyJoinColumn;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
|
||||
/**
|
||||
* SecondaryStorageVmVO domain object
|
||||
@ -89,63 +91,11 @@ public class SecondaryStorageVmVO extends VMInstanceVO implements SecondaryStora
|
||||
|
||||
|
||||
|
||||
public SecondaryStorageVmVO(long id, long serviceOfferingId, String name, long templateId, long guestOSId, long dataCenterId,
|
||||
public SecondaryStorageVmVO(long id, long serviceOfferingId, String name, long templateId, HypervisorType hypervisorType, long guestOSId, long dataCenterId,
|
||||
long domainId, long accountId) {
|
||||
super(id, serviceOfferingId, name, name, Type.SecondaryStorageVm, templateId, guestOSId, domainId, accountId, true);
|
||||
super(id, serviceOfferingId, name, name, Type.SecondaryStorageVm, templateId, hypervisorType, guestOSId, domainId, accountId, true);
|
||||
}
|
||||
|
||||
public SecondaryStorageVmVO(
|
||||
long id,
|
||||
long serviceOfferingId,
|
||||
String name,
|
||||
String guestMacAddress,
|
||||
String guestIpAddress,
|
||||
String guestNetMask,
|
||||
String privateMacAddress,
|
||||
String privateIpAddress,
|
||||
String privateNetmask,
|
||||
long templateId,
|
||||
long guestOSId,
|
||||
String publicMacAddress,
|
||||
String publicIpAddress,
|
||||
String publicNetmask,
|
||||
Long vlanDbId,
|
||||
String vlanId,
|
||||
long podId,
|
||||
long dataCenterId,
|
||||
long domainId,
|
||||
long accountId,
|
||||
String gateway,
|
||||
Long hostId,
|
||||
String dns1,
|
||||
String dns2,
|
||||
String domain,
|
||||
int ramSize,
|
||||
String guid,
|
||||
String nfsShare) {
|
||||
super(id, serviceOfferingId, name, name, Type.SecondaryStorageVm, templateId, guestOSId,
|
||||
privateMacAddress, privateIpAddress, privateNetmask, dataCenterId, podId, domainId, accountId, true, hostId);
|
||||
this.gateway = gateway;
|
||||
this.publicIpAddress = publicIpAddress;
|
||||
this.publicNetmask = publicNetmask;
|
||||
this.publicMacAddress = publicMacAddress;
|
||||
this.guestIpAddress = guestIpAddress;
|
||||
this.guestMacAddress = guestMacAddress;
|
||||
this.guestNetmask = guestNetMask;
|
||||
this.vlanDbId = vlanDbId;
|
||||
this.vlanId = vlanId;
|
||||
this.dns1 = dns1;
|
||||
this.dns2 = dns2;
|
||||
this.domain = domain;
|
||||
this.ramSize = ramSize;
|
||||
this.setGuid(guid);
|
||||
this.nfsShare = nfsShare;
|
||||
}
|
||||
|
||||
public SecondaryStorageVmVO(SecondaryStorageVmVO that) {
|
||||
this(that.id, that.serviceOfferingId, that.instanceName, that.guestMacAddress, that.guestIpAddress, that.guestNetmask, that.privateMacAddress, that.privateIpAddress, that.privateNetmask, that.templateId, that.guestOSId, that.publicMacAddress, that.publicIpAddress, that.publicNetmask, that.vlanDbId, that.vlanId, that.podId, that.dataCenterId, that.domainId, that.accountId, that.gateway, that.hostId, that.dns1, that.dns2, that.domain, that.ramSize, that.guid, that.nfsShare);
|
||||
}
|
||||
|
||||
protected SecondaryStorageVmVO() {
|
||||
super();
|
||||
}
|
||||
|
||||
@ -23,6 +23,7 @@ import javax.persistence.Entity;
|
||||
import javax.persistence.PrimaryKeyJoinColumn;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.uservm.UserVm;
|
||||
|
||||
@Entity
|
||||
@ -66,6 +67,7 @@ public class UserVmVO extends VMInstanceVO implements UserVm {
|
||||
|
||||
transient String password;
|
||||
|
||||
@Override
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
@ -140,49 +142,18 @@ public class UserVmVO extends VMInstanceVO implements UserVm {
|
||||
String instanceName,
|
||||
String displayName,
|
||||
long templateId,
|
||||
HypervisorType hypervisorType,
|
||||
long guestOsId,
|
||||
boolean haEnabled,
|
||||
long domainId,
|
||||
long accountId,
|
||||
long serviceOfferingId,
|
||||
String userData, String name) {
|
||||
super(id, serviceOfferingId, name, instanceName, Type.User, templateId, guestOsId, domainId, accountId, haEnabled);
|
||||
super(id, serviceOfferingId, name, instanceName, Type.User, templateId, hypervisorType, guestOsId, domainId, accountId, haEnabled);
|
||||
this.userData = userData;
|
||||
this.displayName = displayName != null ? displayName : null;
|
||||
}
|
||||
|
||||
public UserVmVO(long id,
|
||||
String name,
|
||||
long templateId,
|
||||
long guestOSId,
|
||||
long accountId,
|
||||
long domainId,
|
||||
long serviceOfferingId,
|
||||
String guestMacAddress,
|
||||
String guestIpAddress,
|
||||
String guestNetMask,
|
||||
String externalIpAddress,
|
||||
String externalMacAddress,
|
||||
Long vlanDbId,
|
||||
Long routerId,
|
||||
long podId,
|
||||
long dcId,
|
||||
boolean haEnabled,
|
||||
String displayName,
|
||||
String userData) {
|
||||
super(id, serviceOfferingId, name, name, Type.User, templateId, guestOSId, guestMacAddress, guestIpAddress, guestNetMask, dcId, podId, domainId, accountId, haEnabled, null);
|
||||
this.domainRouterId = routerId;
|
||||
this.guestIpAddress = guestIpAddress;
|
||||
this.guestNetmask = guestNetMask;
|
||||
this.guestMacAddress = guestMacAddress;
|
||||
this.externalIpAddress = externalIpAddress;
|
||||
this.externalMacAddress = externalMacAddress;
|
||||
this.setUserData(userData);
|
||||
this.setExternalVlanDbId(vlanDbId);
|
||||
this.isoId = null;
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
protected UserVmVO() {
|
||||
super();
|
||||
}
|
||||
|
||||
@ -35,6 +35,7 @@ import javax.persistence.TableGenerator;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
import com.cloud.utils.db.StateMachine;
|
||||
import com.cloud.utils.fsm.FiniteStateObject;
|
||||
@ -139,12 +140,17 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject<State, Vi
|
||||
@Column(name="reservation_id")
|
||||
protected String reservationId;
|
||||
|
||||
@Column(name="hypervisor_type")
|
||||
@Enumerated(value=EnumType.STRING)
|
||||
protected HypervisorType hypervisorType;
|
||||
|
||||
public VMInstanceVO(long id,
|
||||
long serviceOfferingId,
|
||||
String name,
|
||||
String instanceName,
|
||||
Type type,
|
||||
Long vmTemplateId,
|
||||
HypervisorType hypervisorType,
|
||||
long guestOSId,
|
||||
long domainId,
|
||||
long accountId,
|
||||
@ -164,52 +170,9 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject<State, Vi
|
||||
this.accountId = accountId;
|
||||
this.domainId = domainId;
|
||||
this.serviceOfferingId = serviceOfferingId;
|
||||
this.hypervisorType = hypervisorType;
|
||||
}
|
||||
|
||||
|
||||
public VMInstanceVO(long id,
|
||||
long serviceOfferingId,
|
||||
String name,
|
||||
String instanceName,
|
||||
Type type,
|
||||
long vmTemplateId,
|
||||
long guestOSId,
|
||||
String privateMacAddress,
|
||||
String privateIpAddress,
|
||||
String privateNetmask,
|
||||
long dataCenterId,
|
||||
long podId,
|
||||
long domainId,
|
||||
long accountId,
|
||||
boolean haEnabled,
|
||||
Long hostId) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
if (vmTemplateId > -1) {
|
||||
this.templateId = vmTemplateId;
|
||||
} else {
|
||||
this.templateId = null;
|
||||
}
|
||||
this.guestOSId = guestOSId;
|
||||
this.privateIpAddress = privateIpAddress;
|
||||
this.privateMacAddress = privateMacAddress;
|
||||
this.privateNetmask = privateNetmask;
|
||||
this.hostId = hostId;
|
||||
this.dataCenterId = dataCenterId;
|
||||
this.podId = podId;
|
||||
this.type = type;
|
||||
this.haEnabled = haEnabled;
|
||||
this.instanceName = instanceName;
|
||||
this.updated = 0;
|
||||
this.updateTime = new Date();
|
||||
this.vncPassword = Long.toHexString(new Random().nextLong());
|
||||
this.state = State.Creating;
|
||||
this.serviceOfferingId = serviceOfferingId;
|
||||
this.domainId = domainId;
|
||||
this.accountId = accountId;
|
||||
}
|
||||
|
||||
protected VMInstanceVO() {
|
||||
}
|
||||
|
||||
@ -239,6 +202,11 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject<State, Vi
|
||||
@Override
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HypervisorType getHypervisorType() {
|
||||
return hypervisorType;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -486,7 +486,7 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory,
|
||||
final ServiceOfferingVO offering, final VMTemplateVO template,
|
||||
VMInstanceVO vm, Host currentHost, final Set<Host> avoid) {
|
||||
VirtualMachineProfileImpl<VMInstanceVO> vmProfile = new VirtualMachineProfileImpl<VMInstanceVO>(
|
||||
vm, template, offering, null, null, null);
|
||||
vm, template, offering, null, null);
|
||||
DeployDestination dest = null;
|
||||
DataCenterDeployment plan = new DataCenterDeployment(dc.getId(),
|
||||
pod.getId(), sp.getClusterId(), null);
|
||||
|
||||
@ -739,7 +739,7 @@ public class ApiResponseHelper implements ResponseGenerator {
|
||||
volResponse.setDeviceId(volume.getDeviceId());
|
||||
|
||||
Long instanceId = volume.getInstanceId();
|
||||
if (instanceId != null) {
|
||||
if (instanceId != null && volume.getState() != Volume.State.Destroy) {
|
||||
VMInstanceVO vm = ApiDBUtils.findVMInstanceById(instanceId);
|
||||
volResponse.setVirtualMachineId(vm.getId());
|
||||
volResponse.setVirtualMachineName(vm.getName());
|
||||
@ -1083,13 +1083,11 @@ public class ApiResponseHelper implements ResponseGenerator {
|
||||
if (singleNic.getIsolationUri() != null) {
|
||||
nicResponse.setIsolationUri(singleNic.getIsolationUri().toString());
|
||||
}
|
||||
}
|
||||
//Set traffic type
|
||||
}
|
||||
Network network = ApiDBUtils.findNetworkById(singleNic.getNetworkId());
|
||||
nicResponse.setTrafficType(network.getTrafficType().toString());
|
||||
|
||||
//Set type
|
||||
nicResponse.setType(network.getGuestType().toString());
|
||||
nicResponse.setIsDefault(singleNic.isDefaultNic());
|
||||
|
||||
nicResponse.setObjectName("nic");
|
||||
|
||||
@ -2225,6 +2223,7 @@ public class ApiResponseHelper implements ResponseGenerator {
|
||||
}
|
||||
|
||||
response.setIsShared(network.isShared());
|
||||
response.setIsDefault(network.isDefault());
|
||||
response.setState(network.getState().toString());
|
||||
response.setRelated(network.getRelated());
|
||||
response.setDns1(network.getDns1());
|
||||
|
||||
@ -47,6 +47,7 @@ import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.BaseListCmd;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.response.BaseResponse;
|
||||
import com.cloud.serializer.Param;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.thoughtworks.xstream.XStream;
|
||||
@ -230,7 +231,7 @@ public class ApiXmlDocWriter {
|
||||
else
|
||||
System.out.println("Command " + apiCommand.getName() + " misses description");
|
||||
|
||||
//Get request parameters
|
||||
//Set request parameters
|
||||
Field[] fields = clas.getDeclaredFields();
|
||||
|
||||
//Get fields from superclass
|
||||
@ -246,46 +247,13 @@ public class ApiXmlDocWriter {
|
||||
}
|
||||
superClass = superClass.getSuperclass();
|
||||
}
|
||||
|
||||
for (Field f : fields) {
|
||||
Parameter parameterAnnotation = f.getAnnotation(Parameter.class);
|
||||
if (parameterAnnotation != null && parameterAnnotation.expose()) {
|
||||
Argument reqArg = new Argument(parameterAnnotation.name());
|
||||
reqArg.setRequired(parameterAnnotation.required());
|
||||
if (!parameterAnnotation.description().isEmpty())
|
||||
reqArg.setDescription(parameterAnnotation.description());
|
||||
else {
|
||||
//System.out.println("Description is missing for the request parameter " + parameterAnnotation.name() + " of the command " + apiCommand.getName());
|
||||
}
|
||||
request.add(reqArg);
|
||||
}
|
||||
}
|
||||
request = setRequestFields(fields);
|
||||
|
||||
Class<?> responseClas = impl.responseObject();
|
||||
|
||||
//Get response parameters
|
||||
Class<?> responseClas = impl.responseObject();
|
||||
Field[] responseFields = responseClas.getDeclaredFields();
|
||||
for (Field responseField : responseFields) {
|
||||
SerializedName nameAnnotation = responseField.getAnnotation(SerializedName.class);
|
||||
Param descAnnotation = responseField.getAnnotation(Param.class);
|
||||
Argument respArg = new Argument(nameAnnotation.value());
|
||||
boolean toExpose = true;
|
||||
if (descAnnotation != null) {
|
||||
String description = descAnnotation.description();
|
||||
toExpose = descAnnotation.expose();
|
||||
if (description != null && !description.isEmpty()) {
|
||||
respArg.setDescription(description);
|
||||
} else if (toExpose){
|
||||
//System.out.println("Description is missing for the response parameter " + nameAnnotation.value().toString() + " of the command " + apiCommand.getName());
|
||||
}
|
||||
} else {
|
||||
//System.out.println("Description is missing for the response parameter " + nameAnnotation.value().toString() + " of the command " + apiCommand.getName());
|
||||
}
|
||||
|
||||
if (toExpose) {
|
||||
response.add(respArg);
|
||||
}
|
||||
}
|
||||
response = setResponseFields(responseFields);
|
||||
|
||||
apiCommand.setRequest(request);
|
||||
apiCommand.setResponse(response);
|
||||
@ -293,6 +261,61 @@ public class ApiXmlDocWriter {
|
||||
out.writeObject(apiCommand);
|
||||
}
|
||||
|
||||
|
||||
private static ArrayList<Argument> setRequestFields(Field[] fields) {
|
||||
ArrayList<Argument> arguments = new ArrayList<Argument>();
|
||||
for (Field f : fields) {
|
||||
Parameter parameterAnnotation = f.getAnnotation(Parameter.class);
|
||||
if (parameterAnnotation != null && parameterAnnotation.expose()) {
|
||||
Argument reqArg = new Argument(parameterAnnotation.name());
|
||||
reqArg.setRequired(parameterAnnotation.required());
|
||||
if (!parameterAnnotation.description().isEmpty()) {
|
||||
reqArg.setDescription(parameterAnnotation.description());
|
||||
}
|
||||
arguments.add(reqArg);
|
||||
}
|
||||
}
|
||||
return arguments;
|
||||
}
|
||||
|
||||
private static ArrayList<Argument> setResponseFields(Field[] responseFields) {
|
||||
ArrayList<Argument> arguments = new ArrayList<Argument>();
|
||||
for (Field responseField : responseFields) {
|
||||
SerializedName nameAnnotation = responseField.getAnnotation(SerializedName.class);
|
||||
Param paramAnnotation = responseField.getAnnotation(Param.class);
|
||||
Argument respArg = new Argument(nameAnnotation.value());
|
||||
boolean toExpose = true;
|
||||
if (paramAnnotation != null) {
|
||||
String description = paramAnnotation.description();
|
||||
Class fieldClass = paramAnnotation.responseObject();
|
||||
toExpose = paramAnnotation.expose();
|
||||
if (description != null && !description.isEmpty()) {
|
||||
respArg.setDescription(description);
|
||||
}
|
||||
|
||||
if (fieldClass != null) {
|
||||
Class<?> superClass = fieldClass.getSuperclass();
|
||||
if (superClass != null) {
|
||||
String superName = superClass.getName();
|
||||
if (superName.equals(BaseResponse.class.getName())) {
|
||||
ArrayList<Argument> fieldArguments = new ArrayList<Argument>();
|
||||
Field[] fields = fieldClass.getDeclaredFields();
|
||||
fieldArguments = setResponseFields(fields);
|
||||
respArg.setArguments(fieldArguments);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (toExpose) {
|
||||
arguments.add(respArg);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return arguments;
|
||||
}
|
||||
|
||||
private static void zipDir(String zipFileName, String dir) throws Exception {
|
||||
File dirObj = new File(dir);
|
||||
ZipOutputStream out = new ZipOutputStream(new FileOutputStream(zipFileName));
|
||||
|
||||
@ -18,10 +18,13 @@
|
||||
|
||||
package com.cloud.api.doc;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Argument{
|
||||
private String name;
|
||||
private String description;
|
||||
private Boolean required;
|
||||
private List<Argument> arguments;
|
||||
|
||||
public Argument(String name) {
|
||||
this.name = name;
|
||||
@ -45,5 +48,12 @@ public class Argument{
|
||||
public void setRequired(Boolean required) {
|
||||
this.required = required;
|
||||
}
|
||||
|
||||
|
||||
public List<Argument> getArguments() {
|
||||
return arguments;
|
||||
}
|
||||
|
||||
public void setArguments(List<Argument> arguments) {
|
||||
this.arguments = arguments;
|
||||
}
|
||||
}
|
||||
|
||||
@ -214,7 +214,13 @@ public enum Config {
|
||||
SSOKey("Hidden", ManagementServer.class, String.class, "security.singlesignon.key", null, "A Single Sign-On key used for logging into the cloud", null),
|
||||
SSOAuthTolerance("Advanced", ManagementServer.class, Long.class, "security.singlesignon.tolerance.millis", "300000", "The allowable clock difference in milliseconds between when an SSO login request is made and when it is received.", null),
|
||||
//NetworkType("Hidden", ManagementServer.class, String.class, "network.type", "vlan", "The type of network that this deployment will use.", "vlan,direct"),
|
||||
HashKey("Hidden", ManagementServer.class, String.class, "security.hash.key", null, "for generic key-ed hash", null);
|
||||
HashKey("Hidden", ManagementServer.class, String.class, "security.hash.key", null, "for generic key-ed hash", null),
|
||||
|
||||
VmOpWaitInterval("Advanced", ManagementServer.class, Integer.class, "vm.op.wait.interval", "120", "Seconds to wait before checking if a previous operation has succeeded", null),
|
||||
VmOpLockStateRetry("Advanced", ManagementServer.class, Integer.class, "vm.op.lock.state.retry", "5", "Times to retry locking the state of a VM for operations", "-1 means try forever"),
|
||||
VmOpCleanupInterval("Advanced", ManagementServer.class, Long.class, "vm.op.cleanup.interval", "86400", "Interval to run the thread that cleans up the vm operations in seconds", "Seconds"),
|
||||
VmOpCleanupWait("Advanced", ManagementServer.class, Long.class, "vm.op.cleanup.wait", "3600", "Seconds to wait before cleanuping up any vm work items", "Seconds"),
|
||||
VmOpCancelInterval("Advanced", ManagementServer.class, Long.class, "vm.op.cancel.interval", "3600", "Seconds to wait before cancelling a operation", "Seconds");
|
||||
|
||||
private final String _category;
|
||||
private final Class<?> _componentClass;
|
||||
|
||||
@ -1216,6 +1216,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
Account systemAccount = _accountDao.findById(Account.ACCOUNT_ID_SYSTEM);
|
||||
|
||||
BroadcastDomainType broadcastDomainType = null;
|
||||
boolean isNetworkDefault = false;
|
||||
if (offering.getTrafficType() == TrafficType.Management) {
|
||||
broadcastDomainType = BroadcastDomainType.Native;
|
||||
} else if (offering.getTrafficType() == TrafficType.Control) {
|
||||
@ -1228,13 +1229,14 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
}
|
||||
} else if (offering.getTrafficType() == TrafficType.Guest) {
|
||||
if (zone.getNetworkType() == NetworkType.Basic) {
|
||||
isNetworkDefault = true;
|
||||
broadcastDomainType = BroadcastDomainType.Native;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
userNetwork.setBroadcastDomainType(broadcastDomainType);
|
||||
_networkMgr.setupNetwork(systemAccount, offering, userNetwork, plan, null, null, true);
|
||||
_networkMgr.setupNetwork(systemAccount, offering, userNetwork, plan, null, null, true, isNetworkDefault);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -562,7 +562,10 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
||||
ConsoleProxyVO proxy = _consoleProxyDao.findById(proxyVmId);
|
||||
Account systemAcct = _accountMgr.getSystemAccount();
|
||||
User systemUser = _accountMgr.getSystemUser();
|
||||
return _itMgr.start(proxy, null, systemUser, systemAcct, null);
|
||||
if (proxy.getState() == VirtualMachine.State.Running) {
|
||||
return proxy;
|
||||
}
|
||||
return _itMgr.start(proxy, null, systemUser, systemAcct);
|
||||
}
|
||||
|
||||
public ConsoleProxyVO assignProxyFromRunningPool(long dataCenterId) {
|
||||
@ -709,11 +712,11 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
||||
NicProfile defaultNic = new NicProfile();
|
||||
defaultNic.setDefaultNic(true);
|
||||
defaultNic.setDeviceId(2);
|
||||
networks.add(new Pair<NetworkVO, NicProfile>(_networkMgr.setupNetwork(systemAcct, defaultOffering.get(0), plan, null, null, false).get(0), defaultNic));
|
||||
networks.add(new Pair<NetworkVO, NicProfile>(_networkMgr.setupNetwork(systemAcct, defaultOffering.get(0), plan, null, null, false, false).get(0), defaultNic));
|
||||
for (NetworkOfferingVO offering : offerings) {
|
||||
networks.add(new Pair<NetworkVO, NicProfile>(_networkMgr.setupNetwork(systemAcct, offering, plan, null, null, false).get(0), null));
|
||||
networks.add(new Pair<NetworkVO, NicProfile>(_networkMgr.setupNetwork(systemAcct, offering, plan, null, null, false, false).get(0), null));
|
||||
}
|
||||
ConsoleProxyVO proxy = new ConsoleProxyVO(id, _serviceOffering.getId(), name, _template.getId(), _template.getGuestOSId(), dataCenterId, systemAcct.getDomainId(), systemAcct.getId(), 0);
|
||||
ConsoleProxyVO proxy = new ConsoleProxyVO(id, _serviceOffering.getId(), name, _template.getId(), _template.getHypervisorType(), _template.getGuestOSId(), dataCenterId, systemAcct.getDomainId(), systemAcct.getId(), 0);
|
||||
try {
|
||||
proxy = _itMgr.allocate(proxy, _template, _serviceOffering, networks, plan, null, systemAcct);
|
||||
} catch (InsufficientCapacityException e) {
|
||||
@ -1557,64 +1560,13 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
||||
}
|
||||
|
||||
@Override
|
||||
@DB
|
||||
public boolean destroyProxy(long vmId) {
|
||||
AsyncJobExecutor asyncExecutor = BaseAsyncJobExecutor.getCurrentExecutor();
|
||||
if (asyncExecutor != null) {
|
||||
AsyncJobVO job = asyncExecutor.getJob();
|
||||
|
||||
if (s_logger.isInfoEnabled()) {
|
||||
s_logger.info("Destroy console proxy " + vmId + ", update async job-" + job.getId());
|
||||
}
|
||||
_asyncMgr.updateAsyncJobAttachment(job.getId(), "console_proxy", vmId);
|
||||
}
|
||||
|
||||
ConsoleProxyVO vm = _consoleProxyDao.findById(vmId);
|
||||
if (vm == null || vm.getState() == State.Destroyed) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Unable to find vm or vm is destroyed: " + vmId);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Destroying console proxy vm " + vmId);
|
||||
}
|
||||
|
||||
if (!_itMgr.stateTransitTo(vm, VirtualMachine.Event.DestroyRequested, null)) {
|
||||
s_logger.debug("Unable to destroy the vm because it is not in the correct state: " + vmId);
|
||||
return false;
|
||||
}
|
||||
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
List<VolumeVO> vols = null;
|
||||
ConsoleProxyVO proxy = _consoleProxyDao.findById(vmId);
|
||||
try {
|
||||
vols = _volsDao.findByInstance(vmId);
|
||||
if (vols.size() != 0) {
|
||||
_storageMgr.destroy(vm, vols);
|
||||
}
|
||||
|
||||
return true;
|
||||
} finally {
|
||||
try {
|
||||
txn.start();
|
||||
// release critical system resources used by the VM before we
|
||||
// delete them
|
||||
if (vm.getPublicIpAddress() != null) {
|
||||
// freePublicIpAddress(vm.getPublicIpAddress(), vm.getDataCenterId(), vm.getPodId());
|
||||
}
|
||||
vm.setPublicIpAddress(null);
|
||||
|
||||
_consoleProxyDao.remove(vm.getId());
|
||||
|
||||
txn.commit();
|
||||
} catch (Exception e) {
|
||||
s_logger.error("Caught this error: ", e);
|
||||
txn.rollback();
|
||||
return false;
|
||||
} finally {
|
||||
s_logger.debug("console proxy vm is destroyed : " + vm.getName());
|
||||
}
|
||||
return _itMgr.expunge(proxy, _accountMgr.getSystemUser(), _accountMgr.getSystemAccount());
|
||||
} catch (ResourceUnavailableException e) {
|
||||
s_logger.warn("Unable to expunge " + proxy, e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -381,8 +381,10 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
|
||||
if( event.equals(Event.Ping) || event.equals(Event.AgentConnected)) {
|
||||
ub.set(host, _pingTimeAttr, System.currentTimeMillis() >> 10);
|
||||
}
|
||||
}
|
||||
if ( event.equals(Event.ManagementServerDown)) {
|
||||
ub.set(host, _pingTimeAttr, (( System.currentTimeMillis() >> 10) - ( 10 * 60 )));
|
||||
}
|
||||
|
||||
int result = update(ub, sc, null);
|
||||
assert result <= 1 : "How can this update " + result + " rows? ";
|
||||
|
||||
|
||||
@ -108,8 +108,8 @@ public interface NetworkManager extends NetworkService {
|
||||
*/
|
||||
List<IPAddressVO> listPublicIpAddressesInVirtualNetwork(long accountId, long dcId, Boolean sourceNat);
|
||||
|
||||
List<NetworkVO> setupNetwork(Account owner, NetworkOfferingVO offering, DeploymentPlan plan, String name, String displayText, boolean isShared) throws ConcurrentOperationException;
|
||||
List<NetworkVO> setupNetwork(Account owner, NetworkOfferingVO offering, Network predefined, DeploymentPlan plan, String name, String displayText, boolean isShared) throws ConcurrentOperationException;
|
||||
List<NetworkVO> setupNetwork(Account owner, NetworkOfferingVO offering, DeploymentPlan plan, String name, String displayText, boolean isShared, boolean isDefault) throws ConcurrentOperationException;
|
||||
List<NetworkVO> setupNetwork(Account owner, NetworkOfferingVO offering, Network predefined, DeploymentPlan plan, String name, String displayText, boolean isShared, boolean isDefault) throws ConcurrentOperationException;
|
||||
|
||||
List<NetworkOfferingVO> getSystemAccountNetworkOfferings(String... offeringNames);
|
||||
|
||||
|
||||
@ -134,6 +134,7 @@ import com.cloud.vm.ReservationContext;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.VirtualMachine.State;
|
||||
import com.cloud.vm.VirtualMachine.Type;
|
||||
import com.cloud.vm.VirtualMachineProfile;
|
||||
import com.cloud.vm.dao.NicDao;
|
||||
import com.cloud.vm.dao.UserVmDao;
|
||||
@ -783,12 +784,12 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NetworkVO> setupNetwork(Account owner, NetworkOfferingVO offering, DeploymentPlan plan, String name, String displayText, boolean isShared) throws ConcurrentOperationException {
|
||||
return setupNetwork(owner, offering, null, plan, name, displayText, isShared);
|
||||
public List<NetworkVO> setupNetwork(Account owner, NetworkOfferingVO offering, DeploymentPlan plan, String name, String displayText, boolean isShared, boolean isDefault) throws ConcurrentOperationException {
|
||||
return setupNetwork(owner, offering, null, plan, name, displayText, isShared, isDefault);
|
||||
}
|
||||
|
||||
@Override @DB
|
||||
public List<NetworkVO> setupNetwork(Account owner, NetworkOfferingVO offering, Network predefined, DeploymentPlan plan, String name, String displayText, boolean isShared) throws ConcurrentOperationException {
|
||||
public List<NetworkVO> setupNetwork(Account owner, NetworkOfferingVO offering, Network predefined, DeploymentPlan plan, String name, String displayText, boolean isShared, boolean isDefault) throws ConcurrentOperationException {
|
||||
Transaction.currentTxn();
|
||||
Account locked = _accountDao.acquireInLockTable(owner.getId());
|
||||
if (locked == null) {
|
||||
@ -830,7 +831,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
related = id;
|
||||
}
|
||||
|
||||
NetworkVO vo = new NetworkVO(id, config, offering.getId(), plan.getDataCenterId(), guru.getName(), owner.getDomainId(), owner.getId(), related, name, displayText, isShared);
|
||||
NetworkVO vo = new NetworkVO(id, config, offering.getId(), plan.getDataCenterId(), guru.getName(), owner.getDomainId(), owner.getId(), related, name, displayText, isShared, isDefault);
|
||||
configs.add(_networksDao.persist(vo, vo.getGuestType() != null));
|
||||
}
|
||||
|
||||
@ -879,6 +880,11 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
requested.setMode(config.getMode());
|
||||
}
|
||||
NicProfile profile = concierge.allocate(config, requested, vm);
|
||||
|
||||
if (vm != null && vm.getVirtualMachine().getType() == Type.User && config.isDefault()) {
|
||||
profile.setDefaultNic(true);
|
||||
}
|
||||
|
||||
if (profile == null) {
|
||||
continue;
|
||||
}
|
||||
@ -1055,7 +1061,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
_nicDao.update(nic.getId(), nic);
|
||||
URI broadcastUri = nic.getBroadcastUri();
|
||||
if (broadcastUri == null) {
|
||||
network.getBroadcastUri();
|
||||
broadcastUri = network.getBroadcastUri();
|
||||
}
|
||||
|
||||
URI isolationUri = nic.getIsolationUri();
|
||||
@ -1284,6 +1290,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
String endIP = cmd.getEndIp();
|
||||
String netmask = cmd.getNetmask();
|
||||
String cidr = null;
|
||||
Boolean isDefault = cmd.isDefault();
|
||||
if (gateway != null && netmask != null) {
|
||||
cidr = NetUtils.ipAndNetMaskToCidr(gateway, netmask);
|
||||
}
|
||||
@ -1305,6 +1312,19 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
throw new InvalidParameterValueException("Unable to find network offeirng by id " + networkOfferingId);
|
||||
}
|
||||
|
||||
//allow isDefault to be set only for Virtual network
|
||||
if (networkOffering.getTrafficType() == TrafficType.Guest) {
|
||||
if (isDefault != null) {
|
||||
throw new InvalidParameterValueException("Can specify isDefault parameter only for Public network. ");
|
||||
} else {
|
||||
isDefault = true;
|
||||
}
|
||||
} else {
|
||||
if (isDefault == null) {
|
||||
isDefault = false;
|
||||
}
|
||||
}
|
||||
|
||||
//Check if zone exists
|
||||
if (zoneId == null || ((_dcDao.findById(zoneId)) == null)) {
|
||||
throw new InvalidParameterValueException("Please specify a valid zone.");
|
||||
@ -1355,7 +1375,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
}
|
||||
}
|
||||
|
||||
List<NetworkVO> networks = setupNetwork(owner, networkOffering, userNetwork, plan, name, displayText, isShared);
|
||||
List<NetworkVO> networks = setupNetwork(owner, networkOffering, userNetwork, plan, name, displayText, isShared, isDefault);
|
||||
Long networkId = null;
|
||||
|
||||
Network network = null;
|
||||
@ -1424,8 +1444,10 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
Long domainId = cmd.getDomainId();
|
||||
String accountName = cmd.getAccountName();
|
||||
String type = cmd.getType();
|
||||
String trafficType = cmd.getTrafficType();
|
||||
Boolean isSystem = cmd.getIsSystem();
|
||||
Boolean isShared = cmd.getIsShared();
|
||||
Boolean isDefault = cmd.isDefault();
|
||||
Long accountId = null;
|
||||
|
||||
if (isSystem == null) {
|
||||
@ -1510,6 +1532,14 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
sc.addAnd("isShared", SearchCriteria.Op.EQ, isShared);
|
||||
}
|
||||
|
||||
if (isDefault != null) {
|
||||
sc.addAnd("isDefault", SearchCriteria.Op.EQ, isDefault);
|
||||
}
|
||||
|
||||
if (trafficType != null) {
|
||||
sc.addAnd("trafficType", SearchCriteria.Op.EQ, trafficType);
|
||||
}
|
||||
|
||||
List<NetworkVO> networks = _networksDao.search(sc, searchFilter);
|
||||
|
||||
return networks;
|
||||
@ -1708,8 +1738,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
@Override
|
||||
public boolean restartNetwork(RestartNetworkCmd cmd) throws ConcurrentOperationException, ResourceUnavailableException {
|
||||
//This method reapplies Ip addresses, LoadBalancer and PortForwarding rules
|
||||
Account caller = UserContext.current().getCaller();
|
||||
|
||||
Account caller = UserContext.current().getCaller();
|
||||
Long networkId = cmd.getNetworkId();
|
||||
Network network = null;
|
||||
if (networkId != null) {
|
||||
|
||||
@ -131,6 +131,9 @@ public class NetworkVO implements Network {
|
||||
@Column(name="reservation_id")
|
||||
String reservationId;
|
||||
|
||||
@Column(name="is_default")
|
||||
boolean isDefault;
|
||||
|
||||
public NetworkVO() {
|
||||
}
|
||||
|
||||
@ -158,8 +161,8 @@ public class NetworkVO implements Network {
|
||||
this.guestType = guestType;
|
||||
}
|
||||
|
||||
public NetworkVO(long id, Network that, long offeringId, long dataCenterId, String guruName, long domainId, long accountId, long related, String name, String displayText, Boolean isShared) {
|
||||
this(id, that.getTrafficType(), that.getGuestType(), that.getMode(), that.getBroadcastDomainType(), offeringId, dataCenterId, domainId, accountId, related, name, displayText, isShared);
|
||||
public NetworkVO(long id, Network that, long offeringId, long dataCenterId, String guruName, long domainId, long accountId, long related, String name, String displayText, Boolean isShared, boolean isDefault) {
|
||||
this(id, that.getTrafficType(), that.getGuestType(), that.getMode(), that.getBroadcastDomainType(), offeringId, dataCenterId, domainId, accountId, related, name, displayText, isShared, isDefault);
|
||||
this.gateway = that.getGateway();
|
||||
this.dns1 = that.getDns1();
|
||||
this.dns2 = that.getDns2();
|
||||
@ -184,9 +187,10 @@ public class NetworkVO implements Network {
|
||||
* @param accountId
|
||||
* @param name
|
||||
* @param displayText
|
||||
* @param isShared TODO
|
||||
* @param isShared
|
||||
* @param isDefault
|
||||
*/
|
||||
public NetworkVO(long id, TrafficType trafficType, GuestIpType guestType, Mode mode, BroadcastDomainType broadcastDomainType, long networkOfferingId, long dataCenterId, long domainId, long accountId, long related, String name, String displayText, Boolean isShared) {
|
||||
public NetworkVO(long id, TrafficType trafficType, GuestIpType guestType, Mode mode, BroadcastDomainType broadcastDomainType, long networkOfferingId, long dataCenterId, long domainId, long accountId, long related, String name, String displayText, Boolean isShared, boolean isDefault) {
|
||||
this(trafficType, guestType, mode, broadcastDomainType, networkOfferingId, dataCenterId, State.Allocated);
|
||||
this.domainId = domainId;
|
||||
this.accountId = accountId;
|
||||
@ -195,6 +199,7 @@ public class NetworkVO implements Network {
|
||||
this.name = name;
|
||||
this.displayText = displayText;
|
||||
this.isShared = isShared;
|
||||
this.isDefault = isDefault;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -373,6 +378,11 @@ public class NetworkVO implements Network {
|
||||
public boolean isShared() {
|
||||
return isShared;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDefault() {
|
||||
return isDefault;
|
||||
}
|
||||
|
||||
public void setShared(boolean isShared) {
|
||||
this.isShared = isShared;
|
||||
|
||||
@ -1,8 +1,11 @@
|
||||
package com.cloud.network.ovs;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.persistence.EntityExistsException;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.agent.Listener;
|
||||
@ -13,23 +16,33 @@ import com.cloud.agent.api.Command;
|
||||
import com.cloud.agent.api.PingRoutingWithOvsCommand;
|
||||
import com.cloud.agent.api.StartupCommand;
|
||||
import com.cloud.exception.ConnectionException;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.Status;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.network.ovs.dao.GreTunnelDao;
|
||||
import com.cloud.network.ovs.dao.GreTunnelVO;
|
||||
import com.cloud.network.ovs.dao.OvsWorkDao;
|
||||
import com.cloud.network.ovs.dao.OvsWorkVO.Step;
|
||||
import com.cloud.network.ovs.dao.VlanMappingDao;
|
||||
import com.cloud.network.ovs.dao.VlanMappingVO;
|
||||
import com.cloud.utils.component.Inject;
|
||||
|
||||
public class OvsListener implements Listener {
|
||||
public static final Logger s_logger = Logger.getLogger(OvsListener.class.getName());
|
||||
OvsNetworkManager _ovsNetworkMgr;
|
||||
OvsWorkDao _workDao;
|
||||
GreTunnelDao _tunnelDao;
|
||||
VlanMappingDao _mappingDao;
|
||||
HostDao _hostDao;
|
||||
|
||||
public OvsListener(OvsNetworkManager ovsMgr, OvsWorkDao workDao, GreTunnelDao tunnelDao) {
|
||||
public OvsListener(OvsNetworkManager ovsMgr, OvsWorkDao workDao, GreTunnelDao tunnelDao,
|
||||
VlanMappingDao mappingDao, HostDao hostDao) {
|
||||
this._ovsNetworkMgr = ovsMgr;
|
||||
this._workDao = workDao;
|
||||
this._tunnelDao = tunnelDao;
|
||||
this._mappingDao = mappingDao;
|
||||
this._hostDao = hostDao;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -111,6 +124,48 @@ public class OvsListener implements Listener {
|
||||
@Override
|
||||
public void processConnect(HostVO host, StartupCommand cmd)
|
||||
throws ConnectionException {
|
||||
if (host.getType() != Host.Type.Routing) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<VlanMappingVO> maps = _mappingDao.listByHostId(host.getId());
|
||||
if (maps.size() == 0) {
|
||||
for (int i=0; i<512; i++) {
|
||||
VlanMappingVO vo = new VlanMappingVO(0, host.getId(), i);
|
||||
_mappingDao.persist(vo);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
List<HostVO> hosts = _hostDao.listByType(Host.Type.Routing);
|
||||
for (HostVO h : hosts) {
|
||||
if (h.getId() == host.getId()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
GreTunnelVO t = _tunnelDao.getByFromAndTo(host.getId(), h.getId());
|
||||
if (t == null) {
|
||||
t = new GreTunnelVO(host.getId(), h.getId());
|
||||
try {
|
||||
_tunnelDao.persist(t);
|
||||
} catch (EntityExistsException e) {
|
||||
s_logger.debug(String.format("Already has (from=%1$s, to=%2$s)", host.getId(), h.getId()));
|
||||
}
|
||||
}
|
||||
|
||||
t = _tunnelDao.getByFromAndTo(h.getId(), host.getId());
|
||||
if (t == null) {
|
||||
t = new GreTunnelVO(h.getId(), host.getId());
|
||||
try {
|
||||
_tunnelDao.persist(t);
|
||||
} catch (EntityExistsException e) {
|
||||
s_logger.debug(String.format("Already has (from=%1$s, to=%2$s)", h.getId(), host.getId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -12,6 +12,7 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.ejb.Local;
|
||||
import javax.naming.ConfigurationException;
|
||||
import javax.persistence.EntityExistsException;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
@ -44,10 +45,10 @@ import com.cloud.utils.concurrency.NamedThreadFactory;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.vm.DomainRouterVO;
|
||||
import com.cloud.vm.VirtualMachine.State;
|
||||
import com.cloud.vm.UserVmVO;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.VirtualMachine.State;
|
||||
import com.cloud.vm.VirtualMachineProfile;
|
||||
import com.cloud.vm.dao.DomainRouterDao;
|
||||
import com.cloud.vm.dao.NicDao;
|
||||
@ -108,20 +109,13 @@ public class OvsNetworkManagerImpl implements OvsNetworkManager {
|
||||
public boolean configure(String name, Map<String, Object> params)
|
||||
throws ConfigurationException {
|
||||
_name = name;
|
||||
_isEnabled = _configDao.getValue(Config.OvsNetwork.key()).equalsIgnoreCase("true") ? true : false;
|
||||
_isEnabled = Boolean.parseBoolean(_configDao.getValue(Config.OvsNetwork.key()));
|
||||
_serverId = ((ManagementServer)ComponentLocator.getComponent(ManagementServer.Name)).getId();
|
||||
_executorPool = Executors.newScheduledThreadPool(10, new NamedThreadFactory("OVS"));
|
||||
_cleanupExecutor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("OVS-Cleanup"));
|
||||
_ovsListener = new OvsListener(this, _workDao, _tunnelDao);
|
||||
_ovsListener = new OvsListener(this, _workDao, _tunnelDao, _vlanMappingDao, _hostDao);
|
||||
_agentMgr.registerForHostEvents(_ovsListener, true, true, true);
|
||||
|
||||
//FIXME:
|
||||
GreTunnelVO t = _tunnelDao.lockRow(new Long(1), true);
|
||||
if (t == null) {
|
||||
t = new GreTunnelVO(0, 0);
|
||||
_tunnelDao.persist(t);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -249,14 +243,13 @@ public class OvsNetworkManagerImpl implements OvsNetworkManager {
|
||||
|
||||
}
|
||||
|
||||
//TODO: think about lock
|
||||
@DB
|
||||
protected long askVlanId(long accountId, long hostId) {
|
||||
protected long askVlanId(long accountId, long hostId) throws OvsVlanExhaustedException {
|
||||
assert _isEnabled : "Who call me ??? while OvsNetwokr is not enabled!!!";
|
||||
final Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
|
||||
VlanMappingVO currVlan = _vlanMappingDao.findByAccountIdAndHostId(accountId, hostId);
|
||||
VlanMappingVO currVlan = _vlanMappingDao.lockByAccountIdAndHostId(accountId, hostId);
|
||||
long vlan = 0;
|
||||
|
||||
if (currVlan != null) {
|
||||
@ -270,31 +263,35 @@ public class OvsNetworkManagerImpl implements OvsNetworkManager {
|
||||
}
|
||||
|
||||
List<VlanMappingVO>mappings = _vlanMappingDao.listByHostId(hostId);
|
||||
if (mappings.size() > 0) {
|
||||
ArrayList<Long> vlans = new ArrayList<Long>();
|
||||
for (VlanMappingVO vo : mappings) {
|
||||
vlans.add(new Long(vo.getVlan()));
|
||||
}
|
||||
|
||||
// Find first available vlan
|
||||
int i;
|
||||
for (i=0; i<4096; i++) {
|
||||
if (!vlans.contains(new Long(i))) {
|
||||
vlan = i;
|
||||
assert mappings.size() > 0: "where is my data!? it should be added when host connected!";
|
||||
|
||||
VlanMappingVO target = null;
|
||||
for (VlanMappingVO vo : mappings) {
|
||||
if (vo.getAccountId() == 0) {
|
||||
target = _vlanMappingDao.lockRow(vo.getId(), true);
|
||||
if (target == null || target.getAccountId() != 0) {
|
||||
s_logger.debug("Someone took vlan mapping host = "
|
||||
+ vo.getHostId() + " vlan = " + vo.getVlan());
|
||||
continue;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
assert i!=4096 : "Terrible, vlan exhausted on this server!!!";
|
||||
}
|
||||
|
||||
VlanMappingVO newVlan = new VlanMappingVO(accountId, hostId, vlan);
|
||||
_vlanMappingDao.persist(newVlan);
|
||||
if (target == null) {
|
||||
throw new OvsVlanExhaustedException("vlan exhausted on host " + hostId);
|
||||
}
|
||||
|
||||
target.setAccountId(accountId);
|
||||
target.ref();
|
||||
_vlanMappingDao.update(target.getId(), target);
|
||||
_vlanMappingDirtyDao.markDirty(accountId);
|
||||
String s = String.format("allocate a new vlan %1$s(account:%2$s, hostId:%3$s), mark dirty",
|
||||
vlan, accountId, hostId);
|
||||
s_logger.debug("OVSDIRTY:" + s);
|
||||
txn.commit();
|
||||
return vlan;
|
||||
return target.getVlan();
|
||||
}
|
||||
|
||||
@DB
|
||||
@ -309,49 +306,51 @@ public class OvsNetworkManagerImpl implements OvsNetworkManager {
|
||||
return;
|
||||
}
|
||||
|
||||
final Transaction txn = Transaction.currentTxn();
|
||||
long hostId = dest.getHost().getId();
|
||||
long accountId = instance.getAccountId();
|
||||
|
||||
final Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
//TODO: considerate router?
|
||||
List<UserVmVO>vms = _userVmDao.listByAccountId(accountId);
|
||||
DomainRouterVO router = _routerDao.findBy(accountId, instance.getDataCenterId());
|
||||
List<VMInstanceVO>ins = new ArrayList<VMInstanceVO>();
|
||||
ins.addAll(vms);
|
||||
ins.add(router);
|
||||
List<Long>toHostIds = new ArrayList<Long>();
|
||||
List<Long>fromHostIds = new ArrayList<Long>();
|
||||
GreTunnelVO tvo = _tunnelDao.acquireInLockTable(new Long(1));
|
||||
if (tvo == null) {
|
||||
throw new GreTunnelException("can't lock gre tunnel table for: from=" + hostId);
|
||||
}
|
||||
|
||||
for (UserVmVO v : vms) {
|
||||
for (VMInstanceVO v : ins) {
|
||||
Long rh = v.getHostId();
|
||||
if (rh == null || rh.longValue() == hostId) {
|
||||
continue;
|
||||
}
|
||||
|
||||
GreTunnelVO tunnel = _tunnelDao.getByFromAndTo(hostId, rh.longValue());
|
||||
txn.start();
|
||||
GreTunnelVO tunnel = _tunnelDao.lockByFromAndTo(hostId,
|
||||
rh.longValue());
|
||||
txn.commit();
|
||||
if (tunnel == null) {
|
||||
tunnel = new GreTunnelVO(hostId, rh.longValue());
|
||||
_tunnelDao.persist(tunnel);
|
||||
|
||||
if (!toHostIds.contains(rh)) {
|
||||
toHostIds.add(rh);
|
||||
}
|
||||
throw new GreTunnelException(String.format(
|
||||
"No entity(from=%1$s, to=%2$s) of failed to lock",
|
||||
hostId, rh.longValue()));
|
||||
}
|
||||
|
||||
if (tunnel.getInPort() == 0 && !toHostIds.contains(rh)) {
|
||||
toHostIds.add(rh);
|
||||
}
|
||||
|
||||
tunnel = _tunnelDao.getByFromAndTo(rh.longValue(), hostId);
|
||||
txn.start();
|
||||
tunnel = _tunnelDao.lockByFromAndTo(rh.longValue(), hostId);
|
||||
txn.commit();
|
||||
if (tunnel == null) {
|
||||
tunnel = new GreTunnelVO(rh.longValue(), hostId);
|
||||
_tunnelDao.persist(tunnel);
|
||||
|
||||
if (!fromHostIds.contains(rh)) {
|
||||
fromHostIds.add(rh);
|
||||
}
|
||||
}
|
||||
|
||||
throw new GreTunnelException(String.format(
|
||||
"No entity(from=%1$s, to=%2$s) of failed to lock",
|
||||
rh.longValue(), hostId));
|
||||
}
|
||||
|
||||
if (tunnel.getInPort() == 0 && !fromHostIds.contains(rh)) {
|
||||
fromHostIds.add(rh);
|
||||
}
|
||||
}
|
||||
_tunnelDao.releaseFromLockTable(new Long(1));
|
||||
txn.commit();
|
||||
|
||||
try {
|
||||
String myIp = dest.getHost().getPrivateIpAddress();
|
||||
@ -381,11 +380,9 @@ public class OvsNetworkManagerImpl implements OvsNetworkManager {
|
||||
if (tunnels.size() == 0) {
|
||||
return "[]";
|
||||
} else {
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
List<String> maps = new ArrayList<String>();
|
||||
for (GreTunnelVO t : tunnels) {
|
||||
VlanMappingVO m = _vlanMappingDao.lockByAccountIdAndHostId(accountId, t.getTo());
|
||||
VlanMappingVO m = _vlanMappingDao.findByAccountIdAndHostId(accountId, t.getTo());
|
||||
if (m == null) {
|
||||
s_logger.debug("Host " + t.getTo() + " has no VM for account " + accountId + ", skip it");
|
||||
continue;
|
||||
@ -393,7 +390,7 @@ public class OvsNetworkManagerImpl implements OvsNetworkManager {
|
||||
String s = String.format("%1$s:%2$s", m.getVlan(), t.getInPort());
|
||||
maps.add(s);
|
||||
}
|
||||
txn.commit();
|
||||
|
||||
return maps.toString();
|
||||
}
|
||||
}
|
||||
@ -409,17 +406,21 @@ public class OvsNetworkManagerImpl implements OvsNetworkManager {
|
||||
&& vmType != VirtualMachine.Type.DomainRouter) {
|
||||
return;
|
||||
}
|
||||
|
||||
long hostId = instance.getHostId();
|
||||
long accountId = instance.getAccountId();
|
||||
String tag = Long.toString(askVlanId(accountId, hostId));
|
||||
CheckAndUpdateDhcpFlow(instance);
|
||||
String vlans = getVlanInPortMapping(accountId, hostId);
|
||||
|
||||
VmFlowLogVO log = _flowLogDao.findOrNewByVmId(instance.getId(),
|
||||
instance.getName());
|
||||
cmds.addCommand(new OvsSetTagAndFlowCommand(instance.getName(), tag,
|
||||
vlans, Long.toString(log.getLogsequence()), instance.getId()));
|
||||
try {
|
||||
long hostId = instance.getHostId();
|
||||
long accountId = instance.getAccountId();
|
||||
String tag = Long.toString(askVlanId(accountId, hostId));
|
||||
CheckAndUpdateDhcpFlow(instance);
|
||||
String vlans = getVlanInPortMapping(accountId, hostId);
|
||||
VmFlowLogVO log = _flowLogDao.findOrNewByVmId(instance.getId(),
|
||||
instance.getName());
|
||||
cmds.addCommand(new OvsSetTagAndFlowCommand(instance.getName(),
|
||||
tag, vlans, Long.toString(log.getLogsequence()), instance
|
||||
.getId()));
|
||||
} catch (OvsVlanExhaustedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
//FIXME: if router has record in database but not start, this will hang 10 secs due to host
|
||||
@ -444,9 +445,8 @@ public class OvsNetworkManagerImpl implements OvsNetworkManager {
|
||||
}
|
||||
|
||||
try {
|
||||
String tag = Long.toString(_vlanMappingDao.findByAccountIdAndHostId(accountId,
|
||||
router.getHostId()).getVlan());
|
||||
long hostId = router.getHostId();
|
||||
String tag = Long.toString(_vlanMappingDao.findByAccountIdAndHostId(accountId, hostId).getVlan());
|
||||
VmFlowLogVO log = _flowLogDao.findOrNewByVmId(instance.getId(), instance.getName());
|
||||
String vlans = getVlanInPortMapping(accountId, hostId);
|
||||
s_logger.debug("ask router " + router.getName() + " on host "
|
||||
@ -470,8 +470,9 @@ public class OvsNetworkManagerImpl implements OvsNetworkManager {
|
||||
return;
|
||||
}
|
||||
|
||||
if (delayMs == null)
|
||||
delayMs = new Long(100l);
|
||||
if (delayMs == null) {
|
||||
delayMs = new Long(100l);
|
||||
}
|
||||
|
||||
for (Long vmId: affectedVms) {
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
@ -550,7 +551,6 @@ public class OvsNetworkManagerImpl implements OvsNetworkManager {
|
||||
s_logger.debug("OVSDIRTY:Clean dirty for account " + instance.getAccountId());
|
||||
}
|
||||
|
||||
//TODO: think about lock
|
||||
@DB
|
||||
protected void checkAndRemove(VMInstanceVO instance) {
|
||||
long accountId = instance.getAccountId();
|
||||
@ -558,20 +558,20 @@ public class OvsNetworkManagerImpl implements OvsNetworkManager {
|
||||
|
||||
final Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
VlanMappingVO vo = _vlanMappingDao.findByAccountIdAndHostId(accountId, hostId);
|
||||
VlanMappingVO vo = _vlanMappingDao.lockByAccountIdAndHostId(accountId, hostId);
|
||||
assert vo!=null: "Why there is no record for account " + accountId + " host " + hostId;
|
||||
if (vo.unref() == 0) {
|
||||
_vlanMappingDao.remove(vo.getId());
|
||||
vo.setAccountId(0);
|
||||
_vlanMappingDirtyDao.markDirty(accountId);
|
||||
String s = String.format("%1$s is the last VM(host:%2$s, accountId:%3$s), remove vlan",
|
||||
instance.getName(), hostId, accountId);
|
||||
s_logger.debug("OVSDIRTY:" + s);
|
||||
} else {
|
||||
_vlanMappingDao.update(vo.getId(), vo);
|
||||
s_logger.debug(instance.getName()
|
||||
+ " reduces reference count of (account,host) = ("
|
||||
+ accountId + "," + hostId + ") to " + vo.getRef());
|
||||
}
|
||||
_vlanMappingDao.update(vo.getId(), vo);
|
||||
_flowLogDao.deleteByVmId(instance.getId());
|
||||
txn.commit();
|
||||
|
||||
@ -613,14 +613,14 @@ public class OvsNetworkManagerImpl implements OvsNetworkManager {
|
||||
@Override
|
||||
public void UserVmCheckAndCreateTunnel(Commands cmds,
|
||||
VirtualMachineProfile<UserVmVO> profile, DeployDestination dest) throws GreTunnelException {
|
||||
CheckAndCreateTunnel((VMInstanceVO)profile.getVirtualMachine(), dest);
|
||||
CheckAndCreateTunnel(profile.getVirtualMachine(), dest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void RouterCheckAndCreateTunnel(Commands cmds,
|
||||
VirtualMachineProfile<DomainRouterVO> profile,
|
||||
DeployDestination dest) throws GreTunnelException {
|
||||
CheckAndCreateTunnel((VMInstanceVO)profile.getVirtualMachine(), dest);
|
||||
CheckAndCreateTunnel(profile.getVirtualMachine(), dest);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -0,0 +1,7 @@
|
||||
package com.cloud.network.ovs;
|
||||
|
||||
public class OvsVlanExhaustedException extends Exception {
|
||||
public OvsVlanExhaustedException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
}
|
||||
@ -7,4 +7,5 @@ import com.cloud.utils.db.GenericDao;
|
||||
public interface GreTunnelDao extends GenericDao<GreTunnelVO, Long> {
|
||||
List<GreTunnelVO> getByFrom(long from);
|
||||
GreTunnelVO getByFromAndTo(long from, long To);
|
||||
GreTunnelVO lockByFromAndTo(long from, long to);
|
||||
}
|
||||
|
||||
@ -40,5 +40,13 @@ public class GreTunnelDaoImpl extends GenericDaoBase<GreTunnelVO, Long>
|
||||
sc.setParameters("to", to);
|
||||
return findOneBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GreTunnelVO lockByFromAndTo(long from, long to) {
|
||||
SearchCriteria<GreTunnelVO> sc = fromToSearch.create();
|
||||
sc.setParameters("from", from);
|
||||
sc.setParameters("to", to);
|
||||
return lockOneRandomRow(sc, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -6,9 +6,14 @@ import com.cloud.utils.db.GenericDao;
|
||||
|
||||
public interface VlanMappingDao extends GenericDao<VlanMappingVO, Long> {
|
||||
List<VlanMappingVO> listByAccountIdAndHostId(long accountId, long hostId);
|
||||
|
||||
List<VlanMappingVO> listByHostId(long hostId);
|
||||
|
||||
List<VlanMappingVO> listByAccountId(long accountId);
|
||||
|
||||
List<VlanMappingVO> lockByAccountId(long accoutnId);
|
||||
|
||||
VlanMappingVO findByAccountIdAndHostId(long accountId, long hostId);
|
||||
|
||||
VlanMappingVO lockByAccountIdAndHostId(long accountId, long hostId);
|
||||
}
|
||||
|
||||
@ -31,7 +31,7 @@ public class VlanMappingVO {
|
||||
this.hostId = hostId;
|
||||
this.accountId = accountId;
|
||||
this.vlan = vlan;
|
||||
this.ref = 1;
|
||||
this.ref = 0;
|
||||
}
|
||||
|
||||
public VlanMappingVO() {
|
||||
@ -45,6 +45,10 @@ public class VlanMappingVO {
|
||||
public long getAccountId() {
|
||||
return accountId;
|
||||
}
|
||||
|
||||
public void setAccountId(long accountId) {
|
||||
this.accountId = accountId;
|
||||
}
|
||||
|
||||
public long getVlan() {
|
||||
return vlan;
|
||||
|
||||
@ -313,7 +313,6 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
||||
private int _networkRate;
|
||||
private int _multicastRate;
|
||||
String _networkDomain;
|
||||
boolean _noDefaultRouteForDirectNetwork;
|
||||
|
||||
private VMTemplateVO _template;
|
||||
|
||||
@ -349,51 +348,12 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Attempting to destroy router " + routerId);
|
||||
}
|
||||
|
||||
DomainRouterVO router = _routerDao.acquireInLockTable(routerId);
|
||||
|
||||
|
||||
DomainRouterVO router = _routerDao.findById(routerId);
|
||||
if (router == null) {
|
||||
s_logger.debug("Unable to acquire lock on router " + routerId);
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
if (router.getState() == State.Destroyed || router.getState() == State.Expunging || router.getRemoved() != null) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Unable to find router or router is destroyed: " + routerId);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (stopRouterInternal(router.getId())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
router = _routerDao.findById(routerId);
|
||||
if (!_itMgr.stateTransitTo(router, VirtualMachine.Event.DestroyRequested, router.getHostId())) {
|
||||
s_logger.debug("VM " + router.toString() + " is not in a state to be destroyed.");
|
||||
return false;
|
||||
}
|
||||
} finally {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Release lock on router " + routerId + " for stop");
|
||||
}
|
||||
_routerDao.releaseFromLockTable(routerId);
|
||||
}
|
||||
|
||||
router.setPublicIpAddress(null);
|
||||
router.setVlanDbId(null);
|
||||
_routerDao.update(router.getId(), router);
|
||||
_routerDao.remove(router.getId());
|
||||
|
||||
List<VolumeVO> vols = _volsDao.findByInstance(routerId);
|
||||
_storageMgr.destroy(router, vols);
|
||||
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Successfully destroyed router: " + routerId);
|
||||
}
|
||||
|
||||
return true;
|
||||
return _itMgr.expunge(router, _accountMgr.getSystemUser(), _accountMgr.getSystemAccount());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -700,8 +660,6 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
||||
}
|
||||
|
||||
_systemAcct = _accountService.getSystemAccount();
|
||||
|
||||
_noDefaultRouteForDirectNetwork = Boolean.parseBoolean(configs.get(Config.DirectNetworkNoDefaultRoute.key()));
|
||||
|
||||
s_logger.info("DomainRouterManager is configured.");
|
||||
|
||||
@ -1038,11 +996,11 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
||||
|
||||
List<NetworkOfferingVO> offerings = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemControlNetwork);
|
||||
NetworkOfferingVO controlOffering = offerings.get(0);
|
||||
NetworkVO controlConfig = _networkMgr.setupNetwork(_systemAcct, controlOffering, plan, null, null, false).get(0);
|
||||
NetworkVO controlConfig = _networkMgr.setupNetwork(_systemAcct, controlOffering, plan, null, null, false, false).get(0);
|
||||
|
||||
List<Pair<NetworkVO, NicProfile>> networks = new ArrayList<Pair<NetworkVO, NicProfile>>(3);
|
||||
NetworkOfferingVO publicOffering = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemPublicNetwork).get(0);
|
||||
List<NetworkVO> publicConfigs = _networkMgr.setupNetwork(_systemAcct, publicOffering, plan, null, null, false);
|
||||
List<NetworkVO> publicConfigs = _networkMgr.setupNetwork(_systemAcct, publicOffering, plan, null, null, false, false);
|
||||
NicProfile defaultNic = new NicProfile();
|
||||
defaultNic.setDefaultNic(true);
|
||||
defaultNic.setIp4Address(sourceNatIp.getAddress().addr());
|
||||
@ -1050,13 +1008,9 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
||||
defaultNic.setNetmask(sourceNatIp.getNetmask());
|
||||
defaultNic.setTrafficType(TrafficType.Public);
|
||||
defaultNic.setMacAddress(sourceNatIp.getMacAddress());
|
||||
if (sourceNatIp.getVlanTag().equals(Vlan.UNTAGGED)) {
|
||||
defaultNic.setBroadcastType(BroadcastDomainType.Native);
|
||||
} else {
|
||||
defaultNic.setBroadcastType(BroadcastDomainType.Vlan);
|
||||
defaultNic.setBroadcastUri(BroadcastDomainType.Vlan.toUri(sourceNatIp.getVlanTag()));
|
||||
defaultNic.setIsolationUri(IsolationType.Vlan.toUri(sourceNatIp.getVlanTag()));
|
||||
}
|
||||
defaultNic.setBroadcastType(BroadcastDomainType.Vlan);
|
||||
defaultNic.setBroadcastUri(BroadcastDomainType.Vlan.toUri(sourceNatIp.getVlanTag()));
|
||||
defaultNic.setIsolationUri(IsolationType.Vlan.toUri(sourceNatIp.getVlanTag()));
|
||||
defaultNic.setDeviceId(2);
|
||||
networks.add(new Pair<NetworkVO, NicProfile>(publicConfigs.get(0), defaultNic));
|
||||
NicProfile gatewayNic = new NicProfile();
|
||||
@ -1072,7 +1026,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
||||
networks.add(new Pair<NetworkVO, NicProfile>(controlConfig, null));
|
||||
|
||||
router = new DomainRouterVO(id, _offering.getId(), VirtualMachineName.getRouterName(id, _instance), _template.getId(),
|
||||
_template.getGuestOSId(), owner.getDomainId(), owner.getId(), guestNetwork.getId(), _offering.getOfferHA());
|
||||
_template.getHypervisorType(), _template.getGuestOSId(), owner.getDomainId(), owner.getId(), guestNetwork.getId(), _offering.getOfferHA());
|
||||
router = _itMgr.allocate(router, _template, _offering, networks, plan, null, owner);
|
||||
if(router != null){
|
||||
EventUtils.saveEvent(User.UID_SYSTEM, owner.getAccountId(), EventVO.LEVEL_INFO, EventTypes.EVENT_ROUTER_CREATE, "successfully create router : " + router.getName(), startEventId);
|
||||
@ -1080,10 +1034,23 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
||||
EventUtils.saveEvent(User.UID_SYSTEM, owner.getAccountId(), EventVO.LEVEL_ERROR, EventTypes.EVENT_ROUTER_CREATE, "router creation failed", startEventId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
State state = router.getState();
|
||||
|
||||
if ( state == State.Starting ) {
|
||||
// wait 300 seconds
|
||||
for ( int i = 0; i < 300; ) {
|
||||
try {
|
||||
Thread.sleep(2);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
i += 2;
|
||||
state = router.getState();
|
||||
if ( state != State.Starting ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (state != State.Starting && state != State.Running) {
|
||||
long startEventId = EventUtils.saveStartedEvent(User.UID_SYSTEM, owner.getId(), EventTypes.EVENT_ROUTER_START, "Starting router : " +router.getName());
|
||||
router = this.start(router, _accountService.getSystemUser(), _accountService.getSystemAccount());
|
||||
@ -1093,7 +1060,11 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
||||
EventUtils.saveEvent(User.UID_SYSTEM, owner.getAccountId(), EventVO.LEVEL_ERROR, EventTypes.EVENT_ROUTER_START, "failed to start router", startEventId);
|
||||
}
|
||||
}
|
||||
return router;
|
||||
state = router.getState();
|
||||
if ( state == State.Running ) {
|
||||
return router;
|
||||
}
|
||||
throw new CloudRuntimeException(router.getName() + " is not running , it is in " + state);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1128,7 +1099,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
||||
|
||||
List<NetworkOfferingVO> offerings = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemControlNetwork);
|
||||
NetworkOfferingVO controlOffering = offerings.get(0);
|
||||
NetworkVO controlConfig = _networkMgr.setupNetwork(_systemAcct, controlOffering, plan, null, null, false).get(0);
|
||||
NetworkVO controlConfig = _networkMgr.setupNetwork(_systemAcct, controlOffering, plan, null, null, false, false).get(0);
|
||||
|
||||
List<Pair<NetworkVO, NicProfile>> networks = new ArrayList<Pair<NetworkVO, NicProfile>>(3);
|
||||
NicProfile gatewayNic = new NicProfile();
|
||||
@ -1137,7 +1108,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
||||
networks.add(new Pair<NetworkVO, NicProfile>(controlConfig, null));
|
||||
|
||||
router = new DomainRouterVO(id, _offering.getId(), VirtualMachineName.getRouterName(id, _instance), _template.getId(),
|
||||
_template.getGuestOSId(), owner.getDomainId(), owner.getId(), guestNetwork.getId(), _offering.getOfferHA());
|
||||
_template.getHypervisorType(), _template.getGuestOSId(), owner.getDomainId(), owner.getId(), guestNetwork.getId(), _offering.getOfferHA());
|
||||
router.setRole(Role.DHCP_USERDATA);
|
||||
router = _itMgr.allocate(router, _template, _offering, networks, plan, null, owner);
|
||||
if(router != null){
|
||||
@ -1227,7 +1198,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
||||
buf.append(" domain=" + router.getDomain());
|
||||
}
|
||||
|
||||
if (_noDefaultRouteForDirectNetwork && network.getGuestType() == GuestIpType.Direct) {
|
||||
if (!network.isDefault() && network.getGuestType() == GuestIpType.Direct) {
|
||||
buf.append(" defaultroute=false");
|
||||
} else {
|
||||
buf.append(" defaultroute=true");
|
||||
@ -1443,7 +1414,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
||||
private DomainRouterVO start(DomainRouterVO router, User user, Account caller) throws StorageUnavailableException, InsufficientCapacityException,
|
||||
ConcurrentOperationException, ResourceUnavailableException {
|
||||
s_logger.debug("Starting router " + router);
|
||||
if (_itMgr.start(router, null, user, caller, null) != null) {
|
||||
if (_itMgr.start(router, null, user, caller) != null) {
|
||||
return _routerDao.findById(router.getId());
|
||||
} else {
|
||||
return null;
|
||||
|
||||
@ -613,21 +613,21 @@ public class SecurityGroupManagerImpl implements SecurityGroupManager, SecurityG
|
||||
return null;
|
||||
}
|
||||
}
|
||||
IngressRuleVO ingressRule = _ingressRuleDao.findByProtoPortsAndAllowedGroupId(securityGroup.getId(), protocol, startPort, endPort, ngVO.getId());
|
||||
IngressRuleVO ingressRule = _ingressRuleDao.findByProtoPortsAndAllowedGroupId(securityGroup.getId(), protocol, startPortOrType, endPortOrCode, ngVO.getId());
|
||||
if (ingressRule != null) {
|
||||
continue; //rule already exists.
|
||||
}
|
||||
ingressRule = new IngressRuleVO(securityGroup.getId(), startPort, endPort, protocol, ngVO.getId(), ngVO.getName(), ngVO.getAccountName());
|
||||
ingressRule = new IngressRuleVO(securityGroup.getId(), startPortOrType, endPortOrCode, protocol, ngVO.getId(), ngVO.getName(), ngVO.getAccountName());
|
||||
ingressRule = _ingressRuleDao.persist(ingressRule);
|
||||
newRules.add(ingressRule);
|
||||
}
|
||||
if(cidrList != null) {
|
||||
for (String cidr: cidrList) {
|
||||
IngressRuleVO ingressRule = _ingressRuleDao.findByProtoPortsAndCidr(securityGroup.getId(),protocol, startPort, endPort, cidr);
|
||||
IngressRuleVO ingressRule = _ingressRuleDao.findByProtoPortsAndCidr(securityGroup.getId(),protocol, startPortOrType, endPortOrCode, cidr);
|
||||
if (ingressRule != null) {
|
||||
continue;
|
||||
}
|
||||
ingressRule = new IngressRuleVO(securityGroup.getId(), startPort, endPort, protocol, cidr);
|
||||
ingressRule = new IngressRuleVO(securityGroup.getId(), startPortOrType, endPortOrCode, protocol, cidr);
|
||||
ingressRule = _ingressRuleDao.persist(ingressRule);
|
||||
newRules.add(ingressRule);
|
||||
}
|
||||
|
||||
@ -752,7 +752,8 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
||||
|
||||
BroadcastDomainType broadcastDomainType = null;
|
||||
TrafficType trafficType= offering.getTrafficType();
|
||||
|
||||
|
||||
boolean isNetworkDefault = false;
|
||||
if (trafficType == TrafficType.Management || trafficType == TrafficType.Storage) {
|
||||
broadcastDomainType = BroadcastDomainType.Native;
|
||||
} else if (trafficType == TrafficType.Control) {
|
||||
@ -765,6 +766,7 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
||||
}
|
||||
} else if (offering.getTrafficType() == TrafficType.Guest) {
|
||||
if (zone.getNetworkType() == NetworkType.Basic) {
|
||||
isNetworkDefault = true;
|
||||
broadcastDomainType = BroadcastDomainType.Native;
|
||||
} else {
|
||||
continue;
|
||||
@ -772,7 +774,7 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
||||
}
|
||||
|
||||
if (broadcastDomainType != null) {
|
||||
NetworkVO network = new NetworkVO(id, trafficType, null, mode, broadcastDomainType, networkOfferingId, zoneId, domainId, accountId, related, null, null, true);
|
||||
NetworkVO network = new NetworkVO(id, trafficType, null, mode, broadcastDomainType, networkOfferingId, zoneId, domainId, accountId, related, null, null, true, isNetworkDefault);
|
||||
network.setGuruName(guruNames.get(network.getTrafficType()));
|
||||
network.setDns1(zone.getDns1());
|
||||
network.setDns2(zone.getDns2());
|
||||
|
||||
@ -81,14 +81,6 @@ public interface StorageManager extends Manager {
|
||||
*/
|
||||
List<VolumeVO> unshare(VMInstanceVO vm, HostVO host);
|
||||
|
||||
/**
|
||||
* destroy the storage volumes of a certain vm.
|
||||
*
|
||||
* @param vm vm to destroy.
|
||||
* @param vols volumes to remove from storage pool
|
||||
*/
|
||||
void destroy(VMInstanceVO vm, List<VolumeVO> vols);
|
||||
|
||||
/**
|
||||
* Creates volumes for a particular VM.
|
||||
* @param account account to create volumes for.
|
||||
@ -205,7 +197,7 @@ public interface StorageManager extends Manager {
|
||||
* Marks the specified volume as destroyed in the management server database. The expunge thread will delete the volume from its storage pool.
|
||||
* @param volume
|
||||
*/
|
||||
void destroyVolume(VolumeVO volume);
|
||||
void destroyVolume(VolumeVO volume) throws ConcurrentOperationException;
|
||||
|
||||
/** Create capacity entries in the op capacity table
|
||||
* @param storagePool
|
||||
@ -282,5 +274,5 @@ public interface StorageManager extends Manager {
|
||||
|
||||
void release(VirtualMachineProfile<? extends VMInstanceVO> profile);
|
||||
|
||||
void cleanupVolumes(Long vmId);
|
||||
void cleanupVolumes(long vmId) throws ConcurrentOperationException;
|
||||
}
|
||||
|
||||
@ -114,7 +114,6 @@ import com.cloud.host.dao.DetailsDao;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.VirtualNetworkApplianceService;
|
||||
import com.cloud.network.router.VirtualNetworkApplianceManager;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
@ -141,7 +140,6 @@ import com.cloud.storage.snapshot.SnapshotScheduler;
|
||||
import com.cloud.template.TemplateManager;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.AccountManager;
|
||||
import com.cloud.user.User;
|
||||
import com.cloud.user.UserContext;
|
||||
import com.cloud.user.dao.AccountDao;
|
||||
import com.cloud.user.dao.UserDao;
|
||||
@ -874,7 +872,11 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
||||
s_logger.debug(e.getMessage());
|
||||
}
|
||||
if (rootCreated != null) {
|
||||
destroyVolume(rootCreated);
|
||||
try {
|
||||
destroyVolume(rootCreated);
|
||||
} catch (Exception e1) {
|
||||
s_logger.warn("Unable to mark a volume as destroyed: " + rootCreated, e1);
|
||||
}
|
||||
}
|
||||
throw new CloudRuntimeException("Unable to create volumes for " + vm, e);
|
||||
}
|
||||
@ -953,55 +955,6 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy(VMInstanceVO vm, List<VolumeVO> vols) {
|
||||
if (s_logger.isDebugEnabled() && vm != null) {
|
||||
s_logger.debug("Destroying volumes of " + vm.toString());
|
||||
}
|
||||
|
||||
for (VolumeVO vol : vols) {
|
||||
_volsDao.detachVolume(vol.getId());
|
||||
_volsDao.destroyVolume(vol.getId());
|
||||
|
||||
// First delete the entries in the snapshot_policy and
|
||||
// snapshot_schedule table for the volume.
|
||||
// They should not get executed after the volume is destroyed.
|
||||
_snapshotMgr.deletePoliciesForVolume(vol.getId());
|
||||
|
||||
String volumePath = vol.getPath();
|
||||
Long poolId = vol.getPoolId();
|
||||
if (poolId != null && volumePath != null && !volumePath.trim().isEmpty()) {
|
||||
Answer answer = null;
|
||||
StoragePoolVO pool = _storagePoolDao.findById(poolId);
|
||||
String vmName = null;
|
||||
if (vm != null) {
|
||||
vmName = vm.getInstanceName();
|
||||
}
|
||||
final DestroyCommand cmd = new DestroyCommand(pool, vol, vmName);
|
||||
boolean removed = false;
|
||||
List<StoragePoolHostVO> poolhosts = _storagePoolHostDao.listByPoolId(poolId);
|
||||
for (StoragePoolHostVO poolhost : poolhosts) {
|
||||
answer = _agentMgr.easySend(poolhost.getHostId(), cmd);
|
||||
if (answer != null && answer.getResult()) {
|
||||
removed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (removed) {
|
||||
_volsDao.remove(vol.getId());
|
||||
} else {
|
||||
_alertMgr.sendAlert(AlertManager.ALERT_TYPE_STORAGE_MISC, vol.getDataCenterId(), vol.getPodId(),
|
||||
"Storage cleanup required for storage pool: " + pool.getName(), "Volume folder: " + vol.getFolder() + ", Volume Path: " + vol.getPath() + ", Volume id: " +vol.getId()+ ", Volume Name: " +vol.getName()+ ", Storage PoolId: " +vol.getPoolId());
|
||||
s_logger.warn("destroy volume " + vol.getFolder() + " : " + vol.getPath() + " failed for Volume id : " +vol.getId()+ " Volume Name: " +vol.getName()+ " Storage PoolId : " +vol.getPoolId());
|
||||
}
|
||||
} else {
|
||||
_volsDao.remove(vol.getId());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
||||
_name = name;
|
||||
@ -1597,13 +1550,13 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
||||
String destPrimaryStorageVolumePath = cvAnswer.getVolumePath();
|
||||
String destPrimaryStorageVolumeFolder = cvAnswer.getVolumeFolder();
|
||||
|
||||
// Delete the volume on the source storage pool
|
||||
final DestroyCommand cmd = new DestroyCommand(srcPool, volume, null);
|
||||
Answer destroyAnswer = _agentMgr.easySend(sourceHostId, cmd);
|
||||
|
||||
if (destroyAnswer == null || !destroyAnswer.getResult()) {
|
||||
throw new CloudRuntimeException("Failed to delete the volume from the source primary storage pool.");
|
||||
try {
|
||||
destroyVolume(volume);
|
||||
} catch (ConcurrentOperationException e) {
|
||||
s_logger.warn("Concurrent Operation", e);
|
||||
}
|
||||
|
||||
expungeVolume(volume);
|
||||
|
||||
volume.setPath(destPrimaryStorageVolumePath);
|
||||
volume.setFolder(destPrimaryStorageVolumeFolder);
|
||||
@ -1849,16 +1802,14 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
||||
|
||||
@Override
|
||||
@DB
|
||||
public void destroyVolume(VolumeVO volume) {
|
||||
public void destroyVolume(VolumeVO volume) throws ConcurrentOperationException {
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
|
||||
Long volumeId = volume.getId();
|
||||
_volsDao.destroyVolume(volumeId);
|
||||
|
||||
_volsDao.update(volume, Volume.Event.Destroy);
|
||||
long volumeId = volume.getId();
|
||||
|
||||
EventUtils.saveEvent(User.UID_SYSTEM, volume.getAccountId(), EventTypes.EVENT_VOLUME_DELETE, "Volume " +volume.getName()+ " deleted");
|
||||
|
||||
UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_VOLUME_DELETE, volume.getAccountId(), volume.getDataCenterId(), volume.getId(), volume.getName(), null, null , null);
|
||||
UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_VOLUME_DELETE, volume.getAccountId(), volume.getDataCenterId(), volumeId, volume.getName(), null, null , null);
|
||||
_usageEventDao.persist(usageEvent);
|
||||
|
||||
// Delete the recurring snapshot policies for this volume.
|
||||
@ -1994,24 +1945,6 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
||||
return answer;
|
||||
}
|
||||
|
||||
protected class StorageGarbageCollector implements Runnable {
|
||||
|
||||
public StorageGarbageCollector() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
s_logger.info("Storage Garbage Collection Thread is running.");
|
||||
|
||||
cleanupStorage(true);
|
||||
|
||||
} catch (Exception e) {
|
||||
s_logger.error("Caught the following Exception", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cleanupStorage(boolean recurring) {
|
||||
GlobalLock scanLock = GlobalLock.getInternLock(this.getClass().getName());
|
||||
@ -2083,19 +2016,10 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
||||
}
|
||||
}
|
||||
|
||||
List<VolumeVO> vols = _volsDao.listRemovedButNotDestroyed();
|
||||
List<VolumeVO> vols = _volsDao.listVolumesToBeDestroyed();
|
||||
for (VolumeVO vol : vols) {
|
||||
try {
|
||||
Long poolId = vol.getPoolId();
|
||||
Answer answer = null;
|
||||
StoragePoolVO pool = _storagePoolDao.findById(poolId);
|
||||
final DestroyCommand cmd = new DestroyCommand(pool, vol, null);
|
||||
answer = sendToPool(pool, cmd);
|
||||
if (answer != null && answer.getResult()) {
|
||||
s_logger.debug("Destroyed " + vol);
|
||||
vol.setDestroyed(true);
|
||||
_volsDao.update(vol.getId(), vol);
|
||||
}
|
||||
expungeVolume(vol);
|
||||
} catch (Exception e) {
|
||||
s_logger.warn("Unable to destroy " + vol.getId(), e);
|
||||
}
|
||||
@ -2188,7 +2112,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
||||
}
|
||||
|
||||
//shut down the running vms
|
||||
if(vmInstance.getState().equals(State.Running) || vmInstance.getState().equals(State.Starting))
|
||||
if(vmInstance.getState().equals(State.Running) || vmInstance.getState().equals(State.Starting) || vmInstance.getState().equals(State.Stopping))
|
||||
{
|
||||
|
||||
//if the instance is of type consoleproxy, call the console proxy
|
||||
@ -2470,7 +2394,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteVolume(DeleteVolumeCmd cmd) throws InvalidParameterValueException {
|
||||
public boolean deleteVolume(DeleteVolumeCmd cmd) throws ConcurrentOperationException {
|
||||
Account account = UserContext.current().getCaller();
|
||||
Long volumeId = cmd.getId();
|
||||
|
||||
@ -2513,20 +2437,13 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
||||
}
|
||||
|
||||
// Check that the volume is not already destroyed
|
||||
if (volume.getDestroyed()) {
|
||||
throw new InvalidParameterValueException("Please specify a volume that is not already destroyed.");
|
||||
if (volume.getState() != Volume.State.Destroy) {
|
||||
destroyVolume(volume);
|
||||
}
|
||||
|
||||
try {
|
||||
// Destroy the volume
|
||||
destroyVolume(volume);
|
||||
} catch (Exception e) {
|
||||
s_logger.warn("Error destroying volume:"+e);
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Error destroying volume:"+e);
|
||||
}
|
||||
expungeVolume(volume);
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
private boolean validateVolumeSizeRange(long size) throws InvalidParameterValueException {
|
||||
@ -2652,6 +2569,12 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
||||
for (VolumeVO vol : vols) {
|
||||
Volume.State state = vol.getState();
|
||||
if (state == Volume.State.Ready) {
|
||||
|
||||
if(vol.getPoolId() == null) {
|
||||
s_logger.warn("Found volume:"+vol.getId()+" with no storage pool associated with it");
|
||||
throw new StorageUnavailableException("Volume " + vol + " has no storage pool associated with it, and the pool id associated with it is:", vol.getPoolId());
|
||||
}
|
||||
|
||||
StoragePoolVO pool = _storagePoolDao.findById(vol.getPoolId());
|
||||
if (pool.getRemoved() != null || pool.isInMaintenance()) {
|
||||
if (vol.isRecreatable()) {
|
||||
@ -2794,41 +2717,92 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
||||
//add code here
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cleanupVolumes(Long vmId) {
|
||||
VMInstanceVO vm = _vmInstanceDao.findById(vmId);
|
||||
List<VolumeVO> volumesForVm = _volsDao.findByInstance(vmId);
|
||||
for(VolumeVO vol : volumesForVm){
|
||||
if(vol.getVolumeType().equals(VolumeType.ROOT)){
|
||||
if(vol.getState() != Volume.State.Destroyed) {
|
||||
assert(vol.getState() == Volume.State.Destroy);
|
||||
String volumePath = vol.getPath();
|
||||
Long poolId = vol.getPoolId();
|
||||
if (poolId != null && volumePath != null && !volumePath.trim().isEmpty()) {
|
||||
Answer answer = null;
|
||||
StoragePoolVO pool = _storagePoolDao.findById(poolId);
|
||||
|
||||
final DestroyCommand cmd = new DestroyCommand(pool, vol, vm.getName());
|
||||
List<StoragePoolHostVO> poolhosts = _storagePoolHostDao.listByPoolId(poolId);
|
||||
for (StoragePoolHostVO poolhost : poolhosts) {
|
||||
answer = _agentMgr.easySend(poolhost.getHostId(), cmd);
|
||||
if (answer != null && answer.getResult()) {
|
||||
try {
|
||||
_volsDao.update(vol, Volume.Event.OperationSucceeded);
|
||||
} catch (ConcurrentOperationException e) {
|
||||
s_logger.warn("Unable to update volume state. vm: " + vmId + ", vol: " + vol.getId() + " due to ConcurrentOperationException");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
destroyVolume(vol);
|
||||
public void expungeVolume(VolumeVO vol) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Expunging " + vol);
|
||||
}
|
||||
String vmName = null;
|
||||
if (vol.getVolumeType() == VolumeType.ROOT && vol.getInstanceId() != null) {
|
||||
VirtualMachine vm = _vmInstanceDao.findByIdIncludingRemoved(vol.getInstanceId());
|
||||
if (vm != null) {
|
||||
vmName = vm.getInstanceName();
|
||||
}
|
||||
}
|
||||
|
||||
String volumePath = vol.getPath();
|
||||
Long poolId = vol.getPoolId();
|
||||
if (poolId == null || volumePath == null || volumePath.trim().isEmpty()) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Marking volume that was never created as destroyed: " + vol);
|
||||
}
|
||||
_volsDao.remove(vol.getId());
|
||||
return;
|
||||
}
|
||||
|
||||
StoragePoolVO pool = _storagePoolDao.findById(poolId);
|
||||
if (pool == null) {
|
||||
s_logger.debug("Removing volume as storage pool is gone: " + poolId);
|
||||
_volsDao.remove(vol.getId());
|
||||
return;
|
||||
}
|
||||
|
||||
DestroyCommand cmd = new DestroyCommand(pool, vol, vmName);
|
||||
Answer answer = this.sendToPool(pool, cmd);
|
||||
|
||||
if (answer != null && answer.getResult()) {
|
||||
_volsDao.remove(vol.getId());
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Volume successfully expunged from " + poolId);
|
||||
}
|
||||
} else {
|
||||
s_logger.info("Will retry delete of " + vol + " from " + poolId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override @DB
|
||||
public void cleanupVolumes(long vmId) throws ConcurrentOperationException {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Cleaning storage for vm: " + vmId);
|
||||
}
|
||||
List<VolumeVO> volumesForVm = _volsDao.findByInstance(vmId);
|
||||
List<VolumeVO> toBeExpunged = new ArrayList<VolumeVO>();
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
for (VolumeVO vol : volumesForVm) {
|
||||
if (vol.getVolumeType().equals(VolumeType.ROOT)) {
|
||||
destroyVolume(vol);
|
||||
toBeExpunged.add(vol);
|
||||
} else {
|
||||
//data volume
|
||||
_volsDao.detachVolume(vol.getId());
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Detaching " + vol);
|
||||
}
|
||||
_volsDao.detachVolume(vol.getId());
|
||||
}
|
||||
}
|
||||
txn.commit();
|
||||
|
||||
for (VolumeVO expunge : toBeExpunged) {
|
||||
expungeVolume(expunge);
|
||||
}
|
||||
}
|
||||
|
||||
protected class StorageGarbageCollector implements Runnable {
|
||||
|
||||
public StorageGarbageCollector() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
s_logger.trace("Storage Garbage Collection Thread is running.");
|
||||
|
||||
cleanupStorage(true);
|
||||
|
||||
} catch (Exception e) {
|
||||
s_logger.error("Caught the following Exception", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -36,14 +36,10 @@ public interface VolumeDao extends GenericDao<VolumeVO, Long> {
|
||||
List<VolumeVO> findByDetachedDestroyed();
|
||||
List<VolumeVO> findByAccountAndPod(long accountId, long podId);
|
||||
List<VolumeVO> findByTemplateAndZone(long templateId, long zoneId);
|
||||
List<Long> findVMInstancesByStorageHost(long hostId, Volume.MirrorState mState);
|
||||
List<VolumeVO> findStrandedMirrorVolumes();
|
||||
List<Long> findVmsStoredOnHost(long hostId);
|
||||
void deleteVolumesByInstance(long instanceId);
|
||||
void attachVolume(long volumeId, long vmId, long deviceId);
|
||||
void detachVolume(long volumeId);
|
||||
void destroyVolume(long volumeId);
|
||||
void recoverVolume(long volumeId);
|
||||
boolean isAnyVolumeActivelyUsingTemplateOnPool(long templateId, long poolId);
|
||||
List<VolumeVO> listRemovedButNotDestroyed();
|
||||
List<VolumeVO> findCreatedByInstance(long id);
|
||||
@ -59,4 +55,6 @@ public interface VolumeDao extends GenericDao<VolumeVO, Long> {
|
||||
*/
|
||||
boolean update(VolumeVO vol, Volume.Event event) throws ConcurrentOperationException;
|
||||
HypervisorType getHypervisorType(long volumeId);
|
||||
|
||||
List<VolumeVO> listVolumesToBeDestroyed();
|
||||
}
|
||||
|
||||
@ -32,8 +32,6 @@ import com.cloud.async.AsyncInstanceCreateStatus;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.storage.Volume;
|
||||
import com.cloud.storage.Volume.Event;
|
||||
import com.cloud.storage.Volume.MirrorState;
|
||||
import com.cloud.storage.Volume.VolumeType;
|
||||
import com.cloud.storage.VolumeVO;
|
||||
import com.cloud.utils.Pair;
|
||||
@ -53,22 +51,14 @@ import com.cloud.utils.exception.CloudRuntimeException;
|
||||
public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements VolumeDao {
|
||||
private static final Logger s_logger = Logger.getLogger(VolumeDaoImpl.class);
|
||||
protected final SearchBuilder<VolumeVO> DetachedAccountIdSearch;
|
||||
protected final SearchBuilder<VolumeVO> AccountIdSearch;
|
||||
protected final SearchBuilder<VolumeVO> AccountPodSearch;
|
||||
protected final SearchBuilder<VolumeVO> TemplateZoneSearch;
|
||||
protected final GenericSearchBuilder<VolumeVO, SumCount> TotalSizeByPoolSearch;
|
||||
protected final SearchBuilder<VolumeVO> InstanceIdSearch;
|
||||
protected final SearchBuilder<VolumeVO> InstanceAndTypeSearch;
|
||||
protected final SearchBuilder<VolumeVO> InstanceIdDestroyedSearch;
|
||||
protected final SearchBuilder<VolumeVO> InstanceIdCreatedSearch;
|
||||
protected final SearchBuilder<VolumeVO> DetachedDestroyedSearch;
|
||||
protected final SearchBuilder<VolumeVO> MirrorSearch;
|
||||
protected final GenericSearchBuilder<VolumeVO, Long> ActiveTemplateSearch;
|
||||
protected final SearchBuilder<VolumeVO> RemovedButNotDestroyedSearch;
|
||||
protected final SearchBuilder<VolumeVO> PoolIdSearch;
|
||||
protected final SearchBuilder<VolumeVO> InstanceAndDeviceIdSearch;
|
||||
protected final SearchBuilder<VolumeVO> InstanceStatesSearch;
|
||||
protected final SearchBuilder<VolumeVO> IdStateSearch;
|
||||
|
||||
protected final SearchBuilder<VolumeVO> AllFieldsSearch;
|
||||
|
||||
protected final Attribute _stateAttr;
|
||||
|
||||
@ -116,7 +106,7 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol
|
||||
|
||||
@Override
|
||||
public List<VolumeVO> findByAccount(long accountId) {
|
||||
SearchCriteria<VolumeVO> sc = AccountIdSearch.create();
|
||||
SearchCriteria<VolumeVO> sc = AllFieldsSearch.create();
|
||||
sc.setParameters("accountId", accountId);
|
||||
sc.setParameters("destroyed", false);
|
||||
return listBy(sc);
|
||||
@ -124,14 +114,14 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol
|
||||
|
||||
@Override
|
||||
public List<VolumeVO> findByInstance(long id) {
|
||||
SearchCriteria<VolumeVO> sc = InstanceIdSearch.create();
|
||||
SearchCriteria<VolumeVO> sc = AllFieldsSearch.create();
|
||||
sc.setParameters("instanceId", id);
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<VolumeVO> findByInstanceAndDeviceId(long instanceId, long deviceId){
|
||||
SearchCriteria<VolumeVO> sc = InstanceAndDeviceIdSearch.create();
|
||||
SearchCriteria<VolumeVO> sc = AllFieldsSearch.create();
|
||||
sc.setParameters("instanceId", instanceId);
|
||||
sc.setParameters("deviceId", deviceId);
|
||||
return listBy(sc);
|
||||
@ -139,14 +129,14 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol
|
||||
|
||||
@Override
|
||||
public List<VolumeVO> findByPoolId(long poolId) {
|
||||
SearchCriteria<VolumeVO> sc = PoolIdSearch.create();
|
||||
SearchCriteria<VolumeVO> sc = AllFieldsSearch.create();
|
||||
sc.setParameters("poolId", poolId);
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<VolumeVO> findCreatedByInstance(long id) {
|
||||
SearchCriteria<VolumeVO> sc = InstanceIdCreatedSearch.create();
|
||||
SearchCriteria<VolumeVO> sc = AllFieldsSearch.create();
|
||||
sc.setParameters("instanceId", id);
|
||||
sc.setParameters("status", AsyncInstanceCreateStatus.Created);
|
||||
sc.setParameters("destroyed", false);
|
||||
@ -164,7 +154,7 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol
|
||||
|
||||
@Override
|
||||
public List<VolumeVO> findByInstanceAndType(long id, VolumeType vType) {
|
||||
SearchCriteria<VolumeVO> sc = InstanceAndTypeSearch.create();
|
||||
SearchCriteria<VolumeVO> sc = AllFieldsSearch.create();
|
||||
sc.setParameters("instanceId", id);
|
||||
sc.setParameters("vType", vType.toString());
|
||||
return listBy(sc);
|
||||
@ -172,7 +162,7 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol
|
||||
|
||||
@Override
|
||||
public List<VolumeVO> findByInstanceIdDestroyed(long vmId) {
|
||||
SearchCriteria<VolumeVO> sc = InstanceIdDestroyedSearch.create();
|
||||
SearchCriteria<VolumeVO> sc = AllFieldsSearch.create();
|
||||
sc.setParameters("instanceId", vmId);
|
||||
sc.setParameters("destroyed", true);
|
||||
return listIncludingRemovedBy(sc);
|
||||
@ -187,8 +177,8 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol
|
||||
|
||||
@Override
|
||||
public List<VolumeVO> findByAccountAndPod(long accountId, long podId) {
|
||||
SearchCriteria<VolumeVO> sc = AccountPodSearch.create();
|
||||
sc.setParameters("account", accountId);
|
||||
SearchCriteria<VolumeVO> sc = AllFieldsSearch.create();
|
||||
sc.setParameters("accountId", accountId);
|
||||
sc.setParameters("pod", podId);
|
||||
sc.setParameters("destroyed", false);
|
||||
sc.setParameters("status", AsyncInstanceCreateStatus.Created);
|
||||
@ -205,38 +195,6 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol
|
||||
return listIncludingRemovedBy(sc);
|
||||
}
|
||||
|
||||
@Override @DB
|
||||
public List<Long> findVMInstancesByStorageHost(long hostId, Volume.MirrorState mirrState) {
|
||||
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
PreparedStatement pstmt = null;
|
||||
List<Long> result = new ArrayList<Long>();
|
||||
|
||||
try {
|
||||
String sql = SELECT_VM_SQL;
|
||||
pstmt = txn.prepareAutoCloseStatement(sql);
|
||||
pstmt.setLong(1, hostId);
|
||||
pstmt.setString(2, mirrState.toString());
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
while (rs.next()) {
|
||||
result.add(rs.getLong(1));
|
||||
}
|
||||
return result;
|
||||
} catch (SQLException e) {
|
||||
throw new CloudRuntimeException("DB Exception on: " + SELECT_VM_SQL, e);
|
||||
} catch (Throwable e) {
|
||||
throw new CloudRuntimeException("Caught: " + SELECT_VM_SQL, e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<VolumeVO> findStrandedMirrorVolumes() {
|
||||
SearchCriteria<VolumeVO> sc = MirrorSearch.create();
|
||||
sc.setParameters("mirrorState", MirrorState.ACTIVE.toString());
|
||||
|
||||
return listIncludingRemovedBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAnyVolumeActivelyUsingTemplateOnPool(long templateId, long poolId) {
|
||||
SearchCriteria<Long> sc = ActiveTemplateSearch.create();
|
||||
@ -251,7 +209,7 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol
|
||||
|
||||
@Override
|
||||
public void deleteVolumesByInstance(long instanceId) {
|
||||
SearchCriteria<VolumeVO> sc = InstanceIdSearch.create();
|
||||
SearchCriteria<VolumeVO> sc = AllFieldsSearch.create();
|
||||
sc.setParameters("instanceId", instanceId);
|
||||
expunge(sc);
|
||||
}
|
||||
@ -276,34 +234,6 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol
|
||||
update(volumeId, volume);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroyVolume(long volumeId) {
|
||||
VolumeVO volume = createForUpdate(volumeId);
|
||||
volume.setDestroyed(true);
|
||||
|
||||
Volume.State oldState = volume.getState();
|
||||
Volume.State newState = oldState.getNextState(Event.Destroy);
|
||||
|
||||
assert newState != null : "Event "+ Event.Destroy + " cannot happen from " + oldState;
|
||||
volume.setState(newState);
|
||||
|
||||
update(volumeId, volume);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recoverVolume(long volumeId) {
|
||||
VolumeVO volume = createForUpdate(volumeId);
|
||||
volume.setDestroyed(false);
|
||||
|
||||
Volume.State oldState = volume.getState();
|
||||
Volume.State newState = oldState.getNextState(Event.Recover);
|
||||
|
||||
assert newState != null : "Event "+ Event.Recover + " cannot happen from " + oldState;
|
||||
volume.setState(newState);
|
||||
|
||||
update(volumeId, volume);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(VolumeVO vol, Volume.Event event) throws ConcurrentOperationException {
|
||||
Volume.State oldState = vol.getState();
|
||||
@ -314,7 +244,7 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol
|
||||
UpdateBuilder builder = getUpdateBuilder(vol);
|
||||
builder.set(vol, _stateAttr, newState);
|
||||
|
||||
SearchCriteria<VolumeVO> sc = IdStateSearch.create();
|
||||
SearchCriteria<VolumeVO> sc = AllFieldsSearch.create();
|
||||
sc.setParameters("id", vol.getId());
|
||||
sc.setParameters("state", oldState);
|
||||
|
||||
@ -325,6 +255,8 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol
|
||||
}
|
||||
return rows == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
@DB
|
||||
public HypervisorType getHypervisorType(long volumeId) {
|
||||
/*lookup from cluster of pool*/
|
||||
@ -336,8 +268,9 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol
|
||||
pstmt = txn.prepareAutoCloseStatement(sql);
|
||||
pstmt.setLong(1, volumeId);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
if (rs.next())
|
||||
return HypervisorType.getType(rs.getString(1));
|
||||
if (rs.next()) {
|
||||
return HypervisorType.getType(rs.getString(1));
|
||||
}
|
||||
return HypervisorType.None;
|
||||
} catch (SQLException e) {
|
||||
throw new CloudRuntimeException("DB Exception on: " + SELECT_HYPERTYPE_FROM_VOLUME, e);
|
||||
@ -347,98 +280,59 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol
|
||||
}
|
||||
|
||||
protected VolumeDaoImpl() {
|
||||
AccountIdSearch = createSearchBuilder();
|
||||
AccountIdSearch.and("accountId", AccountIdSearch.entity().getAccountId(), SearchCriteria.Op.EQ);
|
||||
AccountIdSearch.and("destroyed", AccountIdSearch.entity().getDestroyed(), SearchCriteria.Op.EQ);
|
||||
AccountIdSearch.done();
|
||||
AllFieldsSearch = createSearchBuilder();
|
||||
AllFieldsSearch.and("state", AllFieldsSearch.entity().getState(), Op.EQ);
|
||||
AllFieldsSearch.and("destroyed", AllFieldsSearch.entity().getDestroyed(), Op.EQ);
|
||||
AllFieldsSearch.and("accountId", AllFieldsSearch.entity().getAccountId(), Op.EQ);
|
||||
AllFieldsSearch.and("pod", AllFieldsSearch.entity().getPodId(), Op.EQ);
|
||||
AllFieldsSearch.and("status", AllFieldsSearch.entity().getStatus(), Op.EQ);
|
||||
AllFieldsSearch.and("instanceId", AllFieldsSearch.entity().getInstanceId(), Op.EQ);
|
||||
AllFieldsSearch.and("deviceId", AllFieldsSearch.entity().getDeviceId(), Op.EQ);
|
||||
AllFieldsSearch.and("poolId", AllFieldsSearch.entity().getPoolId(), Op.EQ);
|
||||
AllFieldsSearch.and("vType", AllFieldsSearch.entity().getVolumeType(), Op.EQ);
|
||||
AllFieldsSearch.and("id", AllFieldsSearch.entity().getId(), Op.EQ);
|
||||
AllFieldsSearch.done();
|
||||
|
||||
DetachedAccountIdSearch = createSearchBuilder();
|
||||
DetachedAccountIdSearch.and("accountId", DetachedAccountIdSearch.entity().getAccountId(), SearchCriteria.Op.EQ);
|
||||
DetachedAccountIdSearch.and("destroyed", DetachedAccountIdSearch.entity().getDestroyed(), SearchCriteria.Op.EQ);
|
||||
DetachedAccountIdSearch.and("instanceId", DetachedAccountIdSearch.entity().getInstanceId(), SearchCriteria.Op.NULL);
|
||||
DetachedAccountIdSearch.and("accountId", DetachedAccountIdSearch.entity().getAccountId(), Op.EQ);
|
||||
DetachedAccountIdSearch.and("destroyed", DetachedAccountIdSearch.entity().getDestroyed(), Op.EQ);
|
||||
DetachedAccountIdSearch.and("instanceId", DetachedAccountIdSearch.entity().getInstanceId(), Op.NULL);
|
||||
DetachedAccountIdSearch.done();
|
||||
|
||||
AccountPodSearch = createSearchBuilder();
|
||||
AccountPodSearch.and("account", AccountPodSearch.entity().getAccountId(), SearchCriteria.Op.EQ);
|
||||
AccountPodSearch.and("pod", AccountPodSearch.entity().getPodId(), SearchCriteria.Op.EQ);
|
||||
AccountPodSearch.and("destroyed", AccountPodSearch.entity().getDestroyed(), SearchCriteria.Op.EQ);
|
||||
AccountPodSearch.and("status", AccountPodSearch.entity().getStatus(), SearchCriteria.Op.EQ);
|
||||
AccountPodSearch.done();
|
||||
|
||||
TemplateZoneSearch = createSearchBuilder();
|
||||
TemplateZoneSearch.and("template", TemplateZoneSearch.entity().getTemplateId(), SearchCriteria.Op.EQ);
|
||||
TemplateZoneSearch.and("zone", TemplateZoneSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
|
||||
TemplateZoneSearch.and("template", TemplateZoneSearch.entity().getTemplateId(), Op.EQ);
|
||||
TemplateZoneSearch.and("zone", TemplateZoneSearch.entity().getDataCenterId(), Op.EQ);
|
||||
TemplateZoneSearch.done();
|
||||
|
||||
TotalSizeByPoolSearch = createSearchBuilder(SumCount.class);
|
||||
TotalSizeByPoolSearch.select("sum", Func.SUM, TotalSizeByPoolSearch.entity().getSize());
|
||||
TotalSizeByPoolSearch.select("count", Func.COUNT, (Object[])null);
|
||||
TotalSizeByPoolSearch.and("poolId", TotalSizeByPoolSearch.entity().getPoolId(), SearchCriteria.Op.EQ);
|
||||
TotalSizeByPoolSearch.and("removed", TotalSizeByPoolSearch.entity().getRemoved(), SearchCriteria.Op.NULL);
|
||||
TotalSizeByPoolSearch.and("poolId", TotalSizeByPoolSearch.entity().getPoolId(), Op.EQ);
|
||||
TotalSizeByPoolSearch.and("removed", TotalSizeByPoolSearch.entity().getRemoved(), Op.NULL);
|
||||
TotalSizeByPoolSearch.done();
|
||||
|
||||
|
||||
InstanceIdCreatedSearch = createSearchBuilder();
|
||||
InstanceIdCreatedSearch.and("instanceId", InstanceIdCreatedSearch.entity().getInstanceId(), SearchCriteria.Op.EQ);
|
||||
InstanceIdCreatedSearch.and("status", InstanceIdCreatedSearch.entity().getStatus(), SearchCriteria.Op.EQ);
|
||||
InstanceIdCreatedSearch.and("destroyed", InstanceIdCreatedSearch.entity().getDestroyed(), SearchCriteria.Op.EQ);
|
||||
InstanceIdCreatedSearch.done();
|
||||
|
||||
InstanceIdSearch = createSearchBuilder();
|
||||
InstanceIdSearch.and("instanceId", InstanceIdSearch.entity().getInstanceId(), SearchCriteria.Op.EQ);
|
||||
InstanceIdSearch.done();
|
||||
|
||||
InstanceAndDeviceIdSearch = createSearchBuilder();
|
||||
InstanceAndDeviceIdSearch.and("instanceId", InstanceAndDeviceIdSearch.entity().getInstanceId(), SearchCriteria.Op.EQ);
|
||||
InstanceAndDeviceIdSearch.and("deviceId", InstanceAndDeviceIdSearch.entity().getDeviceId(), SearchCriteria.Op.EQ);
|
||||
InstanceAndDeviceIdSearch.done();
|
||||
|
||||
PoolIdSearch = createSearchBuilder();
|
||||
PoolIdSearch.and("poolId", PoolIdSearch.entity().getPoolId(), SearchCriteria.Op.EQ);
|
||||
PoolIdSearch.done();
|
||||
|
||||
InstanceAndTypeSearch= createSearchBuilder();
|
||||
InstanceAndTypeSearch.and("instanceId", InstanceAndTypeSearch.entity().getInstanceId(), SearchCriteria.Op.EQ);
|
||||
InstanceAndTypeSearch.and("vType", InstanceAndTypeSearch.entity().getVolumeType(), SearchCriteria.Op.EQ);
|
||||
InstanceAndTypeSearch.done();
|
||||
|
||||
InstanceIdDestroyedSearch = createSearchBuilder();
|
||||
InstanceIdDestroyedSearch.and("instanceId", InstanceIdDestroyedSearch.entity().getInstanceId(), SearchCriteria.Op.EQ);
|
||||
InstanceIdDestroyedSearch.and("destroyed", InstanceIdDestroyedSearch.entity().getDestroyed(), SearchCriteria.Op.EQ);
|
||||
InstanceIdDestroyedSearch.done();
|
||||
|
||||
DetachedDestroyedSearch = createSearchBuilder();
|
||||
DetachedDestroyedSearch.and("instanceId", DetachedDestroyedSearch.entity().getInstanceId(), SearchCriteria.Op.NULL);
|
||||
DetachedDestroyedSearch.and("destroyed", DetachedDestroyedSearch.entity().getDestroyed(), SearchCriteria.Op.EQ);
|
||||
DetachedDestroyedSearch.and("instanceId", DetachedDestroyedSearch.entity().getInstanceId(), Op.NULL);
|
||||
DetachedDestroyedSearch.and("destroyed", DetachedDestroyedSearch.entity().getDestroyed(), Op.EQ);
|
||||
DetachedDestroyedSearch.done();
|
||||
|
||||
MirrorSearch = createSearchBuilder();
|
||||
MirrorSearch.and("mirrorVolume", MirrorSearch.entity().getMirrorVolume(), Op.NULL);
|
||||
MirrorSearch.and("mirrorState", MirrorSearch.entity().getMirrorState(), Op.EQ);
|
||||
MirrorSearch.done();
|
||||
|
||||
ActiveTemplateSearch = createSearchBuilder(Long.class);
|
||||
ActiveTemplateSearch.and("pool", ActiveTemplateSearch.entity().getPoolId(), SearchCriteria.Op.EQ);
|
||||
ActiveTemplateSearch.and("template", ActiveTemplateSearch.entity().getTemplateId(), SearchCriteria.Op.EQ);
|
||||
ActiveTemplateSearch.and("removed", ActiveTemplateSearch.entity().getRemoved(), SearchCriteria.Op.NULL);
|
||||
ActiveTemplateSearch.and("pool", ActiveTemplateSearch.entity().getPoolId(), Op.EQ);
|
||||
ActiveTemplateSearch.and("template", ActiveTemplateSearch.entity().getTemplateId(), Op.EQ);
|
||||
ActiveTemplateSearch.and("removed", ActiveTemplateSearch.entity().getRemoved(), Op.NULL);
|
||||
ActiveTemplateSearch.select(null, Func.COUNT, null);
|
||||
ActiveTemplateSearch.done();
|
||||
|
||||
RemovedButNotDestroyedSearch = createSearchBuilder();
|
||||
RemovedButNotDestroyedSearch.and("destroyed", RemovedButNotDestroyedSearch.entity().getDestroyed(), SearchCriteria.Op.EQ);
|
||||
RemovedButNotDestroyedSearch.and("removed", RemovedButNotDestroyedSearch.entity().getRemoved(), SearchCriteria.Op.NNULL);
|
||||
RemovedButNotDestroyedSearch.and("destroyed", RemovedButNotDestroyedSearch.entity().getDestroyed(), Op.EQ);
|
||||
RemovedButNotDestroyedSearch.and("removed", RemovedButNotDestroyedSearch.entity().getRemoved(), Op.NNULL);
|
||||
RemovedButNotDestroyedSearch.done();
|
||||
|
||||
InstanceStatesSearch = createSearchBuilder();
|
||||
InstanceStatesSearch.and("instance", InstanceStatesSearch.entity().getInstanceId(), SearchCriteria.Op.EQ);
|
||||
InstanceStatesSearch.and("states", InstanceStatesSearch.entity().getState(), SearchCriteria.Op.IN);
|
||||
InstanceStatesSearch.and("instance", InstanceStatesSearch.entity().getInstanceId(), Op.EQ);
|
||||
InstanceStatesSearch.and("states", InstanceStatesSearch.entity().getState(), Op.IN);
|
||||
InstanceStatesSearch.done();
|
||||
|
||||
IdStateSearch = createSearchBuilder();
|
||||
IdStateSearch.and("id", IdStateSearch.entity().getId(), SearchCriteria.Op.EQ);
|
||||
IdStateSearch.and("state", IdStateSearch.entity().getState(), SearchCriteria.Op.EQ);
|
||||
IdStateSearch.done();
|
||||
|
||||
_stateAttr = _allAttributes.get("state");
|
||||
assert _stateAttr != null : "Couldn't get the state attribute";
|
||||
}
|
||||
@ -458,4 +352,12 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol
|
||||
public SumCount() {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<VolumeVO> listVolumesToBeDestroyed() {
|
||||
SearchCriteria<VolumeVO> sc = AllFieldsSearch.create();
|
||||
sc.setParameters("state", Volume.State.Destroy);
|
||||
|
||||
return listBy(sc);
|
||||
}
|
||||
}
|
||||
|
||||
@ -261,7 +261,7 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
|
||||
SecondaryStorageVmVO secStorageVm = _secStorageVmDao.findById(secStorageVmId);
|
||||
Account systemAcct = _accountMgr.getSystemAccount();
|
||||
User systemUser = _accountMgr.getSystemUser();
|
||||
return _itMgr.start(secStorageVm, null, systemUser, systemAcct, null);
|
||||
return _itMgr.start(secStorageVm, null, systemUser, systemAcct);
|
||||
}
|
||||
|
||||
|
||||
@ -455,15 +455,15 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
|
||||
defaultNic.setDefaultNic(true);
|
||||
defaultNic.setDeviceId(2);
|
||||
try {
|
||||
networks.add(new Pair<NetworkVO, NicProfile>(_networkMgr.setupNetwork(systemAcct, defaultOffering.get(0), plan, null, null, false).get(0), defaultNic));
|
||||
networks.add(new Pair<NetworkVO, NicProfile>(_networkMgr.setupNetwork(systemAcct, defaultOffering.get(0), plan, null, null, false, false).get(0), defaultNic));
|
||||
for (NetworkOfferingVO offering : offerings) {
|
||||
networks.add(new Pair<NetworkVO, NicProfile>(_networkMgr.setupNetwork(systemAcct, offering, plan, null, null, false).get(0), null));
|
||||
networks.add(new Pair<NetworkVO, NicProfile>(_networkMgr.setupNetwork(systemAcct, offering, plan, null, null, false, false).get(0), null));
|
||||
}
|
||||
} catch (ConcurrentOperationException e) {
|
||||
s_logger.info("Unable to setup due to concurrent operation. " + e);
|
||||
return new HashMap<String, Object>();
|
||||
}
|
||||
SecondaryStorageVmVO secStorageVm = new SecondaryStorageVmVO(id, _serviceOffering.getId(), name, _template.getId(),
|
||||
SecondaryStorageVmVO secStorageVm = new SecondaryStorageVmVO(id, _serviceOffering.getId(), name, _template.getId(), _template.getHypervisorType(),
|
||||
_template.getGuestOSId(), dataCenterId, systemAcct.getDomainId(), systemAcct.getId());
|
||||
try {
|
||||
secStorageVm = _itMgr.allocate(secStorageVm, _template, _serviceOffering, networks, plan, null, systemAcct);
|
||||
@ -1109,68 +1109,15 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
|
||||
}
|
||||
|
||||
@Override
|
||||
@DB
|
||||
public boolean destroySecStorageVm(long vmId) {
|
||||
AsyncJobExecutor asyncExecutor = BaseAsyncJobExecutor.getCurrentExecutor();
|
||||
if (asyncExecutor != null) {
|
||||
AsyncJobVO job = asyncExecutor.getJob();
|
||||
|
||||
if (s_logger.isInfoEnabled()) {
|
||||
s_logger.info("Destroy secondary storage vm " + vmId + ", update async job-" + job.getId());
|
||||
}
|
||||
_asyncMgr.updateAsyncJobAttachment(job.getId(), "secstorage_vm", vmId);
|
||||
SecondaryStorageVmVO ssvm = _secStorageVmDao.findById(vmId);
|
||||
|
||||
try {
|
||||
return _itMgr.expunge(ssvm, _accountMgr.getSystemUser(), _accountMgr.getSystemAccount());
|
||||
} catch (ResourceUnavailableException e) {
|
||||
s_logger.warn("Unable to expunge " + ssvm, e);
|
||||
return false;
|
||||
}
|
||||
|
||||
SecondaryStorageVmVO vm = _secStorageVmDao.findById(vmId);
|
||||
if (vm == null || vm.getState() == State.Destroyed) {
|
||||
String msg = "Unable to find vm or vm is destroyed: " + vmId;
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug(msg);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Destroying secondary storage vm vm " + vmId);
|
||||
}
|
||||
|
||||
if (! _itMgr.stateTransitTo(vm, VirtualMachine.Event.DestroyRequested, null)) {
|
||||
String msg = "Unable to destroy the vm because it is not in the correct state: " + vmId;
|
||||
s_logger.debug(msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
List<VolumeVO> vols = null;
|
||||
try {
|
||||
vols = _volsDao.findByInstance(vmId);
|
||||
if (vols.size() != 0) {
|
||||
_storageMgr.destroy(vm, vols);
|
||||
}
|
||||
|
||||
return true;
|
||||
} finally {
|
||||
try {
|
||||
txn.start();
|
||||
// release critical system resources used by the VM before we
|
||||
// delete them
|
||||
if (vm.getPublicIpAddress() != null) {
|
||||
freePublicIpAddress(vm.getPublicIpAddress(), vm.getDataCenterId(), vm.getPodId());
|
||||
}
|
||||
vm.setPublicIpAddress(null);
|
||||
|
||||
_secStorageVmDao.remove(vm.getId());
|
||||
|
||||
txn.commit();
|
||||
} catch (Exception e) {
|
||||
s_logger.error("Caught this error: ", e);
|
||||
txn.rollback();
|
||||
return false;
|
||||
} finally {
|
||||
s_logger.debug("secondary storage vm vm is destroyed : "
|
||||
+ vm.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@DB
|
||||
|
||||
@ -18,7 +18,21 @@
|
||||
package com.cloud.vm;
|
||||
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
import com.cloud.vm.VirtualMachine.State;
|
||||
|
||||
public interface ItWorkDao extends GenericDao<ItWorkVO, String> {
|
||||
|
||||
/**
|
||||
* find a work item based on the instanceId and the state.
|
||||
*
|
||||
* @param instanceId vm instance id
|
||||
* @param state state
|
||||
* @return ItWorkVO if found; null if not.
|
||||
*/
|
||||
ItWorkVO findByInstance(long instanceId, State state);
|
||||
|
||||
/**
|
||||
* cleanup rows that are either Done or Cancelled and been that way
|
||||
* for at least wait time.
|
||||
*/
|
||||
void cleanup(long wait);
|
||||
}
|
||||
|
||||
@ -20,10 +20,55 @@ package com.cloud.vm;
|
||||
import javax.ejb.Local;
|
||||
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.SearchCriteria.Op;
|
||||
import com.cloud.utils.time.InaccurateClock;
|
||||
import com.cloud.vm.ItWorkVO.Step;
|
||||
import com.cloud.vm.VirtualMachine.State;
|
||||
|
||||
@Local(value=ItWorkDao.class)
|
||||
public class ItWorkDaoImpl extends GenericDaoBase<ItWorkVO, String> implements ItWorkDao {
|
||||
protected final SearchBuilder<ItWorkVO> AllFieldsSearch;
|
||||
protected final SearchBuilder<ItWorkVO> CleanupSearch;
|
||||
|
||||
protected ItWorkDaoImpl() {
|
||||
super();
|
||||
|
||||
AllFieldsSearch = createSearchBuilder();
|
||||
AllFieldsSearch.and("instance", AllFieldsSearch.entity().getInstanceId(), Op.EQ);
|
||||
AllFieldsSearch.and("op", AllFieldsSearch.entity().getType(), Op.EQ);
|
||||
AllFieldsSearch.and("step", AllFieldsSearch.entity().getStep(), Op.EQ);
|
||||
AllFieldsSearch.done();
|
||||
|
||||
CleanupSearch = createSearchBuilder();
|
||||
CleanupSearch.and("step", CleanupSearch.entity().getType(), Op.IN);
|
||||
CleanupSearch.and("time", CleanupSearch.entity().getUpdatedAt(), Op.LT);
|
||||
CleanupSearch.done();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItWorkVO findByInstance(long instanceId, State state) {
|
||||
SearchCriteria<ItWorkVO> sc = AllFieldsSearch.create();
|
||||
sc.setParameters("instance", instanceId);
|
||||
sc.setParameters("op", state);
|
||||
|
||||
return findOneBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cleanup(long wait) {
|
||||
SearchCriteria<ItWorkVO> sc = CleanupSearch.create();
|
||||
sc.setParameters("step", Step.Done, Step.Cancelled);
|
||||
sc.setParameters("time", InaccurateClock.getTimeInSeconds() - wait);
|
||||
|
||||
remove(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(String id, ItWorkVO work) {
|
||||
work.setUpdatedAt(InaccurateClock.getTimeInSeconds());
|
||||
|
||||
return super.update(id, work);
|
||||
}
|
||||
}
|
||||
|
||||
@ -17,58 +17,52 @@
|
||||
*/
|
||||
package com.cloud.vm;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
import com.cloud.utils.time.InaccurateClock;
|
||||
import com.cloud.vm.VirtualMachine.State;
|
||||
|
||||
@Entity
|
||||
@Table(name="op_it_work")
|
||||
public class ItWorkVO {
|
||||
enum Type {
|
||||
Start,
|
||||
Cleanup;
|
||||
}
|
||||
|
||||
enum ResourceType {
|
||||
Volume,
|
||||
Nic
|
||||
}
|
||||
|
||||
enum Step {
|
||||
Reserve,
|
||||
Prepare,
|
||||
Start,
|
||||
Started,
|
||||
Cancelled,
|
||||
Done
|
||||
}
|
||||
|
||||
@Id
|
||||
@Column(name="id")
|
||||
String id;
|
||||
|
||||
@Column(name=GenericDao.CREATED_COLUMN)
|
||||
Date created;
|
||||
@Column(name="created_at")
|
||||
long createdAt;
|
||||
|
||||
@Column(name="mgmt_server_id")
|
||||
long managementServerId;
|
||||
|
||||
@Column(name="type")
|
||||
Type type;
|
||||
State type;
|
||||
|
||||
@Column(name="thread")
|
||||
String threadName;
|
||||
|
||||
@Column(name="state")
|
||||
@Column(name="step")
|
||||
Step step;
|
||||
|
||||
@Column(name="cancel_taken")
|
||||
@Temporal(value=TemporalType.TIMESTAMP)
|
||||
Date taken;
|
||||
@Column(name="updated_at")
|
||||
long updatedAt;
|
||||
|
||||
@Column(name="instance_id")
|
||||
long instanceId;
|
||||
@ -103,7 +97,7 @@ public class ItWorkVO {
|
||||
protected ItWorkVO() {
|
||||
}
|
||||
|
||||
protected ItWorkVO(String id, long managementServerId, Type type, long instanceId) {
|
||||
protected ItWorkVO(String id, long managementServerId, State type, long instanceId) {
|
||||
this.id = id;
|
||||
this.managementServerId = managementServerId;
|
||||
this.type = type;
|
||||
@ -111,25 +105,27 @@ public class ItWorkVO {
|
||||
this.step = Step.Prepare;
|
||||
this.instanceId = instanceId;
|
||||
this.resourceType = null;
|
||||
this.createdAt = InaccurateClock.getTimeInSeconds();
|
||||
this.updatedAt = createdAt;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public Date getCreated() {
|
||||
return created;
|
||||
public Long getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
|
||||
public long getManagementServerId() {
|
||||
return managementServerId;
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
public State getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(Type type) {
|
||||
public void setType(State type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@ -141,11 +137,23 @@ public class ItWorkVO {
|
||||
return step;
|
||||
}
|
||||
|
||||
public void setStep(Step state) {
|
||||
this.step = state;
|
||||
public void setStep(Step step) {
|
||||
this.step = step;
|
||||
}
|
||||
|
||||
public Date getTaken() {
|
||||
return taken;
|
||||
public long getUpdatedAt() {
|
||||
return updatedAt;
|
||||
}
|
||||
|
||||
public void setUpdatedAt(long updatedAt) {
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
|
||||
public long getSecondsTaskIsInactive() {
|
||||
return InaccurateClock.getTimeInSeconds() - this.updatedAt;
|
||||
}
|
||||
|
||||
public long getSecondsTaskHasBeenCreated() {
|
||||
return InaccurateClock.getTimeInSeconds() - this.createdAt;
|
||||
}
|
||||
}
|
||||
|
||||
@ -134,7 +134,6 @@ import com.cloud.network.ovs.OvsNetworkManager;
|
||||
import com.cloud.network.router.VirtualNetworkApplianceManager;
|
||||
import com.cloud.network.rules.RulesManager;
|
||||
import com.cloud.network.security.SecurityGroupManager;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
import com.cloud.offerings.dao.NetworkOfferingDao;
|
||||
import com.cloud.server.Criteria;
|
||||
@ -1028,13 +1027,11 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
||||
// Recover the VM's disks
|
||||
List<VolumeVO> volumes = _volsDao.findByInstanceIdDestroyed(vmId);
|
||||
for (VolumeVO volume : volumes) {
|
||||
_volsDao.recoverVolume(volume.getId());
|
||||
// Create an event
|
||||
Long templateId = volume.getTemplateId();
|
||||
Long diskOfferingId = volume.getDiskOfferingId();
|
||||
long sizeMB = volume.getSize()/(1024*1024);
|
||||
StoragePoolVO pool = _storagePoolDao.findById(volume.getPoolId());
|
||||
EventUtils.saveEvent(User.UID_SYSTEM, volume.getAccountId(), EventTypes.EVENT_VOLUME_CREATE, "Created volume: "+ volume.getName() +" with size: " + sizeMB + " MB in pool: " + pool.getName());
|
||||
|
||||
UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_VOLUME_CREATE, volume.getAccountId(), volume.getDataCenterId(), volume.getId(), volume.getName(), diskOfferingId, templateId , sizeMB);
|
||||
_usageEventDao.persist(usageEvent);
|
||||
@ -2234,7 +2231,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
||||
if (dc.getNetworkType() == NetworkType.Basic && networkList == null) {
|
||||
Network defaultNetwork = _networkMgr.getSystemNetworkByZoneAndTrafficType(dc.getId(), TrafficType.Guest);
|
||||
if (defaultNetwork == null) {
|
||||
throw new InvalidParameterValueException("Unable to find a default Direct network to start a vm");
|
||||
throw new InvalidParameterValueException("Unable to find a default network to start a vm");
|
||||
} else {
|
||||
networkList = new ArrayList<Long>();
|
||||
networkList.add(defaultNetwork.getId());
|
||||
@ -2246,6 +2243,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
||||
}
|
||||
|
||||
List<Pair<NetworkVO, NicProfile>> networks = new ArrayList<Pair<NetworkVO, NicProfile>>();
|
||||
short defaultNetworkNumber = 0;
|
||||
for (Long networkId : networkList) {
|
||||
NetworkVO network = _networkDao.findById(networkId);
|
||||
if (network == null) {
|
||||
@ -2258,10 +2256,21 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
||||
throw new PermissionDeniedException("Unable to create a vm using network with id " + networkId + ", permission denied");
|
||||
}
|
||||
}
|
||||
|
||||
if (network.isDefault()) {
|
||||
defaultNetworkNumber++;
|
||||
}
|
||||
networks.add(new Pair<NetworkVO, NicProfile>(network, null));
|
||||
}
|
||||
}
|
||||
|
||||
//at least one network default network has to be set
|
||||
if (defaultNetworkNumber == 0) {
|
||||
throw new InvalidParameterValueException("At least 1 default network has to be specified for the vm");
|
||||
} else if (defaultNetworkNumber >1) {
|
||||
throw new InvalidParameterValueException("Only 1 default network per vm is supported");
|
||||
}
|
||||
|
||||
long id = _vmDao.getNextInSequence(Long.class, "id");
|
||||
|
||||
String hostName = cmd.getName();
|
||||
@ -2280,8 +2289,15 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
||||
}
|
||||
}
|
||||
|
||||
UserVmVO vm = new UserVmVO(id, instanceName, cmd.getDisplayName(),
|
||||
template.getId(), template.getGuestOSId(), offering.getOfferHA(), domainId, owner.getId(), offering.getId(), userData, hostName);
|
||||
HypervisorType hypervisorType = null;
|
||||
if (template == null || template.getHypervisorType() == null || template.getHypervisorType() == HypervisorType.None) {
|
||||
hypervisorType = cmd.getHypervisor();
|
||||
} else {
|
||||
hypervisorType = template.getHypervisorType();
|
||||
}
|
||||
|
||||
UserVmVO vm = new UserVmVO(id, instanceName, cmd.getDisplayName(), template.getId(), hypervisorType,
|
||||
template.getGuestOSId(), offering.getOfferHA(), domainId, owner.getId(), offering.getId(), userData, hostName);
|
||||
|
||||
|
||||
if (_itMgr.allocate(vm, template, offering, rootDiskOffering, dataDiskOfferings, networks, null, plan, cmd.getHypervisor(), owner) == null) {
|
||||
@ -2335,7 +2351,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
||||
AccountVO owner = _accountDao.findById(vm.getAccountId());
|
||||
|
||||
try {
|
||||
vm = _itMgr.start(vm, null, caller, owner, cmd.getHypervisor());
|
||||
vm = _itMgr.start(vm, null, caller, owner);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -2409,6 +2425,9 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
||||
UserVmVO vm = profile.getVirtualMachine();
|
||||
_networkGroupMgr.handleVmStateTransition(vm, State.Running);
|
||||
_ovsNetworkMgr.handleVmStateTransition(vm, State.Running);
|
||||
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 true;
|
||||
}
|
||||
|
||||
@ -2489,9 +2508,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
||||
|
||||
userId = accountAndUserValidation(vmId, account, userId, vm);
|
||||
UserVO user = _userDao.findById(userId);
|
||||
VolumeVO disk = _volsDao.findByInstance(vmId).get(0);
|
||||
HypervisorType hyperType = _volsDao.getHypervisorType(disk.getId());
|
||||
return _itMgr.start(vm, null, user, account, hyperType);
|
||||
return _itMgr.start(vm, null, user, account);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -35,7 +35,6 @@ import com.cloud.user.Account;
|
||||
import com.cloud.user.User;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.component.Manager;
|
||||
import com.cloud.vm.VirtualMachine.Event;
|
||||
|
||||
/**
|
||||
* Manages allocating resources to vms.
|
||||
@ -71,7 +70,7 @@ public interface VirtualMachineManager extends Manager {
|
||||
HypervisorType hyperType,
|
||||
Account owner) throws InsufficientCapacityException;
|
||||
|
||||
<T extends VMInstanceVO> T start(T vm, Map<String, Object> params, User caller, Account account, HypervisorType hyperType) throws InsufficientCapacityException, ResourceUnavailableException;
|
||||
<T extends VMInstanceVO> T start(T vm, Map<String, Object> params, User caller, Account account) throws InsufficientCapacityException, ResourceUnavailableException;
|
||||
|
||||
<T extends VMInstanceVO> boolean stop(T vm, User caller, Account account) throws ResourceUnavailableException;
|
||||
|
||||
@ -79,9 +78,9 @@ public interface VirtualMachineManager extends Manager {
|
||||
|
||||
<T extends VMInstanceVO> void registerGuru(VirtualMachine.Type type, VirtualMachineGuru<T> guru);
|
||||
|
||||
boolean stateTransitTo(VMInstanceVO vm, Event e, Long id);
|
||||
boolean stateTransitTo(VMInstanceVO vm, VirtualMachine.Event e, Long hostId);
|
||||
|
||||
<T extends VMInstanceVO> T advanceStart(T vm, Map<String, Object> params, User caller, Account account, HypervisorType hyperType) throws InsufficientCapacityException, ResourceUnavailableException, ConcurrentOperationException, OperationTimedoutException;
|
||||
<T extends VMInstanceVO> T advanceStart(T vm, Map<String, Object> params, User caller, Account account) throws InsufficientCapacityException, ResourceUnavailableException, ConcurrentOperationException, OperationTimedoutException;
|
||||
|
||||
<T extends VMInstanceVO> boolean advanceStop(T vm, boolean forced, User caller, Account account) throws ResourceUnavailableException, OperationTimedoutException, ConcurrentOperationException;
|
||||
|
||||
|
||||
@ -22,6 +22,9 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.ejb.Local;
|
||||
import javax.naming.ConfigurationException;
|
||||
@ -38,8 +41,6 @@ import com.cloud.agent.api.StopCommand;
|
||||
import com.cloud.agent.api.to.VirtualMachineTO;
|
||||
import com.cloud.agent.manager.Commands;
|
||||
import com.cloud.cluster.ClusterManager;
|
||||
import com.cloud.cluster.ClusterManagerListener;
|
||||
import com.cloud.cluster.ManagementServerHostVO;
|
||||
import com.cloud.configuration.Config;
|
||||
import com.cloud.configuration.dao.ConfigurationDao;
|
||||
import com.cloud.dc.DataCenter;
|
||||
@ -68,25 +69,27 @@ import com.cloud.storage.DiskOfferingVO;
|
||||
import com.cloud.storage.Storage.ImageFormat;
|
||||
import com.cloud.storage.StorageManager;
|
||||
import com.cloud.storage.VMTemplateVO;
|
||||
import com.cloud.storage.Volume;
|
||||
import com.cloud.storage.Volume.VolumeType;
|
||||
import com.cloud.storage.dao.VMTemplateDao;
|
||||
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;
|
||||
import com.cloud.utils.Ternary;
|
||||
import com.cloud.utils.component.Adapters;
|
||||
import com.cloud.utils.component.ComponentLocator;
|
||||
import com.cloud.utils.component.Inject;
|
||||
import com.cloud.utils.concurrency.NamedThreadFactory;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.utils.fsm.StateListener;
|
||||
import com.cloud.utils.fsm.StateMachine2;
|
||||
import com.cloud.vm.ItWorkVO.Type;
|
||||
import com.cloud.vm.ItWorkVO.Step;
|
||||
import com.cloud.vm.VirtualMachine.Event;
|
||||
import com.cloud.vm.VirtualMachine.State;
|
||||
import com.cloud.vm.dao.ConsoleProxyDao;
|
||||
@ -97,39 +100,47 @@ import com.cloud.vm.dao.UserVmDao;
|
||||
import com.cloud.vm.dao.VMInstanceDao;
|
||||
|
||||
@Local(value=VirtualMachineManager.class)
|
||||
public class VirtualMachineManagerImpl implements VirtualMachineManager, ClusterManagerListener {
|
||||
public class VirtualMachineManagerImpl implements VirtualMachineManager {
|
||||
private static final Logger s_logger = Logger.getLogger(VirtualMachineManagerImpl.class);
|
||||
|
||||
String _name;
|
||||
@Inject private StorageManager _storageMgr;
|
||||
@Inject private NetworkManager _networkMgr;
|
||||
@Inject private AgentManager _agentMgr;
|
||||
@Inject private VMInstanceDao _vmDao;
|
||||
@Inject private ServiceOfferingDao _offeringDao;
|
||||
@Inject private VMTemplateDao _templateDao;
|
||||
@Inject private UserDao _userDao;
|
||||
@Inject private AccountDao _accountDao;
|
||||
@Inject private DomainDao _domainDao;
|
||||
@Inject private ClusterManager _clusterMgr;
|
||||
@Inject private ItWorkDao _workDao;
|
||||
@Inject private UserVmDao _userVmDao;
|
||||
@Inject private DomainRouterDao _routerDao;
|
||||
@Inject private ConsoleProxyDao _consoleDao;
|
||||
@Inject private SecondaryStorageVmDao _secondaryDao;
|
||||
@Inject private UsageEventDao _usageEventDao;
|
||||
@Inject private NicDao _nicsDao;
|
||||
@Inject protected StorageManager _storageMgr;
|
||||
@Inject protected NetworkManager _networkMgr;
|
||||
@Inject protected AgentManager _agentMgr;
|
||||
@Inject protected VMInstanceDao _vmDao;
|
||||
@Inject protected ServiceOfferingDao _offeringDao;
|
||||
@Inject protected VMTemplateDao _templateDao;
|
||||
@Inject protected UserDao _userDao;
|
||||
@Inject protected AccountDao _accountDao;
|
||||
@Inject protected DomainDao _domainDao;
|
||||
@Inject protected ClusterManager _clusterMgr;
|
||||
@Inject protected ItWorkDao _workDao;
|
||||
@Inject protected UserVmDao _userVmDao;
|
||||
@Inject protected DomainRouterDao _routerDao;
|
||||
@Inject protected ConsoleProxyDao _consoleDao;
|
||||
@Inject protected SecondaryStorageVmDao _secondaryDao;
|
||||
@Inject protected UsageEventDao _usageEventDao;
|
||||
@Inject protected NicDao _nicsDao;
|
||||
|
||||
@Inject(adapter=DeploymentPlanner.class)
|
||||
private Adapters<DeploymentPlanner> _planners;
|
||||
protected Adapters<DeploymentPlanner> _planners;
|
||||
@Inject(adapter=StateListener.class)
|
||||
private Adapters<StateListener<State, VirtualMachine.Event, VMInstanceVO>> _stateListner;
|
||||
protected Adapters<StateListener<State, VirtualMachine.Event, VMInstanceVO>> _stateListner;
|
||||
|
||||
|
||||
Map<VirtualMachine.Type, VirtualMachineGuru<? extends VMInstanceVO>> _vmGurus = new HashMap<VirtualMachine.Type, VirtualMachineGuru<? extends VMInstanceVO>>();
|
||||
Map<HypervisorType, HypervisorGuru> _hvGurus = new HashMap<HypervisorType, HypervisorGuru>();
|
||||
private StateMachine2<State, VirtualMachine.Event, VMInstanceVO> _stateMachine;
|
||||
protected StateMachine2<State, VirtualMachine.Event, VMInstanceVO> _stateMachine;
|
||||
|
||||
private int _retry;
|
||||
private long _nodeId;
|
||||
ScheduledExecutorService _executor = null;
|
||||
|
||||
protected int _retry;
|
||||
protected long _nodeId;
|
||||
protected long _cleanupWait;
|
||||
protected long _cleanupInterval;
|
||||
protected long _cancelWait;
|
||||
protected long _opWaitInterval;
|
||||
protected int _lockStateRetry;
|
||||
|
||||
@Override
|
||||
public <T extends VMInstanceVO> void registerGuru(VirtualMachine.Type type, VirtualMachineGuru<T> guru) {
|
||||
@ -153,7 +164,7 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Cluster
|
||||
s_logger.debug("Allocating entries for VM: " + vm);
|
||||
}
|
||||
|
||||
VirtualMachineProfileImpl<T> vmProfile = new VirtualMachineProfileImpl<T>(vm, template, serviceOffering, owner, params, hyperType);
|
||||
VirtualMachineProfileImpl<T> vmProfile = new VirtualMachineProfileImpl<T>(vm, template, serviceOffering, owner, params);
|
||||
|
||||
vm.setDataCenterId(plan.getDataCenterId());
|
||||
if (plan.getPodId() != null) {
|
||||
@ -338,6 +349,7 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Cluster
|
||||
|
||||
@Override
|
||||
public boolean start() {
|
||||
_executor.scheduleAtFixedRate(new CleanupTask(), _cleanupInterval, _cleanupInterval, TimeUnit.SECONDS);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -364,8 +376,14 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Cluster
|
||||
_hvGurus.put(guru.getHypervisorType(), guru);
|
||||
}
|
||||
|
||||
_cancelWait = NumbersUtil.parseLong(params.get(Config.VmOpCancelInterval.key()), 3600);
|
||||
_cleanupWait = NumbersUtil.parseLong(params.get(Config.VmOpCleanupWait.key()), 3600);
|
||||
_cleanupInterval = NumbersUtil.parseLong(params.get(Config.VmOpCleanupInterval.key()), 86400) * 1000;
|
||||
_opWaitInterval = NumbersUtil.parseLong(params.get(Config.VmOpWaitInterval.key()), 120) * 1000;
|
||||
_lockStateRetry = NumbersUtil.parseInt(params.get(Config.VmOpLockStateRetry.key()), 5);
|
||||
|
||||
_executor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("Vm-Operations-Cleanup"));
|
||||
_nodeId = _clusterMgr.getId();
|
||||
_clusterMgr.registerListener(this);
|
||||
|
||||
setStateMachine();
|
||||
|
||||
@ -381,9 +399,9 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Cluster
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends VMInstanceVO> T start(T vm, Map<String, Object> params, User caller, Account account, HypervisorType hyperType) throws InsufficientCapacityException, ResourceUnavailableException {
|
||||
public <T extends VMInstanceVO> T start(T vm, Map<String, Object> params, User caller, Account account) throws InsufficientCapacityException, ResourceUnavailableException {
|
||||
try {
|
||||
return advanceStart(vm, params, caller, account, hyperType);
|
||||
return advanceStart(vm, params, caller, account);
|
||||
} catch (ConcurrentOperationException e) {
|
||||
throw new CloudRuntimeException("Unable to start a VM due to concurrent operation", e);
|
||||
}
|
||||
@ -396,144 +414,217 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Cluster
|
||||
}
|
||||
}
|
||||
|
||||
assert 1 == 0 : "Why there is no Start Answer???";
|
||||
assert false : "Why there is no Start Answer???";
|
||||
return null;
|
||||
}
|
||||
|
||||
protected boolean checkWorkItems(VMInstanceVO vm, State state) throws ConcurrentOperationException {
|
||||
while (true) {
|
||||
ItWorkVO vo = _workDao.findByInstance(vm.getId(), state);
|
||||
if (vo == null) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Unable to find work for " + vm);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (vo.getStep() == Step.Done || vo.getStep() == Step.Cancelled) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Work for " + vm + " is " + vo.getStep());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (vo.getSecondsTaskIsInactive() > _cancelWait) {
|
||||
s_logger.warn("The task item for vm " + vm + " has been inactive for " + vo.getSecondsTaskIsInactive());
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
Thread.sleep(_opWaitInterval);
|
||||
} catch (InterruptedException e) {
|
||||
s_logger.info("Waiting for " + vm + " but is interrupted");
|
||||
throw new ConcurrentOperationException("Waiting for " + vm + " but is interrupted");
|
||||
}
|
||||
s_logger.debug("Waiting some more to make sure there's no activity on " + vm);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@DB
|
||||
protected <T extends VMInstanceVO> Ternary<T, ReservationContext, ItWorkVO> changeToStartState(VirtualMachineGuru<T> vmGuru, T vm, User caller, Account account) throws ConcurrentOperationException {
|
||||
long vmId = vm.getId();
|
||||
|
||||
ItWorkVO work = new ItWorkVO(UUID.randomUUID().toString(), _nodeId, State.Starting, vm.getId());
|
||||
int retry = _lockStateRetry;
|
||||
while (retry-- != 0) {
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
if (stateTransitTo(vm, Event.StartRequested, null, work.getId())) {
|
||||
|
||||
Journal journal = new Journal.LogJournal("Creating " + vm, s_logger);
|
||||
work = _workDao.persist(work);
|
||||
ReservationContextImpl context = new ReservationContextImpl(work.getId(), journal, caller, account);
|
||||
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Successfully transitioned to start state for " + vm + " reservation id = " + work.getId());
|
||||
}
|
||||
txn.commit();
|
||||
return new Ternary<T, ReservationContext, ItWorkVO>(vmGuru.findById(vmId), context, work);
|
||||
}
|
||||
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Determining why we're unable to update the state to Starting for " + vm);
|
||||
}
|
||||
|
||||
VMInstanceVO instance = _vmDao.lockRow(vmId, true);
|
||||
if (instance == null) {
|
||||
throw new ConcurrentOperationException("Unable to acquire lock on " + vm);
|
||||
}
|
||||
|
||||
State state = instance.getState();
|
||||
if (state == State.Running) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("VM is already started: " + vm);
|
||||
}
|
||||
txn.commit();
|
||||
return null;
|
||||
}
|
||||
|
||||
if (state.isTransitional()) {
|
||||
if (!checkWorkItems(vm, state)) {
|
||||
throw new ConcurrentOperationException("There are concurrent operations on the VM " + vm);
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (state != State.Stopped) {
|
||||
s_logger.debug("VM " + vm + " is not in a state to be started: " + state);
|
||||
txn.commit();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
throw new ConcurrentOperationException("Unable to change the state of " + vm);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends VMInstanceVO> T advanceStart(T vm, Map<String, Object> params, User caller, Account account, HypervisorType hyperType) throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException {
|
||||
State state = vm.getState();
|
||||
if (state == State.Running) {
|
||||
s_logger.debug("VM is already started: " + vm);
|
||||
return vm;
|
||||
public <T extends VMInstanceVO> T advanceStart(T vm, Map<String, Object> params, User caller, Account account) throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException {
|
||||
long vmId = vm.getId();
|
||||
|
||||
VirtualMachineGuru<T> vmGuru = getVmGuru(vm);
|
||||
|
||||
Ternary<T, ReservationContext, ItWorkVO> start = changeToStartState(vmGuru, vm, caller, account);
|
||||
if (start == null) {
|
||||
return vmGuru.findById(vmId);
|
||||
}
|
||||
|
||||
if (state == State.Starting) {
|
||||
vm = start.first();
|
||||
ReservationContext ctx = start.second();
|
||||
ItWorkVO work = start.third();
|
||||
|
||||
T startedVm = null;
|
||||
|
||||
try {
|
||||
ServiceOfferingVO offering = _offeringDao.findById(vm.getServiceOfferingId());
|
||||
VMTemplateVO template = _templateDao.findById(vm.getTemplateId());
|
||||
|
||||
}
|
||||
|
||||
if (state != State.Stopped) {
|
||||
s_logger.debug("VM " + vm + " is not in a state to be started: " + state);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Creating actual resources for VM " + vm);
|
||||
}
|
||||
|
||||
Journal journal = new Journal.LogJournal("Creating " + vm, s_logger);
|
||||
|
||||
ItWorkVO work = new ItWorkVO(UUID.randomUUID().toString(), _nodeId, ItWorkVO.Type.Start, vm.getId());
|
||||
work = _workDao.persist(work);
|
||||
|
||||
ReservationContextImpl context = new ReservationContextImpl(work.getId(), journal, caller, account);
|
||||
|
||||
ServiceOfferingVO offering = _offeringDao.findById(vm.getServiceOfferingId());
|
||||
VMTemplateVO template = _templateDao.findById(vm.getTemplateId());
|
||||
|
||||
DataCenterDeployment plan = new DataCenterDeployment(vm.getDataCenterId(), vm.getPodId(), null, null);
|
||||
|
||||
HypervisorGuru hvGuru;
|
||||
if (hyperType != null && !hyperType.equals(HypervisorType.None)) {
|
||||
hvGuru = _hvGurus.get(hyperType);
|
||||
} else {
|
||||
hvGuru = _hvGurus.get(template.getHypervisorType());
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
VirtualMachineGuru<T> vmGuru = (VirtualMachineGuru<T>)_vmGurus.get(vm.getType());
|
||||
|
||||
vm.setReservationId(work.getId());
|
||||
|
||||
ExcludeList avoids = new ExcludeList();
|
||||
int retry = _retry;
|
||||
DeployDestination dest = null;
|
||||
while (retry-- != 0) { // It's != so that it can match -1.
|
||||
VirtualMachineProfileImpl<T> vmProfile = new VirtualMachineProfileImpl<T>(vm, template, offering, null, params, hyperType);
|
||||
|
||||
for (DeploymentPlanner planner : _planners) {
|
||||
dest = planner.plan(vmProfile, plan, avoids);
|
||||
if (dest != null) {
|
||||
avoids.addHost(dest.getHost().getId());
|
||||
journal.record("Deployment found ", vmProfile, dest);
|
||||
break;
|
||||
DataCenterDeployment plan = new DataCenterDeployment(vm.getDataCenterId(), vm.getPodId(), null, null);
|
||||
|
||||
HypervisorGuru hvGuru = _hvGurus.get(vm.getHypervisorType());
|
||||
VirtualMachineProfileImpl<T> vmProfile = new VirtualMachineProfileImpl<T>(vm, template, offering, null, params);
|
||||
|
||||
Journal journal = start.second().getJournal();
|
||||
|
||||
ExcludeList avoids = new ExcludeList();
|
||||
int retry = _retry;
|
||||
while (retry-- != 0) { // It's != so that it can match -1.
|
||||
|
||||
DeployDestination dest = null;
|
||||
for (DeploymentPlanner planner : _planners) {
|
||||
dest = planner.plan(vmProfile, plan, avoids);
|
||||
if (dest != null) {
|
||||
avoids.addHost(dest.getHost().getId());
|
||||
journal.record("Deployment found ", vmProfile, dest);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (dest == null) {
|
||||
if (retry != (_retry -1)) {
|
||||
stateTransitTo(vm, Event.OperationFailed, null);
|
||||
}
|
||||
throw new InsufficientServerCapacityException("Unable to create a deployment for " + vmProfile, DataCenter.class, plan.getDataCenterId());
|
||||
}
|
||||
|
||||
if (retry == (_retry -1)) {
|
||||
if (!stateTransitTo(vm, Event.StartRequested, dest.getHost().getId())) {
|
||||
throw new ConcurrentOperationException("Unable to start vm " + vm + " due to concurrent operations");
|
||||
}
|
||||
} else {
|
||||
|
||||
if (dest == null) {
|
||||
throw new InsufficientServerCapacityException("Unable to create a deployment for " + vmProfile, DataCenter.class, plan.getDataCenterId());
|
||||
}
|
||||
|
||||
stateTransitTo(vm, Event.OperationRetry, dest.getHost().getId());
|
||||
}
|
||||
|
||||
vm.setDataCenterId(dest.getDataCenter().getId());
|
||||
vm.setPodId(dest.getPod().getId());
|
||||
|
||||
try {
|
||||
_storageMgr.prepare(vmProfile, dest);
|
||||
_networkMgr.prepare(vmProfile, dest, context);
|
||||
} catch (ConcurrentOperationException e) {
|
||||
stateTransitTo(vm, Event.OperationFailed, null);
|
||||
throw e;
|
||||
} catch (ResourceUnavailableException e) {
|
||||
s_logger.warn("Unable to contact storage.", e);
|
||||
avoids.addCluster(dest.getCluster().getId());
|
||||
continue;
|
||||
} catch (InsufficientCapacityException e) {
|
||||
s_logger.warn("Insufficient capacity ", e);
|
||||
avoids.add(e);
|
||||
continue;
|
||||
} catch (RuntimeException e) {
|
||||
s_logger.warn("Failed to start instance " + vm, e);
|
||||
stateTransitTo(vm, Event.OperationFailed, null);
|
||||
return null;
|
||||
}
|
||||
|
||||
vmGuru.finalizeVirtualMachineProfile(vmProfile, dest, context);
|
||||
|
||||
VirtualMachineTO vmTO = hvGuru.implement(vmProfile);
|
||||
|
||||
Commands cmds = new Commands(OnError.Revert);
|
||||
cmds.addCommand(new StartCommand(vmTO));
|
||||
|
||||
vmGuru.finalizeDeployment(cmds, vmProfile, dest, context);
|
||||
try {
|
||||
Answer[] answers = _agentMgr.send(dest.getHost().getId(), cmds);
|
||||
if (getStartAnswer(answers).getResult() && vmGuru.finalizeStart(cmds, vmProfile, dest, context)) {
|
||||
if (!stateTransitTo(vm, Event.OperationSucceeded, dest.getHost().getId())) {
|
||||
throw new CloudRuntimeException("Unable to transition to a new state.");
|
||||
|
||||
try {
|
||||
_storageMgr.prepare(vmProfile, dest);
|
||||
_networkMgr.prepare(vmProfile, dest, ctx);
|
||||
} catch (ResourceUnavailableException e) {
|
||||
if (!avoids.add(e)) {
|
||||
if (e.getScope() == Volume.class || e.getScope() == Nic.class) {
|
||||
throw e;
|
||||
} else {
|
||||
throw new CloudRuntimeException("Resource is not available to start the VM.", e);
|
||||
}
|
||||
}
|
||||
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);
|
||||
s_logger.info("Unable to contact resource.", e);
|
||||
continue;
|
||||
} catch (InsufficientCapacityException e) {
|
||||
if (!avoids.add(e)) {
|
||||
if (e.getScope() == Volume.class || e.getScope() == Nic.class) {
|
||||
throw e;
|
||||
} else {
|
||||
throw new CloudRuntimeException("Insufficient capacity to start the VM.", e);
|
||||
}
|
||||
}
|
||||
return vm;
|
||||
s_logger.info("Insufficient capacity ", e);
|
||||
continue;
|
||||
} catch (RuntimeException e) {
|
||||
s_logger.warn("Failed to start instance " + vm, e);
|
||||
throw new CloudRuntimeException("Failed to start " + vm, e);
|
||||
}
|
||||
|
||||
vmGuru.finalizeVirtualMachineProfile(vmProfile, dest, ctx);
|
||||
|
||||
VirtualMachineTO vmTO = hvGuru.implement(vmProfile);
|
||||
|
||||
Commands cmds = new Commands(OnError.Revert);
|
||||
cmds.addCommand(new StartCommand(vmTO));
|
||||
|
||||
vmGuru.finalizeDeployment(cmds, vmProfile, dest, ctx);
|
||||
try {
|
||||
Answer[] answers = _agentMgr.send(dest.getHost().getId(), cmds);
|
||||
if (getStartAnswer(answers).getResult() && vmGuru.finalizeStart(cmds, vmProfile, dest, ctx)) {
|
||||
if (!stateTransitTo(vm, Event.OperationSucceeded, dest.getHost().getId())) {
|
||||
throw new CloudRuntimeException("Unable to transition to a new state.");
|
||||
}
|
||||
startedVm = vm;
|
||||
break;
|
||||
}
|
||||
s_logger.info("Unable to start VM on " + dest.getHost() + " due to " + answers[0].getDetails());
|
||||
} catch (AgentUnavailableException e) {
|
||||
s_logger.debug("Unable to send the start command to host " + dest.getHost());
|
||||
continue;
|
||||
} catch (OperationTimedoutException e) {
|
||||
s_logger.debug("Unable to send the start command to host " + dest.getHost());
|
||||
continue;
|
||||
}
|
||||
s_logger.info("Unable to start VM on " + dest.getHost() + " due to " + answers[0].getDetails());
|
||||
} catch (AgentUnavailableException e) {
|
||||
s_logger.debug("Unable to send the start command to host " + dest.getHost());
|
||||
continue;
|
||||
} catch (OperationTimedoutException e) {
|
||||
s_logger.debug("Unable to send the start command to host " + dest.getHost());
|
||||
continue;
|
||||
}
|
||||
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Creation complete for VM " + vm);
|
||||
}
|
||||
} finally {
|
||||
if (startedVm == null) {
|
||||
stateTransitTo(vm, Event.OperationFailed, null);
|
||||
}
|
||||
work.setStep(Step.Done);
|
||||
_workDao.update(work.getId(), work);
|
||||
}
|
||||
|
||||
stateTransitTo(vm, Event.OperationFailed, null);
|
||||
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Creation complete for VM " + vm);
|
||||
}
|
||||
|
||||
return null;
|
||||
return startedVm;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -633,22 +724,13 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Cluster
|
||||
stateTransitTo(vm, Event.OperationSucceeded, null);
|
||||
|
||||
if (cleanup) {
|
||||
ItWorkVO work = new ItWorkVO(reservationId, _nodeId, Type.Cleanup, vm.getId());
|
||||
ItWorkVO work = new ItWorkVO(reservationId, _nodeId, State.Stopping, vm.getId());
|
||||
_workDao.persist(work);
|
||||
}
|
||||
|
||||
return stopped;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onManagementNodeJoined(List<ManagementServerHostVO> nodeList, long selfNodeId) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onManagementNodeLeft(List<ManagementServerHostVO> nodeList, long selfNodeId) {
|
||||
}
|
||||
|
||||
private void setStateMachine() {
|
||||
_stateMachine = new StateMachine2<State, VirtualMachine.Event, VMInstanceVO>();
|
||||
|
||||
@ -698,21 +780,36 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Cluster
|
||||
_stateMachine.registerListeners(_stateListner);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean stateTransitTo(VMInstanceVO vm, VirtualMachine.Event e, Long id) {
|
||||
protected boolean stateTransitTo(VMInstanceVO vm, VirtualMachine.Event e, Long hostId, String reservationId) {
|
||||
vm.setReservationId(reservationId);
|
||||
if (vm instanceof UserVmVO) {
|
||||
return _stateMachine.transitTO(vm, e, id, _userVmDao);
|
||||
return _stateMachine.transitTO(vm, e, hostId, _userVmDao);
|
||||
} else if (vm instanceof ConsoleProxyVO) {
|
||||
return _stateMachine.transitTO(vm, e, id, _consoleDao);
|
||||
return _stateMachine.transitTO(vm, e, hostId, _consoleDao);
|
||||
} else if (vm instanceof SecondaryStorageVmVO) {
|
||||
return _stateMachine.transitTO(vm, e, id, _secondaryDao);
|
||||
return _stateMachine.transitTO(vm, e, hostId, _secondaryDao);
|
||||
} else if (vm instanceof DomainRouterVO) {
|
||||
return _stateMachine.transitTO(vm, e, id, _routerDao);
|
||||
return _stateMachine.transitTO(vm, e, hostId, _routerDao);
|
||||
} else {
|
||||
return _stateMachine.transitTO(vm, e, id, _vmDao);
|
||||
return _stateMachine.transitTO(vm, e, hostId, _vmDao);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean stateTransitTo(VMInstanceVO vm, VirtualMachine.Event e, Long hostId) {
|
||||
if (vm instanceof UserVmVO) {
|
||||
return _stateMachine.transitTO(vm, e, hostId, _userVmDao);
|
||||
} else if (vm instanceof ConsoleProxyVO) {
|
||||
return _stateMachine.transitTO(vm, e, hostId, _consoleDao);
|
||||
} else if (vm instanceof SecondaryStorageVmVO) {
|
||||
return _stateMachine.transitTO(vm, e, hostId, _secondaryDao);
|
||||
} else if (vm instanceof DomainRouterVO) {
|
||||
return _stateMachine.transitTO(vm, e, hostId, _routerDao);
|
||||
} else {
|
||||
return _stateMachine.transitTO(vm, e, hostId, _vmDao);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends VMInstanceVO> boolean remove(T vm, User user, Account caller) {
|
||||
return _vmDao.remove(vm.getId());
|
||||
@ -742,4 +839,17 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Cluster
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected class CleanupTask implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
s_logger.trace("VM Operation Thread Running");
|
||||
try {
|
||||
_workDao.cleanup(_cleanupWait);
|
||||
} catch (Exception e) {
|
||||
s_logger.error("VM Operations failed due to ", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -51,9 +51,8 @@ public class VirtualMachineProfileImpl<T extends VMInstanceVO> implements Virtua
|
||||
BootloaderType _bootloader;
|
||||
|
||||
VirtualMachine.Type _type;
|
||||
HypervisorType _hyperType;
|
||||
|
||||
public VirtualMachineProfileImpl(T vm, VMTemplateVO template, ServiceOfferingVO offering, Account owner, Map<String, Object> params, HypervisorType hyperType) {
|
||||
public VirtualMachineProfileImpl(T vm, VMTemplateVO template, ServiceOfferingVO offering, Account owner, Map<String, Object> params) {
|
||||
_vm = vm;
|
||||
_template = template;
|
||||
_offering = offering;
|
||||
@ -63,11 +62,10 @@ public class VirtualMachineProfileImpl<T extends VMInstanceVO> implements Virtua
|
||||
_params = new HashMap<String, Object>();
|
||||
}
|
||||
_type = vm.getType();
|
||||
_hyperType = hyperType;
|
||||
}
|
||||
|
||||
public VirtualMachineProfileImpl(T vm) {
|
||||
this(vm, null, null, null, null, null);
|
||||
this(vm, null, null, null, null);
|
||||
}
|
||||
|
||||
public VirtualMachineProfileImpl(VirtualMachine.Type type) {
|
||||
@ -112,11 +110,7 @@ public class VirtualMachineProfileImpl<T extends VMInstanceVO> implements Virtua
|
||||
|
||||
@Override
|
||||
public HypervisorType getHypervisorType() {
|
||||
if (_hyperType != null && !_hyperType.equals(HypervisorType.None)) {
|
||||
return _hyperType;
|
||||
}
|
||||
getTemplate();
|
||||
return _template.getHypervisorType();
|
||||
return _vm.getHypervisorType();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -53,7 +53,7 @@ public interface VMInstanceDao extends GenericDao<VMInstanceVO, Long>, StateDao<
|
||||
*/
|
||||
public List<VMInstanceVO> listNonExpungedByZoneAndTemplate(long zoneId, long templateId);
|
||||
|
||||
boolean updateIf(VMInstanceVO vm, VirtualMachine.Event event, Long hostId);
|
||||
boolean updateIf(VMInstanceVO vm, VirtualMachine.Event event, Long hostId, String reservationId);
|
||||
|
||||
/**
|
||||
* Find vm instance with names like.
|
||||
|
||||
@ -154,7 +154,7 @@ public class VMInstanceDaoImpl extends GenericDaoBase<VMInstanceVO, Long> implem
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateIf(VMInstanceVO vm, VirtualMachine.Event event, Long hostId) {
|
||||
public boolean updateIf(VMInstanceVO vm, VirtualMachine.Event event, Long hostId, String reservationId) {
|
||||
|
||||
State oldState = vm.getState();
|
||||
State newState = oldState.getNextState(event);
|
||||
@ -173,10 +173,12 @@ public class VMInstanceDaoImpl extends GenericDaoBase<VMInstanceVO, Long> implem
|
||||
sc.setParameters("update", vm.getUpdated());
|
||||
|
||||
vm.incrUpdated();
|
||||
vm.setReservationId(reservationId);
|
||||
UpdateBuilder ub = getUpdateBuilder(vm);
|
||||
ub.set(vm, "state", newState);
|
||||
ub.set(vm, "hostId", hostId);
|
||||
ub.set(vm, _updateTimeAttr, new Date());
|
||||
|
||||
|
||||
int result = update(vm, sc);
|
||||
if (result == 0 && s_logger.isDebugEnabled()) {
|
||||
|
||||
@ -95,24 +95,6 @@ ALTER TABLE `cloud`.`cluster_details` ADD CONSTRAINT `fk_cluster_details__cluste
|
||||
ALTER TABLE `cloud`.`vm_template` ADD INDEX `i_vm_template__removed`(`removed`);
|
||||
ALTER TABLE `cloud`.`vm_template` ADD INDEX `i_vm_template__public`(`public`);
|
||||
|
||||
ALTER TABLE `cloud`.`vm_instance` ADD INDEX `i_vm_instance__removed`(`removed`);
|
||||
ALTER TABLE `cloud`.`vm_instance` ADD INDEX `i_vm_instance__type`(`type`);
|
||||
ALTER TABLE `cloud`.`vm_instance` ADD INDEX `i_vm_instance__pod_id`(`pod_id`);
|
||||
ALTER TABLE `cloud`.`vm_instance` ADD INDEX `i_vm_instance__update_time`(`update_time`);
|
||||
ALTER TABLE `cloud`.`vm_instance` ADD INDEX `i_vm_instance__update_count`(`update_count`);
|
||||
ALTER TABLE `cloud`.`vm_instance` ADD INDEX `i_vm_instance__state`(`state`);
|
||||
ALTER TABLE `cloud`.`vm_instance` ADD INDEX `i_vm_instance__data_center_id`(`data_center_id`);
|
||||
ALTER TABLE `cloud`.`vm_instance` ADD CONSTRAINT `fk_vm_instance__host_id` FOREIGN KEY `fk_vm_instance__host_id` (`host_id`) REFERENCES `host` (`id`);
|
||||
ALTER TABLE `cloud`.`vm_instance` ADD INDEX `i_vm_instance__host_id`(`host_id`);
|
||||
ALTER TABLE `cloud`.`vm_instance` ADD INDEX `i_vm_instance__last_host_id`(`last_host_id`);
|
||||
|
||||
ALTER TABLE `cloud`.`vm_instance` ADD CONSTRAINT `fk_vm_instance__template_id` FOREIGN KEY `fk_vm_instance__template_id` (`vm_template_id`) REFERENCES `vm_template` (`id`);
|
||||
ALTER TABLE `cloud`.`vm_instance` ADD INDEX `i_vm_instance__template_id`(`vm_template_id`);
|
||||
ALTER TABLE `cloud`.`vm_instance` ADD CONSTRAINT `fk_vm_instance__account_id` FOREIGN KEY `fk_vm_instance__account_id` (`account_id`) REFERENCES `account` (`id`);
|
||||
ALTER TABLE `cloud`.`vm_instance` ADD INDEX `i_vm_instance__account_id`(`account_id`);
|
||||
ALTER TABLE `cloud`.`vm_instance` ADD CONSTRAINT `fk_vm_instance__service_offering_id` FOREIGN KEY `fk_vm_instance__service_offering_id` (`service_offering_id`) REFERENCES `service_offering` (`id`);
|
||||
ALTER TABLE `cloud`.`vm_instance` ADD INDEX `i_vm_instance__service_offering_id`(`service_offering_id`);
|
||||
|
||||
ALTER TABLE `cloud`.`service_offering` ADD CONSTRAINT `fk_service_offering__id` FOREIGN KEY `fk_service_offering__id`(`id`) REFERENCES `disk_offering`(`id`) ON DELETE CASCADE;
|
||||
|
||||
ALTER TABLE `cloud`.`user_vm` ADD CONSTRAINT `fk_user_vm__domain_router_id` FOREIGN KEY `fk_user_vm__domain_router_id` (`domain_router_id`) REFERENCES `domain_router` (`id`);
|
||||
|
||||
@ -98,11 +98,11 @@ DROP TABLE IF EXISTS `cloud`.`host_tags`;
|
||||
CREATE TABLE `cloud`.`op_it_work` (
|
||||
`id` char(40) COMMENT 'id',
|
||||
`mgmt_server_id` bigint unsigned COMMENT 'management server id',
|
||||
`created` timestamp NOT NULL COMMENT 'when was this work detail created',
|
||||
`created_at` bigint unsigned NOT NULL COMMENT 'when was this work detail created',
|
||||
`thread` varchar(255) NOT NULL COMMENT 'thread name',
|
||||
`type` char(32) NOT NULL COMMENT 'type of work',
|
||||
`state` char(32) NOT NULL COMMENT 'state',
|
||||
`cancel_taken` timestamp COMMENT 'time it was taken over',
|
||||
`step` char(32) NOT NULL COMMENT 'state',
|
||||
`updated_at` bigint unsigned NOT NULL COMMENT 'time it was taken over',
|
||||
`instance_id` bigint unsigned NOT NULL COMMENT 'vm instance',
|
||||
`resource_type` char(32) COMMENT 'type of resource being worked on',
|
||||
`resource_id` bigint unsigned COMMENT 'resource id being worked on',
|
||||
@ -151,6 +151,7 @@ CREATE TABLE `cloud`.`networks` (
|
||||
`shared` int(1) unsigned NOT NULL DEFAULT 0 COMMENT '0 if network is shared, 1 if network dedicated',
|
||||
`network_domain` varchar(255) COMMENT 'domain',
|
||||
`reservation_id` char(40) COMMENT 'reservation id',
|
||||
`is_default` int(1) unsigned NOT NULL DEFAULT 0 COMMENT '1 if network is default',
|
||||
`created` datetime NOT NULL COMMENT 'date created',
|
||||
`removed` datetime COMMENT 'date removed if not null',
|
||||
PRIMARY KEY (`id`)
|
||||
@ -214,7 +215,7 @@ CREATE TABLE `cloud`.`network_offerings` (
|
||||
`service_offering_id` bigint unsigned UNIQUE COMMENT 'service offering id that this network offering is tied to',
|
||||
`created` datetime NOT NULL COMMENT 'time the entry was created',
|
||||
`removed` datetime DEFAULT NULL COMMENT 'time the entry was removed',
|
||||
`default` int(1) unsigned NOT NULL DEFAULT 0 COMMENT '1 if network is default',
|
||||
`default` int(1) unsigned NOT NULL DEFAULT 0 COMMENT '1 if network offering is default',
|
||||
`availability` varchar(255) NOT NULL COMMENT 'availability of the network',
|
||||
`dns_service` int(1) unsigned NOT NULL DEFAULT 0 COMMENT 'true if network offering provides dns service',
|
||||
`gateway_service` int(1) unsigned NOT NULL DEFAULT 0 COMMENT 'true if network offering provides gateway service',
|
||||
@ -676,7 +677,7 @@ CREATE TABLE `cloud`.`user_ip_address` (
|
||||
INDEX `i_user_ip_address__source_nat`(`source_nat`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE VIEW `cloud`.`user_ip_address_view` AS SELECT INET_NTOA(user_ip_address.public_ip_address) as public_ip_address, user_ip_address.data_center_id, user_ip_address.account_id, user_ip_address.domain_id, user_ip_address.source_nat, user_ip_address.allocated, user_ip_address.vlan_db_id, user_ip_address.one_to_one_nat, user_ip_address.state, user_ip_address.mac_address, user_ip_address.network_id as associated_network_id from user_ip_address;
|
||||
CREATE VIEW `cloud`.`user_ip_address_view` AS SELECT INET_NTOA(user_ip_address.public_ip_address) as ip_address, user_ip_address.data_center_id, user_ip_address.account_id, user_ip_address.domain_id, user_ip_address.source_nat, user_ip_address.allocated, user_ip_address.vlan_db_id, user_ip_address.one_to_one_nat, user_ip_address.state, user_ip_address.mac_address, user_ip_address.network_id as associated_network_id from user_ip_address;
|
||||
|
||||
CREATE TABLE `cloud`.`user_statistics` (
|
||||
`id` bigint unsigned UNIQUE NOT NULL AUTO_INCREMENT,
|
||||
@ -745,7 +746,23 @@ CREATE TABLE `cloud`.`vm_instance` (
|
||||
`domain_id` bigint unsigned NOT NULL,
|
||||
`service_offering_id` bigint unsigned NOT NULL COMMENT 'service offering id',
|
||||
`reservation_id` char(40) COMMENT 'reservation id',
|
||||
PRIMARY KEY (`id`)
|
||||
`hypervisor_type` char(32) COMMENT 'hypervisor type',
|
||||
PRIMARY KEY (`id`),
|
||||
INDEX `i_vm_instance__removed`(`removed`),
|
||||
INDEX `i_vm_instance__type`(`type`),
|
||||
INDEX `i_vm_instance__pod_id`(`pod_id`),
|
||||
INDEX `i_vm_instance__update_time`(`update_time`),
|
||||
INDEX `i_vm_instance__update_count`(`update_count`),
|
||||
INDEX `i_vm_instance__state`(`state`),
|
||||
INDEX `i_vm_instance__data_center_id`(`data_center_id`),
|
||||
CONSTRAINT `fk_vm_instance__host_id` FOREIGN KEY `fk_vm_instance__host_id` (`host_id`) REFERENCES `host` (`id`),
|
||||
CONSTRAINT `fk_vm_instance__last_host_id` FOREIGN KEY `fk_vm_instance__last_host_id` (`last_host_id`) REFERENCES `host`(`id`),
|
||||
CONSTRAINT `fk_vm_instance__template_id` FOREIGN KEY `fk_vm_instance__template_id` (`vm_template_id`) REFERENCES `vm_template` (`id`),
|
||||
INDEX `i_vm_instance__template_id`(`vm_template_id`),
|
||||
CONSTRAINT `fk_vm_instance__account_id` FOREIGN KEY `fk_vm_instance__account_id` (`account_id`) REFERENCES `account` (`id`),
|
||||
INDEX `i_vm_instance__account_id`(`account_id`),
|
||||
CONSTRAINT `fk_vm_instance__service_offering_id` FOREIGN KEY `fk_vm_instance__service_offering_id` (`service_offering_id`) REFERENCES `service_offering` (`id`),
|
||||
INDEX `i_vm_instance__service_offering_id`(`service_offering_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `cloud`.`user_vm` (
|
||||
@ -1320,6 +1337,7 @@ CREATE TABLE `cloud`.`usage_event` (
|
||||
`offering_id` bigint unsigned,
|
||||
`template_id` bigint unsigned,
|
||||
`size` bigint unsigned,
|
||||
`processed` tinyint NOT NULL default '0',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
@ -1337,7 +1355,7 @@ CREATE TABLE `cloud`.`ovs_tunnel_alloc`(
|
||||
`from` bigint unsigned COMMENT 'from host id',
|
||||
`to` bigint unsigned COMMENT 'to host id',
|
||||
`in_port` int unsigned COMMENT 'in port on open vswitch',
|
||||
PRIMARY KEY(`id`)
|
||||
PRIMARY KEY(`from`, `to`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `cloud`.`ovs_vlan_mapping_dirty`(
|
||||
|
||||
@ -268,7 +268,7 @@ a:hover {
|
||||
|
||||
.loginoptions_dropdown {
|
||||
width:91px;
|
||||
height:100px;
|
||||
height:auto;
|
||||
float:left;
|
||||
position:absolute;
|
||||
background:#FFF url(../images/actiondd_bg.gif) repeat-x top left;
|
||||
@ -282,13 +282,13 @@ a:hover {
|
||||
width:73px;
|
||||
height:auto;
|
||||
float:left;
|
||||
margin:3px 0 0 9px;
|
||||
margin:3px 0 0 5px;
|
||||
padding:0 0 10px 0;
|
||||
list-style:none;
|
||||
}
|
||||
|
||||
.loginoptions_dropdown li{
|
||||
width:68px;
|
||||
width:80px;
|
||||
height:auto;
|
||||
float:left;
|
||||
color:#333;
|
||||
@ -297,7 +297,7 @@ a:hover {
|
||||
background:none;
|
||||
border-bottom:1px dotted #999;
|
||||
margin:0;
|
||||
padding:5px 0 3px 5px;
|
||||
padding:5px 0 3px 0px;
|
||||
list-style:none;
|
||||
overflow:hidden;
|
||||
}
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 37 KiB |
61
ui/index.jsp
61
ui/index.jsp
@ -1,4 +1,8 @@
|
||||
<%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt" %>
|
||||
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
|
||||
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
|
||||
<c:if test="${!empty cookie.lang}">
|
||||
<fmt:setLocale value="${cookie.lang.value}" />
|
||||
</c:if>
|
||||
<fmt:setBundle basename="resources/messages"/>
|
||||
<% long now = System.currentTimeMillis(); %>
|
||||
|
||||
@ -46,6 +50,7 @@
|
||||
<script type="text/javascript" src="scripts/cloud.core.globalsetting.js?t=<%=now%>"></script>
|
||||
<script type="text/javascript" src="scripts/cloud.core.resource.js?t=<%=now%>"></script>
|
||||
<script type="text/javascript" src="scripts/cloud.core.zone.js?t=<%=now%>"></script>
|
||||
<script type="text/javascript" src="scripts/cloud.core.secondarystorage.js?t=<%=now%>"></script>
|
||||
<script type="text/javascript" src="scripts/cloud.core.network.js?t=<%=now%>"></script>
|
||||
<script type="text/javascript" src="scripts/cloud.core.pod.js?t=<%=now%>"></script>
|
||||
<script type="text/javascript" src="scripts/cloud.core.cluster.js?t=<%=now%>"></script>
|
||||
@ -108,33 +113,26 @@
|
||||
|
||||
<div class="loginoptions_panel">
|
||||
<div class="loginoptions_box">
|
||||
<div class="loginoptions_dropdownbutton">
|
||||
<p>English</p>
|
||||
<div id="lang_button" class="loginoptions_dropdownbutton">
|
||||
<p id="lang_name">English</p>
|
||||
<div class="loginoptions_ddarrow"></div>
|
||||
|
||||
<div class="loginoptions_dropdown" style="display:none;">
|
||||
<ul>
|
||||
<li> Français </li>
|
||||
<li> 汉语 </li>
|
||||
<li> Français </li>
|
||||
<li> 汉语 </li>
|
||||
|
||||
</ul>
|
||||
<div id="lang_menu" class="loginoptions_dropdown" style="display:none;">
|
||||
<ul>
|
||||
<li id="en">English</li>
|
||||
<li id="zh">Chinese</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="loginoptions_dropdownbutton">
|
||||
<p>Default Theme</p>
|
||||
<div id="theme_button" class="loginoptions_dropdownbutton">
|
||||
<p id="theme_name">Default Theme</p>
|
||||
<div class="loginoptions_ddarrow"></div>
|
||||
|
||||
<div class="loginoptions_dropdown" style="display:none;">>
|
||||
<ul>
|
||||
<li> Custom 1 </li>
|
||||
<li> Custom 2 </li>
|
||||
<li> Custom 3 </li>
|
||||
<li> Custom 4 </li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
<div id="theme_menu" class="loginoptions_dropdown" style="display:none;">
|
||||
<ul>
|
||||
<li id="theme_default">Default Theme</li>
|
||||
<li id="custom/custom1/css/custom1.css">Custom - Grey</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -163,6 +161,7 @@
|
||||
<p>
|
||||
<fmt:message key="label.welcome"/> <span id="main_username"></span>, <a href="#" id="main_logout"><fmt:message key="label.logout"/></a>
|
||||
</p>
|
||||
<!--
|
||||
<div class="language_dropdownpanel">
|
||||
<div class="language_icon"></div>
|
||||
<p>English</p>
|
||||
@ -175,7 +174,7 @@
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
-->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -839,14 +838,22 @@
|
||||
<div id="zone_content" style="display: none">
|
||||
<div id="pods_container">
|
||||
</div>
|
||||
|
||||
<div id="secondarystorage_header" class="leftmenu_content">
|
||||
<div class="leftmenu_fourthindent">
|
||||
<div class="leftmenu_arrows white_nonexpanded_close" id="secondarystorage_arrow">
|
||||
</div>
|
||||
<span id="secondarystorage_name_label">Secondary Storage</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="network_header" class="leftmenu_content" style="display: none">
|
||||
<div class="leftmenu_fourthindent">
|
||||
<div class="leftmenu_arrows white_nonexpanded_close" id="cluster_arrow">
|
||||
<div class="leftmenu_arrows white_nonexpanded_close" id="network_arrow">
|
||||
</div>
|
||||
<span id="network_name_label">Network</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Zone Template (end) -->
|
||||
|
||||
@ -354,9 +354,25 @@
|
||||
</div>
|
||||
<!-- VM detail panel (end) -->
|
||||
|
||||
<!-- VM Network Template (begin) -->
|
||||
<!-- VM Primary Network Template (begin) -->
|
||||
<div class="vmpopup_offeringbox" id="wizard_network_direct_template" style="display:none">
|
||||
<input type="checkbox" name="network_direct_checkbox" class="radio" id="network_direct_checkbox" />
|
||||
<input type="radio" name="primary_network" class="radio" id="network_direct_checkbox" />
|
||||
<label class="label" id="network_direct_name">
|
||||
</label>
|
||||
<div class="vmpopup_offdescriptionbox">
|
||||
<div class="vmpopup_offdescriptionbox_top">
|
||||
</div>
|
||||
<div class="vmpopup_offdescriptionbox_bot">
|
||||
<p id="network_direct_desc">
|
||||
A virtual private network that is fronted by a virtual router. An optional guest CIDR can be specified.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- VM Network Template (end) -->
|
||||
<!-- VM Secondary Network Template (begin) -->
|
||||
<div class="vmpopup_offeringbox" id="wizard_network_direct_secondary_template" style="display:none">
|
||||
<input type="checkbox" name="secondary_network" class="radio" id="network_direct_checkbox" />
|
||||
<label class="label" id="network_direct_name">
|
||||
</label>
|
||||
<div class="vmpopup_offdescriptionbox">
|
||||
@ -622,6 +638,7 @@
|
||||
<h2>
|
||||
Step 4: <strong>Network</strong></h2>
|
||||
<p>
|
||||
Please select the primary network that your virtual instance will be connected to.
|
||||
</p>
|
||||
</div>
|
||||
<div class="vmpopup_contentpanel">
|
||||
@ -638,77 +655,35 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="vmpopup_offeringpanel" style="position:relative;">
|
||||
<div class="vmpopup_offeringbox" id="network_virtual_container" style="display:none">
|
||||
<input type="checkbox" id="network_virtual" name="network_virtual_checkbox" class="radio" checked="checked" />
|
||||
<label class="label" id="network_virtual_name">Virtual Network</label>
|
||||
<div class="vmpopup_offdescriptionbox">
|
||||
<div class="vmpopup_offdescriptionbox_top">
|
||||
</div>
|
||||
<div class="vmpopup_offdescriptionbox_bot">
|
||||
<p id="network_virtual_desc">
|
||||
A dedicated virtualized network for your account. The broadcast domain is contrained within a VLAN and all public network access is routed out by a virtual router.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="network_direct_container"></div>
|
||||
<!--
|
||||
<div class="vmpopup_offeringbox">
|
||||
<input type="radio" name="radiogroup" class="radio" selected />
|
||||
<label class="label">
|
||||
My Virtual Network with Guest CIDR support. Specify guest CIDR:
|
||||
</label>
|
||||
<input type="text" name="disksize" class="text" />
|
||||
<div class="vmpopup_offdescriptionbox">
|
||||
<div class="vmpopup_offdescriptionbox_top">
|
||||
</div>
|
||||
<div class="vmpopup_offdescriptionbox_bot">
|
||||
<p>
|
||||
A virtual private network that is fronted by a virtual router. An optional guest CIDR can be specified.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="vmpopup_offeringbox" style="margin-top: 15px;">
|
||||
<input type="radio" name="radiogroup" class="radio" />
|
||||
<label class="label">
|
||||
My Direct Network:</label>
|
||||
<div class="vmpopup_offdescriptionbox">
|
||||
<div class="vmpopup_offdescriptionbox_top">
|
||||
</div>
|
||||
<div class="vmpopup_offdescriptionbox_bot">
|
||||
<p>
|
||||
A network where the virtual instance is directly assigned an IP from.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="vmpopup_offeringbox" style="margin-top: 15px;">
|
||||
<input type="radio" name="radiogroup" class="radio" />
|
||||
<label class="label">
|
||||
My Direct Shared Network: </label>
|
||||
<select class="select">
|
||||
<option>VLAN 100</option>
|
||||
<option>VLAN 101</option>
|
||||
<option>VLAN 102</option>
|
||||
</select>
|
||||
<div class="vmpopup_offdescriptionbox">
|
||||
<div class="vmpopup_offdescriptionbox_top">
|
||||
</div>
|
||||
<div class="vmpopup_offdescriptionbox_bot">
|
||||
<p>
|
||||
A network where the virtual instance is directly assigned an IP from. A VLAN must be selected.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
-->
|
||||
|
||||
<div id="for_basic_zone" style="display: none">
|
||||
<h3>Security Groups</h3>
|
||||
<ol>
|
||||
<div id="for_advanced_zone" style="display: none;">
|
||||
<div class="vmpopup_offeringbox" id="network_virtual_container" style="display:none">
|
||||
<input type="radio" id="network_virtual" name="primary_network" class="radio" checked="checked" />
|
||||
<label class="label" id="network_virtual_name">Virtual Network</label>
|
||||
<div class="vmpopup_offdescriptionbox">
|
||||
<div class="vmpopup_offdescriptionbox_top">
|
||||
</div>
|
||||
<div class="vmpopup_offdescriptionbox_bot">
|
||||
<p id="network_virtual_desc">
|
||||
A dedicated virtualized network for your account. The broadcast domain is contrained within a VLAN and all public network access is routed out by a virtual router.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="network_direct_container"></div>
|
||||
<h3 id="secondary_network_title" style="display:none">
|
||||
Additional Networks:
|
||||
</h3>
|
||||
<p id="secondary_network_desc" style="display:none">
|
||||
Please select additional network(s) that your virtual instance will be connected to.
|
||||
</p>
|
||||
<div id="network_direct_secondary_container"></div>
|
||||
</div>
|
||||
<div id="for_basic_zone" style="display:none">
|
||||
<h3>Security Groups</h3>
|
||||
<span id="not_available_message" style="display:none">security group is currently not available</span>
|
||||
<ol id="security_group_section" style="display:none">
|
||||
<li>
|
||||
<select id="wizard_security_groups" class="multiple" multiple="multiple" size="15">
|
||||
<select id="security_group_dropdown" class="multiple" multiple="multiple" size="15">
|
||||
</select>
|
||||
</li>
|
||||
<li>
|
||||
@ -828,16 +803,16 @@
|
||||
<span id="wizard_review_disk_offering"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="vmpopup_reviewbox even" id="wizard_review_virtual_network_container">
|
||||
<div class="vmpopup_reviewbox even" id="wizard_review_primary_network_container">
|
||||
<div class="vmopopup_reviewtextbox">
|
||||
<div class="vmpopup_reviewtick">
|
||||
</div>
|
||||
<div class="vmopopup_review_label">
|
||||
Network 1:</div>
|
||||
Primary Network:</div>
|
||||
<span id="wizard_review_network"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div id="wizard_review_direct_network_container"></div>
|
||||
<div id="wizard_review_secondary_network_container"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="vmpopup_navigationpanel">
|
||||
|
||||
@ -326,7 +326,17 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid_rows even">
|
||||
<div class="grid_rows even">
|
||||
<div class="grid_row_cell" style="width: 20%;">
|
||||
<div class="row_celltitles">
|
||||
Is Default:</div>
|
||||
</div>
|
||||
<div class="grid_row_cell" style="width: 79%;">
|
||||
<div class="row_celltitles" id="default">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid_rows odd">
|
||||
<div class="grid_row_cell" style="width: 20%;">
|
||||
<div class="row_celltitles">
|
||||
<%=t.t("vlan")%>:</div>
|
||||
@ -336,7 +346,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid_rows odd">
|
||||
<div class="grid_rows even">
|
||||
<div class="grid_row_cell" style="width: 20%;">
|
||||
<div class="row_celltitles">
|
||||
<%=t.t("gateway")%>:</div>
|
||||
@ -346,7 +356,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid_rows even">
|
||||
<div class="grid_rows odd">
|
||||
<div class="grid_row_cell" style="width: 20%;">
|
||||
<div class="row_celltitles">
|
||||
Netmask:</div>
|
||||
@ -356,7 +366,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid_rows odd">
|
||||
<div class="grid_rows even">
|
||||
<div class="grid_row_cell" style="width: 20%;">
|
||||
<div class="row_celltitles">
|
||||
Domain:</div>
|
||||
@ -366,7 +376,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid_rows even">
|
||||
<div class="grid_rows odd">
|
||||
<div class="grid_row_cell" style="width: 20%;">
|
||||
<div class="row_celltitles">
|
||||
Account:</div>
|
||||
@ -996,6 +1006,14 @@
|
||||
<input class="text" type="text" name="add_publicip_vlan_network_desc" id="add_publicip_vlan_network_desc" />
|
||||
<div id="add_publicip_vlan_network_desc_errormsg" class="dialog_formcontent_errormsg" style="display: none;">
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<label for="user_name">
|
||||
Is Default?</label>
|
||||
<select class="select" name="add_publicip_vlan_default" id="add_publicip_vlan_default">
|
||||
<option value="false">No</option>
|
||||
<option value="true">Yes</option>
|
||||
</select>
|
||||
</li>
|
||||
<li id="add_publicip_vlan_container">
|
||||
<label for="add_publicip_vlan_tagged">
|
||||
|
||||
196
ui/jsp/secondarystorage.jsp
Normal file
196
ui/jsp/secondarystorage.jsp
Normal file
@ -0,0 +1,196 @@
|
||||
<%@ page import="java.util.*" %>
|
||||
<%@ page import="com.cloud.utils.*" %>
|
||||
|
||||
<%
|
||||
Locale browserLocale = request.getLocale();
|
||||
CloudResourceBundle t = CloudResourceBundle.getBundle("resources/resource", browserLocale);
|
||||
%>
|
||||
|
||||
<div class="main_title" id="right_panel_header">
|
||||
|
||||
<div class="main_titleicon">
|
||||
<img src="images/title_secondarystorageicon.gif"/></div>
|
||||
|
||||
<h1>Secondary Storage
|
||||
</h1>
|
||||
</div>
|
||||
<div class="contentbox" id="right_panel_content">
|
||||
<div class="info_detailbox errorbox" id="after_action_info_container_on_top" style="display: none">
|
||||
<p id="after_action_info">
|
||||
</p>
|
||||
</div>
|
||||
<div class="tabbox" style="margin-top:15px;">
|
||||
<div class="content_tabs on">
|
||||
<%=t.t("Details")%></div>
|
||||
</div>
|
||||
<div id="tab_content_details">
|
||||
<div id="tab_spinning_wheel" class="rightpanel_mainloader_panel" style="display: none;">
|
||||
<div class="rightpanel_mainloaderbox">
|
||||
<div class="rightpanel_mainloader_animatedicon">
|
||||
</div>
|
||||
<p>
|
||||
Loading …</p>
|
||||
</div>
|
||||
</div>
|
||||
<div id="tab_container">
|
||||
<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"><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>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="gridheader_loaderbox" id="spinning_wheel" style="border: 1px solid #999;
|
||||
display: none;">
|
||||
<div class="gridheader_loader" id="icon">
|
||||
</div>
|
||||
<p id="description">
|
||||
Waiting …</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid_rows odd">
|
||||
<div class="grid_row_cell" style="width: 20%;">
|
||||
<div class="row_celltitles">
|
||||
<%=t.t("ID")%>:</div>
|
||||
</div>
|
||||
<div class="grid_row_cell" style="width: 79%;">
|
||||
<div class="row_celltitles" id="id">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid_rows even">
|
||||
<div class="grid_row_cell" style="width: 20%;">
|
||||
<div class="row_celltitles">
|
||||
<%=t.t("name")%>:</div>
|
||||
</div>
|
||||
<div class="grid_row_cell" style="width: 79%;">
|
||||
<div class="row_celltitles" id="name">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid_rows odd">
|
||||
<div class="grid_row_cell" style="width: 20%;">
|
||||
<div class="row_celltitles">
|
||||
<%=t.t("zone")%>:</div>
|
||||
</div>
|
||||
<div class="grid_row_cell" style="width: 79%;">
|
||||
<div class="row_celltitles" id="zonename">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid_rows even">
|
||||
<div class="grid_row_cell" style="width: 20%;">
|
||||
<div class="row_celltitles">
|
||||
<%=t.t("type")%>:</div>
|
||||
</div>
|
||||
<div class="grid_row_cell" style="width: 79%;">
|
||||
<div class="row_celltitles" id="type">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid_rows odd">
|
||||
<div class="grid_row_cell" style="width: 20%;">
|
||||
<div class="row_celltitles">
|
||||
<%=t.t("ip.address")%>:</div>
|
||||
</div>
|
||||
<div class="grid_row_cell" style="width: 79%;">
|
||||
<div class="row_celltitles" id="ipaddress">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid_rows even">
|
||||
<div class="grid_row_cell" style="width: 20%;">
|
||||
<div class="row_celltitles">
|
||||
<%=t.t("state")%>:</div>
|
||||
</div>
|
||||
<div class="grid_row_cell" style="width: 79%;">
|
||||
<div class="row_celltitles" id="state">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid_rows odd">
|
||||
<div class="grid_row_cell" style="width: 20%;">
|
||||
<div class="row_celltitles">
|
||||
<%=t.t("version")%>:</div>
|
||||
</div>
|
||||
<div class="grid_row_cell" style="width: 79%;">
|
||||
<div class="row_celltitles" id="version">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid_rows even">
|
||||
<div class="grid_row_cell" style="width: 20%;">
|
||||
<div class="row_celltitles">
|
||||
<%=t.t("last.disconnected")%>:</div>
|
||||
</div>
|
||||
<div class="grid_row_cell" style="width: 79%;">
|
||||
<div class="row_celltitles" id="disconnected">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- top buttons (begin) -->
|
||||
<div id="top_buttons">
|
||||
<div class="actionpanel_button_wrapper" id="add_secondarystorage_button">
|
||||
<div class="actionpanel_button">
|
||||
<div class="actionpanel_button_icons">
|
||||
<img src="images/addvm_actionicon.png" alt="Add Secondary Storage" /></div>
|
||||
<div class="actionpanel_button_links">
|
||||
Add Secondary Storage
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- top buttons (end) -->
|
||||
|
||||
<!-- Add Secondary Storage Dialog (begin) -->
|
||||
<div id="dialog_add_secondarystorage" title="Add Secondary Storage" style="display: none">
|
||||
<p>
|
||||
Add a new storage for zone <b><span id="zone_name"></span></b>
|
||||
</p>
|
||||
<div class="dialog_formcontent">
|
||||
<form action="#" method="post" id="form1">
|
||||
<ol>
|
||||
<li>
|
||||
<label>
|
||||
NFS Server:</label>
|
||||
<input class="text" type="text" name="nfs_server" id="nfs_server" />
|
||||
<div id="nfs_server_errormsg" class="dialog_formcontent_errormsg" style="display: none;">
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<label for="path">
|
||||
Path:</label>
|
||||
<input class="text" type="text" name="path" id="path" />
|
||||
<div id="path_errormsg" class="dialog_formcontent_errormsg" style="display: none;">
|
||||
</div>
|
||||
</li>
|
||||
</ol>
|
||||
</form>
|
||||
</div>
|
||||
<!--Loading box-->
|
||||
<div id="spinning_wheel" class="ui_dialog_loaderbox" style="display: none;">
|
||||
<div class="ui_dialog_loader">
|
||||
</div>
|
||||
<p>
|
||||
Adding....</p>
|
||||
</div>
|
||||
<!--Confirmation msg box-->
|
||||
<!--Note: for error msg, just have to add error besides everything for eg. add error(class) next to ui_dialog_messagebox error, ui_dialog_msgicon error, ui_dialog_messagebox_text error. -->
|
||||
<div id="info_container" class="ui_dialog_messagebox error" style="display: none;">
|
||||
<div id="icon" class="ui_dialog_msgicon error">
|
||||
</div>
|
||||
<div id="info" class="ui_dialog_messagebox_text error">
|
||||
(info)</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Add Secondary Storage Dialog (end) -->
|
||||
@ -99,6 +99,26 @@
|
||||
<div id="displaytext_edit_errormsg" style="display:none"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid_rows odd">
|
||||
<div class="grid_row_cell" style="width: 20%;">
|
||||
<div class="row_celltitles">
|
||||
<%=t.t("hypervisor")%>:</div>
|
||||
</div>
|
||||
<div class="grid_row_cell" style="width: 79%;">
|
||||
<div class="row_celltitles" id="hypervisor">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid_rows even">
|
||||
<div class="grid_row_cell" style="width: 20%;">
|
||||
<div class="row_celltitles">
|
||||
Type:</div>
|
||||
</div>
|
||||
<div class="grid_row_cell" style="width: 79%;">
|
||||
<div class="row_celltitles" id="templatetype">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid_rows odd">
|
||||
<div class="grid_row_cell" style="width: 20%;">
|
||||
<div class="row_celltitles">
|
||||
@ -182,18 +202,8 @@
|
||||
<select class="select" id="ostypename_edit" style="width: 202px; display: none;">
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid_rows even">
|
||||
<div class="grid_row_cell" style="width: 20%;">
|
||||
<div class="row_celltitles">
|
||||
<%=t.t("hypervisor")%>:</div>
|
||||
</div>
|
||||
<div class="grid_row_cell" style="width: 79%;">
|
||||
<div class="row_celltitles" id="hypervisor">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid_rows odd">
|
||||
<div class="grid_row_cell" style="width: 20%;">
|
||||
<div class="row_celltitles">
|
||||
<%=t.t("Account")%>:</div>
|
||||
@ -203,7 +213,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid_rows even">
|
||||
<div class="grid_rows odd">
|
||||
<div class="grid_row_cell" style="width: 20%;">
|
||||
<div class="row_celltitles">
|
||||
<%=t.t("Domain")%>:</div>
|
||||
@ -213,7 +223,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid_rows odd">
|
||||
<div class="grid_rows even">
|
||||
<div class="grid_row_cell" style="width: 20%;">
|
||||
<div class="row_celltitles">
|
||||
<%=t.t("Created")%>:</div>
|
||||
|
||||
@ -754,6 +754,13 @@
|
||||
<option value="true">Yes</option>
|
||||
</select>
|
||||
</li>
|
||||
<li id="isfeatured_container" style="display:none">
|
||||
<label>Featured?:</label>
|
||||
<select class="select" id="isfeatured">
|
||||
<option value="false">No</option>
|
||||
<option value="true">Yes</option>
|
||||
</select>
|
||||
</li>
|
||||
</ol>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@ -22,8 +22,10 @@
|
||||
<div class="tabbox" style="margin-top: 15px;">
|
||||
<div class="content_tabs on" id="tab_details">
|
||||
<%=t.t("details")%></div>
|
||||
<!--
|
||||
<div class="content_tabs off" id="tab_secondarystorage">
|
||||
<%=t.t("secondary.storage")%></div>
|
||||
Secondary Storage</div>
|
||||
-->
|
||||
<!--
|
||||
<div class="content_tabs off" id="tab_network">
|
||||
Network </div>
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
// Default password is MD5 hashed. Set the following variable to false to disable this.
|
||||
var md5Hashed = true;
|
||||
|
||||
$(document).ready(function() {
|
||||
$(document).ready(function() {
|
||||
function initUI() {
|
||||
var context = $.urlParam('lp');
|
||||
if (context != null) {
|
||||
@ -39,6 +39,78 @@ var md5Hashed = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Setup custom theme
|
||||
var $currentTheme = null;
|
||||
if ($.cookie("theme") != null) {
|
||||
$currentTheme = $("<link>").appendTo("head").attr({
|
||||
rel: "stylesheet",
|
||||
type: "text/css",
|
||||
href: $.cookie("theme")
|
||||
});
|
||||
$("#theme_button p").text($.cookie("theme.name"));
|
||||
}
|
||||
$("#theme_button").click(function(event) {
|
||||
var $menu = $(this).find("#theme_menu");
|
||||
if ($menu.css("display") == "none") {
|
||||
$menu.slideDown(500);
|
||||
} else {
|
||||
$menu.slideUp(500);
|
||||
}
|
||||
});
|
||||
|
||||
$("#theme_button #theme_menu").click(function(event) {
|
||||
var target = $(event.target);
|
||||
var id = target.attr("id");
|
||||
if ($currentTheme != null) {
|
||||
$currentTheme.remove();
|
||||
$currentTheme = null;
|
||||
}
|
||||
var name = "Default Theme";
|
||||
if (id != "theme_default") {
|
||||
$currentTheme = $("<link>").appendTo("head").attr({
|
||||
rel: "stylesheet",
|
||||
type: "text/css",
|
||||
href: id
|
||||
});
|
||||
name = target.text();
|
||||
$.cookie("theme.name", name);
|
||||
$.cookie("theme", id);
|
||||
} else {
|
||||
if ($currentTheme != null) {
|
||||
$currentTheme.remove();
|
||||
}
|
||||
$.cookie("theme", null);
|
||||
$.cookie("theme.name", null);
|
||||
name = "Default Theme";
|
||||
}
|
||||
$("#theme_button p").text(name);
|
||||
$(this).hide();
|
||||
return false;
|
||||
});
|
||||
|
||||
// Setup Language option
|
||||
if ($.cookie("lang") != null) {
|
||||
$("#lang_button p").text($.cookie("lang.name"));
|
||||
}
|
||||
|
||||
$("#lang_button").click(function(event) {
|
||||
var $menu = $(this).find("#lang_menu");
|
||||
if ($menu.css("display") == "none") {
|
||||
$menu.slideDown(500);
|
||||
} else {
|
||||
$menu.slideUp(500);
|
||||
}
|
||||
});
|
||||
|
||||
$("#lang_button #lang_menu").click(function(event) {
|
||||
var target = $(event.target);
|
||||
var id = target.attr("id");
|
||||
$.cookie("lang", id);
|
||||
$.cookie("lang.name", target.text());
|
||||
location.replace('/client');
|
||||
return false;
|
||||
});
|
||||
|
||||
// Setup drag and slide for the main UI
|
||||
$("#west_panel").resizable({
|
||||
minWidth: 221,
|
||||
@ -517,7 +589,7 @@ var md5Hashed = true;
|
||||
var activeTab = null;
|
||||
function logout(refresh) {
|
||||
g_mySession = null;
|
||||
g_sessionKey = null;
|
||||
g_sessionKey = null;
|
||||
g_username = null;
|
||||
g_account = null;
|
||||
g_domainid = null;
|
||||
|
||||
@ -391,11 +391,10 @@ function initVMWizard() {
|
||||
dataType: "json",
|
||||
success: function(json) {
|
||||
var items = json.listsecuritygroupsresponse.securitygroup;
|
||||
var $securityGroupSelect = $vmPopup.find("#wizard_security_groups").empty();
|
||||
var $securityGroupDropdown = $vmPopup.find("#security_group_dropdown").empty();
|
||||
if (items != null && items.length > 0) {
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
if(items[i].name != "default")
|
||||
$securityGroupSelect.append("<option value='" + fromdb(items[i].name) + "'>" + fromdb(items[i].name) + "</option>");
|
||||
$securityGroupDropdown.append("<option value='" + fromdb(items[i].name) + "'>" + fromdb(items[i].name) + "</option>");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -835,8 +834,10 @@ function initVMWizard() {
|
||||
|
||||
//Setup Networking before showing it. This only applies to zones with Advanced Networking support.
|
||||
var zoneObj = $thisPopup.find("#wizard_zone option:selected").data("zoneObj");
|
||||
if (zoneObj.networktype == "Advanced") {
|
||||
$thisPopup.find("#step4").find("#for_basic_zone").hide();
|
||||
if (zoneObj.networktype == "Advanced") {
|
||||
$thisPopup.find("#step4").find("#for_advanced_zone").show();
|
||||
$thisPopup.find("#step4").find("#for_basic_zone").hide();
|
||||
|
||||
var networkName = "Virtual Network";
|
||||
var networkDesc = "A dedicated virtualized network for your account. The broadcast domain is contrained within a VLAN and all public network access is routed out by a virtual router.";
|
||||
$.ajax({
|
||||
@ -856,6 +857,7 @@ function initVMWizard() {
|
||||
var $virtualNetworkElement = $("#vm_popup #network_virtual_container");
|
||||
|
||||
// Setup Virtual Networks
|
||||
var requiredVirtual = false;
|
||||
if (virtualNetwork == null) {
|
||||
$.ajax({
|
||||
data: createURL("command=listNetworkOfferings&traffictype=Guest"),
|
||||
@ -876,9 +878,10 @@ function initVMWizard() {
|
||||
if (network.networkofferingavailability != 'Unavailable') {
|
||||
$virtualNetworkElement.show();
|
||||
if (network.networkofferingavailability == 'Required') {
|
||||
requiredVirtual = true;
|
||||
$virtualNetworkElement.find("#network_virtual").attr('disabled', true);
|
||||
}
|
||||
$virtualNetworkElement.data("id", network.id);
|
||||
$virtualNetworkElement.find("#network_virtual").data("id", network.id).data("jsonObj", network);
|
||||
} else {
|
||||
$virtualNetworkElement.hide();
|
||||
}
|
||||
@ -893,9 +896,11 @@ function initVMWizard() {
|
||||
if (virtualNetwork.networkofferingavailability != 'Unavailable') {
|
||||
$virtualNetworkElement.show();
|
||||
if (virtualNetwork.networkofferingavailability == 'Required') {
|
||||
requiredVirtual = true;
|
||||
$virtualNetworkElement.find("#network_virtual").attr('disabled', true);
|
||||
}
|
||||
$virtualNetworkElement.data("id", virtualNetwork.id);
|
||||
$virtualNetworkElement.find("#network_virtual").data("id", virtualNetwork.id).data("jsonObj", virtualNetwork);
|
||||
} else {
|
||||
$virtualNetworkElement.hide();
|
||||
}
|
||||
@ -903,17 +908,33 @@ function initVMWizard() {
|
||||
|
||||
// Setup Direct Networks
|
||||
var $networkDirectTemplate = $("#wizard_network_direct_template");
|
||||
var $networkSecondaryDirectTemplate = $("#wizard_network_direct_secondary_template");
|
||||
var $networkDirectContainer = $("#network_direct_container").empty();
|
||||
var $networkDirectSecondaryContainer = $("#network_direct_secondary_container").empty();
|
||||
var availableSecondary = false;
|
||||
if (networks != null && networks.length > 0) {
|
||||
for (var i = 0; i < networks.length; i++) {
|
||||
if (networks[i].type != 'Direct') {
|
||||
continue;
|
||||
}
|
||||
var $directNetworkElement = $networkDirectTemplate.clone().attr("id", "direct"+networks[i].id);
|
||||
var $directNetworkElement = null;
|
||||
if (networks[i].isdefault) {
|
||||
if (requiredVirtual) {
|
||||
continue;
|
||||
}
|
||||
$directNetworkElement = $networkDirectTemplate.clone().attr("id", "direct"+networks[i].id);
|
||||
} else {
|
||||
$directNetworkElement = $networkSecondaryDirectTemplate.clone().attr("id", "direct"+networks[i].id);
|
||||
}
|
||||
$directNetworkElement.find("#network_direct_checkbox").data("jsonObj", networks[i]);
|
||||
$directNetworkElement.find("#network_direct_name").text(networks[i].name);
|
||||
$directNetworkElement.find("#network_direct_desc").text(networks[i].displaytext);
|
||||
$networkDirectContainer.append($directNetworkElement.show());
|
||||
if (networks[i].isdefault) {
|
||||
$networkDirectContainer.append($directNetworkElement.show());
|
||||
} else {
|
||||
availableSecondary = true;
|
||||
$networkDirectSecondaryContainer.append($directNetworkElement.show());
|
||||
}
|
||||
}
|
||||
|
||||
// Add any additional shared direct networks
|
||||
@ -928,24 +949,46 @@ function initVMWizard() {
|
||||
if (sharedNetworks[i].type != 'Direct') {
|
||||
continue;
|
||||
}
|
||||
var $directNetworkElement = $networkDirectTemplate.clone().attr("id", "direct"+sharedNetworks[i].id);
|
||||
if (sharedNetworks[i].isdefault) {
|
||||
if (requiredVirtual) {
|
||||
continue;
|
||||
}
|
||||
$directNetworkElement = $networkDirectTemplate.clone().attr("id", "direct"+sharedNetworks[i].id);
|
||||
} else {
|
||||
$directNetworkElement = $networkSecondaryDirectTemplate.clone().attr("id", "direct"+sharedNetworks[i].id);
|
||||
}
|
||||
$directNetworkElement.find("#network_direct_checkbox").data("jsonObj", sharedNetworks[i]);
|
||||
$directNetworkElement.find("#network_direct_name").text(sharedNetworks[i].name);
|
||||
$directNetworkElement.find("#network_direct_desc").text(sharedNetworks[i].displaytext);
|
||||
$networkDirectContainer.append($directNetworkElement.show());
|
||||
if (sharedNetworks[i].isdefault) {
|
||||
$networkDirectContainer.append($directNetworkElement.show());
|
||||
} else {
|
||||
availableSecondary = true;
|
||||
$networkDirectSecondaryContainer.append($directNetworkElement.show());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
if (availableSecondary) {
|
||||
$("#secondary_network_title, #secondary_network_desc").show();
|
||||
}
|
||||
}
|
||||
});
|
||||
$thisPopup.find("#wizard_review_network").text(networkName);
|
||||
}
|
||||
else { // Basic Network
|
||||
if(getDirectAttachSecurityGroupsEnabled() == "true" && $selectedVmWizardTemplate.data("hypervisor") != "VmWare" ) {
|
||||
$thisPopup.find("#step4").find("#for_basic_zone").show();
|
||||
$thisPopup.find("#wizard_review_network").text("Basic Network");
|
||||
$thisPopup.find("#step4").find("#for_basic_zone").show();
|
||||
$thisPopup.find("#step4").find("#for_advanced_zone").hide();
|
||||
if(getDirectAttachSecurityGroupsEnabled() == "true" && $selectedVmWizardTemplate.data("hypervisor") != "VmWare" ) {
|
||||
$thisPopup.find("#step4").find("#security_group_section").show();
|
||||
$thisPopup.find("#step4").find("#not_available_message").hide();
|
||||
$thisPopup.find("#step5").find("#wizard_review_network").text("Basic Network");
|
||||
}
|
||||
else {
|
||||
$thisPopup.find("#step4").find("#not_available_message").show();
|
||||
$thisPopup.find("#step4").find("#security_group_section").hide();
|
||||
$thisPopup.find("#step5").find("#wizard_review_network").text("");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -953,29 +996,25 @@ function initVMWizard() {
|
||||
if (currentStepInVmPopup == 4) { //network
|
||||
var zoneObj = $thisPopup.find("#wizard_zone option:selected").data("zoneObj");
|
||||
if (zoneObj.networktype == "Advanced") {
|
||||
var $selectedDirectNetworks = $thisPopup.find("input:checkbox[name=network_direct_checkbox]:checked");
|
||||
var $selectedVirtualNetworks = $thisPopup.find("input:checkbox[name=network_virtual_checkbox]:checked");
|
||||
var $selectedSecondaryNetworks = $thisPopup.find("input:checkbox[name=secondary_network]:checked");
|
||||
var $selectedPrimaryNetworks = $thisPopup.find("input:radio[name=primary_network]:checked");
|
||||
|
||||
// prevent a person from moving on if no network has been selected
|
||||
if($selectedDirectNetworks.length == 0 && $selectedVirtualNetworks.length == 0) {
|
||||
if($selectedPrimaryNetworks.length == 0) {
|
||||
$thisPopup.find("#step4 #wiz_message").show();
|
||||
return false;
|
||||
}
|
||||
|
||||
var modResult = 0;
|
||||
if ($selectedVirtualNetworks.length == 0) {
|
||||
$thisPopup.find("#wizard_review_virtual_network_container").hide();
|
||||
modResult = 1;
|
||||
} else {
|
||||
$thisPopup.find("#wizard_review_virtual_network_container").show();
|
||||
modResult = 0;
|
||||
}
|
||||
$thisPopup.find("#step5").find("#wizard_review_network").text($selectedPrimaryNetworks.data("jsonObj").name);
|
||||
$thisPopup.find("#wizard_review_primary_network_container").show();
|
||||
modResult = 0;
|
||||
|
||||
var $reviewNetworkContainer = $("#wizard_review_direct_network_container").empty();
|
||||
if ($selectedDirectNetworks.length != 0) {
|
||||
var $reviewNetworkContainer = $("#wizard_review_secondary_network_container").empty();
|
||||
if ($selectedSecondaryNetworks.length != 0) {
|
||||
var networkIds = [];
|
||||
|
||||
$selectedDirectNetworks.each(function(i) {
|
||||
$selectedSecondaryNetworks.each(function(i) {
|
||||
var json = $(this).data("jsonObj");
|
||||
if (i == 0) {
|
||||
networkIds.push(json.id);
|
||||
@ -1019,11 +1058,10 @@ function initVMWizard() {
|
||||
|
||||
var zoneObj = $thisPopup.find("#wizard_zone option:selected").data("zoneObj");
|
||||
if (zoneObj.networktype == "Advanced") {
|
||||
var networkIds = null;
|
||||
if ($thisPopup.find("input:checkbox[name=network_virtual_checkbox]:checked").length != 0) {
|
||||
networkIds = $thisPopup.find("#network_virtual_container").data("id");
|
||||
}
|
||||
var directNetworkIds = $thisPopup.find("#wizard_review_direct_network_container").data("directNetworkIds");
|
||||
var $selectedPrimaryNetworks = $thisPopup.find("input:radio[name=primary_network]:checked");
|
||||
var networkIds = $selectedPrimaryNetworks.data("jsonObj").id;
|
||||
|
||||
var directNetworkIds = $thisPopup.find("#wizard_review_secondary_network_container").data("directNetworkIds");
|
||||
if (directNetworkIds != null) {
|
||||
if (networkIds != null) {
|
||||
networkIds = networkIds+","+directNetworkIds;
|
||||
@ -1034,9 +1072,9 @@ function initVMWizard() {
|
||||
moreCriteria.push("&networkIds="+networkIds);
|
||||
}
|
||||
else { //Basic zone
|
||||
if($thisPopup.find("#step4").find("#for_basic_zone").css("style") != "none") {
|
||||
if($thisPopup.find("#wizard_security_groups").val() != null && $thisPopup.find("#wizard_security_groups").val().length > 0) {
|
||||
var securityGroupList = $thisPopup.find("#wizard_security_groups").val().join(",");
|
||||
if($thisPopup.find("#step4").find("#security_group_section").css("display") != "none") {
|
||||
if($thisPopup.find("#security_group_dropdown").val() != null && $thisPopup.find("#security_group_dropdown").val().length > 0) {
|
||||
var securityGroupList = $thisPopup.find("#security_group_dropdown").val().join(",");
|
||||
moreCriteria.push("&securitygrouplist="+encodeURIComponent(securityGroupList));
|
||||
}
|
||||
}
|
||||
|
||||
@ -87,7 +87,7 @@ function networkPopulateMiddleMenu($leftmenuItem1) {
|
||||
//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),
|
||||
data: createURL("command=listNetworks&trafficType=Public&isSystem=true&zoneId="+zoneObj.id),
|
||||
dataType: "json",
|
||||
async: false,
|
||||
success: function(json) {
|
||||
@ -883,7 +883,7 @@ function directNetworkJsonToDetailsTab() {
|
||||
$thisTab.find("#id").text(fromdb(jsonObj.id));
|
||||
$thisTab.find("#name").text(fromdb(jsonObj.name));
|
||||
$thisTab.find("#displaytext").text(fromdb(jsonObj.displaytext));
|
||||
|
||||
$thisTab.find("#default").text((jsonObj.isdefault) ? "Yes" : "No");
|
||||
$thisTab.find("#vlan").text(fromdb(jsonObj.vlan));
|
||||
$thisTab.find("#gateway").text(fromdb(jsonObj.gateway));
|
||||
$thisTab.find("#netmask").text(fromdb(jsonObj.netmask));
|
||||
@ -1105,7 +1105,8 @@ function bindAddNetworkButton($button) {
|
||||
} else if (isDirect) {
|
||||
scopeParams = "&isshared=true";
|
||||
}
|
||||
|
||||
|
||||
var isDefault = trim($thisDialog.find("#add_publicip_vlan_default").val());
|
||||
var gateway = trim($thisDialog.find("#add_publicip_vlan_gateway").val());
|
||||
var netmask = trim($thisDialog.find("#add_publicip_vlan_netmask").val());
|
||||
var startip = trim($thisDialog.find("#add_publicip_vlan_startip").val());
|
||||
@ -1125,7 +1126,7 @@ function bindAddNetworkButton($button) {
|
||||
if (networkOfferings[i].isdefault) {
|
||||
// Create a network from this.
|
||||
$.ajax({
|
||||
data: createURL("command=createNetwork&name="+name+"&displayText="+desc+"&networkOfferingId="+networkOfferings[i].id+"&zoneId="+zoneObj.id+vlan+scopeParams+"&gateway="+todb(gateway)+"&netmask="+todb(netmask)+"&startip="+todb(startip)+"&endip="+todb(endip)),
|
||||
data: createURL("command=createNetwork&isDefault="+isDefault+"&name="+name+"&displayText="+desc+"&networkOfferingId="+networkOfferings[i].id+"&zoneId="+zoneObj.id+vlan+scopeParams+"&gateway="+todb(gateway)+"&netmask="+todb(netmask)+"&startip="+todb(startip)+"&endip="+todb(endip)),
|
||||
dataType: "json",
|
||||
success: function(json) {
|
||||
$thisDialog.find("#spinning_wheel").hide();
|
||||
|
||||
@ -114,6 +114,38 @@ function buildZoneTree() {
|
||||
return false;
|
||||
});
|
||||
|
||||
$("#secondarystorage_header").unbind("click").bind("click", function(event) {
|
||||
selectRowInZoneTree($(this));
|
||||
|
||||
clearMiddleMenu();
|
||||
hideMiddleMenu();
|
||||
|
||||
if(currentRightPanelJSP != "jsp/secondarystorage.jsp") {
|
||||
removeDialogs();
|
||||
|
||||
var $thisNode = $(this);
|
||||
$("#right_panel").load("jsp/secondarystorage.jsp", function(){
|
||||
currentRightPanelJSP = "jsp/secondarystorage.jsp";
|
||||
|
||||
/*
|
||||
$(this).data("onRefreshFn", function() {
|
||||
var zoneObj = $midmenuItem1.data("jsonObj");
|
||||
if(zoneObj == null)
|
||||
return;
|
||||
$("#zone_"+zoneObj.id).find("#secondarystorage_header").click();
|
||||
});
|
||||
*/
|
||||
|
||||
afterLoadSecondaryStorageJSP($thisNode);
|
||||
});
|
||||
}
|
||||
else {
|
||||
secondaryStorageRefreshDataBinding();
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
$("#network_header").unbind("click").bind("click", function(event) {
|
||||
selectRowInZoneTree($(this));
|
||||
|
||||
@ -308,8 +340,9 @@ function zoneJSONToTreeNode(jsonObj, $zoneNode) {
|
||||
var zoneid = jsonObj.id;
|
||||
$zoneNode.attr("id", "zone_" + zoneid);
|
||||
$zoneNode.data("jsonObj", jsonObj);
|
||||
$zoneNode.find("#secondarystorage_header").data("zoneObj", jsonObj);
|
||||
|
||||
if(jsonObj.networktype == "Advanced") {
|
||||
if(jsonObj.networktype == "Advanced") {
|
||||
$zoneNode.find("#network_header").show().data("jsonObj", jsonObj);
|
||||
}
|
||||
|
||||
|
||||
153
ui/scripts/cloud.core.secondarystorage.js
Normal file
153
ui/scripts/cloud.core.secondarystorage.js
Normal file
@ -0,0 +1,153 @@
|
||||
/**
|
||||
* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
function afterLoadSecondaryStorageJSP($midmenuItem1) {
|
||||
var $topButtonContainer = clearButtonsOnTop();
|
||||
$("#top_buttons").appendTo($topButtonContainer);
|
||||
initDialog("dialog_add_secondarystorage");
|
||||
secondaryStorageRefreshDataBinding();
|
||||
}
|
||||
|
||||
function secondaryStorageRefreshDataBinding() {
|
||||
var $secondaryStorageNode = $selectedSubMenu;
|
||||
secondaryStorageJsonToRightPanel($secondaryStorageNode);
|
||||
}
|
||||
|
||||
function secondaryStorageJsonToRightPanel($midmenuItem1) {
|
||||
$("#right_panel_content").data("$midmenuItem1", $midmenuItem1);
|
||||
bindAddSecondaryStorageButton($midmenuItem1.data("zoneObj"));
|
||||
secondaryStorageJsonToDetailsTab();
|
||||
}
|
||||
|
||||
function secondaryStorageJsonToDetailsTab() {
|
||||
var $midmenuItem1 = $("#right_panel_content").data("$midmenuItem1");
|
||||
if($midmenuItem1 == null)
|
||||
return;
|
||||
|
||||
var zoneObj = $midmenuItem1.data("zoneObj");
|
||||
if(zoneObj == null)
|
||||
return;
|
||||
|
||||
var $thisTab = $("#right_panel_content").find("#tab_content_details");
|
||||
$thisTab.find("#tab_container").hide();
|
||||
$thisTab.find("#tab_spinning_wheel").show();
|
||||
|
||||
var jsonObj;
|
||||
$.ajax({
|
||||
data: createURL("command=listHosts&type=SecondaryStorage&zoneid="+zoneObj.id),
|
||||
dataType: "json",
|
||||
async: false,
|
||||
success: function(json) {
|
||||
var items = json.listhostsresponse.host;
|
||||
if(items != null && items.length > 0) {
|
||||
jsonObj = items[0];
|
||||
$midmenuItem1.data("jsonObj", jsonObj);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if(jsonObj == null) {
|
||||
secondaryStorageJsonClearRightPanel();
|
||||
$thisTab.find("#tab_spinning_wheel").hide();
|
||||
$thisTab.find("#tab_container").show();
|
||||
return;
|
||||
}
|
||||
|
||||
$thisTab.find("#id").text(fromdb(jsonObj.id));
|
||||
$thisTab.find("#grid_header_title").text(fromdb(jsonObj.name));
|
||||
$thisTab.find("#name").text(fromdb(jsonObj.name));
|
||||
|
||||
$thisTab.find("#zonename").text(fromdb(jsonObj.zonename));
|
||||
$thisTab.find("#type").text(jsonObj.type);
|
||||
$thisTab.find("#ipaddress").text(jsonObj.ipaddress);
|
||||
|
||||
setHostStateInRightPanel(fromdb(jsonObj.state), $thisTab.find("#state"))
|
||||
|
||||
$thisTab.find("#version").text(jsonObj.version);
|
||||
setDateField(jsonObj.disconnected, $thisTab.find("#disconnected"));
|
||||
|
||||
//actions ***
|
||||
var $actionLink = $thisTab.find("#action_link");
|
||||
$actionLink.bind("mouseover", function(event) {
|
||||
$(this).find("#action_menu").show();
|
||||
return false;
|
||||
});
|
||||
$actionLink.bind("mouseout", function(event) {
|
||||
$(this).find("#action_menu").hide();
|
||||
return false;
|
||||
});
|
||||
var $actionMenu = $thisTab.find("#action_link #action_menu");
|
||||
$actionMenu.find("#action_list").empty();
|
||||
buildActionLinkForTab("Delete Secondary Storage", secondaryStorageActionMap, $actionMenu, $midmenuItem1, $thisTab);
|
||||
|
||||
$thisTab.find("#tab_spinning_wheel").hide();
|
||||
$thisTab.find("#tab_container").show();
|
||||
}
|
||||
|
||||
function secondaryStorageJsonClearRightPanel() {
|
||||
secondaryStorageJsonClearDetailsTab();
|
||||
}
|
||||
|
||||
function secondaryStorageJsonClearDetailsTab() {
|
||||
var $thisTab = $("#right_panel_content").find("#tab_content_details");
|
||||
$thisTab.find("#id").text("");
|
||||
$thisTab.find("#grid_header_title").text("");
|
||||
$thisTab.find("#name").text("");
|
||||
$thisTab.find("#zonename").text("");
|
||||
$thisTab.find("#type").text("");
|
||||
$thisTab.find("#ipaddress").text("");
|
||||
$thisTab.find("#state").text("");
|
||||
$thisTab.find("#version").text("");
|
||||
$thisTab.find("#disconnected").text("");
|
||||
|
||||
//actions ***
|
||||
var $actionMenu = $thisTab.find("#action_link #action_menu");
|
||||
$actionMenu.find("#action_list").empty();
|
||||
$actionMenu.find("#action_list").append($("#no_available_actions").clone().show());
|
||||
}
|
||||
|
||||
var secondaryStorageActionMap = {
|
||||
"Delete Secondary Storage": {
|
||||
isAsyncJob: false,
|
||||
dialogBeforeActionFn: doDeleteSecondaryStorage,
|
||||
inProcessText: "Deleting Secondary Storage....",
|
||||
afterActionSeccessFn: function(json, $midmenuItem1, id) {
|
||||
secondaryStorageJsonClearRightPanel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function doDeleteSecondaryStorage($actionLink, $detailsTab, $midmenuItem1) {
|
||||
var jsonObj = $midmenuItem1.data("jsonObj");
|
||||
|
||||
$("#dialog_info")
|
||||
.text("Please confirm you want to delete this secondary storage")
|
||||
.dialog('option', 'buttons', {
|
||||
"Confirm": function() {
|
||||
var $thisDialog = $(this);
|
||||
$thisDialog.dialog("close");
|
||||
|
||||
var id = jsonObj.id;
|
||||
var apiCommand = "command=deleteHost&id="+id;
|
||||
doActionToTab(id, $actionLink, apiCommand, $midmenuItem1, $detailsTab);
|
||||
},
|
||||
"Cancel": function() {
|
||||
$(this).dialog("close");
|
||||
}
|
||||
}).dialog("open");
|
||||
}
|
||||
@ -186,9 +186,11 @@ function initAddIngressRuleDialog() {
|
||||
"Add": function() {
|
||||
var $thisDialog = $(this);
|
||||
$thisDialog.find("#info_container").hide();
|
||||
var protocol = $thisDialog.find("#protocol").val();
|
||||
|
||||
// validate values
|
||||
var isValid = true;
|
||||
var isValid = true;
|
||||
|
||||
if(protocol == "ICMP") {
|
||||
isValid &= validateNumber("Type", $thisDialog.find("#icmp_type"), $thisDialog.find("#icmp_type_errormsg"), -1, 40, false); //required
|
||||
isValid &= validateNumber("Code", $thisDialog.find("#icmp_code"), $thisDialog.find("#icmp_code_errormsg"), -1 , 15, false); //required
|
||||
@ -226,8 +228,7 @@ function initAddIngressRuleDialog() {
|
||||
moreCriteria.push("&domainid=" + domainId);
|
||||
moreCriteria.push("&account=" + account);
|
||||
moreCriteria.push("&securitygroupname=" + securityGroupName);
|
||||
|
||||
var protocol = $thisDialog.find("#protocol").val();
|
||||
|
||||
if (protocol!=null && protocol.length > 0)
|
||||
moreCriteria.push("&protocol="+encodeURIComponent(protocol));
|
||||
|
||||
|
||||
@ -279,7 +279,10 @@ function templateJsonToDetailsTab() {
|
||||
$thisTab.find("#name_edit").val(fromdb(jsonObj.name));
|
||||
|
||||
$thisTab.find("#displaytext").text(fromdb(jsonObj.displaytext));
|
||||
$thisTab.find("#displaytext_edit").val(fromdb(jsonObj.displaytext));
|
||||
$thisTab.find("#displaytext_edit").val(fromdb(jsonObj.displaytext));
|
||||
|
||||
$thisTab.find("#hypervisor").text(fromdb(jsonObj.hypervisor));
|
||||
$thisTab.find("#templatetype").text(fromdb(jsonObj.templatetype));
|
||||
|
||||
var status = "Ready";
|
||||
if (jsonObj.isready == false)
|
||||
@ -305,8 +308,6 @@ function templateJsonToDetailsTab() {
|
||||
$thisTab.find("#ostypename").text(fromdb(jsonObj.ostypename));
|
||||
$thisTab.find("#ostypename_edit").val(jsonObj.ostypeid);
|
||||
|
||||
$thisTab.find("#hypervisor").text(fromdb(jsonObj.hypervisor));
|
||||
|
||||
$thisTab.find("#account").text(fromdb(jsonObj.account));
|
||||
$thisTab.find("#domain").text(fromdb(jsonObj.domain));
|
||||
setDateField(jsonObj.created, $thisTab.find("#created"));
|
||||
|
||||
@ -57,6 +57,11 @@ function afterLoadVolumeJSP() {
|
||||
initDialog("dialog_create_template_from_snapshot", 450);
|
||||
initDialog("dialog_confirmation_delete_snapshot");
|
||||
initDialog("dialog_download_volume");
|
||||
|
||||
if(isAdmin())
|
||||
$("#dialog_create_template_from_snapshot").find("#isfeatured_container").show();
|
||||
else
|
||||
$("#dialog_create_template_from_snapshot").find("#isfeatured_container").hide();
|
||||
|
||||
$.ajax({
|
||||
data: createURL("command=listOsTypes"),
|
||||
@ -1046,6 +1051,11 @@ function doCreateTemplateFromSnapshotInVolumePage($actionLink, $subgridItem) {
|
||||
var password = thisDialog.find("#password").val();
|
||||
array1.push("&passwordEnabled="+password);
|
||||
|
||||
if(thisDialog.find("#isfeatured_container").css("display")!="none") {
|
||||
var isFeatured = thisDialog.find("#isfeatured").val();
|
||||
array1.push("&isfeatured="+isFeatured);
|
||||
}
|
||||
|
||||
var id = jsonObj.id;
|
||||
var apiCommand = "command=createTemplate&snapshotid="+id+array1.join("");
|
||||
doActionToSubgridItem(id, $actionLink, apiCommand, $subgridItem);
|
||||
|
||||
@ -52,7 +52,7 @@ function zoneJsonToRightPanel($leftmenuItem1) {
|
||||
|
||||
bindAddPodButton($("#add_pod_button"), $leftmenuItem1);
|
||||
//bindAddVLANButton($("#add_vlan_button"), $leftmenuItem1);
|
||||
bindAddSecondaryStorageButton($("#add_secondarystorage_button"), $leftmenuItem1);
|
||||
bindAddSecondaryStorageButton($leftmenuItem1.data("jsonObj"));
|
||||
|
||||
var pods;
|
||||
var zoneObj = $leftmenuItem1.data("jsonObj");
|
||||
@ -581,13 +581,8 @@ function bindAddVLANButton($button, $leftmenuItem1) {
|
||||
}
|
||||
|
||||
|
||||
function bindAddSecondaryStorageButton($button, $leftmenuItem1) {
|
||||
$button.show();
|
||||
$button.unbind("click").bind("click", function(event) {
|
||||
if($("#tab_content_secondarystorage").css("display") == "none")
|
||||
$("#tab_secondarystorage").click();
|
||||
|
||||
var zoneObj = $leftmenuItem1.data("jsonObj");
|
||||
function bindAddSecondaryStorageButton(zoneObj) {
|
||||
$("#add_secondarystorage_button").unbind("click").bind("click", function(event) {
|
||||
$("#dialog_add_secondarystorage").find("#zone_name").text(fromdb(zoneObj.name));
|
||||
$("#dialog_add_secondarystorage").find("#info_container").hide();
|
||||
|
||||
@ -615,13 +610,8 @@ function bindAddSecondaryStorageButton($button, $leftmenuItem1) {
|
||||
dataType: "json",
|
||||
success: function(json) {
|
||||
$thisDialog.find("#spinning_wheel").hide();
|
||||
$thisDialog.dialog("close");
|
||||
|
||||
var $subgridItem = $("#secondary_storage_tab_template").clone(true);
|
||||
secondaryStorageJSONToTemplate(json.addsecondarystorageresponse.secondarystorage, $subgridItem);
|
||||
$subgridItem.find("#after_action_info").text("Secondary storage was added successfully.");
|
||||
$subgridItem.find("#after_action_info_container").removeClass("error").addClass("success").show();
|
||||
$("#tab_content_secondarystorage").find("#tab_container").append($subgridItem.show());
|
||||
$thisDialog.dialog("close");
|
||||
$("#zone_"+zoneId).find("#secondarystorage_header").click();
|
||||
},
|
||||
error: function(XMLHttpResponse) {
|
||||
handleError(XMLHttpResponse, function() {
|
||||
@ -873,6 +863,7 @@ function bindEventHandlerToDialogAddVlanForZone() {
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
var secondarystorageActionMap = {
|
||||
"Delete Secondary Storage": {
|
||||
isAsyncJob: false,
|
||||
@ -885,7 +876,9 @@ var secondarystorageActionMap = {
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
function doDeleteSecondaryStorage($actionLink, $subgridItem) {
|
||||
var jsonObj = $subgridItem.data("jsonObj");
|
||||
|
||||
@ -906,6 +899,7 @@ function doDeleteSecondaryStorage($actionLink, $subgridItem) {
|
||||
}
|
||||
}).dialog("open");
|
||||
}
|
||||
*/
|
||||
|
||||
var zoneActionMap = {
|
||||
"Edit Zone": {
|
||||
|
||||
@ -36,8 +36,8 @@ public class InaccurateClock extends Thread {
|
||||
@Override
|
||||
public void run() {
|
||||
while (true) {
|
||||
time = System.currentTimeMillis();
|
||||
try {
|
||||
try {
|
||||
time = System.currentTimeMillis();
|
||||
Thread.sleep(1000);
|
||||
} catch(Exception e) {
|
||||
}
|
||||
@ -51,4 +51,9 @@ public class InaccurateClock extends Thread {
|
||||
return System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
|
||||
public static long getTimeInSeconds() {
|
||||
// This is obviously not accurate because it >> 10 is / 1024 but it's close enough since we're inaccurate.
|
||||
return getTime() >> 10;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user