When a volume is created, the volume object needs a Red Hat Gluster Storage volume name, volume type and the bricks to be associated with the volume. Before creating a volume, you need to build a corresponding cluster object and associate that cluster with brick objects.
Copy to ClipboardCopied!Toggle word wrapToggle overflow
glusterVolumeStart
To start a volume, you need to pass the cluster name with which the Red Hat Gluster Storage volume is associated and the corresponding volume name to the glusterVolumeStart() function.
Copy to ClipboardCopied!Toggle word wrapToggle overflow
glusterVolumeStop
To stop a volume, you need to pass the cluster name with which the Red Hat Gluster Storage volume is associated and the corresponding volume name to the glusterVolumeStart() function.
Copy to ClipboardCopied!Toggle word wrapToggle overflow
Rebalance operations: startRebalance, stopRebalance, and rebalanceStatus
To rebalance data among the servers, you need to pass the cluster name and the volume name to the startRebalance and stopRebalance functions and the jobID to the rebalanceStatus function.
import ovirtsdk
from ovirtsdk.api import API
from ovirtsdk.xml import params
# This function returns a stop rebalance task instance. Using this
# we can reterive the status of the stop rebalance.
# ex. volume = stopRebalance(clusterName, volumeName)
# print volume.status.state
def stopRebalance(clusterName, volumeName):
volume = api.clusters.get(clusterName).glustervolumes.get(volumeName)
try:
return volume.stoprebalance()
except ovirtsdk.infrastructure.errors.RequestError, e:
print "Error"
def startRebalance(clusterName, volumeName):
volume = api.clusters.get(clusterName).glustervolumes.get(volumeName)
return volume.rebalance()
def rebalanceStatus(jobId):
# jobs.get accepts job name and job id as an optional
# parameters to provide the job details.
return api.jobs.get(None, jobId)
clusterName="Default" # name of the cluser
volumeName="music" # name of the volume which belongs
# to the purticular cluster
try:
api = API (url="https://HOST",
username="USER",
password="PASS",
ca_file="ca.crt")
status = startRebalance(clusterName, volumeName)
jobId = status.job.get_id()
# jobId return by startRebalance can be stored somewhere
# for later use. With out the jobId it would be very
# difficult to find out the actual status of this task.
print jobId
privStatus = None
while True:
status = rebalanceStatus(jobId)
jobStatus = status.get_status().get_state()
if jobStatus != privStatus:
print "Description: ", status.get_description()
print "Status: ", jobStatus
if "FINISHED" == jobStatus:
break
privStatus = jobStatus
api.disconnect()
except Exception as ex:
print "Unexpected error: %s" % ex
import ovirtsdk
from ovirtsdk.api import API
from ovirtsdk.xml import params
# This function returns a stop rebalance task instance. Using this
# we can reterive the status of the stop rebalance.
# ex. volume = stopRebalance(clusterName, volumeName)
# print volume.status.state
def stopRebalance(clusterName, volumeName):
volume = api.clusters.get(clusterName).glustervolumes.get(volumeName)
try:
return volume.stoprebalance()
except ovirtsdk.infrastructure.errors.RequestError, e:
print "Error"
def startRebalance(clusterName, volumeName):
volume = api.clusters.get(clusterName).glustervolumes.get(volumeName)
return volume.rebalance()
def rebalanceStatus(jobId):
# jobs.get accepts job name and job id as an optional
# parameters to provide the job details.
return api.jobs.get(None, jobId)
clusterName="Default" # name of the cluser
volumeName="music" # name of the volume which belongs
# to the purticular cluster
try:
api = API (url="https://HOST",
username="USER",
password="PASS",
ca_file="ca.crt")
status = startRebalance(clusterName, volumeName)
jobId = status.job.get_id()
# jobId return by startRebalance can be stored somewhere
# for later use. With out the jobId it would be very
# difficult to find out the actual status of this task.
print jobId
privStatus = None
while True:
status = rebalanceStatus(jobId)
jobStatus = status.get_status().get_state()
if jobStatus != privStatus:
print "Description: ", status.get_description()
print "Status: ", jobStatus
if "FINISHED" == jobStatus:
break
privStatus = jobStatus
api.disconnect()
except Exception as ex:
print "Unexpected error: %s" % ex
Copy to ClipboardCopied!Toggle word wrapToggle overflow