debuggers.hg
changeset 12673:09c29e91e3cd
[XEND] Rename Xen API methods to match case of the API documentation
Get rid of the case skewing in XendAPI.
Remove _to_xml methods because it has been removed from the latest API
docs.
Signed-off-by: Alastair Tse <atse@xensource.com>
Get rid of the case skewing in XendAPI.
Remove _to_xml methods because it has been removed from the latest API
docs.
Signed-off-by: Alastair Tse <atse@xensource.com>
author | Alastair Tse <atse@xensource.com> |
---|---|
date | Thu Nov 30 14:48:42 2006 +0000 (2006-11-30) |
parents | a3b8c9e773e1 |
children | 96621d417bd4 |
files | tools/python/xen/xend/XendAPI.py |
line diff
1.1 --- a/tools/python/xen/xend/XendAPI.py Thu Nov 30 14:46:45 2006 +0000 1.2 +++ b/tools/python/xen/xend/XendAPI.py Thu Nov 30 14:48:42 2006 +0000 1.3 @@ -303,8 +303,8 @@ class XendAPI: 1.4 # all get_by_uuid() methods. 1.5 1.6 for cls in classes.keys(): 1.7 - get_by_uuid = '%s_get_by_uuid' % cls.lower() 1.8 - get_uuid = '%s_get_uuid' % cls.lower() 1.9 + get_by_uuid = '%s_get_by_uuid' % cls 1.10 + get_uuid = '%s_get_uuid' % cls 1.11 setattr(XendAPI, get_by_uuid, 1.12 lambda s, sess, obj_ref: xen_api_success(obj_ref)) 1.13 setattr(XendAPI, get_uuid, 1.14 @@ -327,7 +327,7 @@ class XendAPI: 1.15 1.16 # wrap validators around readable class attributes 1.17 for attr_name in ro_attrs + rw_attrs + self.Base_attr_ro: 1.18 - getter_name = '%s_get_%s' % (cls.lower(), attr_name) 1.19 + getter_name = '%s_get_%s' % (cls, attr_name) 1.20 try: 1.21 getter = getattr(XendAPI, getter_name) 1.22 for validator in validators: 1.23 @@ -340,7 +340,7 @@ class XendAPI: 1.24 1.25 # wrap validators around writable class attrributes 1.26 for attr_name in rw_attrs + self.Base_attr_rw: 1.27 - setter_name = '%s_set_%s' % (cls.lower(), attr_name) 1.28 + setter_name = '%s_set_%s' % (cls, attr_name) 1.29 try: 1.30 setter = getattr(XendAPI, setter_name) 1.31 for validator in validators: 1.32 @@ -353,7 +353,8 @@ class XendAPI: 1.33 1.34 # wrap validators around methods 1.35 for method_name in methods + self.Base_methods: 1.36 - method_full_name = '%s_%s' % (cls.lower(), method_name) 1.37 + method_full_name = '%s_%s' % (cls, method_name) 1.38 + 1.39 try: 1.40 method = getattr(XendAPI, method_full_name) 1.41 for validator in validators: 1.42 @@ -366,7 +367,7 @@ class XendAPI: 1.43 1.44 # wrap validators around class functions 1.45 for func_name in funcs + self.Base_funcs: 1.46 - func_full_name = '%s_%s' % (cls.lower(), func_name) 1.47 + func_full_name = '%s_%s' % (cls, func_name) 1.48 try: 1.49 method = getattr(XendAPI, func_full_name) 1.50 method = session_required(method) 1.51 @@ -379,7 +380,7 @@ class XendAPI: 1.52 1.53 Base_attr_ro = ['uuid'] 1.54 Base_attr_rw = [] 1.55 - Base_methods = ['destroy', 'to_XML', 'get_record'] 1.56 + Base_methods = ['destroy', 'get_record'] 1.57 Base_funcs = ['create', 'get_by_uuid', 'get_all'] 1.58 1.59 # Xen API: Class Session 1.60 @@ -411,8 +412,6 @@ class XendAPI: 1.61 record = {'this_host': XendNode.instance().uuid, 1.62 'this_user': auth_manager().get_user(session)} 1.63 return xen_api_success(record) 1.64 - def session_to_XML(self, session): 1.65 - return xen_api_todo() 1.66 1.67 # attributes (ro) 1.68 def session_get_this_host(self, session): 1.69 @@ -536,8 +535,6 @@ class XendAPI: 1.70 'features': node.get_host_cpu_features(host_cpu_ref), 1.71 'utilisation': node.get_host_cpu_load(host_cpu_ref)} 1.72 return xen_api_success(record) 1.73 - def host_cpu_to_XML(self, session, host_cpu_ref): 1.74 - return xen_api_todo() 1.75 1.76 # class methods 1.77 def host_cpu_get_all(self, session): 1.78 @@ -656,304 +653,301 @@ class XendAPI: 1.79 'otherConfig'] 1.80 1.81 # attributes (ro) 1.82 - def vm_get_power_state(self, session, vm_ref): 1.83 + def VM_get_power_state(self, session, vm_ref): 1.84 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 1.85 return xen_api_success(dom.state) 1.86 1.87 - def vm_get_resident_on(self, session, vm_ref): 1.88 + def VM_get_resident_on(self, session, vm_ref): 1.89 return xen_api_success(XendNode.instance().uuid) 1.90 1.91 - def vm_get_memory_actual(self, session, vm_ref): 1.92 + def VM_get_memory_actual(self, session, vm_ref): 1.93 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 1.94 return xen_api_todo() # unsupported by xc 1.95 1.96 - def vm_get_memory_static_max(self, session, vm_ref): 1.97 + def VM_get_memory_static_max(self, session, vm_ref): 1.98 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 1.99 return xen_api_success(dom.get_memory_static_max()) 1.100 1.101 - def vm_get_memory_static_min(self, session, vm_ref): 1.102 + def VM_get_memory_static_min(self, session, vm_ref): 1.103 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 1.104 return xen_api_success(dom.get_memory_static_min()) 1.105 1.106 - def vm_get_VCPUs_number(self, session, vm_ref): 1.107 + def VM_get_VCPUs_number(self, session, vm_ref): 1.108 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 1.109 return xen_api_success(dom.getVCpuCount()) 1.110 1.111 - def vm_get_VCPUs_utilisation(self, session, vm_ref): 1.112 + def VM_get_VCPUs_utilisation(self, session, vm_ref): 1.113 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 1.114 return xen_api_success(dom.get_vcpus_util()) 1.115 1.116 - def vm_get_VCPUs_features_required(self, session, vm_ref): 1.117 + def VM_get_VCPUs_features_required(self, session, vm_ref): 1.118 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 1.119 return xen_api_todo() # unsupported by xc 1.120 1.121 - def vm_get_VCPUs_can_use(self, session, vm_ref): 1.122 + def VM_get_VCPUs_can_use(self, session, vm_ref): 1.123 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 1.124 return xen_api_todo() # unsupported by xc 1.125 1.126 - def vm_get_VIFs(self, session, vm_ref): 1.127 + def VM_get_VIFs(self, session, vm_ref): 1.128 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 1.129 return xen_api_success(dom.get_vifs()) 1.130 1.131 - def vm_get_VBDs(self, session, vm_ref): 1.132 + def VM_get_VBDs(self, session, vm_ref): 1.133 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 1.134 return xen_api_success(dom.get_vbds()) 1.135 1.136 - def vm_get_VTPMs(self, session, vm_ref): 1.137 + def VM_get_VTPMs(self, session, vm_ref): 1.138 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 1.139 return xen_api_success(dom.get_vtpms()) 1.140 1.141 - def vm_get_PCI_bus(self, session, vm_ref): 1.142 + def VM_get_PCI_bus(self, session, vm_ref): 1.143 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 1.144 return xen_api_todo() # unsupported by xc 1.145 1.146 - def vm_get_tools_version(self, session, vm_ref): 1.147 + def VM_get_tools_version(self, session, vm_ref): 1.148 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 1.149 return xen_api_todo() 1.150 1.151 # attributes (rw) 1.152 - def vm_get_name_label(self, session, vm_ref): 1.153 + def VM_get_name_label(self, session, vm_ref): 1.154 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 1.155 return xen_api_success(dom.getName()) 1.156 1.157 - def vm_get_name_description(self, session, vm_ref): 1.158 + def VM_get_name_description(self, session, vm_ref): 1.159 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 1.160 return xen_api_todo() 1.161 1.162 - def vm_get_user_version(self, session, vm_ref): 1.163 + def VM_get_user_version(self, session, vm_ref): 1.164 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 1.165 return xen_api_todo() 1.166 1.167 - def vm_get_is_a_template(self, session, vm_ref): 1.168 + def VM_get_is_a_template(self, session, vm_ref): 1.169 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 1.170 return xen_api_todo() 1.171 1.172 - def vm_get_memory_dynamic_max(self, session, vm_ref): 1.173 + def VM_get_memory_dynamic_max(self, session, vm_ref): 1.174 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 1.175 return xen_api_success(dom.get_memory_dynamic_max()) 1.176 1.177 - def vm_get_memory_dynamic_min(self, session, vm_ref): 1.178 + def VM_get_memory_dynamic_min(self, session, vm_ref): 1.179 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 1.180 return xen_api_success(dom.get_memory_dynamic_min()) 1.181 1.182 - def vm_get_VCPUs_policy(self, session, vm_ref): 1.183 + def VM_get_VCPUs_policy(self, session, vm_ref): 1.184 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 1.185 return xen_api_todo() # need to access scheduler 1.186 1.187 - def vm_get_VCPUs_params(self, session, vm_ref): 1.188 + def VM_get_VCPUs_params(self, session, vm_ref): 1.189 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 1.190 return xen_api_todo() # need access to scheduler 1.191 1.192 - def vm_get_VCPUs_features_force_on(self, session, vm_ref): 1.193 + def VM_get_VCPUs_features_force_on(self, session, vm_ref): 1.194 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 1.195 return xen_api_todo() 1.196 1.197 - def vm_get_VCPUs_features_force_off(self, session, vm_ref): 1.198 + def VM_get_VCPUs_features_force_off(self, session, vm_ref): 1.199 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 1.200 return xen_api_todo() 1.201 1.202 - def vm_get_actions_after_shutdown(self, session, vm_ref): 1.203 + def VM_get_actions_after_shutdown(self, session, vm_ref): 1.204 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 1.205 return xen_api_success(dom.get_on_shutdown()) 1.206 1.207 - def vm_get_actions_after_reboot(self, session, vm_ref): 1.208 + def VM_get_actions_after_reboot(self, session, vm_ref): 1.209 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 1.210 return xen_api_success(dom.get_on_reboot()) 1.211 1.212 - def vm_get_actions_after_suspend(self, session, vm_ref): 1.213 + def VM_get_actions_after_suspend(self, session, vm_ref): 1.214 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 1.215 return xen_api_success(dom.get_on_suspend()) 1.216 1.217 - def vm_get_actions_after_crash(self, session, vm_ref): 1.218 + def VM_get_actions_after_crash(self, session, vm_ref): 1.219 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 1.220 return xen_api_success(dom.get_on_crash()) 1.221 1.222 - def vm_get_bios_boot(self, session, vm_ref): 1.223 + def VM_get_bios_boot(self, session, vm_ref): 1.224 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 1.225 return xen_api_success(dom.get_bios_boot()) 1.226 1.227 - def vm_get_platform_std_VGA(self, session, vm_ref): 1.228 + def VM_get_platform_std_VGA(self, session, vm_ref): 1.229 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 1.230 return xen_api_todo() 1.231 1.232 - def vm_get_platform_serial(self, session, vm_ref): 1.233 + def VM_get_platform_serial(self, session, vm_ref): 1.234 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 1.235 return xen_api_todo() 1.236 1.237 - def vm_get_platform_localtime(self, session, vm_ref): 1.238 + def VM_get_platform_localtime(self, session, vm_ref): 1.239 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 1.240 return xen_api_todo() 1.241 1.242 - def vm_get_platform_clock_offset(self, session, vm_ref): 1.243 + def VM_get_platform_clock_offset(self, session, vm_ref): 1.244 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 1.245 return xen_api_todo() 1.246 1.247 - def vm_get_platform_enable_audio(self, session, vm_ref): 1.248 + def VM_get_platform_enable_audio(self, session, vm_ref): 1.249 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 1.250 return xen_api_todo() 1.251 1.252 - def vm_get_platform_keymap(self, session, vm_ref): 1.253 + def VM_get_platform_keymap(self, session, vm_ref): 1.254 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 1.255 return xen_api_todo() 1.256 1.257 - def vm_get_builder(self, session, vm_ref): 1.258 + def VM_get_builder(self, session, vm_ref): 1.259 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 1.260 return xen_api_success(dom.get_builder()) 1.261 1.262 - def vm_get_boot_method(self, session, vm_ref): 1.263 + def VM_get_boot_method(self, session, vm_ref): 1.264 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 1.265 return xen_api_success(dom.get_boot_method()) 1.266 1.267 - def vm_get_kernel_kernel(self, session, vm_ref): 1.268 + def VM_get_kernel_kernel(self, session, vm_ref): 1.269 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 1.270 return xen_api_success('') 1.271 1.272 - def vm_get_kernel_initrd(self, session, vm_ref): 1.273 + def VM_get_kernel_initrd(self, session, vm_ref): 1.274 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 1.275 return xen_api_success('') 1.276 1.277 - def vm_get_kernel_args(self, session, vm_ref): 1.278 + def VM_get_kernel_args(self, session, vm_ref): 1.279 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 1.280 return xen_api_success('') 1.281 1.282 - def vm_get_grub_cmdline(self, session, vm_ref): 1.283 + def VM_get_grub_cmdline(self, session, vm_ref): 1.284 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 1.285 return xen_api_success('') 1.286 1.287 - def vm_get_otherConfig(self, session, vm_ref): 1.288 + def VM_get_otherConfig(self, session, vm_ref): 1.289 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 1.290 return xen_api_todo() 1.291 1.292 - def vm_set_name_label(self, session, vm_ref): 1.293 + def VM_set_name_label(self, session, vm_ref): 1.294 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 1.295 return xen_api_success_void() 1.296 1.297 - def vm_set_name_description(self, session, vm_ref): 1.298 + def VM_set_name_description(self, session, vm_ref): 1.299 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 1.300 return xen_api_success_void() 1.301 1.302 - def vm_set_user_version(self, session, vm_ref): 1.303 + def VM_set_user_version(self, session, vm_ref): 1.304 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 1.305 return xen_api_success_void() 1.306 1.307 - def vm_set_is_a_template(self, session, vm_ref): 1.308 + def VM_set_is_a_template(self, session, vm_ref): 1.309 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 1.310 return xen_api_success_void() 1.311 1.312 - def vm_set_memory_dynamic_max(self, session, vm_ref): 1.313 + def VM_set_memory_dynamic_max(self, session, vm_ref): 1.314 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 1.315 return xen_api_success_void() 1.316 1.317 - def vm_set_memory_dynamic_min(self, session, vm_ref): 1.318 + def VM_set_memory_dynamic_min(self, session, vm_ref): 1.319 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 1.320 return xen_api_success_void() 1.321 1.322 - def vm_set_VCPUs_policy(self, session, vm_ref): 1.323 + def VM_set_VCPUs_policy(self, session, vm_ref): 1.324 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 1.325 return xen_api_success_void() 1.326 1.327 - def vm_set_VCPUs_params(self, session, vm_ref): 1.328 + def VM_set_VCPUs_params(self, session, vm_ref): 1.329 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 1.330 return xen_api_success_void() 1.331 1.332 - def vm_set_VCPUs_features_force_on(self, session, vm_ref): 1.333 + def VM_set_VCPUs_features_force_on(self, session, vm_ref): 1.334 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 1.335 return xen_api_success_void() 1.336 1.337 - def vm_set_VCPUs_features_force_off(self, session, vm_ref): 1.338 + def VM_set_VCPUs_features_force_off(self, session, vm_ref): 1.339 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 1.340 return xen_api_success_void() 1.341 1.342 - def vm_set_actions_after_shutdown(self, session, vm_ref): 1.343 + def VM_set_actions_after_shutdown(self, session, vm_ref): 1.344 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 1.345 return xen_api_success_void() 1.346 1.347 - def vm_set_actions_after_reboot(self, session, vm_ref): 1.348 + def VM_set_actions_after_reboot(self, session, vm_ref): 1.349 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 1.350 return xen_api_success_void() 1.351 1.352 - def vm_set_actions_after_suspend(self, session, vm_ref): 1.353 + def VM_set_actions_after_suspend(self, session, vm_ref): 1.354 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 1.355 return xen_api_success_void() 1.356 1.357 - def vm_set_actions_after_crash(self, session, vm_ref): 1.358 + def VM_set_actions_after_crash(self, session, vm_ref): 1.359 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 1.360 return xen_api_success_void() 1.361 1.362 - def vm_set_bios_boot(self, session, vm_ref): 1.363 + def VM_set_bios_boot(self, session, vm_ref): 1.364 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 1.365 return xen_api_success_void() 1.366 1.367 - def vm_set_platform_std_VGA(self, session, vm_ref): 1.368 + def VM_set_platform_std_VGA(self, session, vm_ref): 1.369 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 1.370 return xen_api_success_void() 1.371 1.372 - def vm_set_platform_serial(self, session, vm_ref): 1.373 + def VM_set_platform_serial(self, session, vm_ref): 1.374 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 1.375 return xen_api_success_void() 1.376 1.377 - def vm_set_platform_localtime(self, session, vm_ref): 1.378 + def VM_set_platform_localtime(self, session, vm_ref): 1.379 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 1.380 return xen_api_success_void() 1.381 1.382 - def vm_set_platform_clock_offset(self, session, vm_ref): 1.383 + def VM_set_platform_clock_offset(self, session, vm_ref): 1.384 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 1.385 return xen_api_success_void() 1.386 1.387 - def vm_set_platform_enable_audio(self, session, vm_ref): 1.388 + def VM_set_platform_enable_audio(self, session, vm_ref): 1.389 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 1.390 return xen_api_success_void() 1.391 1.392 - def vm_set_builder(self, session, vm_ref): 1.393 + def VM_set_builder(self, session, vm_ref): 1.394 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 1.395 return xen_api_success_void() 1.396 1.397 - def vm_set_boot_method(self, session, vm_ref): 1.398 + def VM_set_boot_method(self, session, vm_ref): 1.399 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 1.400 return xen_api_success_void() 1.401 1.402 - def vm_set_kernel_kernel(self, session, vm_ref): 1.403 + def VM_set_kernel_kernel(self, session, vm_ref): 1.404 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 1.405 return xen_api_success_void() 1.406 1.407 - def vm_set_kernel_initrd(self, session, vm_ref): 1.408 + def VM_set_kernel_initrd(self, session, vm_ref): 1.409 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 1.410 return xen_api_success_void() 1.411 1.412 - def vm_set_kernel_args(self, session, vm_ref): 1.413 + def VM_set_kernel_args(self, session, vm_ref): 1.414 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 1.415 return xen_api_success_void() 1.416 1.417 - def vm_set_grub_cmdline(self, session, vm_ref): 1.418 + def VM_set_grub_cmdline(self, session, vm_ref): 1.419 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 1.420 return xen_api_success_void() 1.421 1.422 - def vm_set_otherConfig(self, session, vm_ref): 1.423 + def VM_set_otherConfig(self, session, vm_ref): 1.424 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 1.425 return xen_api_success_void() 1.426 1.427 # class methods 1.428 - def vm_get_all(self, session): 1.429 + def VM_get_all(self, session): 1.430 refs = [d.get_uuid() for d in XendDomain.instance().list()] 1.431 return xen_api_success(refs) 1.432 1.433 - def vm_get_by_name_label(self, session, label): 1.434 + def VM_get_by_name_label(self, session, label): 1.435 xendom = XendDomain.instance() 1.436 dom = xendom.domain_lookup_nr(label) 1.437 if dom: 1.438 return xen_api_success([dom.get_uuid()]) 1.439 return xen_api_error(XEND_ERROR_VM_INVALID) 1.440 1.441 - def vm_create(self, session, vm_struct): 1.442 + def VM_create(self, session, vm_struct): 1.443 xendom = XendDomain.instance() 1.444 domuuid = xendom.create_domain(vm_struct) 1.445 return xen_api_success(domuuid) 1.446 1.447 # object methods 1.448 - def vm_to_XML(self, session, vm_ref): 1.449 - return xen_api_todo() 1.450 - 1.451 - def vm_get_record(self, session, vm_ref): 1.452 + def VM_get_record(self, session, vm_ref): 1.453 xendom = XendDomain.instance() 1.454 xeninfo = xendom.get_vm_by_uuid(vm_ref) 1.455 if not xeninfo: 1.456 @@ -1006,41 +1000,39 @@ class XendAPI: 1.457 } 1.458 return xen_api_success(record) 1.459 1.460 - def vm_clean_reboot(self, session, vm_ref): 1.461 + def VM_clean_reboot(self, session, vm_ref): 1.462 xendom = XendDomain.instance() 1.463 xeninfo = xendom.get_vm_by_uuid(vm_ref) 1.464 xeninfo.shutdown("reboot") 1.465 return xen_api_success_void() 1.466 - def vm_clean_shutdown(self, session, vm_ref): 1.467 + def VM_clean_shutdown(self, session, vm_ref): 1.468 xendom = XendDomain.instance() 1.469 xeninfo = xendom.get_vm_by_uuid(vm_ref) 1.470 xeninfo.shutdown("poweroff") 1.471 return xen_api_success_void() 1.472 - def vm_clone(self, session, vm_ref): 1.473 + def VM_clone(self, session, vm_ref): 1.474 return xen_api_error(XEND_ERROR_UNSUPPORTED) 1.475 - def vm_destroy(self, session, vm_ref): 1.476 + def VM_destroy(self, session, vm_ref): 1.477 return do_vm_func("domain_delete", vm_ref) 1.478 - def vm_hard_reboot(self, session, vm_ref): 1.479 + def VM_hard_reboot(self, session, vm_ref): 1.480 return xen_api_error(XEND_ERROR_UNSUPPORTED) 1.481 - def vm_hard_shutdown(self, session, vm_ref): 1.482 + def VM_hard_shutdown(self, session, vm_ref): 1.483 return do_vm_func("domain_destroy", vm_ref) 1.484 - def vm_pause(self, session, vm_ref): 1.485 + def VM_pause(self, session, vm_ref): 1.486 return do_vm_func("domain_pause", vm_ref) 1.487 - def vm_resume(self, session, vm_ref, start_paused): 1.488 + def VM_resume(self, session, vm_ref, start_paused): 1.489 return do_vm_func("domain_resume", vm_ref, start_paused = start_paused) 1.490 - def vm_start(self, session, vm_ref, start_paused): 1.491 + def VM_start(self, session, vm_ref, start_paused): 1.492 return do_vm_func("domain_start", vm_ref, start_paused = start_paused) 1.493 - def vm_suspend(self, session, vm_ref): 1.494 + def VM_suspend(self, session, vm_ref): 1.495 return do_vm_func("domain_suspend", vm_ref) 1.496 - def vm_unpause(self, session, vm_ref): 1.497 + def VM_unpause(self, session, vm_ref): 1.498 return do_vm_func("domain_unpause", vm_ref) 1.499 1.500 - # Xen API: Class VDI 1.501 - # ---------------------------------------------------------------- 1.502 - # TODO: NOT IMPLEMENTED. 1.503 - 1.504 # Xen API: Class VBD 1.505 # ---------------------------------------------------------------- 1.506 + # Note: accepts a non-API standard 'image' attribute to emulate 1.507 + # regular xm created VBDs 1.508 1.509 VBD_attr_ro = ['image', 1.510 'IO_bandwidth_incoming_kbs', 1.511 @@ -1053,8 +1045,10 @@ class XendAPI: 1.512 1.513 VBD_attr_inst = VBD_attr_rw + ['image'] 1.514 1.515 + VBD_methods = ['media_change'] 1.516 + 1.517 # object methods 1.518 - def vbd_get_record(self, session, vbd_ref): 1.519 + def VBD_get_record(self, session, vbd_ref): 1.520 xendom = XendDomain.instance() 1.521 vm = xendom.get_vm_with_dev_uuid('vbd', vbd_ref) 1.522 if not vm: 1.523 @@ -1063,9 +1057,12 @@ class XendAPI: 1.524 if not cfg: 1.525 return xen_api_error(XEND_ERROR_VBD_INVALID) 1.526 return xen_api_success(cfg) 1.527 - 1.528 + 1.529 + def VBD_media_change(self, session, vbd_ref, vdi_ref): 1.530 + return xen_api_error(XEND_ERROR_UNSUPPORTED) 1.531 + 1.532 # class methods 1.533 - def vbd_create(self, session, vbd_struct): 1.534 + def VBD_create(self, session, vbd_struct): 1.535 xendom = XendDomain.instance() 1.536 if not xendom.is_valid_vm(vbd_struct['VM']): 1.537 return xen_api_error(XEND_ERROR_DOMAIN_INVALID) 1.538 @@ -1092,22 +1089,22 @@ class XendAPI: 1.539 return xen_api_success(vbd_ref) 1.540 1.541 # attributes (rw) 1.542 - def vbd_get_VM(self, session, vbd_ref): 1.543 + def VBD_get_VM(self, session, vbd_ref): 1.544 xendom = XendDomain.instance() 1.545 return xen_api_success(xendom.get_dev_property('vbd', vbd_ref, 'VM')) 1.546 1.547 - def vbd_get_VDI(self, session, vbd_ref): 1.548 + def VBD_get_VDI(self, session, vbd_ref): 1.549 return xen_api_todo() 1.550 1.551 - def vbd_get_device(self, session, vbd_ref): 1.552 + def VBD_get_device(self, session, vbd_ref): 1.553 xendom = XendDomain.instance() 1.554 return xen_api_success(xendom.get_dev_property('vbd', vbd_ref, 1.555 'device')) 1.556 - def vbd_get_mode(self, session, vbd_ref): 1.557 + def VBD_get_mode(self, session, vbd_ref): 1.558 xendom = XendDomain.instance() 1.559 return xen_api_success(xendom.get_dev_property('vbd', vbd_ref, 1.560 'mode')) 1.561 - def vbd_get_driver(self, session, vbd_ref): 1.562 + def VBD_get_driver(self, session, vbd_ref): 1.563 xendom = XendDomain.instance() 1.564 return xen_api_success(xendom.get_dev_property('vbd', vbd_ref, 1.565 'driver')) 1.566 @@ -1130,7 +1127,7 @@ class XendAPI: 1.567 VIF_attr_inst = VIF_attr_rw 1.568 1.569 # object methods 1.570 - def vif_get_record(self, session, vif_ref): 1.571 + def VIF_get_record(self, session, vif_ref): 1.572 xendom = XendDomain.instance() 1.573 vm = xendom.get_vm_with_dev_uuid('vif', vif_ref) 1.574 if not vm: 1.575 @@ -1147,7 +1144,7 @@ class XendAPI: 1.576 return xen_api_success(cfg) 1.577 1.578 # class methods 1.579 - def vif_create(self, session, vif_struct): 1.580 + def VIF_create(self, session, vif_struct): 1.581 xendom = XendDomain.instance() 1.582 if xendom.is_valid_vm(vif_struct['VM']): 1.583 dom = xendom.get_vm_by_uuid(vif_struct['VM']) 1.584 @@ -1180,99 +1177,96 @@ class XendAPI: 1.585 VDI_methods = ['snapshot'] 1.586 VDI_funcs = ['get_by_name_label'] 1.587 1.588 - def vdi_get_VBDs(self, session, vdi_ref): 1.589 + def VDI_get_VBDs(self, session, vdi_ref): 1.590 return xen_api_todo() 1.591 1.592 - def vdi_get_physical_utilisation(self, session, vdi_ref): 1.593 + def VDI_get_physical_utilisation(self, session, vdi_ref): 1.594 sr = XendNode.instance().get_sr() 1.595 image = sr.xen_api_get_by_uuid(vdi_ref) 1.596 return xen_api_success(image.get_physical_utilisation()) 1.597 1.598 - def vdi_get_sector_size(self, session, vdi_ref): 1.599 + def VDI_get_sector_size(self, session, vdi_ref): 1.600 sr = XendNode.instance().get_sr() 1.601 image = sr.xen_api_get_by_uuid(vdi_ref) 1.602 return xen_api_success(image.sector_size) 1.603 1.604 - def vdi_get_type(self, session, vdi_ref): 1.605 + def VDI_get_type(self, session, vdi_ref): 1.606 sr = XendNode.instance().get_sr() 1.607 image = sr.xen_api_get_by_uuid(vdi_ref) 1.608 return xen_api_success(image.type) 1.609 1.610 - def vdi_get_parent(self, session, vdi_ref): 1.611 + def VDI_get_parent(self, session, vdi_ref): 1.612 sr = XendNode.instance().get_sr() 1.613 image = sr.xen_api_get_by_uuid(vdi_ref) 1.614 return xen_api_success(image.parent) 1.615 1.616 - def vdi_get_children(self, session, vdi_ref): 1.617 + def VDI_get_children(self, session, vdi_ref): 1.618 sr = XendNode.instance().get_sr() 1.619 image = sr.xen_api_get_by_uuid(vdi_ref) 1.620 return xen_api_success(image.children) 1.621 1.622 - def vdi_get_name_label(self, session, vdi_ref): 1.623 + def VDI_get_name_label(self, session, vdi_ref): 1.624 sr = XendNode.instance().get_sr() 1.625 image = sr.xen_api_get_by_uuid(vdi_ref) 1.626 return xen_api_success(image.name_label) 1.627 1.628 - def vdi_get_name_description(self, session, vdi_ref): 1.629 + def VDI_get_name_description(self, session, vdi_ref): 1.630 sr = XendNode.instance().get_sr() 1.631 image = sr.xen_api_get_by_uuid(vdi_ref) 1.632 return xen_api_success(image.name_description) 1.633 1.634 - def vdi_get_SR(self, session, vdi_ref): 1.635 + def VDI_get_SR(self, session, vdi_ref): 1.636 sr = XendNode.instance().get_sr() 1.637 return xen_api_success(sr.uuid) 1.638 1.639 - def vdi_get_virtual_size(self, session, vdi_ref): 1.640 + def VDI_get_virtual_size(self, session, vdi_ref): 1.641 sr = XendNode.instance().get_sr() 1.642 image = sr.xen_api_get_by_uuid(vdi_ref) 1.643 return xen_api_success(image.virtual_size) 1.644 1.645 - def vdi_get_sharable(self, session, vdi_ref): 1.646 + def VDI_get_sharable(self, session, vdi_ref): 1.647 sr = XendNode.instance().get_sr() 1.648 image = sr.xen_api_get_by_uuid(vdi_ref) 1.649 return xen_api_success(image.sharable) 1.650 1.651 - def vdi_get_read_only(self, session, vdi_ref): 1.652 + def VDI_get_read_only(self, session, vdi_ref): 1.653 sr = XendNode.instance().get_sr() 1.654 image = sr.xen_api_get_by_uuid(vdi_ref) 1.655 return xen_api_success(image.sharable) 1.656 1.657 - def vdi_set_name_label(self, session, vdi_ref, value): 1.658 + def VDI_set_name_label(self, session, vdi_ref, value): 1.659 sr = XendNode.instance().get_sr() 1.660 image = sr.xen_api_get_by_uuid(vdi_ref) 1.661 image.name_label = value 1.662 return xen_api_success_void() 1.663 1.664 - def vdi_set_name_description(self, session, vdi_ref, value): 1.665 + def VDI_set_name_description(self, session, vdi_ref, value): 1.666 sr = XendNode.instance().get_sr() 1.667 image = sr.xen_api_get_by_uuid(vdi_ref) 1.668 image.name_description = value 1.669 return xen_api_success_void() 1.670 1.671 - def vdi_set_SR(self, session, vdi_ref, value): 1.672 + def VDI_set_SR(self, session, vdi_ref, value): 1.673 return xen_api_error(XEND_ERROR_UNSUPPORTED) 1.674 1.675 - def vdi_set_virtual_size(self, session, vdi_ref, value): 1.676 + def VDI_set_virtual_size(self, session, vdi_ref, value): 1.677 return xen_api_error(XEND_ERROR_UNSUPPORTED) 1.678 1.679 - def vdi_set_sharable(self, session, vdi_ref, value): 1.680 + def VDI_set_sharable(self, session, vdi_ref, value): 1.681 return xen_api_todo() 1.682 - def vdi_set_read_only(self, session, vdi_ref, value): 1.683 + def VDI_set_read_only(self, session, vdi_ref, value): 1.684 return xen_api_todo() 1.685 1.686 # Object Methods 1.687 - def vdi_snapshot(self, session, vdi_ref): 1.688 + def VDI_snapshot(self, session, vdi_ref): 1.689 return xen_api_todo() 1.690 1.691 - def vdi_destroy(self, session, vdi_ref): 1.692 + def VDI_destroy(self, session, vdi_ref): 1.693 sr = XendNode.instance().get_sr() 1.694 sr.destroy_image(vdi_ref) 1.695 return xen_api_success_void() 1.696 1.697 - def vdi_to_XML(self, session, vdi_ref): 1.698 - return xen_api_todo() 1.699 - 1.700 - def vdi_get_record(self, session, vdi_ref): 1.701 + def VDI_get_record(self, session, vdi_ref): 1.702 sr = XendNode.instance().get_sr() 1.703 image = sr.xen_api_get_by_uuid(vdi_ref) 1.704 if image: 1.705 @@ -1295,7 +1289,7 @@ class XendAPI: 1.706 return xen_api_error(XEND_ERROR_VDI_INVALID) 1.707 1.708 # Class Functions 1.709 - def vdi_create(self, session, vdi_struct): 1.710 + def VDI_create(self, session, vdi_struct): 1.711 sr = XendNode.instance().get_sr() 1.712 sr_ref = vdi_struct['SR'] 1.713 if sr.uuid != sr_ref: 1.714 @@ -1304,11 +1298,11 @@ class XendAPI: 1.715 vdi_uuid = sr.create_image(vdi_struct) 1.716 return xen_api_success(vdi_uuid) 1.717 1.718 - def vdi_get_all(self, session): 1.719 + def VDI_get_all(self, session): 1.720 sr = XendNode.instance().get_sr() 1.721 return xen_api_success(sr.list_images()) 1.722 1.723 - def vdi_get_by_name_label(self, session, name): 1.724 + def VDI_get_by_name_label(self, session, name): 1.725 sr = XendNode.instance().get_sr() 1.726 image_uuid = sr.xen_api_get_by_name_label(name) 1.727 if image_uuid: 1.728 @@ -1329,7 +1323,7 @@ class XendAPI: 1.729 VTPM_attr_inst = VTPM_attr_rw 1.730 1.731 # object methods 1.732 - def vtpm_get_record(self, session, vtpm_ref): 1.733 + def VTPM_get_record(self, session, vtpm_ref): 1.734 xendom = XendDomain.instance() 1.735 vm = xendom.get_vm_with_dev_uuid('vtpm', vtpm_ref) 1.736 if not vm: 1.737 @@ -1346,7 +1340,7 @@ class XendAPI: 1.738 return xen_api_success(cfg) 1.739 1.740 # Class Functions 1.741 - def vtpm_get_instance(self, session, vtpm_ref): 1.742 + def VTPM_get_instance(self, session, vtpm_ref): 1.743 xendom = XendDomain.instance() 1.744 vm = xendom.get_vm_with_dev_uuid('vtpm', vtpm_ref) 1.745 if not vm: 1.746 @@ -1360,7 +1354,7 @@ class XendAPI: 1.747 instance = -1 1.748 return xen_api_success(instance) 1.749 1.750 - def vtpm_get_driver(self, session, vtpm_ref): 1.751 + def VTPM_get_driver(self, session, vtpm_ref): 1.752 xendom = XendDomain.instance() 1.753 vm = xendom.get_vm_with_dev_uuid('vtpm', vtpm_ref) 1.754 if not vm: 1.755 @@ -1374,7 +1368,7 @@ class XendAPI: 1.756 driver = "Unknown" 1.757 return xen_api_success(driver) 1.758 1.759 - def vtpm_get_backend(self, session, vtpm_ref): 1.760 + def VTPM_get_backend(self, session, vtpm_ref): 1.761 xendom = XendDomain.instance() 1.762 vm = xendom.get_vm_with_dev_uuid('vtpm', vtpm_ref) 1.763 if not vm: 1.764 @@ -1388,12 +1382,12 @@ class XendAPI: 1.765 backend = "Domain-0" 1.766 return xen_api_success(backend) 1.767 1.768 - def vtpm_get_VM(self, session, vtpm_ref): 1.769 + def VTPM_get_VM(self, session, vtpm_ref): 1.770 xendom = XendDomain.instance() 1.771 return xen_api_success(xendom.get_dev_property('vtpm', vtpm_ref, 'VM')) 1.772 1.773 # class methods 1.774 - def vtpm_create(self, session, vtpm_struct): 1.775 + def VTPM_create(self, session, vtpm_struct): 1.776 xendom = XendDomain.instance() 1.777 if xendom.is_valid_vm(vtpm_struct['VM']): 1.778 dom = xendom.get_vm_by_uuid(vtpm_struct['VM']) 1.779 @@ -1429,32 +1423,30 @@ class XendAPI: 1.780 SR_funcs = ['get_by_name_label'] 1.781 1.782 # Class Functions 1.783 - def sr_get_all(self, session): 1.784 + def SR_get_all(self, session): 1.785 sr = XendNode.instance().get_sr() 1.786 return xen_api_success([sr.uuid]) 1.787 1.788 - def sr_get_by_name_label(self, session, label): 1.789 + def SR_get_by_name_label(self, session, label): 1.790 sr = XendNode.instance().get_sr() 1.791 if sr.name_label != label: 1.792 return xen_api_error(XEND_ERROR_SR_INVALID) 1.793 return xen_api_success([sr.uuid]) 1.794 1.795 - def sr_create(self, session): 1.796 + def SR_create(self, session): 1.797 return xen_api_error(XEND_ERROR_UNSUPPORTED) 1.798 1.799 - def sr_get_by_uuid(self, session): 1.800 + def SR_get_by_uuid(self, session): 1.801 return xen_api_success(XendNode.instance().get_sr().uuid) 1.802 1.803 # Class Methods 1.804 - def sr_clone(self, session, sr_ref): 1.805 - return xen_api_error(XEND_ERROR_UNSUPPORTED) 1.806 - def sr_destroy(self, session, sr_ref): 1.807 + def SR_clone(self, session, sr_ref): 1.808 return xen_api_error(XEND_ERROR_UNSUPPORTED) 1.809 1.810 - def sr_to_XML(self, session, sr_ref): 1.811 - return xen_api_todo() 1.812 + def SR_destroy(self, session, sr_ref): 1.813 + return xen_api_error(XEND_ERROR_UNSUPPORTED) 1.814 1.815 - def sr_get_record(self, session, sr_ref): 1.816 + def SR_get_record(self, session, sr_ref): 1.817 sr = XendNode.instance().get_sr() 1.818 return xen_api_success({ 1.819 'uuid': sr.uuid, 1.820 @@ -1469,44 +1461,44 @@ class XendAPI: 1.821 }) 1.822 1.823 # Attribute acceess 1.824 - def sr_get_VDIs(self, session, sr_ref): 1.825 + def SR_get_VDIs(self, session, sr_ref): 1.826 sr = XendNode.instance().get_sr() 1.827 return xen_api_success(sr.list_images()) 1.828 1.829 - def sr_get_virtual_allocation(self, session, sr_ref): 1.830 + def SR_get_virtual_allocation(self, session, sr_ref): 1.831 sr = XendNode.instance().get_sr() 1.832 return sr.used_space_bytes() 1.833 1.834 - def sr_get_physical_utilisation(self, session, sr_ref): 1.835 + def SR_get_physical_utilisation(self, session, sr_ref): 1.836 sr = XendNode.instance().get_sr() 1.837 return sr.used_space_bytes() 1.838 1.839 - def sr_get_physical_size(self, session, sr_ref): 1.840 + def SR_get_physical_size(self, session, sr_ref): 1.841 sr = XendNode.instance().get_sr() 1.842 return sr.total_space_bytes() 1.843 1.844 - def sr_get_type(self, session, sr_ref): 1.845 + def SR_get_type(self, session, sr_ref): 1.846 sr = XendNode.instance().get_sr() 1.847 return xen_api_success(sr.type) 1.848 1.849 - def sr_get_location(self, session, sr_ref): 1.850 + def SR_get_location(self, session, sr_ref): 1.851 sr = XendNode.instance().get_sr() 1.852 return xen_api_success(sr.location) 1.853 1.854 - def sr_get_name_label(self, session, sr_ref): 1.855 + def SR_get_name_label(self, session, sr_ref): 1.856 sr = XendNode.instance().get_sr() 1.857 return xen_api_success(sr.name_label) 1.858 1.859 - def sr_get_name_description(self, session, sr_ref): 1.860 + def SR_get_name_description(self, session, sr_ref): 1.861 sr = XendNode.instance().get_sr() 1.862 return xen_api_success(sr.name_description) 1.863 1.864 - def sr_set_name_label(self, session, sr_ref, value): 1.865 + def SR_set_name_label(self, session, sr_ref, value): 1.866 sr = XendNode.instance().get_sr() 1.867 sr.name_label = value 1.868 return xen_api_success_void() 1.869 1.870 - def sr_set_name_description(self, session, sr_ref, value): 1.871 + def SR_set_name_description(self, session, sr_ref, value): 1.872 sr = XendNode.instance().get_sr() 1.873 sr.name_description = value 1.874 return xen_api_success_void() 1.875 @@ -1525,24 +1517,24 @@ if __name__ == "__main__": 1.876 methods = getattr(XendAPI, '%s_methods' % cls, []) 1.877 funcs = getattr(XendAPI, '%s_funcs' % cls, []) 1.878 1.879 - ref = '%s_ref' % cls.lower() 1.880 + ref = '%s_ref' % cls 1.881 1.882 for attr_name in ro_attrs + rw_attrs + XendAPI.Base_attr_ro: 1.883 - getter_name = '%s_get_%s' % (cls.lower(), attr_name.lower()) 1.884 + getter_name = '%s_get_%s' % (cls, attr_name) 1.885 output('def %s(self, session, %s):' % (getter_name, ref)) 1.886 output(' return xen_api_todo()') 1.887 1.888 for attr_name in rw_attrs + XendAPI.Base_attr_rw: 1.889 - setter_name = '%s_set_%s' % (cls.lower(), attr_name.lower()) 1.890 + setter_name = '%s_set_%s' % (cls, attr_name) 1.891 output('def %s(self, session, %s, value):' % (setter_name, ref)) 1.892 output(' return xen_api_todo()') 1.893 1.894 for method_name in methods + XendAPI.Base_methods: 1.895 - method_full_name = '%s_%s' % (cls.lower(),method_name.lower()) 1.896 + method_full_name = '%s_%s' % (cls,method_name) 1.897 output('def %s(self, session, %s):' % (method_full_name, ref)) 1.898 output(' return xen_api_todo()') 1.899 1.900 for func_name in funcs + XendAPI.Base_funcs: 1.901 - func_full_name = '%s_%s' % (cls.lower(), func_name.lower()) 1.902 + func_full_name = '%s_%s' % (cls, func_name) 1.903 output('def %s(self, session):' % func_full_name) 1.904 output(' return xen_api_todo()')