blob: 71d6733f002545ac5714134d9bc646c0b29fcccf [file] [log] [blame]
Peter Pentchev469dfea2022-06-27 12:48:18 +03001#! /usr/bin/env python3
2
3# Copyright 2021 Canonical Ltd
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# 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, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17
18from ops_openstack.plugins.classes import CinderStoragePluginCharm
19from ops_openstack.core import charm_class, get_charm_class_for_release
20from ops.main import main
21
22
23class CinderCharmBase(CinderStoragePluginCharm):
24
25 PACKAGES = ['cinder-common']
26 MANDATORY_CONFIG = ['protocol']
27 # Overriden from the parent. May be set depending on the charm's properties
28 stateless = True
29 active_active = True
30
31 def __init__(self, *args, **kwargs):
32 super().__init__(*args, **kwargs)
33
34 def cinder_configuration(self, config):
35 # Return the configuration to be set by the principal.
36 backend_name = config.get('volume-backend-name',
37 self.framework.model.app.name)
38 volume_driver = ''
39 options = [
40 ('volume_driver', volume_driver),
41 ('volume_backend_name', backend_name),
42 ]
43
44 if config.get('use-multipath'):
45 options.extend([
46 ('use_multipath_for_image_xfer', True),
47 ('enforce_multipath_for_image_xfer', True)
48 ])
49
50 return options
51
52
53@charm_class
54class CinderStorPoolCharm(CinderCharmBase):
55 release = 'yoga'
56
57
58if __name__ == '__main__':
Peter Pentchev3a17d7d2022-07-27 13:11:57 +000059 # main(get_charm_class_for_release())
60 main(CinderStorPoolCharm)