Merge "Removes 3PAR domain option from cinder config file"

This commit is contained in:
Jenkins 2013-07-02 05:03:17 +00:00 committed by Gerrit Code Review
commit 83dd8e42c2
5 changed files with 54 additions and 15 deletions

@ -336,6 +336,9 @@ class HP3PARBaseDriver():
def fake_create_client(self):
return FakeHP3ParClient(self.driver.configuration.hp3par_api_url)
def fake_get_domain(self, cpg):
return HP3PAR_DOMAIN
def fake_get_3par_host(self, hostname):
if hostname not in self._hosts:
msg = {'code': 'NON_EXISTENT_HOST',
@ -433,7 +436,6 @@ class TestHP3PARFCDriver(HP3PARBaseDriver, test.TestCase):
configuration.hp3par_username = 'testUser'
configuration.hp3par_password = 'testPassword'
configuration.hp3par_api_url = 'https://1.1.1.1/api/v1'
configuration.hp3par_domain = HP3PAR_DOMAIN
configuration.hp3par_cpg = HP3PAR_CPG
configuration.hp3par_cpg_snap = HP3PAR_CPG_SNAP
configuration.iscsi_ip_address = '1.1.1.2'
@ -457,6 +459,8 @@ class TestHP3PARFCDriver(HP3PARBaseDriver, test.TestCase):
self.fake_create_3par_vlun)
self.stubs.Set(hpdriver.hpcommon.HP3PARCommon, "get_ports",
self.fake_get_ports)
self.stubs.Set(hpfcdriver.hpcommon.HP3PARCommon, "get_domain",
self.fake_get_domain)
self.configuration = configuration
@ -491,7 +495,6 @@ class TestHP3PARFCDriver(HP3PARBaseDriver, test.TestCase):
'id': 11,
'name': hostname}
self._hosts[hostname] = host
self.properties = {'data':
{'target_discovered': True,
'target_lun': 186,
@ -575,6 +578,8 @@ class TestHP3PARFCDriver(HP3PARBaseDriver, test.TestCase):
#record
self.stubs.UnsetAll()
self.stubs.Set(hpfcdriver.hpcommon.HP3PARCommon, "get_domain",
self.fake_get_domain)
_run_ssh = self.mox.CreateMock(hpdriver.hpcommon.HP3PARCommon._run_ssh)
self.stubs.Set(hpdriver.hpcommon.HP3PARCommon, "_run_ssh", _run_ssh)
@ -596,6 +601,8 @@ class TestHP3PARFCDriver(HP3PARBaseDriver, test.TestCase):
#record
self.stubs.UnsetAll()
self.stubs.Set(hpdriver.hpcommon.HP3PARCommon, "get_domain",
self.fake_get_domain)
_run_ssh = self.mox.CreateMock(hpdriver.hpcommon.HP3PARCommon._run_ssh)
self.stubs.Set(hpdriver.hpcommon.HP3PARCommon, "_run_ssh", _run_ssh)
@ -621,6 +628,8 @@ class TestHP3PARFCDriver(HP3PARBaseDriver, test.TestCase):
#record
self.stubs.UnsetAll()
self.stubs.Set(hpdriver.hpcommon.HP3PARCommon, "get_domain",
self.fake_get_domain)
_run_ssh = self.mox.CreateMock(hpdriver.hpcommon.HP3PARCommon._run_ssh)
self.stubs.Set(hpdriver.hpcommon.HP3PARCommon, "_run_ssh", _run_ssh)
@ -654,7 +663,6 @@ class TestHP3PARISCSIDriver(HP3PARBaseDriver, test.TestCase):
configuration.hp3par_username = 'testUser'
configuration.hp3par_password = 'testPassword'
configuration.hp3par_api_url = 'https://1.1.1.1/api/v1'
configuration.hp3par_domain = HP3PAR_DOMAIN
configuration.hp3par_cpg = HP3PAR_CPG
configuration.hp3par_cpg_snap = HP3PAR_CPG_SNAP
configuration.iscsi_ip_address = '1.1.1.2'
@ -682,6 +690,8 @@ class TestHP3PARISCSIDriver(HP3PARBaseDriver, test.TestCase):
self.fake_delete_3par_host)
self.stubs.Set(hpdriver.hpcommon.HP3PARCommon, "_create_3par_vlun",
self.fake_create_3par_vlun)
self.stubs.Set(hpdriver.hpcommon.HP3PARCommon, "get_domain",
self.fake_get_domain)
self.driver = hpdriver.HP3PARISCSIDriver(configuration=configuration)
self.driver.do_setup(None)
@ -803,6 +813,8 @@ class TestHP3PARISCSIDriver(HP3PARBaseDriver, test.TestCase):
#record
self.stubs.UnsetAll()
self.stubs.Set(hpdriver.hpcommon.HP3PARCommon, "get_domain",
self.fake_get_domain)
_run_ssh = self.mox.CreateMock(hpdriver.hpcommon.HP3PARCommon._run_ssh)
self.stubs.Set(hpdriver.hpcommon.HP3PARCommon, "_run_ssh", _run_ssh)
@ -825,6 +837,8 @@ class TestHP3PARISCSIDriver(HP3PARBaseDriver, test.TestCase):
#record
self.stubs.UnsetAll()
self.stubs.Set(hpdriver.hpcommon.HP3PARCommon, "get_domain",
self.fake_get_domain)
_run_ssh = self.mox.CreateMock(hpdriver.hpcommon.HP3PARCommon._run_ssh)
self.stubs.Set(hpdriver.hpcommon.HP3PARCommon, "_run_ssh", _run_ssh)
@ -850,6 +864,8 @@ class TestHP3PARISCSIDriver(HP3PARBaseDriver, test.TestCase):
#record
self.stubs.UnsetAll()
self.stubs.Set(hpdriver.hpcommon.HP3PARCommon, "get_domain",
self.fake_get_domain)
_run_ssh = self.mox.CreateMock(hpdriver.hpcommon.HP3PARCommon._run_ssh)
self.stubs.Set(hpdriver.hpcommon.HP3PARCommon, "_run_ssh", _run_ssh)

@ -74,9 +74,11 @@ hp3par_opts = [
default='',
help="3PAR Super user password",
secret=True),
#TODO(kmartin): Remove hp3par_domain during I release.
cfg.StrOpt('hp3par_domain',
default="OpenStack",
help="The 3par domain name to use"),
default=None,
help="This option is DEPRECATED and no longer used. "
"The 3par domain name to use."),
cfg.StrOpt('hp3par_cpg',
default="OpenStack",
help="The CPG to use for volume creation"),
@ -124,6 +126,10 @@ class HP3PARCommon(object):
self.config = config
self.hosts_naming_dict = dict()
self.client = None
if CONF.hp3par_domain is not None:
LOG.deprecated(_("hp3par_domain has been deprecated and "
"is no longer used. The domain is automatically "
"looked up based on the CPG."))
def check_flags(self, options, required_flags):
for flag in required_flags:
@ -169,14 +175,21 @@ class HP3PARCommon(object):
LOG.error(err)
raise exception.InvalidInput(reason=err)
if ('domain' not in cpg
or cpg['domain'] != self.config.hp3par_domain):
err = ("CPG's domain '%s' and config option hp3par_domain '%s'"
" must be the same" %
(cpg['domain'], self.config.hp3par_domain))
def get_domain(self, cpg_name):
try:
cpg = self.client.getCPG(cpg_name)
except hpexceptions.HTTPNotFound:
err = (_("CPG (%s) doesn't exist on array.") % cpg_name)
LOG.error(err)
raise exception.InvalidInput(reason=err)
domain = cpg['domain']
if not domain:
err = (_("CPG (%s) must be in a domain") % cpg_name)
LOG.error(err)
raise exception.InvalidInput(reason=err)
return domain
def _get_3par_vol_name(self, volume_id):
"""
Converts the openstack volume id from
@ -681,6 +694,14 @@ exit
word = re.search(search_string.strip(' ') + ' ([^ ]*)', s)
return word.groups()[0].strip(' ')
def get_volume_metadata_value(self, volume, key):
metadata = volume.get('volume_metadata')
if metadata:
for i in volume['volume_metadata']:
if i['key'] == key:
return i['value']
return None
def create_cloned_volume(self, volume, src_vref):
try:

@ -217,6 +217,8 @@ class HP3PARFCDriver(cinder.volume.driver.FibreChannelDriver):
"""Creates or modifies existing 3PAR host."""
host = None
hostname = self.common._safe_hostname(connector['host'])
cpg = self.common.get_volume_metadata_value(volume, 'CPG')
domain = self.common.get_domain(cpg)
try:
host = self.common._get_3par_host(hostname)
if not host['FCPaths']:
@ -228,8 +230,7 @@ class HP3PARFCDriver(cinder.volume.driver.FibreChannelDriver):
# host doesn't exist, we have to create it
hostname = self._create_3par_fibrechan_host(hostname,
connector['wwpns'],
self.configuration.
hp3par_domain,
domain,
persona_id)
host = self.common._get_3par_host(hostname)

@ -238,6 +238,8 @@ class HP3PARISCSIDriver(cinder.volume.driver.ISCSIDriver):
# make sure we don't have the host already
host = None
hostname = self.common._safe_hostname(connector['host'])
cpg = self.common.get_volume_metadata_value(volume, 'CPG')
domain = self.common.get_domain(cpg)
try:
host = self.common._get_3par_host(hostname)
if not host['iSCSIPaths']:
@ -249,8 +251,7 @@ class HP3PARISCSIDriver(cinder.volume.driver.ISCSIDriver):
# host doesn't exist, we have to create it
hostname = self._create_3par_iscsi_host(hostname,
connector['initiator'],
self.configuration.
hp3par_domain,
domain,
persona_id)
host = self.common._get_3par_host(hostname)

@ -1139,7 +1139,7 @@
# 3PAR Super user password (string value)
#hp3par_password=
# The 3par domain name to use (string value)
# The 3par domain name to use (string value)-DEPRECATED
#hp3par_domain=OpenStack
# The CPG to use for volume creation (string value)