Copy to ClipboardCopied!Toggle word wrapToggle overflow
remove_Brick
try:
for volume in api.clusters.get(
CLUSTERNAME).glustervolumes.list():
for brick in volume.bricks.list():
if brick.name == BRICKNAME:
brick.delete()
api.disconnect()
except Exception as e:
print "Unexpected error: %s" % e
try:
for volume in api.clusters.get(
CLUSTERNAME).glustervolumes.list():
for brick in volume.bricks.list():
if brick.name == BRICKNAME:
brick.delete()
api.disconnect()
except Exception as e:
print "Unexpected error: %s" % e
Copy to ClipboardCopied!Toggle word wrapToggle overflow
Remove brick operations: startRemoveBrick and removeBrickStatus
You can start a remove brick operation and query the brick status using the code snippet below:
import ovirtsdk
from ovirtsdk.api import API
from ovirtsdk.xml import params
api = None
clusterName = "Default" # name of the cluster
volumeName = "music" # name of the volume which belongs #to the particular cluster
brickName = "10.70.42.164:/home/music_b1"
# brick name. We can get the brick details which are associated to the #volume using getGlusterVolumeBrickDetails(..)
def startRemoveBrick(clusterName, volumeName, brickName):
volume = api.clusters.get(clusterName).glustervolumes.get(volumeName)
bricks = volume.get_bricks()
if not bricks:
return None
brick = bricks.get(brickName)
if not brick:
return None
try:
return brick.delete()
except ovirtsdk.infrastructure.errors.RequestError as e:
print e
def removeBrickStatus(jobId):
# jobs.get accepts job name and job id as an optional
# parameters to provide the job details.
return api.jobs.get(None, jobId)
try:
api = API (url="https://HOST",
username="USER@domain",
password="PASS",
ca_file="ca.crt")
status = startRemoveBrick(clusterName, volumeName, brickName)
if status:
jobId = status.job.get_id()
privStatus = None
while True:
status = removeBrickStatus(jobId)
jobStatus = status.get_status().get_state()
if jobStatus != privStatus:
print "Description: ", status.get_description()
print "Status: ", jobStatus
if "FINISHED" == jobStatus:
break
privStatus = jobStatus
else:
print "Unable to retrieve the brick details"
api.disconnect()
except Exception as ex:
print "Unexpected error: %s" % ex
import ovirtsdk
from ovirtsdk.api import API
from ovirtsdk.xml import params
api = None
clusterName = "Default" # name of the cluster
volumeName = "music" # name of the volume which belongs #to the particular cluster
brickName = "10.70.42.164:/home/music_b1"
# brick name. We can get the brick details which are associated to the #volume using getGlusterVolumeBrickDetails(..)
def startRemoveBrick(clusterName, volumeName, brickName):
volume = api.clusters.get(clusterName).glustervolumes.get(volumeName)
bricks = volume.get_bricks()
if not bricks:
return None
brick = bricks.get(brickName)
if not brick:
return None
try:
return brick.delete()
except ovirtsdk.infrastructure.errors.RequestError as e:
print e
def removeBrickStatus(jobId):
# jobs.get accepts job name and job id as an optional
# parameters to provide the job details.
return api.jobs.get(None, jobId)
try:
api = API (url="https://HOST",
username="USER@domain",
password="PASS",
ca_file="ca.crt")
status = startRemoveBrick(clusterName, volumeName, brickName)
if status:
jobId = status.job.get_id()
privStatus = None
while True:
status = removeBrickStatus(jobId)
jobStatus = status.get_status().get_state()
if jobStatus != privStatus:
print "Description: ", status.get_description()
print "Status: ", jobStatus
if "FINISHED" == jobStatus:
break
privStatus = jobStatus
else:
print "Unable to retrieve the brick details"
api.disconnect()
except Exception as ex:
print "Unexpected error: %s" % ex
Copy to ClipboardCopied!Toggle word wrapToggle overflow
Note
Commit is not an action that can be performed on a brick. Commit happens as part of the delete action. If a remove brick action is in finished state, it commits the changes else it perform a force delete operation.
Important
The code snippet above forcefully remove the brick without migrating the data on the brick.
22632%2C+Console+Developer+Guide-322-09-2014+17%3A11%3A35Report a bug
Nous aidons les utilisateurs de Red Hat à innover et à atteindre leurs objectifs grâce à nos produits et services avec un contenu auquel ils peuvent faire confiance. Découvrez nos récentes mises à jour.
Rendre l’open source plus inclusif
Red Hat s'engage à remplacer le langage problématique dans notre code, notre documentation et nos propriétés Web. Pour plus de détails, consultez le Blog Red Hat.
À propos de Red Hat
Nous proposons des solutions renforcées qui facilitent le travail des entreprises sur plusieurs plates-formes et environnements, du centre de données central à la périphérie du réseau.