Esempio n. 1
0
 def _get_user(self):
     user = None
     try:
         user = self._ctera_portal.users.get(
             portal_types.UserAccount(self.parameters['name']),
             include=CteraPortalLocalUser._create_params)
     except CTERAException:
         pass
     return self._to_user_dict(user) if user else None
 def _test_ensure_absent(is_present):
     name = 'admin'
     user = ctera_portal_local_user.CteraPortalLocalUser()
     user.parameters = dict(name=name)
     user._ensure_absent(user.parameters if is_present else None)
     if is_present:
         user._ctera_portal.users.delete.assert_called_once_with(portal_types.UserAccount(name))
     else:
         user._ctera_portal.users.delete.assert_not_called()
Esempio n. 3
0
 def _ensure_absent(self, user):
     if user:
         self._ctera_portal.users.delete(
             portal_types.UserAccount(self.parameters['name']))
         self.ansible_module.ctera_return_value().changed().msg(
             'User deleted').put(name=self.parameters['name'])
     else:
         self.ansible_module.ctera_return_value().skipped().msg(
             'User already does not exist').put(
                 name=self.parameters['name'])
Esempio n. 4
0
 def _test_ensure_absent(is_present):
     parameters = dict(name='folder_name',
                       owner=dict(name='admin'),
                       group='group_name',
                       winacls=True)
     cloud_folder = CteraPortalCloudFolder()
     cloud_folder.parameters = parameters
     cloud_folder._ensure_absent(
         cloud_folder.parameters if is_present else None)
     if is_present:
         cloud_folder._ctera_portal.cloudfs.delete.assert_called_once_with(
             parameters['name'],
             portal_types.UserAccount(parameters['owner']['name']),
         )
     else:
         cloud_folder._ctera_portal.cloudfs.delete.assert_not_called()
Esempio n. 5
0
 def _test_ensure_present(is_present, change_attributes):
     current_attributes = dict(name='fg_name', owner=dict(name='admin'))
     desired_attributes = copy.deepcopy(current_attributes)
     if change_attributes:
         desired_attributes['owner']['name'] = 'Tester'
     folder_group = CteraPortalFolderGroup()
     folder_group.parameters = desired_attributes
     folder_group._ensure_present(
         current_attributes if is_present else None)
     if is_present:
         folder_group._ctera_portal.cloudfs.mkfg.assert_not_called()
     else:
         folder_group._ctera_portal.cloudfs.mkfg.assert_called_with(
             desired_attributes['name'],
             user=portal_types.UserAccount(
                 desired_attributes['owner']['name']))
Esempio n. 6
0
 def _test_ensure_present(is_present, change_attributes):
     current_attributes = dict(name='folder_name',
                               owner=dict(name='admin'),
                               group='group_name',
                               winacls=True)
     desired_attributes = copy.deepcopy(current_attributes)
     if change_attributes:
         desired_attributes['owner']['name'] = 'Tester'
     cloud_folder = CteraPortalCloudFolder()
     cloud_folder.parameters = desired_attributes
     cloud_folder._ensure_present(
         current_attributes if is_present else None)
     if is_present:
         cloud_folder._ctera_portal.cloudfs.mkdir.assert_not_called()
     else:
         cloud_folder._ctera_portal.cloudfs.mkdir.assert_called_with(
             desired_attributes['name'],
             desired_attributes['group'],
             portal_types.UserAccount(desired_attributes['owner']['name']),
             winacls=True)
Esempio n. 7
0
 def _make_user_account(user_details):
     return portal_types.UserAccount(
         **user_details) if user_details else None