def test_port_mode_access_with_no_port_mode_or_vlan_set_just_sets_the_port_mode(self):
        self.netconf_mock.should_receive("get_config").with_args(
            source="candidate",
            filter=is_xml(
                """
            <filter>
              <configuration>
                <interfaces/>
                <vlans/>
              </configuration>
            </filter>
        """
            ),
        ).and_return(
            a_configuration(
                """
            <interfaces>
              <interface>
                <name>ge-0/0/6</name>
                <unit>
                  <name>0</name>
                  <family>
                    <ethernet-switching>
                    </ethernet-switching>
                  </family>
                </unit>
              </interface>
            </interfaces>
            <vlans/>
        """
            )
        )

        self.netconf_mock.should_receive("edit_config").once().with_args(
            target="candidate",
            config=is_xml(
                """
            <config>
              <configuration>
                <interfaces>
                  <interface>
                    <name>ge-0/0/6</name>
                    <unit>
                      <name>0</name>
                      <family>
                        <ethernet-switching>
                          <interface-mode>access</interface-mode>
                        </ethernet-switching>
                      </family>
                    </unit>
                  </interface>
                </interfaces>
              </configuration>
            </config>
        """
            ),
        ).and_return(an_ok_response())

        self.switch.set_access_mode("ge-0/0/6")
    def test_add_interface_to_bond(self):
        self.netconf_mock.should_receive("get_config").with_args(
            source="candidate",
            filter=is_xml(
                """
            <filter>
              <configuration>
                <interfaces/>
                <vlans/>
                <protocols>
                  <rstp>
                    <interface />
                  </rstp>
                </protocols>
              </configuration>
            </filter>
        """
            ),
        ).and_return(
            a_configuration(
                """
            <interfaces>
              <interface>
                <name>ae10</name>
              </interface>
              <interface>
                <name>ge-0/0/1</name>
              </interface>
            </interfaces>
            <vlans/>
        """
            )
        )

        self.netconf_mock.should_receive("edit_config").once().with_args(
            target="candidate",
            config=is_xml(
                """
            <config>
              <configuration>
                <interfaces>
                  <interface operation="replace">
                    <name>ge-0/0/1</name>
                    <ether-options>
                      <auto-negotiation/>
                      <ieee-802.3ad>
                        <bundle>ae10</bundle>
                      </ieee-802.3ad>
                    </ether-options>
                  </interface>
                </interfaces>
              </configuration>
            </config>"""
            ),
        ).and_return(an_ok_response())

        self.switch.add_interface_to_bond("ge-0/0/1", 10)
    def test_change_bond_speed_update_slaves_and_interface_at_same_time(self):
        self.netconf_mock.should_receive("get_config").with_args(
            source="candidate",
            filter=is_xml(
                """
            <filter>
              <configuration>
                <interfaces />
              </configuration>
            </filter>
        """
            ),
        ).and_return(
            a_configuration(
                """
            <interfaces>
              <interface>
                <name>ae10</name>
              </interface>
              <interface>
                <name>ge-0/0/1</name>
                <ether-options>
                  <ieee-802.3ad>
                    <bundle>ae10</bundle>
                  </ieee-802.3ad>
                </ether-options>
              </interface>
              <interface>
                <name>ge-0/0/2</name>
              </interface>
            </interfaces>
        """
            )
        )

        self.netconf_mock.should_receive("edit_config").once().with_args(
            target="candidate",
            config=is_xml(
                """
            <config>
              <configuration>
                <interfaces>
                  <interface>
                    <name>ae10</name>
                    <aggregated-ether-options>
                      <link-speed>1g</link-speed>
                    </ether-options>
                  </interface>
                </interfaces>
              </configuration>
            </config>"""
            ),
        ).and_return(an_ok_response())

        self.switch.set_bond_link_speed(10, "1g")
Пример #4
0
    def test_port_mode_access_with_no_port_mode_or_vlan_set_just_sets_the_port_mode(
            self):
        self.netconf_mock.should_receive("get_config").with_args(
            source="candidate",
            filter=is_xml("""
            <filter>
              <configuration>
                <interfaces/>
                <vlans/>
              </configuration>
            </filter>
        """)).and_return(
                a_configuration("""
            <interfaces>
              <interface>
                <name>ge-0/0/6</name>
                <unit>
                  <name>0</name>
                  <family>
                    <ethernet-switching>
                    </ethernet-switching>
                  </family>
                </unit>
              </interface>
            </interfaces>
            <vlans/>
        """))

        self.netconf_mock.should_receive("edit_config").once().with_args(
            target="candidate",
            config=is_xml("""
            <config>
              <configuration>
                <interfaces>
                  <interface>
                    <name>ge-0/0/6</name>
                    <unit>
                      <name>0</name>
                      <family>
                        <ethernet-switching>
                          <interface-mode>access</interface-mode>
                        </ethernet-switching>
                      </family>
                    </unit>
                  </interface>
                </interfaces>
              </configuration>
            </config>
        """)).and_return(an_ok_response())

        self.switch.set_access_mode("ge-0/0/6")
