'fake',
_fake_image_meta,
'fake'))
+
+ def test_create_template_no_account(self):
+ sfv = solidfire.SolidFireDriver(configuration=self.configuration)
+
+ def _fake_issue_api_req(method, params, version=0):
+ if 'GetAccountByName' in method:
+ raise exception.SolidFireAPIException
+ return {'result': {'accountID': 1}}
+
+ with mock.patch.object(sfv,
+ '_issue_api_request',
+ side_effect=_fake_issue_api_req):
+ self.assertEqual(1,
+ sfv._create_template_account('foo'))
configuration=self.configuration))
def _create_template_account(self, account_name):
- id = self._issue_api_request(
- 'GetAccountByName',
- {'username': account_name})['result']['account']['accountID']
- if not id:
+ # We raise an API exception if the account doesn't exist
+ try:
+ id = self._issue_api_request(
+ 'GetAccountByName',
+ {'username': account_name})['result']['account']['accountID']
+ except exception.SolidFireAPIException:
chap_secret = self._generate_random_string(12)
params = {'username': account_name,
'initiatorSecret': chap_secret,