Skip to content

Commit 51d4e54

Browse files
committed
Merge remote-tracking branch 'apache/4.16'
2 parents 9363f64 + 8bc69e9 commit 51d4e54

17 files changed

Lines changed: 95 additions & 63 deletions

File tree

plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
import org.apache.log4j.Logger;
3333

34+
import com.cloud.hypervisor.vmware.mo.DatastoreFile;
3435
import com.vmware.vim25.FileInfo;
3536
import com.vmware.vim25.FileQueryFlags;
3637
import com.vmware.vim25.HostDatastoreBrowserSearchResults;
@@ -1140,12 +1141,12 @@ private static String getSnapshotRelativeDirInSecStorage(long accountId, long vo
11401141
return "snapshots/" + accountId + "/" + volumeId;
11411142
}
11421143

1143-
private long getVMSnapshotChainSize(VmwareContext context, VmwareHypervisorHost hyperHost, String fileName, ManagedObjectReference morDs, String exceptFileName)
1144-
throws Exception {
1144+
private long getVMSnapshotChainSize(VmwareContext context, VmwareHypervisorHost hyperHost, String fileName, ManagedObjectReference morDs,
1145+
String exceptFileName, String vmName) throws Exception {
11451146
long size = 0;
11461147
DatastoreMO dsMo = new DatastoreMO(context, morDs);
11471148
HostDatastoreBrowserMO browserMo = dsMo.getHostDatastoreBrowserMO();
1148-
String datastorePath = "[" + dsMo.getName() + "]";
1149+
String datastorePath = (new DatastoreFile(dsMo.getName(), vmName)).getPath();
11491150
HostDatastoreBrowserSearchSpec searchSpec = new HostDatastoreBrowserSearchSpec();
11501151
FileQueryFlags fqf = new FileQueryFlags();
11511152
fqf.setFileSize(true);
@@ -1306,11 +1307,11 @@ private void setVolumeToPathAndSize(List<VolumeObjectTO> volumeTOs, Map<String,
13061307
// get volume's chain size for this VM snapshot; exclude current volume vdisk
13071308
DataStoreTO store = volumeTO.getDataStore();
13081309
ManagedObjectReference morDs = getDatastoreAsManagedObjectReference(baseName, hyperHost, store);
1309-
long size = getVMSnapshotChainSize(context, hyperHost, baseName + "-*.vmdk", morDs, newPath);
1310+
long size = getVMSnapshotChainSize(context, hyperHost, baseName + "-*.vmdk", morDs, newPath, vmName);
13101311

13111312
if (volumeTO.getVolumeType() == Volume.Type.ROOT) {
13121313
// add memory snapshot size
1313-
size += getVMSnapshotChainSize(context, hyperHost, vmName + "-*.vmsn", morDs, null);
1314+
size += getVMSnapshotChainSize(context, hyperHost, vmName + "-*.vmsn", morDs, null, vmName);
13141315
}
13151316

13161317
volumeTO.setSize(size);

plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@
4848
import javax.naming.ConfigurationException;
4949
import javax.xml.datatype.XMLGregorianCalendar;
5050

51-
import com.cloud.utils.script.Script;
52-
import com.cloud.hypervisor.vmware.mo.NetworkMO;
5351
import org.apache.cloudstack.api.ApiConstants;
5452
import org.apache.cloudstack.storage.command.CopyCommand;
5553
import org.apache.cloudstack.storage.command.StorageSubSystemCommand;
@@ -234,6 +232,7 @@
234232
import com.cloud.hypervisor.vmware.mo.HostStorageSystemMO;
235233
import com.cloud.hypervisor.vmware.mo.HypervisorHostHelper;
236234
import com.cloud.hypervisor.vmware.mo.NetworkDetails;
235+
import com.cloud.hypervisor.vmware.mo.NetworkMO;
237236
import com.cloud.hypervisor.vmware.mo.PbmProfileManagerMO;
238237
import com.cloud.hypervisor.vmware.mo.StoragepodMO;
239238
import com.cloud.hypervisor.vmware.mo.TaskMO;
@@ -276,6 +275,7 @@
276275
import com.cloud.utils.mgmt.PropertyMapDynamicBean;
277276
import com.cloud.utils.net.NetUtils;
278277
import com.cloud.utils.nicira.nvp.plugin.NiciraNvpApiVersion;
278+
import com.cloud.utils.script.Script;
279279
import com.cloud.utils.ssh.SshHelper;
280280
import com.cloud.vm.VirtualMachine;
281281
import com.cloud.vm.VirtualMachine.PowerState;
@@ -1764,7 +1764,7 @@ protected ScaleVmAnswer execute(ScaleVmCommand cmd) {
17641764

17651765
// Check if license supports the feature
17661766
VmwareHelper.isFeatureLicensed(hyperHost, FeatureKeyConstants.HOTPLUG);
1767-
VmwareHelper.setVmScaleUpConfig(vmConfigSpec, vmSpec.getCpus(), vmSpec.getMaxSpeed(), vmSpec.getMinSpeed(), (int) requestedMaxMemoryInMb, ramMb,
1767+
VmwareHelper.setVmScaleUpConfig(vmConfigSpec, vmSpec.getCpus(), vmSpec.getMaxSpeed(), getReservedCpuMHZ(vmSpec), (int) requestedMaxMemoryInMb, ramMb,
17681768
vmSpec.getLimitCpuUse());
17691769

17701770
if (!vmMo.configureVm(vmConfigSpec)) {

server/src/main/java/com/cloud/api/ApiResponseHelper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3947,7 +3947,7 @@ public UsageRecordResponse createUsageResponse(Usage usageRecord, Map<String, Se
39473947
final StringBuilder builder = new StringBuilder();
39483948
builder.append("VMSnapshot usage");
39493949
if (vmSnapshotVO != null) {
3950-
builder.append(" Id: ").append(vmSnapshotVO.getId()).append(" (").append(vmSnapshotVO.getUuid()).append(") ");
3950+
builder.append(" Id: ").append(vmSnapshotVO.getUuid());
39513951
}
39523952
if (vmInstance != null) {
39533953
builder.append(" for VM ").append(vmInstance.getHostName()).append(" (").append(vmInstance.getUuid()).append(")");
@@ -3990,7 +3990,7 @@ public UsageRecordResponse createUsageResponse(Usage usageRecord, Map<String, Se
39903990
final StringBuilder builder = new StringBuilder();
39913991
builder.append("VMSnapshot on primary storage usage");
39923992
if (vmSnapshotVO != null) {
3993-
builder.append(" Id: ").append(vmSnapshotVO.getId()).append(" (").append(vmSnapshotVO.getUuid()).append(") ");
3993+
builder.append(" Id: ").append(vmSnapshotVO.getUuid());
39943994
}
39953995
if (vmInstance != null) {
39963996
builder.append(" for VM ").append(vmInstance.getHostName()).append(" (").append(vmInstance.getUuid()).append(") ")

ui/src/config/section/network.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
// under the License.
1717

1818
import store from '@/store'
19+
import { isAdmin } from '@/role'
1920

2021
export default {
2122
name: 'network',
@@ -29,8 +30,20 @@ export default {
2930
icon: 'apartment',
3031
permission: ['listNetworks'],
3132
resourceType: 'Network',
32-
columns: ['name', 'state', 'type', 'vpcname', 'cidr', 'ip6cidr', 'broadcasturi', 'domain', 'account', 'zonename'],
33-
details: ['name', 'id', 'description', 'type', 'traffictype', 'vpcid', 'vlan', 'broadcasturi', 'cidr', 'ip6cidr', 'netmask', 'gateway', 'aclname', 'ispersistent', 'restartrequired', 'reservediprange', 'redundantrouter', 'networkdomain', 'zonename', 'account', 'domain'],
33+
columns: () => {
34+
var fields = ['name', 'state', 'type', 'vpcname', 'cidr', 'ip6cidr', 'broadcasturi', 'domain', 'account', 'zonename']
35+
if (!isAdmin()) {
36+
fields = fields.filter(function (e) { return e !== 'broadcasturi' })
37+
}
38+
return fields
39+
},
40+
details: () => {
41+
var fields = ['name', 'id', 'description', 'type', 'traffictype', 'vpcid', 'vlan', 'broadcasturi', 'cidr', 'ip6cidr', 'netmask', 'gateway', 'aclname', 'ispersistent', 'restartrequired', 'reservediprange', 'redundantrouter', 'networkdomain', 'zonename', 'account', 'domain']
42+
if (!isAdmin()) {
43+
fields = fields.filter(function (e) { return e !== 'broadcasturi' })
44+
}
45+
return fields
46+
},
3447
filters: ['all', 'isolated', 'shared', 'l2'],
3548
searchFilters: ['keyword', 'zoneid', 'domainid', 'account', 'tags'],
3649
related: [{

ui/src/role/index.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
import store from '@/store'
19+
20+
export function isAdmin () {
21+
return ['Admin'].includes(store.getters.userInfo.roletype)
22+
}
23+
24+
export function isAdminOrDomainAdmin () {
25+
return ['Admin', 'DomainAdmin'].includes(this.$store.getters.userInfo.roletype)
26+
}

ui/src/views/compute/KubernetesServiceTab.vue

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@
150150

151151
<script>
152152
import { api } from '@/api'
153+
import { isAdmin } from '@/role'
153154
import { mixinDevice } from '@/utils/mixin.js'
154155
import DetailsTab from '@/components/view/DetailsTab'
155156
import FirewallRules from '@/views/network/FirewallRules'
@@ -230,7 +231,7 @@ export default {
230231
dataIndex: 'zonename'
231232
}
232233
]
233-
if (!this.isAdmin()) {
234+
if (!isAdmin()) {
234235
this.vmColumns = this.vmColumns.filter(x => x.dataIndex !== 'instancename')
235236
}
236237
this.handleFetchData()
@@ -279,12 +280,6 @@ export default {
279280
}).join('&')
280281
)
281282
},
282-
isAdmin () {
283-
return ['Admin'].includes(this.$store.getters.userInfo.roletype)
284-
},
285-
isAdminOrDomainAdmin () {
286-
return ['Admin', 'DomainAdmin'].includes(this.$store.getters.userInfo.roletype)
287-
},
288283
isValidValueForKey (obj, key) {
289284
return key in obj && obj[key] != null
290285
},

ui/src/views/infra/zone/ZoneWizardPhysicalNetworkSetupStep.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@
141141
:closable="true"
142142
:footer="null"
143143
@cancel="() => { showError = false }"
144-
v-ctrl-enter="showError = false"
144+
v-ctrl-enter="() => { showError = false }"
145145
centered
146146
>
147147
<span>{{ $t('message.required.traffic.type') }}</span>

ui/src/views/network/CreateIsolatedNetworkForm.vue

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
</a-select-option>
6969
</a-select>
7070
</a-form-item>
71-
<a-form-item v-if="this.isAdminOrDomainAdmin()">
71+
<a-form-item v-if="isAdminOrDomainAdmin()">
7272
<tooltip-label slot="label" :title="$t('label.domainid')" :tooltip="apiParams.domainid.description"/>
7373
<a-select
7474
v-decorator="['domainid', {}]"
@@ -193,6 +193,7 @@
193193

194194
<script>
195195
import { api } from '@/api'
196+
import { isAdmin, isAdminOrDomainAdmin } from '@/role'
196197
import ResourceIcon from '@/components/view/ResourceIcon'
197198
import TooltipLabel from '@/components/widgets/TooltipLabel'
198199
@@ -231,7 +232,7 @@ export default {
231232
vpcs: [],
232233
vpcLoading: false,
233234
selectedVpc: {},
234-
accountVisible: this.isAdminOrDomainAdmin()
235+
accountVisible: isAdminOrDomainAdmin()
235236
}
236237
},
237238
watch: {
@@ -257,11 +258,8 @@ export default {
257258
this.fetchDomainData()
258259
this.fetchZoneData()
259260
},
260-
isAdmin () {
261-
return ['Admin'].includes(this.$store.getters.userInfo.roletype)
262-
},
263261
isAdminOrDomainAdmin () {
264-
return ['Admin', 'DomainAdmin'].includes(this.$store.getters.userInfo.roletype)
262+
return isAdminOrDomainAdmin()
265263
},
266264
isObjectEmpty (obj) {
267265
return !(obj !== null && obj !== undefined && Object.keys(obj).length > 0 && obj.constructor === Object)
@@ -320,7 +318,7 @@ export default {
320318
handleDomainChange (domain) {
321319
this.selectedDomain = domain
322320
this.accountVisible = domain.id !== '-1'
323-
if (this.isAdminOrDomainAdmin()) {
321+
if (isAdminOrDomainAdmin()) {
324322
this.updateVPCCheckAndFetchNetworkOfferingData()
325323
}
326324
},
@@ -349,10 +347,10 @@ export default {
349347
supportedServices: 'SourceNat',
350348
state: 'Enabled'
351349
}
352-
if (this.isAdminOrDomainAdmin() && this.selectedDomain.id !== '-1') { // domain is visible only for admins
350+
if (isAdminOrDomainAdmin() && this.selectedDomain.id !== '-1') { // domain is visible only for admins
353351
params.domainid = this.selectedDomain.id
354352
}
355-
if (!this.isAdmin()) { // normal user is not aware of the VLANs in the system, so normal user is not allowed to create network with network offerings whose specifyvlan = true
353+
if (!isAdmin()) { // normal user is not aware of the VLANs in the system, so normal user is not allowed to create network with network offerings whose specifyvlan = true
356354
params.specifyvlan = false
357355
}
358356
if (forVpc !== null) {

ui/src/views/network/CreateL2NetworkForm.vue

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
</a-select-option>
6969
</a-select>
7070
</a-form-item>
71-
<a-form-item v-if="this.isAdminOrDomainAdmin()">
71+
<a-form-item v-if="isAdminOrDomainAdmin()">
7272
<tooltip-label slot="label" :title="$t('label.domainid')" :tooltip="apiParams.domainid.description"/>
7373
<a-select
7474
v-decorator="['domainid', {}]"
@@ -180,6 +180,7 @@
180180

181181
<script>
182182
import { api } from '@/api'
183+
import { isAdmin, isAdminOrDomainAdmin } from '@/role'
183184
import ResourceIcon from '@/components/view/ResourceIcon'
184185
import TooltipLabel from '@/components/widgets/TooltipLabel'
185186
@@ -215,7 +216,7 @@ export default {
215216
networkOfferings: [],
216217
networkOfferingLoading: false,
217218
selectedNetworkOffering: {},
218-
accountVisible: this.isAdminOrDomainAdmin(),
219+
accountVisible: isAdminOrDomainAdmin(),
219220
isolatePvlanType: 'none'
220221
}
221222
},
@@ -242,11 +243,8 @@ export default {
242243
this.fetchDomainData()
243244
this.fetchZoneData()
244245
},
245-
isAdmin () {
246-
return ['Admin'].includes(this.$store.getters.userInfo.roletype)
247-
},
248246
isAdminOrDomainAdmin () {
249-
return ['Admin', 'DomainAdmin'].includes(this.$store.getters.userInfo.roletype)
247+
return isAdminOrDomainAdmin()
250248
},
251249
isObjectEmpty (obj) {
252250
return !(obj !== null && obj !== undefined && Object.keys(obj).length > 0 && obj.constructor === Object)
@@ -309,7 +307,7 @@ export default {
309307
handleDomainChange (domain) {
310308
this.selectedDomain = domain
311309
this.accountVisible = domain.id !== '-1'
312-
if (this.isAdminOrDomainAdmin()) {
310+
if (isAdminOrDomainAdmin()) {
313311
this.updateVPCCheckAndFetchNetworkOfferingData()
314312
}
315313
},
@@ -337,10 +335,10 @@ export default {
337335
guestiptype: 'L2',
338336
state: 'Enabled'
339337
}
340-
if (this.isAdminOrDomainAdmin() && this.selectedDomain.id !== '-1') { // domain is visible only for admins
338+
if (isAdminOrDomainAdmin() && this.selectedDomain.id !== '-1') { // domain is visible only for admins
341339
params.domainid = this.selectedDomain.id
342340
}
343-
if (!this.isAdmin()) { // normal user is not aware of the VLANs in the system, so normal user is not allowed to create network with network offerings whose specifyvlan = true
341+
if (!isAdmin()) { // normal user is not aware of the VLANs in the system, so normal user is not allowed to create network with network offerings whose specifyvlan = true
344342
params.specifyvlan = false
345343
}
346344
if (forVpc !== null) {

ui/src/views/network/CreateNetwork.vue

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
@refresh-data="refreshParent"
3535
@refresh="handleRefresh"/>
3636
</a-tab-pane>
37-
<a-tab-pane :tab="$t('label.shared')" key="3" v-if="this.isAdmin()">
37+
<a-tab-pane :tab="$t('label.shared')" key="3" v-if="isAdmin()">
3838
<CreateSharedNetworkForm
3939
:loading="loading"
4040
:resource="resource"
@@ -48,6 +48,7 @@
4848

4949
<script>
5050
import { api } from '@/api'
51+
import { isAdmin } from '@/role'
5152
import CreateIsolatedNetworkForm from '@/views/network/CreateIsolatedNetworkForm'
5253
import CreateL2NetworkForm from '@/views/network/CreateL2NetworkForm'
5354
import CreateSharedNetworkForm from '@/views/network/CreateSharedNetworkForm'
@@ -89,9 +90,6 @@ export default {
8990
})
9091
},
9192
methods: {
92-
isAdmin () {
93-
return ['Admin'].includes(this.$store.getters.userInfo.roletype)
94-
},
9593
fetchActionZoneData () {
9694
this.loading = true
9795
const params = {}
@@ -107,6 +105,9 @@ export default {
107105
this.loading = false
108106
})
109107
},
108+
isAdmin () {
109+
return isAdmin()
110+
},
110111
handleRefresh () {
111112
},
112113
refreshParent () {

0 commit comments

Comments
 (0)