mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
bug 5909: Implementing the enhancement for adding attach time for volumes. In the case of general VM creation, the attach time is usually~creation time. In the case of attaching a volume to a vm, the time significantly differs. The value is nulled out during the detaching of volume from the vm
status 5909: resolved fixed
This commit is contained in:
parent
5e80d9b31f
commit
b3803d563e
@ -17,6 +17,8 @@
|
||||
*/
|
||||
package com.cloud.storage;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.cloud.domain.PartOf;
|
||||
import com.cloud.template.BasedOn;
|
||||
import com.cloud.user.OwnedBy;
|
||||
@ -86,4 +88,8 @@ public interface Volume extends PartOf, OwnedBy, BasedOn {
|
||||
void setSourceId(Long sourceId);
|
||||
|
||||
Long getSourceId();
|
||||
|
||||
Date getAttached();
|
||||
|
||||
void setAttached(Date attached);
|
||||
}
|
||||
|
||||
@ -64,7 +64,7 @@ public class CreateCommand extends Command {
|
||||
this.pool = new StoragePoolTO(pool);
|
||||
this.templateUrl = null;
|
||||
this.size = size;
|
||||
this.instanceName = vm.getInstanceName();
|
||||
//this.instanceName = vm.getInstanceName();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -90,6 +90,10 @@ public class VolumeVO implements Volume {
|
||||
@Column(name="created")
|
||||
Date created;
|
||||
|
||||
@Column(name="attached")
|
||||
@Temporal(value=TemporalType.TIMESTAMP)
|
||||
Date attached;
|
||||
|
||||
@Column(name="data_center_id")
|
||||
long dataCenterId;
|
||||
|
||||
@ -535,4 +539,15 @@ public class VolumeVO implements Volume {
|
||||
public Long getSourceId(){
|
||||
return this.sourceId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Date getAttached(){
|
||||
return this.attached;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAttached(Date attached){
|
||||
this.attached = attached;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -234,6 +234,7 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol
|
||||
volume.setInstanceId(vmId);
|
||||
volume.setDeviceId(deviceId);
|
||||
volume.setUpdated(new Date());
|
||||
volume.setAttached(new Date());
|
||||
update(volumeId, volume);
|
||||
}
|
||||
|
||||
@ -243,6 +244,7 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol
|
||||
volume.setInstanceId(null);
|
||||
volume.setDeviceId(null);
|
||||
volume.setUpdated(new Date());
|
||||
volume.setAttached(null);
|
||||
update(volumeId, volume);
|
||||
}
|
||||
|
||||
|
||||
@ -153,6 +153,7 @@ public abstract class BaseCmd {
|
||||
CPU_ALLOCATED("cpuallocated", BaseCmd.TYPE_LONG, "cpuallocated"),
|
||||
CPU_USED("cpuused", BaseCmd.TYPE_LONG, "cpuused"),
|
||||
CREATED("created", BaseCmd.TYPE_DATE, "created"),
|
||||
ATTACHED("attached", BaseCmd.TYPE_DATE, "attached"),
|
||||
CROSS_ZONES("crossZones", BaseCmd.TYPE_BOOLEAN, "crosszones"),
|
||||
DAILY_MAX("dailymax", BaseCmd.TYPE_INT, "dailyMax"),
|
||||
DATA_DISK_OFFERING_ID("datadiskofferingid", BaseCmd.TYPE_LONG, "dataDiskOfferingId"),
|
||||
|
||||
@ -194,6 +194,7 @@ public class ListVolumesCmd extends BaseCmd{
|
||||
volumeData.add(new Pair<String, Object>(BaseCmd.Properties.SIZE.getName(), virtualSizeInBytes));
|
||||
|
||||
volumeData.add(new Pair<String, Object>(BaseCmd.Properties.CREATED.getName(), getDateString(volume.getCreated())));
|
||||
volumeData.add(new Pair<String, Object>(BaseCmd.Properties.ATTACHED.getName(), getDateString(volume.getAttached())));
|
||||
volumeData.add(new Pair<String, Object>(BaseCmd.Properties.STATE.getName(),volume.getStatus()));
|
||||
|
||||
Account accountTemp = getManagementServer().findAccountById(volume.getAccountId());
|
||||
|
||||
@ -19,7 +19,11 @@ package com.cloud.storage;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.UnknownHostException;
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.Enumeration;
|
||||
@ -29,6 +33,7 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TimeZone;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
@ -122,8 +127,12 @@ import com.cloud.user.Account;
|
||||
import com.cloud.user.AccountManager;
|
||||
import com.cloud.user.AccountVO;
|
||||
import com.cloud.user.User;
|
||||
import com.cloud.user.UserContext;
|
||||
import com.cloud.user.UserVO;
|
||||
import com.cloud.user.dao.AccountDao;
|
||||
import com.cloud.user.dao.UserDao;
|
||||
import com.cloud.uservm.UserVm;
|
||||
import com.cloud.utils.DateUtil;
|
||||
import com.cloud.utils.NumbersUtil;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.component.Adapters;
|
||||
@ -188,6 +197,7 @@ public class StorageManagerImpl implements StorageManager {
|
||||
@Inject protected VMTemplateDao _templateDao;
|
||||
@Inject protected VMTemplateHostDao _templateHostDao;
|
||||
@Inject protected ServiceOfferingDao _offeringDao;
|
||||
@Inject protected UserDao _userDao;
|
||||
|
||||
protected SearchBuilder<VMTemplateHostVO> HostTemplateStatesSearch;
|
||||
protected SearchBuilder<StoragePoolVO> PoolsUsedByVmSearch;
|
||||
@ -921,6 +931,17 @@ public class StorageManagerImpl implements StorageManager {
|
||||
}
|
||||
|
||||
for (VolumeVO v : volumes) {
|
||||
|
||||
//when the user vm is created, the volume is attached upon creation
|
||||
//set the attached datetime
|
||||
try{
|
||||
v.setAttached(new Date());
|
||||
_volsDao.update(v.getId(), v);
|
||||
}catch(Exception e)
|
||||
{
|
||||
s_logger.warn("Error updating the attached value for volume "+v.getId()+":"+e);
|
||||
}
|
||||
|
||||
long volumeId = v.getId();
|
||||
// Create an event
|
||||
long sizeMB = v.getSize() / (1024 * 1024);
|
||||
|
||||
@ -251,6 +251,7 @@ CREATE TABLE `cloud`.`volumes` (
|
||||
`recreatable` tinyint(1) unsigned NOT NULL DEFAULT 0 COMMENT 'Is this volume recreatable?',
|
||||
`destroyed` tinyint(1) COMMENT 'indicates whether the volume was destroyed by the user or not',
|
||||
`created` datetime COMMENT 'Date Created',
|
||||
`attached` datetime COMMENT 'Date Attached',
|
||||
`updated` datetime COMMENT 'Date updated for attach/detach',
|
||||
`removed` datetime COMMENT 'Date removed. not null if removed',
|
||||
`status` varchar(32) COMMENT 'Async API volume creation status',
|
||||
|
||||
@ -9,3 +9,4 @@ ALTER TABLE `cloud`.`resource_count` MODIFY COLUMN `account_id` bigint unsigned;
|
||||
ALTER TABLE `cloud`.`storage_pool` add COLUMN STATUS varchar(32) not null; -- new status column for maintenance mode support for primary storage
|
||||
ALTER TABLE `cloud`.`volumes` ADD COLUMN `source_id` bigint unsigned; -- id for the source
|
||||
ALTER TABLE `cloud`.`volumes` ADD COLUMN `source_type` varchar(32); --source from which the volume is created i.e. snapshot, diskoffering, template, blank
|
||||
ALTER TABLE `cloud`.`volumes` ADD COLUMN 'attached' datetime; --date and time the volume was attached
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user