Beispiel #1
0
    def test_rename(self):
        orig_xml = "<view><name>oldname</name></view>"
        new_name = "newname"
        expected_xml = "<view><name>{0}</name></view>".format(new_name)

        vxml = ViewXML(orig_xml)
        vxml.rename(new_name)
        self.assertIn(expected_xml, vxml.XML)
Beispiel #2
0
    def clone(self, new_view_name):
        """Make a copy of this view with the specified name

        :param str new_view_name: name of the newly cloned view
        :return: reference to the View object that manages the new, cloned view
        :rtype: :class:`~.view.View`
        """
        new_view = self._master.create_view(new_view_name, self.type)
        vxml = ViewXML(self.config_xml)
        vxml.rename(new_view_name)
        new_view.config_xml = vxml.xml
        return new_view
Beispiel #3
0
    def clone_subview(self, existing_view, new_view_name):
        """Creates a clone of an existing view under this nested view

         :param existing_view: Instance of a PyJen view to be cloned
         :type existing_view: :class:`~.view.View`
         :param str new_view_name: the new name for the view
         :returns: reference to new PyJen view object
         :rtype: :class:`~.view.View`
         """
        retval = self.create_view(new_view_name, existing_view.type)
        vxml = ViewXML(existing_view.config_xml)
        vxml.rename(new_view_name)
        retval.config_xml = vxml.xml
        return retval