Writing Plugins¶
This is the best place to start if you plan on building a plugin.
There are a few different archetypes of each set function:
#TODO Examine archetypes
All methods must have execute and it must default to True. IF execute is true, run and apply the command immediately Otherwise just return the line(s) needed to run the command
If you plan on implementing a method in the future, please override that module and raise a NotImplemented exception.
The plugin you implement MUST accept all of the arguments present in the skeleton class (documented below).
Plugin Class Structure¶
-
class
etherweaver.plugins.plugin_class.
NetWeaverPlugin
¶ -
add_command
(commands)¶ Adds a command to the command queue :param commands: :return:
-
after_connect
()¶ PLUGIN_OVERRIDE
Put anything here that your plugin needs to do after a self.connect is called
-
build_ssh_session
()¶ Build the SSH Object
-
connect
()¶ Examine protocol attribute and set up connection accordingly
-
set_bond_admin_down
(int_type, bond, down_status, commit=True, execute=True)¶ Parameters: - int_type – This is the type of the interface, for instance: ‘bond’, ‘1G’, ‘10G’. Used to determine the group of the interface to be modified.
- bond – This is the number of the interface, or text ID of the bond. You will likely need to translate this.
- down_status – True for a downed bond, False for an up bond.
- commit – If commit is true, the appliance must load the new configuration as part of this method.
- execute – If execute is True, this method must run and apply the configuration.
Returns: Return the list of commands that can be run to effect the change. You must return the list EVEN IF execute=True
-
set_bond_clag_id
(int_type, interface, clag_id, execute=True, delete=False, commit=True)¶ Sets the CLAG ID of a bond
Parameters: - int_type – This is the type of the interface, for instance: ‘bond’, ‘1G’, ‘10G’. Used to determine the group of the interface to be modified.
- interface – This is the number of the interface, or text ID of the bond. You will likely need to translate this.
- clag_id – Non negative integer
- commit – If commit is true, the appliance must load the new configuration as part of this method.
- delete – If delete is true and no value is set, remove all values. If delete is true and there is one or more values, remove only the specified values.
- execute – If execute is True, this method must run and apply the configuration.
Returns: Return the list of commands that can be run to effect the change. You must return the list EVEN IF execute=True
-
set_bond_mtu
(int_type, bond, mtu, execute=True, commit=True, delete=False)¶ Parameters: - int_type – The type/speed of the bond (Will always be a string ‘bond’, this parameter exists for consistency)
- bond – The ID of the bond
- mtu – Non zero non negative integer
- execute – If execute is True, this method must run and apply the configuration
- commit – If commit is true, this method must also commit the change (if applicable)
- delete – Resets MTU to default on appliances that support it. Raise an error if yours doesn’t.
Returns: List of commands that can be run to effect the change. You must return the list even if execute=True
-
set_bond_slaves
(int_type, interface, bond, execute=True, commit=True, delete=False)¶ Parameters: - int_type – This is the type of the interface, for instance: ‘bond’, ‘1G’, ‘10G’. Used to determine the group of the interface to be modified.
- interface – This is the number of the interface. You will likely need to translate this.
- bond – This is the ID of the bond that the interface will be added to.
- execute – If execute is True, this method must run and apply the configuration
- commit – If commit is true, this method must also commit the change (if applicable)
- delete – Delete the bond.
Returns: List of commands that can be run to effect the change. You must return the list even if execute=True
-
set_clag_backup_ip
(backup_ip, execute=True, delete=False, commit=True)¶ Sets the backup peer IP for CLAG
Parameters: - backup_ip – IPv4 or IPv6 backup address of CLAG member (call self._not_supported(string) with string as a helpful error message if your plugin’s appliance doesn’t support IPv6.
- commit – If commit is true, the appliance must load the new configuration as part of this method.
- delete – If delete is true and no value is set, remove all values. If delete is true and there is one or more values, remove only the specified values.
- execute – If execute is True, this method must run and apply the configuration.
Returns: Return the list of commands that can be run to effect the change. You must return the list EVEN IF execute=True
-
set_clag_cidr
(cidr, execute=True, delete=False, commit=True, add=False)¶ - Set the IP address and subnet mask of the primary CLAG peer interface
Parameters: - cidr – CIDR of the appliance’s CLAG peering interface as a string. EX; ‘169.254.2.1/30’
- add – List of cidrs to add.
- commit – If commit is true, the appliance must load the new configuration as part of this method.
- delete – If delete is true and no value is set, remove all values. If delete is true and there is one or more values, remove only the specified values.
- execute – If execute is True, this method must run and apply the configuration.
Returns: Return the list of commands that can be run to effect the change. You must return the list EVEN IF execute=True
-
set_clag_peer_ip
(peer_ip, execute=True, delete=False, commit=True)¶ Sets CLAG interface peer IP
Parameters: - peer_ip – IP address of the peer as a string I.E. ‘169.254.2.1’
- commit – If commit is true, the appliance must load the new configuration as part of this method.
- delete – If delete is true and no value is set, remove all values. If delete is true and there is one or more values, remove only the specified values.
- execute – If execute is True, this method must run and apply the configuration.
Returns: Return the list of commands that can be run to effect the change. You must return the list EVEN IF execute=True
-
set_clag_priority
(priority, execute=True, delete=False, commit=True)¶ Sets the CLAG priority of the appliance
Parameters: - priority – Non negative integer
- commit – If commit is true, the appliance must load the new configuration as part of this method.
- delete – If delete is true and no value is set, remove all values. If delete is true and there is one or more values, remove only the specified values.
- execute – If execute is True, this method must run and apply the configuration.
Returns: Return the list of commands that can be run to effect the change. You must return the list EVEN IF execute=True
Sets the shared mac of the CLAG daemon on the appliance
Parameters: - shared_mac – String containing the shared MAC address of the cluster
- commit – If commit is true, the appliance must load the new configuration as part of this method.
- delete – If delete is true and no value is set, remove all values. If delete is true and there is one or more values, remove only the specified values.
- execute – If execute is True, this method must run and apply the configuration.
Returns: Return the list of commands that can be run to effect the change. You must return the list EVEN IF execute=True
-
set_dns_nameservers
(nameserverlist, execute=True, commit=True, delete=False, add=False)¶ This method sets the dns resolvers used by the appliance.
Parameters: - nameserverlist – A list of DNS server IPv4 or IPv6 addresses to add to the resolver list.
- execute – If execute is True, this method must run and apply the configuration.
- add – List of DNS nameservers to be added.
- commit – If commit is true, the appliance must load the new configuration as part of this method.
- delete – If delete is true and no value is set, remove all tagged vlans from the interface. If delete is true and there is one or more values, remove only the specified values.
Returns: Return the list of commands that can be run to effect the change. You must return the list EVEN IF execute=True
-
set_hostname
(hostname, execute=True, commit=True, delete=False)¶ This method sets the system hostname of the appliance
Parameters: - hostname – A string containing the hostname of the system. Either a FQDN or short name, but not both (as most appliances don’t differentiate)
- execute – If execute is True, this method must run and apply the configuration.
- commit – If commit is true, the appliance must load the new configuration as part of this method.
- delete – If delete is true and no value is set, remove all tagged vlans from the interface. If delete is true and there is one or more values, remove only the specified values.
Returns: Return the list of commands that can be run to effect the change. You must return the list EVEN IF execute=True
-
set_interface_admin_down
(int_type, interface, down_status, commit=True, execute=True)¶ Parameters: - int_type – This is the type of the interface, for instance: ‘bond’, ‘1G’, ‘10G’. Used to determine the group of the interface to be modified.
- interface – This is the number of the interface, or text ID of the bond. You will likely need to translate this.
- down_status – True for a downed interface, False for an up interface.
- commit – If commit is true, the appliance must load the new configuration as part of this method.
- execute – If execute is True, this method must run and apply the configuration.
Returns: Return the list of commands that can be run to effect the change. You must return the list EVEN IF execute=True
-
set_interface_ip_addresses
(int_type, interface, ips, execute=True, commit=True, delete=False, add=False)¶ Adds and removes IP addresses from the interface
Parameters: - int_type – This is the type of the interface, for instance: ‘bond’, ‘1G’, ‘10G’. Used to determine the group of the interface to be modified.
- interface – This is the number of the interface, or text ID of the bond. You will likely need to translate this.
- ips – A list of CIDR notated IP addresses (I.E. [‘10.0.0.1/16’, ‘192.168.0.5/24’])
- commit – If commit is true, the appliance must load the new configuration as part of this method.
- delete – If delete is true and no value is set, remove all values. If delete is true and there is one or more values, remove only the specified values.
- execute – If execute is True, this method must run and apply the configuration.
Returns: Return the list of commands that can be run to effect the change. You must return the list EVEN IF execute=True
-
set_interface_mtu
(int_type, interface, mtu, execute=True, commit=True, delete=False)¶ Parameters: - int_type – The type/speed of interface
- interface – The ID of the interface
- mtu – Non zero non negative integer
- execute – If execute is True, this method must run and apply the configuration
- commit – If commit is true, this method must also commit the change (if applicable)
- delete – Resets MTU to default on appliances that support it. Raise an error if yours doesn’t.
Returns: List of commands that can be run to effect the change. You must return the list even if execute=True
-
set_interface_tagged_vlans
(speed, interface, vlans, execute=True, commit=True, delete=False, add=False)¶ This method modifies the list of allowed tagged vlans for a given interface.
Parameters: - speed – This is the type of the interface, for instance: ‘bond’, ‘1G’, ‘10G’. Used to determine the group of the interface to be modified.
- interface – This is the number of the interface, or text ID of the bond. You will likely need to translate this.
- vlans – This parameter will always contain a list of vlans to add or remove, even if there is a single value, and may be empty.
- execute – If execute is True, this method must run and apply the configuration.
- commit – If commit is true, the appliance must load the new configuration as part of this method.
- delete – If delete is true and no value is set, remove all tagged vlans from the interface. If delete is true and there is one or more values, remove only the specified values.
- add – If add is true and value is set, add all the tagged vlans in the list without removing any.
Returns: Return the list of commands that can be run to effect the change. You must return the list EVEN IF execute=True
-
set_interface_untagged_vlan
(int_type, interface, vlan, execute=True, delete=False, commit=True)¶ Sets the untagged (PVID) of an interface
Parameters: - int_type – This is the type of the interface, for instance: ‘bond’, ‘1G’, ‘10G’. Used to determine the group of the interface to be modified.
- interface – This is the number of the interface, or text ID of the bond. You will likely need to translate this.
- vlan – The ID of the vlan to add.
- commit – If commit is true, the appliance must load the new configuration as part of this method.
- delete – If delete is true and no value is set, remove all values. If delete is true and there is one or more values, remove only the specified values.
- execute – If execute is True, this method must run and apply the configuration.
Returns: Return the list of commands that can be run to effect the change. You must return the list EVEN IF execute=True
-
set_ntp_client_servers
(ntpserverlist, execute=True, commit=True, delete=False)¶ Parameters: - ntpserverlist – A list of ntp servers to add (IP Addresses or DNS)
- execute – If execute is True, this method must run and apply the configuration.
- commit – If commit is true, the appliance must load the new configuration as part of this method.
- delete – If delete is true and no value is set, remove all values. If delete is true and there is one or more values, remove only the specified values.
Returns: Return the list of commands that can be run to effect the change. You must return the list EVEN IF execute=True
-
set_ntp_client_timezone
(timezone, execute=True, delete=True, commit=True)¶ Sets the timezone of the NTP client.
Parameters: - timezone – Contains a string containing a valid timeozne recognized by pytz
- execute – If execute is True, this method must run and apply the configuration.
- commit – If commit is true, the appliance must load the new configuration as part of this method.
- delete – If delete is true and no value is set, remove all tagged vlans from the interface. If delete is true and there is one or more values, remove only the specified values. If you cannot delete the timezone on your appliance (I.E., one must always be specified), call the inherited self._not_supported(string), with string being an informative error message.
Returns: Return the list of commands that can be run to effect the change. You must return the list EVEN IF execute=True
-
set_portfast
(int_type, interface, enable_bool, execute=True, commit=True)¶ Portfast skips STP listening stage on the port to allow the link to come up faster.
Parameters: - int_type – This is the type of the interface, for instance: ‘bond’, ‘1G’, ‘10G’. Used to determine the group of the interface to be modified.
- interface – This is the number of the interface, or text ID of the bond. You will likely need to translate this.
- enable_bool – If true, enable portfast, if false disable portfast
- execute – If execute is True, this method must run and apply the configuration
- commit – If commit is true, this method must also commit the change (if applicable)
Returns: List of commands that can be run to effect the change. You must return the list even if execute=True
-