4.6.2. Instances¶
Warning
This API is deprecated.
Axonius API v2 is now available, we recommend you move to API v2.
New features will no longer be added to this API. Axonius will only provide bug fixes.
API for working with instances.
- class axonius_api_client.api.system.instances.Instances(auth, log_level='debug', **kwargs)[source]¶
Bases:
ModelMixins
API for working with instances.
Examples
Get all instances:
get()
Get the core instance:
get_core()
Get all collector instances:
get_collectors()
Get an instance by name:
get_by_name()
Set the name of an instance:
set_name()
Get the hostname of an instance:
get_hostname()
Set the hostname of an instance:
get_hostname()
Get the setting for is environment name of an instance:
get_is_env_name()
Set the setting for is environment name of an instance:
set_is_env_name()
Get the central core mode:
get_central_core_mode()
Set the central core mode:
get_central_core_mode()
Get the core delete backups mode:
get_core_delete_mode()
Set the core delete backups mode:
set_core_delete_mode()
Get the central core config:
get_central_core_config()
Perform a restore on a core from a file in an AWS S3 Bucket:
restore_from_aws_s3()
Notes
Certain functionality is not yet exposed, please submit a feature request via support@axonius.com if you would like to:
Deactivate an instance
Connect an instance
Tag an instance
- Parameters:
auth (
axonius_api_client.auth.model.AuthModel
) –log_level (
typing.Union
[int
,str
]) –
- get()[source]¶
Get metadata about all instances. :rtype:
dict
Examples
Create a
client
usingaxonius_api_client.connect.Connect
>>> data = client.instances.get() >>> len(data) 1
- get_core(key=None)[source]¶
Get the core instance.
Examples
Create a
client
usingaxonius_api_client.connect.Connect
>>> instance = client.instances.get_core() >>> instance['node_name'] 'Master' >>> instance['cpu_usage'] 39 >>> instance['data_disk_free_space'] 74431500 >>> instance['hostname'] 'builds-vm-jim-pre-3-10-1601596999-000' >>> instance['ips'] ['10.20.0.61'] >>> instance['data_disk_free_space_percent'] 36.62 >>> instance['memory_free_space_percent'] 1.46 >>> instance['swap_free_space_percent'] 0.0
- Parameters:
key (
typing.Optional
[str
]) – key to return or just return whole object- Return type:
- get_collectors()[source]¶
Get the collector instances. :rtype:
typing.List
[dict
]Examples
Create a
client
usingaxonius_api_client.connect.Connect
>>> collectors = client.instances.get_collectors() >>> len(collectors) 0
- get_by_name(name, key=None)[source]¶
Get an instance by name.
Examples
Create a
client
usingaxonius_api_client.connect.Connect
>>> instance = client.instances.get_by_name("Master") >>> instance['cpu_usage'] 39 >>> instance['data_disk_free_space'] 74431500 >>> instance['hostname'] 'builds-vm-jim-pre-3-10-1601596999-000' >>> instance['ips'] ['10.20.0.61'] >>> instance['data_disk_free_space_percent'] 36.62 >>> instance['memory_free_space_percent'] 1.46 >>> instance['swap_free_space_percent'] 0.0
- Parameters:
name (
str
) – name of instancekey (
typing.Optional
[str
]) – key to return or just return whole object
- Return type:
- get_by_name_id_core(value=None, serial=True)[source]¶
Pass.
- Parameters:
value (
typing.Optional
[str
]) –serial (
bool
) –
- Return type:
- get_tunnels(feature_error=True)[source]¶
Pass.
- Parameters:
feature_error (
bool
) –- Return type:
typing.List
[axonius_api_client.api.json_api.instances.Tunnel
]
- get_tunnel(value=None, return_id=False, feature_error=True)[source]¶
Pass.
- Parameters:
value (
typing.Optional
[str
]) –return_id (
bool
) –feature_error (
bool
) –
- Return type:
typing.Union
[axonius_api_client.api.json_api.instances.Tunnel
,str
,None
]
- get_tunnel_default(return_id=False, feature_error=True)[source]¶
Pass.
- Parameters:
- Return type:
typing.Union
[axonius_api_client.api.json_api.instances.Tunnel
,str
,None
]
- set_name(name, new_name)[source]¶
Set the name of an instance.
Examples
Create a
client
usingaxonius_api_client.connect.Connect
Get the current name
>>> orig_value = client.instances.get_core(key='name') >>> orig_value 'Master'
Set a new name
>>> new_value = client.instances.set_name(name=orig_value, new_name='Temp') >>> new_value 'Temp'
Revert back to the original name
>>> reset_value = client.instances.set_name(name=new_value, new_name=orig_value) >>> reset_value 'Master'
- get_hostname(name)[source]¶
Get the host name of an instance.
Examples
Create a
client
usingaxonius_api_client.connect.Connect
Get the hostname
>>> hostname = client.instances.get_hostname(name='Master') >>> hostname 'builds-vm-jim-pre-3-10-1601596999-000'
- set_hostname(name, value)[source]¶
Set the hostname of an instance.
Examples
Create a
client
usingaxonius_api_client.connect.Connect
Get the current hostname
>>> orig_value = client.instances.get_hostname(name='Master') >>> orig_value 'builds-vm-jim-pre-3-10-1601596999-000'
Set a new hostname
>>> new_value = client.instances.set_hostname(name='Master', value="hostname") >>> new_value "hostname"
Revert to the old hostname
>>> reset_value = client.instances.set_hostname(name='Master', value=orig_value) >>> reset_value 'builds-vm-jim-pre-3-10-1601596999-000'
- get_is_env_name(name)[source]¶
See if an instance name is being used for the environment name.
Examples
Create a
client
usingaxonius_api_client.connect.Connect
>>> client.instances.get_is_env_name(name='Master') False
Notes
Environment name is the name shown in the banner at the bottom of the GUI.
- set_is_env_name(name, enabled)[source]¶
Set if an instance name is being used for the environment name.
Examples
Create a
client
usingaxonius_api_client.connect.Connect
Enable an instance name as the environment name
>>> client.instances.set_is_env_name(name='Master', enabled=True) True
Disable an instance name as the environment name
>>> client.instances.set_is_env_name(name='Master', enabled=False) False
Notes
Environment name is the name shown in the banner at the bottom of the GUI.
- get_central_core_mode()[source]¶
Get a bool that shows if a core is in central core mode. :rtype:
bool
Examples
Create a
client
usingaxonius_api_client.connect.Connect
>>> client.instances.get_central_core_mode() False
- set_central_core_mode(enabled)[source]¶
Convert a normal core into a central core.
Examples
Create a
client
usingaxonius_api_client.connect.Connect
Enable central core mode on a core
>>> client.instances.set_central_core_mode(enabled=True) True
Disable central core mode on a core
>>> client.instances.set_central_core_mode(enabled=False) False
- get_core_delete_mode()[source]¶
Get a bool that shows if a core is in central core mode. :rtype:
bool
Examples
Create a
client
usingaxonius_api_client.connect.Connect
>>> client.instances.get_core_delete_mode() True
- set_core_delete_mode(enabled)[source]¶
Configure a normal core to delete backups after they have been restored.
Examples
Create a
client
usingaxonius_api_client.connect.Connect
Set backups to delete after restore
>>> client.instances.set_core_delete_mode(enabled=True) True
Set backups to NOT delete after restore
>>> client.instances.set_core_delete_mode(enabled=False) False
- factory_reset(reset=False)[source]¶
Perform a factory reset on an instance.
Notes
Can not run in test suite!
- Parameters:
reset (
bool
) – actually do it… be careful!- Return type:
axonius_api_client.api.json_api.instances.FactoryReset
- get_central_core_config()[source]¶
Get the current central core configuration. :rtype:
dict
Examples
Create a
client
usingaxonius_api_client.connect.Connect
>>> client.instances.get_central_core_config() {'core_delete_backups': False, 'central_core_enabled': False}
- restore_from_aws_s3(key_name, bucket_name=None, access_key_id=None, secret_access_key=None, preshared_key=None, allow_re_restore=None, delete_backups=None)[source]¶
Perform a restore on a core from a file in an AWS S3 Bucket.
Notes
Can not run in test suite!
- Parameters:
key_name (
str
) – Name of backup file from central core in [bucket_name] to restore to this corebucket_name (
typing.Optional
[str
]) – Name of bucket in S3 to get [key_name] from (OverridesGlobal Settings > Amazon S3 Settings > Amazon S3 bucket name
)access_key_id (
typing.Optional
[str
]) – AWS Access Key ID to use to access [bucket_name] (OverridesGlobal Settings > Amazon S3 Settings > AWS Access Key ID
)secret_access_key (
typing.Optional
[str
]) – AWS Secret Access Key to use to access [bucket_name] (OverridesGlobal Settings > Amazon S3 Settings > AWS Secret Access Key
)preshared_key (
typing.Optional
[str
]) – Password to use to decrypt [key_name] (Overrides:Global Settings > Amazon S3 Settings > Backup encryption passphrase
)allow_re_restore (
typing.Optional
[bool
]) – Restore [key_name] even if it has already been restoreddelete_backups (
typing.Optional
[bool
]) – Delete [key_name] from [bucket_name] after restore has finished (Overrides the current value ofget_core_delete_mode()
)
- Return type:
- property feature_flags: FeatureFlags¶
Get the feature flags for the core.
- admin_script_upload(file_name, file_content)[source]¶
Upload an admin script and execute it.
- Parameters:
file_name (
str
) – name to give uploaded script filefile_content (
typing.Union
[str
,bytes
]) – content to upload
- Return type:
- admin_script_upload_path(path, path_verify=True, **kwargs)[source]¶
Upload an admin script from a file or URL and execute it.
- Parameters:
path (
typing.Union
[str
,pathlib.Path
]) – URL or path to file of script to upload and execute**kwargs – passed to
upload_script()
path_verify (
bool
) –
- Return type:
- _get()[source]¶
Direct API method to get instances.
- Return type:
typing.List
[axonius_api_client.api.json_api.instances.Instance
]
- _factory_reset(approve_not_recoverable_action=False)[source]¶
Direct API method to do a factory reset on an instance.
Notes
Can not run in test suite!
- Parameters:
approve_not_recoverable_action (
bool
) – actually do it… be careful!- Return type:
axonius_api_client.api.json_api.instances.FactoryReset
- _update_attrs(node_id, node_name, hostname, use_as_environment_name)[source]¶
Direct API method to update an instance.
- _update_active(node_id, status)[source]¶
Direct API method to update an instance.
Notes
Can not run in test suite!
- _get_central_core_config()[source]¶
Direct API method to get the current central core configuration.
- Return type:
axonius_api_client.api.json_api.system_settings.SystemSettings
- _update_central_core_config(enabled, delete_backups)[source]¶
Direct API method to set the current central core configuration.
- _restore_aws(key_name, bucket_name=None, preshared_key=None, access_key_id=None, secret_access_key=None, delete_backups=None, allow_re_restore=None)[source]¶
Direct API method to perform a central core restore operation.
Notes
Can not run in test suite!
- Parameters:
restore_type – currently only AWS supported?
additional_data – options specific to restore_type
key_name (
str
) –bucket_name (
typing.Optional
[str
]) –preshared_key (
typing.Optional
[str
]) –access_key_id (
typing.Optional
[str
]) –secret_access_key (
typing.Optional
[str
]) –delete_backups (
typing.Optional
[bool
]) –allow_re_restore (
typing.Optional
[bool
]) –
- Return type:
axonius_api_client.api.json_api.central_core.CentralCoreRestore
- _feature_flags()[source]¶
Direct API method to get the feature flags for the core.
- Return type:
axonius_api_client.api.json_api.system_settings.FeatureFlags
- _admin_script_upload(file_name, file_content, chunk_size=104857600)[source]¶
Upload an admin script.
- _get_api_version()[source]¶
Pass.
- Return type:
axonius_api_client.api.json_api.generic.StrValueSchema
-
LOG:
logging.Logger
= None¶ Logger for this object.
- __init__(auth, log_level='debug', **kwargs)¶
Mixins for API Models.
- Parameters:
auth (
axonius_api_client.auth.model.AuthModel
) – object to use for auth and sending API requestslog_level (
typing.Union
[int
,str
]) – logging level to use for this objects logger**kwargs – passed to
_init()
- _init(**kwargs)¶
Post init method for subclasses to use for extra setup.
- _init_auth(**kwargs)¶
Post init method for subclasses to use for overriding auth setup.
-
auth:
axonius_api_client.auth.model.AuthModel
= None¶ Authentication model with bound Http object to use for requests.
-
http:
axonius_api_client.http.Http
= None¶ Http object to use for requests.