From 90018fc6d7e0070367d6e1e90c03a03e571c73bc Mon Sep 17 00:00:00 2001 From: ryanmerolle Date: Tue, 29 Dec 2020 22:10:19 -0500 Subject: [PATCH] add cluster group startup script --- initializers/cluster_groups.yml | 4 ++++ initializers/clusters.yml | 1 + startup_scripts/165_cluster_groups.py | 14 ++++++++++++++ 3 files changed, 19 insertions(+) create mode 100644 initializers/cluster_groups.yml create mode 100644 startup_scripts/165_cluster_groups.py 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)