Skip to content

Instantly share code, notes, and snippets.

@prehensilecode
Created August 4, 2020 21:03
Show Gist options
  • Save prehensilecode/ef64d5d157b9240dd16cb923a3133ee4 to your computer and use it in GitHub Desktop.
Save prehensilecode/ef64d5d157b9240dd16cb923a3133ee4 to your computer and use it in GitHub Desktop.
Programmatically update node categories in Bright Cluster Manager 9.0 using Python
#!/usr/bin/env python3
import sys
import os
from pythoncm.cluster import Cluster
from pythoncm.settings import Settings
from pythoncm.entity import *
debug_p = False
cluster = Cluster()
categories = cluster.get_by_type(Category)
for c in categories:
if debug_p:
print(c.name)
if c.name == "compute-202007":
compute202007 = c
print("compute202007 category = {}".format(compute202007))
nodes = cluster.get_by_type(ComputeNode)
for n in nodes:
if n.category.name == "compute":
print("Changing category for node {} from {} to {}".format(n.hostname, n.category.name, compute202007.name))
n.category = compute202007
n.commit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment