/** * 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 . * */ package com.cloud.vm; import com.cloud.hypervisor.Hypervisor.HypervisorType; import com.cloud.offering.DiskOffering; import com.cloud.storage.Volume; /** * DiskCharacteristics describes a disk and what functionality is required from it. * This object is generated by the management server and passed to the allocators * and resources to allocate and create disks. There object is immutable once * it has been created. */ public class DiskProfile { private long size; private String[] tags; private Volume.VolumeType type; private String name; private boolean useLocalStorage; private boolean recreatable; private long diskOfferingId; private Long templateId; private long volumeId; private Volume vol; private DiskOffering offering; private HypervisorType hyperType; protected DiskProfile() { } public DiskProfile(long volumeId, Volume.VolumeType type, String name, long diskOfferingId, long size, String[] tags, boolean useLocalStorage, boolean recreatable, Long templateId) { this.type = type; this.name = name; this.size = size; this.tags = tags; this.useLocalStorage = useLocalStorage; this.recreatable = recreatable; this.diskOfferingId = diskOfferingId; this.templateId = templateId; this.volumeId = volumeId; } public DiskProfile(Volume vol, DiskOffering offering, HypervisorType hyperType) { this(vol.getId(), vol.getVolumeType(), vol.getName(), offering.getId(), vol.getSize(), offering.getTagsArray(), offering.getUseLocalStorage(), offering.getUseLocalStorage(), vol.getSize()); this.vol = vol; this.offering = offering; this.hyperType = hyperType; } /** * @return size of the disk requested in bytes. */ public long getSize() { return size; } /** * @return id of the volume backing up this disk characteristics */ public long getVolumeId() { return volumeId; } /** * @return Unique name for the disk. */ public String getName() { return name; } /** * @return tags for the disk. This can be used to match it to different storage pools. */ public String[] getTags() { return tags; } /** * @return type of volume. */ public Volume.VolumeType getType() { return type; } /** * @return Does this volume require local storage? */ public boolean useLocalStorage() { return useLocalStorage; } /** * @return Is this volume recreatable? A volume is recreatable if the disk's content can be * reconstructed from the template. */ public boolean isRecreatable() { return recreatable; } /** * @return template id the disk is based on. Can be null if it is not based on any templates. */ public Long getTemplateId() { return templateId; } /** * @return disk offering id that the disk is based on. */ public long getDiskOfferingId() { return diskOfferingId; } @Override public String toString() { return new StringBuilder("DskChr[").append(type).append("|").append(size).append("|").append("]").toString(); } public void setHyperType(HypervisorType hyperType) { this.hyperType = hyperType; } public HypervisorType getHypersorType() { return this.hyperType; } }