Merge "Add importing modules instead of classes"

This commit is contained in:
Jenkins
2016-06-23 15:39:08 +00:00
committed by Gerrit Code Review
24 changed files with 131 additions and 126 deletions

View File

@@ -17,10 +17,10 @@
# limitations under the License.
#
from enum import Enum
import enum
class Events(Enum):
class Events(enum.Enum):
ALL = '*',
ACTION_PLAN = "action_plan"
TRIGGER_AUDIT = "trigger_audit"

View File

@@ -14,17 +14,17 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from watcher.decision_engine.model.compute_resource import ComputeResource
from watcher.decision_engine.model.hypervisor_state import HypervisorState
from watcher.decision_engine.model.power_state import PowerState
from watcher.decision_engine.model import compute_resource
from watcher.decision_engine.model import hypervisor_state
from watcher.decision_engine.model import power_state
class Hypervisor(ComputeResource):
class Hypervisor(compute_resource.ComputeResource):
def __init__(self):
super(Hypervisor, self).__init__()
self._state = HypervisorState.ONLINE
self._status = HypervisorState.ENABLED
self._power_state = PowerState.g0
self._state = hypervisor_state.HypervisorState.ONLINE
self._status = hypervisor_state.HypervisorState.ENABLED
self._power_state = power_state.PowerState.g0
@property
def state(self):

View File

@@ -14,10 +14,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from enum import Enum
import enum
class HypervisorState(Enum):
class HypervisorState(enum.Enum):
ONLINE = 'up'
OFFLINE = 'down'
ENABLED = 'enabled'

View File

@@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from oslo_log import log
from threading import Lock
import threading
LOG = log.getLogger(__name__)
@@ -24,7 +24,7 @@ class Mapping(object):
self.model = model
self._mapping_hypervisors = {}
self.mapping_vm = {}
self.lock = Lock()
self.lock = threading.Lock()
def map(self, hypervisor, vm):
"""Select the hypervisor where the instance are launched

View File

@@ -10,10 +10,10 @@
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from enum import Enum
import enum
class PowerState(Enum):
class PowerState(enum.Enum):
# away mode
g0 = "g0"
# power on suspend (processor caches are flushed)

View File

@@ -14,10 +14,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from enum import Enum
import enum
class ResourceType(Enum):
class ResourceType(enum.Enum):
cpu_cores = 'num_cores'
memory = 'memory'
disk = 'disk'

View File

@@ -13,14 +13,14 @@
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from watcher.decision_engine.model.compute_resource import ComputeResource
from watcher.decision_engine.model.vm_state import VMState
from watcher.decision_engine.model import compute_resource
from watcher.decision_engine.model import vm_state
class VM(ComputeResource):
class VM(compute_resource.ComputeResource):
def __init__(self):
super(VM, self).__init__()
self._state = VMState.ACTIVE.value
self._state = vm_state.VMState.ACTIVE.value
@property
def state(self):

View File

@@ -14,10 +14,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from enum import Enum
import enum
class VMState(Enum):
class VMState(enum.Enum):
ACTIVE = 'active' # VM is running
BUILDING = 'building' # VM only exists in DB
PAUSED = 'paused'