Exemplo n.º 1
0
    def test_build_and_run_instance_limits_juno_compat(
            self, is_neutron, get_by_host_and_nodename):
        host_topology = objects_numa.NUMATopology(cells=[
            objects_numa.NUMACell(id=0,
                                  cpuset=set([1, 2]),
                                  memory=512,
                                  cpu_usage=2,
                                  memory_usage=256,
                                  pinned_cpus=set([1])),
            objects_numa.NUMACell(id=1,
                                  cpuset=set([3, 4]),
                                  memory=512,
                                  cpu_usage=1,
                                  memory_usage=128,
                                  pinned_cpus=set([]))
        ])
        limits = objects_numa.NUMATopologyLimits(cpu_allocation_ratio=16,
                                                 ram_allocation_ratio=2)
        cnode = objects_compute_node.ComputeNode(
            numa_topology=jsonutils.dumps(host_topology.obj_to_primitive()))

        get_by_host_and_nodename.return_value = cnode
        legacy_limits = jsonutils.dumps(limits.to_dict_legacy(host_topology))

        self.flags(compute='juno', group='upgrade_levels')
        netreqs = objects_network_request.NetworkRequestList(objects=[
            objects_network_request.NetworkRequest(
                network_id="fake_network_id",
                address="10.0.0.1",
                port_id="fake_port_id")
        ])

        self._test_compute_api('build_and_run_instance',
                               'cast',
                               instance=self.fake_instance_obj,
                               host='host',
                               image='image',
                               request_spec={'request': 'spec'},
                               filter_properties=[],
                               admin_password='******',
                               injected_files=None,
                               requested_networks=netreqs,
                               security_groups=None,
                               block_device_mapping=None,
                               node='node',
                               limits={'numa_topology': limits},
                               legacy_limits={'numa_topology': legacy_limits},
                               version='3.33')
Exemplo n.º 2
0
#    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_serialization import jsonutils
from oslo_utils.fixture import uuidsentinel as uuids

from nova import conf
from nova import objects
from nova.objects import numa
from nova.scheduler import host_manager
from nova.tests.unit.objects import test_objects

CONF = conf.CONF

fake_numa_limit1 = numa.NUMATopologyLimits(cpu_allocation_ratio=1.0,
                                           ram_allocation_ratio=1.0)
fake_limit1 = {
    "memory_mb": 1024,
    "disk_gb": 100,
    "vcpus": 2,
    "numa_topology": fake_numa_limit1
}
fake_limit_obj1 = objects.SchedulerLimits.from_dict(fake_limit1)
fake_host1 = {
    "uuid": uuids.host1,
    "host": "host1",
    "nodename": "node1",
    "cell_uuid": uuids.cell,
    "limits": fake_limit1,
}
fake_host_state1 = host_manager.HostState("host1", "node1", uuids.cell)