Bug #63857 unable to open an administrator tab, when remote management via ssh is set
Submitted: 27 Dec 2011 2:36 Modified: 30 Mar 2012 1:09
Reporter: Lutz Mndle Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Workbench: Administration Severity:S2 (Serious)
Version:5.2.36, 5.2.37 OS:Linux
Assigned to: CPU Architecture:Any
Tags: Contribution, open administrator tab

[27 Dec 2011 2:36] Lutz Mndle
Description:
Opening a new administrator tab to a server instance, which has SSH based remote management enabled, results in an error of "AttributeError: 'NoneType' object has no attribute 'get_password'". 

The backtrace is as follows:
Traceback (most recent call last):
  File "/usr/lib64/mysql-workbench/modules/wb_admin_grt.py", line 125, in do_open_administrator
    adminTab = AdministratorTab(server_instance)
  File "/usr/lib64/mysql-workbench/modules/wb_admin_grt.py", line 65, in __init__
    self.ctrl_be.init()
  File "/usr/lib64/mysql-workbench/modules/wb_admin_control.py", line 366, in init
    self.connect_sql()
  File "/usr/lib64/mysql-workbench/modules/wb_admin_control.py", line 636, in connect_sql
    opts = get_config_options()
  File "/usr/lib64/mysql-workbench/modules/wb_admin_control.py", line 582, in get_config_options
    password = self.server_control.get_password()
AttributeError: 'NoneType' object has no attribute 'get_password'

How to repeat:
See description.

Suggested fix:
Here comes a patch that corrects the problem:
--- wb_admin_control.py	2011-12-02 12:36:54.000000000 +0100
+++ /usr/lib64/mysql-workbench/modules/wb_admin_control.py	2011-12-26 19:55:27.103215460 +0100
@@ -360,32 +360,6 @@
 
         
     def init(self):
-        # connect SQL
-        while self.sql_enabled:
-            try:
-                self.connect_sql()
-                break
-            except MySQLError, err:
-                if err.code == MYSQL_ERR_ACCESS_DENIED:
-                    # Invalid password, request password
-                    r = mforms.Utilities.show_error("Could not connect to MySQL Server at %s" % err.location,
-                            "Could not connect to MySQL server: %s\nClick Continue to proceed without functionality that requires a DB connection." % err,
-                            "Retry", "Cancel", "Continue")
-                    if r == mforms.ResultOk:
-                        continue
-                    elif r == mforms.ResultCancel:
-                        raise OperationCancelledError("Connection cancelled")
-                    else:
-                        # continue without a db connection
-                       self.sql_enabled = False 
-                else:
-                    if mforms.Utilities.show_warning("Could not connect to MySQL Server at %s" % err.location,
-                            "%s\nYou may continue anyway, but some functionality will be unavailable." % err,
-                            "Continue", "Cancel", "") != mforms.ResultOk:
-                        raise OperationCancelledError("Could not connect to MySQL")
-                    else:
-                        self.sql_enabled = False
-
         if self.server_profile.uses_ssh:
             try:
                 self.ssh = SSH(self.server_profile, self.password_handler)
@@ -432,6 +406,32 @@
                 dprint_ex(1, "uses_ssh: %i uses_wmi: %i" % (self.server_profile.uses_ssh, self.server_profile.uses_wmi))
                 raise Exception("Unknown management method selected. Server Profile is possibly inconsistent")
 
+        # connect SQL
+        while self.sql_enabled:
+            try:
+                self.connect_sql()
+                break
+            except MySQLError, err:
+                if err.code == MYSQL_ERR_ACCESS_DENIED:
+                    # Invalid password, request password
+                    r = mforms.Utilities.show_error("Could not connect to MySQL Server at %s" % err.location,
+                            "Could not connect to MySQL server: %s\nClick Continue to proceed without functionality that requires a DB connection." % err,
+                            "Retry", "Cancel", "Continue")
+                    if r == mforms.ResultOk:
+                        continue
+                    elif r == mforms.ResultCancel:
+                        raise OperationCancelledError("Connection cancelled")
+                    else:
+                        # continue without a db connection
+                       self.sql_enabled = False 
+                else:
+                    if mforms.Utilities.show_warning("Could not connect to MySQL Server at %s" % err.location,
+                            "%s\nYou may continue anyway, but some functionality will be unavailable." % err,
+                            "Continue", "Cancel", "") != mforms.ResultOk:
+                        raise OperationCancelledError("Could not connect to MySQL")
+                    else:
+                        self.sql_enabled = False
+
 
     def shutdown(self):
         self.events.event('shutdown')
@@ -583,7 +583,7 @@
                         self.cfg_data = self.execute_filtered_command('cat %s' % self.server_profile.config_file_path,
                                                                       as_admin = True,
                                                                       admin_password = password)[0]
-                        cfg_file = StringIO.StringIO(self.tail_data)
+                        cfg_file = StringIO.StringIO(self.cfg_data)
                     else:
                         return {}
[28 Dec 2011 17:32] Valeriy Kravchuk
I do not see this problem with 5.2.37 on Mac OS X.
[28 Dec 2011 20:09] Lutz Mndle
patch for ./plugins/wb.admin/backend/wb_admin_control.py

Attachment: wb_admin_control.py.diff (text/x-patch), 4.01 KiB.

[28 Dec 2011 20:14] Lutz Mndle
The problem remains the same in 5.2.37 and the solution is the same. I've attached my proposed patch as a separate file for eventually better handling.
[31 Jan 2012 17:42] David Drake
I also ran into this problem on 5.2.37, using Mac OSX v10.7.2.

The patch worked, although the location of the file on my system is different than shown in the patch:

/Applications/MySQLWorkbench.app/Contents/PlugIns/wb_admin_control.py
[31 Jan 2012 17:43] David Drake
Note that I ran into this problem with a local mysql instance, and I only ran into this problem if the instance was running when I tried to open the instance.
[9 Feb 2012 11:23] Robert Hook
This may also be related to the presence or absence of the /etc/my.cnf file. I found that on a fresh install of MySql, that file did not exist, and the workbench seemed quite upset about it. I shut down the instance, and attempted to access the administrator tab in workbench again, and that succeeded. It then complained about the state of /etc/my.cnf and indicated it could not read or write the file. When I looked, the file had been created at this point, but the permissions were not good - it was only read/write for root. I modified the file to be world readable, and the problems with administrator seemed to go away.

Please note that this was with a fresh install, and only accessing a local instance.
[30 Mar 2012 1:09] Philip Olson
Fixed as of 5.2.38, and here's the changelog entry:

Opening a "Server Administration" tab for a
server instance that has remote management via SSH enabled would
result in an error, and fail to load.