mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 01:32:18 +02:00
server: don't export B&R APIs if feature is not enabled globally (#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 <rohit.yadav@shapeblue.com>
This commit is contained in:
parent
b141b8e256
commit
db9f8258d7
@ -38,7 +38,7 @@ public interface BackupManager extends BackupService, Configurable, PluggableSer
|
||||
ConfigKey<Boolean> BackupFrameworkEnabled = new ConfigKey<>("Advanced", Boolean.class,
|
||||
"backup.framework.enabled",
|
||||
"false",
|
||||
"Is backup and recovery framework enabled.", true, ConfigKey.Scope.Zone);
|
||||
"Is backup and recovery framework enabled.", false, ConfigKey.Scope.Zone);
|
||||
|
||||
ConfigKey<String> BackupProviderPlugin = new ConfigKey<>("Advanced", String.class,
|
||||
"backup.framework.provider.plugin",
|
||||
|
||||
@ -114,16 +114,21 @@ INSERT INTO `cloud`.`configuration` (category, instance, component, name, value)
|
||||
VALUES ('Advanced', 'DEFAULT', 'management-server',
|
||||
'ping.timeout', '2.0');
|
||||
|
||||
-- Enable dynamic RBAC by default for fresh deployments
|
||||
-- Enable dynamic RBAC by default for developers
|
||||
INSERT INTO `cloud`.`configuration` (category, instance, component, name, value)
|
||||
VALUES ('Advanced', 'DEFAULT', 'RoleService',
|
||||
'dynamic.apichecker.enabled', 'true');
|
||||
|
||||
-- Enable RootCA auth strictness for fresh deployments
|
||||
-- Enable RootCA auth strictness for developers
|
||||
INSERT INTO `cloud`.`configuration` (category, instance, component, name, value)
|
||||
VALUES ('Advanced', 'DEFAULT', 'RootCAProvider',
|
||||
'ca.plugin.root.auth.strictness', 'true');
|
||||
|
||||
-- Enable B&R feature for developers
|
||||
INSERT INTO `cloud`.`configuration` (category, instance, component, name, value)
|
||||
VALUES ('Advanced', 'DEFAULT', 'BackupService',
|
||||
'backup.framework.enabled', 'true');
|
||||
|
||||
-- Add developer configuration entry; allows management server to be run as a user other than "cloud"
|
||||
INSERT INTO `cloud`.`configuration` (category, instance, component, name, value)
|
||||
VALUES ('Advanced', 'DEFAULT', 'management-server',
|
||||
|
||||
@ -736,7 +736,7 @@ public class BackupManagerImpl extends ManagerBase implements BackupManager {
|
||||
}
|
||||
|
||||
public boolean isDisabled(final Long zoneId) {
|
||||
return !BackupFrameworkEnabled.valueIn(zoneId);
|
||||
return !(BackupFrameworkEnabled.value() && BackupFrameworkEnabled.valueIn(zoneId));
|
||||
}
|
||||
|
||||
private void validateForZone(final Long zoneId) {
|
||||
@ -769,6 +769,10 @@ public class BackupManagerImpl extends ManagerBase implements BackupManager {
|
||||
@Override
|
||||
public List<Class<?>> getCommands() {
|
||||
final List<Class<?>> cmdList = new ArrayList<Class<?>>();
|
||||
if (!BackupFrameworkEnabled.value()) {
|
||||
return cmdList;
|
||||
}
|
||||
|
||||
// Offerings
|
||||
cmdList.add(ListBackupProvidersCmd.class);
|
||||
cmdList.add(ListBackupProviderOfferingsCmd.class);
|
||||
|
||||
@ -41,15 +41,9 @@ class TestDummyBackupAndRecovery(cloudstackTestCase):
|
||||
assert False, "get_template() failed to return template with description %s" % cls.services["ostype"]
|
||||
cls.services["small"]["zoneid"] = cls.zone.id
|
||||
cls.services["small"]["template"] = cls.template.id
|
||||
cls.account = Account.create(cls.api_client, cls.services["account"], domainid=cls.domain.id)
|
||||
cls.offering = ServiceOffering.create(cls.api_client,cls.services["service_offerings"]["small"])
|
||||
cls.vm = VirtualMachine.create(cls.api_client, cls.services["small"], accountid=cls.account.name,
|
||||
domainid=cls.account.domainid, serviceofferingid=cls.offering.id,
|
||||
mode=cls.services["mode"])
|
||||
cls._cleanup = [cls.offering, cls.account]
|
||||
cls._cleanup = []
|
||||
|
||||
# Check backup configuration values, set them to enable the dummy provider
|
||||
|
||||
backup_enabled_cfg = Configurations.list(cls.api_client, name='backup.framework.enabled', zoneid=cls.zone.id)
|
||||
backup_provider_cfg = Configurations.list(cls.api_client, name='backup.framework.provider.plugin', zoneid=cls.zone.id)
|
||||
cls.backup_enabled = backup_enabled_cfg[0].value
|
||||
@ -59,7 +53,17 @@ class TestDummyBackupAndRecovery(cloudstackTestCase):
|
||||
Configurations.update(cls.api_client, 'backup.framework.enabled', value='true', zoneid=cls.zone.id)
|
||||
if cls.backup_provider != "dummy":
|
||||
Configurations.update(cls.api_client, 'backup.framework.provider.plugin', value='dummy', zoneid=cls.zone.id)
|
||||
|
||||
|
||||
if cls.hypervisor.lower() != 'simulator':
|
||||
return
|
||||
|
||||
cls.account = Account.create(cls.api_client, cls.services["account"], domainid=cls.domain.id)
|
||||
cls.offering = ServiceOffering.create(cls.api_client,cls.services["service_offerings"]["small"])
|
||||
cls.vm = VirtualMachine.create(cls.api_client, cls.services["small"], accountid=cls.account.name,
|
||||
domainid=cls.account.domainid, serviceofferingid=cls.offering.id,
|
||||
mode=cls.services["mode"])
|
||||
cls._cleanup = [cls.offering, cls.account]
|
||||
|
||||
# Import a dummy backup offering to use on tests
|
||||
|
||||
cls.provider_offerings = BackupOffering.listExternal(cls.api_client, cls.zone.id)
|
||||
@ -85,6 +89,8 @@ class TestDummyBackupAndRecovery(cloudstackTestCase):
|
||||
def setUp(self):
|
||||
self.apiclient = self.testClient.getApiClient()
|
||||
self.dbclient = self.testClient.getDbConnection()
|
||||
if self.hypervisor.lower() != 'simulator':
|
||||
raise self.skipTest("Skipping test cases which must only run for Simulator")
|
||||
self.cleanup = []
|
||||
|
||||
def tearDown(self):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user