1
# vim: tabstop=4 shiftwidth=4 softtabstop=4
3
# Copyright 2012 Cloudbase Solutions Srl
6
# Licensed under the Apache License, Version 2.0 (the "License"); you may
7
# not use this file except in compliance with the License. You may obtain
8
# a copy of the License at
10
# http://www.apache.org/licenses/LICENSE-2.0
12
# Unless required by applicable law or agreed to in writing, software
13
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15
# License for the specific language governing permissions and limitations
19
Management base class for Hyper-V operations.
23
from nova.openstack.common import log as logging
25
# Check needed for unit testing on Unix
26
if sys.platform == 'win32':
29
LOG = logging.getLogger(__name__)
32
class BaseOps(object):
36
self.__conn_cimv2 = None
37
self.__conn_wmi = None
38
self.__conn_storage = None
42
if self.__conn is None:
43
self.__conn = wmi.WMI(moniker='//./root/virtualization')
48
if self.__conn_v2 is None:
49
self.__conn_v2 = wmi.WMI(moniker='//./root/virtualization/v2')
53
def _conn_cimv2(self):
54
if self.__conn_cimv2 is None:
55
self.__conn_cimv2 = wmi.WMI(moniker='//./root/cimv2')
56
return self.__conn_cimv2
60
if self.__conn_wmi is None:
61
self.__conn_wmi = wmi.WMI(moniker='//./root/wmi')
62
return self.__conn_wmi
65
def _conn_storage(self):
66
if self.__conn_storage is None:
67
storage_namespace = '//./Root/Microsoft/Windows/Storage'
68
self.__conn_storage = wmi.WMI(moniker=storage_namespace)
69
return self.__conn_storage