@@ -78,6 +78,17 @@ class ErofsLinstorCallException(LinstorCallException):
78
78
class NoPathLinstorCallException (LinstorCallException ):
79
79
pass
80
80
81
+ def log_successful_call (target_host , device_path , vdi_uuid , remote_method , response ):
82
+ util .SMlog (
83
+ 'Successful access on {} for device {} ({}): `{}` => {}' .format (target_host , device_path , vdi_uuid , remote_method , str (response )),
84
+ priority = util .LOG_DEBUG
85
+ )
86
+
87
+ def log_failed_call (target_host , next_target , device_path , vdi_uuid , remote_method , e ):
88
+ util .SMlog (
89
+ 'Failed to call method on {} for device {} ({}): {}. Trying accessing on {}... (cause: {})' .format (target_host , device_path , vdi_uuid , remote_method , next_target , e ),
90
+ priority = util .LOG_DEBUG
91
+ )
81
92
82
93
def linstorhostcall (local_method , remote_method ):
83
94
def decorated (response_parser ):
@@ -102,39 +113,36 @@ def wrapper(*args, **kwargs):
102
113
response = call_remote_method (
103
114
self ._session , host_ref_attached , remote_method , device_path , remote_args
104
115
)
116
+ log_successful_call ('attached node' , device_path , vdi_uuid , remote_method , response )
105
117
return response_parser (self , vdi_uuid , response )
106
118
except Exception as e :
107
- util .SMlog (
108
- 'Failed to call method on attached host. Trying local access... (cause: {})' .format (e ),
109
- priority = util .LOG_DEBUG
110
- )
119
+ log_failed_call ('attached node' , 'master' , device_path , vdi_uuid , remote_method , e )
111
120
112
121
try :
113
122
master_ref = self ._session .xenapi .pool .get_all_records ().values ()[0 ]['master' ]
114
123
response = call_remote_method (self ._session , master_ref , remote_method , device_path , remote_args )
124
+ log_successful_call ('master' , device_path , vdi_uuid , remote_method , response )
115
125
return response_parser (self , vdi_uuid , response )
116
126
except Exception as e :
117
- util .SMlog (
118
- 'Failed to call method on master host. Finding primary node... (cause: {})' .format (e ),
119
- priority = util .LOG_DEBUG
120
- )
127
+ log_failed_call ('master' , 'primary' , device_path , vdi_uuid , remote_method , e )
128
+
121
129
122
130
nodes , primary_hostname = self ._linstor .find_up_to_date_diskful_nodes (vdi_uuid )
123
131
if primary_hostname :
124
132
try :
125
133
host_ref = self ._get_readonly_host (vdi_uuid , device_path , {primary_hostname })
126
134
response = call_remote_method (self ._session , host_ref , remote_method , device_path , remote_args )
135
+ log_successful_call ('primary' , device_path , vdi_uuid , remote_method , response )
127
136
return response_parser (self , vdi_uuid , response )
128
137
except Exception as remote_e :
129
138
self ._raise_openers_exception (device_path , remote_e )
130
139
else :
131
- util .SMlog (
132
- 'Couldn\' t get primary for {}. Trying with another node...' .format (vdi_uuid ),
133
- priority = util .LOG_DEBUG
134
- )
140
+ log_failed_call ('primary' , 'another node' , device_path , vdi_uuid , remote_method , e )
141
+
135
142
try :
136
143
host = self ._get_readonly_host (vdi_uuid , device_path , nodes )
137
144
response = call_remote_method (self ._session , host , remote_method , device_path , remote_args )
145
+ log_successful_call ('another node' , device_path , vdi_uuid , remote_method , response )
138
146
return response_parser (self , vdi_uuid , response )
139
147
except Exception as remote_e :
140
148
self ._raise_openers_exception (device_path , remote_e )
0 commit comments