Add a basic filter for Nova
Change-Id: I2c54418e15c4783f6f062209a7038282bcb66cd8 Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
f7504de458
commit
ceae8641a1
0
climate/nova/__init__.py
Normal file
0
climate/nova/__init__.py
Normal file
27
climate/nova/climate_filter.py
Normal file
27
climate/nova/climate_filter.py
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
# Copyright 2013 Julien Danjou <julien@danjou.info>
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
|
||||||
|
from nova.scheduler import filters
|
||||||
|
|
||||||
|
|
||||||
|
class ClimateFilter(filters.BaseHostFilter):
|
||||||
|
"""Climate Filter for nova-scheduler."""
|
||||||
|
|
||||||
|
def host_passes(self, host_state, filter_properties):
|
||||||
|
"""Filter based on Climate."""
|
||||||
|
scheduler_hints = filter_properties.get('scheduler_hints') or {}
|
||||||
|
# XXX send host_state + to Climate API
|
||||||
|
return True
|
20
tests_nova_scheduler/__init__.py
Normal file
20
tests_nova_scheduler/__init__.py
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- encoding: utf-8 -*-
|
||||||
|
#
|
||||||
|
# Copyright © 2013 Julien Danjou <julien@danjou.info>
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
|
||||||
|
import gettext
|
||||||
|
|
||||||
|
gettext.install('nova', unicode=True)
|
29
tests_nova_scheduler/test_climate_scheduler.py
Normal file
29
tests_nova_scheduler/test_climate_scheduler.py
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- encoding: utf-8 -*-
|
||||||
|
#
|
||||||
|
# Copyright © 2013 Julien Danjou <julien@danjou.info>
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
from nova.tests.scheduler import fakes
|
||||||
|
from climate.nova import climate_filter
|
||||||
|
|
||||||
|
|
||||||
|
class ClimateSchedulerTestCase(unittest.TestCase):
|
||||||
|
def test_climate_scheduler(self):
|
||||||
|
f = climate_filter.ClimateFilter()
|
||||||
|
host = fakes.FakeHostState('host1', 'node1', {})
|
||||||
|
filter_properties = {"scheduler_hints": {"foo": "bar"}}
|
||||||
|
self.assertTrue(f.host_passes(host, filter_properties))
|
@ -1,3 +1,4 @@
|
|||||||
nose
|
nose
|
||||||
mock
|
mock
|
||||||
mox
|
mox
|
||||||
|
http://tarballs.openstack.org/nova/nova-master.tar.gz
|
3
tox.ini
3
tox.ini
@ -10,7 +10,8 @@ setenv = VIRTUAL_ENV={envdir}
|
|||||||
NOSE_OPENSTACK_RED=0.05
|
NOSE_OPENSTACK_RED=0.05
|
||||||
NOSE_OPENSTACK_YELLOW=0.025
|
NOSE_OPENSTACK_YELLOW=0.025
|
||||||
NOSE_OPENSTACK_SHOW_ELAPSED=1
|
NOSE_OPENSTACK_SHOW_ELAPSED=1
|
||||||
commands = nosetests --no-path-adjustment
|
commands = nosetests --no-path-adjustment --where=tests_nova_scheduler
|
||||||
|
nosetests --no-path-adjustment --where=tests {posargs}
|
||||||
sitepackages = False
|
sitepackages = False
|
||||||
|
|
||||||
[testenv:cover]
|
[testenv:cover]
|
||||||
|
Loading…
Reference in New Issue
Block a user