Skip to content

Commit

Permalink
Appending the build number along woth release number
Browse files Browse the repository at this point in the history
when we create the upgradesave dir during backup_config in upgrade.
Closes-bug: 1460827

Change-Id: I82aa03fc9f6ac75cd93ebeb632c6c1bdff6cecf8
(cherry picked from commit 260c616)
  • Loading branch information
Shweta Naik committed Jun 4, 2015
1 parent cadb798 commit e09c65d
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions contrail_provisioning/common/upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def __init__(self):
'remove' : [],
'downgrade' : [],
'ensure' : [],
'backup' : ['/etc/contrail'],
'backup' : ['/etc/contrail'],
'restore' : [],
'remove_config' : [],
'rename_config' : [],
Expand Down Expand Up @@ -72,7 +72,7 @@ def _parse_args(self, args_str):
parser.set_defaults(**self.global_defaults)

return parser

def _upgrade_package(self):
if not self.upgrade_data['upgrade']:
return
Expand All @@ -88,7 +88,8 @@ def _upgrade_package(self):
local(cmd)

def _backup_config(self):
self.backup_dir = "/var/tmp/contrail-%s-upgradesave" % self._args.to_rel
self.backup_dir = "/var/tmp/contrail-%s-%s-upgradesave" % \
(self._args.to_rel, self.get_build().split('~')[0])

for backup_elem in self.upgrade_data['backup']:
backup_config = self.backup_dir + backup_elem
Expand Down Expand Up @@ -149,7 +150,6 @@ def _remove_config(self):
os.remove(remove_config)
else:
shutil.rmtree(remove_config)


def _rename_config(self):
for src, dst in self.upgrade_data['rename_config']:
Expand All @@ -160,6 +160,18 @@ def _rename_config(self):
local('cp -rfp %s %s' % src, dst)
shutil.rmtree(src)

def get_build(self, pkg='contrail-install-packages'):
pkg_rel = None
if self.pdist in ['centos', 'redhat']:
cmd = "rpm -q --queryformat '%%{RELEASE}' %s" %pkg
elif self.pdist in ['Ubuntu']:
cmd = "dpkg -s %s | grep Version: | cut -d' ' -f2 | cut -d'-' -f2" %pkg
pkg_rel = local(cmd, capture=True)
if 'is not installed' in pkg_rel or 'is not available' in pkg_rel:
print "Package %s not installed." % pkg
return None
return pkg_rel

def _upgrade(self):
self._backup_config()
if self.pdist in ['centos']:
Expand All @@ -179,7 +191,7 @@ def upgrade_python_pkgs(self):
# Installing packages(python-nova, python-cinder) brings in lower
# version of python-paramiko(1.7.5), fabric-utils requires 1.9.0 or
# above.ubuntu does not need this, as pycrypto and paramiko are
# installed as debian packages.
# installed as debian packages.
cmd = "sudo easy_install \
/opt/contrail/python_packages/pycrypto-2.6.tar.gz;\
sudo easy_install \
Expand Down

0 comments on commit e09c65d

Please sign in to comment.