Cloud Search Service (CSS)

Cloud Search Service is a fully hosted distributed search service powered on Elasticsearch. It is fully compatible with Elasticsearch APIs and provides users with structured and unstructured data search, statistics, and report capabilities.

CSS Cluster

List CSS Clusters

This interface is used to query an CSS cluster list.. Cluster.

import openstack
import json

openstack.enable_logging(True)
conn = openstack.connect()

for cluster in conn.css.clusters():
    print(json.dumps(cluster.to_dict(computed=False), indent=4))

Create CSS Cluster

This interface is used to create a CSS cluster with parameters. Cluster.

import openstack

openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')

attrs = {
    'name': 'test-cluster',
    'datastore': {'type': 'elasticsearch', 'version': '7.10.2'},
    'instanceNum': 3,
    'httpsEnable': False,
    'diskEncryption': {
        'systemEncrypted': '0',
    },
    'instance': {
        'availability_zone': 'eu-de-01',
        'flavorRef': 'css.xlarge.2',
        'volume': {'volume_type': 'COMMON', 'size': 100},
        'nics': {
            'vpcId': 'router-id',
            'netId': 'network-id',
            'securityGroupId': 'security-group-id',
        },
    },
    'tags': [
        {'key': 'key0', 'value': 'value0'},
        {'key': 'key1', 'value': 'value1'},
    ],
    'backupStrategy': {
        'period': '00:00 GMT+03:00',
        'prefix': 'backup',
        'keepday': 1,
        'bucket': 'css-test-0',
        'agency': 'test-css',
        'basePath': 'css',
    },
}
cluster = conn.css.create_cluster(**attrs)
conn.css.wait_for_cluster(cluster)
result = conn.css.get_cluster(cluster)
print(result)

Get CSS Cluster

This interface is used to get a CSS cluster by ID or an instance of class Cluster.

import openstack

openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')

cluster_id = 'cluster-uuid'
resp = conn.css.get_cluster(cluster_id)
print(resp)

Find CSS Cluster

This interface is used to find a CSS cluster by id or name. Cluster.

import openstack

openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')

name_or_id = 'css-test-1'
resp = conn.css.find_cluster(name_or_id, ignore_missing=False)
print(resp)

Restart CSS Cluster

This interface is used to restart a CSS cluster by id or an instance of class Cluster.

import openstack

openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')

cluster_id = 'cluter-uuid'
conn.css.restart_cluster(cluster_id)

Extend CSS Cluster

This interface is used to extend CSS cluster by id or an instance of class Cluster.

import openstack

openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')

cluster_id = 'cluster-uuid'
add_nodes = 2
conn.css.extend_cluster(cluster_id, add_nodes)

Extend CSS Cluster Nodes

This interface is used to extend CSS cluster nodes by id or an instance of class Cluster.

import openstack

openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')

cluster_id = 'cluster-uuid'
attrs = {
    'grow': [
        {'type': 'ess-master', 'nodesize': 2, 'disksize': 0},
        {'type': 'ess', 'nodesize': 0, 'disksize': 60},
        {'type': 'ess-client', 'nodesize': 1, 'disksize': 0},
    ]
}
conn.css.extend_cluster_nodes(cluster_id, **attrs)

Delete CSS Cluster

This interface is used to delete a CSS Cluster by ID or an instance of class Cluster.

import openstack

openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')

cluster_id = 'cluster-uuid'
conn.css.delete_cluster(cluster_id)

Add CSS Cluster Nodes

This interface is used to add master and client nodes to a cluster. Cluster.

import openstack

openstack.enable_logging(True)
conn = openstack.connect()

cluster_name_or_id = 'a4915eea-7a70-4058-bbf5-c391989c10e3'

attrs = {
    'node_type': 'ess-master',
    'flavor': 'ced8d1a7-eff8-4e30-a3de-cd9578fd518f',
    'node_size': 3,
    'volume_type': 'COMMON',
}

cluster = conn.css.find_cluster(cluster_name_or_id, ignore_missing=False)

conn.css.add_cluster_nodes(cluster, **attrs)

Create CSS Opensearch Cluster

This interface is used to create a CSS opensearch cluster with parameters. Cluster.

import openstack

openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')


attrs = {
    'name': 'opensearch_test',
    'instanceNum': 3,
    'datastore': {
        'type': 'opensearch',
        'version': '1.3.6',
    },
    'instance': {
        'availability_zone': 'eu-de-01',
        'flavorRef': 'css.xlarge.2',
        'volume': {
            'volume_type': 'COMMON',
            'size': 100,
        },
        'nics': {
            'vpcId': 'VPC-ID',
            'netId': 'Network-ID',
            'securityGroupId': 'SecurityGroup-ID',
        },
    },
    'httpsEnable': 'false',
    'diskEncryption': {
        'systemEncrypted': '0',
    },
    'tags': [
        {'key': 'key0', 'value': 'value0'},
        {'key': 'key1', 'value': 'value1'},
    ],
    'backupStrategy': {
        'period': '00:00 GMT+01:00',
        'prefix': 'backup',
        'keepday': 1,
        'bucket': 'css-backup-1663481103064',
        'agency': 'test_agency',
        'basePath': 'css',
    },
}
result = conn.css.create_cluster(**attrs)
conn.css.wait_for_cluster(result)
cluster = conn.css.get_cluster(result)
print(cluster)

