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.
Table of Contents
CSS Cluster¶
List CSS Clusters¶
This interface is used to query an CSS cluster list..
Cluster
.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
print(list(conn.css.clusters()))
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': 'ES-Test',
'instanceNum': 3,
'datastore': {
'type': 'elasticsearch',
'version': '7.6.2'
},
'instance': {
'availability_zone': 'eu-de-01',
'flavorRef': 'css.xlarge.2',
'volume': {
'volume_type': 'COMMON',
'size': 100
},
'nics': {
'vpcId': 'vpcId',
'netId': 'netId',
'securityGroupId': 'securityGroupId'
}
},
'httpsEnable': 'false',
'diskEncryption': {
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)
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)))
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_setting=True)
# Set Cluster Snapshot Configuration with custom bucket & agency.
attrs = {
"bucket": "css-backup-1626212749424",
"agency": "css_obs_agency"
}
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)