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',
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'
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
'id': 11,
'name': hostname}
self._hosts[hostname] = host
-
self.properties = {'data':
{'target_discovered': True,
'target_lun': 186,
#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)
#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)
#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)
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'
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)
#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)
#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)
#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)
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"),
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:
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
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: