Skip to content

Commit f4e2258

Browse files
committed
config: fix ManagementServer scope
Signed-off-by: Abhishek Kumar <[email protected]>
1 parent b2c8fa5 commit f4e2258

File tree

13 files changed

+273
-3
lines changed

13 files changed

+273
-3
lines changed

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@
1919
import java.util.ArrayList;
2020
import java.util.List;
2121

22+
import org.apache.cloudstack.api.ApiArgValidator;
2223
import org.apache.cloudstack.api.ApiErrorCode;
2324
import org.apache.cloudstack.api.ServerApiException;
2425
import org.apache.cloudstack.api.response.DomainResponse;
26+
import org.apache.cloudstack.api.response.ManagementServerResponse;
2527
import org.apache.commons.lang3.StringUtils;
2628

2729
import org.apache.cloudstack.api.APICommand;
@@ -94,6 +96,14 @@ public class ListCfgsByCmd extends BaseListCmd {
9496
description = "the ID of the Image Store to update the parameter value for corresponding image store")
9597
private Long imageStoreId;
9698

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

@@ -139,6 +149,10 @@ public Long getImageStoreId() {
139149
return imageStoreId;
140150
}
141151

152+
public Long getManagementServerId() {
153+
return managementServerId;
154+
}
155+
142156
public String getGroupName() {
143157
return groupName;
144158
}
@@ -200,6 +214,9 @@ private void setScope(ConfigurationResponse cfgResponse) {
200214
if (getImageStoreId() != null){
201215
cfgResponse.setScope("imagestore");
202216
}
217+
if (getManagementServerId() != null){
218+
cfgResponse.setScope("managementserver");
219+
}
203220
}
204221

205222
@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
/////////////////////////////////////////////////////
@@ -184,7 +197,7 @@ public ConfigurationResponse setResponseScopes(ConfigurationResponse response) {
184197
if (getClusterId() != null) {
185198
response.setScope("cluster");
186199
}
187-
if (getStoragepoolId() != null) {
200+
if (getStoragePoolId() != null) {
188201
response.setScope("storagepool");
189202
}
190203
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: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,17 @@ AND NOT EXISTS(SELECT 1 FROM cloud.role_permissions rp_ WHERE rp.role_id = rp_.r
3838

3939
CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.host', 'last_mgmt_server_id', 'bigint unsigned DEFAULT NULL COMMENT "last management server this host is connected to" AFTER `mgmt_server_id`');
4040

41+
CREATE TABLE IF NOT EXISTS `management_server_details` (
42+
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
43+
`management_server_id` bigint unsigned NOT NULL COMMENT 'management server the detail is related to',
44+
`name` varchar(255) NOT NULL COMMENT 'name of the detail',
45+
`value` varchar(255) NOT NULL,
46+
`display` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'True if the detail can be displayed to the end user',
47+
PRIMARY KEY (`id`),
48+
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,
49+
KEY `i_management_server_details__name__value` (`name`(128),`value`(128))
50+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
51+
4152
CREATE TABLE IF NOT EXISTS `cloud`.`logs_web_session` (
4253
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY,
4354
`uuid` varchar(40) NOT NULL COMMENT 'UUID generated for the session',

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)