Update for lint and unit test errors

This commit is contained in:
Chris MacNaughton 2022-03-28 12:59:10 +02:00
parent 99b1a70c1f
commit d8d66cf576
6 changed files with 24 additions and 22 deletions

View File

@ -7,3 +7,5 @@ exclude:
build
dist
*.egg_info
# Excluded because it is imported almost verbatim from Manila
src/manager.py

View File

@ -417,7 +417,8 @@ class CephNFSCharm(
name = event.params.get('name')
allowed_ips = event.params.get('allowed-ips')
allowed_ips = [ip.strip() for ip in allowed_ips.split(',')]
export_path = self.ganesha_client.create_share(size=share_size, name=name, access_ips=allowed_ips)
export_path = self.ganesha_client.create_share(
size=share_size, name=name, access_ips=allowed_ips)
if not export_path:
event.fail("Failed to create share, check the log for more details")
return

View File

@ -93,7 +93,6 @@ class Export(object):
class GaneshaNFS(object):
export_index = "ganesha-export-index"
export_counter = "ganesha-export-counter"
@ -261,8 +260,8 @@ class GaneshaNFS(object):
:param name: String name of the share to create
"""
self._ceph_subvolume_command(
'deauthorize', 'ceph-fs', name,
'ganesha-{name}'.format(name=name))
'deauthorize', 'ceph-fs', name,
'ganesha-{name}'.format(name=name))
self._ceph_subvolume_command('rm', 'ceph-fs', name)
def _create_cephfs_share(self, name: str, size_in_bytes: int = None):

View File

@ -17,7 +17,6 @@
import logging
import subprocess
import tenacity
import time
from typing import Dict
import unittest
import yaml

View File

@ -12,7 +12,7 @@ sys.path.append('src') # noqa
from unittest.mock import patch, Mock
from charm import CephNfsCharm
from charm import CephNFSCharm
# from ops.model import ActiveStatus
from ops.testing import Harness
@ -40,7 +40,7 @@ class CharmTestCase(unittest.TestCase):
setattr(self, method, self.patch(method))
class _CephNfsCharm(CephNfsCharm):
class _CephNFSCharm(CephNFSCharm):
@staticmethod
def get_bluestore_compression():
@ -58,7 +58,7 @@ class TestCephNFSCharmBase(CharmTestCase):
def setUp(self):
super().setUp(charm, self.PATCHES)
self.harness = Harness(
_CephNfsCharm,
_CephNFSCharm,
)
self.addCleanup(self.harness.cleanup)

View File

@ -43,35 +43,36 @@ class ExportTest(unittest.TestCase):
def test_add_client(self):
export = ganesha.Export.from_export(EXAMPLE_EXPORT)
export.add_client('10.0.0.0/8', 'rw')
export.add_client('10.0.0.0/8')
self.assertEqual(
export.clients,
[{'Access_Type': 'rw', 'Clients': '0.0.0.0, 10.0.0.0/8'}])
# adding again shouldn't duplicate export
export.add_client('10.0.0.0/8', 'rw')
export.add_client('10.0.0.0/8')
self.assertEqual(
export.clients,
[{'Access_Type': 'rw', 'Clients': '0.0.0.0, 10.0.0.0/8'}])
export.add_client('192.168.0.0/16', 'r')
export.add_client('192.168.0.0/16')
self.assertEqual(
export.clients,
[{'Access_Type': 'r', 'Clients': '192.168.0.0/16'},
{'Access_Type': 'rw', 'Clients': '0.0.0.0, 10.0.0.0/8'},
])
[{
'Access_Type': 'rw', 'Clients': '0.0.0.0, 10.0.0.0/8, 192.168.0.0/16'
}])
def test_remove_client(self):
export = ganesha.Export.from_export(EXAMPLE_EXPORT)
export.add_client('10.0.0.0/8', 'rw')
export.add_client('192.168.0.0/16', 'r')
export.add_client('10.0.0.0/8')
export.add_client('192.168.0.0/16')
self.assertEqual(
export.clients,
[{'Access_Type': 'r', 'Clients': '192.168.0.0/16'},
{'Access_Type': 'rw', 'Clients': '0.0.0.0, 10.0.0.0/8'},
])
[{
'Access_Type': 'rw',
'Clients': '0.0.0.0, 10.0.0.0/8, 192.168.0.0/16'
}])
export.remove_client('0.0.0.0')
self.assertEqual(
export.clients,
[{'Access_Type': 'r', 'Clients': '192.168.0.0/16'},
{'Access_Type': 'rw', 'Clients': '10.0.0.0/8'},
])
[
{'Access_Type': 'rw', 'Clients': '10.0.0.0/8, 192.168.0.0/16'},
])