Change XMLTemplate to JinjaTemplate
This commit is contained in:
parent
95080f88ad
commit
8eb49fd01d
3 changed files with 7 additions and 7 deletions
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
from . import settings
|
from . import settings
|
||||||
from . import util
|
from . import util
|
||||||
from .xml_template import XMLTemplate
|
from .jinja_template import JinjaTemplate
|
||||||
|
|
||||||
import libvirt
|
import libvirt
|
||||||
import tempfile
|
import tempfile
|
||||||
|
@ -156,7 +156,7 @@ class Container(util.LibvirtObject):
|
||||||
|
|
||||||
self.overlay_root = OverlayDirectory(settings.BASE_SYSTEM_ROOT, name=self.name)
|
self.overlay_root = OverlayDirectory(settings.BASE_SYSTEM_ROOT, name=self.name)
|
||||||
|
|
||||||
xml = XMLTemplate("container.xml").inst(
|
xml = JinjaTemplate("container.xml").inst(
|
||||||
name=self.name,
|
name=self.name,
|
||||||
uuid=self.uuid,
|
uuid=self.uuid,
|
||||||
mem=self.mem,
|
mem=self.mem,
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
""" Reads an XML template from a file """
|
""" Reads a jinja template from a file """
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import jinja2
|
import jinja2
|
||||||
|
|
||||||
|
|
||||||
class XMLTemplate:
|
class JinjaTemplate:
|
||||||
""" Reads and instanciates a template from a file """
|
""" Reads and instanciates a template from a file """
|
||||||
|
|
||||||
base_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "templates")
|
base_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "templates")
|
||||||
env = jinja2.Environment(
|
env = jinja2.Environment(
|
||||||
loader=jinja2.FileSystemLoader(base_path),
|
loader=jinja2.FileSystemLoader(base_path),
|
||||||
autoescape=jinja2.select_autoescape(
|
autoescape=jinja2.select_autoescape(
|
||||||
enabled_extensions=("xml"), default_for_string=True,
|
enabled_extensions=("xml", "network"), default_for_string=True,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
from . import settings
|
from . import settings
|
||||||
from . import util
|
from . import util
|
||||||
from .xml_template import XMLTemplate
|
from .jinja_template import JinjaTemplate
|
||||||
|
|
||||||
|
|
||||||
class Network(util.LibvirtObject):
|
class Network(util.LibvirtObject):
|
||||||
|
@ -27,7 +27,7 @@ class Network(util.LibvirtObject):
|
||||||
if self.lxc_network:
|
if self.lxc_network:
|
||||||
raise self.AlreadyExists()
|
raise self.AlreadyExists()
|
||||||
|
|
||||||
xml = XMLTemplate("network.xml").inst(
|
xml = JinjaTemplate("network.xml").inst(
|
||||||
name=self.name,
|
name=self.name,
|
||||||
uuid=self.uuid,
|
uuid=self.uuid,
|
||||||
bridge_id=self.bridge_id,
|
bridge_id=self.bridge_id,
|
||||||
|
|
Loading…
Reference in a new issue