Beispiel #1
0
    def test_multi_mode_list_with_keys(self):
        # Test multiple list with keys
        # Also list key without mode is also tested
        xml_stream = io.BytesIO(b"""
<data xmlns="http://riftio.com/ns/riftware-1.0/rw-base">
  <colony xmlns="http://riftio.com/ns/yangtools/rwclitest">
    <name>trafgen</name>
    <network-context>
        <name>trafgen-lb</name>
        <interface>
            <name>N1TenGi-1</name>
            <ip>
                <address>11.0.1.4/24</address>
            </ip>
        </interface>
    </network-context>
  </colony>
</data>""")
        expected_output = """config
  colony trafgen
    network-context trafgen-lb
      interface N1TenGi-1
        ip 11.0.1.4/24
      exit
    exit
  exit
end
"""
        out_stream = io.StringIO()
        writer = cliwriter.ConfigWriter(self.model, xml_stream)
        writer.write(out_stream)
        logger.debug("Outstream=%s", out_stream.getvalue())
        self.assertEqual(out_stream.getvalue(), expected_output)
Beispiel #2
0
    def test_list_empty(self):
        xml_stream = io.BytesIO(b"""
<data xmlns="http://riftio.com/ns/riftware-1.0/rw-base">
    <vnf-config xmlns="http://riftio.com/ns/yangtools/rwclitest">
    <vnf>
        <name>trafgen</name>
        <instance>0</instance>
        <network-context>
            <name>trafgen-lb</name>
            <interface>
                <name>N1TenGi-1</name>
            </interface>
        </network-context>
    </vnf>
    </vnf-config>
</data>
""")
        expected_output = """config
  vnf-config vnf trafgen 0
    network-context trafgen-lb
      interface N1TenGi-1
      exit
    exit
  exit
end
"""
        out_stream = io.StringIO()
        writer = cliwriter.ConfigWriter(self.model, xml_stream)
        writer.write(out_stream)
        logger.debug("Outstream=%s", out_stream.getvalue())
        self.assertEqual(out_stream.getvalue(), expected_output)
Beispiel #3
0
    def test_list_within_list_one(self):
        xml_stream = io.BytesIO(b"""
<data xmlns="http://riftio.com/ns/riftware-1.0/rw-base">
    <network xmlns="http://riftio.com/ns/yangtools/rwclitest">
        <network-id>l2net1</network-id>
        <node>
            <node-id>node1</node-id>
            <termination-point>
                <tp-id>tp1</tp-id>
                <attributes>
                    <maximum-frame-size>1500</maximum-frame-size>
                    <eth-encapsulation>vxlan</eth-encapsulation>
                </attributes>
            </termination-point>
        </node>
    </network>
</data>""")
        expected_output = """config
  network l2net1 node node1 termination-point tp1 attributes  maximum-frame-size 1500 eth-encapsulation vxlan
end
"""
        out_stream = io.StringIO()
        writer = cliwriter.ConfigWriter(self.model, xml_stream)
        writer.write(out_stream)
        logger.debug("Outstream=%s", out_stream.getvalue())
        self.assertEqual(out_stream.getvalue(), expected_output)
Beispiel #4
0
    def test_list_key_path_multi(self):
        # Test multiple list with keys
        # Also list key without mode is also tested
        xml_stream = io.BytesIO(b"""
<data xmlns="http://riftio.com/ns/riftware-1.0/rw-base">
    <cloud xmlns="http://riftio.com/ns/yangtools/rwclitest">
        <account>
            <name>c1</name>
            <account-type>cloudsim</account-type>
        </account>
        <account>
            <name>c2</name>
            <account-type>openstack</account-type>
        </account>
        <account>
            <name>c3</name>
            <account-type>cloudsim</account-type>
        </account>
    </cloud>
</data>""")
        expected_output = """config
  cloud account c1 account-type cloudsim
  cloud account c2 account-type openstack
  cloud account c3 account-type cloudsim
end
"""
        out_stream = io.StringIO()
        writer = cliwriter.ConfigWriter(self.model, xml_stream)
        writer.write(out_stream)
        logger.debug("Outstream=%s", out_stream.getvalue())
        self.assertEqual(out_stream.getvalue(), expected_output)
Beispiel #5
0
    def test_empty_config(self):
        expected_output = """config
end
"""
        out_stream = io.StringIO()
        xml_stream = io.BytesIO(
            b"""<data xmlns="http://riftio.com/ns/riftware-1.0/rw-base"/>""")
        writer = cliwriter.ConfigWriter(self.model, xml_stream)
        writer.write(out_stream)
        logger.debug("Outstream=%s", out_stream.getvalue())
        self.assertEqual(out_stream.getvalue(), expected_output)
Beispiel #6
0
    def test_multi_mode_ignore_unknown(self):
        xml_stream = io.BytesIO(b"""
<data xmlns="http://riftio.com/ns/riftware-1.0/rw-base">
  <colony xmlns="http://riftio.com/ns/yangtools/rwclitest">
    <name>trafgen</name>
    <port>
      <name>trafgen/2/1</name>
      <receive-q-length>2</receive-q-length>
      <open>
        <application><trafgen/></application>
      </open>
      <trafsink>
        <transmit-params>
            <transmit-mode><range/></transmit-mode>
        </transmit-params>
        <range-template>
            <packet-size>
            <start>512</start>
            <increment>1</increment>
            <maximum>512</maximum>
            <minimum>512</minimum>
            </packet-size>
            <source-ip>
                <start>11.0.1.4</start>
                <increment>1</increment>
                <minimum>11.0.1.4</minimum>
                <maximum>11.0.1.4</maximum>
            </source-ip>
            <destination-ip>
                <start>11.0.1.3</start>
                <increment>1</increment>
                <minimum>11.0.1.3</minimum>
                <maximum>11.0.1.3</maximum>
            </destination-ip>
        </range-template>
      </trafsink>
    </port>
  </colony>
</data>""")
        expected_output = """config
  colony trafgen
    port trafgen/2/1
      receive-q-length 2
      open  application trafgen
    exit
  exit
end
"""
        out_stream = io.StringIO()
        writer = cliwriter.ConfigWriter(self.model, xml_stream)
        writer.write(out_stream)
        logger.debug("Outstream=%s", out_stream.getvalue())
        self.assertEqual(out_stream.getvalue(), expected_output)