Questo contenuto non è disponibile nella lingua selezionata.

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

Formazione

Prova, acquista e vendi

Community

Informazioni sulla documentazione di Red Hat

Aiutiamo gli utenti Red Hat a innovarsi e raggiungere i propri obiettivi con i nostri prodotti e servizi grazie a contenuti di cui possono fidarsi. Esplora i nostri ultimi aggiornamenti.

Rendiamo l’open source più inclusivo

Red Hat si impegna a sostituire il linguaggio problematico nel codice, nella documentazione e nelle proprietà web. Per maggiori dettagli, visita il Blog di Red Hat.

Informazioni su Red Hat

Forniamo soluzioni consolidate che rendono più semplice per le aziende lavorare su piattaforme e ambienti diversi, dal datacenter centrale all'edge della rete.

Theme

© 2026 Red Hat
Torna in cima