Skip to content

Commit

Permalink
Liberty live migration provision fix
Browse files Browse the repository at this point in the history
Closes-Bug: #1557256
Fix issue with live migration provision.
1. Glance image create command line option changed
2. Use openstack cli command instead of keystone

Change-Id: Ib7056beff57046944b8b68fef2895b67b2b61140
  • Loading branch information
Jeya ganesh babu J committed Mar 15, 2016
1 parent f16afc4 commit f1094ca
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 7 deletions.
31 changes: 28 additions & 3 deletions contrail_provisioning/storage/storagefs/livemnfs_setup.py
Expand Up @@ -3,6 +3,7 @@
import argparse
import ConfigParser

import platform
import os
import sys
import time
Expand All @@ -14,6 +15,8 @@
from fabric.api import local, env, run
from fabric.operations import get, put
from fabric.context_managers import lcd, settings
from distutils.version import LooseVersion

sys.path.insert(0, os.getcwd())

class SetupNFSLivem(object):
Expand All @@ -29,6 +32,14 @@ class SetupNFSLivem(object):
NOVA_INST_GLOBAL='/var/lib/nova/instances/global'
global MAX_RETRY_WAIT
MAX_RETRY_WAIT = 10
global cinder_version
cinder_version = 2015
global LIBERTY_VERSION
LIBERTY_VERSION = 2016
# Denotes the OS type whether Ubuntu or Centos.
global pdist
pdist = platform.dist()[0]


def check_vm(self, vmip):
retry = 0
Expand All @@ -47,6 +58,7 @@ def check_vm(self, vmip):
#end check_vm

def __init__(self, args_str = None):
global cinder_version
print sys.argv[1:]
self._args = None
if not args_str:
Expand All @@ -59,6 +71,12 @@ def __init__(self, args_str = None):
self._args.storage_setup_mode == 'setup_global') and \
self._args.nfs_livem_host:

if pdist == 'Ubuntu':
os_cinder = local('dpkg-query -W -f=\'${Version}\' cinder-api',
capture=True)
if LooseVersion(os_cinder) >= LooseVersion('2:0.0.0'):
cinder_version = LIBERTY_VERSION

nfs_livem_image = self._args.nfs_livem_image[0]
nfs_livem_host = self._args.nfs_livem_host[0]
nfs_livem_subnet = self._args.nfs_livem_subnet[0]
Expand All @@ -69,7 +87,10 @@ def __init__(self, args_str = None):
print 'NFS Live migration is already configured'
else:
print 'NFS Live migration is yet to be configured'
local('source /etc/contrail/openstackrc && /usr/bin/glance image-create --name livemnfs --disk-format qcow2 --container-format ovf --file %s --is-public True' %(nfs_livem_image) , capture=True, shell='/bin/bash')
if cinder_version >= LIBERTY_VERSION:
local('source /etc/contrail/openstackrc && /usr/bin/glance image-create --name livemnfs --disk-format qcow2 --container-format ovf --file %s --visibility public' %(nfs_livem_image) , capture=True, shell='/bin/bash')
else:
local('source /etc/contrail/openstackrc && /usr/bin/glance image-create --name livemnfs --disk-format qcow2 --container-format ovf --file %s --is-public True' %(nfs_livem_image) , capture=True, shell='/bin/bash')
livemnfs=local('source /etc/contrail/openstackrc && /usr/bin/glance image-list | grep livemnfs|wc -l', capture=True, shell='/bin/bash')
if livemnfs == '1':
print 'image add success'
Expand Down Expand Up @@ -310,7 +331,10 @@ def __init__(self, args_str = None):
# update quota based on Total size
total=local('rados df | grep "total space" | awk \'{ print $3 }\'', capture = True, shell='/bin/bash')
quota_gb = int(total)/1024/1024/2
admintenantid=local('source /etc/contrail/openstackrc && keystone tenant-list |grep " admin" | awk \'{print $2}\'' , capture=True, shell='/bin/bash')
if cinder_version >= LIBERTY_VERSION:
admintenantid=local('source /etc/contrail/openstackrc && openstack project list |grep " admin" | awk \'{print $2}\'' , capture=True, shell='/bin/bash')
else:
admintenantid=local('source /etc/contrail/openstackrc && keystone tenant-list |grep " admin" | awk \'{print $2}\'' , capture=True, shell='/bin/bash')
local('source /etc/contrail/openstackrc && cinder quota-update --gigabytes=%d %s' %(quota_gb, admintenantid), capture=True, shell='/bin/bash')

cindervolavail=local('source /etc/contrail/openstackrc && cinder list | grep livemnfsvol |wc -l' , capture=True, shell='/bin/bash')
Expand Down Expand Up @@ -718,7 +742,8 @@ def __init__(self, args_str = None):
local('source /etc/contrail/openstackrc && neutron net-delete livemnfs', shell='/bin/bash')
livemnfs=local('source /etc/contrail/openstackrc && /usr/bin/glance image-list | grep livemnfs|wc -l', capture=True, shell='/bin/bash')
if livemnfs == '1':
local('source /etc/contrail/openstackrc && /usr/bin/glance image-delete livemnfs', capture=True, shell='/bin/bash')
id = local('source /etc/contrail/openstackrc && glance image-list | grep -w livemnfs | awk \'{print $2}\'', capture=True, shell='/bin/bash')
local('source /etc/contrail/openstackrc && /usr/bin/glance image-delete %s' %(id), capture=True, shell='/bin/bash')

if self._args.storage_setup_mode == 'unconfigure':
# Remove Storage scope configuration
Expand Down
8 changes: 4 additions & 4 deletions contrail_provisioning/storage/storagefs/setup.py
Expand Up @@ -2301,14 +2301,14 @@ def do_configure_cinder(self):
%(CINDER_CONFIG_FILE))
if self._args.cinder_vip != 'none':
run('sudo openstack-config --set %s keystone_authtoken \
auth_uri http://%s:5000/v2.0'
auth_uri http://%s:5000'
%(CINDER_CONFIG_FILE, self._args.cinder_vip))
run('sudo openstack-config --set %s keystone_authtoken \
identity_uri http://%s:35357'
%(CINDER_CONFIG_FILE, self._args.cinder_vip))
else:
run('sudo openstack-config --set %s keystone_authtoken \
auth_uri http://%s:5000/v2.0'
auth_uri http://%s:5000'
%(CINDER_CONFIG_FILE, self._args.openstack_ip))
run('sudo openstack-config --set %s keystone_authtoken \
identity_uri http://%s:35357'
Expand All @@ -2328,14 +2328,14 @@ def do_configure_cinder(self):
%(CINDER_CONFIG_FILE))
if self._args.cinder_vip != 'none':
local('sudo openstack-config --set %s keystone_authtoken \
auth_uri http://%s:5000/v2.0'
auth_uri http://%s:5000'
%(CINDER_CONFIG_FILE, self._args.cinder_vip))
local('sudo openstack-config --set %s keystone_authtoken \
identity_uri http://%s:35357'
%(CINDER_CONFIG_FILE, self._args.cinder_vip))
else:
local('sudo openstack-config --set %s keystone_authtoken \
auth_uri http://%s:5000/v2.0'
auth_uri http://%s:5000'
%(CINDER_CONFIG_FILE, self._args.openstack_ip))
local('sudo openstack-config --set %s keystone_authtoken \
identity_uri http://%s:35357'
Expand Down

0 comments on commit f1094ca

Please sign in to comment.