Skip to content

Commit 81269ad

Browse files
VNF: add API listVnfAppliances (apache#8994)
1 parent 2315a73 commit 81269ad

File tree

6 files changed

+83
-4
lines changed

6 files changed

+83
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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+
package org.apache.cloudstack.api.command.admin.vm;
18+
19+
import com.cloud.vm.VirtualMachine;
20+
import org.apache.cloudstack.acl.RoleType;
21+
import org.apache.cloudstack.api.APICommand;
22+
import org.apache.cloudstack.api.ResponseObject.ResponseView;
23+
import org.apache.cloudstack.api.command.admin.AdminCmd;
24+
25+
import org.apache.cloudstack.api.command.user.vm.ListVnfAppliancesCmd;
26+
import org.apache.cloudstack.api.response.UserVmResponse;
27+
28+
@APICommand(name = "listVnfAppliances", description = "List VNF appliance owned by the account.",
29+
responseObject = UserVmResponse.class,
30+
responseView = ResponseView.Full,
31+
entityType = {VirtualMachine.class},
32+
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false,
33+
authorized = {RoleType.Admin},
34+
since = "4.19.1")
35+
public class ListVnfAppliancesCmdByAdmin extends ListVnfAppliancesCmd implements AdminCmd {
36+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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+
package org.apache.cloudstack.api.command.user.vm;
18+
19+
import com.cloud.vm.VirtualMachine;
20+
import org.apache.cloudstack.acl.RoleType;
21+
import org.apache.cloudstack.api.APICommand;
22+
import org.apache.cloudstack.api.ResponseObject.ResponseView;
23+
import org.apache.cloudstack.api.command.user.UserCmd;
24+
25+
import org.apache.cloudstack.api.response.UserVmResponse;
26+
27+
@APICommand(name = "listVnfAppliances", description = "List VNF appliance owned by the account.",
28+
responseObject = UserVmResponse.class,
29+
responseView = ResponseView.Restricted, entityType = {VirtualMachine.class},
30+
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false,
31+
authorized = {RoleType.Admin, RoleType.ResourceAdmin, RoleType.DomainAdmin, RoleType.User},
32+
since = "4.19.1")
33+
public class ListVnfAppliancesCmd extends ListVMsCmd implements UserCmd {
34+
35+
@Override
36+
public Boolean getVnf() {
37+
return true;
38+
}
39+
}

server/src/main/java/org/apache/cloudstack/storage/template/VnfTemplateManagerImpl.java

+4
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,13 @@
7171
import org.apache.cloudstack.api.command.admin.template.RegisterVnfTemplateCmdByAdmin;
7272
import org.apache.cloudstack.api.command.admin.template.UpdateVnfTemplateCmdByAdmin;
7373
import org.apache.cloudstack.api.command.admin.vm.DeployVnfApplianceCmdByAdmin;
74+
import org.apache.cloudstack.api.command.admin.vm.ListVnfAppliancesCmdByAdmin;
7475
import org.apache.cloudstack.api.command.user.template.DeleteVnfTemplateCmd;
7576
import org.apache.cloudstack.api.command.user.template.ListVnfTemplatesCmd;
7677
import org.apache.cloudstack.api.command.user.template.RegisterVnfTemplateCmd;
7778
import org.apache.cloudstack.api.command.user.template.UpdateVnfTemplateCmd;
7879
import org.apache.cloudstack.api.command.user.vm.DeployVnfApplianceCmd;
80+
import org.apache.cloudstack.api.command.user.vm.ListVnfAppliancesCmd;
7981
import org.apache.cloudstack.framework.config.ConfigKey;
8082
import org.apache.cloudstack.framework.config.Configurable;
8183
import org.apache.commons.collections.CollectionUtils;
@@ -133,6 +135,8 @@ public List<Class<?>> getCommands() {
133135
cmdList.add(DeleteVnfTemplateCmd.class);
134136
cmdList.add(DeployVnfApplianceCmd.class);
135137
cmdList.add(DeployVnfApplianceCmdByAdmin.class);
138+
cmdList.add(ListVnfAppliancesCmd.class);
139+
cmdList.add(ListVnfAppliancesCmdByAdmin.class);
136140
return cmdList;
137141
}
138142

ui/src/config/section/image.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export default {
9090
}, {
9191
name: 'vnf.settings',
9292
component: shallowRef(defineAsyncComponent(() => import('@/views/image/TemplateVnfSettings.vue'))),
93-
show: (record) => { return record.templatetype === 'VNF' }
93+
show: (record) => { return record.templatetype === 'VNF' && 'updateVnfTemplate' in store.getters.apis }
9494
},
9595
{
9696
name: 'events',

ui/src/config/section/network.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export default {
8282
}, {
8383
name: 'vnf.appliances',
8484
component: shallowRef(defineAsyncComponent(() => import('@/views/network/VnfAppliancesTab.vue'))),
85-
show: () => { return 'deployVnfAppliance' in store.getters.apis }
85+
show: () => { return 'listVnfAppliances' in store.getters.apis }
8686
}, {
8787
name: 'guest.ip.range',
8888
component: shallowRef(defineAsyncComponent(() => import('@/views/network/GuestIpRanges.vue'))),
@@ -337,7 +337,7 @@ export default {
337337
name: 'vnfapp',
338338
title: 'label.vnf.appliances',
339339
icon: 'gateway-outlined',
340-
permission: ['listVnfTemplates'],
340+
permission: ['listVnfAppliances'],
341341
resourceType: 'UserVm',
342342
params: () => {
343343
return { details: 'servoff,tmpl,nics', isvnf: true }

ui/src/views/network/VnfAppliancesTab.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ export default {
130130
params.networkid = this.resource.id
131131
}
132132
this.fetchLoading = true
133-
api('listVirtualMachines', params).then(json => {
133+
api('listVnfAppliances', params).then(json => {
134134
this.virtualmachines = json.listvirtualmachinesresponse.virtualmachine || []
135135
for (const vm of this.virtualmachines) {
136136
for (const vmnic of vm.nic) {

0 commit comments

Comments
 (0)