Workload¶
Submodules¶
cbc_sdk.workload.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.
-
RUNNING_STATUSES
= ['UNASSIGNED', 'SCHEDULED', 'RUNNING', 'RUNNING_UNDELIVERED']¶
-
VALID_TAGS
= ['CB-NSX-Quarantine', 'CB-NSX-Isolate', 'CB-NSX-Custom']¶
-
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: Raises: ApiError
– If the parameters to start the request are incorrect.ServerError
– If the request could not be successfully started.
-
status
¶ Returns the current status.
Returns: The current status, mapping individual job IDs to status value dicts. Return type: dict
cbc_sdk.workload.sensor_lifecycle module¶
Sensor Lifecycle Management for Workloads
-
class
SensorKit
(cb, initial_data=None)¶ Bases:
cbc_sdk.base.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.
-
COMPUTE_RESOURCE_MAP
= {'CENTOS': 'RHEL', 'ORACLE': 'RHEL', 'SLES': 'SUSE'}¶
-
VALID_ARCHITECTURES
= ['32', '64', 'OTHER']¶
-
VALID_DEVICE_TYPES
= ['WINDOWS', 'LINUX', 'MAC']¶
-
VALID_TYPES
= ['WINDOWS', 'MAC', 'RHEL', 'UBUNTU', 'SUSE', 'AMAZON_LINUX']¶
-
error_code
= None¶
-
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.
-
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
-
message
= None¶
-
sensor_config_url
= None¶
-
sensor_type
= {}¶
-
sensor_url
= None¶
-
class
SensorKitQuery
(doc_class, cb)¶ Bases:
cbc_sdk.base.BaseQuery
,cbc_sdk.base.CriteriaBuilderSupportMixin
,cbc_sdk.base.IterableQueryMixin
,cbc_sdk.base.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_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:
-
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
-
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
cbc_sdk.workload.vm_workloads_search module¶
Model and Query Classes for VM Workloads Search API
-
class
ComputeResource
(cb, model_unique_id, initial_data=None)¶ Bases:
cbc_sdk.base.NewBaseModel
ComputeResource Model
Initialize the ComputeResource object.
Parameters: - cb (BaseAPI) – Reference to API object used to communicate with the server.
- model_unique_id (str) – ID of the alert represented.
- initial_data (dict) – Initial data used to populate the alert.
-
classmethod
bulk_install
(cb, compute_resources, sensor_kit_types, config_file=None)¶ Install a sensor on a list of compute resources.
Parameters: - cb (BaseAPI) – Reference to API object used to communicate with the server.
- compute_resources (list) – A list of ComputeResource objects used to specify compute resources to install sensors on.
- sensor_kit_types (list) – A list of SensorKit objects used to specify sensor types to choose from in installation.
- config_file (str) – The text of a config.ini file with a list of sensor properties to configure on installation.
Returns: A dict with two members, ‘type’ and ‘code’, indicating the status of the installation.
Return type: dict
-
classmethod
bulk_install_by_id
(cb, compute_resources, sensor_kit_types, config_file=None)¶ Install a sensor on a list of compute resources, specified by ID.
Parameters: - cb (BaseAPI) – Reference to API object used to communicate with the server.
- compute_resources (list) – A list of dicts, each of which contains the keys ‘vcenter_uuid’ and ‘compute_resource_id’, specifying the compute resources to install sensors on.
- sensor_kit_types (list) – A list of SensorKit objects used to specify sensor types to choose from in installation.
- config_file (str) – The text of a config.ini file with a list of sensor properties to configure on installation.
Returns: A dict with two members, ‘type’ and ‘code’, indicating the status of the installation.
Return type: dict
-
install_sensor
(sensor_version, config_file=None)¶ Install a sensor on this compute resource.
Parameters: - sensor_version (str) – The version number of the sensor to be used.
- config_file (str) – The text of a config.ini file with a list of sensor properties to configure on installation.
Returns: A dict with two members, ‘type’ and ‘code’, indicating the status of the installation.
Return type: dict
Raises: ApiError
– If the compute node is not eligible or is of an invalid type.
-
primary_key
= 'id'¶
-
urlobject
= '/lcm/view/v1/orgs/{0}/compute_resources'¶
-
urlobject_single
= '/lcm/view/v1/orgs/{0}/compute_resources/{1}'¶
-
class
ComputeResourceQuery
(doc_class, cb)¶ Bases:
cbc_sdk.base.BaseQuery
,cbc_sdk.base.QueryBuilderSupportMixin
,cbc_sdk.base.CriteriaBuilderSupportMixin
,cbc_sdk.base.IterableQueryMixin
,cbc_sdk.base.AsyncQueryMixin
Represents a query that is used to locate ComputeResource objects.
Initialize the ComputeResource.
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.
-
VALID_DIRECTIONS
= ('ASC', 'DESC')¶
-
VALID_ELIGIBILITY
= ('ELIGIBLE', 'NOT_ELIGIBLE', 'UNSUPPORTED')¶
-
VALID_INSTALLATION_STATUS
= ('SUCCESS', 'ERROR', 'PENDING', 'NOT_INSTALLED')¶
-
VALID_OS_ARCHITECTURE
= ('32', '64')¶
-
VALID_OS_TYPE
= ('WINDOWS', 'RHEL', 'UBUNTU', 'SUSE', 'SLES', 'CENTOS', 'OTHER', 'AMAZON_LINUX', 'ORACLE')¶
-
set_appliance_uuid
(appliance_uuid)¶ Restricts the search that this query is performed on to the specified appliance uuid.
Parameters: appliance_uuid (list) – List of string appliance uuids. Returns: This instance. Return type: ComputeResourceQuery
-
set_cluster_name
(cluster_name)¶ Restricts the search that this query is performed on to the specified cluster name.
Parameters: cluster_name (list) – List of string cluster names. Returns: This instance. Return type: ComputeResourceQuery
-
set_eligibility
(eligibility)¶ Restricts the search that this query is performed on to the specified eligibility.
Parameters: eligibility (list) – List of string eligibilities. Returns: This instance. Return type: ComputeResourceQuery
-
set_installation_status
(installation_status)¶ Restricts the search that this query is performed on to the specified installation status.
Parameters: installation_status (list) – List of string installation status. Returns: This instance. Return type: ComputeResourceQuery
-
set_ip_address
(ip_address)¶ Restricts the search that this query is performed on to the specified ip address.
Parameters: ip_address (list) – List of string ip addresses. Returns: This instance. Return type: ComputeResourceQuery
-
set_name
(name)¶ Restricts the search that this query is performed on to the specified name.
Parameters: name (list) – List of string names. Returns: This instance. Return type: ComputeResourceQuery
-
set_os_architecture
(os_architecture)¶ Restricts the search that this query is performed on to the specified os architecture.
Parameters: os_architecture (list) – List of string os architecture. Returns: This instance. Return type: ComputeResourceQuery
-
set_os_type
(os_type)¶ Restricts the search that this query is performed on to the specified os type.
Parameters: os_type (list) – List of string os type. Returns: This instance. Return type: ComputeResourceQuery
-
set_uuid
(uuid)¶ Restricts the search that this query is performed on to the specified uuid.
Parameters: uuid (list) – List of string uuid. Returns: This instance. Return type: ComputeResourceQuery
-
sort_by
(key, direction='ASC')¶ Sets the sorting behavior on a query’s results.
Example
>>> cb.select(ComputeResource).sort_by("name")
Parameters: - key (str) – The key in the schema to sort by.
- direction (str) – The sort order.
Returns: This instance.
Return type:
-
log
= <Logger cbc_sdk.workload.vm_workloads_search (WARNING)>¶ type: Workloads Search model