Skip to content

Commit 686534a

Browse files
committed
config: fix ManagementServer scope
Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
1 parent 8f15865 commit 686534a

File tree

13 files changed

+278
-9
lines changed

13 files changed

+278
-9
lines changed

api/src/main/java/org/apache/cloudstack/api/command/admin/config/ListCfgsByCmd.java

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,24 @@
1919
import java.util.ArrayList;
2020
import java.util.List;
2121

22-
import org.apache.cloudstack.api.ApiErrorCode;
23-
import org.apache.cloudstack.api.ServerApiException;
24-
import org.apache.cloudstack.api.response.DomainResponse;
25-
import org.apache.commons.lang3.StringUtils;
26-
2722
import org.apache.cloudstack.api.APICommand;
23+
import org.apache.cloudstack.api.ApiArgValidator;
2824
import org.apache.cloudstack.api.ApiConstants;
25+
import org.apache.cloudstack.api.ApiErrorCode;
2926
import org.apache.cloudstack.api.BaseListCmd;
3027
import org.apache.cloudstack.api.Parameter;
28+
import org.apache.cloudstack.api.ServerApiException;
3129
import org.apache.cloudstack.api.response.AccountResponse;
3230
import org.apache.cloudstack.api.response.ClusterResponse;
3331
import org.apache.cloudstack.api.response.ConfigurationResponse;
32+
import org.apache.cloudstack.api.response.DomainResponse;
3433
import org.apache.cloudstack.api.response.ImageStoreResponse;
3534
import org.apache.cloudstack.api.response.ListResponse;
35+
import org.apache.cloudstack.api.response.ManagementServerResponse;
3636
import org.apache.cloudstack.api.response.StoragePoolResponse;
3737
import org.apache.cloudstack.api.response.ZoneResponse;
3838
import org.apache.cloudstack.config.Configuration;
39+
import org.apache.commons.lang3.StringUtils;
3940

4041
import com.cloud.exception.InvalidParameterValueException;
4142
import com.cloud.utils.Pair;
@@ -94,6 +95,14 @@ public class ListCfgsByCmd extends BaseListCmd {
9495
description = "The ID of the Image Store to update the parameter value for corresponding image store")
9596
private Long imageStoreId;
9697

98+
@Parameter(name = ApiConstants.MANAGEMENT_SERVER_ID,
99+
type = CommandType.UUID,
100+
entityType = ManagementServerResponse.class,
101+
description = "the ID of the Management Server to update the parameter value for corresponding management server",
102+
validations = ApiArgValidator.PositiveNumber,
103+
since = "4.21.0")
104+
private Long managementServerId;
105+
97106
@Parameter(name = ApiConstants.GROUP, type = CommandType.STRING, description = "Lists configuration by group name (primarily used for UI)", since = "4.18.0")
98107
private String groupName;
99108

@@ -139,6 +148,10 @@ public Long getImageStoreId() {
139148
return imageStoreId;
140149
}
141150

151+
public Long getManagementServerId() {
152+
return managementServerId;
153+
}
154+
142155
public String getGroupName() {
143156
return groupName;
144157
}
@@ -200,6 +213,9 @@ private void setScope(ConfigurationResponse cfgResponse) {
200213
if (getImageStoreId() != null){
201214
cfgResponse.setScope("imagestore");
202215
}
216+
if (getManagementServerId() != null){
217+
cfgResponse.setScope("managementserver");
218+
}
203219
}
204220

205221
@Override

api/src/main/java/org/apache/cloudstack/api/command/admin/config/ResetCfgCmd.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.apache.cloudstack.api.Parameter;
2525
import org.apache.cloudstack.api.ServerApiException;
2626
import org.apache.cloudstack.api.response.ImageStoreResponse;
27+
import org.apache.cloudstack.api.response.ManagementServerResponse;
2728
import org.apache.cloudstack.framework.config.ConfigKey;
2829

2930
import org.apache.cloudstack.api.response.AccountResponse;
@@ -84,6 +85,14 @@ public class ResetCfgCmd extends BaseCmd {
8485
description = "The ID of the Image Store to reset the parameter value for corresponding image store")
8586
private Long imageStoreId;
8687

88+
@Parameter(name = ApiConstants.MANAGEMENT_SERVER_ID,
89+
type = CommandType.UUID,
90+
entityType = ManagementServerResponse.class,
91+
description = "the ID of the Management Server to update the parameter value for corresponding management server",
92+
validations = ApiArgValidator.PositiveNumber,
93+
since = "4.21.0")
94+
private Long managementServerId;
95+
8796
/////////////////////////////////////////////////////
8897
/////////////////// Accessors ///////////////////////
8998
/////////////////////////////////////////////////////
@@ -116,6 +125,10 @@ public Long getImageStoreId() {
116125
return imageStoreId;
117126
}
118127

