mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
remove preallocatedLun
This commit is contained in:
parent
cc0ed77fee
commit
96d9776c20
@ -44,7 +44,6 @@ import com.cloud.api.response.SecurityGroupResponse;
|
||||
import com.cloud.api.response.NetworkOfferingResponse;
|
||||
import com.cloud.api.response.NetworkResponse;
|
||||
import com.cloud.api.response.PodResponse;
|
||||
import com.cloud.api.response.PreallocatedLunResponse;
|
||||
import com.cloud.api.response.RemoteAccessVpnResponse;
|
||||
import com.cloud.api.response.ResourceLimitResponse;
|
||||
import com.cloud.api.response.ServiceOfferingResponse;
|
||||
@ -138,8 +137,6 @@ public interface ResponseGenerator {
|
||||
|
||||
InstanceGroupResponse createInstanceGroupResponse(InstanceGroup group);
|
||||
|
||||
PreallocatedLunResponse createPreallocatedLunResponse(Object preallocatedLun);
|
||||
|
||||
StoragePoolResponse createStoragePoolResponse(StoragePool pool);
|
||||
|
||||
ClusterResponse createClusterResponse(Cluster cluster);
|
||||
|
||||
@ -1,65 +0,0 @@
|
||||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.SuccessResponse;
|
||||
|
||||
@Implementation(description="Unregisters PreallocatedLun", responseObject=SuccessResponse.class)
|
||||
public class DeletePreallocatedLunCmd extends BaseCmd {
|
||||
private static final String s_name = "deletePreallocatedLunsResponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="preallocated LUN ID")
|
||||
private Long id;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
boolean result = _mgr.unregisterPreallocatedLun(this);
|
||||
if (result) {
|
||||
SuccessResponse response = new SuccessResponse(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete preallocated lun");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,88 +0,0 @@
|
||||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseListCmd;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.response.ListResponse;
|
||||
import com.cloud.api.response.PreallocatedLunResponse;
|
||||
|
||||
@Implementation(description="List PreallocatedLuns",responseObject=PreallocatedLunResponse.class)
|
||||
public class ListPreallocatedLunsCmd extends BaseListCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(ListPreallocatedLunsCmd.class.getName());
|
||||
|
||||
private static final String s_name = "listpreallocatedlunsresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
//FIXME - add description
|
||||
@Parameter(name=ApiConstants.SCOPE, type=CommandType.STRING)
|
||||
private String scope;
|
||||
|
||||
//FIXME - add description
|
||||
@Parameter(name=ApiConstants.TARGET_IQN, type=CommandType.STRING)
|
||||
private String targetIqn;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public String getScope() {
|
||||
return scope;
|
||||
}
|
||||
|
||||
public String getTargetIqn() {
|
||||
return targetIqn;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
List<? extends Object> preallocatedLuns = _mgr.getPreAllocatedLuns(this);
|
||||
ListResponse<PreallocatedLunResponse> response = new ListResponse<PreallocatedLunResponse>();
|
||||
List<PreallocatedLunResponse> lunResponses = new ArrayList<PreallocatedLunResponse>();
|
||||
for (Object preallocatedLun : preallocatedLuns) {
|
||||
PreallocatedLunResponse preallocLunResponse = _responseGenerator.createPreallocatedLunResponse(preallocatedLun);
|
||||
|
||||
preallocLunResponse.setObjectName("preallocatedlun");
|
||||
lunResponses.add(preallocLunResponse);
|
||||
}
|
||||
|
||||
response.setResponses(lunResponses);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
}
|
||||
}
|
||||
@ -1,102 +0,0 @@
|
||||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.PreallocatedLunResponse;
|
||||
|
||||
@Implementation(description="Registers PreallocatedLun", responseObject=PreallocatedLunResponse.class)
|
||||
public class RegisterPreallocatedLunCmd extends BaseCmd {
|
||||
private static final String s_name = "registerPreallocatedLunsResponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Parameter(name=ApiConstants.DISK_SIZE, type=CommandType.LONG, required=true, description="Volume size")
|
||||
private Long diskSize;
|
||||
|
||||
@Parameter(name=ApiConstants.LUN, type=CommandType.INTEGER, required=true, description="Lun id")
|
||||
private Integer lun;
|
||||
|
||||
//FIXME - add description
|
||||
@Parameter(name=ApiConstants.PORTAL, type=CommandType.STRING, required=true)
|
||||
private String portal;
|
||||
|
||||
@Parameter(name=ApiConstants.TAGS, type=CommandType.STRING, description="tags for the volume")
|
||||
private String tags;
|
||||
|
||||
@Parameter(name=ApiConstants.TARGET_IQN, type=CommandType.STRING, required=true, description="the target IQN on the storage host where LUN is created")
|
||||
private String targetIqn;
|
||||
|
||||
@Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, required=true, description="zone ID where LUN is going to be created")
|
||||
private Long zoneId;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public Long getDiskSize() {
|
||||
return diskSize;
|
||||
}
|
||||
|
||||
public Integer getLun() {
|
||||
return lun;
|
||||
}
|
||||
|
||||
public String getPortal() {
|
||||
return portal;
|
||||
}
|
||||
|
||||
public String getTags() {
|
||||
return tags;
|
||||
}
|
||||
|
||||
public String getTargetIqn() {
|
||||
return targetIqn;
|
||||
}
|
||||
|
||||
public Long getZoneId() {
|
||||
return zoneId;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
Object result = _mgr.registerPreallocatedLun(this);
|
||||
if (result != null){
|
||||
PreallocatedLunResponse response = _responseGenerator.createPreallocatedLunResponse(result);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to register preallocated lun");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,114 +0,0 @@
|
||||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.cloud.api.response;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.cloud.serializer.Param;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class PreallocatedLunResponse extends BaseResponse {
|
||||
@SerializedName("id") @Param(description="the ID of the preallocated LUN")
|
||||
private Long id;
|
||||
|
||||
@SerializedName("volumeid") @Param(description="the ID of the preallocated LUN")
|
||||
private Long volumeId;
|
||||
|
||||
@SerializedName("zoneid") @Param(description="the zone ID of the preallocated LUN")
|
||||
private Long zoneId;
|
||||
|
||||
@SerializedName("lun") @Param(description="the name of the preallocated LUN")
|
||||
private Integer lun;
|
||||
|
||||
//FIXME - add description
|
||||
@SerializedName("portal")
|
||||
private String portal;
|
||||
|
||||
@SerializedName("size") @Param(description="the size of the preallocated LUN")
|
||||
private Long size;
|
||||
|
||||
@SerializedName("taken") @Param(description="true if the preallocated LUN is used by the volume, false otherwise")
|
||||
private Date taken;
|
||||
|
||||
@SerializedName("targetiqn") @Param(description="the target IQN of the preallocated LUN")
|
||||
private String targetIqn;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getVolumeId() {
|
||||
return volumeId;
|
||||
}
|
||||
|
||||
public void setVolumeId(Long volumeId) {
|
||||
this.volumeId = volumeId;
|
||||
}
|
||||
|
||||
public Long getZoneId() {
|
||||
return zoneId;
|
||||
}
|
||||
|
||||
public void setZoneId(Long zoneId) {
|
||||
this.zoneId = zoneId;
|
||||
}
|
||||
|
||||
public Integer getLun() {
|
||||
return lun;
|
||||
}
|
||||
|
||||
public void setLun(Integer lun) {
|
||||
this.lun = lun;
|
||||
}
|
||||
|
||||
public String getPortal() {
|
||||
return portal;
|
||||
}
|
||||
|
||||
public void setPortal(String portal) {
|
||||
this.portal = portal;
|
||||
}
|
||||
|
||||
public Long getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public void setSize(Long size) {
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
public Date getTaken() {
|
||||
return taken;
|
||||
}
|
||||
|
||||
public void setTaken(Date taken) {
|
||||
this.taken = taken;
|
||||
}
|
||||
|
||||
public String getTargetIqn() {
|
||||
return targetIqn;
|
||||
}
|
||||
|
||||
public void setTargetIqn(String targetIqn) {
|
||||
this.targetIqn = targetIqn;
|
||||
}
|
||||
}
|
||||
@ -28,7 +28,6 @@ import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.commands.CreateDomainCmd;
|
||||
import com.cloud.api.commands.CreateSSHKeyPairCmd;
|
||||
import com.cloud.api.commands.DeleteDomainCmd;
|
||||
import com.cloud.api.commands.DeletePreallocatedLunCmd;
|
||||
import com.cloud.api.commands.DeleteSSHKeyPairCmd;
|
||||
import com.cloud.api.commands.DestroySystemVmCmd;
|
||||
import com.cloud.api.commands.ExtractVolumeCmd;
|
||||
@ -51,7 +50,6 @@ import com.cloud.api.commands.ListHostsCmd;
|
||||
import com.cloud.api.commands.ListHypervisorsCmd;
|
||||
import com.cloud.api.commands.ListIsosCmd;
|
||||
import com.cloud.api.commands.ListPodsByCmd;
|
||||
import com.cloud.api.commands.ListPreallocatedLunsCmd;
|
||||
import com.cloud.api.commands.ListPublicIpAddressesCmd;
|
||||
import com.cloud.api.commands.ListRoutersCmd;
|
||||
import com.cloud.api.commands.ListSSHKeyPairsCmd;
|
||||
@ -67,7 +65,6 @@ import com.cloud.api.commands.ListVolumesCmd;
|
||||
import com.cloud.api.commands.ListZonesByCmd;
|
||||
import com.cloud.api.commands.RebootSystemVmCmd;
|
||||
import com.cloud.api.commands.RegisterCmd;
|
||||
import com.cloud.api.commands.RegisterPreallocatedLunCmd;
|
||||
import com.cloud.api.commands.RegisterSSHKeyPairCmd;
|
||||
import com.cloud.api.commands.StartSystemVMCmd;
|
||||
import com.cloud.api.commands.StopSystemVmCmd;
|
||||
@ -184,21 +181,7 @@ public interface ManagementService {
|
||||
* @return List of Events.
|
||||
*/
|
||||
List<? extends Event> searchForEvents(ListEventsCmd c);
|
||||
|
||||
/**
|
||||
* registerPreallocatedLun registers a preallocated lun in our database.
|
||||
*
|
||||
* @param cmd the API command wrapping the register parameters
|
||||
* - targetIqn iqn for the storage server.
|
||||
* - portal portal ip address for the storage server.
|
||||
* - lun lun #
|
||||
* - size size of the lun
|
||||
* - dcId data center to attach to
|
||||
* - tags tags to attach to the lun
|
||||
* @return the new PreAllocatedLun
|
||||
*/
|
||||
Object registerPreallocatedLun(RegisterPreallocatedLunCmd cmd);
|
||||
|
||||
|
||||
/**
|
||||
* Obtains a list of routers by the specified search criteria.
|
||||
* Can search by: "userId", "name", "state", "dataCenterId", "podId", "hostId"
|
||||
@ -343,8 +326,6 @@ public interface ManagementService {
|
||||
*/
|
||||
ArrayList<String> getCloudIdentifierResponse(GetCloudIdentifierCmd cmd);
|
||||
|
||||
public List<? extends Object> getPreAllocatedLuns(ListPreallocatedLunsCmd cmd);
|
||||
|
||||
boolean updateTemplatePermissions(UpdateTemplatePermissionsCmd cmd);
|
||||
boolean updateTemplatePermissions(UpdateIsoPermissionsCmd cmd);
|
||||
String[] createApiKeyAndSecretKey(RegisterCmd cmd);
|
||||
@ -401,13 +382,6 @@ public interface ManagementService {
|
||||
* @return a random password
|
||||
*/
|
||||
String generateRandomPassword();
|
||||
/**
|
||||
* Unregisters a preallocated lun in our database
|
||||
* @param cmd the api command wrapping the id of the lun
|
||||
* @return true if unregistered; false if not.
|
||||
* @throws IllegalArgumentException
|
||||
*/
|
||||
boolean unregisterPreallocatedLun(DeletePreallocatedLunCmd cmd) throws IllegalArgumentException;
|
||||
|
||||
public Long saveStartedEvent(Long userId, Long accountId, String type, String description, long startEventId);
|
||||
|
||||
|
||||
@ -1,62 +0,0 @@
|
||||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.cloud.storage.preallocatedlun;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name="ext_lun_details")
|
||||
public class PreallocatedLunDetailVO {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
||||
@Column(name="id")
|
||||
private long id;
|
||||
|
||||
@Column(name="ext_lun_id")
|
||||
private long lunId;
|
||||
|
||||
@Column(name="tag")
|
||||
private String tag;
|
||||
|
||||
protected PreallocatedLunDetailVO() {
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public long getLunId() {
|
||||
return lunId;
|
||||
}
|
||||
|
||||
public String getTag() {
|
||||
return tag;
|
||||
}
|
||||
|
||||
public PreallocatedLunDetailVO(long lunId, String tag) {
|
||||
this.lunId = lunId;
|
||||
this.tag = tag;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,131 +0,0 @@
|
||||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.cloud.storage.preallocatedlun;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
|
||||
@Entity
|
||||
@Table(name="ext_lun_alloc")
|
||||
public class PreallocatedLunVO {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
||||
@Column(name="id")
|
||||
private long id;
|
||||
|
||||
private String portal;
|
||||
|
||||
@Column(name="target_iqn")
|
||||
private String targetIqn;
|
||||
|
||||
private int lun;
|
||||
|
||||
@Column(name="data_center_id")
|
||||
private long dataCenterId;
|
||||
|
||||
private long size;
|
||||
|
||||
@Column(name="taken", nullable=true)
|
||||
@Temporal(value=TemporalType.TIMESTAMP)
|
||||
private Date taken;
|
||||
|
||||
@Column(name="volume_id")
|
||||
private Long volumeId;
|
||||
|
||||
public PreallocatedLunVO(long dataCenterId, String portal, String targetIqn, int lun, long size) {
|
||||
this.portal = portal;
|
||||
this.targetIqn = targetIqn;
|
||||
this.lun = lun;
|
||||
this.size = size;
|
||||
this.taken = null;
|
||||
this.volumeId = null;
|
||||
this.dataCenterId = dataCenterId;
|
||||
}
|
||||
|
||||
public long getDataCenterId() {
|
||||
return dataCenterId;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public Date getTaken() {
|
||||
return taken;
|
||||
}
|
||||
|
||||
public Long getVolumeId() {
|
||||
return volumeId;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getPortal() {
|
||||
return portal;
|
||||
}
|
||||
|
||||
public void setPortal(String portal) {
|
||||
this.portal = portal;
|
||||
}
|
||||
|
||||
public String getTargetIqn() {
|
||||
return targetIqn;
|
||||
}
|
||||
|
||||
public void setTargetIqn(String targetIqn) {
|
||||
this.targetIqn = targetIqn;
|
||||
}
|
||||
|
||||
public int getLun() {
|
||||
return lun;
|
||||
}
|
||||
|
||||
public void setLun(int lun) {
|
||||
this.lun = lun;
|
||||
}
|
||||
|
||||
public long getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public void setSize(long size) {
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
public void setTaken(Date taken) {
|
||||
this.taken = taken;
|
||||
}
|
||||
|
||||
public void setVolumeId(Long instanceId) {
|
||||
this.volumeId = instanceId;
|
||||
}
|
||||
|
||||
protected PreallocatedLunVO() {
|
||||
}
|
||||
}
|
||||
@ -56,7 +56,6 @@ import com.cloud.api.response.NetworkOfferingResponse;
|
||||
import com.cloud.api.response.NetworkResponse;
|
||||
import com.cloud.api.response.NicResponse;
|
||||
import com.cloud.api.response.PodResponse;
|
||||
import com.cloud.api.response.PreallocatedLunResponse;
|
||||
import com.cloud.api.response.RemoteAccessVpnResponse;
|
||||
import com.cloud.api.response.ResourceLimitResponse;
|
||||
import com.cloud.api.response.SecurityGroupResponse;
|
||||
@ -135,7 +134,6 @@ import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
|
||||
import com.cloud.storage.VMTemplateVO;
|
||||
import com.cloud.storage.Volume;
|
||||
import com.cloud.storage.VolumeVO;
|
||||
import com.cloud.storage.preallocatedlun.PreallocatedLunVO;
|
||||
import com.cloud.storage.snapshot.SnapshotPolicy;
|
||||
import com.cloud.template.VirtualMachineTemplate;
|
||||
import com.cloud.test.PodZoneConfig;
|
||||
@ -858,22 +856,6 @@ public class ApiResponseHelper implements ResponseGenerator {
|
||||
return groupResponse;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PreallocatedLunResponse createPreallocatedLunResponse(Object result) {
|
||||
PreallocatedLunVO preallocatedLun = (PreallocatedLunVO)result;
|
||||
PreallocatedLunResponse preallocLunResponse = new PreallocatedLunResponse();
|
||||
preallocLunResponse.setId(preallocatedLun.getId());
|
||||
preallocLunResponse.setVolumeId(preallocatedLun.getVolumeId());
|
||||
preallocLunResponse.setZoneId(preallocatedLun.getDataCenterId());
|
||||
preallocLunResponse.setLun(preallocatedLun.getLun());
|
||||
preallocLunResponse.setPortal(preallocatedLun.getPortal());
|
||||
preallocLunResponse.setSize(preallocatedLun.getSize());
|
||||
preallocLunResponse.setTaken(preallocatedLun.getTaken());
|
||||
preallocLunResponse.setTargetIqn(preallocatedLun.getTargetIqn());
|
||||
preallocLunResponse.setObjectName("preallocatedlun");
|
||||
return preallocLunResponse;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StoragePoolResponse createStoragePoolResponse(StoragePool pool) {
|
||||
StoragePoolResponse poolResponse = new StoragePoolResponse();
|
||||
|
||||
@ -113,7 +113,6 @@ import com.cloud.storage.dao.VMTemplatePoolDaoImpl;
|
||||
import com.cloud.storage.dao.VMTemplateZoneDaoImpl;
|
||||
import com.cloud.storage.dao.VolumeDaoImpl;
|
||||
import com.cloud.storage.download.DownloadMonitorImpl;
|
||||
import com.cloud.storage.preallocatedlun.dao.PreallocatedLunDaoImpl;
|
||||
import com.cloud.storage.secondary.SecondaryStorageManagerImpl;
|
||||
import com.cloud.storage.snapshot.SnapshotManagerImpl;
|
||||
import com.cloud.storage.snapshot.SnapshotSchedulerImpl;
|
||||
@ -234,7 +233,6 @@ public class DefaultComponentLibrary implements ComponentLibrary {
|
||||
addDao("DetailsDao", DetailsDaoImpl.class);
|
||||
addDao("SnapshotPolicyDao", SnapshotPolicyDaoImpl.class);
|
||||
addDao("SnapshotScheduleDao", SnapshotScheduleDaoImpl.class);
|
||||
addDao("PreallocatedLunDao", PreallocatedLunDaoImpl.class);
|
||||
addDao("ClusterDao", ClusterDaoImpl.class);
|
||||
addDao("CertificateDao", CertificateDaoImpl.class);
|
||||
addDao("NetworkConfigurationDao", NetworkDaoImpl.class);
|
||||
|
||||
@ -77,7 +77,6 @@ import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.commands.CreateDomainCmd;
|
||||
import com.cloud.api.commands.CreateSSHKeyPairCmd;
|
||||
import com.cloud.api.commands.DeleteDomainCmd;
|
||||
import com.cloud.api.commands.DeletePreallocatedLunCmd;
|
||||
import com.cloud.api.commands.DeleteSSHKeyPairCmd;
|
||||
import com.cloud.api.commands.DestroySystemVmCmd;
|
||||
import com.cloud.api.commands.ExtractVolumeCmd;
|
||||
@ -100,7 +99,6 @@ import com.cloud.api.commands.ListHostsCmd;
|
||||
import com.cloud.api.commands.ListHypervisorsCmd;
|
||||
import com.cloud.api.commands.ListIsosCmd;
|
||||
import com.cloud.api.commands.ListPodsByCmd;
|
||||
import com.cloud.api.commands.ListPreallocatedLunsCmd;
|
||||
import com.cloud.api.commands.ListPublicIpAddressesCmd;
|
||||
import com.cloud.api.commands.ListRoutersCmd;
|
||||
import com.cloud.api.commands.ListSSHKeyPairsCmd;
|
||||
@ -116,7 +114,6 @@ import com.cloud.api.commands.ListVolumesCmd;
|
||||
import com.cloud.api.commands.ListZonesByCmd;
|
||||
import com.cloud.api.commands.RebootSystemVmCmd;
|
||||
import com.cloud.api.commands.RegisterCmd;
|
||||
import com.cloud.api.commands.RegisterPreallocatedLunCmd;
|
||||
import com.cloud.api.commands.RegisterSSHKeyPairCmd;
|
||||
import com.cloud.api.commands.StartSystemVMCmd;
|
||||
import com.cloud.api.commands.StopSystemVmCmd;
|
||||
@ -219,8 +216,6 @@ import com.cloud.storage.dao.StoragePoolHostDao;
|
||||
import com.cloud.storage.dao.UploadDao;
|
||||
import com.cloud.storage.dao.VMTemplateDao;
|
||||
import com.cloud.storage.dao.VolumeDao;
|
||||
import com.cloud.storage.preallocatedlun.PreallocatedLunVO;
|
||||
import com.cloud.storage.preallocatedlun.dao.PreallocatedLunDao;
|
||||
import com.cloud.storage.secondary.SecondaryStorageVmManager;
|
||||
import com.cloud.storage.upload.UploadMonitor;
|
||||
import com.cloud.template.TemplateManager;
|
||||
@ -325,7 +320,6 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
private final AsyncJobManager _asyncMgr;
|
||||
private final TemplateManager _tmpltMgr;
|
||||
private final int _purgeDelay;
|
||||
private final PreallocatedLunDao _lunDao;
|
||||
private final InstanceGroupDao _vmGroupDao;
|
||||
private final UploadMonitor _uploadMonitor;
|
||||
private final UploadDao _uploadDao;
|
||||
@ -352,7 +346,6 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
|
||||
protected ManagementServerImpl() {
|
||||
ComponentLocator locator = ComponentLocator.getLocator(Name);
|
||||
_lunDao = locator.getDao(PreallocatedLunDao.class);
|
||||
_configDao = locator.getDao(ConfigurationDao.class);
|
||||
_routerDao = locator.getDao(DomainRouterDao.class);
|
||||
_eventDao = locator.getDao(EventDao.class);
|
||||
@ -449,45 +442,7 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
public StorageStats getStorageStatistics(long hostId) {
|
||||
return _statsCollector.getStorageStats(hostId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PreallocatedLunVO registerPreallocatedLun(RegisterPreallocatedLunCmd cmd) {
|
||||
Long zoneId = cmd.getZoneId();
|
||||
String portal = cmd.getPortal();
|
||||
String targetIqn = cmd.getTargetIqn();
|
||||
Integer lun = cmd.getLun();
|
||||
Long size = cmd.getDiskSize();
|
||||
String t = cmd.getTags();
|
||||
|
||||
String[] tags = null;
|
||||
if (t != null) {
|
||||
tags = t.split(",");
|
||||
for (int i = 0; i < tags.length; i++) {
|
||||
tags[i] = tags[i].trim();
|
||||
}
|
||||
} else {
|
||||
tags = new String[0];
|
||||
}
|
||||
|
||||
PreallocatedLunVO vo = new PreallocatedLunVO(zoneId, portal, targetIqn, lun, size);
|
||||
return _lunDao.persist(vo, tags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean unregisterPreallocatedLun(DeletePreallocatedLunCmd cmd) throws IllegalArgumentException {
|
||||
Long id = cmd.getId();
|
||||
PreallocatedLunVO lun = null;
|
||||
if ((lun = _lunDao.findById(id)) == null) {
|
||||
throw new IllegalArgumentException("Unable to find a LUN with ID " + id);
|
||||
}
|
||||
|
||||
if (lun.getTaken() != null) {
|
||||
throw new IllegalArgumentException("The LUN is currently in use and cannot be deleted.");
|
||||
}
|
||||
|
||||
return _lunDao.delete(id);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public VolumeStats[] getVolumeStatistics(long[] volIds) {
|
||||
return _statsCollector.getVolumeStats(volIds);
|
||||
@ -4139,36 +4094,7 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
return pendingEvents;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PreallocatedLunVO> getPreAllocatedLuns(ListPreallocatedLunsCmd cmd) {
|
||||
Filter searchFilter = new Filter(PreallocatedLunVO.class, "id", true, cmd.getStartIndex(), cmd.getPageSizeVal());
|
||||
SearchCriteria<PreallocatedLunVO> sc = _lunDao.createSearchCriteria();
|
||||
|
||||
Object targetIqn = cmd.getTargetIqn();
|
||||
Object scope = cmd.getScope();
|
||||
|
||||
if (targetIqn != null) {
|
||||
sc.addAnd("targetIqn", SearchCriteria.Op.EQ, targetIqn);
|
||||
}
|
||||
|
||||
if (scope == null || scope.toString().equalsIgnoreCase("ALL")) {
|
||||
return _lunDao.search(sc, searchFilter);
|
||||
} else if(scope.toString().equalsIgnoreCase("ALLOCATED")) {
|
||||
sc.addAnd("volumeId", SearchCriteria.Op.NNULL);
|
||||
sc.addAnd("taken", SearchCriteria.Op.NNULL);
|
||||
|
||||
return _lunDao.search(sc, searchFilter);
|
||||
} else if(scope.toString().equalsIgnoreCase("FREE")) {
|
||||
sc.addAnd("volumeId", SearchCriteria.Op.NULL);
|
||||
sc.addAnd("taken", SearchCriteria.Op.NULL);
|
||||
|
||||
return _lunDao.search(sc, searchFilter);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public boolean checkLocalStorageConfigVal()
|
||||
{
|
||||
String value = _configs.get("use.local.storage");
|
||||
|
||||
@ -1,54 +0,0 @@
|
||||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.cloud.storage.preallocatedlun.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.cloud.storage.preallocatedlun.PreallocatedLunVO;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
public interface PreallocatedLunDao extends GenericDao<PreallocatedLunVO, Long> {
|
||||
/**
|
||||
* Takes a LUN
|
||||
* @param instanceId vm instance that's taking this LUN
|
||||
* @param tags special tag to match to the LUN
|
||||
* @return PreallocatedLunVO if matches; NULL if not.
|
||||
*/
|
||||
PreallocatedLunVO take(long volumeId, String targetIqn, long size1, long size2, String... tags);
|
||||
|
||||
/**
|
||||
* Releases a LUN
|
||||
* @param id LUN to release
|
||||
* @param instanceId vm instance that this LUN used to belong to.
|
||||
* @return true if released; false if not.
|
||||
*/
|
||||
boolean release(String targetIqn, int lunId, long volumeId);
|
||||
|
||||
/**
|
||||
* Return the distinct preallocated luns. Ignore the LUN as it is meaningless.
|
||||
* @return List of PreallocatedLunVO
|
||||
*/
|
||||
List<PreallocatedLunVO> listDistinctTargets(long dataCenterId);
|
||||
|
||||
List<String> findDistinctTagsForTarget(String targetIqn);
|
||||
|
||||
PreallocatedLunVO persist(PreallocatedLunVO lun, String[] tags);
|
||||
long getTotalSize(String targetIqn);
|
||||
long getUsedSize(String targetIqn);
|
||||
boolean delete(long id);
|
||||
}
|
||||
@ -1,238 +0,0 @@
|
||||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.cloud.storage.preallocatedlun.dao;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.ejb.Local;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.storage.preallocatedlun.PreallocatedLunDetailVO;
|
||||
import com.cloud.storage.preallocatedlun.PreallocatedLunVO;
|
||||
import com.cloud.utils.component.ComponentLocator;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.GenericSearchBuilder;
|
||||
import com.cloud.utils.db.JoinBuilder;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.SearchCriteria.Func;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
||||
@Local(value=PreallocatedLunDao.class) @DB(txn=false)
|
||||
public class PreallocatedLunDaoImpl extends GenericDaoBase<PreallocatedLunVO, Long> implements PreallocatedLunDao {
|
||||
private static final Logger s_logger = Logger.getLogger(PreallocatedLunDaoImpl.class);
|
||||
|
||||
final PreallocatedLunDetailsDao _detailsDao = ComponentLocator.inject(PreallocatedLunDetailsDaoImpl.class);
|
||||
|
||||
private final SearchBuilder<PreallocatedLunVO> TakeSearch;
|
||||
private final SearchBuilder<PreallocatedLunVO> ReleaseSearch;
|
||||
private final GenericSearchBuilder<PreallocatedLunDetailVO, String> DetailsSearch;
|
||||
private final GenericSearchBuilder<PreallocatedLunVO, Long> TotalSizeSearch;
|
||||
private final GenericSearchBuilder<PreallocatedLunVO, Long> UsedSizeSearch;
|
||||
private final SearchBuilder<PreallocatedLunVO> DeleteSearch;
|
||||
|
||||
private final String TakeSqlPrefix = "SELECT ext_lun_alloc.* FROM ext_lun_alloc LEFT JOIN ext_lun_details ON ext_lun_details.ext_lun_id = ext_lun_alloc.id WHERE (ext_lun_alloc.target_iqn=?) AND (ext_lun_alloc.size>=?) AND (ext_lun_alloc.size<=?) AND ";
|
||||
private final String TakeSqlSuffix = " ext_lun_alloc.taken IS NULL GROUP BY ext_lun_details.ext_lun_id HAVING COUNT(ext_lun_details.tag) >= ? LIMIT 1 FOR UPDATE";
|
||||
|
||||
protected PreallocatedLunDaoImpl() {
|
||||
TakeSearch = createSearchBuilder();
|
||||
TakeSearch.and("taken", TakeSearch.entity().getTaken(), SearchCriteria.Op.NULL);
|
||||
TakeSearch.done();
|
||||
|
||||
ReleaseSearch = createSearchBuilder();
|
||||
ReleaseSearch.and("lun", ReleaseSearch.entity().getLun(), SearchCriteria.Op.EQ);
|
||||
ReleaseSearch.and("target", ReleaseSearch.entity().getTargetIqn(), SearchCriteria.Op.EQ);
|
||||
ReleaseSearch.and("taken", ReleaseSearch.entity().getTaken(), SearchCriteria.Op.NNULL);
|
||||
ReleaseSearch.and("instanceId", ReleaseSearch.entity().getVolumeId(), SearchCriteria.Op.EQ);
|
||||
ReleaseSearch.done();
|
||||
|
||||
DetailsSearch = _detailsDao.createSearchBuilder(String.class);
|
||||
SearchBuilder<PreallocatedLunVO> targetSearch = createSearchBuilder();
|
||||
targetSearch.and("targetiqn", targetSearch.entity().getTargetIqn(), SearchCriteria.Op.EQ);
|
||||
DetailsSearch.join("target", targetSearch, targetSearch.entity().getId(), DetailsSearch.entity().getLunId(), JoinBuilder.JoinType.INNER);
|
||||
DetailsSearch.select(null, Func.DISTINCT, DetailsSearch.entity().getTag());
|
||||
DetailsSearch.done();
|
||||
targetSearch.done();
|
||||
|
||||
TotalSizeSearch = createSearchBuilder(Long.class);
|
||||
TotalSizeSearch.and("target", TotalSizeSearch.entity().getTargetIqn(), SearchCriteria.Op.EQ);
|
||||
TotalSizeSearch.select(null, Func.SUM, TotalSizeSearch.entity().getSize());
|
||||
TotalSizeSearch.done();
|
||||
|
||||
UsedSizeSearch = createSearchBuilder(Long.class);
|
||||
UsedSizeSearch.and("target", UsedSizeSearch.entity().getTargetIqn(), SearchCriteria.Op.EQ);
|
||||
UsedSizeSearch.and("taken", UsedSizeSearch.entity().getTaken(), SearchCriteria.Op.NNULL);
|
||||
UsedSizeSearch.select(null, Func.SUM, UsedSizeSearch.entity().getSize());
|
||||
UsedSizeSearch.done();
|
||||
|
||||
DeleteSearch = createSearchBuilder();
|
||||
DeleteSearch.and("id", DeleteSearch.entity().getId(), SearchCriteria.Op.EQ);
|
||||
DeleteSearch.and("taken", DeleteSearch.entity().getTaken(), SearchCriteria.Op.NULL);
|
||||
DeleteSearch.done();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean delete(long id) {
|
||||
SearchCriteria<PreallocatedLunVO> sc = DeleteSearch.create();
|
||||
sc.setParameters("id", id);
|
||||
|
||||
return expunge(sc) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean release(String targetIqn, int lunId, long instanceId) {
|
||||
SearchCriteria<PreallocatedLunVO> sc = ReleaseSearch.create();
|
||||
sc.setParameters("lun", lunId);
|
||||
sc.setParameters("target", targetIqn);
|
||||
sc.setParameters("instanceId", instanceId);
|
||||
|
||||
PreallocatedLunVO vo = createForUpdate();
|
||||
vo.setTaken(null);
|
||||
vo.setVolumeId(null);
|
||||
|
||||
return update(vo, sc) > 0;
|
||||
}
|
||||
|
||||
@Override @DB
|
||||
public PreallocatedLunVO take(long volumeId, String targetIqn, long size1, long size2, String... tags) {
|
||||
StringBuilder sql = new StringBuilder(TakeSqlPrefix);
|
||||
|
||||
if (tags.length > 0) {
|
||||
sql.append("(");
|
||||
for (String tag : tags) {
|
||||
sql.append("ext_lun_details.tag=?").append(" OR ");
|
||||
}
|
||||
sql.delete(sql.length() - 4, sql.length());
|
||||
sql.append(") AND ");
|
||||
}
|
||||
sql.append(TakeSqlSuffix);
|
||||
|
||||
try {
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
PreparedStatement pstmt = txn.prepareAutoCloseStatement(sql.toString());
|
||||
int i = 1;
|
||||
pstmt.setString(i++, targetIqn);
|
||||
pstmt.setLong(i++, size1);
|
||||
pstmt.setLong(i++, size2);
|
||||
for (String tag : tags) {
|
||||
pstmt.setString(i++, tag);
|
||||
}
|
||||
pstmt.setInt(i++, tags.length);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
s_logger.debug("Statement is " + pstmt.toString());
|
||||
if (!rs.next()) {
|
||||
return null;
|
||||
}
|
||||
PreallocatedLunVO lun = toEntityBean(rs, false);
|
||||
lun.setTaken(new Date());
|
||||
lun.setVolumeId(volumeId);
|
||||
update(lun.getId(), lun);
|
||||
txn.commit();
|
||||
return lun;
|
||||
} catch (SQLException e) {
|
||||
throw new CloudRuntimeException("Unable to execute " + sql.toString(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override @DB
|
||||
public List<PreallocatedLunVO> listDistinctTargets(long dataCenterId) {
|
||||
String DistinctTargetSearchSql = "SELECT * FROM ext_lun_alloc where data_center_id = ? GROUP BY target_iqn";
|
||||
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
try {
|
||||
PreparedStatement ps = txn.prepareAutoCloseStatement(DistinctTargetSearchSql);
|
||||
ps.setLong(1, dataCenterId);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
List<PreallocatedLunVO> lst = new ArrayList<PreallocatedLunVO>();
|
||||
while (rs.next()) {
|
||||
lst.add(toEntityBean(rs, false));
|
||||
}
|
||||
|
||||
return lst;
|
||||
} catch (SQLException e) {
|
||||
throw new CloudRuntimeException("Unable to execute " + DistinctTargetSearchSql, e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTotalSize(String targetIqn) {
|
||||
SearchCriteria<Long> sc = TotalSizeSearch.create();
|
||||
sc.setParameters("target", targetIqn);
|
||||
|
||||
List<Long> results = customSearchIncludingRemoved(sc, null);
|
||||
if (results.size() == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return results.get(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getUsedSize(String targetIqn) {
|
||||
SearchCriteria<Long> sc = UsedSizeSearch.create();
|
||||
sc.setParameters("target", targetIqn);
|
||||
|
||||
List<Long> results = customSearchIncludingRemoved(sc, null);
|
||||
if (results.size() == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return results.get(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> findDistinctTagsForTarget(String targetIqn) {
|
||||
SearchCriteria<String> sc = DetailsSearch.create();
|
||||
sc.setJoinParameters("target", "targetiqn", targetIqn);
|
||||
return _detailsDao.customSearchIncludingRemoved(sc, null);
|
||||
}
|
||||
|
||||
@Override @DB
|
||||
public PreallocatedLunVO persist(PreallocatedLunVO lun, String[] tags) {
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
lun = persist(lun);
|
||||
for (String tag : tags) {
|
||||
PreallocatedLunDetailVO detail = new PreallocatedLunDetailVO(lun.getId(), tag);
|
||||
_detailsDao.persist(detail);
|
||||
}
|
||||
txn.commit();
|
||||
return lun;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
||||
super.configure(name, params);
|
||||
|
||||
_detailsDao.configure(name, params);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,24 +0,0 @@
|
||||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.cloud.storage.preallocatedlun.dao;
|
||||
|
||||
import com.cloud.storage.preallocatedlun.PreallocatedLunDetailVO;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
public interface PreallocatedLunDetailsDao extends GenericDao<PreallocatedLunDetailVO, Long> {
|
||||
}
|
||||
@ -1,31 +0,0 @@
|
||||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.cloud.storage.preallocatedlun.dao;
|
||||
|
||||
import javax.ejb.Local;
|
||||
|
||||
import com.cloud.storage.preallocatedlun.PreallocatedLunDetailVO;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
|
||||
@Local(value=PreallocatedLunDetailsDao.class) @DB(txn=false)
|
||||
public class PreallocatedLunDetailsDaoImpl extends GenericDaoBase<PreallocatedLunDetailVO, Long> implements PreallocatedLunDetailsDao {
|
||||
protected PreallocatedLunDetailsDaoImpl() {
|
||||
}
|
||||
|
||||
}
|
||||
@ -71,9 +71,7 @@ DROP TABLE IF EXISTS `cloud`.`snapshot_policy`;
|
||||
DROP TABLE IF EXISTS `cloud`.`snapshot_policy_ref`;
|
||||
DROP TABLE IF EXISTS `cloud`.`snapshot_schedule`;
|
||||
DROP TABLE IF EXISTS `cloud`.`op_pod_vlan_alloc`;
|
||||
DROP TABLE IF EXISTS `cloud`.`ext_lun_alloc`;
|
||||
DROP TABLE IF EXISTS `cloud`.`storage_pool_details`;
|
||||
DROP TABLE IF EXISTS `cloud`.`ext_lun_details`;
|
||||
DROP TABLE IF EXISTS `cloud`.`cluster`;
|
||||
DROP TABLE IF EXISTS `cloud`.`nics`;
|
||||
DROP TABLE IF EXISTS `cloud`.`networks`;
|
||||
@ -247,25 +245,6 @@ CREATE TABLE `cloud`.`cluster_details` (
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `cloud`.`ext_lun_alloc` (
|
||||
`id` bigint unsigned NOT NULL UNIQUE AUTO_INCREMENT COMMENT 'id',
|
||||
`size` bigint unsigned NOT NULL COMMENT 'virtual size',
|
||||
`portal` varchar(255) NOT NULL COMMENT 'ip or host name to the storage server',
|
||||
`target_iqn` varchar(255) NOT NULL COMMENT 'target iqn',
|
||||
`data_center_id` bigint unsigned NOT NULL COMMENT 'data center id this belongs to',
|
||||
`lun` int NOT NULL COMMENT 'lun',
|
||||
`taken` datetime COMMENT 'time occupied',
|
||||
`volume_id` bigint unsigned COMMENT 'vm taking this lun',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `cloud`.`ext_lun_details` (
|
||||
`id` bigint unsigned NOT NULL UNIQUE AUTO_INCREMENT COMMENT 'id',
|
||||
`ext_lun_id` bigint unsigned NOT NULL COMMENT 'lun id',
|
||||
`tag` varchar(255) COMMENT 'tags associated with this vm',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `cloud`.`op_host_upgrade` (
|
||||
`host_id` bigint unsigned NOT NULL UNIQUE COMMENT 'host id',
|
||||
`version` varchar(20) NOT NULL COMMENT 'version',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user