Return-Path: X-Original-To: apmail-cloudstack-commits-archive@www.apache.org Delivered-To: apmail-cloudstack-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 2099BFCD7 for ; Thu, 25 Apr 2013 13:06:26 +0000 (UTC) Received: (qmail 9261 invoked by uid 500); 25 Apr 2013 13:06:26 -0000 Delivered-To: apmail-cloudstack-commits-archive@cloudstack.apache.org Received: (qmail 9235 invoked by uid 500); 25 Apr 2013 13:06:25 -0000 Mailing-List: contact commits-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list commits@cloudstack.apache.org Received: (qmail 9198 invoked by uid 99); 25 Apr 2013 13:06:24 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 25 Apr 2013 13:06:24 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 4E6A2881115; Thu, 25 Apr 2013 13:06:24 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: nitin@apache.org To: commits@cloudstack.apache.org Date: Thu, 25 Apr 2013 13:06:24 -0000 Message-Id: <22e6e2d21ec74c53ad62dfb57d9b7ced@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [1/2] =initial changes Updated Branches: refs/heads/cs2163 [created] d1642a489 http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d1642a48/api/test/org/apache/cloudstack/api/command/test/updateNicDetailCmdTest.java ---------------------------------------------------------------------- diff --git a/api/test/org/apache/cloudstack/api/command/test/updateNicDetailCmdTest.java b/api/test/org/apache/cloudstack/api/command/test/updateNicDetailCmdTest.java new file mode 100644 index 0000000..7143e2c --- /dev/null +++ b/api/test/org/apache/cloudstack/api/command/test/updateNicDetailCmdTest.java @@ -0,0 +1,62 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for updateitional 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 org.apache.cloudstack.api.command.test; + +import com.cloud.network.NetworkService; +import junit.framework.Assert; +import junit.framework.TestCase; +import org.apache.cloudstack.api.ResponseGenerator; + +import org.apache.cloudstack.api.command.user.network.UpdateNicDetailCmd; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.mockito.Mockito; +import static org.mockito.Mockito.*; + + +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + + +public class updateNicDetailCmdTest extends TestCase{ + + private UpdateNicDetailCmd updateNicDetailCmd; + private ResponseGenerator responseGenerator; + + @Rule + public ExpectedException expectedException = ExpectedException.none(); + + @Before + public void setUp() { + + updateNicDetailCmd = new UpdateNicDetailCmd(); + + } + + + @Test + public void testCreateSuccess() { + + NetworkService networkService = Mockito.mock(NetworkService.class); + doNothing().when(networkService).updateNicDetail(updateNicDetailCmd); + + } + +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d1642a48/client/tomcatconf/commands.properties.in ---------------------------------------------------------------------- diff --git a/client/tomcatconf/commands.properties.in b/client/tomcatconf/commands.properties.in index b49e1fb..c4d0fcf 100644 --- a/client/tomcatconf/commands.properties.in +++ b/client/tomcatconf/commands.properties.in @@ -269,6 +269,10 @@ listVolumes=15 extractVolume=15 migrateVolume=15 resizeVolume=15 +addVolumeDetail=15 +updateVolumeDetail=15 +removeVolumeDetail=15 +listVolumeDetails=15 #### registration command: FIXME -- this really should be something in management server that #### generates a new key for the user and they just have to @@ -339,6 +343,9 @@ updateNetwork=15 addNicToVirtualMachine=15 removeNicFromVirtualMachine=15 updateDefaultNicForVirtualMachine=15 +addNicDetail=15 +updateNicDetail=15 +removeNicDetail=15 #### addIpToNic=15 http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d1642a48/core/src/com/cloud/storage/DiskOfferingVO.java ---------------------------------------------------------------------- diff --git a/core/src/com/cloud/storage/DiskOfferingVO.java b/core/src/com/cloud/storage/DiskOfferingVO.java index e4fc21c..909d7fe 100755 --- a/core/src/com/cloud/storage/DiskOfferingVO.java +++ b/core/src/com/cloud/storage/DiskOfferingVO.java @@ -100,6 +100,9 @@ public class DiskOfferingVO implements DiskOffering { @Column(name="sort_key") int sortKey; + @Column(name="display_offering") + boolean displayOffering; + public DiskOfferingVO() { this.uuid = UUID.randomUUID().toString(); } @@ -315,4 +318,13 @@ public class DiskOfferingVO implements DiskOffering { public void setRecreatable(boolean recreatable) { this.recreatable = recreatable; } + + + public boolean getDisplayOffering() { + return displayOffering; + } + + public void setDisplayOffering(boolean displayOffering) { + this.displayOffering = displayOffering; + } } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d1642a48/core/src/com/cloud/storage/VolumeDetailVO.java ---------------------------------------------------------------------- diff --git a/core/src/com/cloud/storage/VolumeDetailVO.java b/core/src/com/cloud/storage/VolumeDetailVO.java new file mode 100644 index 0000000..b0c8c1d --- /dev/null +++ b/core/src/com/cloud/storage/VolumeDetailVO.java @@ -0,0 +1,85 @@ +// 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.storage; + +import org.apache.cloudstack.api.InternalIdentity; + +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="volume_details") +public class VolumeDetailVO implements InternalIdentity { + @Id + @GeneratedValue(strategy=GenerationType.IDENTITY) + @Column(name="id") + private long id; + + @Column(name="volume_id") + private long volumeId; + + @Column(name="name") + private String name; + + @Column(name="value", length=1024) + private String value; + + public VolumeDetailVO() {} + + public VolumeDetailVO(long volumeId, String name, String value) { + this.volumeId = volumeId; + this.name = name; + this.value = value; + } + + public long getId() { + return id; + } + + public long getVolumeId() { + return volumeId; + } + + public String getName() { + return name; + } + + public String getValue() { + return value; + } + + public void setId(long id) { + this.id = id; + } + + public void setVolumeId(long volumeId) { + this.volumeId = volumeId; + } + + public void setName(String name) { + this.name = name; + } + + public void setValue(String value) { + this.value = value; + } + +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d1642a48/core/src/com/cloud/storage/VolumeVO.java ---------------------------------------------------------------------- diff --git a/core/src/com/cloud/storage/VolumeVO.java b/core/src/com/cloud/storage/VolumeVO.java index a287c26..1699afd 100755 --- a/core/src/com/cloud/storage/VolumeVO.java +++ b/core/src/com/cloud/storage/VolumeVO.java @@ -130,7 +130,10 @@ public class VolumeVO implements Volume { @Column(name = "uuid") String uuid; - + + @Column(name="display_volume", updatable=true, nullable=false) + protected boolean displayVolume; + @Transient // @Column(name="reservation") String reservationId; @@ -451,4 +454,13 @@ public class VolumeVO implements Volume { public void setUuid(String uuid) { this.uuid = uuid; } + + + public boolean isDisplayVolume() { + return displayVolume; + } + + public void setDisplayVolume(boolean displayVolume) { + this.displayVolume = displayVolume; + } } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d1642a48/core/src/com/cloud/vm/VMInstanceVO.java ---------------------------------------------------------------------- diff --git a/core/src/com/cloud/vm/VMInstanceVO.java b/core/src/com/cloud/vm/VMInstanceVO.java index 77e9c02..5f93019 100644 --- a/core/src/com/cloud/vm/VMInstanceVO.java +++ b/core/src/com/cloud/vm/VMInstanceVO.java @@ -111,6 +111,9 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject { this(that.getSize(), that.getVolumeType(), that.getName(), that.getTemplateId()); this.recreatable = that.isRecreatable(); this.state = that.getState(); + this.size = that.getSize(); this.diskOfferingId = that.getDiskOfferingId(); this.poolId = that.getPoolId(); @@ -413,4 +414,5 @@ public class VolumeVO implements Identity, StateObject { public void setDiskType(DiskFormat type) { diskType = type; } + } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d1642a48/server/src/com/cloud/api/ApiResponseHelper.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/api/ApiResponseHelper.java b/server/src/com/cloud/api/ApiResponseHelper.java index 894ec8d..4cf261e 100755 --- a/server/src/com/cloud/api/ApiResponseHelper.java +++ b/server/src/com/cloud/api/ApiResponseHelper.java @@ -2394,6 +2394,7 @@ public class ApiResponseHelper implements ResponseGenerator { if (network.getAclType() != null) { response.setAclType(network.getAclType().toString()); } + response.setDisplayNetwork(network.getDisplayNetwork()); response.setState(network.getState().toString()); response.setRestartRequired(network.isRestartRequired()); NetworkVO nw = ApiDBUtils.findNetworkById(network.getRelated()); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d1642a48/server/src/com/cloud/api/query/QueryManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/api/query/QueryManagerImpl.java b/server/src/com/cloud/api/query/QueryManagerImpl.java index 6690b24..592757b 100644 --- a/server/src/com/cloud/api/query/QueryManagerImpl.java +++ b/server/src/com/cloud/api/query/QueryManagerImpl.java @@ -16,12 +16,7 @@ // under the License. package com.cloud.api.query; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; import javax.ejb.Local; import javax.inject.Inject; @@ -29,6 +24,8 @@ import javax.inject.Inject; import org.apache.cloudstack.affinity.AffinityGroupResponse; import org.apache.cloudstack.affinity.AffinityGroupVMMapVO; import org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDao; +import com.cloud.storage.VolumeDetailVO; +import com.cloud.storage.dao.VolumeDetailsDao; import org.apache.cloudstack.api.command.admin.host.ListHostsCmd; import org.apache.cloudstack.api.command.admin.router.ListRoutersCmd; import org.apache.cloudstack.api.command.admin.storage.ListStoragePoolsCmd; @@ -45,28 +42,12 @@ import org.apache.cloudstack.api.command.user.securitygroup.ListSecurityGroupsCm import org.apache.cloudstack.api.command.user.tag.ListTagsCmd; import org.apache.cloudstack.api.command.user.vm.ListVMsCmd; import org.apache.cloudstack.api.command.user.vmgroup.ListVMGroupsCmd; +import org.apache.cloudstack.api.command.user.volume.ListVolumeDetailsCmd; import org.apache.cloudstack.api.command.user.volume.ListVolumesCmd; import org.apache.cloudstack.api.command.user.zone.ListZonesByCmd; -import org.apache.cloudstack.api.response.AccountResponse; -import org.apache.cloudstack.api.response.AsyncJobResponse; -import org.apache.cloudstack.api.response.DiskOfferingResponse; -import org.apache.cloudstack.api.response.DomainRouterResponse; -import org.apache.cloudstack.api.response.EventResponse; -import org.apache.cloudstack.api.response.HostResponse; -import org.apache.cloudstack.api.response.InstanceGroupResponse; -import org.apache.cloudstack.api.response.ListResponse; -import org.apache.cloudstack.api.response.ProjectAccountResponse; -import org.apache.cloudstack.api.response.ProjectInvitationResponse; -import org.apache.cloudstack.api.response.ProjectResponse; -import org.apache.cloudstack.api.response.ResourceTagResponse; -import org.apache.cloudstack.api.response.SecurityGroupResponse; -import org.apache.cloudstack.api.response.ServiceOfferingResponse; -import org.apache.cloudstack.api.response.StoragePoolResponse; -import org.apache.cloudstack.api.response.UserResponse; -import org.apache.cloudstack.api.response.UserVmResponse; -import org.apache.cloudstack.api.response.VolumeResponse; -import org.apache.cloudstack.api.response.ZoneResponse; +import org.apache.cloudstack.api.response.*; import org.apache.cloudstack.query.QueryService; +import org.apache.commons.collections.map.HashedMap; import org.apache.log4j.Logger; import org.springframework.stereotype.Component; @@ -246,6 +227,9 @@ public class QueryManagerImpl extends ManagerBase implements QueryService { private DomainRouterDao _routerDao; @Inject + private VolumeDetailsDao _volumeDetailDao; + + @Inject private HighAvailabilityManager _haMgr; @Inject @@ -1508,6 +1492,34 @@ public class QueryManagerImpl extends ManagerBase implements QueryService { return response; } + @Override + public List searchForVolumeDetails(ListVolumeDetailsCmd cmd){ + + Long id = cmd.getId(); + String name = cmd.getName(); + + List volumeDetailList; + if(name == null){ + volumeDetailList = _volumeDetailDao.findDetails(id); + }else{ + VolumeDetailVO volumeDetail = _volumeDetailDao.findDetail(id, name); + volumeDetailList = new LinkedList(); + volumeDetailList.add(volumeDetail); + } + + List volumeDetailResponseList = new ArrayList(); + for (VolumeDetailVO volumeDetail : volumeDetailList ){ + VolumeDetailResponse volumeDetailResponse = new VolumeDetailResponse(); + volumeDetailResponse.setId(id.toString()); + volumeDetailResponse.setName(volumeDetail.getName()); + volumeDetailResponse.setValue(volumeDetail.getValue()); + volumeDetailResponse.setObjectName("volumedetail"); + volumeDetailResponseList.add(volumeDetailResponse); + } + + return volumeDetailResponseList; + } + private Pair, Integer> searchForVolumesInternal(ListVolumesCmd cmd) { http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d1642a48/server/src/com/cloud/api/query/dao/DiskOfferingJoinDaoImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/api/query/dao/DiskOfferingJoinDaoImpl.java b/server/src/com/cloud/api/query/dao/DiskOfferingJoinDaoImpl.java index 43c9d00..283181f 100644 --- a/server/src/com/cloud/api/query/dao/DiskOfferingJoinDaoImpl.java +++ b/server/src/com/cloud/api/query/dao/DiskOfferingJoinDaoImpl.java @@ -68,8 +68,9 @@ public class DiskOfferingJoinDaoImpl extends GenericDaoBase implem userVmResponse.setDomainName(userVm.getDomainName()); userVmResponse.setCreated(userVm.getCreated()); + userVmResponse.setDisplayVm(userVm.isDisplayVm()); if (userVm.getState() != null) { userVmResponse.setState(userVm.getState().toString()); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d1642a48/server/src/com/cloud/api/query/dao/VolumeJoinDaoImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/api/query/dao/VolumeJoinDaoImpl.java b/server/src/com/cloud/api/query/dao/VolumeJoinDaoImpl.java index a7a0bf0..018745d 100644 --- a/server/src/com/cloud/api/query/dao/VolumeJoinDaoImpl.java +++ b/server/src/com/cloud/api/query/dao/VolumeJoinDaoImpl.java @@ -195,6 +195,7 @@ public class VolumeJoinDaoImpl extends GenericDaoBase implem } volResponse.setExtractable(isExtractable); + volResponse.setDisplayVm(volume.isDisplayVolume()); // set async job volResponse.setJobId(volume.getJobUuid()); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d1642a48/server/src/com/cloud/api/query/vo/DiskOfferingJoinVO.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/api/query/vo/DiskOfferingJoinVO.java b/server/src/com/cloud/api/query/vo/DiskOfferingJoinVO.java index 7785bee..6d3cdcb 100644 --- a/server/src/com/cloud/api/query/vo/DiskOfferingJoinVO.java +++ b/server/src/com/cloud/api/query/vo/DiskOfferingJoinVO.java @@ -85,6 +85,9 @@ public class DiskOfferingJoinVO extends BaseViewVO implements InternalIdentity, @Column(name="domain_path") private String domainPath = null; + @Column(name="display_offering") + boolean displayOffering; + public DiskOfferingJoinVO() { } @@ -164,6 +167,14 @@ public class DiskOfferingJoinVO extends BaseViewVO implements InternalIdentity, this.customized = customized; } + public boolean isDisplayOffering() { + return displayOffering; + } + + public void setDisplayOffering(boolean displayOffering) { + this.displayOffering = displayOffering; + } + public Date getCreated() { return created; } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d1642a48/server/src/com/cloud/api/query/vo/UserVmJoinVO.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/api/query/vo/UserVmJoinVO.java b/server/src/com/cloud/api/query/vo/UserVmJoinVO.java index a50906d..7fdb93e 100644 --- a/server/src/com/cloud/api/query/vo/UserVmJoinVO.java +++ b/server/src/com/cloud/api/query/vo/UserVmJoinVO.java @@ -128,6 +128,9 @@ public class UserVmJoinVO extends BaseViewVO implements ControlledViewEntity { @Column(name="limit_cpu_use", updatable=true, nullable=true) private boolean limitCpuUse; + @Column(name="display_vm", updatable=true, nullable=false) + protected boolean displayVm = true; + @Column(name="last_host_id", updatable=true, nullable=true) private Long lastHostId; @@ -780,6 +783,13 @@ public class UserVmJoinVO extends BaseViewVO implements ControlledViewEntity { limitCpuUse = value; } + public boolean isDisplayVm() { + return displayVm; + } + + public void setDisplayVm(boolean displayVm) { + this.displayVm = displayVm; + } public String getDataCenterUuid() { return dataCenterUuid; http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d1642a48/server/src/com/cloud/api/query/vo/VolumeJoinVO.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/api/query/vo/VolumeJoinVO.java b/server/src/com/cloud/api/query/vo/VolumeJoinVO.java index 8a4bfe5..e5e50b0 100644 --- a/server/src/com/cloud/api/query/vo/VolumeJoinVO.java +++ b/server/src/com/cloud/api/query/vo/VolumeJoinVO.java @@ -246,6 +246,9 @@ public class VolumeJoinVO extends BaseViewVO implements ControlledViewEntity { private String tagCustomer; + @Column(name="display_volume", updatable=true, nullable=false) + protected boolean displayVolume; + public VolumeJoinVO() { } @@ -387,6 +390,13 @@ public class VolumeJoinVO extends BaseViewVO implements ControlledViewEntity { } + public boolean isDisplayVolume() { + return displayVolume; + } + + public void setDisplayVolume(boolean displayVolume) { + this.displayVolume = displayVolume; + } @Override public String getAccountUuid() { http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d1642a48/server/src/com/cloud/configuration/ConfigurationManager.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/configuration/ConfigurationManager.java b/server/src/com/cloud/configuration/ConfigurationManager.java index 738c5ba..ca035af 100755 --- a/server/src/com/cloud/configuration/ConfigurationManager.java +++ b/server/src/com/cloud/configuration/ConfigurationManager.java @@ -93,9 +93,11 @@ public interface ConfigurationManager extends ConfigurationService, Manager { * @param numGibibytes * @param tags * @param isCustomized + * @param localStorageRequired + * @param isDisplayOfferingEnabled * @return newly created disk offering */ - DiskOfferingVO createDiskOffering(Long domainId, String name, String description, Long numGibibytes, String tags, boolean isCustomized, boolean localStorageRequired); + DiskOfferingVO createDiskOffering(Long domainId, String name, String description, Long numGibibytes, String tags, boolean isCustomized, boolean localStorageRequired, boolean isDisplayOfferingEnabled); /** * Creates a new pod http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d1642a48/server/src/com/cloud/configuration/ConfigurationManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java index d5e405d..40cceb7 100755 --- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java +++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java @@ -1727,7 +1727,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati userNetwork.setBroadcastDomainType(broadcastDomainType); userNetwork.setNetworkDomain(networkDomain); _networkMgr.setupNetwork(systemAccount, offering, userNetwork, plan, null, null, false, - Domain.ROOT_DOMAIN, null, null, null); + Domain.ROOT_DOMAIN, null, null, null, true); } } } @@ -1954,7 +1954,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati @Override @ActionEvent(eventType = EventTypes.EVENT_DISK_OFFERING_CREATE, eventDescription = "creating disk offering") - public DiskOfferingVO createDiskOffering(Long domainId, String name, String description, Long numGibibytes, String tags, boolean isCustomized, boolean localStorageRequired) { + public DiskOfferingVO createDiskOffering(Long domainId, String name, String description, Long numGibibytes, String tags, boolean isCustomized, boolean localStorageRequired, boolean isDisplayOfferingEnabled) { long diskSize = 0;// special case for custom disk offerings if (numGibibytes != null && (numGibibytes <= 0)) { throw new InvalidParameterValueException("Please specify a disk size of at least 1 Gb."); @@ -1973,6 +1973,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati tags = cleanupTags(tags); DiskOfferingVO newDiskOffering = new DiskOfferingVO(domainId, name, description, diskSize, tags, isCustomized); newDiskOffering.setUseLocalStorage(localStorageRequired); + newDiskOffering.setDisplayOffering(isDisplayOfferingEnabled); UserContext.current().setEventDetails("Disk offering id=" + newDiskOffering.getId()); DiskOfferingVO offering = _diskOfferingDao.persist(newDiskOffering); if (offering != null) { @@ -1988,6 +1989,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati String name = cmd.getOfferingName(); String description = cmd.getDisplayText(); Long numGibibytes = cmd.getDiskSize(); + boolean isDisplayOfferingEnabled = cmd.getDisplayOffering() != null ? cmd.getDisplayOffering() : true; boolean isCustomized = cmd.isCustomized() != null ? cmd.isCustomized() : false; // false // by // default @@ -2012,7 +2014,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati } } - return createDiskOffering(domainId, name, description, numGibibytes, tags, isCustomized, localStorageRequired); + return createDiskOffering(domainId, name, description, numGibibytes, tags, isCustomized, localStorageRequired, isDisplayOfferingEnabled); } @Override @@ -2376,9 +2378,9 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati @Override @DB - public Vlan createVlanAndPublicIpRange(long zoneId, long networkId, long physicalNetworkId, boolean forVirtualNetwork, Long podId, - String startIP, String endIP, String vlanGateway, String vlanNetmask, - String vlanId, Account vlanOwner, String startIPv6, String endIPv6, String vlanIp6Gateway, String vlanIp6Cidr) { + public Vlan createVlanAndPublicIpRange(long zoneId, long networkId, long physicalNetworkId, boolean forVirtualNetwork, Long podId, + String startIP, String endIP, String vlanGateway, String vlanNetmask, + String vlanId, Account vlanOwner, String startIPv6, String endIPv6, String vlanIp6Gateway, String vlanIp6Cidr) { Network network = _networkModel.getNetwork(networkId); boolean ipv4 = false, ipv6 = false; http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d1642a48/server/src/com/cloud/network/dao/NetworkVO.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/network/dao/NetworkVO.java b/server/src/com/cloud/network/dao/NetworkVO.java index 77b40c8..7e4c6bc 100644 --- a/server/src/com/cloud/network/dao/NetworkVO.java +++ b/server/src/com/cloud/network/dao/NetworkVO.java @@ -163,6 +163,9 @@ public class NetworkVO implements Network { @Column(name="ip6_cidr") String ip6Cidr; + @Column(name="display_network", updatable=true, nullable=false) + protected boolean displayNetwork = true; + public NetworkVO() { this.uuid = UUID.randomUUID().toString(); } @@ -540,4 +543,13 @@ public class NetworkVO implements Network { public void setIp6Gateway(String ip6Gateway) { this.ip6Gateway = ip6Gateway; } + + @Override() + public boolean getDisplayNetwork() { + return displayNetwork; + } + + public void setDisplayNetwork(boolean displayNetwork) { + this.displayNetwork = displayNetwork; + } } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d1642a48/server/src/com/cloud/server/ManagementServerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java index 16127a2..485790a 100755 --- a/server/src/com/cloud/server/ManagementServerImpl.java +++ b/server/src/com/cloud/server/ManagementServerImpl.java @@ -2480,7 +2480,13 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe cmdList.add(ListAffinityGroupsCmd.class); cmdList.add(UpdateVMAffinityGroupCmd.class); cmdList.add(ListAffinityGroupTypesCmd.class); - + cmdList.add(AddVolumeDetailCmd.class); + cmdList.add(UpdateVolumeDetailCmd.class); + cmdList.add(RemoveVolumeDetailCmd.class); + cmdList.add(ListVolumeDetailsCmd.class); + cmdList.add(AddNicDetailCmd.class); + cmdList.add(UpdateNicDetailCmd.class); + cmdList.add(RemoveNicDetailCmd.class); return cmdList; } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d1642a48/server/src/com/cloud/storage/VolumeManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/storage/VolumeManagerImpl.java b/server/src/com/cloud/storage/VolumeManagerImpl.java index e57d393..73e96f4 100644 --- a/server/src/com/cloud/storage/VolumeManagerImpl.java +++ b/server/src/com/cloud/storage/VolumeManagerImpl.java @@ -36,14 +36,10 @@ import java.util.concurrent.ExecutionException; import javax.inject.Inject; import javax.naming.ConfigurationException; +import com.cloud.storage.dao.*; import org.apache.cloudstack.api.BaseCmd; -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.CommandResult; +import org.apache.cloudstack.api.command.user.volume.*; import org.apache.cloudstack.engine.subsystem.api.storage.DataStore; import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager; import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProviderManager; @@ -122,18 +118,6 @@ import com.cloud.storage.Storage.ImageFormat; import com.cloud.storage.Storage.StoragePoolType; import com.cloud.storage.Volume.Event; import com.cloud.storage.Volume.Type; -import com.cloud.storage.dao.DiskOfferingDao; -import com.cloud.storage.dao.SnapshotDao; -import com.cloud.storage.dao.SnapshotPolicyDao; -import com.cloud.storage.dao.StoragePoolHostDao; -import com.cloud.storage.dao.StoragePoolWorkDao; -import com.cloud.storage.dao.VMTemplateDao; -import com.cloud.storage.dao.VMTemplateHostDao; -import com.cloud.storage.dao.VMTemplatePoolDao; -import com.cloud.storage.dao.VMTemplateS3Dao; -import com.cloud.storage.dao.VMTemplateSwiftDao; -import com.cloud.storage.dao.VolumeDao; -import com.cloud.storage.dao.VolumeHostDao; import com.cloud.storage.download.DownloadMonitor; import com.cloud.storage.s3.S3Manager; import com.cloud.storage.secondary.SecondaryStorageVmManager; @@ -302,6 +286,8 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager { @Inject ConfigurationDao _configDao; @Inject + VolumeDetailsDao _volDetailDao; + @Inject ManagementServer _msServer; @Inject DataStoreManager dataStoreMgr; @@ -817,6 +803,7 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager { Account caller = UserContext.current().getCaller(); long ownerId = cmd.getEntityOwnerId(); + Boolean displayVolumeEnabled = cmd.getDisplayVolume(); // permission check _accountMgr.checkAccess(caller, null, true, @@ -891,6 +878,10 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager { size = diskOffering.getDiskSize(); } + if(displayVolumeEnabled == null){ + displayVolumeEnabled = true; + } + if (!validateVolumeSizeRange(size)) {// convert size from mb to gb // for validation throw new InvalidParameterValueException( @@ -971,6 +962,7 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager { volume.setUpdated(new Date()); volume.setDomainId((caller == null) ? Domain.ROOT_DOMAIN : caller .getDomainId()); + volume.setDisplayVolume(displayVolumeEnabled); if (parentVolume != null) { volume.setTemplateId(parentVolume.getTemplateId()); } else { @@ -1782,6 +1774,66 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager { } @Override + @ActionEvent(eventType = EventTypes.EVENT_VOLUME_DETAIL_UPDATE, eventDescription = "updating volume detail", async = true) + public void updateVolumeDetails(UpdateVolumeDetailCmd cmd){ + UserContext.current().setEventDetails("Volume Id: "+cmd.getId()); + Account caller = UserContext.current().getCaller(); + Long volumeId = cmd.getId(); + String name = cmd.getName(); + String value = cmd.getValue(); + + VolumeVO volume = _volsDao.findById(volumeId); + _accountMgr.checkAccess(caller, null, true, volume); + VolumeDetailVO volDetail = _volDetailDao.findDetail(volumeId, name); + if(volDetail != null){ + volDetail.setValue(value); + _volDetailDao.update(volDetail.getId(), volDetail); + }else{ + throw new InvalidParameterValueException("This detail doesnt exist for the volume "); + } + + } + + + @Override + @ActionEvent(eventType = EventTypes.EVENT_VOLUME_DETAIL_REMOVE, eventDescription = "removing volume detail", async = true) + public void removeVolumeDetail(RemoveVolumeDetailCmd cmd){ + UserContext.current().setEventDetails("Volume Id: "+cmd.getId()); + Account caller = UserContext.current().getCaller(); + Long volumeId = cmd.getId(); + String name = cmd.getName(); + + VolumeVO volume = _volsDao.findById(volumeId); + _accountMgr.checkAccess(caller, null, true, volume); + VolumeDetailVO volDetail = _volDetailDao.findDetail(volumeId, name); + if(volDetail != null){ + _volDetailDao.remove(volDetail.getId()); + }else{ + throw new InvalidParameterValueException("This detail doesnt exist for the volume "); + } + + } + + + @Override + @ActionEvent(eventType = EventTypes.EVENT_VOLUME_DETAIL_ADD, eventDescription = "adding volume detail", async = true) + public void addVolumeDetail(AddVolumeDetailCmd cmd){ + + Account caller = UserContext.current().getCaller(); + UserContext.current().setEventDetails("Volume Id: "+ cmd.getId()); + + Long volumeId = cmd.getId(); + String name = cmd.getName(); + String value = cmd.getValue(); + + VolumeVO volume = _volsDao.findById(volumeId); + _accountMgr.checkAccess(caller, null, true, volume); + VolumeDetailVO volDetail = new VolumeDetailVO(volumeId, name, value); + _volDetailDao.persist(volDetail); + } + + + @Override @ActionEvent(eventType = EventTypes.EVENT_VOLUME_DETACH, eventDescription = "detaching volume", async = true) public Volume detachVolumeFromVM(DetachVolumeCmd cmmd) { Account caller = UserContext.current().getCaller(); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d1642a48/server/src/com/cloud/storage/dao/VolumeDetailsDao.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/storage/dao/VolumeDetailsDao.java b/server/src/com/cloud/storage/dao/VolumeDetailsDao.java new file mode 100644 index 0000000..37a98d6 --- /dev/null +++ b/server/src/com/cloud/storage/dao/VolumeDetailsDao.java @@ -0,0 +1,33 @@ +// 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.storage.dao; + +import java.util.List; +import java.util.Map; + +import com.cloud.storage.VolumeDetailVO; +import com.cloud.utils.db.GenericDao; + +public interface VolumeDetailsDao extends GenericDao { + List findDetails(long volumeId); + + void persist(long vmId, Map details); + + VolumeDetailVO findDetail(long vmId, String name); + + void deleteDetails(long vmId); +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d1642a48/server/src/com/cloud/storage/dao/VolumeDetailsDaoImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/storage/dao/VolumeDetailsDaoImpl.java b/server/src/com/cloud/storage/dao/VolumeDetailsDaoImpl.java new file mode 100644 index 0000000..d3967ea --- /dev/null +++ b/server/src/com/cloud/storage/dao/VolumeDetailsDaoImpl.java @@ -0,0 +1,93 @@ +// 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.storage.dao; + +import java.util.List; +import java.util.Map; + +import javax.ejb.Local; + +import com.cloud.storage.VolumeDetailVO; +import org.springframework.stereotype.Component; + +import com.cloud.utils.db.GenericDaoBase; +import com.cloud.utils.db.SearchBuilder; +import com.cloud.utils.db.SearchCriteria; +import com.cloud.utils.db.Transaction; + +@Component +@Local(value=VolumeDetailsDao.class) +public class VolumeDetailsDaoImpl extends GenericDaoBase implements VolumeDetailsDao { + protected final SearchBuilder VolumeSearch; + protected final SearchBuilder DetailSearch; + + public VolumeDetailsDaoImpl() { + VolumeSearch = createSearchBuilder(); + VolumeSearch.and("volumeId", VolumeSearch.entity().getVolumeId(), SearchCriteria.Op.EQ); + VolumeSearch.done(); + + DetailSearch = createSearchBuilder(); + DetailSearch.and("volumeId", DetailSearch.entity().getVolumeId(), SearchCriteria.Op.EQ); + DetailSearch.and("name", DetailSearch.entity().getName(), SearchCriteria.Op.EQ); + DetailSearch.done(); + } + + @Override + public void deleteDetails(long volumeId) { + SearchCriteria sc = VolumeSearch.create(); + sc.setParameters("volumeId", volumeId); + + List results = search(sc, null); + for (VolumeDetailVO result : results) { + remove(result.getId()); + } + } + + @Override + public VolumeDetailVO findDetail(long volumeId, String name) { + SearchCriteria sc = DetailSearch.create(); + sc.setParameters("volumeId", volumeId); + sc.setParameters("name", name); + + return findOneBy(sc); + } + + @Override + public List findDetails(long volumeId) { + SearchCriteria sc = VolumeSearch.create(); + sc.setParameters("volumeId", volumeId); + + List results = search(sc, null); + return results; + } + + @Override + public void persist(long volumeId, Map details) { + Transaction txn = Transaction.currentTxn(); + txn.start(); + SearchCriteria sc = VolumeSearch.create(); + sc.setParameters("volumeId", volumeId); + expunge(sc); + + for (Map.Entry detail : details.entrySet()) { + VolumeDetailVO vo = new VolumeDetailVO(volumeId, detail.getKey(), detail.getValue()); + persist(vo); + } + txn.commit(); + } + +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d1642a48/server/src/com/cloud/vm/NicDetailVO.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/vm/NicDetailVO.java b/server/src/com/cloud/vm/NicDetailVO.java new file mode 100644 index 0000000..9149972 --- /dev/null +++ b/server/src/com/cloud/vm/NicDetailVO.java @@ -0,0 +1,85 @@ +// 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.vm; + +import org.apache.cloudstack.api.InternalIdentity; + +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="nic_details") +public class NicDetailVO implements InternalIdentity { + @Id + @GeneratedValue(strategy=GenerationType.IDENTITY) + @Column(name="id") + private long id; + + @Column(name="nic_id") + private long nicId; + + @Column(name="name") + private String name; + + @Column(name="value", length=1024) + private String value; + + public NicDetailVO() {} + + public NicDetailVO(long nicId, String name, String value) { + this.nicId = nicId; + this.name = name; + this.value = value; + } + + public long getId() { + return id; + } + + public long getNicId() { + return nicId; + } + + public String getName() { + return name; + } + + public String getValue() { + return value; + } + + public void setId(long id) { + this.id = id; + } + + public void setNicId(long nicId) { + this.nicId = nicId; + } + + public void setName(String name) { + this.name = name; + } + + public void setValue(String value) { + this.value = value; + } + +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d1642a48/server/src/com/cloud/vm/NicDetailsVO.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/vm/NicDetailsVO.java b/server/src/com/cloud/vm/NicDetailsVO.java new file mode 100644 index 0000000..f7cc9df --- /dev/null +++ b/server/src/com/cloud/vm/NicDetailsVO.java @@ -0,0 +1,11 @@ +package com.cloud.vm; + +/** + * Created with IntelliJ IDEA. + * User: nitinmehta + * Date: 15/04/13 + * Time: 5:03 PM + * To change this template use File | Settings | File Templates. + */ +public class NicDetailsVO { +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d1642a48/server/src/com/cloud/vm/UserVmManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java index ebc5757..5bc3a16 100755 --- a/server/src/com/cloud/vm/UserVmManagerImpl.java +++ b/server/src/com/cloud/vm/UserVmManagerImpl.java @@ -1572,6 +1572,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use String displayName = cmd.getDisplayName(); String group = cmd.getGroup(); Boolean ha = cmd.getHaEnable(); + Boolean isDisplayVmEnabled = cmd.getDisplayVm(); Long id = cmd.getId(); Long osTypeId = cmd.getOsTypeId(); String userData = cmd.getUserData(); @@ -1605,6 +1606,10 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use ha = vmInstance.isHaEnabled(); } + if (isDisplayVmEnabled == null) { + isDisplayVmEnabled = vmInstance.isDisplayVm(); + } + UserVmVO vm = _vmDao.findById(id); if (vm == null) { throw new CloudRuntimeException( @@ -1653,7 +1658,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use } } - _vmDao.updateVM(id, displayName, ha, osTypeId, userData); + _vmDao.updateVM(id, displayName, ha, osTypeId, userData, isDisplayVmEnabled); if (updateUserdata) { boolean result = updateUserDataInternal(_vmDao.findById(id)); @@ -1945,9 +1950,9 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use public UserVm createBasicSecurityGroupVirtualMachine(DataCenter zone, ServiceOffering serviceOffering, VirtualMachineTemplate template, List securityGroupIdList, Account owner, String hostName, String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor, HTTPMethod httpmethod, String userData, String sshKeyPair, - Map requestedIps, IpAddresses defaultIps, String keyboard, + Map requestedIps, IpAddresses defaultIps, Boolean displayVm, String keyboard, List affinityGroupIdList) - throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException, ResourceAllocationException { + throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException, ResourceAllocationException { Account caller = UserContext.current().getCaller(); List networkList = new ArrayList(); @@ -1997,16 +2002,17 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use return createVirtualMachine(zone, serviceOffering, template, hostName, displayName, owner, diskOfferingId, diskSize, networkList, securityGroupIdList, group, httpmethod, userData, sshKeyPair, hypervisor, - caller, requestedIps, defaultIps, keyboard, affinityGroupIdList); + caller, requestedIps, defaultIps, displayVm, keyboard, affinityGroupIdList); + } @Override public UserVm createAdvancedSecurityGroupVirtualMachine(DataCenter zone, ServiceOffering serviceOffering, VirtualMachineTemplate template, List networkIdList, List securityGroupIdList, Account owner, String hostName, String displayName, Long diskOfferingId, - Long diskSize, String group, HypervisorType hypervisor, HTTPMethod httpmethod, String userData, - String sshKeyPair, Map requestedIps, IpAddresses defaultIps, String keyboard, - List affinityGroupIdList) throws InsufficientCapacityException, ConcurrentOperationException, - ResourceUnavailableException, StorageUnavailableException, ResourceAllocationException { + Long diskSize, String group, HypervisorType hypervisor, HTTPMethod httpmethod, String userData, + String sshKeyPair, Map requestedIps, IpAddresses defaultIps, Boolean displayVm, String keyboard, + List affinityGroupIdList) throws InsufficientCapacityException, ConcurrentOperationException, + ResourceUnavailableException, StorageUnavailableException, ResourceAllocationException { Account caller = UserContext.current().getCaller(); List networkList = new ArrayList(); @@ -2113,15 +2119,15 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use return createVirtualMachine(zone, serviceOffering, template, hostName, displayName, owner, diskOfferingId, diskSize, networkList, securityGroupIdList, group, httpmethod, userData, sshKeyPair, hypervisor, - caller, requestedIps, defaultIps, keyboard, affinityGroupIdList); + caller, requestedIps, defaultIps, displayVm, keyboard, affinityGroupIdList); } @Override public UserVm createAdvancedVirtualMachine(DataCenter zone, ServiceOffering serviceOffering, VirtualMachineTemplate template, List networkIdList, Account owner, String hostName, - String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor, + String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor, HTTPMethod httpmethod, String userData, String sshKeyPair, Map requestedIps, - IpAddresses defaultIps, String keyboard, List affinityGroupIdList) - throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException, ResourceAllocationException { + IpAddresses defaultIps, Boolean displayvm, String keyboard, List affinityGroupIdList) + throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException, ResourceAllocationException { Account caller = UserContext.current().getCaller(); List networkList = new ArrayList(); @@ -2165,7 +2171,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use s_logger.debug("Creating network for account " + owner + " from the network offering id=" +requiredOfferings.get(0).getId() + " as a part of deployVM process"); Network newNetwork = _networkMgr.createGuestNetwork(requiredOfferings.get(0).getId(), owner.getAccountName() + "-network", owner.getAccountName() + "-network", null, null, - null, null, owner, null, physicalNetwork, zone.getId(), ACLType.Account, null, null, null, null); + null, null, owner, null, physicalNetwork, zone.getId(), ACLType.Account, null, null, null, null, true); defaultNetwork = _networkDao.findById(newNetwork.getId()); } else if (virtualNetworks.size() > 1) { throw new InvalidParameterValueException( @@ -2230,7 +2236,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use return createVirtualMachine(zone, serviceOffering, template, hostName, displayName, owner, diskOfferingId, diskSize, networkList, null, group, httpmethod, userData, sshKeyPair, hypervisor, caller, requestedIps, - defaultIps, keyboard, affinityGroupIdList); + defaultIps, displayvm, keyboard, affinityGroupIdList); } @@ -2243,9 +2249,9 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use @DB @ActionEvent(eventType = EventTypes.EVENT_VM_CREATE, eventDescription = "deploying Vm", create = true) protected UserVm createVirtualMachine(DataCenter zone, ServiceOffering serviceOffering, VirtualMachineTemplate template, String hostName, String displayName, Account owner, Long diskOfferingId, - Long diskSize, List networkList, List securityGroupIdList, String group, HTTPMethod httpmethod, + Long diskSize, List networkList, List securityGroupIdList, String group, HTTPMethod httpmethod, String userData, String sshKeyPair, HypervisorType hypervisor, Account caller, Map requestedIps, - IpAddresses defaultIps, String keyboard, List affinityGroupIdList) + IpAddresses defaultIps, Boolean displayvm, String keyboard, List affinityGroupIdList) throws InsufficientCapacityException, ResourceUnavailableException, ConcurrentOperationException, StorageUnavailableException, ResourceAllocationException { _accountMgr.checkAccess(caller, null, true, owner); @@ -2510,6 +2516,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use } else { hypervisorType = template.getHypervisorType(); } + Transaction txn = Transaction.currentTxn(); txn.start(); UserVmVO vm = new UserVmVO(id, instanceName, displayName, @@ -2530,6 +2537,12 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use vm.setIsoId(template.getId()); } + if(displayvm != null){ + vm.setDisplayVm(displayvm); + }else { + vm.setDisplayVm(true); + } + // If hypervisor is vSphere, check for clone type setting. if (hypervisorType.equals(HypervisorType.VMware)) { // retrieve clone flag. @@ -4003,7 +4016,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use requiredOfferings.get(0).getId() + " as a part of deployVM process"); Network newNetwork = _networkMgr.createGuestNetwork(requiredOfferings.get(0).getId(), newAccount.getAccountName() + "-network", newAccount.getAccountName() + "-network", null, null, - null, null, newAccount, null, physicalNetwork, zone.getId(), ACLType.Account, null, null, null, null); + null, null, newAccount, null, physicalNetwork, zone.getId(), ACLType.Account, null, null, null, null, true); // if the network offering has persistent set to true, implement the network if (requiredOfferings.get(0).getIsPersistent()) { DeployDestination dest = new DeployDestination(zone, null, null, null); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d1642a48/server/src/com/cloud/vm/dao/NicDetailDao.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/vm/dao/NicDetailDao.java b/server/src/com/cloud/vm/dao/NicDetailDao.java new file mode 100644 index 0000000..ff6802b --- /dev/null +++ b/server/src/com/cloud/vm/dao/NicDetailDao.java @@ -0,0 +1,32 @@ +// 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.vm.dao; + +import java.util.Map; + +import com.cloud.utils.db.GenericDao; +import com.cloud.vm.NicDetailVO; + +public interface NicDetailDao extends GenericDao { + Map findDetails(long nicId); + + void persist(long nicId, Map details); + + NicDetailVO findDetail(long nicId, String name); + + void deleteDetails(long nicId); +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d1642a48/server/src/com/cloud/vm/dao/NicDetailDaoImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/vm/dao/NicDetailDaoImpl.java b/server/src/com/cloud/vm/dao/NicDetailDaoImpl.java new file mode 100644 index 0000000..519e4e7 --- /dev/null +++ b/server/src/com/cloud/vm/dao/NicDetailDaoImpl.java @@ -0,0 +1,98 @@ +// 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.vm.dao; + +import com.cloud.utils.db.GenericDaoBase; +import com.cloud.utils.db.SearchBuilder; +import com.cloud.utils.db.SearchCriteria; +import com.cloud.utils.db.Transaction; +import com.cloud.vm.NicDetailVO; +import org.springframework.stereotype.Component; + +import javax.ejb.Local; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Component +@Local(value = { NicDetailDao.class }) +public class NicDetailDaoImpl extends GenericDaoBase implements NicDetailDao { + protected final SearchBuilder NicSearch; + protected final SearchBuilder DetailSearch; + + public NicDetailDaoImpl() { + NicSearch = createSearchBuilder(); + NicSearch.and("nicId", NicSearch.entity().getNicId(), SearchCriteria.Op.EQ); + NicSearch.done(); + + DetailSearch = createSearchBuilder(); + DetailSearch.and("nicId", DetailSearch.entity().getNicId(), SearchCriteria.Op.EQ); + DetailSearch.and("name", DetailSearch.entity().getName(), SearchCriteria.Op.EQ); + DetailSearch.done(); + } + + @Override + public void deleteDetails(long nicId) { + SearchCriteria sc = NicSearch.create(); + sc.setParameters("nicId", nicId); + + List results = search(sc, null); + for (NicDetailVO result : results) { + remove(result.getId()); + } + } + + @Override + public NicDetailVO findDetail(long nicId, String name) { + SearchCriteria sc = DetailSearch.create(); + sc.setParameters("nicId", nicId); + sc.setParameters("name", name); + + return findOneBy(sc); + } + + @Override + public Map findDetails(long nicId) { + SearchCriteria sc = NicSearch.create(); + sc.setParameters("nicId", nicId); + + List results = search(sc, null); + Map details = new HashMap(results.size()); + for (NicDetailVO result : results) { + details.put(result.getName(), result.getValue()); + } + + return details; + } + + @Override + public void persist(long nicId, Map details) { + Transaction txn = Transaction.currentTxn(); + txn.start(); + SearchCriteria sc = NicSearch.create(); + sc.setParameters("nicId", nicId); + expunge(sc); + + for (Map.Entry detail : details.entrySet()) { + NicDetailVO vo = new NicDetailVO(nicId, detail.getKey(), detail.getValue()); + persist(vo); + } + txn.commit(); + } + + +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d1642a48/server/src/com/cloud/vm/dao/UserVmDao.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/vm/dao/UserVmDao.java b/server/src/com/cloud/vm/dao/UserVmDao.java index 81d13cd..e7cd61b 100755 --- a/server/src/com/cloud/vm/dao/UserVmDao.java +++ b/server/src/com/cloud/vm/dao/UserVmDao.java @@ -38,8 +38,9 @@ public interface UserVmDao extends GenericDao { * @param id vm id. * @param displan name and enable for ha * @param userData updates the userData of the vm + * @param displayVm updates the displayvm attribute signifying whether it has to be displayed to the end user or not. */ - void updateVM(long id, String displayName, boolean enable, Long osTypeId, String userData); + void updateVM(long id, String displayName, boolean enable, Long osTypeId, String userData, boolean displayVm); List findDestroyedVms(Date date); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d1642a48/server/src/com/cloud/vm/dao/UserVmDaoImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/vm/dao/UserVmDaoImpl.java b/server/src/com/cloud/vm/dao/UserVmDaoImpl.java index c2fd648..5e8be10 100755 --- a/server/src/com/cloud/vm/dao/UserVmDaoImpl.java +++ b/server/src/com/cloud/vm/dao/UserVmDaoImpl.java @@ -224,12 +224,13 @@ public class UserVmDaoImpl extends GenericDaoBase implements Use } @Override - public void updateVM(long id, String displayName, boolean enable, Long osTypeId, String userData) { + public void updateVM(long id, String displayName, boolean enable, Long osTypeId, String userData, boolean displayVm) { UserVmVO vo = createForUpdate(); vo.setDisplayName(displayName); vo.setHaEnabled(enable); vo.setGuestOSId(osTypeId); vo.setUserData(userData); + vo.setDisplayVm(displayVm); update(id, vo); } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d1642a48/server/test/com/cloud/vm/MockUserVmManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/test/com/cloud/vm/MockUserVmManagerImpl.java b/server/test/com/cloud/vm/MockUserVmManagerImpl.java index d886fd8..46eb6eb 100644 --- a/server/test/com/cloud/vm/MockUserVmManagerImpl.java +++ b/server/test/com/cloud/vm/MockUserVmManagerImpl.java @@ -23,7 +23,10 @@ import java.util.Map; import javax.ejb.Local; import javax.naming.ConfigurationException; + import org.apache.cloudstack.api.BaseCmd.HTTPMethod; + +import com.cloud.hypervisor.Hypervisor; import org.apache.cloudstack.api.command.admin.vm.AssignVMCmd; import org.apache.cloudstack.api.command.admin.vm.RecoverVMCmd; import org.apache.cloudstack.api.command.user.vm.AddNicToVMCmd; @@ -339,11 +342,10 @@ public class MockUserVmManagerImpl extends ManagerBase implements UserVmManager, return null; } - @Override public UserVm createBasicSecurityGroupVirtualMachine(DataCenter zone, ServiceOffering serviceOffering, VirtualMachineTemplate template, List securityGroupIdList, Account owner, String hostName, String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor, HTTPMethod httpmethod, String userData, String sshKeyPair, Map requestedIps, - IpAddresses defaultIp, String keyboard, List affinityGroupIdList) + IpAddresses defaultIp, Boolean displayVm, String keyboard, List affinityGroupIdList) throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException, ResourceAllocationException { // TODO Auto-generated method stub @@ -355,7 +357,7 @@ public class MockUserVmManagerImpl extends ManagerBase implements UserVmManager, List securityGroupIdList, Account owner, String hostName, String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor, HTTPMethod httpmethod, String userData, String sshKeyPair, Map requestedIps, IpAddresses defaultIps, - String keyboard, List affinityGroupIdList) throws InsufficientCapacityException, + Boolean displayVm, String keyboard, List affinityGroupIdList) throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException, ResourceAllocationException { // TODO Auto-generated method stub return null; @@ -365,7 +367,7 @@ public class MockUserVmManagerImpl extends ManagerBase implements UserVmManager, public UserVm createAdvancedVirtualMachine(DataCenter zone, ServiceOffering serviceOffering, VirtualMachineTemplate template, List networkIdList, Account owner, String hostName, String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor, HTTPMethod httpmethod, String userData, String sshKeyPair, Map requestedIps, - IpAddresses defaultIps, String keyboard, List affinityGroupIdList) throws InsufficientCapacityException, + IpAddresses defaultIps, Boolean displayVm, String keyboard, List affinityGroupIdList) throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException, ResourceAllocationException { // TODO Auto-generated method stub return null; http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d1642a48/server/test/com/cloud/vpc/MockConfigurationManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/test/com/cloud/vpc/MockConfigurationManagerImpl.java b/server/test/com/cloud/vpc/MockConfigurationManagerImpl.java index 6cda294..4656860 100755 --- a/server/test/com/cloud/vpc/MockConfigurationManagerImpl.java +++ b/server/test/com/cloud/vpc/MockConfigurationManagerImpl.java @@ -75,13 +75,11 @@ import com.cloud.offering.NetworkOffering; import com.cloud.offering.NetworkOffering.Availability; import com.cloud.offering.ServiceOffering; import com.cloud.offerings.NetworkOfferingVO; -import com.cloud.offerings.dao.NetworkOfferingDao; import com.cloud.offerings.dao.NetworkOfferingDaoImpl; import com.cloud.org.Grouping.AllocationState; import com.cloud.service.ServiceOfferingVO; import com.cloud.storage.DiskOfferingVO; import com.cloud.user.Account; -import com.cloud.utils.component.Manager; import com.cloud.utils.component.ManagerBase; import com.cloud.vm.VirtualMachine.Type; @@ -511,7 +509,7 @@ public class MockConfigurationManagerImpl extends ManagerBase implements Configu */ @Override public Vlan createVlanAndPublicIpRange(long zoneId, long networkId, long physicalNetworkId, boolean forVirtualNetwork, Long podId, String startIP, String endIP, String vlanGateway, String vlanNetmask, String vlanId, - Account vlanOwner, String startIPv6, String endIPv6, String vlanGatewayv6, String vlanCidrv6) throws InsufficientCapacityException, ConcurrentOperationException, InvalidParameterValueException { + Account vlanOwner, String startIPv6, String endIPv6, String vlanGatewayv6, String vlanCidrv6) throws InsufficientCapacityException, ConcurrentOperationException, InvalidParameterValueException { // TODO Auto-generated method stub return null; } @@ -598,10 +596,10 @@ public class MockConfigurationManagerImpl extends ManagerBase implements Configu } /* (non-Javadoc) - * @see com.cloud.configuration.ConfigurationManager#createDiskOffering(java.lang.Long, java.lang.String, java.lang.String, java.lang.Long, java.lang.String, boolean, boolean) + * @see com.cloud.configuration.ConfigurationManager#createDiskOffering(java.lang.Long, java.lang.String, java.lang.String, java.lang.Long, java.lang.String, boolean, boolean, boolean) */ @Override - public DiskOfferingVO createDiskOffering(Long domainId, String name, String description, Long numGibibytes, String tags, boolean isCustomized, boolean localStorageRequired) { + public DiskOfferingVO createDiskOffering(Long domainId, String name, String description, Long numGibibytes, String tags, boolean isCustomized, boolean localStorageRequired, boolean isDisplayOfferingEnabled) { // TODO Auto-generated method stub return null; } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d1642a48/setup/db/db/schema-410to420.sql ---------------------------------------------------------------------- diff --git a/setup/db/db/schema-410to420.sql b/setup/db/db/schema-410to420.sql index 78444fd..2154d1c 100644 --- a/setup/db/db/schema-410to420.sql +++ b/setup/db/db/schema-410to420.sql @@ -243,6 +243,58 @@ ALTER TABLE `cloud`.`external_load_balancer_devices` ADD COLUMN `gslb_site_publi ALTER TABLE `cloud`.`external_load_balancer_devices` ADD COLUMN `gslb_site_privateip` varchar(255) DEFAULT NULL COMMENT 'GSLB service Provider site private ip'; +ALTER TABLE `cloud`.`vm_instance` ADD COLUMN `display_vm` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Should vm instance be displayed to the end user'; + +ALTER TABLE `cloud`.`user_vm_details` ADD COLUMN `display_detail` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Should vm detail instance be displayed to the end user'; + +ALTER TABLE `cloud`.`volumes` ADD COLUMN `display_volume` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Should volume be displayed to the end user'; + +ALTER TABLE `cloud`.`networks` ADD COLUMN `display_network` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Should network be displayed to the end user'; + +ALTER TABLE `cloud`.`nics` ADD COLUMN `display_nic` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Should nic be displayed to the end user'; + +ALTER TABLE `cloud`.`disk_offering` ADD COLUMN `display_offering` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Should disk offering be displayed to the end user'; + +CREATE TABLE `cloud`.`volume_details` ( + `id` bigint unsigned NOT NULL auto_increment, + `volume_id` bigint unsigned NOT NULL COMMENT 'volume id', + `name` varchar(255) NOT NULL, + `value` varchar(1024) NOT NULL, + `display_detail` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Should detail be displayed to the end user', + PRIMARY KEY (`id`), + CONSTRAINT `fk_volume_details__volume_id` FOREIGN KEY `fk_volume_details__volume_id`(`volume_id`) REFERENCES `volumes`(`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE `cloud`.`network_details` ( + `id` bigint unsigned NOT NULL auto_increment, + `network_id` bigint unsigned NOT NULL COMMENT 'network id', + `name` varchar(255) NOT NULL, + `value` varchar(1024) NOT NULL, + `display_detail` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Should detail be displayed to the end user', + PRIMARY KEY (`id`), + CONSTRAINT `fk_network_details__network_id` FOREIGN KEY `fk_network_details__network_id`(`network_id`) REFERENCES `networks`(`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE `cloud`.`nic_details` ( + `id` bigint unsigned NOT NULL auto_increment, + `nic_id` bigint unsigned NOT NULL COMMENT 'nic id', + `name` varchar(255) NOT NULL, + `value` varchar(1024) NOT NULL, + `display_detail` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Should detail be displayed to the end user', + PRIMARY KEY (`id`), + CONSTRAINT `fk_nic_details__nic_id` FOREIGN KEY `fk_nic_details__nic_id`(`nic_id`) REFERENCES `nics`(`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE `cloud`.`disk_offering_details` ( + `id` bigint unsigned NOT NULL auto_increment, + `offering_id` bigint unsigned NOT NULL COMMENT 'offering id', + `name` varchar(255) NOT NULL, + `value` varchar(1024) NOT NULL, + `display_detail` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Should detail be displayed to the end user', + PRIMARY KEY (`id`), + CONSTRAINT `fk_offering_details__offering_id` FOREIGN KEY `fk_offering_details__offering_id`(`offering_id`) REFERENCES `disk_offering`(`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + CREATE TABLE `cloud`.`global_load_balancing_rules` ( `id` bigint unsigned NOT NULL auto_increment COMMENT 'id', `uuid` varchar(40), @@ -1110,3 +1162,301 @@ CREATE VIEW `cloud`.`account_view` AS and async_job.job_status = 0; alter table `cloud_usage`.`usage_network_offering` add column nic_id bigint(20) unsigned NOT NULL; +DROP VIEW IF EXISTS `cloud`.`disk_offering_view`; +CREATE VIEW `cloud`.`disk_offering_view` AS + select + disk_offering.id, + disk_offering.uuid, + disk_offering.name, + disk_offering.display_text, + disk_offering.disk_size, + disk_offering.created, + disk_offering.tags, + disk_offering.customized, + disk_offering.removed, + disk_offering.use_local_storage, + disk_offering.system_use, + disk_offering.sort_key, + disk_offering.type, + disk_offering.display_offering, + domain.id domain_id, + domain.uuid domain_uuid, + domain.name domain_name, + domain.path domain_path + from + `cloud`.`disk_offering` + left join + `cloud`.`domain` ON disk_offering.domain_id = domain.id; + +DROP VIEW IF EXISTS `cloud`.`user_vm_view`; +CREATE VIEW `cloud`.`user_vm_view` AS + select + vm_instance.id id, + vm_instance.name name, + user_vm.display_name display_name, + user_vm.user_data user_data, + account.id account_id, + account.uuid account_uuid, + account.account_name account_name, + account.type account_type, + domain.id domain_id, + domain.uuid domain_uuid, + domain.name domain_name, + domain.path domain_path, + projects.id project_id, + projects.uuid project_uuid, + projects.name project_name, + instance_group.id instance_group_id, + instance_group.uuid instance_group_uuid, + instance_group.name instance_group_name, + vm_instance.uuid uuid, + vm_instance.last_host_id last_host_id, + vm_instance.vm_type type, + vm_instance.vnc_password vnc_password, + vm_instance.limit_cpu_use limit_cpu_use, + vm_instance.created created, + vm_instance.state state, + vm_instance.removed removed, + vm_instance.ha_enabled ha_enabled, + vm_instance.hypervisor_type hypervisor_type, + vm_instance.instance_name instance_name, + vm_instance.guest_os_id guest_os_id, + vm_instance.display_vm display_vm, + guest_os.uuid guest_os_uuid, + vm_instance.pod_id pod_id, + host_pod_ref.uuid pod_uuid, + vm_instance.private_ip_address private_ip_address, + vm_instance.private_mac_address private_mac_address, + vm_instance.vm_type vm_type, + data_center.id data_center_id, + data_center.uuid data_center_uuid, + data_center.name data_center_name, + data_center.is_security_group_enabled security_group_enabled, + host.id host_id, + host.uuid host_uuid, + host.name host_name, + vm_template.id template_id, + vm_template.uuid template_uuid, + vm_template.name template_name, + vm_template.display_text template_display_text, + vm_template.enable_password password_enabled, + iso.id iso_id, + iso.uuid iso_uuid, + iso.name iso_name, + iso.display_text iso_display_text, + service_offering.id service_offering_id, + disk_offering.uuid service_offering_uuid, + service_offering.cpu cpu, + service_offering.speed speed, + service_offering.ram_size ram_size, + disk_offering.name service_offering_name, + storage_pool.id pool_id, + storage_pool.uuid pool_uuid, + storage_pool.pool_type pool_type, + volumes.id volume_id, + volumes.uuid volume_uuid, + volumes.device_id volume_device_id, + volumes.volume_type volume_type, + security_group.id security_group_id, + security_group.uuid security_group_uuid, + security_group.name security_group_name, + security_group.description security_group_description, + nics.id nic_id, + nics.uuid nic_uuid, + nics.network_id network_id, + nics.ip4_address ip_address, + nics.ip6_address ip6_address, + nics.ip6_gateway ip6_gateway, + nics.ip6_cidr ip6_cidr, + nics.default_nic is_default_nic, + nics.gateway gateway, + nics.netmask netmask, + nics.mac_address mac_address, + nics.broadcast_uri broadcast_uri, + nics.isolation_uri isolation_uri, + vpc.id vpc_id, + vpc.uuid vpc_uuid, + networks.uuid network_uuid, + networks.name network_name, + networks.traffic_type traffic_type, + networks.guest_type guest_type, + user_ip_address.id public_ip_id, + user_ip_address.uuid public_ip_uuid, + user_ip_address.public_ip_address public_ip_address, + ssh_keypairs.keypair_name keypair_name, + resource_tags.id tag_id, + resource_tags.uuid tag_uuid, + resource_tags.key tag_key, + resource_tags.value tag_value, + resource_tags.domain_id tag_domain_id, + resource_tags.account_id tag_account_id, + resource_tags.resource_id tag_resource_id, + resource_tags.resource_uuid tag_resource_uuid, + resource_tags.resource_type tag_resource_type, + resource_tags.customer tag_customer, + async_job.id job_id, + async_job.uuid job_uuid, + async_job.job_status job_status, + async_job.account_id job_account_id + from + `cloud`.`user_vm` + inner join + `cloud`.`vm_instance` ON vm_instance.id = user_vm.id + and vm_instance.removed is NULL + inner join + `cloud`.`account` ON vm_instance.account_id = account.id + inner join + `cloud`.`domain` ON vm_instance.domain_id = domain.id + left join + `cloud`.`guest_os` ON vm_instance.guest_os_id = guest_os.id + left join + `cloud`.`host_pod_ref` ON vm_instance.pod_id = host_pod_ref.id + left join + `cloud`.`projects` ON projects.project_account_id = account.id + left join + `cloud`.`instance_group_vm_map` ON vm_instance.id = instance_group_vm_map.instance_id + left join + `cloud`.`instance_group` ON instance_group_vm_map.group_id = instance_group.id + left join + `cloud`.`data_center` ON vm_instance.data_center_id = data_center.id + left join + `cloud`.`host` ON vm_instance.host_id = host.id + left join + `cloud`.`vm_template` ON vm_instance.vm_template_id = vm_template.id + left join + `cloud`.`vm_template` iso ON iso.id = user_vm.iso_id + left join + `cloud`.`service_offering` ON vm_instance.service_offering_id = service_offering.id + left join + `cloud`.`disk_offering` ON vm_instance.service_offering_id = disk_offering.id + left join + `cloud`.`volumes` ON vm_instance.id = volumes.instance_id + left join + `cloud`.`storage_pool` ON volumes.pool_id = storage_pool.id + left join + `cloud`.`security_group_vm_map` ON vm_instance.id = security_group_vm_map.instance_id + left join + `cloud`.`security_group` ON security_group_vm_map.security_group_id = security_group.id + left join + `cloud`.`nics` ON vm_instance.id = nics.instance_id + left join + `cloud`.`networks` ON nics.network_id = networks.id + left join + `cloud`.`vpc` ON networks.vpc_id = vpc.id + left join + `cloud`.`user_ip_address` ON user_ip_address.vm_id = vm_instance.id + left join + `cloud`.`user_vm_details` ON user_vm_details.vm_id = vm_instance.id + and user_vm_details.name = 'SSH.PublicKey' + left join + `cloud`.`ssh_keypairs` ON ssh_keypairs.public_key = user_vm_details.value + left join + `cloud`.`resource_tags` ON resource_tags.resource_id = vm_instance.id + and resource_tags.resource_type = 'UserVm' + left join + `cloud`.`async_job` ON async_job.instance_id = vm_instance.id + and async_job.instance_type = 'VirtualMachine' + and async_job.job_status = 0; + +DROP VIEW IF EXISTS `cloud`.`volume_view`; +CREATE VIEW `cloud`.`volume_view` AS + select + volumes.id, + volumes.uuid, + volumes.name, + volumes.device_id, + volumes.volume_type, + volumes.size, + volumes.created, + volumes.state, + volumes.attached, + volumes.removed, + volumes.pod_id, + volumes.display_volume, + account.id account_id, + account.uuid account_uuid, + account.account_name account_name, + account.type account_type, + domain.id domain_id, + domain.uuid domain_uuid, + domain.name domain_name, + domain.path domain_path, + projects.id project_id, + projects.uuid project_uuid, + projects.name project_name, + data_center.id data_center_id, + data_center.uuid data_center_uuid, + data_center.name data_center_name, + vm_instance.id vm_id, + vm_instance.uuid vm_uuid, + vm_instance.name vm_name, + vm_instance.state vm_state, + vm_instance.vm_type, + user_vm.display_name vm_display_name, + volume_host_ref.size volume_host_size, + volume_host_ref.created volume_host_created, + volume_host_ref.format, + volume_host_ref.download_pct, + volume_host_ref.download_state, + volume_host_ref.error_str, + disk_offering.id disk_offering_id, + disk_offering.uuid disk_offering_uuid, + disk_offering.name disk_offering_name, + disk_offering.display_text disk_offering_display_text, + disk_offering.use_local_storage, + disk_offering.system_use, + storage_pool.id pool_id, + storage_pool.uuid pool_uuid, + storage_pool.name pool_name, + cluster.hypervisor_type, + vm_template.id template_id, + vm_template.uuid template_uuid, + vm_template.extractable, + vm_template.type template_type, + resource_tags.id tag_id, + resource_tags.uuid tag_uuid, + resource_tags.key tag_key, + resource_tags.value tag_value, + resource_tags.domain_id tag_domain_id, + resource_tags.account_id tag_account_id, + resource_tags.resource_id tag_resource_id, + resource_tags.resource_uuid tag_resource_uuid, + resource_tags.resource_type tag_resource_type, + resource_tags.customer tag_customer, + async_job.id job_id, + async_job.uuid job_uuid, + async_job.job_status job_status, + async_job.account_id job_account_id + from + `cloud`.`volumes` + inner join + `cloud`.`account` ON volumes.account_id = account.id + inner join + `cloud`.`domain` ON volumes.domain_id = domain.id + left join + `cloud`.`projects` ON projects.project_account_id = account.id + left join + `cloud`.`data_center` ON volumes.data_center_id = data_center.id + left join + `cloud`.`vm_instance` ON volumes.instance_id = vm_instance.id + left join + `cloud`.`user_vm` ON user_vm.id = vm_instance.id + left join + `cloud`.`volume_host_ref` ON volumes.id = volume_host_ref.volume_id + and volumes.data_center_id = volume_host_ref.zone_id + left join + `cloud`.`disk_offering` ON volumes.disk_offering_id = disk_offering.id + left join + `cloud`.`storage_pool` ON volumes.pool_id = storage_pool.id + left join + `cloud`.`cluster` ON storage_pool.cluster_id = cluster.id + left join + `cloud`.`vm_template` ON volumes.template_id = vm_template.id + left join + `cloud`.`resource_tags` ON resource_tags.resource_id = volumes.id + and resource_tags.resource_type = 'Volume' + left join + `cloud`.`async_job` ON async_job.instance_id = volumes.id + and async_job.instance_type = 'Volume' + and async_job.job_status = 0; +