Workload Package

NSX Remediation Module

NSX Remediation for Workloads

class NSXRemediationJob(cb, running_job_ids)

Bases: object

An object that runs and monitors an NSX Remediation operation.

Creates a new NSXRemediationJob object.

Parameters:
  • cb (BaseAPI) – Reference to API object used to communicate with the server.

  • running_job_ids (list[str]) – The list of running job IDs.

async_await_result()

Sets up a Future which can be used to wait asynchronously for all running jobs to be completed.

Required Permissions:

appliances.registration(READ)

Returns:

A future representing the job and its results.

Return type:

Future

await_result()

Waits for all running jobs to be completed and returns the final status.

Required Permissions:

appliances.registration(READ)

Returns:

The final status, mapping individual job IDs to status value dicts.

Return type:

dict

classmethod start_request(cb, device_ids, tag, set_tag=True)

Starts an NSX Remediation request and returns the job object.

Required Permissions:

appliances.nsx.remediation(EXECUTE)

Parameters:
  • cb (BaseAPI) – Reference to API object used to communicate with the server.

  • device_ids (int|list) – The device ID(s) to run the remediation request on.

  • tag (str) – The NSX tag to apply to specified devices. Valid values are “CB-NSX-Quarantine”, “CB-NSX-Isolate”, and “CB-NSX-Custom”.

  • set_tag (bool) – True to toggle the specified tag on, False to toggle it off. Default True.

Returns:

The object representing all running jobs.

Return type:

NSXRemediationJob

Raises:
  • ApiError – If the parameters to start the request are incorrect.

  • ServerError – If the request could not be successfully started.

property status

Returns the current status.

Returns:

The current status, mapping individual job IDs to status value dicts.

Return type:

dict

Sensor Lifecycle Module

Sensor Lifecycle Management for Workloads

class SensorKit(cb, initial_data=None)

Bases: UnrefreshableModel

Represents the information about a sensor, including installation file URLs.

Parameters:
  • sensor_type – The type of information this sensor is for.

  • sensor_url – The URL for downloading the sensor installation package.

  • sensor_config_url – The URL for downloading the sensor configuration information.

  • error_code – Code for any error that occurred while getting the sensor information.

  • message – Message for any error that occurred while getting the sensor information.

Initialize the SensorKit object.

Parameters:
  • cb (BaseAPI) – Reference to API object used to communicate with the server.

  • initial_data (dict) – Initial data used to populate the sensor kit data.

classmethod from_type(cb, device_type, architecture, sensor_type, version)

Helper method used to create a temporary SensorKit object from its four components.

This method CANNOT be used to create an object that will be persisted to the server.

Parameters:
  • cb (BaseAPI) – Reference to API object used to communicate with the server.

  • device_type (str) – Device type to be used. Valid values are “WINDOWS”, “LINUX”, and “MAC”.

  • architecture (str) – Architecture to be used. Valid values are “32”, “64”, and “OTHER”.

  • sensor_type (str) – Sensor type to be used. Valid values are “WINDOWS”, “MAC”, “RHEL”, “UBUNTU”, “SUSE”, and “AMAZON_LINUX”.

  • version (str) – Sensor version number to be used.

Returns:

A SensorType object with those specified values.

Return type:

SensorType

Raises:

ApiError – If an invalid value was used for one of the three limited values.

get(attrname, default_val=None)

Return an attribute of this object.

Parameters:
  • attrname (str) – Name of the attribute to be returned.

  • default_val (Any) – Default value to be used if the attribute is not set.

Returns:

The returned attribute value, which may be defaulted.

Return type:

Any

classmethod get_config_template(cb)

Retrieve the sample config.ini file with the properties populated from the server.

Parameters:

cb (BaseAPI) – Reference to API object used to communicate with the server.

Returns:

Text of the sample configuration file.

Return type:

str

refresh()

Reload this object from the server.

to_json()

Return a json object of the response.

Returns:

The response dictionary representation.

Return type:

Any

class SensorKitQuery(doc_class, cb)

Bases: BaseQuery, CriteriaBuilderSupportMixin, IterableQueryMixin, AsyncQueryMixin

Query class used to read in SensorKit objects.

Initialize the SensorKitQuery.

Parameters:
  • doc_class (class) – The model class that will be returned by this query.

  • cb (BaseAPI) – Reference to API object used to communicate with the server.

add_criteria(key, newlist)

Add to the criteria on this query with a custom criteria key.

Will overwrite any existing criteria for the specified key.

Parameters:
  • key (str) – The key for the criteria item to be set.

  • newlist (str or list[str]) – Value or list of values to be set for the criteria item.

Returns:

The query object with specified custom criteria.

Example

>>> query = api.select(Alert).add_criteria("type", ["CB_ANALYTIC", "WATCHLIST"])
>>> query = api.select(Alert).add_criteria("type", "CB_ANALYTIC")
add_sensor_kit_type(skit=None, **kwargs)

Add a sensor kit type to the request.

Parameters:
  • skit (SensorKit) – The sensor kit type to be added to the request.

  • **kwargs (dict) – If skit is None, the keyword arguments ‘device_type’, ‘architecture’, ‘sensor_type’, and ‘version’ are used to create the sensor kit type to be added.

Returns:

Reference to this object.

Return type:

SensorKitQuery

all()

Returns all the items of a query as a list.

Returns:

List of query items

Return type:

list

config_params(params)

Sets the configuration parameters for the sensor kit query request.

Parameters:

params (str) – The text of a config.ini file with a list of sensor properties to configure on installation.

Returns:

Reference to this object.

Return type:

SensorKitQuery

execute_async()

Executes the current query in an asynchronous fashion.

Returns:

A future representing the query and its results.

Return type:

Future

expires(expiration_date_time)

Sets the expiration date and time for the sensor kit query request.

Parameters:

expiration_date_time (str) – The time at which the sensor download link will expire, expressed as ISO 8601 UTC.

Returns:

Reference to this object.

Return type:

SensorKitQuery

first()

Returns the first item that would be returned as the result of a query.

Returns:

First query item

Return type:

obj

one()

Returns the only item that would be returned by a query.

Returns:

Sole query return item

Return type:

obj

Raises:
update_criteria(key, newlist)

Update the criteria on this query with a custom criteria key.

Parameters:
  • key (str) – The key for the criteria item to be set.

  • newlist (list) – List of values to be set for the criteria item.

Returns:

The query object with specified custom criteria.

Example

>>> query = api.select(Alert).update_criteria("my.criteria.key", ["criteria_value"])

Note

Use this method if there is no implemented method for your desired criteria.