add filter plugins, have juju add machines with full dns names
diff --git a/filter_plugins/format_string.py b/filter_plugins/format_string.py
new file mode 100644
index 0000000..8210d89
--- /dev/null
+++ b/filter_plugins/format_string.py
@@ -0,0 +1,16 @@
+from jinja2.utils import soft_unicode
+
+def format_string(string, pattern):
+ """
+ formats the string with the value passed to it
+ basicaly the reverse order of standard "format()"
+ """
+ return soft_unicode(pattern) % (string)
+
+class FilterModule(object):
+
+ def filters(self):
+ return {
+ 'format_string': format_string,
+ }
+
diff --git a/filter_plugins/genmac.py b/filter_plugins/genmac.py
new file mode 100644
index 0000000..5bdee2a
--- /dev/null
+++ b/filter_plugins/genmac.py
@@ -0,0 +1,29 @@
+import hashlib
+import netaddr
+
+def genmac(value, prefix='', length=12):
+ '''
+ deterministically generates a "random" MAC with a configurable prefix
+ '''
+
+ # from: http://serverfault.com/questions/40712/what-range-of-mac-addresses-can-i-safely-use-for-my-virtual-machines
+ if prefix == ''
+ mac_prefix = "0ac04d" # random "cord"-esque
+
+ # deterministically generate a value
+ h = hashlib.new('sha1')
+ h.update(value)
+
+ # build/trim MAC
+ mac_string = (mac_prefix + h.hexdigest())[0:length]
+
+ return netaddr.EUI(mac_string)
+
+class FilterModule(object):
+ ''' MAC generation filter '''
+ filter_map = {
+ 'genmac': genmac,
+ }
+
+ def filters(self):
+ return self.filter_map