Get CSS Cluster Upgrade Info

This interface is used to obtain the CSS cluster updgrade details. Cluster.

import openstack


openstack.enable_logging(True)
conn = openstack.connect()

cluster_name_or_id = 'ce50ce66-3083-437c-91aa-58921abd9f99'
cluster = conn.css.find_cluster(cluster_name_or_id)

resp = conn.css.get_cluster_upgrade_status(cluster)

for cluster_upgrade_info in resp:
    print(cluster_upgrade_info)

Get CSS Cluster Upgradable Version Info

This interface is used to get the CSS cluster upgradable version info. Cluster.

import openstack

openstack.enable_logging(True)
conn = openstack.connect()

cluster_name_or_id = 'css-test0802'
upgrade_type = 'same'

cluster = conn.css.find_cluster(cluster_name_or_id)

resp = conn.css.cluster_upgradable_versions(cluster, upgrade_type)
print(resp)

Replace CSS Cluster Node

This interface is used to replace a failed node in a CSS cluster. Cluster.

import openstack

openstack.enable_logging(True)
conn = openstack.connect()

cluster_name_or_id = '3b300b4e-2aa9-45c0-b898-a9e6fa319922'
node_id = '3b04c1ab-3887-4cb6-9796-d15619cec0f5'

cluster = conn.css.find_cluster(cluster_name_or_id)

conn.css.replace_cluster_node(cluster, node_id)

Retry CSS Cluster Upgrade Job

This interface is used to retry a task or terminate the impact of a task in a CSS cluster. Cluster.

import openstack

openstack.enable_logging(True)
conn = openstack.connect()

cluster_name_or_id = '3b300b4e-2aa9-45c0-b898-a9e6fa319922'
job_id = '0249620d-1c4a-4211-943a-ced7b9a3cda5'
retry_mode = 'abort'

cluster = conn.css.find_cluster(cluster_name_or_id)

conn.css.retry_cluster_upgrade_job(cluster, job_id, retry_mode)

Scale In CSS cluster

This interface is used to scale in a CSS cluster by removing specified nodes. Cluster.:

import openstack

openstack.enable_logging(True)
conn = openstack.connect()

cluster_name_or_id = 'ce50ce66-3083-437c-91aa-58921abd9f99'
cluster = conn.css.find_cluster(cluster_name_or_id)

nodes = ['5e134b90-8159-4233-9dae-4305029a838a']

conn.css.scale_in_cluster(cluster, nodes)

Scale In CSS Cluster By Node Type

This interface is used to remove instances of specific types and reduce instance storage capacity in a CSS cluster. Cluster.

import openstack

openstack.enable_logging(True)
conn = openstack.connect()

cluster_name_or_id = 'css-c647'
cluster = conn.css.find_cluster(cluster_name_or_id)

nodes = [{'type': 'ess', 'reducedNodeNum': 1}]

conn.css.scale_in_cluster_by_node_type(cluster, nodes)

Update CSS Cluster Flavor

This interface is used to update the flavor of a CSS cluster. Cluster.

import openstack

openstack.enable_logging(True)
conn = openstack.connect()

cluster_name_or_id = 'asomogyi_0509'

node_type = 'ess'

check_replica = False
new_flavor = 'd9dc06ae-b9c4-4ef4-acd8-953ef4205e27'

cluster = conn.css.find_cluster(cluster_name_or_id)

conn.css.update_cluster_flavor(cluster, new_flavor, node_type, check_replica)

Update CSS Cluster Kernel

This interface is used to update the kernel of a CSS cluster. Cluster.

import openstack

openstack.enable_logging(True)
conn = openstack.connect()

cluster_name_or_id = 'csstest0716'
cluster = conn.css.find_cluster(cluster_name_or_id)

upgrade_type = 'cross'
target_image = conn.css.get_cluster_version_upgrade_info(cluster, upgrade_type)
target_image = next(iter(target_image.image_info_list))
if target_image:
    target_image_id = target_image.id
    indices_backup_check = True
    agency = 'css_upgrade_agency'
    cluster_load_check = True
    conn.css.update_cluster_kernel(
        cluster,
        target_image_id,
        upgrade_type,
        indices_backup_check,
        agency,
        cluster_load_check,
    )

Update CSS Cluster Name

This interface is used to update the name of a CSS cluster. Cluster.

import openstack

openstack.enable_logging(True)
conn = openstack.connect()

cluster_name_or_id = 'asomogyi_0506_update_vpruthi'

new_name = 'asomogyi_0506_test'

cluster = conn.css.find_cluster(cluster_name_or_id)

conn.css.update_cluster_name(cluster, new_name)

Update CSS Cluster Password

