def test_create_project_1_site_3_hosts(self): xmlfile = os.path.join(XML_FILE_LOCATION, "project_1_site_3_hosts.xml") tree = etree.parse(xmlfile) project = Project() project.configure_from_node(tree.getroot(), self.defaults, None) self.failUnlessEqual( len(project.get_sites()), 1) site = project.get_sites()[0] hosts = project.get_sites()[0].get_hosts() self.failUnlessEqual( len(hosts), 3)
def test_create_project_1_site_3_hosts(self): xmlfile = os.path.join(XML_FILE_LOCATION, "project_1_site_3_hosts.xml") tree = etree.parse(xmlfile) project = Project() project.configure_from_node(tree.getroot(), self.defaults, None) self.failUnlessEqual(len(project.get_sites()), 1) site = project.get_sites()[0] hosts = project.get_sites()[0].get_hosts() self.failUnlessEqual(len(hosts), 3)
def test_create_project_1_site(self): xmlfile = os.path.join(XML_FILE_LOCATION, "project_1_site.xml") tree = etree.parse(xmlfile) project = Project() project.configure_from_node(tree.getroot(), self.defaults, None) # see if the convenience functions are set correctly self.failUnlessEqual( len(project.get_sites()), 1)
def test_create_project_1_site(self): xmlfile = os.path.join(XML_FILE_LOCATION, "project_1_site.xml") tree = etree.parse(xmlfile) project = Project() project.configure_from_node(tree.getroot(), self.defaults, None) # see if the convenience functions are set correctly self.failUnlessEqual(len(project.get_sites()), 1)
class VolumeTest(unittest.TestCase): """ Test various volume configurations """ def setUp(self): optparser = BaseOptions() optparser.parseOptions(['dummyfile.xml', '--debug=%s' % logging._levelNames[log.level].lower()]) self.defaults = RawConfigParser() configfiles = self.defaults.read(TESTCONF) xmldata = """ <project name="testproj" code="01"> <site name="sitea" type="primary" location="testlab"> <filer name="filer1" type="filer"> <vfiler name="vftest01"> <aggregate type="root" name="aggr0"/> <aggregate name="aggr01"/> </vfiler> </filer> </site> </project> """ node = etree.fromstring(xmldata) self.project = Project() self.project.configure_from_node(node, self.defaults, None) self.sitea = self.project.get_sites()[0] self.filer1 = self.sitea.get_filers()[0] self.vfiler1 = self.filer1.get_vfilers()[0] self.aggr1 = self.vfiler1.get_aggregates()[0] def test_line_volume(self): """ Test the simplest possible volume configuration """ xmldata = """ <volume> </volume> """ node = etree.fromstring(xmldata) vol = volume.create_volume_from_node(node, self.defaults, self.aggr1) self.failUnlessEqual(vol.name, "filer1_vftest01_fs_01") def test_simple_volume(self): """ Test the simplest possible volume configuration """ xmldata = """ <filer name='testfiler1'> <aggregate name='testaggr01'> <volume> </volume> </aggregate> </filer> """ node = etree.fromstring(xmldata) volnode = node.xpath('*/volume')[0] volume.create_volume_from_node(volnode, self.defaults, self.aggr1)
class VFilerTest(unittest.TestCase): """ Test the VFiler class """ def setUp(self): optparser = BaseOptions() optparser.parseOptions(['dummyfile.xml', '--debug=%s' % logging._levelNames[log.level].lower()]) self.defaults = RawConfigParser() configfiles = self.defaults.read(TESTCONF) xmldata = """ <project name="demo" code="3"> <site name="one" type="primary" location="somewhere"> <vlan number="3001" type="project"/> <filer name="testfiler1" type="filer"> </filer> </site> </project> """ node = etree.fromstring(xmldata) self.project = Project() self.project.configure_from_node(node, self.defaults, None) self.site = self.project.get_sites()[0] self.filer = self.site.get_filers()[0] def test_create_vfiler_bare(self): """ A bare vfiler with full default options """ xmldata = """ <vfiler /> """ node = etree.fromstring(xmldata) vfiler = VFiler() vfiler.configure_from_node(node, self.defaults, self.filer) self.failUnlessEqual( vfiler.name, "vfdemo" ) rootaggr = vfiler.get_root_aggregate() self.failUnlessEqual( rootaggr.name, "rootaggr" ) def test_create_vfiler_minimal(self): xmldata = """ <vfiler name="vftest01" /> """ node = etree.fromstring(xmldata) vfiler = VFiler() vfiler.configure_from_node(node, self.defaults, self.filer) self.failUnlessEqual( vfiler.name, "vftest01" ) rootaggr = vfiler.get_root_aggregate() self.failUnlessEqual( rootaggr.name, "rootaggr" )
class AggregateTest(unittest.TestCase): """ Test various aggregate configurations """ def setUp(self): optparser = BaseOptions() optparser.parseOptions(['dummyfile.xml', '--debug=%s' % logging._levelNames[log.level].lower()]) self.defaults = RawConfigParser() configfiles = self.defaults.read(TESTCONF) xmldata = """ <project name="testproj" code="01"> <site name="sitea" type="primary" location="testlab"> <filer name="filer1" type="filer"> <vfiler name="vftest01"> <aggregate type="root" name="aggr0"/> </vfiler> </filer> </site> </project> """ node = etree.fromstring(xmldata) self.project = Project() self.project.configure_from_node(node, self.defaults, None) self.sitea = self.project.get_sites()[0] self.filer1 = self.sitea.get_filers()[0] self.vfiler1 = self.filer1.get_vfilers()[0] def test_bare_aggregate(self): """ Test the simplest single aggregate node """ xmldata = """ <aggregate> </aggregate> """ node = etree.fromstring(xmldata) self.failUnlessRaises(KeyError, aggregate.create_aggregate_from_node, node, self.defaults, self.vfiler1)
class AggregateTest(unittest.TestCase): """ Test various aggregate configurations """ def setUp(self): optparser = BaseOptions() optparser.parseOptions(["dummyfile.xml", "--debug=%s" % logging._levelNames[log.level].lower()]) self.defaults = RawConfigParser() configfiles = self.defaults.read(TESTCONF) xmldata = """ <project name="testproj" code="01"> <site name="sitea" type="primary" location="testlab"> <filer name="filer1" type="filer"> <vfiler name="vftest01"> <aggregate type="root" name="aggr0"/> </vfiler> </filer> </site> </project> """ node = etree.fromstring(xmldata) self.project = Project() self.project.configure_from_node(node, self.defaults, None) self.sitea = self.project.get_sites()[0] self.filer1 = self.sitea.get_filers()[0] self.vfiler1 = self.filer1.get_vfilers()[0] def test_bare_aggregate(self): """ Test the simplest single aggregate node """ xmldata = """ <aggregate> </aggregate> """ node = etree.fromstring(xmldata) self.failUnlessRaises(KeyError, aggregate.create_aggregate_from_node, node, self.defaults, self.vfiler1)
class ExportTest(unittest.TestCase): """ Test various export configurations """ def setUp(self): optparser = BaseOptions() optparser.parseOptions(['dummyfile.xml', '--debug=%s' % logging._levelNames[log.level].lower()]) self.defaults = RawConfigParser() configfiles = self.defaults.read(TESTCONF) xmldata = """ <project name="testproj" code="01"> <site name="sitea" type="primary" location="testlab"> <host name="sitea_host01" operatingsystem="linux" /> <host name="sitea_host02" operatingsystem="windows" /> <host name="sitea_host03" operatingsystem="solaris" /> <vlan type="project" number="3001"> <network number="10.20.30.1/26" gateway="10.20.30.254"/> </vlan> <filer name="filer1" type="filer"> <vfiler name="vftest01" rootaggr="aggr0"> <ipaddress type="primary" ip="10.20.30.1"/> <aggregate name="aggr01"/> </vfiler> </filer> </site> </project> """ node = etree.fromstring(xmldata) self.project = Project() self.project.configure_from_node(node, self.defaults, None) self.sitea = self.project.get_sites()[0] self.filer1 = self.sitea.get_filers()[0] self.vfiler1 = self.filer1.get_vfilers()[0] self.aggr1 = self.vfiler1.get_aggregates()[0] def test_default_exports(self): """ Test a single volume and the default exports. """ xmldata = """ <volume> </volume> """ node = etree.fromstring(xmldata) vol = volume.create_volume_from_node(node, self.defaults, self.aggr1) self.aggr1.add_child(vol) self.failUnlessEqual(vol.name, "filer1_vftest01_fs_01") self.project.setup_exports(self.defaults) # check the exports are set up correctly for qtree in self.vfiler1.get_qtrees(): exports = qtree.get_exports() log.debug("exports: %s", [ str(x) for x in exports ]) self.failUnlessEqual( len(exports), 3 ) self.failUnlessEqual( exports[0].fromip, '10.20.30.1' ) def test_default_exports_2(self): """ Test a two volumes and the default exports. """ xmldata = """ <volume/> """ node = etree.fromstring(xmldata) vol = volume.create_volume_from_node(node, self.defaults, self.aggr1) self.aggr1.add_child(vol) vol = volume.create_volume_from_node(node, self.defaults, self.aggr1) self.aggr1.add_child(vol) self.failUnlessEqual(vol.name, "filer1_vftest01_fs_02") self.project.setup_exports(self.defaults) # check the exports are set up correctly for qtree in self.vfiler1.get_qtrees(): exports = qtree.get_exports() log.debug("exports: %s", [ str(x) for x in exports ]) self.failUnlessEqual( len(exports), 3 ) self.failUnlessEqual( exports[0].fromip, '10.20.30.1' ) def test_qtree_default(self): """ Test a single volume and the default exports. """ xmldata = """ <volume> <qtree name="blahblah"/> </volume> """ node = etree.fromstring(xmldata) vol = volume.create_volume_from_node(node, self.defaults, self.aggr1) self.aggr1.add_child(vol) self.failUnlessEqual(vol.name, "filer1_vftest01_fs_01") self.project.setup_exports(self.defaults) # check the exports are set up correctly for qtree in self.vfiler1.get_qtrees(): exports = qtree.get_exports() log.debug("exports: %s", [ str(x) for x in exports ]) self.failUnlessEqual( len(exports), 3 ) self.failUnlessEqual( exports[0].fromip, '10.20.30.1' )
class ExportTest(unittest.TestCase): """ Test various export configurations """ def setUp(self): optparser = BaseOptions() optparser.parseOptions([ 'dummyfile.xml', '--debug=%s' % logging._levelNames[log.level].lower() ]) self.defaults = RawConfigParser() configfiles = self.defaults.read(TESTCONF) xmldata = """ <project name="testproj" code="01"> <site name="sitea" type="primary" location="testlab"> <host name="sitea_host01" operatingsystem="linux" /> <host name="sitea_host02" operatingsystem="windows" /> <host name="sitea_host03" operatingsystem="solaris" /> <vlan type="project" number="3001"> <network number="10.20.30.1/26" gateway="10.20.30.254"/> </vlan> <filer name="filer1" type="filer"> <vfiler name="vftest01" rootaggr="aggr0"> <ipaddress type="primary" ip="10.20.30.1"/> <aggregate name="aggr01"/> </vfiler> </filer> </site> </project> """ node = etree.fromstring(xmldata) self.project = Project() self.project.configure_from_node(node, self.defaults, None) self.sitea = self.project.get_sites()[0] self.filer1 = self.sitea.get_filers()[0] self.vfiler1 = self.filer1.get_vfilers()[0] self.aggr1 = self.vfiler1.get_aggregates()[0] def test_default_exports(self): """ Test a single volume and the default exports. """ xmldata = """ <volume> </volume> """ node = etree.fromstring(xmldata) vol = volume.create_volume_from_node(node, self.defaults, self.aggr1) self.aggr1.add_child(vol) self.failUnlessEqual(vol.name, "filer1_vftest01_fs_01") self.project.setup_exports(self.defaults) # check the exports are set up correctly for qtree in self.vfiler1.get_qtrees(): exports = qtree.get_exports() log.debug("exports: %s", [str(x) for x in exports]) self.failUnlessEqual(len(exports), 3) self.failUnlessEqual(exports[0].fromip, '10.20.30.1') def test_default_exports_2(self): """ Test a two volumes and the default exports. """ xmldata = """ <volume/> """ node = etree.fromstring(xmldata) vol = volume.create_volume_from_node(node, self.defaults, self.aggr1) self.aggr1.add_child(vol) vol = volume.create_volume_from_node(node, self.defaults, self.aggr1) self.aggr1.add_child(vol) self.failUnlessEqual(vol.name, "filer1_vftest01_fs_02") self.project.setup_exports(self.defaults) # check the exports are set up correctly for qtree in self.vfiler1.get_qtrees(): exports = qtree.get_exports() log.debug("exports: %s", [str(x) for x in exports]) self.failUnlessEqual(len(exports), 3) self.failUnlessEqual(exports[0].fromip, '10.20.30.1') def test_qtree_default(self): """ Test a single volume and the default exports. """ xmldata = """ <volume> <qtree name="blahblah"/> </volume> """ node = etree.fromstring(xmldata) vol = volume.create_volume_from_node(node, self.defaults, self.aggr1) self.aggr1.add_child(vol) self.failUnlessEqual(vol.name, "filer1_vftest01_fs_01") self.project.setup_exports(self.defaults) # check the exports are set up correctly for qtree in self.vfiler1.get_qtrees(): exports = qtree.get_exports() log.debug("exports: %s", [str(x) for x in exports]) self.failUnlessEqual(len(exports), 3) self.failUnlessEqual(exports[0].fromip, '10.20.30.1')
class VolumeTest(unittest.TestCase): """ Test various volume configurations """ def setUp(self): optparser = BaseOptions() optparser.parseOptions([ 'dummyfile.xml', '--debug=%s' % logging._levelNames[log.level].lower() ]) self.defaults = RawConfigParser() configfiles = self.defaults.read(TESTCONF) xmldata = """ <project name="testproj" code="01"> <site name="sitea" type="primary" location="testlab"> <filer name="filer1" type="filer"> <vfiler name="vftest01"> <aggregate type="root" name="aggr0"/> <aggregate name="aggr01"/> </vfiler> </filer> </site> </project> """ node = etree.fromstring(xmldata) self.project = Project() self.project.configure_from_node(node, self.defaults, None) self.sitea = self.project.get_sites()[0] self.filer1 = self.sitea.get_filers()[0] self.vfiler1 = self.filer1.get_vfilers()[0] self.aggr1 = self.vfiler1.get_aggregates()[0] def test_line_volume(self): """ Test the simplest possible volume configuration """ xmldata = """ <volume> </volume> """ node = etree.fromstring(xmldata) vol = volume.create_volume_from_node(node, self.defaults, self.aggr1) self.failUnlessEqual(vol.name, "filer1_vftest01_fs_01") def test_simple_volume(self): """ Test the simplest possible volume configuration """ xmldata = """ <filer name='testfiler1'> <aggregate name='testaggr01'> <volume> </volume> </aggregate> </filer> """ node = etree.fromstring(xmldata) volnode = node.xpath('*/volume')[0] volume.create_volume_from_node(volnode, self.defaults, self.aggr1)