Skip to content

Commit bd52fa8

Browse files
New feature: VNF templates and appliances integration (#8022)
1 parent a06f8a8 commit bd52fa8

File tree

82 files changed

+9026
-63
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+9026
-63
lines changed
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
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 com.cloud.network;
18+
19+
import org.apache.commons.lang3.StringUtils;
20+
21+
public class VNF {
22+
23+
public enum AccessMethod {
24+
SSH_WITH_PASSWORD("ssh-password"),
25+
SSH_WITH_KEY("ssh-key"),
26+
HTTP("http"),
27+
HTTPS("https"),
28+
CONSOLE("console");
29+
30+
String _method;
31+
32+
AccessMethod(String method) {
33+
_method = method;
34+
}
35+
36+
@Override
37+
public String toString() {
38+
return _method;
39+
}
40+
41+
public static AccessMethod fromValue(String method) {
42+
if (StringUtils.isBlank(method)) {
43+
return null;
44+
} else {
45+
for (AccessMethod accessMethod : AccessMethod.values()) {
46+
if (accessMethod.toString().equalsIgnoreCase(method)) {
47+
return accessMethod;
48+
}
49+
}
50+
}
51+
return null;
52+
}
53+
}
54+
55+
public enum AccessDetail {
56+
ACCESS_METHODS,
57+
USERNAME,
58+
PASSWORD,
59+
SSH_USER,
60+
SSH_PASSWORD,
61+
SSH_PORT,
62+
WEB_USER,
63+
WEB_PASSWORD,
64+
HTTP_PATH,
65+
HTTP_PORT,
66+
HTTPS_PATH,
67+
HTTPS_PORT
68+
}
69+
70+
public enum VnfDetail {
71+
ICON,
72+
VERSION,
73+
VENDOR,
74+
MAINTAINER
75+
}
76+
77+
public static class VnfNic {
78+
long deviceId;
79+
String name;
80+
boolean required;
81+
boolean management;
82+
String description;
83+
84+
public VnfNic(long deviceId, String nicName, boolean required, boolean management, String nicDescription) {
85+
this.deviceId = deviceId;
86+
this.name = nicName;
87+
this.required = required;
88+
this.management = management;
89+
this.description = nicDescription;
90+
}
91+
92+
public long getDeviceId() {
93+
return deviceId;
94+
}
95+
96+
public String getName() {
97+
return name;
98+
}
99+
100+
public boolean isRequired() {
101+
return required;
102+
}
103+
104+
public boolean isManagement() {
105+
return management;
106+
}
107+
108+
public String getDescription() {
109+
return description;
110+
}
111+
}
112+
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public interface ResourceTag extends ControlledEntity, Identity, InternalIdentit
3030
public enum ResourceObjectType {
3131
UserVm(true, true, true),
3232
Template(true, true, true),
33+
VnfTemplate(true, true, true),
3334
ISO(true, false, true),
3435
Volume(true, true),
3536
Snapshot(true, false),

api/src/main/java/com/cloud/storage/Storage.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ public static enum TemplateType {
125125
BUILTIN, /* buildin template */
126126
PERHOST, /* every host has this template, don't need to install it in secondary storage */
127127
USER, /* User supplied template/iso */
128+
VNF, /* VNFs (virtual network functions) template */
128129
DATADISK, /* Template corresponding to a datadisk(non root disk) present in an OVA */
129130
ISODISK /* Template corresponding to a iso (non root disk) present in an OVA */
130131
}

api/src/main/java/org/apache/cloudstack/api/ApiConstants.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,7 @@ public class ApiConstants {
436436
public static final String TEMPLATE_ID = "templateid";
437437
public static final String TEMPLATE_IDS = "templateids";
438438
public static final String TEMPLATE_NAME = "templatename";
439+
public static final String TEMPLATE_TYPE = "templatetype";
439440
public static final String TIMEOUT = "timeout";
440441
public static final String TIMEZONE = "timezone";
441442
public static final String TIMEZONEOFFSET = "timezoneoffset";
@@ -1013,7 +1014,6 @@ public class ApiConstants {
10131014
public static final String DEPLOY_AS_IS = "deployasis";
10141015
public static final String DEPLOY_AS_IS_DETAILS = "deployasisdetails";
10151016
public static final String CROSS_ZONES = "crossZones";
1016-
public static final String TEMPLATETYPE = "templatetype";
10171017
public static final String SOURCETEMPLATEID = "sourcetemplateid";
10181018
public static final String DYNAMIC_SCALING_ENABLED = "dynamicscalingenabled";
10191019
public static final String IOTHREADS_ENABLED = "iothreadsenabled";
@@ -1047,6 +1047,15 @@ public class ApiConstants {
10471047
public static final String SOURCE_NAT_IP_ID = "sourcenatipaddressid";
10481048
public static final String HAS_RULES = "hasrules";
10491049

1050+
public static final String MANAGEMENT = "management";
1051+
public static final String IS_VNF = "isvnf";
1052+
public static final String VNF_NICS = "vnfnics";
1053+
public static final String VNF_DETAILS = "vnfdetails";
1054+
public static final String CLEAN_UP_VNF_DETAILS = "cleanupvnfdetails";
1055+
public static final String CLEAN_UP_VNF_NICS = "cleanupvnfnics";
1056+
public static final String VNF_CONFIGURE_MANAGEMENT = "vnfconfiguremanagement";
1057+
public static final String VNF_CIDR_LIST = "vnfcidrlist";
1058+
10501059
/**
10511060
* This enum specifies IO Drivers, each option controls specific policies on I/O.
10521061
* Qemu guests support "threads" and "native" options Since 0.8.8 ; "io_uring" is supported Since 6.3.0 (QEMU 5.0).
@@ -1092,7 +1101,7 @@ public enum HostDetails {
10921101
}
10931102

10941103
public enum VMDetails {
1095-
all, group, nics, stats, secgrp, tmpl, servoff, diskoff, backoff, iso, volume, min, affgrp;
1104+
all, group, nics, stats, secgrp, tmpl, servoff, diskoff, backoff, iso, volume, min, affgrp, vnfnics;
10961105
}
10971106

10981107
public enum DomainDetails {

api/src/main/java/org/apache/cloudstack/api/BaseCmd.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import org.apache.cloudstack.network.lb.InternalLoadBalancerVMService;
4444
import org.apache.cloudstack.query.QueryService;
4545
import org.apache.cloudstack.storage.ImageStoreService;
46+
import org.apache.cloudstack.storage.template.VnfTemplateManager;
4647
import org.apache.cloudstack.usage.UsageService;
4748
import org.apache.commons.collections.MapUtils;
4849
import org.apache.log4j.Logger;
@@ -213,6 +214,8 @@ public static enum CommandType {
213214
public ResourceIconManager resourceIconManager;
214215
@Inject
215216
public Ipv6Service ipv6Service;
217+
@Inject
218+
public VnfTemplateManager vnfTemplateManager;
216219

217220
public abstract void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
218221
ResourceAllocationException, NetworkRuleConflictException;
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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.template;
18+
19+
import org.apache.cloudstack.api.APICommand;
20+
import org.apache.cloudstack.api.ResponseObject.ResponseView;
21+
import org.apache.cloudstack.api.command.admin.AdminCmd;
22+
import org.apache.cloudstack.api.command.user.template.ListVnfTemplatesCmd;
23+
import org.apache.cloudstack.api.response.TemplateResponse;
24+
25+
import com.cloud.template.VirtualMachineTemplate;
26+
27+
@APICommand(name = "listVnfTemplates", description = "List all public, private, and privileged VNF templates.",
28+
responseObject = TemplateResponse.class, entityType = {VirtualMachineTemplate.class}, responseView = ResponseView.Full,
29+
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false,
30+
since = "4.19.0")
31+
public class ListVnfTemplatesCmdByAdmin extends ListVnfTemplatesCmd implements AdminCmd {
32+
}

api/src/main/java/org/apache/cloudstack/api/command/admin/template/RegisterTemplateCmdByAdmin.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@
1818

1919
import org.apache.cloudstack.api.APICommand;
2020
import org.apache.cloudstack.api.ResponseObject.ResponseView;
21+
import org.apache.cloudstack.api.command.admin.AdminCmd;
2122
import org.apache.cloudstack.api.command.user.template.RegisterTemplateCmd;
2223
import org.apache.cloudstack.api.response.TemplateResponse;
2324

2425
@APICommand(name = "registerTemplate", description = "Registers an existing template into the CloudStack cloud.", responseObject = TemplateResponse.class, responseView = ResponseView.Full,
2526
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
26-
public class RegisterTemplateCmdByAdmin extends RegisterTemplateCmd {}
27+
public class RegisterTemplateCmdByAdmin extends RegisterTemplateCmd implements AdminCmd {
28+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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.template;
18+
19+
import org.apache.cloudstack.api.APICommand;
20+
import org.apache.cloudstack.api.ResponseObject.ResponseView;
21+
import org.apache.cloudstack.api.command.admin.AdminCmd;
22+
import org.apache.cloudstack.api.command.user.template.RegisterVnfTemplateCmd;
23+
import org.apache.cloudstack.api.response.TemplateResponse;
24+
25+
@APICommand(name = "registerVnfTemplate",
26+
description = "Registers an existing VNF template into the CloudStack cloud. ",
27+
responseObject = TemplateResponse.class, responseView = ResponseView.Full,
28+
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false,
29+
since = "4.19.0")
30+
public class RegisterVnfTemplateCmdByAdmin extends RegisterVnfTemplateCmd implements AdminCmd {
31+
}

api/src/main/java/org/apache/cloudstack/api/command/admin/template/UpdateTemplateCmdByAdmin.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@
2424

2525
@APICommand(name = "updateTemplate", description = "Updates attributes of a template.", responseObject = TemplateResponse.class, responseView = ResponseView.Full,
2626
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
27-
public class UpdateTemplateCmdByAdmin extends UpdateTemplateCmd implements AdminCmd {}
27+
public class UpdateTemplateCmdByAdmin extends UpdateTemplateCmd implements AdminCmd {
28+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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.template;
18+
19+
import org.apache.cloudstack.api.APICommand;
20+
import org.apache.cloudstack.api.ResponseObject.ResponseView;
21+
import org.apache.cloudstack.api.command.admin.AdminCmd;
22+
import org.apache.cloudstack.api.command.user.template.UpdateVnfTemplateCmd;
23+
import org.apache.cloudstack.api.response.TemplateResponse;
24+
25+
@APICommand(name = "updateVnfTemplate",
26+
description = "Updates a template to VNF template or attributes of a VNF template.",
27+
responseObject = TemplateResponse.class, responseView = ResponseView.Full,
28+
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false,
29+
since = "4.19.0")
30+
public class UpdateVnfTemplateCmdByAdmin extends UpdateVnfTemplateCmd implements AdminCmd {
31+
}

0 commit comments

Comments
 (0)