Modify a few bugs for supporting ftp/ftps
Change-Id: Ia0cd1a3561097f543cab932bf34cd8161754a0d4
This commit is contained in:
parent
cac61b7132
commit
d59b138182
|
@ -90,7 +90,6 @@ class NovaEngine(engine.BackupEngine):
|
||||||
with open(file.name) as f:
|
with open(file.name) as f:
|
||||||
data = f.readline()
|
data = f.readline()
|
||||||
LOG.info("get_nova_tenant download {0}".format(data))
|
LOG.info("get_nova_tenant download {0}".format(data))
|
||||||
file.close()
|
|
||||||
|
|
||||||
return json.loads(data)
|
return json.loads(data)
|
||||||
|
|
||||||
|
@ -208,7 +207,6 @@ class NovaEngine(engine.BackupEngine):
|
||||||
f.write(data)
|
f.write(data)
|
||||||
LOG.info("backup_nova_tenant data={0}".format(data))
|
LOG.info("backup_nova_tenant data={0}".format(data))
|
||||||
self.storage.put_file(file.name, backup_basepath)
|
self.storage.put_file(file.name, backup_basepath)
|
||||||
file.close()
|
|
||||||
|
|
||||||
executor = futures.ThreadPoolExecutor(
|
executor = futures.ThreadPoolExecutor(
|
||||||
max_workers=len(instance_ids))
|
max_workers=len(instance_ids))
|
||||||
|
|
|
@ -19,6 +19,8 @@ Freezer restore modes related functions
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
import shutil
|
||||||
|
import tempfile
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
|
@ -62,7 +64,7 @@ class RestoreOs(object):
|
||||||
elif self.storage.type == "local":
|
elif self.storage.type == "local":
|
||||||
path = "{0}/{1}".format(self.container, path)
|
path = "{0}/{1}".format(self.container, path)
|
||||||
backups = os.listdir(os.path.abspath(path))
|
backups = os.listdir(os.path.abspath(path))
|
||||||
elif self.storage.type in ["ssh", 'ftp', 'ftps']:
|
elif self.storage.type in ['ssh', 'ftp', 'ftps']:
|
||||||
path = "{0}/{1}".format(self.container, path)
|
path = "{0}/{1}".format(self.container, path)
|
||||||
backups = self.storage.listdir(path)
|
backups = self.storage.listdir(path)
|
||||||
else:
|
else:
|
||||||
|
@ -161,7 +163,7 @@ class RestoreOs(object):
|
||||||
disk_format="raw",
|
disk_format="raw",
|
||||||
data=data)
|
data=data)
|
||||||
return info, image
|
return info, image
|
||||||
elif self.storage.type in ['ssh', 'ftp', 'ftps']:
|
elif self.storage.type == 'ssh':
|
||||||
image_file = "{0}/{1}/{2}/{3}".format(self.container, path,
|
image_file = "{0}/{1}/{2}/{3}".format(self.container, path,
|
||||||
backup, path)
|
backup, path)
|
||||||
metadata_file = "{0}/{1}/{2}/metadata".format(self.container,
|
metadata_file = "{0}/{1}/{2}/metadata".format(self.container,
|
||||||
|
@ -179,6 +181,32 @@ class RestoreOs(object):
|
||||||
disk_format="raw",
|
disk_format="raw",
|
||||||
data=data)
|
data=data)
|
||||||
return info, image
|
return info, image
|
||||||
|
elif self.storage.type in ['ftp', 'ftps']:
|
||||||
|
image_file = "{0}/{1}/{2}/{3}".format(self.container, path,
|
||||||
|
backup, path)
|
||||||
|
metadata_file = "{0}/{1}/{2}/metadata".format(self.container,
|
||||||
|
path, backup)
|
||||||
|
try:
|
||||||
|
tmpdir = tempfile.mkdtemp()
|
||||||
|
except Exception:
|
||||||
|
LOG.error("Unable to create a tmp directory")
|
||||||
|
raise
|
||||||
|
try:
|
||||||
|
data_image = utils.path_join(tmpdir, "data_image")
|
||||||
|
LOG.info('create image restore ftp storage')
|
||||||
|
self.storage.get_file(image_file, data_image)
|
||||||
|
data_meta = utils.path_join(tmpdir, "data_meta")
|
||||||
|
self.storage.get_file(metadata_file, data_meta)
|
||||||
|
data = open(data_image, 'rb')
|
||||||
|
info = json.load(open(data_meta, 'r'))
|
||||||
|
image = self.client_manager.create_image(
|
||||||
|
name="restore_{}".format(path),
|
||||||
|
container_format="bare",
|
||||||
|
disk_format="raw",
|
||||||
|
data=data)
|
||||||
|
return info, image
|
||||||
|
finally:
|
||||||
|
shutil.rmtree(tmpdir)
|
||||||
else:
|
else:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
|
|
@ -74,7 +74,6 @@ class BaseFtpStorage(fslike.FsLikeStorage):
|
||||||
def _create_tempdir(self):
|
def _create_tempdir(self):
|
||||||
try:
|
try:
|
||||||
tmpdir = tempfile.mkdtemp()
|
tmpdir = tempfile.mkdtemp()
|
||||||
LOG.info("****mkdir****")
|
|
||||||
except Exception:
|
except Exception:
|
||||||
LOG.error("Unable to create a tmp directory")
|
LOG.error("Unable to create a tmp directory")
|
||||||
raise
|
raise
|
||||||
|
|
Loading…
Reference in New Issue