def _create_share(self):
     print("Creating a new share")
     share_dir_base_path = 'public'
     directory_name = self._get_input(
         GatewaySample._share_directory_name_request_string)
     directory_path = '/'.join([share_dir_base_path, directory_name])
     self._device.files.mkdir(directory_path, recurse=True)
     self._device.shares.add(
         directory_name,
         '/'.join([self._volume_name, directory_path]),
         acl=[
             gateway_types.ShareAccessControlEntry(
                 principal_type=gateway_enum.PrincipalType.LG,
                 name='Everyone',
                 perm=gateway_enum.FileAccessMode.RW)
         ],
         access=gateway_enum.Acl.OnlyAuthenticatedUsers)
     self._device.shares.add_acl(directory_name, [
         gateway_types.ShareAccessControlEntry(
             principal_type=gateway_enum.PrincipalType.LG,
             name='Administrators',
             perm=gateway_enum.FileAccessMode.RO)
     ])
     self._device.shares.remove_acl(
         directory_name,
         acl=[
             gateway_types.RemoveShareAccessControlEntry(
                 principal_type=gateway_enum.PrincipalType.LG,
                 name='Everyone')
         ])
     print("New share was created successfully")
Exemplo n.º 2
0
 def _remote_device_operations(self):
     print("Creating a new share")
     device_name = CTERASDKSampleBase._get_input(
         PortalSimpleSample._portal_device_name_request_string)
     device = self._global_admin.devices.device(device_name)
     share_dir_base_path = 'public'
     directory_name = self._get_input(
         PortalSimpleSample._share_directory_name_request_string)
     directory_path = '/'.join([share_dir_base_path, directory_name])
     device.shares.add(
         directory_name,
         '/'.join(['main', directory_path]),
         acl=[
             gateway_types.ShareAccessControlEntry(type='LG',
                                                   name='Everyone',
                                                   perm='RW'),
             gateway_types.ShareAccessControlEntry(type='LG',
                                                   name='Administrators',
                                                   perm='RO')
         ],
         access=gateway_enum.Acl.OnlyAuthenticatedUsers)
     print("New Share was created successfully")
     print("Deleting previosly created share")
     device.shares.delete(directory_name)
     print("Share was deleted successfully")
 def test_to_external_acl(self):
     name = 'admin'
     principal_types = {
         'LU': gateway_enum.PrincipalType.LU,
         'LG': gateway_enum.PrincipalType.LG,
         'DU': gateway_enum.PrincipalType.DU,
         'DG': gateway_enum.PrincipalType.DG,
     }
     perms = {
         'RW': gateway_enum.FileAccessMode.RW,
         'RO': gateway_enum.FileAccessMode.RO,
         'NA': gateway_enum.FileAccessMode.NA
     }
     for principal_type_name, principal_type in principal_types.items():
         for perm_name, perm in perms.items():
             sdk_object = gateway_types.ShareAccessControlEntry(
                 principal_type=principal_type,
                 name='admin',
                 perm=perm
             )
             expected_json = {
                 'principal_type': principal_type_name,
                 'name': name,
                 'perm': perm_name
             }
             self.assertDictEqual(
                 converters.to_external_acl(sdk_object.to_server_object()),
                 expected_json
             )
 def test_acl_json_to_object(self):
     name = 'admin'
     principal_types = {
         'LU': gateway_enum.PrincipalType.LU,
         'LG': gateway_enum.PrincipalType.LG,
         'DU': gateway_enum.PrincipalType.DU,
         'DG': gateway_enum.PrincipalType.DG,
     }
     perms = {
         'RW': gateway_enum.FileAccessMode.RW,
         'RO': gateway_enum.FileAccessMode.RO,
         'NA': gateway_enum.FileAccessMode.NA
     }
     for principal_type_name, principal_type in principal_types.items():
         for perm_name, perm in perms.items():
             acl_json = {
                 'principal_type': principal_type_name,
                 'name': name,
                 'perm': perm_name
             }
             expected_object = gateway_types.ShareAccessControlEntry(
                 principal_type=principal_type,
                 name='admin',
                 perm=perm
             )
             self._assert_equal_objects(
                 actual_param=converters.acl_json_to_object(acl_json),
                 expected_param=expected_object)
Exemplo n.º 5
0
 def _assert_equal_acl_object_and_json(self, acl_object, acl_json):
     self._assert_equal_objects(
         acl_object,
         gateway_types.ShareAccessControlEntry(
             principal_type=gateway_enum.PrincipalType.__dict__[
                 acl_json['principal_type']],
             name=acl_json['name'],
             perm=gateway_enum.FileAccessMode.__dict__[acl_json['perm']]))
 def _verify_acl_dict(self, acl_dict, actual_acl):
     expected_acl = gateway_types.ShareAccessControlEntry(**acl_dict)
     self.assertEqual(expected_acl.principal_type,
                      actual_acl.principal_type)
     self.assertEqual(expected_acl.name, actual_acl.name)
     self.assertEqual(expected_acl.perm, actual_acl.perm)
Exemplo n.º 7
0
 def _make_ShareAccessControlEntry(acl_dict):
     return gateway_types.ShareAccessControlEntry(
         principal_type=acl_dict['principal_type'],
         name=acl_dict['name'],
         perm=acl_dict['perm'])