If I look in cloud_configure_azure_instance.py file on the management server instance deployed (R81.20) I see are defined the function to enable api on management and set the access permission:
def accepted_api_calls_from_allowed_value(self, enable_api_to):
"""#TODO fixDocstring"""
switcher = {
object_to_str(EnableApiAllowedValues.ALL):
EnableApiToCommand.ALL,
object_to_str(EnableApiAllowedValues.MANAGEMENT_ONLY):
EnableApiToCommand.
MANAGEMENT_ONLY,
object_to_str(EnableApiAllowedValues.GUI_CLIENTS):
EnableApiToCommand.
GUI_CLIENTS
}
return (switcher.get(enable_api_to))
def run_enable_api_commands(self, enable_api_to):
"""#TODO fixDocstring"""
accepted_api_calls_from = object_to_str(
self.accepted_api_calls_from_allowed_value(
enable_api_to.lower()))
enable_api_commands = ['api start',
'mgmt_cli -r true set-api-settings '
'accepted-api-calls-from "{}" --domain '
'\'System Data\''.format(
accepted_api_calls_from),
'api reconf']
for command in enable_api_commands:
try:
out, status = run_cmd(command)
except Exception as e:
log('{}'.format(e), level=logging.ERROR)
def enable_api(self):
"""#TODO fixDocstring"""
enable_api_to = self.template_vars[ENABLE_API]
is_valid_value = enable_api_to.lower() in (value.lower() for
value in
ENABLE_API_ALLOW_VALUES)
if is_valid_value:
self.run_enable_api_commands(enable_api_to)
else:
log(
"-- Error message: invalid value for 'enableApi' parameter. "
"The invalid value {} should be replaced by one of the "
"following values: {} or 'disable'.".format(
enable_api_to, ENABLE_API_ALLOW_VALUES),
level=logging.ERROR)
def enable_api_if_needed(self):
"""#TODO fixDocstring"""
enable_api = self.template_vars.get(ENABLE_API)
if not enable_api or enable_api == EnableApiAllowedValues.DISABLE:
pass
else:
self.enable_api()
In the file cloud_config_globals.py there are defined these two classes that confirm that I need to use the "all" value that is managed as "all ip addresses":
class EnableApiAllowedValues(set):
"""#TODO fixDocstring"""
DISABLE = "disable"
ALL = "all"
MANAGEMENT_ONLY = "management_only"
GUI_CLIENTS = "gui_clients"
class EnableApiToCommand(set):
"""#TODO fixDocstring"""
DISABLE = "disable"
ALL = "all ip addresses"
MANAGEMENT_ONLY = "management server only"
GUI_CLIENTS = "all ip addresses that can be used for gui clients"
So I need to understand why in my case the api are correctly enabled and started, but the access permissions are not set to any ip address despite the parameter is set to "all" but only in my latest days instead before was correctly setted to any and not to the default value "management server only".