Extract Disk and Space object into separate file
This commit is contained in:
parent
c26c417d7a
commit
c67aa04291
@ -18,13 +18,14 @@ import itertools
|
||||
import math
|
||||
|
||||
import numpy as np
|
||||
import six
|
||||
|
||||
from oslo_log import log
|
||||
from scipy.optimize import linprog
|
||||
from termcolor import colored
|
||||
|
||||
from bareon_dynamic_allocator import errors
|
||||
from bareon_dynamic_allocator.objects import Disk
|
||||
from bareon_dynamic_allocator.objects import Space
|
||||
from bareon_dynamic_allocator.parser import Parser
|
||||
from bareon_dynamic_allocator.sequences import CrossSumInequalitySequence
|
||||
|
||||
@ -79,35 +80,6 @@ def format_equation(matrix, vector, row_len):
|
||||
return '\n'.join(equation)
|
||||
|
||||
|
||||
class Disk(object):
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
for k, v in six.iteritems(kwargs):
|
||||
setattr(self, k, v)
|
||||
|
||||
|
||||
class Space(object):
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
for k, v in six.iteritems(kwargs):
|
||||
setattr(self, k, v)
|
||||
|
||||
# If no min_size specified set it to 0
|
||||
if not kwargs.get('min_size'):
|
||||
self.min_size = 0
|
||||
|
||||
# Exact size can be repreneted as min_size and max_size
|
||||
if kwargs.get('size'):
|
||||
self.min_size = kwargs.get('size')
|
||||
self.max_size = kwargs.get('size')
|
||||
|
||||
if not kwargs.get('best_with_disks'):
|
||||
self.best_with_disks = set([])
|
||||
|
||||
def __repr__(self):
|
||||
return str(self.__dict__)
|
||||
|
||||
|
||||
class DynamicAllocator(object):
|
||||
|
||||
def __init__(self, hw_info, schema):
|
||||
|
20
bareon_dynamic_allocator/objects/__init__.py
Normal file
20
bareon_dynamic_allocator/objects/__init__.py
Normal file
@ -0,0 +1,20 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2016 Mirantis, Inc.
|
||||
#
|
||||
# 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.
|
||||
|
||||
# flake8: noqa
|
||||
|
||||
from bareon_dynamic_allocator.objects.disk import Disk
|
||||
from bareon_dynamic_allocator.objects.space import Space
|
24
bareon_dynamic_allocator/objects/disk.py
Normal file
24
bareon_dynamic_allocator/objects/disk.py
Normal file
@ -0,0 +1,24 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2016 Mirantis, Inc.
|
||||
#
|
||||
# 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 six
|
||||
|
||||
|
||||
class Disk(object):
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
for k, v in six.iteritems(kwargs):
|
||||
setattr(self, k, v)
|
39
bareon_dynamic_allocator/objects/space.py
Normal file
39
bareon_dynamic_allocator/objects/space.py
Normal file
@ -0,0 +1,39 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2016 Mirantis, Inc.
|
||||
#
|
||||
# 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 six
|
||||
|
||||
|
||||
class Space(object):
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
for k, v in six.iteritems(kwargs):
|
||||
setattr(self, k, v)
|
||||
|
||||
# If no min_size specified set it to 0
|
||||
if not kwargs.get('min_size'):
|
||||
self.min_size = 0
|
||||
|
||||
# Exact size can be repreneted as min_size and max_size
|
||||
if kwargs.get('size'):
|
||||
self.min_size = kwargs.get('size')
|
||||
self.max_size = kwargs.get('size')
|
||||
|
||||
if not kwargs.get('best_with_disks'):
|
||||
self.best_with_disks = set([])
|
||||
|
||||
def __repr__(self):
|
||||
return str(self.__dict__)
|
Loading…
x
Reference in New Issue
Block a user