def get_option(self, option, *options, **kwargs):
     if option == 'db':
         src = {
             option: {
                 'host': 'localhost',
                 'port': 3306,
                 'type': 'mysql',
                 'user': '******'
             },
         }
     elif option == 'ip':
         return utils.get_host_ip()
     elif utils.has_any(option, 'extra_flags', 'extra_opts', 'instances_path'):
         return ''
     else:
         # Make a fake dictionary hierachy
         src = make_fakey([option] + list(options))
     return utils.get_deep(src, [option] + list(options))
Example #2
0
 def get_interpolated_option(self, option, default_value=None):
     tried = [option]
     while True:
         option_value = utils.get_deep(self.options, [option])
         if option_value is None:
             return default_value
         else:
             if not isinstance(option_value, six.string_types):
                 return option_value
             if option_value.startswith("$"):
                 maybe_option = option_value[1:]
                 if maybe_option in tried:
                     tried.append(maybe_option)
                     raise excp.ConfigException("Option loop %s detected" % tried)
                 else:
                     tried.append(maybe_option)
                     option = maybe_option
             else:
                 return option_value
 def get_option(self, option, *options, **kwargs):
     if option == 'db':
         src = {
             option: {
                 'host': 'localhost',
                 'port': 3306,
                 'type': 'mysql',
                 'user': '******'
             },
         }
     elif option == 'ip':
         return utils.get_host_ip()
     elif utils.has_any(option, 'extra_flags', 'extra_opts',
                        'instances_path'):
         return ''
     else:
         # Make a fake dictionary hierachy
         src = make_fakey([option] + list(options))
     return utils.get_deep(src, [option] + list(options))
Example #4
0
 def get_option(self, option, *options, **kwargs):
     option_value = utils.get_deep(self.options, [option] + list(options))
     if option_value is None:
         return kwargs.get('default_value')
     else:
         return option_value
Example #5
0
 def get_option(self, option, *options, **kwargs):
     option_value = utils.get_deep(self.options, [option] + list(options))
     if option_value is None:
         return kwargs.get('default_value')
     else:
         return option_value