Exemplo n.º 1
0
#    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 oslo_log.log import logging

from zun.api import servicegroup
from zun.scheduler import filters

LOG = logging.getLogger(__name__)


class ComputeFilter(filters.BaseHostFilter):
    """Filter on active Compute nodes"""

    def __init__(self):
        self.servicegroup_api = servicegroup.ServiceGroup()
        super(ComputeFilter, self).__init__()

    # Host state does not change within a request
    run_filter_once_per_request = True

    def host_passes(self, host_state, container, extra_spec):
        """Returns True for only active compute nodes"""
        service = host_state.service
Exemplo n.º 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 functools

from oslo_log.log import logging
from oslo_utils import timeutils

from zun.common import utils
from zun.pci import stats as pci_stats

LOG = logging.getLogger(__name__)


class HostState(object):
    """Mutable and immutable information tracked for a host.

    This is an attempt to remove the ad-hoc data structures.
    """
    def __init__(self, host):
        self.hostname = host
        self._lock_name = host
        self.uuid = None

        # Mutable available resources.
        # These will change as resources are virtually "consumed".
        self.mem_available = 0