diff --git a/initializers/cluster_groups.yml b/initializers/cluster_groups.yml new file mode 100644 index 0000000..a611afa --- /dev/null +++ b/initializers/cluster_groups.yml @@ -0,0 +1,4 @@ +# - name: Group 1 +# slug: group-1 +# - name: Group 2 +# slug: group-2 diff --git a/initializers/clusters.yml b/initializers/clusters.yml index 1b1aca0..692be6c 100644 --- a/initializers/clusters.yml +++ b/initializers/clusters.yml @@ -1,5 +1,6 @@ # - name: cluster1 # type: Hyper-V +# group: Group 1 # - name: cluster2 # type: Hyper-V # site: SING 1 diff --git a/startup_scripts/165_cluster_groups.py b/startup_scripts/165_cluster_groups.py new file mode 100644 index 0000000..b52518a --- /dev/null +++ b/startup_scripts/165_cluster_groups.py @@ -0,0 +1,14 @@ +from virtualization.models import ClusterGroup +from startup_script_utils import load_yaml +import sys + +cluster_groups = load_yaml('/opt/netbox/initializers/cluster_groups.yml') + +if cluster_groups is None: + sys.exit() + +for params in cluster_groups: + cluster_group, created = ClusterGroup.objects.get_or_create(**params) + + if created: + print("🗄️ Created Cluster Group", cluster_group.name)