This interface is used to update the password of a CSS cluster. Cluster.

import openstack

openstack.enable_logging(True)
conn = openstack.connect()

cluster_name_or_id = 'asomogyi_0506_updated'

new_password = 'NewCssPassword123'

cluster = conn.css.find_cluster(cluster_name_or_id)

conn.css.update_cluster_password(cluster, new_password)

Update CSS Cluster Security Group

This interface is used to update the security group of a CSS cluster. Cluster.

import openstack

openstack.enable_logging(True)
conn = openstack.connect()

cluster_name_or_id = 'asomogyi_0506_updated'

security_group_id = '2a386cf6-bf8a-494b-8e2a-f550307a4871'

cluster = conn.css.find_cluster(cluster_name_or_id)

conn.css.update_cluster_security_group(cluster, security_group_id)

Update CSS Cluster Security Mode

This interface is used to update the security mode of a CSS cluster. Cluster.

import openstack

openstack.enable_logging(True)
conn = openstack.connect()

cluster_name_or_id = 'css-c414'

cluster = conn.css.find_cluster(cluster_name_or_id)

conn.css.update_cluster_security_mode(
    cluster,
    https_enable=True,
    authority_enable=True,
    admin_pwd='testTEST123!!!',
)

CSS Cluster Snapshot

The SNAT function translates a private IP address to a public IP address by binding EIPs to servers in a VPC, providing secure and efficient access to the Internet.

List Snapshots

This interface is used to query all snapshots of a cluster by id or an instance of cluster class. Snapshot.

import openstack


openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')

cluster_id = 'cluster-uuid'
print(list(conn.css.snapshots(cluster_id)))

Find Snapshot

This interface is used to find a CSS snapshot by id or name. Cluster.

import openstack

openstack.enable_logging(True)
conn = openstack.connect(cloud='bigdataai')

cluster_name_or_id = 'asomogyi_0509'
snapshot_name_or_id = 'snapshot-2037'
cluster = conn.css.find_cluster(cluster_name_or_id, ignore_missing=False)
snapshot = conn.css.find_snapshot(
    cluster, snapshot_name_or_id, ignore_missing=False
)
print(snapshot)

Create Snapshot

This interface is used to manually create a snapshot by id or an instance of cluster class. Snapshot.

import openstack

openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')

cluster_id = 'cluster-uuid'
attrs = {
    'name': 'snapshot_001',
    'indices': 'myindex1,myindex2',
    'description': '',
}

result = conn.css.create_snapshot(cluster_id, **attrs)
print(result)

Restore Snapshot

This interface is used to restore a snapshot with indices to a target cluster. Snapshot.

import openstack

openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')

attrs = {
    'targetCluster': 'target-cluster-uuid',
    'indices': 'myindex1,myindex2',
}

cluster_id = 'cluster-uuid'
snapshot_id = 'snapshot-uuid'

conn.css.restore_snapshot(cluster_id, snapshot_id, **attrs)

Delete Snapshot

This interface is used to delete a manually created snapshot of a cluster. This interface requires id or an instance of cluster class and id of the snapshot. Snapshot.

import openstack

openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')

cluster_id = 'cluster-uuid'
snapshot_id = 'snapshot-uuid'
conn.css.delete_snapshot(cluster_id, snapshot_id)

Set Snapshot Policy

This interface is used to set parameters related to automatic snapshot creation for a cluster. SnapshotPolicy.

import openstack

openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')

attrs = {
    'prefix': 'snapshot',
    'period': '16:00 GMT+08:00',
    'keepday': 7,
    'enable': 'true',
}

cluster_id = 'cluster-uuid'
resp = conn.css.set_snapshot_policy(cluster_id, **attrs)
print(resp)

Get Snapshot Policy

This interface is used to query the automatic snapshot creation policy for a cluster. SnapshotPolicy.

import openstack

openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')

cluster_id = 'cluster-uuid'
resp = conn.css.get_snapshot_policy(cluster_id)
print(resp)

Set Snapshot Configuration

This interface is used to set basic configurations for a cluster snapshot, including configuring OBS buckets and IAM agency. SnapshotConfiguration.

import openstack

openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')

cluster_id = 'cluster-uuid'

# Set Cluster Snapshot Configuration automatically.
conn.css.set_snapshot_configuration(cluster_id, auto_configure=True)

# Set Cluster Snapshot Configuration with custom bucket & agency.
attrs = {
    'bucket': 'css-backup-1626212749424',
    'agency': 'css_obs_agency',
    'backup_path': 'css/repository/test-css',
}
conn.css.set_snapshot_configuration(cluster_id, **attrs)

Disable Snapshot Function

This interface is used to disable the snapshot function for a cluster. Snapshot.

import openstack

openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')

cluster_id = 'cluster-uuid'
conn.css.disable_snapshot_function(cluster_id)

CSS Flavor

List CSS Flavors

This interface is used to query list of node types (flavors) supported by CSS Cluster. Flavor.

import openstack


openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')

print(list(conn.css.flavors()))