This fixes TgtAdm Target Objects not to regenerate random
username/password every time initialize_connection is called,
as TgtAdm doesn't accept the change while the initiator is
connected. This fixes the live-migration of nova instances which
have volumes attached.
Change-Id: I1b48a66da5a0d8726490f50c2ee58352c42d9587
Closes-Bug: #
1408162
Related-Bug: #
1383509
def test_verify_backing_lun(self):
pass
+ def test_get_target_chap_auth(self):
+ pass
+
def test_create_iscsi_target_already_exists(self):
def _fake_execute(*args, **kwargs):
raise putils.ProcessExecutionError(exit_code=1)
'_verify_backing_lun',
lambda x, y: True)
+ self.stubs.Set(self.target,
+ '_get_target_chap_auth',
+ lambda x: None)
self.stubs.Set(vutils,
'generate_username',
lambda: 'QZJbisGmn9AL954FNF4D')
self.testvol_1,
self.fake_volumes_dir))
+ self.stubs.Set(self.target,
+ '_get_target_chap_auth',
+ lambda x: ('otzLy2UYbYfnP4zXLG5z',
+ '234Zweo38VGBBvrpK9nt'))
+
+ expected_result['auth'] = ('CHAP '
+ 'otzLy2UYbYfnP4zXLG5z 234Zweo38VGBBvrpK9nt')
+
+ self.assertEqual(expected_result,
+ self.target.create_export(ctxt,
+ self.testvol_1,
+ self.fake_volumes_dir))
+
def test_ensure_export(self):
ctxt = context.get_admin_context()
with mock.patch.object(self.target, 'create_iscsi_target'):
def __init__(self, *args, **kwargs):
super(IetAdm, self).__init__(*args, **kwargs)
+ def _get_target_chap_auth(self, name):
+ pass
+
def ensure_export(self, context, volume, volume_path):
pass
self._verify_rtstool()
+ def _get_target_chap_auth(self, name):
+ pass
+
def remove_export(self, context, volume):
try:
iscsi_target = self.db.volume_get_iscsi_target_num(context,
iscsi_name = "%s%s" % (self.configuration.iscsi_target_prefix,
volume['name'])
iscsi_target, lun = self._get_target_and_lun(context, volume)
- chap_username = vutils.generate_username()
- chap_password = vutils.generate_password()
+
+ # Verify we haven't setup a CHAP creds file already
+ # if DNE no big deal, we'll just create it
+ current_chap_auth = self._get_target_chap_auth(iscsi_name)
+ if current_chap_auth:
+ (chap_username, chap_password) = current_chap_auth
+ else:
+ chap_username = vutils.generate_username()
+ chap_password = vutils.generate_password()
chap_auth = self._iscsi_authentication('IncomingUser', chap_username,
chap_password)
# NOTE(jdg): For TgtAdm case iscsi_name is the ONLY param we need