Ejemplo n.º 1
0
class NetInterfaceTest(unittest.TestCase):
    """
    Test the Project 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 = """
<site name="primary" type="prod" location="testlab">
  <vlan number="1453" type="storage"/>
  <vlan number="100" type="storage"/>
  <vlan number="300" type="storage"/>
  <host name="fred" platform="intel" operatingsystem="linux"/>
</site>
"""
        node = etree.fromstring(xmldata)
        self.site = Site()
        self.site.configure_from_node(node, self.defaults, None)

        self.host = self.site.get_hosts()[0]

    def test_create_netinterface_bare(self):
        xmlfile = os.path.join(XML_FILE_LOCATION, "netinterface_bare.xml")
        tree = etree.parse(xmlfile)
        node = tree.getroot()
        #netinterface.create_netinterface_from_node(node, self.defaults, self.host)
        self.failUnlessRaises(KeyError, netinterface.create_netinterface_from_node, node, self.defaults, self.host)
        
    def test_create_netinterface_minimal(self):
        xmlfile = os.path.join(XML_FILE_LOCATION, "netinterface_minimal.xml")
        tree = etree.parse(xmlfile)
        node = tree.getroot()
        iface = netinterface.create_netinterface_from_node(node, self.defaults, self.host)

    def test_create_netinterface_with_mtu(self):
        xmlfile = os.path.join(XML_FILE_LOCATION, "netinterface_with_mtu.xml")
        tree = etree.parse(xmlfile)
        node = tree.getroot()
        iface = netinterface.create_netinterface_from_node(node, self.defaults, self.host)
        self.failUnlessEqual(iface.mtu, 3445)
    
    def test_create_netinterface_with_single_vlan(self):
        xmlfile = os.path.join(XML_FILE_LOCATION, "netinterface_with_single_vlan.xml")
        tree = etree.parse(xmlfile)
        node = tree.getroot()
        iface = netinterface.create_netinterface_from_node(node, self.defaults, self.host)
        self.failUnlessEqual(len(iface.get_vlans()), 1)
        self.failUnlessEqual(iface.get_vlans()[0].number, 1453)
        
    def test_create_netinterface_with_multiple_vlan(self):
        xmlfile = os.path.join(XML_FILE_LOCATION, "netinterface_with_multiple_vlans.xml")
        tree = etree.parse(xmlfile)
        node = tree.getroot()
        iface = netinterface.create_netinterface_from_node(node, self.defaults, self.host)
        self.failUnlessEqual(len(iface.get_vlans()), 3)
Ejemplo n.º 2
0
    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 = """
<site name="primary" type="prod" location="testlab">
  <vlan number="1453" type="storage"/>
  <vlan number="100" type="storage"/>
  <vlan number="300" type="storage"/>
  <host name="fred" platform="intel" operatingsystem="linux"/>
</site>
"""
        node = etree.fromstring(xmldata)
        self.site = Site()
        self.site.configure_from_node(node, self.defaults, None)

        self.host = self.site.get_hosts()[0]
Ejemplo n.º 3
0
    def setUp(self):
        optparser = BaseOptions()
        optparser.parseOptions(['dummyfile.xml', '--debug=%s' % logging._levelNames[log.level].lower()])
        self.defaults = RawConfigParser()
        configfiles = self.defaults.read(TESTCONF)

        self.site = Site()
        self.site.name = 'sitea'
        self.site.type = 'primary'
        self.site.location = 'testlab'
        pass
Ejemplo n.º 4
0
    def setUp(self):
        optparser = BaseOptions()
        optparser.parseOptions([
            'dummyfile.xml',
            '--debug=%s' % logging._levelNames[log.level].lower()
        ])

        self.defaults = RawConfigParser()
        configfiles = self.defaults.read(TESTCONF)
        self.defaults.get('global', 'dns_domain_name')
        if len(configfiles) == 0:
            raise ValueError("Cannot load configuration file: %s" %
                             optparser.options.configfile)

        self.sitea = Site()
        self.sitea.name = 'sitea'
        self.sitea.type = 'primary'
        self.sitea.location = 'testlab'