3.5.7.2 Python

Obtaining the Server Pool ID Value

If you have only just created the server pool, and you made use of the wait_for_job function that we defined in Track Job Status, you should already have a dictionary populated with the new server pool ID. If you are creating a cluster for an existing server pool and need to obtain an ID value for it, you can use the SOAP API to obtain the ID for any server pool based on the name assigned to it:

spids=client.service.serverPoolGetIds()
for sp in spids:
    if sp.name=='MyServerPool':
       svrpool_id=sp
Create the Cluster Object

Using the Suds Client Factory, it is simple to define the cluster object that is required for the serverPoolCreateCluster method. In this case, we only set the name of the cluster object:

cluster=client.factory.create('cluster')
cluster.name='MyServerPool_cluster'

Using the server pool ID and the cluster object that we have just created, we can call the serverPoolCreateCluster method to create the cluster for the server pool:

job=client.service.serverPoolCreateCluster(svrpool_id,cluster)
clusterid=wait_for_job(client,job.id)
Create the Cluster Heartbeat Device

Finally, to create a cluster heartbeat device you need to choose a shared storage repository that can be used for the heartbeat device. If you have not already set up a storage repository, you must do so before continuing. See Section 3.5.9, “Discovering a Network File Server” and Section 3.5.10, “Creating a Storage Repository” for more information. In our example, we use an NFS repository that is already available within Oracle VM Manager:

for id in client.service.fileSystemGetIds():
    if hasattr(id,'name'):
        if id.name=="nfs:/mnt/vol1/poolfs01":
            fsid=id

Now use the Suds Client Factory to create a clusterHeartbeatDevice object:

clhbdev=client.factory.create('clusterHeartbeatDevice')
clhbdev.name="MyServerPool_cluster_heartbeat"
clhbdev.storageType="NFS"
clhbdev.networkFileSystemId=fsid
job=client.service.clusterCreateHeartbeatDevice(clusterid,clhbdev)
clhbdevid=wait_for_job(client,job.id)