Пример #5
0
    def test_add_interface_to_bond(self):
        self.netconf_mock.should_receive("get_config").with_args(
            source="candidate",
            filter=is_xml("""
            <filter>
              <configuration>
                <interfaces/>
                <vlans/>
                <protocols>
                  <rstp>
                    <interface />
                  </rstp>
                </protocols>
              </configuration>
            </filter>
        """)).and_return(
                a_configuration("""
            <interfaces>
              <interface>
                <name>ae10</name>
              </interface>
              <interface>
                <name>ge-0/0/1</name>
              </interface>
            </interfaces>
            <vlans/>
        """))

        self.netconf_mock.should_receive("edit_config").once().with_args(
            target="candidate",
            config=is_xml("""
            <config>
              <configuration>
                <interfaces>
                  <interface operation="replace">
                    <name>ge-0/0/1</name>
                    <ether-options>
                      <auto-negotiation/>
                      <ieee-802.3ad>
                        <bundle>ae10</bundle>
                      </ieee-802.3ad>
                    </ether-options>
                  </interface>
                </interfaces>
              </configuration>
            </config>""")).and_return(an_ok_response())

        self.switch.add_interface_to_bond('ge-0/0/1', 10)
Пример #6
0
    def test_change_bond_speed_update_slaves_and_interface_at_same_time(self):
        self.netconf_mock.should_receive("get_config").with_args(
            source="candidate",
            filter=is_xml("""
            <filter>
              <configuration>
                <interfaces />
              </configuration>
            </filter>
        """)).and_return(
                a_configuration("""
            <interfaces>
              <interface>
                <name>ae10</name>
              </interface>
              <interface>
                <name>ge-0/0/1</name>
                <ether-options>
                  <ieee-802.3ad>
                    <bundle>ae10</bundle>
                  </ieee-802.3ad>
                </ether-options>
              </interface>
              <interface>
                <name>ge-0/0/2</name>
              </interface>
            </interfaces>
        """))

        self.netconf_mock.should_receive("edit_config").once().with_args(
            target="candidate",
            config=is_xml("""
            <config>
              <configuration>
                <interfaces>
                  <interface>
                    <name>ae10</name>
                    <aggregated-ether-options>
                      <link-speed>1g</link-speed>
                    </ether-options>
                  </interface>
                </interfaces>
              </configuration>
            </config>""")).and_return(an_ok_response())

        self.switch.set_bond_link_speed(10, '1g')
Пример #7
0
    def test_add_interface_to_bond_gets_up_to_speed_and_removes_existing_rstp_protocol(self):
        with self.expecting_successful_transaction():

            self.netconf_mock.should_receive("get_config").with_args(source="candidate", filter=is_xml("""
                <filter>
                  <configuration>
                    <interfaces/>
                    <vlans/>
                    <protocols>
                      <rstp>
                        <interface />
                      </rstp>
                    </protocols>
                  </configuration>
                </filter>
            """)).and_return(a_configuration("""
                <interfaces>
                  <interface>
                    <name>ae10</name>
                    <aggregated-ether-options>
                      <link-speed>1g</link-speed>
                    </aggregated-ether-options>
                  </interface>
                  <interface>
                    <name>ge-0/0/1</name>
                  </interface>
                </interfaces>
                <vlans/>
                <protocols>
                  <rstp>
                    <interface>
                      <name>ge-0/0/1</name>
                      <edge />
                    </interface>
                  </rstp>
                </protocols>
            """))

            self.netconf_mock.should_receive("edit_config").once().with_args(target="candidate", config=is_xml("""
                <config>
                  <configuration>
                    <interfaces>
                      <interface operation="replace">
                        <name>ge-0/0/1</name>
                        <ether-options>
                          <auto-negotiation/>
                          <ieee-802.3ad>
                            <bundle>ae10</bundle>
                          </ieee-802.3ad>
                        </ether-options>
                      </interface>
                    </interfaces>
                    <protocols>
                      <rstp>
                        <interface operation="delete">
                          <name>ge-0/0/1</name>
                        </interface>
                      </rstp>
                    </protocols>
                  </configuration>
                </config>""")).and_return(an_ok_response())

        self.switch.add_interface_to_bond('ge-0/0/1', 10)