Skip to content

Commit db9f825

Browse files
server: don't export B&R APIs if feature is not enabled globally (apache#4202)
This change will ensure that B&R APIs are not exported if the feature is not enabled in any of the zones. Signed-off-by: Rohit Yadav <[email protected]>
1 parent b141b8e commit db9f825

File tree

4 files changed

+27
-12
lines changed

4 files changed

+27
-12
lines changed

api/src/main/java/org/apache/cloudstack/backup/BackupManager.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public interface BackupManager extends BackupService, Configurable, PluggableSer
3838
ConfigKey<Boolean> BackupFrameworkEnabled = new ConfigKey<>("Advanced", Boolean.class,
3939
"backup.framework.enabled",
4040
"false",
41-
"Is backup and recovery framework enabled.", true, ConfigKey.Scope.Zone);
41+
"Is backup and recovery framework enabled.", false, ConfigKey.Scope.Zone);
4242

4343
ConfigKey<String> BackupProviderPlugin = new ConfigKey<>("Advanced", String.class,
4444
"backup.framework.provider.plugin",

developer/developer-prefill.sql

+7-2
Original file line numberDiff line numberDiff line change
@@ -114,16 +114,21 @@ INSERT INTO `cloud`.`configuration` (category, instance, component, name, value)
114114
VALUES ('Advanced', 'DEFAULT', 'management-server',
115115
'ping.timeout', '2.0');
116116

117-
-- Enable dynamic RBAC by default for fresh deployments
117+
-- Enable dynamic RBAC by default for developers
118118
INSERT INTO `cloud`.`configuration` (category, instance, component, name, value)
119119
VALUES ('Advanced', 'DEFAULT', 'RoleService',
120120
'dynamic.apichecker.enabled', 'true');
121121

122-
-- Enable RootCA auth strictness for fresh deployments
122+
-- Enable RootCA auth strictness for developers
123123
INSERT INTO `cloud`.`configuration` (category, instance, component, name, value)
124124
VALUES ('Advanced', 'DEFAULT', 'RootCAProvider',
125125
'ca.plugin.root.auth.strictness', 'true');
126126

127+
-- Enable B&R feature for developers
128+
INSERT INTO `cloud`.`configuration` (category, instance, component, name, value)
129+
VALUES ('Advanced', 'DEFAULT', 'BackupService',
130+
'backup.framework.enabled', 'true');
131+
127132
-- Add developer configuration entry; allows management server to be run as a user other than "cloud"
128133
INSERT INTO `cloud`.`configuration` (category, instance, component, name, value)
129134
VALUES ('Advanced', 'DEFAULT', 'management-server',

server/src/main/java/org/apache/cloudstack/backup/BackupManagerImpl.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,7 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
736736
}
737737

738738
public boolean isDisabled(final Long zoneId) {
739-
return !BackupFrameworkEnabled.valueIn(zoneId);
739+
return !(BackupFrameworkEnabled.value() && BackupFrameworkEnabled.valueIn(zoneId));
740740
}
741741

742742
private void validateForZone(final Long zoneId) {
@@ -769,6 +769,10 @@ public BackupProvider getBackupProvider(final String name) {
769769
@Override
770770
public List<Class<?>> getCommands() {
771771
final List<Class<?>> cmdList = new ArrayList<Class<?>>();
772+
if (!BackupFrameworkEnabled.value()) {
773+
return cmdList;
774+
}
775+
772776
// Offerings
773777
cmdList.add(ListBackupProvidersCmd.class);
774778
cmdList.add(ListBackupProviderOfferingsCmd.class);

test/integration/smoke/test_backup_recovery_dummy.py

+14-8
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,9 @@ def setUpClass(cls):
4141
assert False, "get_template() failed to return template with description %s" % cls.services["ostype"]
4242
cls.services["small"]["zoneid"] = cls.zone.id
4343
cls.services["small"]["template"] = cls.template.id
44-
cls.account = Account.create(cls.api_client, cls.services["account"], domainid=cls.domain.id)
45-
cls.offering = ServiceOffering.create(cls.api_client,cls.services["service_offerings"]["small"])
46-
cls.vm = VirtualMachine.create(cls.api_client, cls.services["small"], accountid=cls.account.name,
47-
domainid=cls.account.domainid, serviceofferingid=cls.offering.id,
48-
mode=cls.services["mode"])
49-
cls._cleanup = [cls.offering, cls.account]
44+
cls._cleanup = []
5045

5146
# Check backup configuration values, set them to enable the dummy provider
52-
5347
backup_enabled_cfg = Configurations.list(cls.api_client, name='backup.framework.enabled', zoneid=cls.zone.id)
5448
backup_provider_cfg = Configurations.list(cls.api_client, name='backup.framework.provider.plugin', zoneid=cls.zone.id)
5549
cls.backup_enabled = backup_enabled_cfg[0].value
@@ -59,7 +53,17 @@ def setUpClass(cls):
5953
Configurations.update(cls.api_client, 'backup.framework.enabled', value='true', zoneid=cls.zone.id)
6054
if cls.backup_provider != "dummy":
6155
Configurations.update(cls.api_client, 'backup.framework.provider.plugin', value='dummy', zoneid=cls.zone.id)
62-
56+
57+
if cls.hypervisor.lower() != 'simulator':
58+
return
59+
60+
cls.account = Account.create(cls.api_client, cls.services["account"], domainid=cls.domain.id)
61+
cls.offering = ServiceOffering.create(cls.api_client,cls.services["service_offerings"]["small"])
62+
cls.vm = VirtualMachine.create(cls.api_client, cls.services["small"], accountid=cls.account.name,
63+
domainid=cls.account.domainid, serviceofferingid=cls.offering.id,
64+
mode=cls.services["mode"])
65+
cls._cleanup = [cls.offering, cls.account]
66+
6367
# Import a dummy backup offering to use on tests
6468

6569
cls.provider_offerings = BackupOffering.listExternal(cls.api_client, cls.zone.id)
@@ -85,6 +89,8 @@ def tearDownClass(cls):
8589
def setUp(self):
8690
self.apiclient = self.testClient.getApiClient()
8791
self.dbclient = self.testClient.getDbConnection()
92+
if self.hypervisor.lower() != 'simulator':
93+
raise self.skipTest("Skipping test cases which must only run for Simulator")
8894
self.cleanup = []
8995

9096
def tearDown(self):

0 commit comments

Comments
 (0)