AILearnDocumentationResourcesConsoleDevelopersSupportSearch

A.3. Python SDK Example: Cluster


createCluster
def createCluster(name, datacenterName,
                     cpu_type=config.HOST_CPU_TYPE, version=VERSION, enable_virt=False, enable_gluster=True):
     """ Creates cluster """
     LOGGER.info("create_cluster")
     dc = API.datacenters.get(datacenterName)
     API.clusters.add(params.Cluster(
                 name=name,
                 cpu=params.CPU(id=cpu_type),
                 data_center=dc,
                 version=VERSION,
                 virt_service=enable_virt,
                 gluster_service=enable_gluster))
     cluster = API.clusters.get(name)
     LOGGER.info("Creating cluster '%s'" % name)
     assert cluster is not None

Example A.1. Building a cluster object

You can build a cluster object by passing the required parameters to the api.clusters.add() function.
api.clusters.add(params.Cluster(name="mytest.cluster.3", cpu=params.CPU(id="Intel Nehalem Family"),
data_center=dc, virt_service=False, gluster_service=True))
removeCluster
 def removeCluster(name):
     """ Removes cluster """
     cluster = API.clusters.get(name)
     if cluster is not None:
         cluster.delete()
         LOGGER.info("Removing cluster '%s'" % name)
         assert updateObject(cluster) is None, "Can't remove cluster"
22632%2C+Console+Developer+Guide-322-09-2014+17%3A11%3A35Report a bug
Red Hat logoGithubredditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat Documentation

Legal Notice

Theme

© 2026 Red Hat
Back to top