From 00c6ad2733123cd7107970c65d2c50565b86400a Mon Sep 17 00:00:00 2001 From: sureshanaparti <12028987+sureshanaparti@users.noreply.github.com> Date: Fri, 3 Dec 2021 16:46:31 +0530 Subject: [PATCH 1/5] vmware: Perform volume file search in the VM directory on the datastore while computing the VM snapshot chain size. (#5735) This PR improves the volume file search on the datastore while computing the VM snapshot chain size in VMware. The file search is now performed in the VM directory on the datastore, instead of all the directories on the datastore (which is leading to incorrect VM snapshot chain size computation when VM id has 6 digits). --- .../vmware/manager/VmwareStorageManagerImpl.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java b/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java index e84b744d5c1..da317bbdf65 100644 --- a/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java +++ b/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java @@ -31,6 +31,7 @@ import java.util.UUID; import org.apache.log4j.Logger; +import com.cloud.hypervisor.vmware.mo.DatastoreFile; import com.vmware.vim25.FileInfo; import com.vmware.vim25.FileQueryFlags; import com.vmware.vim25.HostDatastoreBrowserSearchResults; @@ -1140,12 +1141,12 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager { return "snapshots/" + accountId + "/" + volumeId; } - private long getVMSnapshotChainSize(VmwareContext context, VmwareHypervisorHost hyperHost, String fileName, ManagedObjectReference morDs, String exceptFileName) - throws Exception { + private long getVMSnapshotChainSize(VmwareContext context, VmwareHypervisorHost hyperHost, String fileName, ManagedObjectReference morDs, + String exceptFileName, String vmName) throws Exception { long size = 0; DatastoreMO dsMo = new DatastoreMO(context, morDs); HostDatastoreBrowserMO browserMo = dsMo.getHostDatastoreBrowserMO(); - String datastorePath = "[" + dsMo.getName() + "]"; + String datastorePath = (new DatastoreFile(dsMo.getName(), vmName)).getPath(); HostDatastoreBrowserSearchSpec searchSpec = new HostDatastoreBrowserSearchSpec(); FileQueryFlags fqf = new FileQueryFlags(); fqf.setFileSize(true); @@ -1306,11 +1307,11 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager { // get volume's chain size for this VM snapshot; exclude current volume vdisk DataStoreTO store = volumeTO.getDataStore(); ManagedObjectReference morDs = getDatastoreAsManagedObjectReference(baseName, hyperHost, store); - long size = getVMSnapshotChainSize(context, hyperHost, baseName + "-*.vmdk", morDs, newPath); + long size = getVMSnapshotChainSize(context, hyperHost, baseName + "-*.vmdk", morDs, newPath, vmName); if (volumeTO.getVolumeType() == Volume.Type.ROOT) { // add memory snapshot size - size += getVMSnapshotChainSize(context, hyperHost, vmName + "-*.vmsn", morDs, null); + size += getVMSnapshotChainSize(context, hyperHost, vmName + "-*.vmsn", morDs, null, vmName); } volumeTO.setSize(size); From 19880687b79383343429b7b5979ce98f575bd5a8 Mon Sep 17 00:00:00 2001 From: Hoang Nguyen Date: Mon, 6 Dec 2021 14:01:38 +0700 Subject: [PATCH 2/5] UI fix: button next not working when adding more physical networks (#5734) --- ui/src/views/infra/zone/ZoneWizardPhysicalNetworkSetupStep.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/src/views/infra/zone/ZoneWizardPhysicalNetworkSetupStep.vue b/ui/src/views/infra/zone/ZoneWizardPhysicalNetworkSetupStep.vue index 6c8bdf06fd0..73a09507a65 100644 --- a/ui/src/views/infra/zone/ZoneWizardPhysicalNetworkSetupStep.vue +++ b/ui/src/views/infra/zone/ZoneWizardPhysicalNetworkSetupStep.vue @@ -141,7 +141,7 @@ :closable="true" :footer="null" @cancel="() => { showError = false }" - v-ctrl-enter="showError = false" + v-ctrl-enter="() => { showError = false }" centered > {{ $t('message.required.traffic.type') }} From 93f4ecab84818f1099de16e213f8744104a9f23e Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Tue, 7 Dec 2021 09:47:00 +0530 Subject: [PATCH 3/5] vmware: fix cpu reservation during vm scale (#5708) Fixes #5706 Correctly set CPU reservation while scaling a dynamically scalable VM. Signed-off-by: Abhishek Kumar --- .../cloud/hypervisor/vmware/resource/VmwareResource.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java b/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java index d1776eaf8b0..ed3739182f0 100644 --- a/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java +++ b/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java @@ -48,8 +48,6 @@ import java.util.stream.Collectors; import javax.naming.ConfigurationException; import javax.xml.datatype.XMLGregorianCalendar; -import com.cloud.utils.script.Script; -import com.cloud.hypervisor.vmware.mo.NetworkMO; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.storage.command.CopyCommand; import org.apache.cloudstack.storage.command.StorageSubSystemCommand; @@ -234,6 +232,7 @@ import com.cloud.hypervisor.vmware.mo.HostMO; import com.cloud.hypervisor.vmware.mo.HostStorageSystemMO; import com.cloud.hypervisor.vmware.mo.HypervisorHostHelper; import com.cloud.hypervisor.vmware.mo.NetworkDetails; +import com.cloud.hypervisor.vmware.mo.NetworkMO; import com.cloud.hypervisor.vmware.mo.PbmProfileManagerMO; import com.cloud.hypervisor.vmware.mo.StoragepodMO; import com.cloud.hypervisor.vmware.mo.TaskMO; @@ -276,6 +275,7 @@ import com.cloud.utils.mgmt.JmxUtil; import com.cloud.utils.mgmt.PropertyMapDynamicBean; import com.cloud.utils.net.NetUtils; import com.cloud.utils.nicira.nvp.plugin.NiciraNvpApiVersion; +import com.cloud.utils.script.Script; import com.cloud.utils.ssh.SshHelper; import com.cloud.vm.VirtualMachine; import com.cloud.vm.VirtualMachine.PowerState; @@ -1765,7 +1765,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa // Check if license supports the feature VmwareHelper.isFeatureLicensed(hyperHost, FeatureKeyConstants.HOTPLUG); - VmwareHelper.setVmScaleUpConfig(vmConfigSpec, vmSpec.getCpus(), vmSpec.getMaxSpeed(), vmSpec.getMinSpeed(), (int) requestedMaxMemoryInMb, ramMb, + VmwareHelper.setVmScaleUpConfig(vmConfigSpec, vmSpec.getCpus(), vmSpec.getMaxSpeed(), getReservedCpuMHZ(vmSpec), (int) requestedMaxMemoryInMb, ramMb, vmSpec.getLimitCpuUse()); if (!vmMo.configureVm(vmConfigSpec)) { From a47e53fceee528486f83e0a52b61868338315c9e Mon Sep 17 00:00:00 2001 From: dahn Date: Tue, 7 Dec 2021 05:39:38 +0100 Subject: [PATCH 4/5] internal ref replaced by uuid (#5738) * internal ref replaced by uuid * remove all internal DB IDs from usage records * remove superfluent .append(")") Co-authored-by: Daan Hoogland --- server/src/main/java/com/cloud/api/ApiResponseHelper.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/src/main/java/com/cloud/api/ApiResponseHelper.java b/server/src/main/java/com/cloud/api/ApiResponseHelper.java index 95aebc815e7..f2132cfb5b4 100644 --- a/server/src/main/java/com/cloud/api/ApiResponseHelper.java +++ b/server/src/main/java/com/cloud/api/ApiResponseHelper.java @@ -3948,7 +3948,7 @@ public class ApiResponseHelper implements ResponseGenerator { final StringBuilder builder = new StringBuilder(); builder.append("VMSnapshot usage"); if (vmSnapshotVO != null) { - builder.append(" Id: ").append(vmSnapshotVO.getId()).append(" (").append(vmSnapshotVO.getUuid()).append(") "); + builder.append(" Id: ").append(vmSnapshotVO.getUuid()); } if (vmInstance != null) { builder.append(" for VM ").append(vmInstance.getHostName()).append(" (").append(vmInstance.getUuid()).append(")"); @@ -3991,7 +3991,7 @@ public class ApiResponseHelper implements ResponseGenerator { final StringBuilder builder = new StringBuilder(); builder.append("VMSnapshot on primary storage usage"); if (vmSnapshotVO != null) { - builder.append(" Id: ").append(vmSnapshotVO.getId()).append(" (").append(vmSnapshotVO.getUuid()).append(") "); + builder.append(" Id: ").append(vmSnapshotVO.getUuid()); } if (vmInstance != null) { builder.append(" for VM ").append(vmInstance.getHostName()).append(" (").append(vmInstance.getUuid()).append(") ") From 8bc69e919c965efcb0efcd5239c2c39c4782f6df Mon Sep 17 00:00:00 2001 From: dahn Date: Wed, 8 Dec 2021 05:57:58 +0100 Subject: [PATCH 5/5] conditional broadcastUri (#5745) * conditional broadcastUri * add filter to keep order and apply to details as well * use global isAdmin method Co-authored-by: Daan Hoogland --- ui/src/config/section/network.js | 17 ++++++++++-- ui/src/role/index.js | 26 +++++++++++++++++++ ui/src/views/compute/KubernetesServiceTab.vue | 9 ++----- .../network/CreateIsolatedNetworkForm.vue | 16 +++++------- ui/src/views/network/CreateL2NetworkForm.vue | 16 +++++------- ui/src/views/network/CreateNetwork.vue | 9 ++++--- .../views/network/CreateSharedNetworkForm.vue | 6 ----- ui/src/views/network/UpdateNetwork.vue | 7 ++--- ui/src/views/offering/AddComputeOffering.vue | 9 ++++--- ui/src/views/offering/AddDiskOffering.vue | 7 ++--- ui/src/views/offering/AddNetworkOffering.vue | 3 ++- ui/src/views/offering/AddVpcOffering.vue | 3 ++- .../views/offering/UpdateOfferingAccess.vue | 7 ++--- 13 files changed, 83 insertions(+), 52 deletions(-) create mode 100644 ui/src/role/index.js diff --git a/ui/src/config/section/network.js b/ui/src/config/section/network.js index a91e6b5e145..95c24159bb0 100644 --- a/ui/src/config/section/network.js +++ b/ui/src/config/section/network.js @@ -16,6 +16,7 @@ // under the License. import store from '@/store' +import { isAdmin } from '@/role' export default { name: 'network', @@ -29,8 +30,20 @@ export default { icon: 'apartment', permission: ['listNetworks'], resourceType: 'Network', - columns: ['name', 'state', 'type', 'vpcname', 'cidr', 'ip6cidr', 'broadcasturi', 'domain', 'account', 'zonename'], - details: ['name', 'id', 'description', 'type', 'traffictype', 'vpcid', 'vlan', 'broadcasturi', 'cidr', 'ip6cidr', 'netmask', 'gateway', 'aclname', 'ispersistent', 'restartrequired', 'reservediprange', 'redundantrouter', 'networkdomain', 'zonename', 'account', 'domain'], + columns: () => { + var fields = ['name', 'state', 'type', 'vpcname', 'cidr', 'ip6cidr', 'broadcasturi', 'domain', 'account', 'zonename'] + if (!isAdmin()) { + fields = fields.filter(function (e) { return e !== 'broadcasturi' }) + } + return fields + }, + details: () => { + var fields = ['name', 'id', 'description', 'type', 'traffictype', 'vpcid', 'vlan', 'broadcasturi', 'cidr', 'ip6cidr', 'netmask', 'gateway', 'aclname', 'ispersistent', 'restartrequired', 'reservediprange', 'redundantrouter', 'networkdomain', 'zonename', 'account', 'domain'] + if (!isAdmin()) { + fields = fields.filter(function (e) { return e !== 'broadcasturi' }) + } + return fields + }, filters: ['all', 'isolated', 'shared', 'l2'], searchFilters: ['keyword', 'zoneid', 'domainid', 'account', 'tags'], related: [{ diff --git a/ui/src/role/index.js b/ui/src/role/index.js new file mode 100644 index 00000000000..2052e3e0577 --- /dev/null +++ b/ui/src/role/index.js @@ -0,0 +1,26 @@ +// 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. + +import store from '@/store' + +export function isAdmin () { + return ['Admin'].includes(store.getters.userInfo.roletype) +} + +export function isAdminOrDomainAdmin () { + return ['Admin', 'DomainAdmin'].includes(this.$store.getters.userInfo.roletype) +} diff --git a/ui/src/views/compute/KubernetesServiceTab.vue b/ui/src/views/compute/KubernetesServiceTab.vue index 3a738f7a76f..97f1c5456ec 100644 --- a/ui/src/views/compute/KubernetesServiceTab.vue +++ b/ui/src/views/compute/KubernetesServiceTab.vue @@ -150,6 +150,7 @@