|
| 1 | +# Copyright 2024 Cloudbase Solutions Srl |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 4 | +# not use this file except in compliance with the License. You may obtain |
| 5 | +# a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 11 | +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 12 | +# License for the specific language governing permissions and limitations |
| 13 | +# under the License. |
| 14 | + |
| 15 | +"""Config options available for the OpenStack metadata service.""" |
| 16 | + |
| 17 | +from oslo_config import cfg |
| 18 | + |
| 19 | +from cloudbaseinit.conf import base as conf_base |
| 20 | + |
| 21 | + |
| 22 | +class NoCloudOptions(conf_base.Options): |
| 23 | + |
| 24 | + """Config options available for the OpenStack metadata service.""" |
| 25 | + |
| 26 | + def __init__(self, config): |
| 27 | + super(NoCloudOptions, self).__init__(config, group="nocloud") |
| 28 | + self._options = [ |
| 29 | + cfg.StrOpt( |
| 30 | + "metadata_file", default="meta-data", |
| 31 | + help="The file name where the service looks for" |
| 32 | + "metadata"), |
| 33 | + cfg.StrOpt( |
| 34 | + "userdata_file", default="user-data", |
| 35 | + help="The file name where the service looks for" |
| 36 | + "userdata"), |
| 37 | + ] |
| 38 | + |
| 39 | + def register(self): |
| 40 | + """Register the current options to the global ConfigOpts object.""" |
| 41 | + group = cfg.OptGroup(self.group_name, title='NoCloud Options') |
| 42 | + self._config.register_group(group) |
| 43 | + self._config.register_opts(self._options, group=group) |
| 44 | + |
| 45 | + def list(self): |
| 46 | + """Return a list which contains all the available options.""" |
| 47 | + return self._options |
0 commit comments