128+
public Long getManagementServerId() {
129+
return managementServerId;
130+
}
131+
119132
/////////////////////////////////////////////////////
120133
/////////////// API Implementation///////////////////
121134
/////////////////////////////////////////////////////
@@ -149,6 +162,9 @@ public void execute() {
149162
if (getImageStoreId() != null) {
150163
response.setScope(ConfigKey.Scope.ImageStore.name());
151164
}
165+
if (getManagementServerId() != null) {
166+
response.setScope(ConfigKey.Scope.ManagementServer.name());
167+
}
152168
response.setValue(cfg.second());
153169
this.setResponseObject(response);
154170
} else {

api/src/main/java/org/apache/cloudstack/api/command/admin/config/UpdateCfgCmd.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import org.apache.cloudstack.api.response.ClusterResponse;
3131
import org.apache.cloudstack.api.response.ConfigurationResponse;
3232
import org.apache.cloudstack.api.response.ImageStoreResponse;
33+
import org.apache.cloudstack.api.response.ManagementServerResponse;
3334
import org.apache.cloudstack.api.response.StoragePoolResponse;
3435
import org.apache.cloudstack.api.response.ZoneResponse;
3536
import org.apache.cloudstack.config.Configuration;
@@ -88,6 +89,14 @@ public class UpdateCfgCmd extends BaseCmd {
8889
validations = ApiArgValidator.PositiveNumber)
8990
private Long imageStoreId;
9091

92+
@Parameter(name = ApiConstants.MANAGEMENT_SERVER_ID,
93+
type = CommandType.UUID,
94+
entityType = ManagementServerResponse.class,
95+
description = "the ID of the Management Server to update the parameter value for corresponding management server",
96+
validations = ApiArgValidator.PositiveNumber,
97+
since = "4.21.0")
98+
private Long managementServerId;
99+
91100
/////////////////////////////////////////////////////
92101
/////////////////// Accessors ///////////////////////
93102
/////////////////////////////////////////////////////
@@ -112,7 +121,7 @@ public Long getClusterId() {
112121
return clusterId;
113122
}
114123

115-
public Long getStoragepoolId() {
124+
public Long getStoragePoolId() {
116125
return storagePoolId;
117126
}
118127

@@ -128,6 +137,10 @@ public Long getImageStoreId() {
128137
return imageStoreId;
129138
}
130139

140+
public Long getManagementServerId() {
141+
return managementServerId;
142+
}
143+
131144
/////////////////////////////////////////////////////
132145
/////////////// API Implementation///////////////////
133146
/////////////////////////////////////////////////////
@@ -182,7 +195,7 @@ public ConfigurationResponse setResponseScopes(ConfigurationResponse response) {
182195
if (getClusterId() != null) {
183196
response.setScope("cluster");
184197
}
185-
if (getStoragepoolId() != null) {
198+
if (getStoragePoolId() != null) {
186199
response.setScope("storagepool");
187200
}
188201
if (getAccountId() != null) {

engine/schema/src/main/resources/META-INF/cloudstack/core/spring-engine-schema-core-daos-context.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@
116116
<bean id="loadBalancerVMMapDaoImpl" class="com.cloud.network.dao.LoadBalancerVMMapDaoImpl" />
117117
<bean id="loadBalancerCertMapDaoImpl" class="com.cloud.network.dao.LoadBalancerCertMapDaoImpl" />
118118
<bean id="managementServerHostDaoImpl" class="com.cloud.cluster.dao.ManagementServerHostDaoImpl" />
119+
<bean id="managementServerHostDetailsDaoImpl" class="com.cloud.cluster.dao.ManagementServerHostDetailsDaoImpl" />
119120
<bean id="managementServerHostPeerDaoImpl" class="com.cloud.cluster.dao.ManagementServerHostPeerDaoImpl" />
120121
<bean id="managementServerHostPeerJoinDaoImpl" class="com.cloud.cluster.dao.ManagementServerHostPeerJoinDaoImpl" />
121122
<bean id="managementServerStatusDaoImpl" class="com.cloud.cluster.dao.ManagementServerStatusDaoImpl" />

engine/schema/src/main/resources/META-INF/db/schema-42010to42100.sql

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,6 @@ SET `sort_key` = CASE
208208
END;
209209
-- End: Changes for Guest OS category cleanup
210210

211-
<<<<<<< HEAD
212211
-- Update description for configuration: host.capacityType.to.order.clusters
213212
UPDATE `cloud`.`configuration` SET
214213
`description` = 'The host capacity type (CPU, RAM or COMBINED) is used by deployment planner to order clusters during VM resource allocation'
@@ -759,6 +758,18 @@ SET `cs`.`domain_id` = (
759758
-- Re-apply VPC: update default network offering for vpc tier to conserve_mode=1 (#8309)
760759
UPDATE `cloud`.`network_offerings` SET conserve_mode = 1 WHERE name = 'DefaultIsolatedNetworkOfferingForVpcNetworks';
761760

761+
-- Add management_server_details table to allow ManagementServer scope configs
762+
CREATE TABLE IF NOT EXISTS `management_server_details` (
763+
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
764+
`management_server_id` bigint unsigned NOT NULL COMMENT 'management server the detail is related to',
765+
`name` varchar(255) NOT NULL COMMENT 'name of the detail',
766+
`value` varchar(255) NOT NULL,
767+
`display` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'True if the detail can be displayed to the end user',
768+
PRIMARY KEY (`id`),
769+
CONSTRAINT `fk_management_server_details__management_server_id` FOREIGN KEY `fk_management_server_details__management_server_id`(`management_server_id`) REFERENCES `mshost`(`id`) ON DELETE CASCADE,
770+
KEY `i_management_server_details__name__value` (`name`(128),`value`(128))
771+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
772+
762773
-- Create table for logs web session
763774
CREATE TABLE IF NOT EXISTS `cloud`.`logs_web_session` (
764775
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY,

framework/cluster/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@
4848
<artifactId>cloud-api</artifactId>
4949
<version>${project.version}</version>
5050
</dependency>
51+
<dependency>
52+
<groupId>org.apache.cloudstack</groupId>
53+
<artifactId>cloud-engine-schema</artifactId>
54+
<version>4.21.0.0-SNAPSHOT</version>
55+
<scope>compile</scope>
56+
</dependency>
5157
</dependencies>
5258

5359
</project>
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
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+
package com.cloud.cluster;
19+
20+
import javax.persistence.Column;
21+
import javax.persistence.Entity;
22+
import javax.persistence.GeneratedValue;
23+
import javax.persistence.GenerationType;
24+
import javax.persistence.Id;
25+
import javax.persistence.Table;
26+
27+
import org.apache.cloudstack.api.ResourceDetail;
28+
29+
@Entity
30+
@Table(name = "management_server_details")
31+
public class ManagementServerHostDetailVO implements ResourceDetail {
32+
@Id
33+
@GeneratedValue(strategy = GenerationType.IDENTITY)
34+
@Column(name = "id")
35+
long id;
36+
37+
@Column(name = "management_server_id")
38+
long resourceId;
39+
40+
@Column(name = "name")
41+
String name;
42+
43+
@Column(name = "value")
44+
String value;
45+
46+
@Column(name = "display")
47+
private boolean display = true;
48+
49+
public ManagementServerHostDetailVO(long poolId, String name, String value, boolean display) {
50+
this.resourceId = poolId;
51+
this.name = name;
52+
this.value = value;
53+
this.display = display;
54+
}
55+
56+
public ManagementServerHostDetailVO() {
57+
}
58+
59+
@Override
60+
public long getId() {
61+
return id;
62+
}
63+
64+
@Override
65+
public long getResourceId() {
66+
return resourceId;
67+
}
68+
69+
@Override
70+
public String getName() {
71+
return name;
72+
}
73+
74+
public void setValue(String value) {
75+
this.value = value;
76+
}
77+
78+
@Override
79+
public String getValue() {
80+
return value;
81+
}
82+
83+
@Override
84+
public boolean isDisplay() {
85+
return display;
86+
}
87+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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+
package com.cloud.cluster.dao;
19+
20+
import org.apache.cloudstack.resourcedetail.ResourceDetailsDao;
21+
22+
import com.cloud.cluster.ManagementServerHostDetailVO;
23+
import com.cloud.utils.db.GenericDao;
24+
25+
public interface ManagementServerHostDetailsDao extends GenericDao<ManagementServerHostDetailVO, Long>, ResourceDetailsDao<ManagementServerHostDetailVO> {
26+
}
27+
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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+
package com.cloud.cluster.dao;
19+
20+
import org.apache.cloudstack.framework.config.ConfigKey;
21+
import org.apache.cloudstack.framework.config.ScopedConfigStorage;
22+
import org.apache.cloudstack.resourcedetail.ResourceDetailsDaoBase;
23+
24+
import com.cloud.cluster.ManagementServerHostDetailVO;
25+
26+
public class ManagementServerHostDetailsDaoImpl extends ResourceDetailsDaoBase<ManagementServerHostDetailVO> implements ManagementServerHostDetailsDao, ScopedConfigStorage {
27+
28+
public ManagementServerHostDetailsDaoImpl() {
29+
}
30+
31+
@Override
32+
public ConfigKey.Scope getScope() {
33+
return ConfigKey.Scope.ManagementServer;
34+
}
35+
36+
@Override
37+
public String getConfigValue(long id, String key) {
38+
ManagementServerHostDetailVO vo = findDetail(id, key);
39+
return vo == null ? null : vo.getValue();
40+
}
41+
42+
@Override
43+
public void addDetail(long resourceId, String key, String value, boolean display) {
44+
super.addDetail(new ManagementServerHostDetailVO(resourceId, key, value, display));
45+
}
46+
}

0 commit comments

Comments
 (0)