diff --git a/climate/nova/__init__.py b/climate/nova/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/climate/nova/climate_filter.py b/climate/nova/climate_filter.py new file mode 100644 index 00000000..d6048e9c --- /dev/null +++ b/climate/nova/climate_filter.py @@ -0,0 +1,27 @@ +# Copyright 2013 Julien Danjou +# +# 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 diff --git a/tests_nova_scheduler/__init__.py b/tests_nova_scheduler/__init__.py new file mode 100644 index 00000000..82ebc50d --- /dev/null +++ b/tests_nova_scheduler/__init__.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python +# -*- encoding: utf-8 -*- +# +# Copyright © 2013 Julien Danjou +# +# 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) diff --git a/tests_nova_scheduler/test_climate_scheduler.py b/tests_nova_scheduler/test_climate_scheduler.py new file mode 100644 index 00000000..14bd0a9a --- /dev/null +++ b/tests_nova_scheduler/test_climate_scheduler.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python +# -*- encoding: utf-8 -*- +# +# Copyright © 2013 Julien Danjou +# +# 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)) diff --git a/tools/test-requires b/tools/test-requires index a6d31a8c..67a31259 100644 --- a/tools/test-requires +++ b/tools/test-requires @@ -1,3 +1,4 @@ nose mock mox +http://tarballs.openstack.org/nova/nova-master.tar.gz \ No newline at end of file diff --git a/tox.ini b/tox.ini index cf31b4d6..76199afa 100644 --- a/tox.ini +++ b/tox.ini @@ -10,7 +10,8 @@ setenv = VIRTUAL_ENV={envdir} NOSE_OPENSTACK_RED=0.05 NOSE_OPENSTACK_YELLOW=0.025 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 [testenv:cover]