| Total Complexity | 2 |
| Total Lines | 30 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | # encoding: utf-8 |
||
| 7 | class OPSCommand(Action): |
||
| 8 | |||
| 9 | def run(self, host, command): |
||
| 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_command = command.encode('utf-8', 'ignore') |
||
| 21 | utf8_host = host.encode('utf-8', 'ignore') |
||
| 22 | |||
| 23 | try: |
||
| 24 | |||
| 25 | transport = generic(host=utf8_host, username=self.username, |
||
| 26 | enable=self.enable, method=self.method, |
||
| 27 | password=self.password) |
||
| 28 | |||
| 29 | return_value = transport.read(utf8_command, return_type="string") |
||
| 30 | return_value = unicode(return_value, "utf-8") |
||
| 31 | transport.close() |
||
| 32 | return return_value |
||
| 33 | except Exception, err: |
||
| 34 | self.logger.info('FUBARd') |
||
| 35 | self.logger.info(err) |
||
| 36 | sys.exit(2) |
||
| 37 |