Conditions | 4 |
Total Lines | 36 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | # encoding: utf-8 |
||
9 | def run(self, host, command, save): |
||
10 | self.method = self.config['method'] |
||
11 | self.username = self.config['username'] |
||
12 | self.password = self.config['password'] |
||
13 | self.enable = self.config['enable'] |
||
14 | |||
15 | self.method = self.method.encode('utf-8', 'ignore') |
||
16 | self.username = self.username.encode('utf-8', 'ignore') |
||
17 | self.password = self.password.encode('utf-8', 'ignore') |
||
18 | self.enable = self.enable.encode('utf-8', 'ignore') |
||
19 | |||
20 | utf8_host = host.encode('utf-8', 'ignore') |
||
21 | |||
22 | utf8_commands = [] |
||
23 | |||
24 | for cmd in command: |
||
25 | utf8_commands.append(cmd.encode('utf-8', 'ignore')) |
||
26 | |||
27 | try: |
||
28 | |||
29 | transport = generic(host=utf8_host, username=self.username, |
||
30 | enable=self.enable, method=self.method, |
||
31 | password=self.password) |
||
32 | |||
33 | return_value = transport.configure(utf8_commands) |
||
34 | _return_value = str(return_value).encode('utf-8', 'ignore') |
||
35 | |||
36 | if save is True: |
||
37 | transport.configure(["write mem"]) |
||
38 | |||
39 | transport.close() |
||
40 | return _return_value |
||
41 | except Exception, err: |
||
42 | self.logger.info('FUBARd') |
||
43 | self.logger.info(err) |
||
44 | sys.exit(2) |
||
45 |