aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Smith <daniel.smith@ericsson.com>2015-12-09 10:08:28 +0000
committerGerrit Code Review <gerrit@172.30.200.206>2015-12-09 10:08:28 +0000
commit2e2d69dcef35b57c57f30b7f3a96d32353e9bc05 (patch)
tree11b929c439dd5823f6b56a403c4452797a2b1d56
parent90722b2a0de85d9b60130883b1b4f7b0e21dcffd (diff)
parentfaecd53622b233f72961ce626ef70788b8a12562 (diff)
Merge "Refactor temporary directory creation"
-rw-r--r--deploy/dha_adapters/libvirt_adapter.py3
-rw-r--r--deploy/environments/libvirt_environment.py3
-rw-r--r--deploy/environments/virtual_fuel.py3
-rwxr-xr-xdeploy/reap.py3
4 files changed, 8 insertions, 4 deletions
diff --git a/deploy/dha_adapters/libvirt_adapter.py b/deploy/dha_adapters/libvirt_adapter.py
index d6a30d75e..c65dab554 100644
--- a/deploy/dha_adapters/libvirt_adapter.py
+++ b/deploy/dha_adapters/libvirt_adapter.py
@@ -10,6 +10,7 @@
from lxml import etree
from hardware_adapter import HardwareAdapter
+import tempfile
from common import (
log,
@@ -60,7 +61,7 @@ class LibvirtAdapter(HardwareAdapter):
def node_set_boot_order(self, node_id, boot_order_list):
boot_order_list = self.translate(boot_order_list)
vm_name = self.get_node_property(node_id, 'libvirtName')
- temp_dir = exec_cmd('mktemp -d')
+ temp_dir = tempfile.mkdtemp()
log('Set boot order %s on Node %s' % (boot_order_list, vm_name))
resp = exec_cmd('virsh dumpxml %s' % vm_name)
xml_dump = etree.fromstring(resp, self.parser)
diff --git a/deploy/environments/libvirt_environment.py b/deploy/environments/libvirt_environment.py
index af2d3f8fb..c8a2ef529 100644
--- a/deploy/environments/libvirt_environment.py
+++ b/deploy/environments/libvirt_environment.py
@@ -11,6 +11,7 @@
from lxml import etree
import glob
from execution_environment import ExecutionEnvironment
+import tempfile
from common import (
exec_cmd,
@@ -42,7 +43,7 @@ class LibvirtEnvironment(ExecutionEnvironment):
exec_cmd('fallocate -l %s %s' % (disk_size, disk_path))
def create_vms(self):
- temp_dir = exec_cmd('mktemp -d')
+ temp_dir = tempfile.mkdtemp()
disk_sizes = self.dha.get_disks()
for node_id in self.node_ids:
vm_name = self.dha.get_node_property(node_id, 'libvirtName')
diff --git a/deploy/environments/virtual_fuel.py b/deploy/environments/virtual_fuel.py
index 705eee48b..89a82c078 100644
--- a/deploy/environments/virtual_fuel.py
+++ b/deploy/environments/virtual_fuel.py
@@ -10,6 +10,7 @@
from lxml import etree
from execution_environment import ExecutionEnvironment
+import tempfile
from common import (
exec_cmd,
@@ -45,7 +46,7 @@ class VirtualFuel(ExecutionEnvironment):
vm_xml.write(f, pretty_print=True, xml_declaration=True)
def create_vm(self):
- temp_dir = exec_cmd('mktemp -d')
+ temp_dir = tempfile.mkdtemp()
vm_name = self.dha.get_node_property(self.fuel_node_id, 'libvirtName')
vm_template = '%s/%s' % (self.root_dir,
self.dha.get_node_property(
diff --git a/deploy/reap.py b/deploy/reap.py
index 2155f3faa..72bfcee4c 100755
--- a/deploy/reap.py
+++ b/deploy/reap.py
@@ -14,6 +14,7 @@ import os
import yaml
import glob
import shutil
+import tempfile
from common import (
N,
@@ -294,7 +295,7 @@ class Reap(object):
def intro(self):
delete(self.dea_file)
delete(self.dha_file)
- self.temp_dir = exec_cmd('mktemp -d')
+ self.temp_dir = tempfile.mkdtemp()
date = time.strftime('%c')
self.write(self.dea_file,
DEA_1.format(date=date, comment=self.comment), False)