def ensure_netmiko_conn(func):
def wrap_function(self, filename=None, config=None):<EOL><INDENT>try:<EOL><INDENT>netmiko_object = self._netmiko_device<EOL>if netmiko_object is None:<EOL><INDENT>raise AttributeError()<EOL><DEDENT><DEDENT>except AttributeError:<EOL><INDENT>device_type = c.NETMIKO_MAP[self.platform]<EOL>netmiko_optional_args = self.netmiko_optional_args<EOL>if "<STR_LIT:port>" in netmiko_optional_args:<EOL><INDENT>netmiko_optional_args["<STR_LIT:port>"] = <NUM_LIT><EOL><DEDENT>self._netmiko_open(<EOL>device_type=device_type, netmiko_optional_args=netmiko_optional_args<EOL>)<EOL><DEDENT>func(self, filename=filename, config=config)<EOL><DEDENT>return wrap_function<EOL>
Decorator that ensures Netmiko connection exists.