diff --git a/api/src/com/cloud/hypervisor/Hypervisor.java b/api/src/com/cloud/hypervisor/Hypervisor.java index a4ee5b98fd9..710ddfce458 100644 --- a/api/src/com/cloud/hypervisor/Hypervisor.java +++ b/api/src/com/cloud/hypervisor/Hypervisor.java @@ -16,6 +16,8 @@ // under the License. package com.cloud.hypervisor; +import com.cloud.storage.Storage.ImageFormat; + public class Hypervisor { public static enum HypervisorType { @@ -63,6 +65,26 @@ public class Hypervisor { return HypervisorType.None; } } + + /** + * This method really needs to be part of the properties of the hypervisor type itself. + * + * @param hyperType + * @return + */ + public static ImageFormat getSupportedImageFormat(HypervisorType hyperType) { + if (hyperType == HypervisorType.XenServer) { + return ImageFormat.VHD; + } else if (hyperType == HypervisorType.KVM) { + return ImageFormat.QCOW2; + } else if (hyperType == HypervisorType.VMware) { + return ImageFormat.OVA; + } else if (hyperType == HypervisorType.Ovm) { + return ImageFormat.RAW; + } else { + return null; + } + } } } diff --git a/api/src/com/cloud/offering/DiskOffering.java b/api/src/com/cloud/offering/DiskOffering.java index 9c196e08b69..587d4a0f17d 100644 --- a/api/src/com/cloud/offering/DiskOffering.java +++ b/api/src/com/cloud/offering/DiskOffering.java @@ -65,6 +65,8 @@ public interface DiskOffering extends InfrastructureEntity, Identity, InternalId Long getMaxIops(); + boolean isRecreatable(); + void setBytesReadRate(Long bytesReadRate); Long getBytesReadRate(); diff --git a/api/src/com/cloud/offering/ServiceOffering.java b/api/src/com/cloud/offering/ServiceOffering.java index 45d5f38952b..9f7bf8e1315 100755 --- a/api/src/com/cloud/offering/ServiceOffering.java +++ b/api/src/com/cloud/offering/ServiceOffering.java @@ -25,7 +25,7 @@ import org.apache.cloudstack.api.InternalIdentity; /** * offered. */ -public interface ServiceOffering extends InfrastructureEntity, InternalIdentity, Identity { +public interface ServiceOffering extends DiskOffering, InfrastructureEntity, InternalIdentity, Identity { public static final String consoleProxyDefaultOffUniqueName = "Cloud.com-ConsoleProxy"; public static final String ssvmDefaultOffUniqueName = "Cloud.com-SecondaryStorage"; public static final String routerDefaultOffUniqueName = "Cloud.Com-SoftwareRouter"; @@ -37,20 +37,25 @@ public interface ServiceOffering extends InfrastructureEntity, InternalIdentity, shared } + @Override String getDisplayText(); + @Override Date getCreated(); + @Override String getTags(); /** * @return user readable description */ + @Override String getName(); /** * @return is this a system service offering */ + @Override boolean getSystemUse(); /** @@ -96,8 +101,10 @@ public interface ServiceOffering extends InfrastructureEntity, InternalIdentity, /** * @return whether or not the service offering requires local storage */ + @Override boolean getUseLocalStorage(); + @Override Long getDomainId(); /** diff --git a/engine/schema/src/com/cloud/migration/DiskOffering20Dao.java b/engine/schema/src/com/cloud/migration/DiskOffering20Dao.java deleted file mode 100644 index ce22f48c3b9..00000000000 --- a/engine/schema/src/com/cloud/migration/DiskOffering20Dao.java +++ /dev/null @@ -1,22 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -package com.cloud.migration; - -import com.cloud.utils.db.GenericDao; - -public interface DiskOffering20Dao extends GenericDao { -} diff --git a/engine/schema/src/com/cloud/migration/DiskOffering20DaoImpl.java b/engine/schema/src/com/cloud/migration/DiskOffering20DaoImpl.java deleted file mode 100644 index e0eb40eafa8..00000000000 --- a/engine/schema/src/com/cloud/migration/DiskOffering20DaoImpl.java +++ /dev/null @@ -1,27 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -package com.cloud.migration; - -import javax.ejb.Local; - -import org.springframework.stereotype.Component; - -import com.cloud.utils.db.GenericDaoBase; - -@Local(value={DiskOffering20Dao.class}) -public class DiskOffering20DaoImpl extends GenericDaoBase implements DiskOffering20Dao { -} diff --git a/engine/schema/src/com/cloud/migration/DiskOffering20VO.java b/engine/schema/src/com/cloud/migration/DiskOffering20VO.java deleted file mode 100644 index e50328d7cd7..00000000000 --- a/engine/schema/src/com/cloud/migration/DiskOffering20VO.java +++ /dev/null @@ -1,113 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -package com.cloud.migration; - -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 com.cloud.utils.db.GenericDao; -import org.apache.cloudstack.api.InternalIdentity; - -@Entity -@Table(name="disk_offering") -public class DiskOffering20VO implements InternalIdentity { - @Id - @GeneratedValue(strategy=GenerationType.IDENTITY) - @Column(name="id") - Long id; - - @Column(name="domain_id") - long domainId; - - @Column(name="name") - private String name = null; - - @Column(name="display_text") - private String displayText = null; - - @Column(name="disk_size") - long diskSize; - - @Column(name="mirrored") - boolean mirrored; - - @Column(name=GenericDao.REMOVED_COLUMN) - private Date removed; - - public DiskOffering20VO() { - } - - public DiskOffering20VO(long domainId, String name, String displayText, long diskSize, boolean mirrored) { - this.domainId = domainId; - this.name = name; - this.displayText = displayText; - this.diskSize = diskSize; - this.mirrored = mirrored; - } - - public long getId() { - return id; - } - public void setId(Long id) { - this.id = id; - } - - public long getDomainId() { - return domainId; - } - public void setDomainId(long domainId) { - this.domainId = domainId; - } - - public String getName() { - return name; - } - public void setName(String name) { - this.name = name; - } - - public String getDisplayText() { - return displayText; - } - public void setDisplayText(String displayText) { - this.displayText = displayText; - } - - public long getDiskSize() { - return diskSize; - } - public void setDiskSize(long diskSize) { - this.diskSize = diskSize; - } - - public boolean getMirrored() { - return mirrored; - } - public void setMirrored(boolean mirrored) { - this.mirrored = mirrored; - } - - public Date getRemoved() { - return removed; - } -} diff --git a/engine/schema/src/com/cloud/migration/DiskOffering21Dao.java b/engine/schema/src/com/cloud/migration/DiskOffering21Dao.java deleted file mode 100644 index 21781ea2af5..00000000000 --- a/engine/schema/src/com/cloud/migration/DiskOffering21Dao.java +++ /dev/null @@ -1,23 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -package com.cloud.migration; - -import com.cloud.utils.db.GenericDao; - -public interface DiskOffering21Dao extends GenericDao { -} - diff --git a/engine/schema/src/com/cloud/migration/DiskOffering21DaoImpl.java b/engine/schema/src/com/cloud/migration/DiskOffering21DaoImpl.java deleted file mode 100644 index b67d8fbaf8b..00000000000 --- a/engine/schema/src/com/cloud/migration/DiskOffering21DaoImpl.java +++ /dev/null @@ -1,27 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -package com.cloud.migration; - -import javax.ejb.Local; - -import org.springframework.stereotype.Component; - -import com.cloud.utils.db.GenericDaoBase; - -@Local(value={DiskOffering21Dao.class}) -public class DiskOffering21DaoImpl extends GenericDaoBase implements DiskOffering21Dao { -} diff --git a/engine/schema/src/com/cloud/migration/DiskOffering21VO.java b/engine/schema/src/com/cloud/migration/DiskOffering21VO.java deleted file mode 100644 index 593f7ba61ff..00000000000 --- a/engine/schema/src/com/cloud/migration/DiskOffering21VO.java +++ /dev/null @@ -1,257 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -package com.cloud.migration; - -import java.util.Date; -import java.util.List; - -import javax.persistence.Column; -import javax.persistence.DiscriminatorColumn; -import javax.persistence.DiscriminatorType; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.Inheritance; -import javax.persistence.InheritanceType; -import javax.persistence.Table; -import javax.persistence.Transient; - -import com.cloud.utils.db.GenericDao; -import org.apache.cloudstack.api.InternalIdentity; - -@Entity -@Table(name="disk_offering_21") -@Inheritance(strategy=InheritanceType.JOINED) -@DiscriminatorColumn(name="type", discriminatorType=DiscriminatorType.STRING, length=32) -public class DiskOffering21VO implements InternalIdentity { - public enum Type { - Disk, - Service - }; - - @Id - @GeneratedValue(strategy=GenerationType.AUTO) - @Column(name="id") - long id; - - @Column(name="domain_id") - Long domainId; - - @Column(name="unique_name") - private String uniqueName; - - @Column(name="name") - private String name = null; - - @Column(name="display_text") - private String displayText = null; - - @Column(name="disk_size") - long diskSize; - - @Column(name="mirrored") - boolean mirrored; - - @Column(name="tags") - String tags; - - @Column(name="type") - Type type; - - @Column(name=GenericDao.REMOVED_COLUMN) - private Date removed; - - @Column(name=GenericDao.CREATED_COLUMN) - private Date created; - - @Column(name="recreatable") - private boolean recreatable; - - @Column(name="use_local_storage") - private boolean useLocalStorage; - - @Column(name="system_use") - protected boolean systemUse; - - - public DiskOffering21VO() { - } - - public DiskOffering21VO(long domainId, String name, String displayText, long diskSize, boolean mirrored, String tags) { - this.domainId = domainId; - this.name = name; - this.displayText = displayText; - this.diskSize = diskSize; - this.mirrored = mirrored; - this.tags = tags; - this.recreatable = false; - this.type = Type.Disk; - this.useLocalStorage = false; - } - - public DiskOffering21VO(String name, String displayText, boolean mirrored, String tags, boolean recreatable, boolean useLocalStorage) { - this.domainId = null; - this.type = Type.Service; - this.name = name; - this.displayText = displayText; - this.mirrored = mirrored; - this.tags = tags; - this.recreatable = recreatable; - this.useLocalStorage = useLocalStorage; - } - - public long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getUniqueName() { - return uniqueName; - } - - public boolean getSystemUse() { - return systemUse; - } - - public void setSystemUse(boolean systemUse) { - this.systemUse = systemUse; - } - - public boolean getUseLocalStorage() { - return useLocalStorage; - } - - public void setUserLocalStorage(boolean useLocalStorage) { - this.useLocalStorage = useLocalStorage; - } - - public Long getDomainId() { - return domainId; - } - - public Type getType() { - return type; - } - - public void setType(Type type) { - this.type = type; - } - - public boolean isRecreatable() { - return recreatable; - } - - public void setDomainId(Long domainId) { - this.domainId = domainId; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getDisplayText() { - return displayText; - } - public void setDisplayText(String displayText) { - this.displayText = displayText; - } - - public long getDiskSizeInBytes() { - return diskSize * 1024 * 1024; - } - - public void setDiskSize(long diskSize) { - this.diskSize = diskSize; - } - - public boolean isMirrored() { - return mirrored; - } - public void setMirrored(boolean mirrored) { - this.mirrored = mirrored; - } - - public Date getRemoved() { - return removed; - } - - public Date getCreated() { - return created; - } - - protected void setTags(String tags) { - this.tags = tags; - } - - public String getTags() { - return tags; - } - - public void setUniqueName(String name) { - this.uniqueName = name; - } - - @Transient - public String[] getTagsArray() { - String tags = getTags(); - if (tags == null || tags.isEmpty()) { - return new String[0]; - } - - return tags.split(","); - } - - @Transient - public boolean containsTag(String... tags) { - if (this.tags == null) { - return false; - } - - for (String tag : tags) { - if (!this.tags.matches(tag)) { - return false; - } - } - - return true; - } - - @Transient - public void setTagsArray(List newTags) { - if (newTags.isEmpty()) { - setTags(null); - return; - } - - StringBuilder buf = new StringBuilder(); - for (String tag : newTags) { - buf.append(tag).append(","); - } - - buf.delete(buf.length() - 1, buf.length()); - - setTags(buf.toString()); - } -} diff --git a/engine/schema/src/com/cloud/migration/ServiceOffering20Dao.java b/engine/schema/src/com/cloud/migration/ServiceOffering20Dao.java deleted file mode 100644 index e87b6843f1c..00000000000 --- a/engine/schema/src/com/cloud/migration/ServiceOffering20Dao.java +++ /dev/null @@ -1,22 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -package com.cloud.migration; - -import com.cloud.utils.db.GenericDao; - -public interface ServiceOffering20Dao extends GenericDao { -} diff --git a/engine/schema/src/com/cloud/migration/ServiceOffering20DaoImpl.java b/engine/schema/src/com/cloud/migration/ServiceOffering20DaoImpl.java deleted file mode 100644 index f67949e5a0b..00000000000 --- a/engine/schema/src/com/cloud/migration/ServiceOffering20DaoImpl.java +++ /dev/null @@ -1,27 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -package com.cloud.migration; - -import javax.ejb.Local; - -import org.springframework.stereotype.Component; - -import com.cloud.utils.db.GenericDaoBase; - -@Local(value={ServiceOffering20Dao.class}) -public class ServiceOffering20DaoImpl extends GenericDaoBase implements ServiceOffering20Dao { -} diff --git a/engine/schema/src/com/cloud/migration/ServiceOffering20VO.java b/engine/schema/src/com/cloud/migration/ServiceOffering20VO.java deleted file mode 100644 index bed29ecf3b9..00000000000 --- a/engine/schema/src/com/cloud/migration/ServiceOffering20VO.java +++ /dev/null @@ -1,199 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -package com.cloud.migration; - -import java.util.Date; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.EnumType; -import javax.persistence.Enumerated; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.Table; - -import com.cloud.dc.Vlan; -import com.cloud.dc.Vlan.VlanType; -import com.cloud.utils.db.GenericDao; -import org.apache.cloudstack.api.InternalIdentity; - -@Entity -@Table(name="service_offering") -public class ServiceOffering20VO implements InternalIdentity { - @Id - @GeneratedValue(strategy=GenerationType.IDENTITY) - @Column(name="id") - private Long id = null; - - @Column(name="name") - private String name = null; - - @Column(name="cpu") - private int cpu; - - @Column(name="speed") - private int speed; - - @Column(name="ram_size") - private int ramSize; - - @Column(name="nw_rate") - private int rateMbps; - - @Column(name="mc_rate") - private int multicastRateMbps; - - @Column(name="mirrored") - private boolean mirroredVolumes; - - @Column(name="ha_enabled") - private boolean offerHA; - - @Column(name="display_text") - private String displayText = null; - - @Column(name="guest_ip_type") - @Enumerated(EnumType.STRING) - private Vlan.VlanType guestIpType = Vlan.VlanType.VirtualNetwork; - - @Column(name="use_local_storage") - private boolean useLocalStorage; - - @Column(name=GenericDao.CREATED_COLUMN) - private Date created; - - @Column(name=GenericDao.REMOVED_COLUMN) - private Date removed; - - protected ServiceOffering20VO() { - } - - public ServiceOffering20VO(Long id, String name, int cpu, int ramSize, int speed, int rateMbps, int multicastRateMbps, boolean offerHA, String displayText, boolean localStorageRequired) { - this(id, name, cpu, ramSize, speed, rateMbps, multicastRateMbps, offerHA, displayText, Vlan.VlanType.VirtualNetwork, localStorageRequired); - } - - public ServiceOffering20VO(Long id, String name, int cpu, int ramSize, int speed, int rateMbps, int multicastRateMbps, boolean offerHA, String displayText, VlanType guestIpType, boolean useLocalStorage) { - this.id = id; - this.name = name; - this.cpu = cpu; - this.ramSize = ramSize; - this.speed = speed; - this.rateMbps = rateMbps; - this.multicastRateMbps = multicastRateMbps; - this.offerHA = offerHA; - this.displayText = displayText; - this.guestIpType = guestIpType; - this.useLocalStorage = useLocalStorage; - } - - public boolean getOfferHA() { - return offerHA; - } - - public void setOfferHA(boolean offerHA) { - this.offerHA = offerHA; - } - - public long getId() { - return id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public int getCpu() { - return cpu; - } - - public void setCpu(int cpu) { - this.cpu = cpu; - } - - public void setSpeed(int speed) { - this.speed = speed; - } - - public void setRamSize(int ramSize) { - this.ramSize = ramSize; - } - - public int getSpeed() { - return speed; - } - - public int getRamSize() { - return ramSize; - } - - public Date getCreated() { - return created; - } - - public Date getRemoved() { - return removed; - } - - public void setMirroredVolumes(boolean mirroredVolumes) { - this.mirroredVolumes = mirroredVolumes; - } - - public boolean isMirroredVolumes() { - return mirroredVolumes; - } - - public String getDisplayText() { - return displayText; - } - - public void setDisplayText(String displayText) { - this.displayText = displayText; - } - - public void setRateMbps(int rateMbps) { - this.rateMbps = rateMbps; - } - - public int getRateMbps() { - return rateMbps; - } - - public void setMulticastRateMbps(int multicastRateMbps) { - this.multicastRateMbps = multicastRateMbps; - } - - public int getMulticastRateMbps() { - return multicastRateMbps; - } - - public void setGuestIpType(Vlan.VlanType guestIpType) { - this.guestIpType = guestIpType; - } - - public Vlan.VlanType getGuestIpType() { - return guestIpType; - } - - public boolean getUseLocalStorage() { - return useLocalStorage; - } -} diff --git a/engine/schema/src/com/cloud/migration/ServiceOffering21Dao.java b/engine/schema/src/com/cloud/migration/ServiceOffering21Dao.java deleted file mode 100644 index eece426465e..00000000000 --- a/engine/schema/src/com/cloud/migration/ServiceOffering21Dao.java +++ /dev/null @@ -1,22 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -package com.cloud.migration; - -import com.cloud.utils.db.GenericDao; - -public interface ServiceOffering21Dao extends GenericDao { -} diff --git a/engine/schema/src/com/cloud/migration/ServiceOffering21DaoImpl.java b/engine/schema/src/com/cloud/migration/ServiceOffering21DaoImpl.java deleted file mode 100644 index ce24191432c..00000000000 --- a/engine/schema/src/com/cloud/migration/ServiceOffering21DaoImpl.java +++ /dev/null @@ -1,27 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -package com.cloud.migration; - -import javax.ejb.Local; - -import org.springframework.stereotype.Component; - -import com.cloud.utils.db.GenericDaoBase; - -@Local(value={ServiceOffering21Dao.class}) -public class ServiceOffering21DaoImpl extends GenericDaoBase implements ServiceOffering21Dao { -} diff --git a/engine/schema/src/com/cloud/migration/ServiceOffering21VO.java b/engine/schema/src/com/cloud/migration/ServiceOffering21VO.java deleted file mode 100644 index 7a49e63e5b3..00000000000 --- a/engine/schema/src/com/cloud/migration/ServiceOffering21VO.java +++ /dev/null @@ -1,183 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -package com.cloud.migration; - -import javax.persistence.Column; -import javax.persistence.DiscriminatorValue; -import javax.persistence.Entity; -import javax.persistence.PrimaryKeyJoinColumn; -import javax.persistence.Table; -import javax.persistence.Transient; - -import com.cloud.offering.ServiceOffering; - -@Entity -@Table(name="service_offering_21") -@DiscriminatorValue(value="Service") -@PrimaryKeyJoinColumn(name="id") -public class ServiceOffering21VO extends DiskOffering21VO implements ServiceOffering { - @Column(name="cpu") - private int cpu; - - @Column(name="speed") - private int speed; - - @Column(name="ram_size") - private int ramSize; - - @Column(name="nw_rate") - private Integer rateMbps; - - @Column(name="mc_rate") - private Integer multicastRateMbps; - - @Column(name="ha_enabled") - private boolean offerHA; - - @Column(name="host_tag") - private String hostTag; - - protected ServiceOffering21VO() { - super(); - } - - public ServiceOffering21VO(String name, int cpu, int ramSize, int speed, Integer rateMbps, Integer multicastRateMbps, boolean offerHA, String displayText, boolean useLocalStorage, boolean recreatable, String tags) { - super(name, displayText, false, tags, recreatable, useLocalStorage); - this.cpu = cpu; - this.ramSize = ramSize; - this.speed = speed; - this.rateMbps = rateMbps; - this.multicastRateMbps = multicastRateMbps; - this.offerHA = offerHA; - } - - public ServiceOffering21VO(String name, int cpu, int ramSize, int speed, Integer rateMbps, Integer multicastRateMbps, boolean offerHA, String displayText, boolean useLocalStorage, boolean recreatable, String tags, String hostTag) { - this(name, cpu, ramSize, speed, rateMbps, multicastRateMbps, offerHA, displayText, useLocalStorage, recreatable, tags); - this.hostTag = hostTag; - } - - - @Override - public boolean getOfferHA() { - return offerHA; - } - - @Override - public boolean getLimitCpuUse() { - return false; - } - - public void setOfferHA(boolean offerHA) { - this.offerHA = offerHA; - } - - @Override - @Transient - public String[] getTagsArray() { - String tags = getTags(); - if (tags == null || tags.length() == 0) { - return new String[0]; - } - - return tags.split(","); - } - - @Override - public int getCpu() { - return cpu; - } - - public void setCpu(int cpu) { - this.cpu = cpu; - } - - public void setSpeed(int speed) { - this.speed = speed; - } - - public void setRamSize(int ramSize) { - this.ramSize = ramSize; - } - - @Override - public int getSpeed() { - return speed; - } - - @Override - public int getRamSize() { - return ramSize; - } - - public void setRateMbps(Integer rateMbps) { - this.rateMbps = rateMbps; - } - - @Override - public Integer getRateMbps() { - return rateMbps; - } - - public void setMulticastRateMbps(Integer multicastRateMbps) { - this.multicastRateMbps = multicastRateMbps; - } - - @Override - public Integer getMulticastRateMbps() { - return multicastRateMbps; - } - - public String gethypervisorType() { - return null; - } - - public void setHostTag(String hostTag) { - this.hostTag = hostTag; - } - - public String getHostTag() { - return hostTag; - } - - @Override - public boolean getDefaultUse() { - return false; - } - - @Override - public String getSystemVmType() { - return null; - } - - @Override - public String getUuid() { - // TODO Auto-generated method stub - return null; - } - - @Override - public boolean getVolatileVm() { - return false; - } - - @Override - public String getDeploymentPlanner() { - // TODO Auto-generated method stub - return null; - } - -} diff --git a/server/src/com/cloud/storage/VolumeManager.java b/server/src/com/cloud/storage/VolumeManager.java index d95a8149fe1..944abc0c18f 100644 --- a/server/src/com/cloud/storage/VolumeManager.java +++ b/server/src/com/cloud/storage/VolumeManager.java @@ -20,37 +20,25 @@ package com.cloud.storage; import java.util.Map; -import org.apache.cloudstack.api.command.user.volume.AttachVolumeCmd; -import org.apache.cloudstack.api.command.user.volume.CreateVolumeCmd; -import org.apache.cloudstack.api.command.user.volume.DetachVolumeCmd; -import org.apache.cloudstack.api.command.user.volume.MigrateVolumeCmd; -import org.apache.cloudstack.api.command.user.volume.ResizeVolumeCmd; -import org.apache.cloudstack.api.command.user.volume.UploadVolumeCmd; import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo; import com.cloud.agent.api.to.VirtualMachineTO; import com.cloud.deploy.DeployDestination; import com.cloud.exception.ConcurrentOperationException; import com.cloud.exception.InsufficientStorageCapacityException; -import com.cloud.exception.ResourceAllocationException; import com.cloud.exception.StorageUnavailableException; import com.cloud.host.Host; import com.cloud.hypervisor.Hypervisor.HypervisorType; import com.cloud.storage.Volume.Type; import com.cloud.user.Account; +import com.cloud.utils.fsm.NoTransitionException; import com.cloud.vm.DiskProfile; import com.cloud.vm.VMInstanceVO; import com.cloud.vm.VirtualMachine; import com.cloud.vm.VirtualMachineProfile; -public interface VolumeManager extends VolumeApiService { - VolumeInfo moveVolume(VolumeInfo volume, long destPoolDcId, Long destPoolPodId, - Long destPoolClusterId, HypervisorType dataDiskHyperType) - throws ConcurrentOperationException; - - @Override - VolumeVO uploadVolume(UploadVolumeCmd cmd) - throws ResourceAllocationException; +public interface VolumeManager { + VolumeInfo moveVolume(VolumeInfo volume, long destPoolDcId, Long destPoolPodId, Long destPoolClusterId, HypervisorType dataDiskHyperType) throws ConcurrentOperationException; VolumeVO allocateDuplicateVolume(VolumeVO oldVol, Long templateId); @@ -60,54 +48,29 @@ public interface VolumeManager extends VolumeApiService { String getVmNameOnVolume(Volume volume); - @Override - VolumeVO allocVolume(CreateVolumeCmd cmd) - throws ResourceAllocationException; - - @Override - VolumeVO createVolume(CreateVolumeCmd cmd); - - @Override - VolumeVO resizeVolume(ResizeVolumeCmd cmd) - throws ResourceAllocationException; - - @Override - boolean deleteVolume(long volumeId, Account caller) - throws ConcurrentOperationException; + Volume migrateVolume(Volume volume, StoragePool destPool); void destroyVolume(VolumeVO volume); DiskProfile allocateRawVolume(Type type, String name, DiskOfferingVO offering, Long size, VMInstanceVO vm, VMTemplateVO template, Account owner); - @Override - Volume attachVolumeToVM(AttachVolumeCmd command); - @Override - Volume detachVolumeFromVM(DetachVolumeCmd cmmd); + VolumeInfo createVolumeOnPrimaryStorage(VMInstanceVO vm, VolumeVO rootVolumeOfVm, VolumeInfo volume, HypervisorType rootDiskHyperType) throws NoTransitionException; void release(VirtualMachineProfile profile); void cleanupVolumes(long vmId) throws ConcurrentOperationException; - @Override - Volume migrateVolume(MigrateVolumeCmd cmd); - - void migrateVolumes(VirtualMachine vm, VirtualMachineTO vmTo, Host srcHost, Host destHost, - Map volumeToPool); + void migrateVolumes(VirtualMachine vm, VirtualMachineTO vmTo, Host srcHost, Host destHost, Map volumeToPool); boolean storageMigration(VirtualMachineProfile vm, StoragePool destPool); void prepareForMigration(VirtualMachineProfile vm, DeployDestination dest); - void prepare(VirtualMachineProfile vm, - DeployDestination dest) throws StorageUnavailableException, - InsufficientStorageCapacityException, ConcurrentOperationException; + void prepare(VirtualMachineProfile vm, DeployDestination dest) throws StorageUnavailableException, InsufficientStorageCapacityException, ConcurrentOperationException; boolean canVmRestartOnAnotherServer(long vmId); - DiskProfile allocateTemplatedVolume(Type type, String name, - DiskOfferingVO offering, VMTemplateVO template, VMInstanceVO vm, - Account owner); - + DiskProfile allocateTemplatedVolume(Type type, String name, DiskOfferingVO offering, VMTemplateVO template, VMInstanceVO vm, Account owner); String getVmNameFromVolumeId(long volumeId); diff --git a/server/src/com/cloud/user/AccountManagerImpl.java b/server/src/com/cloud/user/AccountManagerImpl.java index c0901603763..2f11fae2c8c 100755 --- a/server/src/com/cloud/user/AccountManagerImpl.java +++ b/server/src/com/cloud/user/AccountManagerImpl.java @@ -110,7 +110,7 @@ import com.cloud.projects.dao.ProjectDao; import com.cloud.server.auth.UserAuthenticator; import com.cloud.storage.VMTemplateVO; import com.cloud.storage.Volume; -import com.cloud.storage.VolumeManager; +import com.cloud.storage.VolumeApiService; import com.cloud.storage.VolumeVO; import com.cloud.storage.dao.SnapshotDao; import com.cloud.storage.dao.VMTemplateDao; @@ -225,7 +225,8 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M Site2SiteVpnManager _vpnMgr; @Inject private AutoScaleManager _autoscaleMgr; - @Inject VolumeManager volumeMgr; + @Inject + VolumeApiService volumeService; @Inject private AffinityGroupDao _affinityGroupDao; @Inject @@ -623,7 +624,7 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M for (VolumeVO volume : volumes) { if (!volume.getState().equals(Volume.State.Destroy)) { try { - volumeMgr.deleteVolume(volume.getId(), caller); + volumeService.deleteVolume(volume.getId(), caller); } catch (Exception ex) { s_logger.warn("Failed to cleanup volumes as a part of account id=" + accountId + " cleanup due to Exception: ", ex); accountCleanupNeeded = true;