You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi! Love this project so far. I realize this project is still very early in its development, but I've been looking for something like this for a while and now that the ground work is on the way, I'm thinking that I could perhaps contribute to make it fit my need.
I'd like to use the model as a source of truth for Terraform to provision at least a good chunk of an ACI tenant. I'm an extremely inexperienced developer, but I've been toying with your plugin to output the API calls in a format that Terraform will like.
I don't know if this is the right way to do this, but I've been modifying ACIEndpointGroupSerializer class in the serializer.py file to change the output. Obviously I'm changing ACIEndpointGroupSerializer to make it easier on me to test, but the end goal would be to have a parallel set of API calls to output in Terraform format.
For example (this isn't complete, but I'm happy enough with the result that I think it's possible. Also, note that the two additional classes were written with the help of ChatGPT):
class BooleanToYesNoField(serializers.Field):
def to_representation(self, value):
return 'yes' if value else 'no'
def to_internal_value(self, data):
if data.lower() == 'yes':
return True
elif data.lower() == 'no':
return False
else:
raise serializers.ValidationError('Invalid value. Expected "yes" or "no".')
class BooleanToEnabledDisabledField(serializers.Field):
def to_representation(self, value):
return 'enabled' if value else 'disabled'
def to_internal_value(self, data):
if data.lower() == 'enabled':
return True
elif data.lower() == 'disabled':
return False
else:
raise serializers.ValidationError('Invalid value. Expected "enabled" or "disabled".')
class ACIEndpointGroupSerializer(NetBoxModelSerializer):
"""Serializer for ACI Endpoint Group model in Terraform import format."""
url = serializers.HyperlinkedIdentityField(
view_name="plugins-api:netbox_aci_plugin-api:aciendpointgroup-detail"
)
application_profile_dn = serializers.CharField(read_only=True, source="aci_app_profile.name")
relation_fv_rs_bd = serializers.CharField(read_only=True, source="aci_bridge_domain.name")
shutdown = BooleanToYesNoField(source="admin_shutdown")
flood_on_encap = BooleanToEnabledDisabledField(source="flood_on_encap")
class Meta:
model = ACIEndpointGroup
fields: tuple = (
"id",
"url",
"display",
"name",
"description",
"application_profile_dn",
"relation_fv_rs_bd",
"description",
"shutdown",
"flood_on_encap",
)
So, a few questions:
Is this something you'd be interested in having in your plugin or should I fork it or something?
Is this the way to go about doing this? I can do the leg work of formatting the output if I have the "proper" way of doing it.
Use case
Use Netbox as a source of truth for Terraform
External dependencies
No response
The text was updated successfully, but these errors were encountered:
Hi, thank you so much for looking at this project and your kind words. Especially I like to thank you for providing a useful use case and even some code snippets. Very appreciated!
Your use case is totally valid. Actually, I started this project to be able to document and even automate the most relevant elements within Cisco ACI. But as you already know, it is quite early in the development process, since it is missing models and even simple features like bulk edits. (But I think, these thoughts were better be put in the discussion section.)
The idea behind using boolean fields for enabled and disabled states are for providing an easy to use API for any automation tool (being tool agnostic).
In your request, it seems quite Terraform specific, although I see some value in providing an APIC API mapping.
Let me think about it in more detail.
Would you mind sharing the code querying the plugin’s API and using the values as an input for the resource aci_application_epg?
(It may be possible to make the relevant mapping within the Terraform configuration itself.)
Hi. I'm realizing that what I want is probably quite easily achieved through an export template, which may or may not be able to be included in the plugin. There probably isn't a need to do anything at all on your end for this. I can close the issue or you can as well. I can share the templates I create later on if that's of interest to you.
NetBox ACI Plugin version
v0.0.5
NetBox version
v4.0.5
Feature type
Data model extension
Proposed functionality
Hi! Love this project so far. I realize this project is still very early in its development, but I've been looking for something like this for a while and now that the ground work is on the way, I'm thinking that I could perhaps contribute to make it fit my need.
I'd like to use the model as a source of truth for Terraform to provision at least a good chunk of an ACI tenant. I'm an extremely inexperienced developer, but I've been toying with your plugin to output the API calls in a format that Terraform will like.
I don't know if this is the right way to do this, but I've been modifying ACIEndpointGroupSerializer class in the serializer.py file to change the output. Obviously I'm changing ACIEndpointGroupSerializer to make it easier on me to test, but the end goal would be to have a parallel set of API calls to output in Terraform format.
For example (this isn't complete, but I'm happy enough with the result that I think it's possible. Also, note that the two additional classes were written with the help of ChatGPT):
So, a few questions:
Is this something you'd be interested in having in your plugin or should I fork it or something?
Is this the way to go about doing this? I can do the leg work of formatting the output if I have the "proper" way of doing it.
Use case
Use Netbox as a source of truth for Terraform
External dependencies
No response
The text was updated successfully, but these errors were encountered: