summaryrefslogtreecommitdiffstats
path: root/tests/unit/scheduler/fake_hosts.py
diff options
context:
space:
mode:
authorZhiteng Huang <zhiteng.huang@intel.com>2012-12-06 14:21:50 +0800
committerZhiteng Huang <zhiteng.huang@intel.com>2013-01-04 11:31:58 +0800
commit5177c7918b4d48645071234f8474b824759d71ef (patch)
tree0011c9974c33c82a27c98f29e62f690173feb127 /tests/unit/scheduler/fake_hosts.py
parent008500197a82a0ec15822bf17a35c5a283c50910 (diff)
downloadoslo-5177c7918b4d48645071234f8474b824759d71ef.tar.gz
oslo-5177c7918b4d48645071234f8474b824759d71ef.tar.xz
oslo-5177c7918b4d48645071234f8474b824759d71ef.zip
Add common filter/filter handler for filter scheduler
Filter scheduler is being used for more than one core projects (Nova and Cinder as of writing), the implementation shared a lot of common code. This patch moves base filter/filter handler class as well as common filter implementation for filter scheduler into oslo to reduce possible porting. implement bp: common-filters Change-Id: If0b1dee79c410c98e152230b55c1ec5dbcdef27c
Diffstat (limited to 'tests/unit/scheduler/fake_hosts.py')
-rw-r--r--tests/unit/scheduler/fake_hosts.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/unit/scheduler/fake_hosts.py b/tests/unit/scheduler/fake_hosts.py
new file mode 100644
index 0000000..e3e8ac0
--- /dev/null
+++ b/tests/unit/scheduler/fake_hosts.py
@@ -0,0 +1,46 @@
+# Copyright 2012 Intel Inc, OpenStack LLC.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+"""
+Fakes For filters tests.
+"""
+
+
+class FakeHostManager(object):
+ """host1: free_ram_mb=1024-512-512=0, free_disk_gb=1024-512-512=0
+ host2: free_ram_mb=2048-512=1536 free_disk_gb=2048-512=1536
+ host3: free_ram_mb=4096-1024=3072 free_disk_gb=4096-1024=3072
+ host4: free_ram_mb=8192 free_disk_gb=8192"""
+
+ def __init__(self):
+ self.service_states = {
+ 'host1': {
+ 'compute': {'host_memory_free': 1073741824},
+ },
+ 'host2': {
+ 'compute': {'host_memory_free': 2147483648},
+ },
+ 'host3': {
+ 'compute': {'host_memory_free': 3221225472},
+ },
+ 'host4': {
+ 'compute': {'host_memory_free': 999999999},
+ },
+ }
+
+
+class FakeHostState(object):
+ def __init__(self, host, attribute_dict):
+ for (key, val) in attribute_dict.iteritems():
+ setattr(self, key, val)