begin_unit
comment|'#    Licensed under the Apache License, Version 2.0 (the "License"); you may'
nl|'\n'
comment|'#    not use this file except in compliance with the License. You may obtain'
nl|'\n'
comment|'#    a copy of the License at'
nl|'\n'
comment|'#'
nl|'\n'
comment|'#         http://www.apache.org/licenses/LICENSE-2.0'
nl|'\n'
comment|'#'
nl|'\n'
comment|'#    Unless required by applicable law or agreed to in writing, software'
nl|'\n'
comment|'#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT'
nl|'\n'
comment|'#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the'
nl|'\n'
comment|'#    License for the specific language governing permissions and limitations'
nl|'\n'
comment|'#    under the License.'
nl|'\n'
nl|'\n'
name|'import'
name|'copy'
newline|'\n'
nl|'\n'
name|'import'
name|'mock'
newline|'\n'
name|'from'
name|'oslo_utils'
name|'import'
name|'units'
newline|'\n'
nl|'\n'
name|'from'
name|'nova'
op|'.'
name|'compute'
name|'import'
name|'arch'
newline|'\n'
name|'from'
name|'nova'
op|'.'
name|'compute'
name|'import'
name|'claims'
newline|'\n'
name|'from'
name|'nova'
op|'.'
name|'compute'
name|'import'
name|'hv_type'
newline|'\n'
name|'from'
name|'nova'
op|'.'
name|'compute'
name|'import'
name|'power_state'
newline|'\n'
name|'from'
name|'nova'
op|'.'
name|'compute'
name|'import'
name|'resource_tracker'
newline|'\n'
name|'from'
name|'nova'
op|'.'
name|'compute'
name|'import'
name|'task_states'
newline|'\n'
name|'from'
name|'nova'
op|'.'
name|'compute'
name|'import'
name|'vm_mode'
newline|'\n'
name|'from'
name|'nova'
op|'.'
name|'compute'
name|'import'
name|'vm_states'
newline|'\n'
name|'from'
name|'nova'
name|'import'
name|'exception'
name|'as'
name|'exc'
newline|'\n'
name|'from'
name|'nova'
name|'import'
name|'objects'
newline|'\n'
name|'from'
name|'nova'
op|'.'
name|'objects'
name|'import'
name|'base'
name|'as'
name|'obj_base'
newline|'\n'
name|'from'
name|'nova'
op|'.'
name|'pci'
name|'import'
name|'manager'
name|'as'
name|'pci_manager'
newline|'\n'
name|'from'
name|'nova'
name|'import'
name|'test'
newline|'\n'
nl|'\n'
DECL|variable|_VIRT_DRIVER_AVAIL_RESOURCES
name|'_VIRT_DRIVER_AVAIL_RESOURCES'
op|'='
op|'{'
nl|'\n'
string|"'vcpus'"
op|':'
number|'4'
op|','
nl|'\n'
string|"'memory_mb'"
op|':'
number|'512'
op|','
nl|'\n'
string|"'local_gb'"
op|':'
number|'6'
op|','
nl|'\n'
string|"'vcpus_used'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'memory_mb_used'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'local_gb_used'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'hypervisor_type'"
op|':'
string|"'fake'"
op|','
nl|'\n'
string|"'hypervisor_version'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'hypervisor_hostname'"
op|':'
string|"'fakehost'"
op|','
nl|'\n'
string|"'cpu_info'"
op|':'
string|"''"
op|','
nl|'\n'
string|"'numa_topology'"
op|':'
name|'None'
op|','
nl|'\n'
op|'}'
newline|'\n'
nl|'\n'
DECL|variable|_COMPUTE_NODE_FIXTURES
name|'_COMPUTE_NODE_FIXTURES'
op|'='
op|'['
nl|'\n'
name|'objects'
op|'.'
name|'ComputeNode'
op|'('
nl|'\n'
DECL|variable|id
name|'id'
op|'='
number|'1'
op|','
nl|'\n'
DECL|variable|host
name|'host'
op|'='
string|"'fake-host'"
op|','
nl|'\n'
DECL|variable|vcpus
name|'vcpus'
op|'='
name|'_VIRT_DRIVER_AVAIL_RESOURCES'
op|'['
string|"'vcpus'"
op|']'
op|','
nl|'\n'
DECL|variable|memory_mb
name|'memory_mb'
op|'='
name|'_VIRT_DRIVER_AVAIL_RESOURCES'
op|'['
string|"'memory_mb'"
op|']'
op|','
nl|'\n'
DECL|variable|local_gb
name|'local_gb'
op|'='
name|'_VIRT_DRIVER_AVAIL_RESOURCES'
op|'['
string|"'local_gb'"
op|']'
op|','
nl|'\n'
DECL|variable|vcpus_used
name|'vcpus_used'
op|'='
name|'_VIRT_DRIVER_AVAIL_RESOURCES'
op|'['
string|"'vcpus_used'"
op|']'
op|','
nl|'\n'
DECL|variable|memory_mb_used
name|'memory_mb_used'
op|'='
name|'_VIRT_DRIVER_AVAIL_RESOURCES'
op|'['
string|"'memory_mb_used'"
op|']'
op|','
nl|'\n'
DECL|variable|local_gb_used
name|'local_gb_used'
op|'='
name|'_VIRT_DRIVER_AVAIL_RESOURCES'
op|'['
string|"'local_gb_used'"
op|']'
op|','
nl|'\n'
DECL|variable|hypervisor_type
name|'hypervisor_type'
op|'='
string|"'fake'"
op|','
nl|'\n'
DECL|variable|hypervisor_version
name|'hypervisor_version'
op|'='
number|'0'
op|','
nl|'\n'
DECL|variable|hypervisor_hostname
name|'hypervisor_hostname'
op|'='
string|"'fake-host'"
op|','
nl|'\n'
DECL|variable|free_ram_mb
name|'free_ram_mb'
op|'='
op|'('
name|'_VIRT_DRIVER_AVAIL_RESOURCES'
op|'['
string|"'memory_mb'"
op|']'
op|'-'
nl|'\n'
name|'_VIRT_DRIVER_AVAIL_RESOURCES'
op|'['
string|"'memory_mb_used'"
op|']'
op|')'
op|','
nl|'\n'
DECL|variable|free_disk_gb
name|'free_disk_gb'
op|'='
op|'('
name|'_VIRT_DRIVER_AVAIL_RESOURCES'
op|'['
string|"'local_gb'"
op|']'
op|'-'
nl|'\n'
name|'_VIRT_DRIVER_AVAIL_RESOURCES'
op|'['
string|"'local_gb_used'"
op|']'
op|')'
op|','
nl|'\n'
DECL|variable|current_workload
name|'current_workload'
op|'='
number|'0'
op|','
nl|'\n'
DECL|variable|running_vms
name|'running_vms'
op|'='
number|'0'
op|','
nl|'\n'
DECL|variable|cpu_info
name|'cpu_info'
op|'='
string|"'{}'"
op|','
nl|'\n'
DECL|variable|disk_available_least
name|'disk_available_least'
op|'='
number|'0'
op|','
nl|'\n'
DECL|variable|host_ip
name|'host_ip'
op|'='
string|"'1.1.1.1'"
op|','
nl|'\n'
DECL|variable|supported_hv_specs
name|'supported_hv_specs'
op|'='
op|'['
nl|'\n'
name|'objects'
op|'.'
name|'HVSpec'
op|'.'
name|'from_list'
op|'('
op|'['
name|'arch'
op|'.'
name|'I686'
op|','
name|'hv_type'
op|'.'
name|'KVM'
op|','
name|'vm_mode'
op|'.'
name|'HVM'
op|']'
op|')'
nl|'\n'
op|']'
op|','
nl|'\n'
DECL|variable|metrics
name|'metrics'
op|'='
name|'None'
op|','
nl|'\n'
DECL|variable|pci_device_pools
name|'pci_device_pools'
op|'='
name|'None'
op|','
nl|'\n'
DECL|variable|extra_resources
name|'extra_resources'
op|'='
name|'None'
op|','
nl|'\n'
DECL|variable|stats
name|'stats'
op|'='
op|'{'
op|'}'
op|','
nl|'\n'
DECL|variable|numa_topology
name|'numa_topology'
op|'='
name|'None'
op|','
nl|'\n'
DECL|variable|cpu_allocation_ratio
name|'cpu_allocation_ratio'
op|'='
number|'16.0'
op|','
nl|'\n'
DECL|variable|ram_allocation_ratio
name|'ram_allocation_ratio'
op|'='
number|'1.5'
op|','
nl|'\n'
DECL|variable|disk_allocation_ratio
name|'disk_allocation_ratio'
op|'='
number|'1.0'
op|','
nl|'\n'
op|')'
op|','
nl|'\n'
op|']'
newline|'\n'
nl|'\n'
DECL|variable|_INSTANCE_TYPE_FIXTURES
name|'_INSTANCE_TYPE_FIXTURES'
op|'='
op|'{'
nl|'\n'
number|'1'
op|':'
op|'{'
nl|'\n'
string|"'id'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'flavorid'"
op|':'
string|"'fakeid-1'"
op|','
nl|'\n'
string|"'name'"
op|':'
string|"'fake1.small'"
op|','
nl|'\n'
string|"'memory_mb'"
op|':'
number|'128'
op|','
nl|'\n'
string|"'vcpus'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'root_gb'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'ephemeral_gb'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'swap'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'rxtx_factor'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'vcpu_weight'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'extra_specs'"
op|':'
op|'{'
op|'}'
op|','
nl|'\n'
op|'}'
op|','
nl|'\n'
number|'2'
op|':'
op|'{'
nl|'\n'
string|"'id'"
op|':'
number|'2'
op|','
nl|'\n'
string|"'flavorid'"
op|':'
string|"'fakeid-2'"
op|','
nl|'\n'
string|"'name'"
op|':'
string|"'fake1.medium'"
op|','
nl|'\n'
string|"'memory_mb'"
op|':'
number|'256'
op|','
nl|'\n'
string|"'vcpus'"
op|':'
number|'2'
op|','
nl|'\n'
string|"'root_gb'"
op|':'
number|'5'
op|','
nl|'\n'
string|"'ephemeral_gb'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'swap'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'rxtx_factor'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'vcpu_weight'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'extra_specs'"
op|':'
op|'{'
op|'}'
op|','
nl|'\n'
op|'}'
op|','
nl|'\n'
op|'}'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|variable|_INSTANCE_TYPE_OBJ_FIXTURES
name|'_INSTANCE_TYPE_OBJ_FIXTURES'
op|'='
op|'{'
nl|'\n'
number|'1'
op|':'
name|'objects'
op|'.'
name|'Flavor'
op|'('
name|'id'
op|'='
number|'1'
op|','
name|'flavorid'
op|'='
string|"'fakeid-1'"
op|','
name|'name'
op|'='
string|"'fake1.small'"
op|','
nl|'\n'
name|'memory_mb'
op|'='
number|'128'
op|','
name|'vcpus'
op|'='
number|'1'
op|','
name|'root_gb'
op|'='
number|'1'
op|','
nl|'\n'
name|'ephemeral_gb'
op|'='
number|'0'
op|','
name|'swap'
op|'='
number|'0'
op|','
name|'rxtx_factor'
op|'='
number|'0'
op|','
nl|'\n'
name|'vcpu_weight'
op|'='
number|'1'
op|','
name|'extra_specs'
op|'='
op|'{'
op|'}'
op|')'
op|','
nl|'\n'
number|'2'
op|':'
name|'objects'
op|'.'
name|'Flavor'
op|'('
name|'id'
op|'='
number|'2'
op|','
name|'flavorid'
op|'='
string|"'fakeid-2'"
op|','
name|'name'
op|'='
string|"'fake1.medium'"
op|','
nl|'\n'
name|'memory_mb'
op|'='
number|'256'
op|','
name|'vcpus'
op|'='
number|'2'
op|','
name|'root_gb'
op|'='
number|'5'
op|','
nl|'\n'
name|'ephemeral_gb'
op|'='
number|'0'
op|','
name|'swap'
op|'='
number|'0'
op|','
name|'rxtx_factor'
op|'='
number|'0'
op|','
nl|'\n'
name|'vcpu_weight'
op|'='
number|'1'
op|','
name|'extra_specs'
op|'='
op|'{'
op|'}'
op|')'
op|','
nl|'\n'
op|'}'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|variable|_2MB
name|'_2MB'
op|'='
number|'2'
op|'*'
name|'units'
op|'.'
name|'Mi'
op|'/'
name|'units'
op|'.'
name|'Ki'
newline|'\n'
nl|'\n'
DECL|variable|_INSTANCE_NUMA_TOPOLOGIES
name|'_INSTANCE_NUMA_TOPOLOGIES'
op|'='
op|'{'
nl|'\n'
string|"'2mb'"
op|':'
name|'objects'
op|'.'
name|'InstanceNUMATopology'
op|'('
name|'cells'
op|'='
op|'['
nl|'\n'
name|'objects'
op|'.'
name|'InstanceNUMACell'
op|'('
nl|'\n'
name|'id'
op|'='
number|'0'
op|','
name|'cpuset'
op|'='
name|'set'
op|'('
op|'['
number|'1'
op|']'
op|')'
op|','
name|'memory'
op|'='
name|'_2MB'
op|','
name|'pagesize'
op|'='
number|'0'
op|')'
op|','
nl|'\n'
name|'objects'
op|'.'
name|'InstanceNUMACell'
op|'('
nl|'\n'
name|'id'
op|'='
number|'1'
op|','
name|'cpuset'
op|'='
name|'set'
op|'('
op|'['
number|'3'
op|']'
op|')'
op|','
name|'memory'
op|'='
name|'_2MB'
op|','
name|'pagesize'
op|'='
number|'0'
op|')'
op|']'
op|')'
op|','
nl|'\n'
op|'}'
newline|'\n'
nl|'\n'
DECL|variable|_NUMA_LIMIT_TOPOLOGIES
name|'_NUMA_LIMIT_TOPOLOGIES'
op|'='
op|'{'
nl|'\n'
string|"'2mb'"
op|':'
name|'objects'
op|'.'
name|'NUMATopologyLimits'
op|'('
name|'id'
op|'='
number|'0'
op|','
nl|'\n'
DECL|variable|cpu_allocation_ratio
name|'cpu_allocation_ratio'
op|'='
number|'1.0'
op|','
nl|'\n'
DECL|variable|ram_allocation_ratio
name|'ram_allocation_ratio'
op|'='
number|'1.0'
op|')'
op|','
nl|'\n'
op|'}'
newline|'\n'
nl|'\n'
DECL|variable|_NUMA_PAGE_TOPOLOGIES
name|'_NUMA_PAGE_TOPOLOGIES'
op|'='
op|'{'
nl|'\n'
string|"'2kb*8'"
op|':'
name|'objects'
op|'.'
name|'NUMAPagesTopology'
op|'('
name|'size_kb'
op|'='
number|'2'
op|','
name|'total'
op|'='
number|'8'
op|','
name|'used'
op|'='
number|'0'
op|')'
nl|'\n'
op|'}'
newline|'\n'
nl|'\n'
DECL|variable|_NUMA_HOST_TOPOLOGIES
name|'_NUMA_HOST_TOPOLOGIES'
op|'='
op|'{'
nl|'\n'
string|"'2mb'"
op|':'
name|'objects'
op|'.'
name|'NUMATopology'
op|'('
name|'cells'
op|'='
op|'['
nl|'\n'
name|'objects'
op|'.'
name|'NUMACell'
op|'('
name|'id'
op|'='
number|'0'
op|','
name|'cpuset'
op|'='
name|'set'
op|'('
op|'['
number|'1'
op|','
number|'2'
op|']'
op|')'
op|','
name|'memory'
op|'='
name|'_2MB'
op|','
nl|'\n'
name|'cpu_usage'
op|'='
number|'0'
op|','
name|'memory_usage'
op|'='
number|'0'
op|','
nl|'\n'
DECL|variable|mempages
name|'mempages'
op|'='
op|'['
name|'_NUMA_PAGE_TOPOLOGIES'
op|'['
string|"'2kb*8'"
op|']'
op|']'
op|','
nl|'\n'
name|'siblings'
op|'='
op|'['
op|']'
op|','
name|'pinned_cpus'
op|'='
name|'set'
op|'('
op|'['
op|']'
op|')'
op|')'
op|','
nl|'\n'
name|'objects'
op|'.'
name|'NUMACell'
op|'('
name|'id'
op|'='
number|'1'
op|','
name|'cpuset'
op|'='
name|'set'
op|'('
op|'['
number|'3'
op|','
number|'4'
op|']'
op|')'
op|','
name|'memory'
op|'='
name|'_2MB'
op|','
nl|'\n'
name|'cpu_usage'
op|'='
number|'0'
op|','
name|'memory_usage'
op|'='
number|'0'
op|','
nl|'\n'
DECL|variable|mempages
name|'mempages'
op|'='
op|'['
name|'_NUMA_PAGE_TOPOLOGIES'
op|'['
string|"'2kb*8'"
op|']'
op|']'
op|','
nl|'\n'
name|'siblings'
op|'='
op|'['
op|']'
op|','
name|'pinned_cpus'
op|'='
name|'set'
op|'('
op|'['
op|']'
op|')'
op|')'
op|']'
op|')'
op|','
nl|'\n'
op|'}'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|variable|_INSTANCE_FIXTURES
name|'_INSTANCE_FIXTURES'
op|'='
op|'['
nl|'\n'
name|'objects'
op|'.'
name|'Instance'
op|'('
nl|'\n'
DECL|variable|id
name|'id'
op|'='
number|'1'
op|','
nl|'\n'
DECL|variable|host
name|'host'
op|'='
name|'None'
op|','
comment|'# prevent RT trying to lazy-load this'
nl|'\n'
DECL|variable|node
name|'node'
op|'='
name|'None'
op|','
nl|'\n'
DECL|variable|uuid
name|'uuid'
op|'='
string|"'c17741a5-6f3d-44a8-ade8-773dc8c29124'"
op|','
nl|'\n'
DECL|variable|memory_mb
name|'memory_mb'
op|'='
name|'_INSTANCE_TYPE_FIXTURES'
op|'['
number|'1'
op|']'
op|'['
string|"'memory_mb'"
op|']'
op|','
nl|'\n'
DECL|variable|vcpus
name|'vcpus'
op|'='
name|'_INSTANCE_TYPE_FIXTURES'
op|'['
number|'1'
op|']'
op|'['
string|"'vcpus'"
op|']'
op|','
nl|'\n'
DECL|variable|root_gb
name|'root_gb'
op|'='
name|'_INSTANCE_TYPE_FIXTURES'
op|'['
number|'1'
op|']'
op|'['
string|"'root_gb'"
op|']'
op|','
nl|'\n'
DECL|variable|ephemeral_gb
name|'ephemeral_gb'
op|'='
name|'_INSTANCE_TYPE_FIXTURES'
op|'['
number|'1'
op|']'
op|'['
string|"'ephemeral_gb'"
op|']'
op|','
nl|'\n'
DECL|variable|numa_topology
name|'numa_topology'
op|'='
name|'_INSTANCE_NUMA_TOPOLOGIES'
op|'['
string|"'2mb'"
op|']'
op|','
nl|'\n'
DECL|variable|instance_type_id
name|'instance_type_id'
op|'='
number|'1'
op|','
nl|'\n'
DECL|variable|vm_state
name|'vm_state'
op|'='
name|'vm_states'
op|'.'
name|'ACTIVE'
op|','
nl|'\n'
DECL|variable|power_state
name|'power_state'
op|'='
name|'power_state'
op|'.'
name|'RUNNING'
op|','
nl|'\n'
DECL|variable|task_state
name|'task_state'
op|'='
name|'None'
op|','
nl|'\n'
DECL|variable|os_type
name|'os_type'
op|'='
string|"'fake-os'"
op|','
comment|'# Used by the stats collector.'
nl|'\n'
DECL|variable|project_id
name|'project_id'
op|'='
string|"'fake-project'"
op|','
comment|'# Used by the stats collector.'
nl|'\n'
DECL|variable|flavor
name|'flavor'
op|'='
name|'_INSTANCE_TYPE_OBJ_FIXTURES'
op|'['
number|'1'
op|']'
op|','
nl|'\n'
DECL|variable|old_flavor
name|'old_flavor'
op|'='
name|'_INSTANCE_TYPE_OBJ_FIXTURES'
op|'['
number|'1'
op|']'
op|','
nl|'\n'
DECL|variable|new_flavor
name|'new_flavor'
op|'='
name|'_INSTANCE_TYPE_OBJ_FIXTURES'
op|'['
number|'1'
op|']'
op|','
nl|'\n'
op|')'
op|','
nl|'\n'
name|'objects'
op|'.'
name|'Instance'
op|'('
nl|'\n'
DECL|variable|id
name|'id'
op|'='
number|'2'
op|','
nl|'\n'
DECL|variable|host
name|'host'
op|'='
name|'None'
op|','
nl|'\n'
DECL|variable|node
name|'node'
op|'='
name|'None'
op|','
nl|'\n'
DECL|variable|uuid
name|'uuid'
op|'='
string|"'33805b54-dea6-47b8-acb2-22aeb1b57919'"
op|','
nl|'\n'
DECL|variable|memory_mb
name|'memory_mb'
op|'='
name|'_INSTANCE_TYPE_FIXTURES'
op|'['
number|'2'
op|']'
op|'['
string|"'memory_mb'"
op|']'
op|','
nl|'\n'
DECL|variable|vcpus
name|'vcpus'
op|'='
name|'_INSTANCE_TYPE_FIXTURES'
op|'['
number|'2'
op|']'
op|'['
string|"'vcpus'"
op|']'
op|','
nl|'\n'
DECL|variable|root_gb
name|'root_gb'
op|'='
name|'_INSTANCE_TYPE_FIXTURES'
op|'['
number|'2'
op|']'
op|'['
string|"'root_gb'"
op|']'
op|','
nl|'\n'
DECL|variable|ephemeral_gb
name|'ephemeral_gb'
op|'='
name|'_INSTANCE_TYPE_FIXTURES'
op|'['
number|'2'
op|']'
op|'['
string|"'ephemeral_gb'"
op|']'
op|','
nl|'\n'
DECL|variable|numa_topology
name|'numa_topology'
op|'='
name|'None'
op|','
nl|'\n'
DECL|variable|instance_type_id
name|'instance_type_id'
op|'='
number|'2'
op|','
nl|'\n'
DECL|variable|vm_state
name|'vm_state'
op|'='
name|'vm_states'
op|'.'
name|'DELETED'
op|','
nl|'\n'
DECL|variable|power_state
name|'power_state'
op|'='
name|'power_state'
op|'.'
name|'SHUTDOWN'
op|','
nl|'\n'
DECL|variable|task_state
name|'task_state'
op|'='
name|'None'
op|','
nl|'\n'
DECL|variable|os_type
name|'os_type'
op|'='
string|"'fake-os'"
op|','
nl|'\n'
DECL|variable|project_id
name|'project_id'
op|'='
string|"'fake-project-2'"
op|','
nl|'\n'
DECL|variable|flavor
name|'flavor'
op|'='
name|'_INSTANCE_TYPE_OBJ_FIXTURES'
op|'['
number|'2'
op|']'
op|','
nl|'\n'
DECL|variable|old_flavor
name|'old_flavor'
op|'='
name|'_INSTANCE_TYPE_OBJ_FIXTURES'
op|'['
number|'2'
op|']'
op|','
nl|'\n'
DECL|variable|new_flavor
name|'new_flavor'
op|'='
name|'_INSTANCE_TYPE_OBJ_FIXTURES'
op|'['
number|'2'
op|']'
op|','
nl|'\n'
op|')'
op|','
nl|'\n'
op|']'
newline|'\n'
nl|'\n'
DECL|variable|_MIGRATION_FIXTURES
name|'_MIGRATION_FIXTURES'
op|'='
op|'{'
nl|'\n'
comment|'# A migration that has only this compute node as the source host'
nl|'\n'
string|"'source-only'"
op|':'
name|'objects'
op|'.'
name|'Migration'
op|'('
nl|'\n'
DECL|variable|id
name|'id'
op|'='
number|'1'
op|','
nl|'\n'
DECL|variable|instance_uuid
name|'instance_uuid'
op|'='
string|"'f15ecfb0-9bf6-42db-9837-706eb2c4bf08'"
op|','
nl|'\n'
DECL|variable|source_compute
name|'source_compute'
op|'='
string|"'fake-host'"
op|','
nl|'\n'
DECL|variable|dest_compute
name|'dest_compute'
op|'='
string|"'other-host'"
op|','
nl|'\n'
DECL|variable|source_node
name|'source_node'
op|'='
string|"'fake-node'"
op|','
nl|'\n'
DECL|variable|dest_node
name|'dest_node'
op|'='
string|"'other-node'"
op|','
nl|'\n'
DECL|variable|old_instance_type_id
name|'old_instance_type_id'
op|'='
number|'1'
op|','
nl|'\n'
DECL|variable|new_instance_type_id
name|'new_instance_type_id'
op|'='
number|'2'
op|','
nl|'\n'
DECL|variable|migration_type
name|'migration_type'
op|'='
string|"'resize'"
op|','
nl|'\n'
DECL|variable|status
name|'status'
op|'='
string|"'migrating'"
nl|'\n'
op|')'
op|','
nl|'\n'
comment|'# A migration that has only this compute node as the dest host'
nl|'\n'
string|"'dest-only'"
op|':'
name|'objects'
op|'.'
name|'Migration'
op|'('
nl|'\n'
DECL|variable|id
name|'id'
op|'='
number|'2'
op|','
nl|'\n'
DECL|variable|instance_uuid
name|'instance_uuid'
op|'='
string|"'f6ed631a-8645-4b12-8e1e-2fff55795765'"
op|','
nl|'\n'
DECL|variable|source_compute
name|'source_compute'
op|'='
string|"'other-host'"
op|','
nl|'\n'
DECL|variable|dest_compute
name|'dest_compute'
op|'='
string|"'fake-host'"
op|','
nl|'\n'
DECL|variable|source_node
name|'source_node'
op|'='
string|"'other-node'"
op|','
nl|'\n'
DECL|variable|dest_node
name|'dest_node'
op|'='
string|"'fake-node'"
op|','
nl|'\n'
DECL|variable|old_instance_type_id
name|'old_instance_type_id'
op|'='
number|'1'
op|','
nl|'\n'
DECL|variable|new_instance_type_id
name|'new_instance_type_id'
op|'='
number|'2'
op|','
nl|'\n'
DECL|variable|migration_type
name|'migration_type'
op|'='
string|"'resize'"
op|','
nl|'\n'
DECL|variable|status
name|'status'
op|'='
string|"'migrating'"
nl|'\n'
op|')'
op|','
nl|'\n'
comment|'# A migration that has this compute node as both the source and dest host'
nl|'\n'
string|"'source-and-dest'"
op|':'
name|'objects'
op|'.'
name|'Migration'
op|'('
nl|'\n'
DECL|variable|id
name|'id'
op|'='
number|'3'
op|','
nl|'\n'
DECL|variable|instance_uuid
name|'instance_uuid'
op|'='
string|"'f4f0bfea-fe7e-4264-b598-01cb13ef1997'"
op|','
nl|'\n'
DECL|variable|source_compute
name|'source_compute'
op|'='
string|"'fake-host'"
op|','
nl|'\n'
DECL|variable|dest_compute
name|'dest_compute'
op|'='
string|"'fake-host'"
op|','
nl|'\n'
DECL|variable|source_node
name|'source_node'
op|'='
string|"'fake-node'"
op|','
nl|'\n'
DECL|variable|dest_node
name|'dest_node'
op|'='
string|"'fake-node'"
op|','
nl|'\n'
DECL|variable|old_instance_type_id
name|'old_instance_type_id'
op|'='
number|'1'
op|','
nl|'\n'
DECL|variable|new_instance_type_id
name|'new_instance_type_id'
op|'='
number|'2'
op|','
nl|'\n'
DECL|variable|migration_type
name|'migration_type'
op|'='
string|"'resize'"
op|','
nl|'\n'
DECL|variable|status
name|'status'
op|'='
string|"'migrating'"
nl|'\n'
op|')'
op|','
nl|'\n'
comment|'# A migration that has this compute node as destination and is an evac'
nl|'\n'
string|"'dest-only-evac'"
op|':'
name|'objects'
op|'.'
name|'Migration'
op|'('
nl|'\n'
DECL|variable|id
name|'id'
op|'='
number|'4'
op|','
nl|'\n'
DECL|variable|instance_uuid
name|'instance_uuid'
op|'='
string|"'077fb63a-bdc8-4330-90ef-f012082703dc'"
op|','
nl|'\n'
DECL|variable|source_compute
name|'source_compute'
op|'='
string|"'other-host'"
op|','
nl|'\n'
DECL|variable|dest_compute
name|'dest_compute'
op|'='
string|"'fake-host'"
op|','
nl|'\n'
DECL|variable|source_node
name|'source_node'
op|'='
string|"'other-node'"
op|','
nl|'\n'
DECL|variable|dest_node
name|'dest_node'
op|'='
string|"'fake-node'"
op|','
nl|'\n'
DECL|variable|old_instance_type_id
name|'old_instance_type_id'
op|'='
number|'2'
op|','
nl|'\n'
DECL|variable|new_instance_type_id
name|'new_instance_type_id'
op|'='
name|'None'
op|','
nl|'\n'
DECL|variable|migration_type
name|'migration_type'
op|'='
string|"'evacuation'"
op|','
nl|'\n'
DECL|variable|status
name|'status'
op|'='
string|"'pre-migrating'"
nl|'\n'
op|')'
op|','
nl|'\n'
op|'}'
newline|'\n'
nl|'\n'
DECL|variable|_MIGRATION_INSTANCE_FIXTURES
name|'_MIGRATION_INSTANCE_FIXTURES'
op|'='
op|'{'
nl|'\n'
comment|'# source-only'
nl|'\n'
string|"'f15ecfb0-9bf6-42db-9837-706eb2c4bf08'"
op|':'
name|'objects'
op|'.'
name|'Instance'
op|'('
nl|'\n'
DECL|variable|id
name|'id'
op|'='
number|'101'
op|','
nl|'\n'
DECL|variable|host
name|'host'
op|'='
name|'None'
op|','
comment|'# prevent RT trying to lazy-load this'
nl|'\n'
DECL|variable|node
name|'node'
op|'='
name|'None'
op|','
nl|'\n'
DECL|variable|uuid
name|'uuid'
op|'='
string|"'f15ecfb0-9bf6-42db-9837-706eb2c4bf08'"
op|','
nl|'\n'
DECL|variable|memory_mb
name|'memory_mb'
op|'='
name|'_INSTANCE_TYPE_FIXTURES'
op|'['
number|'1'
op|']'
op|'['
string|"'memory_mb'"
op|']'
op|','
nl|'\n'
DECL|variable|vcpus
name|'vcpus'
op|'='
name|'_INSTANCE_TYPE_FIXTURES'
op|'['
number|'1'
op|']'
op|'['
string|"'vcpus'"
op|']'
op|','
nl|'\n'
DECL|variable|root_gb
name|'root_gb'
op|'='
name|'_INSTANCE_TYPE_FIXTURES'
op|'['
number|'1'
op|']'
op|'['
string|"'root_gb'"
op|']'
op|','
nl|'\n'
DECL|variable|ephemeral_gb
name|'ephemeral_gb'
op|'='
name|'_INSTANCE_TYPE_FIXTURES'
op|'['
number|'1'
op|']'
op|'['
string|"'ephemeral_gb'"
op|']'
op|','
nl|'\n'
DECL|variable|numa_topology
name|'numa_topology'
op|'='
name|'_INSTANCE_NUMA_TOPOLOGIES'
op|'['
string|"'2mb'"
op|']'
op|','
nl|'\n'
DECL|variable|instance_type_id
name|'instance_type_id'
op|'='
number|'1'
op|','
nl|'\n'
DECL|variable|vm_state
name|'vm_state'
op|'='
name|'vm_states'
op|'.'
name|'ACTIVE'
op|','
nl|'\n'
DECL|variable|power_state
name|'power_state'
op|'='
name|'power_state'
op|'.'
name|'RUNNING'
op|','
nl|'\n'
DECL|variable|task_state
name|'task_state'
op|'='
name|'task_states'
op|'.'
name|'RESIZE_MIGRATING'
op|','
nl|'\n'
DECL|variable|system_metadata
name|'system_metadata'
op|'='
op|'{'
op|'}'
op|','
nl|'\n'
DECL|variable|os_type
name|'os_type'
op|'='
string|"'fake-os'"
op|','
nl|'\n'
DECL|variable|project_id
name|'project_id'
op|'='
string|"'fake-project'"
op|','
nl|'\n'
DECL|variable|flavor
name|'flavor'
op|'='
name|'_INSTANCE_TYPE_OBJ_FIXTURES'
op|'['
number|'1'
op|']'
op|','
nl|'\n'
DECL|variable|old_flavor
name|'old_flavor'
op|'='
name|'_INSTANCE_TYPE_OBJ_FIXTURES'
op|'['
number|'1'
op|']'
op|','
nl|'\n'
DECL|variable|new_flavor
name|'new_flavor'
op|'='
name|'_INSTANCE_TYPE_OBJ_FIXTURES'
op|'['
number|'2'
op|']'
op|','
nl|'\n'
op|')'
op|','
nl|'\n'
comment|'# dest-only'
nl|'\n'
string|"'f6ed631a-8645-4b12-8e1e-2fff55795765'"
op|':'
name|'objects'
op|'.'
name|'Instance'
op|'('
nl|'\n'
DECL|variable|id
name|'id'
op|'='
number|'102'
op|','
nl|'\n'
DECL|variable|host
name|'host'
op|'='
name|'None'
op|','
comment|'# prevent RT trying to lazy-load this'
nl|'\n'
DECL|variable|node
name|'node'
op|'='
name|'None'
op|','
nl|'\n'
DECL|variable|uuid
name|'uuid'
op|'='
string|"'f6ed631a-8645-4b12-8e1e-2fff55795765'"
op|','
nl|'\n'
DECL|variable|memory_mb
name|'memory_mb'
op|'='
name|'_INSTANCE_TYPE_FIXTURES'
op|'['
number|'2'
op|']'
op|'['
string|"'memory_mb'"
op|']'
op|','
nl|'\n'
DECL|variable|vcpus
name|'vcpus'
op|'='
name|'_INSTANCE_TYPE_FIXTURES'
op|'['
number|'2'
op|']'
op|'['
string|"'vcpus'"
op|']'
op|','
nl|'\n'
DECL|variable|root_gb
name|'root_gb'
op|'='
name|'_INSTANCE_TYPE_FIXTURES'
op|'['
number|'2'
op|']'
op|'['
string|"'root_gb'"
op|']'
op|','
nl|'\n'
DECL|variable|ephemeral_gb
name|'ephemeral_gb'
op|'='
name|'_INSTANCE_TYPE_FIXTURES'
op|'['
number|'2'
op|']'
op|'['
string|"'ephemeral_gb'"
op|']'
op|','
nl|'\n'
DECL|variable|numa_topology
name|'numa_topology'
op|'='
name|'None'
op|','
nl|'\n'
DECL|variable|instance_type_id
name|'instance_type_id'
op|'='
number|'2'
op|','
nl|'\n'
DECL|variable|vm_state
name|'vm_state'
op|'='
name|'vm_states'
op|'.'
name|'ACTIVE'
op|','
nl|'\n'
DECL|variable|power_state
name|'power_state'
op|'='
name|'power_state'
op|'.'
name|'RUNNING'
op|','
nl|'\n'
DECL|variable|task_state
name|'task_state'
op|'='
name|'task_states'
op|'.'
name|'RESIZE_MIGRATING'
op|','
nl|'\n'
DECL|variable|system_metadata
name|'system_metadata'
op|'='
op|'{'
op|'}'
op|','
nl|'\n'
DECL|variable|os_type
name|'os_type'
op|'='
string|"'fake-os'"
op|','
nl|'\n'
DECL|variable|project_id
name|'project_id'
op|'='
string|"'fake-project'"
op|','
nl|'\n'
DECL|variable|flavor
name|'flavor'
op|'='
name|'_INSTANCE_TYPE_OBJ_FIXTURES'
op|'['
number|'2'
op|']'
op|','
nl|'\n'
DECL|variable|old_flavor
name|'old_flavor'
op|'='
name|'_INSTANCE_TYPE_OBJ_FIXTURES'
op|'['
number|'1'
op|']'
op|','
nl|'\n'
DECL|variable|new_flavor
name|'new_flavor'
op|'='
name|'_INSTANCE_TYPE_OBJ_FIXTURES'
op|'['
number|'2'
op|']'
op|','
nl|'\n'
op|')'
op|','
nl|'\n'
comment|'# source-and-dest'
nl|'\n'
string|"'f4f0bfea-fe7e-4264-b598-01cb13ef1997'"
op|':'
name|'objects'
op|'.'
name|'Instance'
op|'('
nl|'\n'
DECL|variable|id
name|'id'
op|'='
number|'3'
op|','
nl|'\n'
DECL|variable|host
name|'host'
op|'='
name|'None'
op|','
comment|'# prevent RT trying to lazy-load this'
nl|'\n'
DECL|variable|node
name|'node'
op|'='
name|'None'
op|','
nl|'\n'
DECL|variable|uuid
name|'uuid'
op|'='
string|"'f4f0bfea-fe7e-4264-b598-01cb13ef1997'"
op|','
nl|'\n'
DECL|variable|memory_mb
name|'memory_mb'
op|'='
name|'_INSTANCE_TYPE_FIXTURES'
op|'['
number|'2'
op|']'
op|'['
string|"'memory_mb'"
op|']'
op|','
nl|'\n'
DECL|variable|vcpus
name|'vcpus'
op|'='
name|'_INSTANCE_TYPE_FIXTURES'
op|'['
number|'2'
op|']'
op|'['
string|"'vcpus'"
op|']'
op|','
nl|'\n'
DECL|variable|root_gb
name|'root_gb'
op|'='
name|'_INSTANCE_TYPE_FIXTURES'
op|'['
number|'2'
op|']'
op|'['
string|"'root_gb'"
op|']'
op|','
nl|'\n'
DECL|variable|ephemeral_gb
name|'ephemeral_gb'
op|'='
name|'_INSTANCE_TYPE_FIXTURES'
op|'['
number|'2'
op|']'
op|'['
string|"'ephemeral_gb'"
op|']'
op|','
nl|'\n'
DECL|variable|numa_topology
name|'numa_topology'
op|'='
name|'None'
op|','
nl|'\n'
DECL|variable|instance_type_id
name|'instance_type_id'
op|'='
number|'2'
op|','
nl|'\n'
DECL|variable|vm_state
name|'vm_state'
op|'='
name|'vm_states'
op|'.'
name|'ACTIVE'
op|','
nl|'\n'
DECL|variable|power_state
name|'power_state'
op|'='
name|'power_state'
op|'.'
name|'RUNNING'
op|','
nl|'\n'
DECL|variable|task_state
name|'task_state'
op|'='
name|'task_states'
op|'.'
name|'RESIZE_MIGRATING'
op|','
nl|'\n'
DECL|variable|system_metadata
name|'system_metadata'
op|'='
op|'{'
op|'}'
op|','
nl|'\n'
DECL|variable|os_type
name|'os_type'
op|'='
string|"'fake-os'"
op|','
nl|'\n'
DECL|variable|project_id
name|'project_id'
op|'='
string|"'fake-project'"
op|','
nl|'\n'
DECL|variable|flavor
name|'flavor'
op|'='
name|'_INSTANCE_TYPE_OBJ_FIXTURES'
op|'['
number|'2'
op|']'
op|','
nl|'\n'
DECL|variable|old_flavor
name|'old_flavor'
op|'='
name|'_INSTANCE_TYPE_OBJ_FIXTURES'
op|'['
number|'1'
op|']'
op|','
nl|'\n'
DECL|variable|new_flavor
name|'new_flavor'
op|'='
name|'_INSTANCE_TYPE_OBJ_FIXTURES'
op|'['
number|'2'
op|']'
op|','
nl|'\n'
op|')'
op|','
nl|'\n'
comment|'# dest-only-evac'
nl|'\n'
string|"'077fb63a-bdc8-4330-90ef-f012082703dc'"
op|':'
name|'objects'
op|'.'
name|'Instance'
op|'('
nl|'\n'
DECL|variable|id
name|'id'
op|'='
number|'102'
op|','
nl|'\n'
DECL|variable|host
name|'host'
op|'='
name|'None'
op|','
comment|'# prevent RT trying to lazy-load this'
nl|'\n'
DECL|variable|node
name|'node'
op|'='
name|'None'
op|','
nl|'\n'
DECL|variable|uuid
name|'uuid'
op|'='
string|"'077fb63a-bdc8-4330-90ef-f012082703dc'"
op|','
nl|'\n'
DECL|variable|memory_mb
name|'memory_mb'
op|'='
name|'_INSTANCE_TYPE_FIXTURES'
op|'['
number|'2'
op|']'
op|'['
string|"'memory_mb'"
op|']'
op|','
nl|'\n'
DECL|variable|vcpus
name|'vcpus'
op|'='
name|'_INSTANCE_TYPE_FIXTURES'
op|'['
number|'2'
op|']'
op|'['
string|"'vcpus'"
op|']'
op|','
nl|'\n'
DECL|variable|root_gb
name|'root_gb'
op|'='
name|'_INSTANCE_TYPE_FIXTURES'
op|'['
number|'2'
op|']'
op|'['
string|"'root_gb'"
op|']'
op|','
nl|'\n'
DECL|variable|ephemeral_gb
name|'ephemeral_gb'
op|'='
name|'_INSTANCE_TYPE_FIXTURES'
op|'['
number|'2'
op|']'
op|'['
string|"'ephemeral_gb'"
op|']'
op|','
nl|'\n'
DECL|variable|numa_topology
name|'numa_topology'
op|'='
name|'None'
op|','
nl|'\n'
DECL|variable|instance_type_id
name|'instance_type_id'
op|'='
number|'2'
op|','
nl|'\n'
DECL|variable|vm_state
name|'vm_state'
op|'='
name|'vm_states'
op|'.'
name|'ACTIVE'
op|','
nl|'\n'
DECL|variable|power_state
name|'power_state'
op|'='
name|'power_state'
op|'.'
name|'RUNNING'
op|','
nl|'\n'
DECL|variable|task_state
name|'task_state'
op|'='
name|'task_states'
op|'.'
name|'REBUILDING'
op|','
nl|'\n'
DECL|variable|system_metadata
name|'system_metadata'
op|'='
op|'{'
op|'}'
op|','
nl|'\n'
DECL|variable|os_type
name|'os_type'
op|'='
string|"'fake-os'"
op|','
nl|'\n'
DECL|variable|project_id
name|'project_id'
op|'='
string|"'fake-project'"
op|','
nl|'\n'
DECL|variable|flavor
name|'flavor'
op|'='
name|'_INSTANCE_TYPE_OBJ_FIXTURES'
op|'['
number|'2'
op|']'
op|','
nl|'\n'
DECL|variable|old_flavor
name|'old_flavor'
op|'='
name|'_INSTANCE_TYPE_OBJ_FIXTURES'
op|'['
number|'1'
op|']'
op|','
nl|'\n'
DECL|variable|new_flavor
name|'new_flavor'
op|'='
name|'_INSTANCE_TYPE_OBJ_FIXTURES'
op|'['
number|'2'
op|']'
op|','
nl|'\n'
op|')'
op|','
nl|'\n'
op|'}'
newline|'\n'
nl|'\n'
DECL|variable|_MIGRATION_CONTEXT_FIXTURES
name|'_MIGRATION_CONTEXT_FIXTURES'
op|'='
op|'{'
nl|'\n'
string|"'f4f0bfea-fe7e-4264-b598-01cb13ef1997'"
op|':'
name|'objects'
op|'.'
name|'MigrationContext'
op|'('
nl|'\n'
DECL|variable|instance_uuid
name|'instance_uuid'
op|'='
string|"'f4f0bfea-fe7e-4264-b598-01cb13ef1997'"
op|','
nl|'\n'
DECL|variable|migration_id
name|'migration_id'
op|'='
number|'3'
op|','
nl|'\n'
DECL|variable|new_numa_topology
name|'new_numa_topology'
op|'='
name|'None'
op|','
nl|'\n'
DECL|variable|old_numa_topology
name|'old_numa_topology'
op|'='
name|'None'
op|')'
op|','
nl|'\n'
string|"'c17741a5-6f3d-44a8-ade8-773dc8c29124'"
op|':'
name|'objects'
op|'.'
name|'MigrationContext'
op|'('
nl|'\n'
DECL|variable|instance_uuid
name|'instance_uuid'
op|'='
string|"'c17741a5-6f3d-44a8-ade8-773dc8c29124'"
op|','
nl|'\n'
DECL|variable|migration_id
name|'migration_id'
op|'='
number|'3'
op|','
nl|'\n'
DECL|variable|new_numa_topology
name|'new_numa_topology'
op|'='
name|'None'
op|','
nl|'\n'
DECL|variable|old_numa_topology
name|'old_numa_topology'
op|'='
name|'None'
op|')'
op|','
nl|'\n'
string|"'f15ecfb0-9bf6-42db-9837-706eb2c4bf08'"
op|':'
name|'objects'
op|'.'
name|'MigrationContext'
op|'('
nl|'\n'
DECL|variable|instance_uuid
name|'instance_uuid'
op|'='
string|"'f15ecfb0-9bf6-42db-9837-706eb2c4bf08'"
op|','
nl|'\n'
DECL|variable|migration_id
name|'migration_id'
op|'='
number|'1'
op|','
nl|'\n'
DECL|variable|new_numa_topology
name|'new_numa_topology'
op|'='
name|'None'
op|','
nl|'\n'
DECL|variable|old_numa_topology
name|'old_numa_topology'
op|'='
name|'_INSTANCE_NUMA_TOPOLOGIES'
op|'['
string|"'2mb'"
op|']'
op|')'
op|','
nl|'\n'
string|"'f6ed631a-8645-4b12-8e1e-2fff55795765'"
op|':'
name|'objects'
op|'.'
name|'MigrationContext'
op|'('
nl|'\n'
DECL|variable|instance_uuid
name|'instance_uuid'
op|'='
string|"'f6ed631a-8645-4b12-8e1e-2fff55795765'"
op|','
nl|'\n'
DECL|variable|migration_id
name|'migration_id'
op|'='
number|'2'
op|','
nl|'\n'
DECL|variable|new_numa_topology
name|'new_numa_topology'
op|'='
name|'_INSTANCE_NUMA_TOPOLOGIES'
op|'['
string|"'2mb'"
op|']'
op|','
nl|'\n'
DECL|variable|old_numa_topology
name|'old_numa_topology'
op|'='
name|'None'
op|')'
op|','
nl|'\n'
string|"'077fb63a-bdc8-4330-90ef-f012082703dc'"
op|':'
name|'objects'
op|'.'
name|'MigrationContext'
op|'('
nl|'\n'
DECL|variable|instance_uuid
name|'instance_uuid'
op|'='
string|"'077fb63a-bdc8-4330-90ef-f012082703dc'"
op|','
nl|'\n'
DECL|variable|migration_id
name|'migration_id'
op|'='
number|'2'
op|','
nl|'\n'
DECL|variable|new_numa_topology
name|'new_numa_topology'
op|'='
name|'None'
op|','
nl|'\n'
DECL|variable|old_numa_topology
name|'old_numa_topology'
op|'='
name|'None'
op|')'
op|','
nl|'\n'
op|'}'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|function|overhead_zero
name|'def'
name|'overhead_zero'
op|'('
name|'instance'
op|')'
op|':'
newline|'\n'
comment|'# Emulate that the driver does not adjust the memory'
nl|'\n'
comment|'# of the instance...'
nl|'\n'
indent|'    '
name|'return'
op|'{'
nl|'\n'
string|"'memory_mb'"
op|':'
number|'0'
nl|'\n'
op|'}'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|function|setup_rt
dedent|''
name|'def'
name|'setup_rt'
op|'('
name|'hostname'
op|','
name|'nodename'
op|','
name|'virt_resources'
op|'='
name|'_VIRT_DRIVER_AVAIL_RESOURCES'
op|','
nl|'\n'
name|'estimate_overhead'
op|'='
name|'overhead_zero'
op|')'
op|':'
newline|'\n'
indent|'    '
string|'"""Sets up the resource tracker instance with mock fixtures.\n\n    :param virt_resources: Optional override of the resource representation\n                           returned by the virt driver\'s\n                           `get_available_resource()` method.\n    :param estimate_overhead: Optional override of a function that should\n                              return overhead of memory given an instance\n                              object. Defaults to returning zero overhead.\n    """'
newline|'\n'
name|'sched_client_mock'
op|'='
name|'mock'
op|'.'
name|'MagicMock'
op|'('
op|')'
newline|'\n'
name|'notifier_mock'
op|'='
name|'mock'
op|'.'
name|'MagicMock'
op|'('
op|')'
newline|'\n'
name|'vd'
op|'='
name|'mock'
op|'.'
name|'MagicMock'
op|'('
op|')'
newline|'\n'
comment|"# Make sure we don't change any global fixtures during tests"
nl|'\n'
name|'virt_resources'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'virt_resources'
op|')'
newline|'\n'
name|'vd'
op|'.'
name|'get_available_resource'
op|'.'
name|'return_value'
op|'='
name|'virt_resources'
newline|'\n'
name|'vd'
op|'.'
name|'estimate_instance_overhead'
op|'.'
name|'side_effect'
op|'='
name|'estimate_overhead'
newline|'\n'
nl|'\n'
name|'with'
name|'test'
op|'.'
name|'nested'
op|'('
nl|'\n'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.scheduler.client.SchedulerClient'"
op|','
nl|'\n'
name|'return_value'
op|'='
name|'sched_client_mock'
op|')'
op|','
nl|'\n'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.rpc.get_notifier'"
op|','
name|'return_value'
op|'='
name|'notifier_mock'
op|')'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'rt'
op|'='
name|'resource_tracker'
op|'.'
name|'ResourceTracker'
op|'('
name|'hostname'
op|','
name|'vd'
op|','
name|'nodename'
op|')'
newline|'\n'
dedent|''
name|'return'
op|'('
name|'rt'
op|','
name|'sched_client_mock'
op|','
name|'vd'
op|')'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|class|BaseTestCase
dedent|''
name|'class'
name|'BaseTestCase'
op|'('
name|'test'
op|'.'
name|'NoDBTestCase'
op|')'
op|':'
newline|'\n'
nl|'\n'
DECL|member|setUp
indent|'    '
name|'def'
name|'setUp'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'super'
op|'('
name|'BaseTestCase'
op|','
name|'self'
op|')'
op|'.'
name|'setUp'
op|'('
op|')'
newline|'\n'
name|'self'
op|'.'
name|'rt'
op|'='
name|'None'
newline|'\n'
name|'self'
op|'.'
name|'flags'
op|'('
name|'my_ip'
op|'='
string|"'1.1.1.1'"
op|')'
newline|'\n'
nl|'\n'
DECL|member|_setup_rt
dedent|''
name|'def'
name|'_setup_rt'
op|'('
name|'self'
op|','
name|'virt_resources'
op|'='
name|'_VIRT_DRIVER_AVAIL_RESOURCES'
op|','
nl|'\n'
name|'estimate_overhead'
op|'='
name|'overhead_zero'
op|')'
op|':'
newline|'\n'
indent|'        '
op|'('
name|'self'
op|'.'
name|'rt'
op|','
name|'self'
op|'.'
name|'sched_client_mock'
op|','
nl|'\n'
name|'self'
op|'.'
name|'driver_mock'
op|')'
op|'='
name|'setup_rt'
op|'('
nl|'\n'
string|"'fake-host'"
op|','
string|"'fake-node'"
op|','
name|'virt_resources'
op|','
name|'estimate_overhead'
op|')'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|class|TestUpdateAvailableResources
dedent|''
dedent|''
name|'class'
name|'TestUpdateAvailableResources'
op|'('
name|'BaseTestCase'
op|')'
op|':'
newline|'\n'
nl|'\n'
DECL|member|_update_available_resources
indent|'    '
name|'def'
name|'_update_available_resources'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
comment|'# We test RT._update separately, since the complexity'
nl|'\n'
comment|'# of the update_available_resource() function is high enough as'
nl|'\n'
comment|'# it is, we just want to focus here on testing the resources'
nl|'\n'
comment|'# parameter that update_available_resource() eventually passes'
nl|'\n'
comment|'# to _update().'
nl|'\n'
indent|'        '
name|'with'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'self'
op|'.'
name|'rt'
op|','
string|"'_update'"
op|')'
name|'as'
name|'update_mock'
op|':'
newline|'\n'
indent|'            '
name|'self'
op|'.'
name|'rt'
op|'.'
name|'update_available_resource'
op|'('
name|'mock'
op|'.'
name|'sentinel'
op|'.'
name|'ctx'
op|')'
newline|'\n'
dedent|''
name|'return'
name|'update_mock'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.ComputeNode.get_by_host_and_nodename'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.MigrationList.get_in_progress_by_host_and_node'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.InstanceList.get_by_host_and_node'"
op|')'
newline|'\n'
DECL|member|test_no_instances_no_migrations_no_reserved
name|'def'
name|'test_no_instances_no_migrations_no_reserved'
op|'('
name|'self'
op|','
name|'get_mock'
op|','
name|'migr_mock'
op|','
nl|'\n'
name|'get_cn_mock'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'self'
op|'.'
name|'flags'
op|'('
name|'reserved_host_disk_mb'
op|'='
number|'0'
op|','
nl|'\n'
name|'reserved_host_memory_mb'
op|'='
number|'0'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'_setup_rt'
op|'('
op|')'
newline|'\n'
nl|'\n'
name|'get_mock'
op|'.'
name|'return_value'
op|'='
op|'['
op|']'
newline|'\n'
name|'migr_mock'
op|'.'
name|'return_value'
op|'='
op|'['
op|']'
newline|'\n'
name|'get_cn_mock'
op|'.'
name|'return_value'
op|'='
name|'_COMPUTE_NODE_FIXTURES'
op|'['
number|'0'
op|']'
newline|'\n'
nl|'\n'
name|'update_mock'
op|'='
name|'self'
op|'.'
name|'_update_available_resources'
op|'('
op|')'
newline|'\n'
nl|'\n'
name|'vd'
op|'='
name|'self'
op|'.'
name|'driver_mock'
newline|'\n'
name|'vd'
op|'.'
name|'get_available_resource'
op|'.'
name|'assert_called_once_with'
op|'('
string|"'fake-node'"
op|')'
newline|'\n'
name|'get_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'mock'
op|'.'
name|'sentinel'
op|'.'
name|'ctx'
op|','
string|"'fake-host'"
op|','
nl|'\n'
string|"'fake-node'"
op|','
nl|'\n'
name|'expected_attrs'
op|'='
op|'['
nl|'\n'
string|"'system_metadata'"
op|','
nl|'\n'
string|"'numa_topology'"
op|','
nl|'\n'
string|"'flavor'"
op|','
nl|'\n'
string|"'migration_context'"
op|']'
op|')'
newline|'\n'
name|'get_cn_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'mock'
op|'.'
name|'sentinel'
op|'.'
name|'ctx'
op|','
string|"'fake-host'"
op|','
nl|'\n'
string|"'fake-node'"
op|')'
newline|'\n'
name|'migr_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'mock'
op|'.'
name|'sentinel'
op|'.'
name|'ctx'
op|','
string|"'fake-host'"
op|','
nl|'\n'
string|"'fake-node'"
op|')'
newline|'\n'
nl|'\n'
name|'expected_resources'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'_COMPUTE_NODE_FIXTURES'
op|'['
number|'0'
op|']'
op|')'
newline|'\n'
name|'vals'
op|'='
op|'{'
nl|'\n'
comment|'# host is added in update_available_resources()'
nl|'\n'
comment|'# before calling _update()'
nl|'\n'
string|"'host'"
op|':'
string|"'fake-host'"
op|','
nl|'\n'
string|"'host_ip'"
op|':'
string|"'1.1.1.1'"
op|','
nl|'\n'
string|"'numa_topology'"
op|':'
name|'None'
op|','
nl|'\n'
string|"'metrics'"
op|':'
string|"'[]'"
op|','
nl|'\n'
string|"'cpu_info'"
op|':'
string|"''"
op|','
nl|'\n'
string|"'hypervisor_hostname'"
op|':'
string|"'fakehost'"
op|','
nl|'\n'
string|"'free_disk_gb'"
op|':'
number|'6'
op|','
nl|'\n'
string|"'hypervisor_version'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'local_gb'"
op|':'
number|'6'
op|','
nl|'\n'
string|"'free_ram_mb'"
op|':'
number|'512'
op|','
nl|'\n'
string|"'memory_mb_used'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'pci_device_pools'"
op|':'
name|'objects'
op|'.'
name|'PciDevicePoolList'
op|'('
op|')'
op|','
nl|'\n'
string|"'vcpus_used'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'hypervisor_type'"
op|':'
string|"'fake'"
op|','
nl|'\n'
string|"'local_gb_used'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'memory_mb'"
op|':'
number|'512'
op|','
nl|'\n'
string|"'current_workload'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'vcpus'"
op|':'
number|'4'
op|','
nl|'\n'
string|"'running_vms'"
op|':'
number|'0'
nl|'\n'
op|'}'
newline|'\n'
name|'_update_compute_node'
op|'('
name|'expected_resources'
op|','
op|'**'
name|'vals'
op|')'
newline|'\n'
name|'update_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'mock'
op|'.'
name|'sentinel'
op|'.'
name|'ctx'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertTrue'
op|'('
name|'obj_base'
op|'.'
name|'obj_equal_prims'
op|'('
name|'expected_resources'
op|','
nl|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|')'
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.ComputeNode.get_by_host_and_nodename'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.MigrationList.get_in_progress_by_host_and_node'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.InstanceList.get_by_host_and_node'"
op|')'
newline|'\n'
DECL|member|test_no_instances_no_migrations_reserved_disk_and_ram
name|'def'
name|'test_no_instances_no_migrations_reserved_disk_and_ram'
op|'('
nl|'\n'
name|'self'
op|','
name|'get_mock'
op|','
name|'migr_mock'
op|','
name|'get_cn_mock'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'self'
op|'.'
name|'flags'
op|'('
name|'reserved_host_disk_mb'
op|'='
number|'1024'
op|','
nl|'\n'
name|'reserved_host_memory_mb'
op|'='
number|'512'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'_setup_rt'
op|'('
op|')'
newline|'\n'
nl|'\n'
name|'get_mock'
op|'.'
name|'return_value'
op|'='
op|'['
op|']'
newline|'\n'
name|'migr_mock'
op|'.'
name|'return_value'
op|'='
op|'['
op|']'
newline|'\n'
name|'get_cn_mock'
op|'.'
name|'return_value'
op|'='
name|'_COMPUTE_NODE_FIXTURES'
op|'['
number|'0'
op|']'
newline|'\n'
nl|'\n'
name|'update_mock'
op|'='
name|'self'
op|'.'
name|'_update_available_resources'
op|'('
op|')'
newline|'\n'
nl|'\n'
name|'get_cn_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'mock'
op|'.'
name|'sentinel'
op|'.'
name|'ctx'
op|','
string|"'fake-host'"
op|','
nl|'\n'
string|"'fake-node'"
op|')'
newline|'\n'
name|'expected_resources'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'_COMPUTE_NODE_FIXTURES'
op|'['
number|'0'
op|']'
op|')'
newline|'\n'
name|'vals'
op|'='
op|'{'
nl|'\n'
comment|'# host is added in update_available_resources()'
nl|'\n'
comment|'# before calling _update()'
nl|'\n'
string|"'host'"
op|':'
string|"'fake-host'"
op|','
nl|'\n'
string|"'host_ip'"
op|':'
string|"'1.1.1.1'"
op|','
nl|'\n'
string|"'numa_topology'"
op|':'
name|'None'
op|','
nl|'\n'
string|"'metrics'"
op|':'
string|"'[]'"
op|','
nl|'\n'
string|"'cpu_info'"
op|':'
string|"''"
op|','
nl|'\n'
string|"'hypervisor_hostname'"
op|':'
string|"'fakehost'"
op|','
nl|'\n'
string|"'free_disk_gb'"
op|':'
number|'5'
op|','
comment|'# 6GB avail - 1 GB reserved'
nl|'\n'
string|"'hypervisor_version'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'local_gb'"
op|':'
number|'6'
op|','
nl|'\n'
string|"'free_ram_mb'"
op|':'
number|'0'
op|','
comment|'# 512MB avail - 512MB reserved'
nl|'\n'
string|"'memory_mb_used'"
op|':'
number|'512'
op|','
comment|'# 0MB used + 512MB reserved'
nl|'\n'
string|"'pci_device_pools'"
op|':'
name|'objects'
op|'.'
name|'PciDevicePoolList'
op|'('
op|')'
op|','
nl|'\n'
string|"'vcpus_used'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'hypervisor_type'"
op|':'
string|"'fake'"
op|','
nl|'\n'
string|"'local_gb_used'"
op|':'
number|'1'
op|','
comment|'# 0GB used + 1 GB reserved'
nl|'\n'
string|"'memory_mb'"
op|':'
number|'512'
op|','
nl|'\n'
string|"'current_workload'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'vcpus'"
op|':'
number|'4'
op|','
nl|'\n'
string|"'running_vms'"
op|':'
number|'0'
nl|'\n'
op|'}'
newline|'\n'
name|'_update_compute_node'
op|'('
name|'expected_resources'
op|','
op|'**'
name|'vals'
op|')'
newline|'\n'
name|'update_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'mock'
op|'.'
name|'sentinel'
op|'.'
name|'ctx'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertTrue'
op|'('
name|'obj_base'
op|'.'
name|'obj_equal_prims'
op|'('
name|'expected_resources'
op|','
nl|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|')'
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.ComputeNode.get_by_host_and_nodename'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.MigrationList.get_in_progress_by_host_and_node'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.InstanceList.get_by_host_and_node'"
op|')'
newline|'\n'
DECL|member|test_some_instances_no_migrations
name|'def'
name|'test_some_instances_no_migrations'
op|'('
name|'self'
op|','
name|'get_mock'
op|','
name|'migr_mock'
op|','
nl|'\n'
name|'get_cn_mock'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'self'
op|'.'
name|'flags'
op|'('
name|'reserved_host_disk_mb'
op|'='
number|'0'
op|','
nl|'\n'
name|'reserved_host_memory_mb'
op|'='
number|'0'
op|')'
newline|'\n'
nl|'\n'
comment|'# Setup virt resources to match used resources to number'
nl|'\n'
comment|'# of defined instances on the hypervisor'
nl|'\n'
name|'virt_resources'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'_VIRT_DRIVER_AVAIL_RESOURCES'
op|')'
newline|'\n'
name|'virt_resources'
op|'.'
name|'update'
op|'('
name|'vcpus_used'
op|'='
number|'1'
op|','
nl|'\n'
name|'memory_mb_used'
op|'='
number|'128'
op|','
nl|'\n'
name|'local_gb_used'
op|'='
number|'1'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'_setup_rt'
op|'('
name|'virt_resources'
op|'='
name|'virt_resources'
op|')'
newline|'\n'
nl|'\n'
name|'get_mock'
op|'.'
name|'return_value'
op|'='
name|'_INSTANCE_FIXTURES'
newline|'\n'
name|'migr_mock'
op|'.'
name|'return_value'
op|'='
op|'['
op|']'
newline|'\n'
name|'get_cn_mock'
op|'.'
name|'return_value'
op|'='
name|'_COMPUTE_NODE_FIXTURES'
op|'['
number|'0'
op|']'
newline|'\n'
nl|'\n'
name|'update_mock'
op|'='
name|'self'
op|'.'
name|'_update_available_resources'
op|'('
op|')'
newline|'\n'
nl|'\n'
name|'get_cn_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'mock'
op|'.'
name|'sentinel'
op|'.'
name|'ctx'
op|','
string|"'fake-host'"
op|','
nl|'\n'
string|"'fake-node'"
op|')'
newline|'\n'
name|'expected_resources'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'_COMPUTE_NODE_FIXTURES'
op|'['
number|'0'
op|']'
op|')'
newline|'\n'
name|'vals'
op|'='
op|'{'
nl|'\n'
comment|'# host is added in update_available_resources()'
nl|'\n'
comment|'# before calling _update()'
nl|'\n'
string|"'host'"
op|':'
string|"'fake-host'"
op|','
nl|'\n'
string|"'host_ip'"
op|':'
string|"'1.1.1.1'"
op|','
nl|'\n'
string|"'numa_topology'"
op|':'
name|'None'
op|','
nl|'\n'
string|"'metrics'"
op|':'
string|"'[]'"
op|','
nl|'\n'
string|"'cpu_info'"
op|':'
string|"''"
op|','
nl|'\n'
string|"'hypervisor_hostname'"
op|':'
string|"'fakehost'"
op|','
nl|'\n'
string|"'free_disk_gb'"
op|':'
number|'5'
op|','
comment|'# 6 - 1 used'
nl|'\n'
string|"'hypervisor_version'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'local_gb'"
op|':'
number|'6'
op|','
nl|'\n'
string|"'free_ram_mb'"
op|':'
number|'384'
op|','
comment|'# 512 - 128 used'
nl|'\n'
string|"'memory_mb_used'"
op|':'
number|'128'
op|','
nl|'\n'
string|"'pci_device_pools'"
op|':'
name|'objects'
op|'.'
name|'PciDevicePoolList'
op|'('
op|')'
op|','
nl|'\n'
string|"'vcpus_used'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'hypervisor_type'"
op|':'
string|"'fake'"
op|','
nl|'\n'
string|"'local_gb_used'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'memory_mb'"
op|':'
number|'512'
op|','
nl|'\n'
string|"'current_workload'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'vcpus'"
op|':'
number|'4'
op|','
nl|'\n'
string|"'running_vms'"
op|':'
number|'1'
comment|'# One active instance'
nl|'\n'
op|'}'
newline|'\n'
name|'_update_compute_node'
op|'('
name|'expected_resources'
op|','
op|'**'
name|'vals'
op|')'
newline|'\n'
name|'update_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'mock'
op|'.'
name|'sentinel'
op|'.'
name|'ctx'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertTrue'
op|'('
name|'obj_base'
op|'.'
name|'obj_equal_prims'
op|'('
name|'expected_resources'
op|','
nl|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|')'
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.ComputeNode.get_by_host_and_nodename'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.MigrationList.get_in_progress_by_host_and_node'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.InstanceList.get_by_host_and_node'"
op|')'
newline|'\n'
DECL|member|test_orphaned_instances_no_migrations
name|'def'
name|'test_orphaned_instances_no_migrations'
op|'('
name|'self'
op|','
name|'get_mock'
op|','
name|'migr_mock'
op|','
nl|'\n'
name|'get_cn_mock'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'self'
op|'.'
name|'flags'
op|'('
name|'reserved_host_disk_mb'
op|'='
number|'0'
op|','
nl|'\n'
name|'reserved_host_memory_mb'
op|'='
number|'0'
op|')'
newline|'\n'
nl|'\n'
comment|'# Setup virt resources to match used resources to number'
nl|'\n'
comment|'# of defined instances on the hypervisor'
nl|'\n'
name|'virt_resources'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'_VIRT_DRIVER_AVAIL_RESOURCES'
op|')'
newline|'\n'
name|'virt_resources'
op|'.'
name|'update'
op|'('
name|'memory_mb_used'
op|'='
number|'64'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'_setup_rt'
op|'('
name|'virt_resources'
op|'='
name|'virt_resources'
op|')'
newline|'\n'
nl|'\n'
name|'get_mock'
op|'.'
name|'return_value'
op|'='
op|'['
op|']'
newline|'\n'
name|'migr_mock'
op|'.'
name|'return_value'
op|'='
op|'['
op|']'
newline|'\n'
name|'get_cn_mock'
op|'.'
name|'return_value'
op|'='
name|'_COMPUTE_NODE_FIXTURES'
op|'['
number|'0'
op|']'
newline|'\n'
nl|'\n'
comment|'# Orphaned instances are those that the virt driver has on'
nl|'\n'
comment|'# record as consuming resources on the compute node, but the'
nl|'\n'
comment|'# Nova database has no record of the instance being active'
nl|'\n'
comment|'# on the host. For some reason, the resource tracker only'
nl|'\n'
comment|"# considers orphaned instance's memory usage in its calculations"
nl|'\n'
comment|'# of free resources...'
nl|'\n'
name|'orphaned_usages'
op|'='
op|'{'
nl|'\n'
string|"'71ed7ef6-9d2e-4c65-9f4e-90bb6b76261d'"
op|':'
op|'{'
nl|'\n'
comment|'# Yes, the return result format of get_per_instance_usage'
nl|'\n'
comment|'# is indeed this stupid and redundant. Also note that the'
nl|'\n'
comment|'# libvirt driver just returns an empty dict always for this'
nl|'\n'
comment|'# method and so who the heck knows whether this stuff'
nl|'\n'
comment|'# actually works.'
nl|'\n'
string|"'uuid'"
op|':'
string|"'71ed7ef6-9d2e-4c65-9f4e-90bb6b76261d'"
op|','
nl|'\n'
string|"'memory_mb'"
op|':'
number|'64'
nl|'\n'
op|'}'
nl|'\n'
op|'}'
newline|'\n'
name|'vd'
op|'='
name|'self'
op|'.'
name|'driver_mock'
newline|'\n'
name|'vd'
op|'.'
name|'get_per_instance_usage'
op|'.'
name|'return_value'
op|'='
name|'orphaned_usages'
newline|'\n'
nl|'\n'
name|'update_mock'
op|'='
name|'self'
op|'.'
name|'_update_available_resources'
op|'('
op|')'
newline|'\n'
nl|'\n'
name|'get_cn_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'mock'
op|'.'
name|'sentinel'
op|'.'
name|'ctx'
op|','
string|"'fake-host'"
op|','
nl|'\n'
string|"'fake-node'"
op|')'
newline|'\n'
name|'expected_resources'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'_COMPUTE_NODE_FIXTURES'
op|'['
number|'0'
op|']'
op|')'
newline|'\n'
name|'vals'
op|'='
op|'{'
nl|'\n'
comment|'# host is added in update_available_resources()'
nl|'\n'
comment|'# before calling _update()'
nl|'\n'
string|"'host'"
op|':'
string|"'fake-host'"
op|','
nl|'\n'
string|"'host_ip'"
op|':'
string|"'1.1.1.1'"
op|','
nl|'\n'
string|"'numa_topology'"
op|':'
name|'None'
op|','
nl|'\n'
string|"'metrics'"
op|':'
string|"'[]'"
op|','
nl|'\n'
string|"'cpu_info'"
op|':'
string|"''"
op|','
nl|'\n'
string|"'hypervisor_hostname'"
op|':'
string|"'fakehost'"
op|','
nl|'\n'
string|"'free_disk_gb'"
op|':'
number|'6'
op|','
nl|'\n'
string|"'hypervisor_version'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'local_gb'"
op|':'
number|'6'
op|','
nl|'\n'
string|"'free_ram_mb'"
op|':'
number|'448'
op|','
comment|'# 512 - 64 orphaned usage'
nl|'\n'
string|"'memory_mb_used'"
op|':'
number|'64'
op|','
nl|'\n'
string|"'pci_device_pools'"
op|':'
name|'objects'
op|'.'
name|'PciDevicePoolList'
op|'('
op|')'
op|','
nl|'\n'
string|"'vcpus_used'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'hypervisor_type'"
op|':'
string|"'fake'"
op|','
nl|'\n'
string|"'local_gb_used'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'memory_mb'"
op|':'
number|'512'
op|','
nl|'\n'
string|"'current_workload'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'vcpus'"
op|':'
number|'4'
op|','
nl|'\n'
comment|'# Yep, for some reason, orphaned instances are not counted'
nl|'\n'
comment|'# as running VMs...'
nl|'\n'
string|"'running_vms'"
op|':'
number|'0'
nl|'\n'
op|'}'
newline|'\n'
name|'_update_compute_node'
op|'('
name|'expected_resources'
op|','
op|'**'
name|'vals'
op|')'
newline|'\n'
name|'update_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'mock'
op|'.'
name|'sentinel'
op|'.'
name|'ctx'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertTrue'
op|'('
name|'obj_base'
op|'.'
name|'obj_equal_prims'
op|'('
name|'expected_resources'
op|','
nl|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|')'
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.ComputeNode.get_by_host_and_nodename'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.MigrationList.get_in_progress_by_host_and_node'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.Instance.get_by_uuid'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.InstanceList.get_by_host_and_node'"
op|')'
newline|'\n'
DECL|member|test_no_instances_source_migration
name|'def'
name|'test_no_instances_source_migration'
op|'('
name|'self'
op|','
name|'get_mock'
op|','
name|'get_inst_mock'
op|','
nl|'\n'
name|'migr_mock'
op|','
name|'get_cn_mock'
op|')'
op|':'
newline|'\n'
comment|'# We test the behavior of update_available_resource() when'
nl|'\n'
comment|'# there is an active migration that involves this compute node'
nl|'\n'
comment|'# as the source host not the destination host, and the resource'
nl|'\n'
comment|'# tracker does not have any instances assigned to it. This is'
nl|'\n'
comment|'# the case when a migration from this compute host to another'
nl|'\n'
comment|'# has been completed, but the user has not confirmed the resize'
nl|'\n'
comment|'# yet, so the resource tracker must continue to keep the resources'
nl|'\n'
comment|'# for the original instance type available on the source compute'
nl|'\n'
comment|'# node in case of a revert of the resize.'
nl|'\n'
indent|'        '
name|'self'
op|'.'
name|'flags'
op|'('
name|'reserved_host_disk_mb'
op|'='
number|'0'
op|','
nl|'\n'
name|'reserved_host_memory_mb'
op|'='
number|'0'
op|')'
newline|'\n'
nl|'\n'
comment|'# Setup virt resources to match used resources to number'
nl|'\n'
comment|'# of defined instances on the hypervisor'
nl|'\n'
name|'virt_resources'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'_VIRT_DRIVER_AVAIL_RESOURCES'
op|')'
newline|'\n'
name|'virt_resources'
op|'.'
name|'update'
op|'('
name|'vcpus_used'
op|'='
number|'4'
op|','
nl|'\n'
name|'memory_mb_used'
op|'='
number|'128'
op|','
nl|'\n'
name|'local_gb_used'
op|'='
number|'1'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'_setup_rt'
op|'('
name|'virt_resources'
op|'='
name|'virt_resources'
op|')'
newline|'\n'
nl|'\n'
name|'get_mock'
op|'.'
name|'return_value'
op|'='
op|'['
op|']'
newline|'\n'
name|'migr_obj'
op|'='
name|'_MIGRATION_FIXTURES'
op|'['
string|"'source-only'"
op|']'
newline|'\n'
name|'migr_mock'
op|'.'
name|'return_value'
op|'='
op|'['
name|'migr_obj'
op|']'
newline|'\n'
name|'get_cn_mock'
op|'.'
name|'return_value'
op|'='
name|'_COMPUTE_NODE_FIXTURES'
op|'['
number|'0'
op|']'
newline|'\n'
comment|'# Migration.instance property is accessed in the migration'
nl|'\n'
comment|'# processing code, and this property calls'
nl|'\n'
comment|'# objects.Instance.get_by_uuid, so we have the migration return'
nl|'\n'
name|'inst_uuid'
op|'='
name|'migr_obj'
op|'.'
name|'instance_uuid'
newline|'\n'
name|'instance'
op|'='
name|'_MIGRATION_INSTANCE_FIXTURES'
op|'['
name|'inst_uuid'
op|']'
op|'.'
name|'obj_clone'
op|'('
op|')'
newline|'\n'
name|'get_inst_mock'
op|'.'
name|'return_value'
op|'='
name|'instance'
newline|'\n'
name|'instance'
op|'.'
name|'migration_context'
op|'='
name|'_MIGRATION_CONTEXT_FIXTURES'
op|'['
name|'inst_uuid'
op|']'
newline|'\n'
nl|'\n'
name|'update_mock'
op|'='
name|'self'
op|'.'
name|'_update_available_resources'
op|'('
op|')'
newline|'\n'
nl|'\n'
name|'get_cn_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'mock'
op|'.'
name|'sentinel'
op|'.'
name|'ctx'
op|','
string|"'fake-host'"
op|','
nl|'\n'
string|"'fake-node'"
op|')'
newline|'\n'
name|'expected_resources'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'_COMPUTE_NODE_FIXTURES'
op|'['
number|'0'
op|']'
op|')'
newline|'\n'
name|'vals'
op|'='
op|'{'
nl|'\n'
comment|'# host is added in update_available_resources()'
nl|'\n'
comment|'# before calling _update()'
nl|'\n'
string|"'host'"
op|':'
string|"'fake-host'"
op|','
nl|'\n'
string|"'host_ip'"
op|':'
string|"'1.1.1.1'"
op|','
nl|'\n'
string|"'numa_topology'"
op|':'
name|'None'
op|','
nl|'\n'
string|"'metrics'"
op|':'
string|"'[]'"
op|','
nl|'\n'
string|"'cpu_info'"
op|':'
string|"''"
op|','
nl|'\n'
string|"'hypervisor_hostname'"
op|':'
string|"'fakehost'"
op|','
nl|'\n'
string|"'free_disk_gb'"
op|':'
number|'5'
op|','
nl|'\n'
string|"'hypervisor_version'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'local_gb'"
op|':'
number|'6'
op|','
nl|'\n'
string|"'free_ram_mb'"
op|':'
number|'384'
op|','
comment|'# 512 total - 128 for possible revert of orig'
nl|'\n'
string|"'memory_mb_used'"
op|':'
number|'128'
op|','
comment|'# 128 possible revert amount'
nl|'\n'
string|"'pci_device_pools'"
op|':'
name|'objects'
op|'.'
name|'PciDevicePoolList'
op|'('
op|')'
op|','
nl|'\n'
string|"'vcpus_used'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'hypervisor_type'"
op|':'
string|"'fake'"
op|','
nl|'\n'
string|"'local_gb_used'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'memory_mb'"
op|':'
number|'512'
op|','
nl|'\n'
string|"'current_workload'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'vcpus'"
op|':'
number|'4'
op|','
nl|'\n'
string|"'running_vms'"
op|':'
number|'0'
nl|'\n'
op|'}'
newline|'\n'
name|'_update_compute_node'
op|'('
name|'expected_resources'
op|','
op|'**'
name|'vals'
op|')'
newline|'\n'
name|'update_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'mock'
op|'.'
name|'sentinel'
op|'.'
name|'ctx'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertTrue'
op|'('
name|'obj_base'
op|'.'
name|'obj_equal_prims'
op|'('
name|'expected_resources'
op|','
nl|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|')'
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.ComputeNode.get_by_host_and_nodename'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.MigrationList.get_in_progress_by_host_and_node'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.Instance.get_by_uuid'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.InstanceList.get_by_host_and_node'"
op|')'
newline|'\n'
DECL|member|test_no_instances_dest_migration
name|'def'
name|'test_no_instances_dest_migration'
op|'('
name|'self'
op|','
name|'get_mock'
op|','
name|'get_inst_mock'
op|','
nl|'\n'
name|'migr_mock'
op|','
name|'get_cn_mock'
op|')'
op|':'
newline|'\n'
comment|'# We test the behavior of update_available_resource() when'
nl|'\n'
comment|'# there is an active migration that involves this compute node'
nl|'\n'
comment|'# as the destination host not the source host, and the resource'
nl|'\n'
comment|'# tracker does not yet have any instances assigned to it. This is'
nl|'\n'
comment|'# the case when a migration to this compute host from another host'
nl|'\n'
comment|'# is in progress, but the user has not confirmed the resize'
nl|'\n'
comment|'# yet, so the resource tracker must reserve the resources'
nl|'\n'
comment|"# for the possibly-to-be-confirmed instance's instance type"
nl|'\n'
comment|'# node in case of a confirm of the resize.'
nl|'\n'
indent|'        '
name|'self'
op|'.'
name|'flags'
op|'('
name|'reserved_host_disk_mb'
op|'='
number|'0'
op|','
nl|'\n'
name|'reserved_host_memory_mb'
op|'='
number|'0'
op|')'
newline|'\n'
nl|'\n'
comment|'# Setup virt resources to match used resources to number'
nl|'\n'
comment|'# of defined instances on the hypervisor'
nl|'\n'
name|'virt_resources'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'_VIRT_DRIVER_AVAIL_RESOURCES'
op|')'
newline|'\n'
name|'virt_resources'
op|'.'
name|'update'
op|'('
name|'vcpus_used'
op|'='
number|'2'
op|','
nl|'\n'
name|'memory_mb_used'
op|'='
number|'256'
op|','
nl|'\n'
name|'local_gb_used'
op|'='
number|'5'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'_setup_rt'
op|'('
name|'virt_resources'
op|'='
name|'virt_resources'
op|')'
newline|'\n'
nl|'\n'
name|'get_mock'
op|'.'
name|'return_value'
op|'='
op|'['
op|']'
newline|'\n'
name|'migr_obj'
op|'='
name|'_MIGRATION_FIXTURES'
op|'['
string|"'dest-only'"
op|']'
newline|'\n'
name|'migr_mock'
op|'.'
name|'return_value'
op|'='
op|'['
name|'migr_obj'
op|']'
newline|'\n'
name|'inst_uuid'
op|'='
name|'migr_obj'
op|'.'
name|'instance_uuid'
newline|'\n'
name|'instance'
op|'='
name|'_MIGRATION_INSTANCE_FIXTURES'
op|'['
name|'inst_uuid'
op|']'
op|'.'
name|'obj_clone'
op|'('
op|')'
newline|'\n'
name|'get_inst_mock'
op|'.'
name|'return_value'
op|'='
name|'instance'
newline|'\n'
name|'get_cn_mock'
op|'.'
name|'return_value'
op|'='
name|'_COMPUTE_NODE_FIXTURES'
op|'['
number|'0'
op|']'
newline|'\n'
name|'instance'
op|'.'
name|'migration_context'
op|'='
name|'_MIGRATION_CONTEXT_FIXTURES'
op|'['
name|'inst_uuid'
op|']'
newline|'\n'
nl|'\n'
name|'update_mock'
op|'='
name|'self'
op|'.'
name|'_update_available_resources'
op|'('
op|')'
newline|'\n'
nl|'\n'
name|'get_cn_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'mock'
op|'.'
name|'sentinel'
op|'.'
name|'ctx'
op|','
string|"'fake-host'"
op|','
nl|'\n'
string|"'fake-node'"
op|')'
newline|'\n'
name|'expected_resources'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'_COMPUTE_NODE_FIXTURES'
op|'['
number|'0'
op|']'
op|')'
newline|'\n'
name|'vals'
op|'='
op|'{'
nl|'\n'
comment|'# host is added in update_available_resources()'
nl|'\n'
comment|'# before calling _update()'
nl|'\n'
string|"'host'"
op|':'
string|"'fake-host'"
op|','
nl|'\n'
string|"'host_ip'"
op|':'
string|"'1.1.1.1'"
op|','
nl|'\n'
string|"'numa_topology'"
op|':'
name|'None'
op|','
nl|'\n'
string|"'metrics'"
op|':'
string|"'[]'"
op|','
nl|'\n'
string|"'cpu_info'"
op|':'
string|"''"
op|','
nl|'\n'
string|"'hypervisor_hostname'"
op|':'
string|"'fakehost'"
op|','
nl|'\n'
string|"'free_disk_gb'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'hypervisor_version'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'local_gb'"
op|':'
number|'6'
op|','
nl|'\n'
string|"'free_ram_mb'"
op|':'
number|'256'
op|','
comment|'# 512 total - 256 for possible confirm of new'
nl|'\n'
string|"'memory_mb_used'"
op|':'
number|'256'
op|','
comment|'# 256 possible confirmed amount'
nl|'\n'
string|"'pci_device_pools'"
op|':'
name|'objects'
op|'.'
name|'PciDevicePoolList'
op|'('
op|')'
op|','
nl|'\n'
string|"'vcpus_used'"
op|':'
number|'2'
op|','
nl|'\n'
string|"'hypervisor_type'"
op|':'
string|"'fake'"
op|','
nl|'\n'
string|"'local_gb_used'"
op|':'
number|'5'
op|','
nl|'\n'
string|"'memory_mb'"
op|':'
number|'512'
op|','
nl|'\n'
string|"'current_workload'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'vcpus'"
op|':'
number|'4'
op|','
nl|'\n'
string|"'running_vms'"
op|':'
number|'0'
nl|'\n'
op|'}'
newline|'\n'
name|'_update_compute_node'
op|'('
name|'expected_resources'
op|','
op|'**'
name|'vals'
op|')'
newline|'\n'
name|'update_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'mock'
op|'.'
name|'sentinel'
op|'.'
name|'ctx'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertTrue'
op|'('
name|'obj_base'
op|'.'
name|'obj_equal_prims'
op|'('
name|'expected_resources'
op|','
nl|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|')'
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.ComputeNode.get_by_host_and_nodename'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.MigrationList.get_in_progress_by_host_and_node'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.Instance.get_by_uuid'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.InstanceList.get_by_host_and_node'"
op|')'
newline|'\n'
DECL|member|test_no_instances_dest_evacuation
name|'def'
name|'test_no_instances_dest_evacuation'
op|'('
name|'self'
op|','
name|'get_mock'
op|','
name|'get_inst_mock'
op|','
nl|'\n'
name|'migr_mock'
op|','
name|'get_cn_mock'
op|')'
op|':'
newline|'\n'
comment|'# We test the behavior of update_available_resource() when'
nl|'\n'
comment|'# there is an active evacuation that involves this compute node'
nl|'\n'
comment|'# as the destination host not the source host, and the resource'
nl|'\n'
comment|'# tracker does not yet have any instances assigned to it. This is'
nl|'\n'
comment|'# the case when a migration to this compute host from another host'
nl|'\n'
comment|'# is in progress, but not finished yet.'
nl|'\n'
indent|'        '
name|'self'
op|'.'
name|'flags'
op|'('
name|'reserved_host_disk_mb'
op|'='
number|'0'
op|','
nl|'\n'
name|'reserved_host_memory_mb'
op|'='
number|'0'
op|')'
newline|'\n'
nl|'\n'
comment|'# Setup virt resources to match used resources to number'
nl|'\n'
comment|'# of defined instances on the hypervisor'
nl|'\n'
name|'virt_resources'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'_VIRT_DRIVER_AVAIL_RESOURCES'
op|')'
newline|'\n'
name|'virt_resources'
op|'.'
name|'update'
op|'('
name|'vcpus_used'
op|'='
number|'2'
op|','
nl|'\n'
name|'memory_mb_used'
op|'='
number|'256'
op|','
nl|'\n'
name|'local_gb_used'
op|'='
number|'5'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'_setup_rt'
op|'('
name|'virt_resources'
op|'='
name|'virt_resources'
op|')'
newline|'\n'
nl|'\n'
name|'get_mock'
op|'.'
name|'return_value'
op|'='
op|'['
op|']'
newline|'\n'
name|'migr_obj'
op|'='
name|'_MIGRATION_FIXTURES'
op|'['
string|"'dest-only-evac'"
op|']'
newline|'\n'
name|'migr_mock'
op|'.'
name|'return_value'
op|'='
op|'['
name|'migr_obj'
op|']'
newline|'\n'
name|'inst_uuid'
op|'='
name|'migr_obj'
op|'.'
name|'instance_uuid'
newline|'\n'
name|'instance'
op|'='
name|'_MIGRATION_INSTANCE_FIXTURES'
op|'['
name|'inst_uuid'
op|']'
op|'.'
name|'obj_clone'
op|'('
op|')'
newline|'\n'
name|'get_inst_mock'
op|'.'
name|'return_value'
op|'='
name|'instance'
newline|'\n'
name|'get_cn_mock'
op|'.'
name|'return_value'
op|'='
name|'_COMPUTE_NODE_FIXTURES'
op|'['
number|'0'
op|']'
newline|'\n'
name|'instance'
op|'.'
name|'migration_context'
op|'='
name|'_MIGRATION_CONTEXT_FIXTURES'
op|'['
name|'inst_uuid'
op|']'
newline|'\n'
nl|'\n'
name|'update_mock'
op|'='
name|'self'
op|'.'
name|'_update_available_resources'
op|'('
op|')'
newline|'\n'
nl|'\n'
name|'get_cn_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'mock'
op|'.'
name|'sentinel'
op|'.'
name|'ctx'
op|','
string|"'fake-host'"
op|','
nl|'\n'
string|"'fake-node'"
op|')'
newline|'\n'
name|'expected_resources'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'_COMPUTE_NODE_FIXTURES'
op|'['
number|'0'
op|']'
op|')'
newline|'\n'
name|'vals'
op|'='
op|'{'
nl|'\n'
comment|'# host is added in update_available_resources()'
nl|'\n'
comment|'# before calling _update()'
nl|'\n'
string|"'host'"
op|':'
string|"'fake-host'"
op|','
nl|'\n'
string|"'host_ip'"
op|':'
string|"'1.1.1.1'"
op|','
nl|'\n'
string|"'numa_topology'"
op|':'
name|'None'
op|','
nl|'\n'
string|"'metrics'"
op|':'
string|"'[]'"
op|','
nl|'\n'
string|"'cpu_info'"
op|':'
string|"''"
op|','
nl|'\n'
string|"'hypervisor_hostname'"
op|':'
string|"'fakehost'"
op|','
nl|'\n'
string|"'free_disk_gb'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'hypervisor_version'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'local_gb'"
op|':'
number|'6'
op|','
nl|'\n'
string|"'free_ram_mb'"
op|':'
number|'256'
op|','
comment|'# 512 total - 256 for possible confirm of new'
nl|'\n'
string|"'memory_mb_used'"
op|':'
number|'256'
op|','
comment|'# 256 possible confirmed amount'
nl|'\n'
string|"'pci_device_pools'"
op|':'
name|'objects'
op|'.'
name|'PciDevicePoolList'
op|'('
op|')'
op|','
nl|'\n'
string|"'vcpus_used'"
op|':'
number|'2'
op|','
nl|'\n'
string|"'hypervisor_type'"
op|':'
string|"'fake'"
op|','
nl|'\n'
string|"'local_gb_used'"
op|':'
number|'5'
op|','
nl|'\n'
string|"'memory_mb'"
op|':'
number|'512'
op|','
nl|'\n'
string|"'current_workload'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'vcpus'"
op|':'
number|'4'
op|','
nl|'\n'
string|"'running_vms'"
op|':'
number|'0'
nl|'\n'
op|'}'
newline|'\n'
name|'_update_compute_node'
op|'('
name|'expected_resources'
op|','
op|'**'
name|'vals'
op|')'
newline|'\n'
name|'update_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'mock'
op|'.'
name|'sentinel'
op|'.'
name|'ctx'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertTrue'
op|'('
name|'obj_base'
op|'.'
name|'obj_equal_prims'
op|'('
name|'expected_resources'
op|','
nl|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|')'
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.MigrationContext.get_by_instance_uuid'"
op|','
nl|'\n'
name|'return_value'
op|'='
name|'None'
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.ComputeNode.get_by_host_and_nodename'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.MigrationList.get_in_progress_by_host_and_node'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.Instance.get_by_uuid'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.InstanceList.get_by_host_and_node'"
op|')'
newline|'\n'
DECL|member|test_some_instances_source_and_dest_migration
name|'def'
name|'test_some_instances_source_and_dest_migration'
op|'('
name|'self'
op|','
name|'get_mock'
op|','
nl|'\n'
name|'get_inst_mock'
op|','
name|'migr_mock'
op|','
nl|'\n'
name|'get_cn_mock'
op|','
nl|'\n'
name|'get_mig_ctxt_mock'
op|')'
op|':'
newline|'\n'
comment|'# We test the behavior of update_available_resource() when'
nl|'\n'
comment|'# there is an active migration that involves this compute node'
nl|'\n'
comment|'# as the destination host AND the source host, and the resource'
nl|'\n'
comment|'# tracker has a few instances assigned to it, including the'
nl|'\n'
comment|'# instance that is resizing to this same compute node. The tracking'
nl|'\n'
comment|'# of resource amounts takes into account both the old and new'
nl|'\n'
comment|'# resize instance types as taking up space on the node.'
nl|'\n'
indent|'        '
name|'self'
op|'.'
name|'flags'
op|'('
name|'reserved_host_disk_mb'
op|'='
number|'0'
op|','
nl|'\n'
name|'reserved_host_memory_mb'
op|'='
number|'0'
op|')'
newline|'\n'
nl|'\n'
comment|'# Setup virt resources to match used resources to number'
nl|'\n'
comment|'# of defined instances on the hypervisor'
nl|'\n'
name|'virt_resources'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'_VIRT_DRIVER_AVAIL_RESOURCES'
op|')'
newline|'\n'
name|'virt_resources'
op|'.'
name|'update'
op|'('
name|'vcpus_used'
op|'='
number|'4'
op|','
nl|'\n'
name|'memory_mb_used'
op|'='
number|'512'
op|','
nl|'\n'
name|'local_gb_used'
op|'='
number|'7'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'_setup_rt'
op|'('
name|'virt_resources'
op|'='
name|'virt_resources'
op|')'
newline|'\n'
nl|'\n'
name|'migr_obj'
op|'='
name|'_MIGRATION_FIXTURES'
op|'['
string|"'source-and-dest'"
op|']'
newline|'\n'
name|'migr_mock'
op|'.'
name|'return_value'
op|'='
op|'['
name|'migr_obj'
op|']'
newline|'\n'
name|'inst_uuid'
op|'='
name|'migr_obj'
op|'.'
name|'instance_uuid'
newline|'\n'
comment|'# The resizing instance has already had its instance type'
nl|'\n'
comment|'# changed to the *new* instance type (the bigger one, instance type 2)'
nl|'\n'
name|'resizing_instance'
op|'='
name|'_MIGRATION_INSTANCE_FIXTURES'
op|'['
name|'inst_uuid'
op|']'
op|'.'
name|'obj_clone'
op|'('
op|')'
newline|'\n'
name|'resizing_instance'
op|'.'
name|'migration_context'
op|'='
op|'('
nl|'\n'
name|'_MIGRATION_CONTEXT_FIXTURES'
op|'['
name|'resizing_instance'
op|'.'
name|'uuid'
op|']'
op|')'
newline|'\n'
name|'all_instances'
op|'='
name|'_INSTANCE_FIXTURES'
op|'+'
op|'['
name|'resizing_instance'
op|']'
newline|'\n'
name|'get_mock'
op|'.'
name|'return_value'
op|'='
name|'all_instances'
newline|'\n'
name|'get_inst_mock'
op|'.'
name|'return_value'
op|'='
name|'resizing_instance'
newline|'\n'
name|'get_cn_mock'
op|'.'
name|'return_value'
op|'='
name|'_COMPUTE_NODE_FIXTURES'
op|'['
number|'0'
op|']'
newline|'\n'
nl|'\n'
name|'update_mock'
op|'='
name|'self'
op|'.'
name|'_update_available_resources'
op|'('
op|')'
newline|'\n'
nl|'\n'
name|'get_cn_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'mock'
op|'.'
name|'sentinel'
op|'.'
name|'ctx'
op|','
string|"'fake-host'"
op|','
nl|'\n'
string|"'fake-node'"
op|')'
newline|'\n'
name|'expected_resources'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'_COMPUTE_NODE_FIXTURES'
op|'['
number|'0'
op|']'
op|')'
newline|'\n'
name|'vals'
op|'='
op|'{'
nl|'\n'
comment|'# host is added in update_available_resources()'
nl|'\n'
comment|'# before calling _update()'
nl|'\n'
string|"'host'"
op|':'
string|"'fake-host'"
op|','
nl|'\n'
string|"'host_ip'"
op|':'
string|"'1.1.1.1'"
op|','
nl|'\n'
string|"'numa_topology'"
op|':'
name|'None'
op|','
nl|'\n'
string|"'metrics'"
op|':'
string|"'[]'"
op|','
nl|'\n'
string|"'cpu_info'"
op|':'
string|"''"
op|','
nl|'\n'
string|"'hypervisor_hostname'"
op|':'
string|"'fakehost'"
op|','
nl|'\n'
comment|'# 6 total - 1G existing - 5G new flav - 1G old flav'
nl|'\n'
string|"'free_disk_gb'"
op|':'
op|'-'
number|'1'
op|','
nl|'\n'
string|"'hypervisor_version'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'local_gb'"
op|':'
number|'6'
op|','
nl|'\n'
comment|'# 512 total - 128 existing - 256 new flav - 128 old flav'
nl|'\n'
string|"'free_ram_mb'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'memory_mb_used'"
op|':'
number|'512'
op|','
comment|'# 128 exist + 256 new flav + 128 old flav'
nl|'\n'
string|"'pci_device_pools'"
op|':'
name|'objects'
op|'.'
name|'PciDevicePoolList'
op|'('
op|')'
op|','
nl|'\n'
string|"'vcpus_used'"
op|':'
number|'4'
op|','
nl|'\n'
string|"'hypervisor_type'"
op|':'
string|"'fake'"
op|','
nl|'\n'
string|"'local_gb_used'"
op|':'
number|'7'
op|','
comment|'# 1G existing, 5G new flav + 1 old flav'
nl|'\n'
string|"'memory_mb'"
op|':'
number|'512'
op|','
nl|'\n'
string|"'current_workload'"
op|':'
number|'1'
op|','
comment|'# One migrating instance...'
nl|'\n'
string|"'vcpus'"
op|':'
number|'4'
op|','
nl|'\n'
string|"'running_vms'"
op|':'
number|'2'
nl|'\n'
op|'}'
newline|'\n'
name|'_update_compute_node'
op|'('
name|'expected_resources'
op|','
op|'**'
name|'vals'
op|')'
newline|'\n'
name|'update_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'mock'
op|'.'
name|'sentinel'
op|'.'
name|'ctx'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertTrue'
op|'('
name|'obj_base'
op|'.'
name|'obj_equal_prims'
op|'('
name|'expected_resources'
op|','
nl|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|')'
op|')'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|class|TestInitComputeNode
dedent|''
dedent|''
name|'class'
name|'TestInitComputeNode'
op|'('
name|'BaseTestCase'
op|')'
op|':'
newline|'\n'
nl|'\n'
indent|'    '
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.ComputeNode.create'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.Service.get_by_compute_host'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.ComputeNode.get_by_host_and_nodename'"
op|')'
newline|'\n'
DECL|member|test_no_op_init_compute_node
name|'def'
name|'test_no_op_init_compute_node'
op|'('
name|'self'
op|','
name|'get_mock'
op|','
name|'service_mock'
op|','
nl|'\n'
name|'create_mock'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'self'
op|'.'
name|'_setup_rt'
op|'('
op|')'
newline|'\n'
nl|'\n'
name|'resources'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'_VIRT_DRIVER_AVAIL_RESOURCES'
op|')'
newline|'\n'
name|'compute_node'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'_COMPUTE_NODE_FIXTURES'
op|'['
number|'0'
op|']'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|'='
name|'compute_node'
newline|'\n'
nl|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'_init_compute_node'
op|'('
name|'mock'
op|'.'
name|'sentinel'
op|'.'
name|'ctx'
op|','
name|'resources'
op|')'
newline|'\n'
nl|'\n'
name|'self'
op|'.'
name|'assertFalse'
op|'('
name|'service_mock'
op|'.'
name|'called'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertFalse'
op|'('
name|'get_mock'
op|'.'
name|'called'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertFalse'
op|'('
name|'create_mock'
op|'.'
name|'called'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertFalse'
op|'('
name|'self'
op|'.'
name|'rt'
op|'.'
name|'disabled'
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.ComputeNode.create'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.ComputeNode.get_by_host_and_nodename'"
op|')'
newline|'\n'
DECL|member|test_compute_node_loaded
name|'def'
name|'test_compute_node_loaded'
op|'('
name|'self'
op|','
name|'get_mock'
op|','
name|'create_mock'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'self'
op|'.'
name|'_setup_rt'
op|'('
op|')'
newline|'\n'
nl|'\n'
DECL|function|fake_get_node
name|'def'
name|'fake_get_node'
op|'('
name|'_ctx'
op|','
name|'host'
op|','
name|'node'
op|')'
op|':'
newline|'\n'
indent|'            '
name|'res'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'_COMPUTE_NODE_FIXTURES'
op|'['
number|'0'
op|']'
op|')'
newline|'\n'
name|'return'
name|'res'
newline|'\n'
nl|'\n'
dedent|''
name|'get_mock'
op|'.'
name|'side_effect'
op|'='
name|'fake_get_node'
newline|'\n'
name|'resources'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'_VIRT_DRIVER_AVAIL_RESOURCES'
op|')'
newline|'\n'
nl|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'_init_compute_node'
op|'('
name|'mock'
op|'.'
name|'sentinel'
op|'.'
name|'ctx'
op|','
name|'resources'
op|')'
newline|'\n'
nl|'\n'
name|'get_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'mock'
op|'.'
name|'sentinel'
op|'.'
name|'ctx'
op|','
string|"'fake-host'"
op|','
nl|'\n'
string|"'fake-node'"
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertFalse'
op|'('
name|'create_mock'
op|'.'
name|'called'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertFalse'
op|'('
name|'self'
op|'.'
name|'rt'
op|'.'
name|'disabled'
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.ComputeNode.create'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.ComputeNode.get_by_host_and_nodename'"
op|')'
newline|'\n'
DECL|member|test_compute_node_created_on_empty
name|'def'
name|'test_compute_node_created_on_empty'
op|'('
name|'self'
op|','
name|'get_mock'
op|','
name|'create_mock'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'self'
op|'.'
name|'_setup_rt'
op|'('
op|')'
newline|'\n'
nl|'\n'
name|'get_mock'
op|'.'
name|'side_effect'
op|'='
name|'exc'
op|'.'
name|'NotFound'
newline|'\n'
name|'cpu_alloc_ratio'
op|'='
number|'1.0'
newline|'\n'
name|'ram_alloc_ratio'
op|'='
number|'1.0'
newline|'\n'
name|'disk_alloc_ratio'
op|'='
number|'1.0'
newline|'\n'
nl|'\n'
name|'resources'
op|'='
op|'{'
nl|'\n'
string|"'host_ip'"
op|':'
string|"'1.1.1.1'"
op|','
nl|'\n'
string|"'numa_topology'"
op|':'
name|'None'
op|','
nl|'\n'
string|"'metrics'"
op|':'
string|"'[]'"
op|','
nl|'\n'
string|"'cpu_info'"
op|':'
string|"''"
op|','
nl|'\n'
string|"'hypervisor_hostname'"
op|':'
string|"'fakehost'"
op|','
nl|'\n'
string|"'free_disk_gb'"
op|':'
number|'6'
op|','
nl|'\n'
string|"'hypervisor_version'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'local_gb'"
op|':'
number|'6'
op|','
nl|'\n'
string|"'free_ram_mb'"
op|':'
number|'512'
op|','
nl|'\n'
string|"'memory_mb_used'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'pci_device_pools'"
op|':'
op|'['
op|']'
op|','
nl|'\n'
string|"'vcpus_used'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'hypervisor_type'"
op|':'
string|"'fake'"
op|','
nl|'\n'
string|"'local_gb_used'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'memory_mb'"
op|':'
number|'512'
op|','
nl|'\n'
string|"'current_workload'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'vcpus'"
op|':'
number|'4'
op|','
nl|'\n'
string|"'running_vms'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'pci_passthrough_devices'"
op|':'
string|"'[]'"
nl|'\n'
op|'}'
newline|'\n'
comment|'# The expected compute represents the initial values used'
nl|'\n'
comment|'# when creating a compute node.'
nl|'\n'
name|'expected_compute'
op|'='
name|'objects'
op|'.'
name|'ComputeNode'
op|'('
nl|'\n'
name|'host_ip'
op|'='
name|'resources'
op|'['
string|"'host_ip'"
op|']'
op|','
nl|'\n'
name|'vcpus'
op|'='
name|'resources'
op|'['
string|"'vcpus'"
op|']'
op|','
nl|'\n'
name|'memory_mb'
op|'='
name|'resources'
op|'['
string|"'memory_mb'"
op|']'
op|','
nl|'\n'
name|'local_gb'
op|'='
name|'resources'
op|'['
string|"'local_gb'"
op|']'
op|','
nl|'\n'
name|'cpu_info'
op|'='
name|'resources'
op|'['
string|"'cpu_info'"
op|']'
op|','
nl|'\n'
name|'vcpus_used'
op|'='
name|'resources'
op|'['
string|"'vcpus_used'"
op|']'
op|','
nl|'\n'
name|'memory_mb_used'
op|'='
name|'resources'
op|'['
string|"'memory_mb_used'"
op|']'
op|','
nl|'\n'
name|'local_gb_used'
op|'='
name|'resources'
op|'['
string|"'local_gb_used'"
op|']'
op|','
nl|'\n'
name|'numa_topology'
op|'='
name|'resources'
op|'['
string|"'numa_topology'"
op|']'
op|','
nl|'\n'
name|'hypervisor_type'
op|'='
name|'resources'
op|'['
string|"'hypervisor_type'"
op|']'
op|','
nl|'\n'
name|'hypervisor_version'
op|'='
name|'resources'
op|'['
string|"'hypervisor_version'"
op|']'
op|','
nl|'\n'
name|'hypervisor_hostname'
op|'='
name|'resources'
op|'['
string|"'hypervisor_hostname'"
op|']'
op|','
nl|'\n'
comment|'# NOTE(sbauza): ResourceTracker adds host field'
nl|'\n'
name|'host'
op|'='
string|"'fake-host'"
op|','
nl|'\n'
comment|'# NOTE(sbauza): ResourceTracker adds CONF allocation ratios'
nl|'\n'
name|'ram_allocation_ratio'
op|'='
name|'ram_alloc_ratio'
op|','
nl|'\n'
name|'cpu_allocation_ratio'
op|'='
name|'cpu_alloc_ratio'
op|','
nl|'\n'
name|'disk_allocation_ratio'
op|'='
name|'disk_alloc_ratio'
op|','
nl|'\n'
name|'stats'
op|'='
op|'{'
op|'}'
op|','
nl|'\n'
op|')'
newline|'\n'
nl|'\n'
comment|'# Forcing the flags to the values we know'
nl|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'ram_allocation_ratio'
op|'='
name|'ram_alloc_ratio'
newline|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'cpu_allocation_ratio'
op|'='
name|'cpu_alloc_ratio'
newline|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'disk_allocation_ratio'
op|'='
name|'disk_alloc_ratio'
newline|'\n'
nl|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'_init_compute_node'
op|'('
name|'mock'
op|'.'
name|'sentinel'
op|'.'
name|'ctx'
op|','
name|'resources'
op|')'
newline|'\n'
nl|'\n'
name|'self'
op|'.'
name|'assertFalse'
op|'('
name|'self'
op|'.'
name|'rt'
op|'.'
name|'disabled'
op|')'
newline|'\n'
name|'get_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'mock'
op|'.'
name|'sentinel'
op|'.'
name|'ctx'
op|','
string|"'fake-host'"
op|','
nl|'\n'
string|"'fake-node'"
op|')'
newline|'\n'
name|'create_mock'
op|'.'
name|'assert_called_once_with'
op|'('
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertTrue'
op|'('
name|'obj_base'
op|'.'
name|'obj_equal_prims'
op|'('
name|'expected_compute'
op|','
nl|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|')'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_copy_resources_adds_allocation_ratios
dedent|''
name|'def'
name|'test_copy_resources_adds_allocation_ratios'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'self'
op|'.'
name|'flags'
op|'('
name|'cpu_allocation_ratio'
op|'='
number|'4.0'
op|','
name|'ram_allocation_ratio'
op|'='
number|'3.0'
op|','
nl|'\n'
name|'disk_allocation_ratio'
op|'='
number|'2.0'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'_setup_rt'
op|'('
op|')'
newline|'\n'
nl|'\n'
name|'resources'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'_VIRT_DRIVER_AVAIL_RESOURCES'
op|')'
newline|'\n'
name|'compute_node'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'_COMPUTE_NODE_FIXTURES'
op|'['
number|'0'
op|']'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|'='
name|'compute_node'
newline|'\n'
nl|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'_copy_resources'
op|'('
name|'resources'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
number|'4.0'
op|','
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|'.'
name|'cpu_allocation_ratio'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
number|'3.0'
op|','
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|'.'
name|'ram_allocation_ratio'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
number|'2.0'
op|','
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|'.'
name|'disk_allocation_ratio'
op|')'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|class|TestUpdateComputeNode
dedent|''
dedent|''
name|'class'
name|'TestUpdateComputeNode'
op|'('
name|'BaseTestCase'
op|')'
op|':'
newline|'\n'
nl|'\n'
indent|'    '
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.Service.get_by_compute_host'"
op|')'
newline|'\n'
DECL|member|test_existing_compute_node_updated_same_resources
name|'def'
name|'test_existing_compute_node_updated_same_resources'
op|'('
name|'self'
op|','
name|'service_mock'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'self'
op|'.'
name|'_setup_rt'
op|'('
op|')'
newline|'\n'
nl|'\n'
comment|'# This is the same set of resources as the fixture, deliberately. We'
nl|'\n'
comment|'# are checking below to see that update_resource_stats() is not'
nl|'\n'
comment|"# needlessly called when the resources don't actually change."
nl|'\n'
name|'compute'
op|'='
name|'objects'
op|'.'
name|'ComputeNode'
op|'('
nl|'\n'
name|'host_ip'
op|'='
string|"'1.1.1.1'"
op|','
nl|'\n'
name|'numa_topology'
op|'='
name|'None'
op|','
nl|'\n'
name|'metrics'
op|'='
string|"'[]'"
op|','
nl|'\n'
name|'cpu_info'
op|'='
string|"''"
op|','
nl|'\n'
name|'hypervisor_hostname'
op|'='
string|"'fakehost'"
op|','
nl|'\n'
name|'free_disk_gb'
op|'='
number|'6'
op|','
nl|'\n'
name|'hypervisor_version'
op|'='
number|'0'
op|','
nl|'\n'
name|'local_gb'
op|'='
number|'6'
op|','
nl|'\n'
name|'free_ram_mb'
op|'='
number|'512'
op|','
nl|'\n'
name|'memory_mb_used'
op|'='
number|'0'
op|','
nl|'\n'
name|'pci_device_pools'
op|'='
name|'objects'
op|'.'
name|'PciDevicePoolList'
op|'('
op|')'
op|','
nl|'\n'
name|'vcpus_used'
op|'='
number|'0'
op|','
nl|'\n'
name|'hypervisor_type'
op|'='
string|"'fake'"
op|','
nl|'\n'
name|'local_gb_used'
op|'='
number|'0'
op|','
nl|'\n'
name|'memory_mb'
op|'='
number|'512'
op|','
nl|'\n'
name|'current_workload'
op|'='
number|'0'
op|','
nl|'\n'
name|'vcpus'
op|'='
number|'4'
op|','
nl|'\n'
name|'running_vms'
op|'='
number|'0'
op|','
nl|'\n'
name|'cpu_allocation_ratio'
op|'='
number|'16.0'
op|','
nl|'\n'
name|'ram_allocation_ratio'
op|'='
number|'1.5'
op|','
nl|'\n'
name|'disk_allocation_ratio'
op|'='
number|'1.0'
op|','
nl|'\n'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|'='
name|'compute'
newline|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'_update'
op|'('
name|'mock'
op|'.'
name|'sentinel'
op|'.'
name|'ctx'
op|')'
newline|'\n'
nl|'\n'
name|'self'
op|'.'
name|'assertFalse'
op|'('
name|'self'
op|'.'
name|'rt'
op|'.'
name|'disabled'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertFalse'
op|'('
name|'service_mock'
op|'.'
name|'called'
op|')'
newline|'\n'
nl|'\n'
comment|'# The above call to _update() will populate the'
nl|'\n'
comment|'# RT.old_resources collection with the resources. Here, we check that'
nl|'\n'
comment|'# if we call _update() again with the same resources, that'
nl|'\n'
comment|"# the scheduler client won't be called again to update those"
nl|'\n'
comment|'# (unchanged) resources for the compute node'
nl|'\n'
name|'self'
op|'.'
name|'sched_client_mock'
op|'.'
name|'reset_mock'
op|'('
op|')'
newline|'\n'
name|'urs_mock'
op|'='
name|'self'
op|'.'
name|'sched_client_mock'
op|'.'
name|'update_resource_stats'
newline|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'_update'
op|'('
name|'mock'
op|'.'
name|'sentinel'
op|'.'
name|'ctx'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertFalse'
op|'('
name|'urs_mock'
op|'.'
name|'called'
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.Service.get_by_compute_host'"
op|')'
newline|'\n'
DECL|member|test_existing_compute_node_updated_new_resources
name|'def'
name|'test_existing_compute_node_updated_new_resources'
op|'('
name|'self'
op|','
name|'service_mock'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'self'
op|'.'
name|'_setup_rt'
op|'('
op|')'
newline|'\n'
nl|'\n'
comment|'# Deliberately changing local_gb_used, vcpus_used, and memory_mb_used'
nl|'\n'
comment|"# below to be different from the compute node fixture's base usages."
nl|'\n'
comment|'# We want to check that the code paths update the stored compute node'
nl|'\n'
comment|'# usage records with what is supplied to _update().'
nl|'\n'
name|'compute'
op|'='
name|'objects'
op|'.'
name|'ComputeNode'
op|'('
nl|'\n'
name|'host'
op|'='
string|"'fake-host'"
op|','
nl|'\n'
name|'host_ip'
op|'='
string|"'1.1.1.1'"
op|','
nl|'\n'
name|'numa_topology'
op|'='
name|'None'
op|','
nl|'\n'
name|'metrics'
op|'='
string|"'[]'"
op|','
nl|'\n'
name|'cpu_info'
op|'='
string|"''"
op|','
nl|'\n'
name|'hypervisor_hostname'
op|'='
string|"'fakehost'"
op|','
nl|'\n'
name|'free_disk_gb'
op|'='
number|'2'
op|','
nl|'\n'
name|'hypervisor_version'
op|'='
number|'0'
op|','
nl|'\n'
name|'local_gb'
op|'='
number|'6'
op|','
nl|'\n'
name|'free_ram_mb'
op|'='
number|'384'
op|','
nl|'\n'
name|'memory_mb_used'
op|'='
number|'128'
op|','
nl|'\n'
name|'pci_device_pools'
op|'='
name|'objects'
op|'.'
name|'PciDevicePoolList'
op|'('
op|')'
op|','
nl|'\n'
name|'vcpus_used'
op|'='
number|'2'
op|','
nl|'\n'
name|'hypervisor_type'
op|'='
string|"'fake'"
op|','
nl|'\n'
name|'local_gb_used'
op|'='
number|'4'
op|','
nl|'\n'
name|'memory_mb'
op|'='
number|'512'
op|','
nl|'\n'
name|'current_workload'
op|'='
number|'0'
op|','
nl|'\n'
name|'vcpus'
op|'='
number|'4'
op|','
nl|'\n'
name|'running_vms'
op|'='
number|'0'
op|','
nl|'\n'
name|'cpu_allocation_ratio'
op|'='
number|'16.0'
op|','
nl|'\n'
name|'ram_allocation_ratio'
op|'='
number|'1.5'
op|','
nl|'\n'
name|'disk_allocation_ratio'
op|'='
number|'1.0'
op|','
nl|'\n'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|'='
name|'compute'
newline|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'_update'
op|'('
name|'mock'
op|'.'
name|'sentinel'
op|'.'
name|'ctx'
op|')'
newline|'\n'
nl|'\n'
name|'self'
op|'.'
name|'assertFalse'
op|'('
name|'self'
op|'.'
name|'rt'
op|'.'
name|'disabled'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertFalse'
op|'('
name|'service_mock'
op|'.'
name|'called'
op|')'
newline|'\n'
name|'urs_mock'
op|'='
name|'self'
op|'.'
name|'sched_client_mock'
op|'.'
name|'update_resource_stats'
newline|'\n'
name|'urs_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|')'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|class|TestInstanceClaim
dedent|''
dedent|''
name|'class'
name|'TestInstanceClaim'
op|'('
name|'BaseTestCase'
op|')'
op|':'
newline|'\n'
nl|'\n'
DECL|member|setUp
indent|'    '
name|'def'
name|'setUp'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'super'
op|'('
name|'TestInstanceClaim'
op|','
name|'self'
op|')'
op|'.'
name|'setUp'
op|'('
op|')'
newline|'\n'
name|'self'
op|'.'
name|'flags'
op|'('
name|'reserved_host_disk_mb'
op|'='
number|'0'
op|','
name|'reserved_host_memory_mb'
op|'='
number|'0'
op|')'
newline|'\n'
nl|'\n'
name|'self'
op|'.'
name|'_setup_rt'
op|'('
op|')'
newline|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'_COMPUTE_NODE_FIXTURES'
op|'['
number|'0'
op|']'
op|')'
newline|'\n'
nl|'\n'
comment|'# not using mock.sentinel.ctx because instance_claim calls #elevated'
nl|'\n'
name|'self'
op|'.'
name|'ctx'
op|'='
name|'mock'
op|'.'
name|'MagicMock'
op|'('
op|')'
newline|'\n'
name|'self'
op|'.'
name|'elevated'
op|'='
name|'mock'
op|'.'
name|'MagicMock'
op|'('
op|')'
newline|'\n'
name|'self'
op|'.'
name|'ctx'
op|'.'
name|'elevated'
op|'.'
name|'return_value'
op|'='
name|'self'
op|'.'
name|'elevated'
newline|'\n'
nl|'\n'
name|'self'
op|'.'
name|'instance'
op|'='
name|'_INSTANCE_FIXTURES'
op|'['
number|'0'
op|']'
op|'.'
name|'obj_clone'
op|'('
op|')'
newline|'\n'
nl|'\n'
DECL|member|assertEqualNUMAHostTopology
dedent|''
name|'def'
name|'assertEqualNUMAHostTopology'
op|'('
name|'self'
op|','
name|'expected'
op|','
name|'got'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'attrs'
op|'='
op|'('
string|"'cpuset'"
op|','
string|"'memory'"
op|','
string|"'id'"
op|','
string|"'cpu_usage'"
op|','
string|"'memory_usage'"
op|')'
newline|'\n'
name|'if'
name|'None'
name|'in'
op|'('
name|'expected'
op|','
name|'got'
op|')'
op|':'
newline|'\n'
indent|'            '
name|'if'
name|'expected'
op|'!='
name|'got'
op|':'
newline|'\n'
indent|'                '
name|'raise'
name|'AssertionError'
op|'('
string|'"Topologies don\'t match. Expected: "'
nl|'\n'
string|'"%(expected)s, but got: %(got)s"'
op|'%'
nl|'\n'
op|'{'
string|"'expected'"
op|':'
name|'expected'
op|','
string|"'got'"
op|':'
name|'got'
op|'}'
op|')'
newline|'\n'
dedent|''
name|'else'
op|':'
newline|'\n'
indent|'                '
name|'return'
newline|'\n'
nl|'\n'
dedent|''
dedent|''
name|'if'
name|'len'
op|'('
name|'expected'
op|')'
op|'!='
name|'len'
op|'('
name|'got'
op|')'
op|':'
newline|'\n'
indent|'            '
name|'raise'
name|'AssertionError'
op|'('
string|'"Topologies don\'t match due to different "'
nl|'\n'
string|'"number of cells. Expected: "'
nl|'\n'
string|'"%(expected)s, but got: %(got)s"'
op|'%'
nl|'\n'
op|'{'
string|"'expected'"
op|':'
name|'expected'
op|','
string|"'got'"
op|':'
name|'got'
op|'}'
op|')'
newline|'\n'
dedent|''
name|'for'
name|'exp_cell'
op|','
name|'got_cell'
name|'in'
name|'zip'
op|'('
name|'expected'
op|'.'
name|'cells'
op|','
name|'got'
op|'.'
name|'cells'
op|')'
op|':'
newline|'\n'
indent|'            '
name|'for'
name|'attr'
name|'in'
name|'attrs'
op|':'
newline|'\n'
indent|'                '
name|'if'
name|'getattr'
op|'('
name|'exp_cell'
op|','
name|'attr'
op|')'
op|'!='
name|'getattr'
op|'('
name|'got_cell'
op|','
name|'attr'
op|')'
op|':'
newline|'\n'
indent|'                    '
name|'raise'
name|'AssertionError'
op|'('
string|'"Topologies don\'t match. Expected: "'
nl|'\n'
string|'"%(expected)s, but got: %(got)s"'
op|'%'
nl|'\n'
op|'{'
string|"'expected'"
op|':'
name|'expected'
op|','
string|"'got'"
op|':'
name|'got'
op|'}'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_claim_disabled
dedent|''
dedent|''
dedent|''
dedent|''
name|'def'
name|'test_claim_disabled'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|'='
name|'None'
newline|'\n'
name|'self'
op|'.'
name|'assertTrue'
op|'('
name|'self'
op|'.'
name|'rt'
op|'.'
name|'disabled'
op|')'
newline|'\n'
nl|'\n'
name|'with'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'self'
op|'.'
name|'instance'
op|','
string|"'save'"
op|')'
op|':'
newline|'\n'
indent|'            '
name|'claim'
op|'='
name|'self'
op|'.'
name|'rt'
op|'.'
name|'instance_claim'
op|'('
name|'mock'
op|'.'
name|'sentinel'
op|'.'
name|'ctx'
op|','
name|'self'
op|'.'
name|'instance'
op|','
nl|'\n'
name|'None'
op|')'
newline|'\n'
nl|'\n'
dedent|''
name|'self'
op|'.'
name|'assertEqual'
op|'('
name|'self'
op|'.'
name|'rt'
op|'.'
name|'host'
op|','
name|'self'
op|'.'
name|'instance'
op|'.'
name|'host'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
name|'self'
op|'.'
name|'rt'
op|'.'
name|'host'
op|','
name|'self'
op|'.'
name|'instance'
op|'.'
name|'launched_on'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
name|'self'
op|'.'
name|'rt'
op|'.'
name|'nodename'
op|','
name|'self'
op|'.'
name|'instance'
op|'.'
name|'node'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertIsInstance'
op|'('
name|'claim'
op|','
name|'claims'
op|'.'
name|'NopClaim'
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.InstancePCIRequests.get_by_instance_uuid'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.MigrationList.get_in_progress_by_host_and_node'"
op|')'
newline|'\n'
DECL|member|test_update_usage_with_claim
name|'def'
name|'test_update_usage_with_claim'
op|'('
name|'self'
op|','
name|'migr_mock'
op|','
name|'pci_mock'
op|')'
op|':'
newline|'\n'
comment|'# Test that RT.update_usage() only changes the compute node'
nl|'\n'
comment|'# resources if there has been a claim first.'
nl|'\n'
indent|'        '
name|'pci_mock'
op|'.'
name|'return_value'
op|'='
name|'objects'
op|'.'
name|'InstancePCIRequests'
op|'('
name|'requests'
op|'='
op|'['
op|']'
op|')'
newline|'\n'
nl|'\n'
name|'expected'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'_COMPUTE_NODE_FIXTURES'
op|'['
number|'0'
op|']'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'update_usage'
op|'('
name|'self'
op|'.'
name|'ctx'
op|','
name|'self'
op|'.'
name|'instance'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertTrue'
op|'('
name|'obj_base'
op|'.'
name|'obj_equal_prims'
op|'('
name|'expected'
op|','
nl|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|')'
op|')'
newline|'\n'
nl|'\n'
name|'disk_used'
op|'='
name|'self'
op|'.'
name|'instance'
op|'.'
name|'root_gb'
op|'+'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'ephemeral_gb'
newline|'\n'
name|'vals'
op|'='
op|'{'
nl|'\n'
string|"'local_gb_used'"
op|':'
name|'disk_used'
op|','
nl|'\n'
string|"'memory_mb_used'"
op|':'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'memory_mb'
op|','
nl|'\n'
string|"'free_disk_gb'"
op|':'
name|'expected'
op|'.'
name|'local_gb'
op|'-'
name|'disk_used'
op|','
nl|'\n'
string|'"free_ram_mb"'
op|':'
name|'expected'
op|'.'
name|'memory_mb'
op|'-'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'memory_mb'
op|','
nl|'\n'
string|"'running_vms'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'vcpus_used'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'pci_device_pools'"
op|':'
name|'objects'
op|'.'
name|'PciDevicePoolList'
op|'('
op|')'
op|','
nl|'\n'
string|"'stats'"
op|':'
op|'{'
nl|'\n'
string|"'io_workload'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'num_instances'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'num_task_None'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'num_os_type_'"
op|'+'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'os_type'
op|':'
number|'1'
op|','
nl|'\n'
string|"'num_proj_'"
op|'+'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'project_id'
op|':'
number|'1'
op|','
nl|'\n'
string|"'num_vm_'"
op|'+'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'vm_state'
op|':'
number|'1'
op|','
nl|'\n'
op|'}'
op|','
nl|'\n'
op|'}'
newline|'\n'
name|'_update_compute_node'
op|'('
name|'expected'
op|','
op|'**'
name|'vals'
op|')'
newline|'\n'
name|'with'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'self'
op|'.'
name|'rt'
op|','
string|"'_update'"
op|')'
name|'as'
name|'update_mock'
op|':'
newline|'\n'
indent|'            '
name|'with'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'self'
op|'.'
name|'instance'
op|','
string|"'save'"
op|')'
op|':'
newline|'\n'
indent|'                '
name|'self'
op|'.'
name|'rt'
op|'.'
name|'instance_claim'
op|'('
name|'self'
op|'.'
name|'ctx'
op|','
name|'self'
op|'.'
name|'instance'
op|','
name|'None'
op|')'
newline|'\n'
dedent|''
name|'update_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'self'
op|'.'
name|'elevated'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertTrue'
op|'('
name|'obj_base'
op|'.'
name|'obj_equal_prims'
op|'('
name|'expected'
op|','
nl|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|')'
op|')'
newline|'\n'
nl|'\n'
dedent|''
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.InstancePCIRequests.get_by_instance_uuid'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.MigrationList.get_in_progress_by_host_and_node'"
op|')'
newline|'\n'
DECL|member|test_update_usage_removed
name|'def'
name|'test_update_usage_removed'
op|'('
name|'self'
op|','
name|'migr_mock'
op|','
name|'pci_mock'
op|')'
op|':'
newline|'\n'
comment|'# Test that RT.update_usage() removes the instance when update is'
nl|'\n'
comment|'# called in a removed state'
nl|'\n'
indent|'        '
name|'pci_mock'
op|'.'
name|'return_value'
op|'='
name|'objects'
op|'.'
name|'InstancePCIRequests'
op|'('
name|'requests'
op|'='
op|'['
op|']'
op|')'
newline|'\n'
nl|'\n'
name|'expected'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'_COMPUTE_NODE_FIXTURES'
op|'['
number|'0'
op|']'
op|')'
newline|'\n'
name|'disk_used'
op|'='
name|'self'
op|'.'
name|'instance'
op|'.'
name|'root_gb'
op|'+'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'ephemeral_gb'
newline|'\n'
name|'vals'
op|'='
op|'{'
nl|'\n'
string|"'local_gb_used'"
op|':'
name|'disk_used'
op|','
nl|'\n'
string|"'memory_mb_used'"
op|':'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'memory_mb'
op|','
nl|'\n'
string|"'free_disk_gb'"
op|':'
name|'expected'
op|'.'
name|'local_gb'
op|'-'
name|'disk_used'
op|','
nl|'\n'
string|'"free_ram_mb"'
op|':'
name|'expected'
op|'.'
name|'memory_mb'
op|'-'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'memory_mb'
op|','
nl|'\n'
string|"'running_vms'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'vcpus_used'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'pci_device_pools'"
op|':'
name|'objects'
op|'.'
name|'PciDevicePoolList'
op|'('
op|')'
op|','
nl|'\n'
string|"'stats'"
op|':'
op|'{'
nl|'\n'
string|"'io_workload'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'num_instances'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'num_task_None'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'num_os_type_'"
op|'+'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'os_type'
op|':'
number|'1'
op|','
nl|'\n'
string|"'num_proj_'"
op|'+'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'project_id'
op|':'
number|'1'
op|','
nl|'\n'
string|"'num_vm_'"
op|'+'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'vm_state'
op|':'
number|'1'
op|','
nl|'\n'
op|'}'
op|','
nl|'\n'
op|'}'
newline|'\n'
name|'_update_compute_node'
op|'('
name|'expected'
op|','
op|'**'
name|'vals'
op|')'
newline|'\n'
name|'with'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'self'
op|'.'
name|'rt'
op|','
string|"'_update'"
op|')'
name|'as'
name|'update_mock'
op|':'
newline|'\n'
indent|'            '
name|'with'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'self'
op|'.'
name|'instance'
op|','
string|"'save'"
op|')'
op|':'
newline|'\n'
indent|'                '
name|'self'
op|'.'
name|'rt'
op|'.'
name|'instance_claim'
op|'('
name|'self'
op|'.'
name|'ctx'
op|','
name|'self'
op|'.'
name|'instance'
op|','
name|'None'
op|')'
newline|'\n'
dedent|''
name|'update_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'self'
op|'.'
name|'elevated'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertTrue'
op|'('
name|'obj_base'
op|'.'
name|'obj_equal_prims'
op|'('
name|'expected'
op|','
nl|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|')'
op|')'
newline|'\n'
nl|'\n'
dedent|''
name|'expected_updated'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'_COMPUTE_NODE_FIXTURES'
op|'['
number|'0'
op|']'
op|')'
newline|'\n'
name|'vals'
op|'='
op|'{'
nl|'\n'
string|"'pci_device_pools'"
op|':'
name|'objects'
op|'.'
name|'PciDevicePoolList'
op|'('
op|')'
op|','
nl|'\n'
string|"'stats'"
op|':'
op|'{'
nl|'\n'
string|"'io_workload'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'num_instances'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'num_task_None'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'num_os_type_'"
op|'+'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'os_type'
op|':'
number|'0'
op|','
nl|'\n'
string|"'num_proj_'"
op|'+'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'project_id'
op|':'
number|'0'
op|','
nl|'\n'
string|"'num_vm_'"
op|'+'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'vm_state'
op|':'
number|'0'
op|','
nl|'\n'
op|'}'
op|','
nl|'\n'
op|'}'
newline|'\n'
name|'_update_compute_node'
op|'('
name|'expected_updated'
op|','
op|'**'
name|'vals'
op|')'
newline|'\n'
nl|'\n'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'vm_state'
op|'='
name|'vm_states'
op|'.'
name|'SHELVED_OFFLOADED'
newline|'\n'
name|'with'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'self'
op|'.'
name|'rt'
op|','
string|"'_update'"
op|')'
name|'as'
name|'update_mock'
op|':'
newline|'\n'
indent|'            '
name|'self'
op|'.'
name|'rt'
op|'.'
name|'update_usage'
op|'('
name|'self'
op|'.'
name|'ctx'
op|','
name|'self'
op|'.'
name|'instance'
op|')'
newline|'\n'
dedent|''
name|'self'
op|'.'
name|'assertTrue'
op|'('
name|'obj_base'
op|'.'
name|'obj_equal_prims'
op|'('
name|'expected_updated'
op|','
nl|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|')'
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.InstancePCIRequests.get_by_instance_uuid'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.MigrationList.get_in_progress_by_host_and_node'"
op|')'
newline|'\n'
DECL|member|test_claim
name|'def'
name|'test_claim'
op|'('
name|'self'
op|','
name|'migr_mock'
op|','
name|'pci_mock'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'self'
op|'.'
name|'assertFalse'
op|'('
name|'self'
op|'.'
name|'rt'
op|'.'
name|'disabled'
op|')'
newline|'\n'
nl|'\n'
name|'pci_mock'
op|'.'
name|'return_value'
op|'='
name|'objects'
op|'.'
name|'InstancePCIRequests'
op|'('
name|'requests'
op|'='
op|'['
op|']'
op|')'
newline|'\n'
nl|'\n'
name|'disk_used'
op|'='
name|'self'
op|'.'
name|'instance'
op|'.'
name|'root_gb'
op|'+'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'ephemeral_gb'
newline|'\n'
name|'expected'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'_COMPUTE_NODE_FIXTURES'
op|'['
number|'0'
op|']'
op|')'
newline|'\n'
name|'vals'
op|'='
op|'{'
nl|'\n'
string|"'local_gb_used'"
op|':'
name|'disk_used'
op|','
nl|'\n'
string|"'memory_mb_used'"
op|':'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'memory_mb'
op|','
nl|'\n'
string|"'free_disk_gb'"
op|':'
name|'expected'
op|'.'
name|'local_gb'
op|'-'
name|'disk_used'
op|','
nl|'\n'
string|'"free_ram_mb"'
op|':'
name|'expected'
op|'.'
name|'memory_mb'
op|'-'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'memory_mb'
op|','
nl|'\n'
string|"'running_vms'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'vcpus_used'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'pci_device_pools'"
op|':'
name|'objects'
op|'.'
name|'PciDevicePoolList'
op|'('
op|')'
op|','
nl|'\n'
string|"'stats'"
op|':'
op|'{'
nl|'\n'
string|"'io_workload'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'num_instances'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'num_task_None'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'num_os_type_'"
op|'+'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'os_type'
op|':'
number|'1'
op|','
nl|'\n'
string|"'num_proj_'"
op|'+'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'project_id'
op|':'
number|'1'
op|','
nl|'\n'
string|"'num_vm_'"
op|'+'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'vm_state'
op|':'
number|'1'
op|','
nl|'\n'
op|'}'
op|','
nl|'\n'
op|'}'
newline|'\n'
name|'_update_compute_node'
op|'('
name|'expected'
op|','
op|'**'
name|'vals'
op|')'
newline|'\n'
name|'with'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'self'
op|'.'
name|'rt'
op|','
string|"'_update'"
op|')'
name|'as'
name|'update_mock'
op|':'
newline|'\n'
indent|'            '
name|'with'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'self'
op|'.'
name|'instance'
op|','
string|"'save'"
op|')'
op|':'
newline|'\n'
indent|'                '
name|'self'
op|'.'
name|'rt'
op|'.'
name|'instance_claim'
op|'('
name|'self'
op|'.'
name|'ctx'
op|','
name|'self'
op|'.'
name|'instance'
op|','
name|'None'
op|')'
newline|'\n'
dedent|''
name|'update_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'self'
op|'.'
name|'elevated'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertTrue'
op|'('
name|'obj_base'
op|'.'
name|'obj_equal_prims'
op|'('
name|'expected'
op|','
nl|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|')'
op|')'
newline|'\n'
nl|'\n'
dedent|''
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.pci.stats.PciDeviceStats.support_requests'"
op|','
nl|'\n'
name|'return_value'
op|'='
name|'True'
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.pci.manager.PciDevTracker.claim_instance'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.InstancePCIRequests.get_by_instance_uuid'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.MigrationList.get_in_progress_by_host_and_node'"
op|')'
newline|'\n'
DECL|member|test_claim_with_pci
name|'def'
name|'test_claim_with_pci'
op|'('
name|'self'
op|','
name|'migr_mock'
op|','
name|'pci_mock'
op|','
nl|'\n'
name|'pci_manager_mock'
op|','
name|'pci_stats_mock'
op|')'
op|':'
newline|'\n'
comment|'# Test that a claim involving PCI requests correctly claims'
nl|'\n'
comment|'# PCI devices on the host and sends an updated pci_device_pools'
nl|'\n'
comment|'# attribute of the ComputeNode object.'
nl|'\n'
indent|'        '
name|'self'
op|'.'
name|'assertFalse'
op|'('
name|'self'
op|'.'
name|'rt'
op|'.'
name|'disabled'
op|')'
newline|'\n'
nl|'\n'
comment|'# TODO(jaypipes): Remove once the PCI tracker is always created'
nl|'\n'
comment|'# upon the resource tracker being initialized...'
nl|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'pci_tracker'
op|'='
name|'pci_manager'
op|'.'
name|'PciDevTracker'
op|'('
name|'mock'
op|'.'
name|'sentinel'
op|'.'
name|'ctx'
op|')'
newline|'\n'
nl|'\n'
name|'pci_pools'
op|'='
name|'objects'
op|'.'
name|'PciDevicePoolList'
op|'('
op|')'
newline|'\n'
name|'pci_manager_mock'
op|'.'
name|'return_value'
op|'='
name|'pci_pools'
newline|'\n'
nl|'\n'
name|'request'
op|'='
name|'objects'
op|'.'
name|'InstancePCIRequest'
op|'('
name|'count'
op|'='
number|'1'
op|','
nl|'\n'
name|'spec'
op|'='
op|'['
op|'{'
string|"'vendor_id'"
op|':'
string|"'v'"
op|','
string|"'product_id'"
op|':'
string|"'p'"
op|'}'
op|']'
op|')'
newline|'\n'
name|'pci_mock'
op|'.'
name|'return_value'
op|'='
name|'objects'
op|'.'
name|'InstancePCIRequests'
op|'('
name|'requests'
op|'='
op|'['
name|'request'
op|']'
op|')'
newline|'\n'
nl|'\n'
name|'disk_used'
op|'='
name|'self'
op|'.'
name|'instance'
op|'.'
name|'root_gb'
op|'+'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'ephemeral_gb'
newline|'\n'
name|'expected'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'_COMPUTE_NODE_FIXTURES'
op|'['
number|'0'
op|']'
op|')'
newline|'\n'
name|'vals'
op|'='
op|'{'
nl|'\n'
string|"'local_gb_used'"
op|':'
name|'disk_used'
op|','
nl|'\n'
string|"'memory_mb_used'"
op|':'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'memory_mb'
op|','
nl|'\n'
string|"'free_disk_gb'"
op|':'
name|'expected'
op|'.'
name|'local_gb'
op|'-'
name|'disk_used'
op|','
nl|'\n'
string|'"free_ram_mb"'
op|':'
name|'expected'
op|'.'
name|'memory_mb'
op|'-'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'memory_mb'
op|','
nl|'\n'
string|"'running_vms'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'vcpus_used'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'pci_device_pools'"
op|':'
name|'pci_pools'
op|','
nl|'\n'
string|"'stats'"
op|':'
op|'{'
nl|'\n'
string|"'io_workload'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'num_instances'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'num_task_None'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'num_os_type_'"
op|'+'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'os_type'
op|':'
number|'1'
op|','
nl|'\n'
string|"'num_proj_'"
op|'+'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'project_id'
op|':'
number|'1'
op|','
nl|'\n'
string|"'num_vm_'"
op|'+'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'vm_state'
op|':'
number|'1'
op|','
nl|'\n'
op|'}'
op|','
nl|'\n'
op|'}'
newline|'\n'
name|'_update_compute_node'
op|'('
name|'expected'
op|','
op|'**'
name|'vals'
op|')'
newline|'\n'
name|'with'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'self'
op|'.'
name|'rt'
op|','
string|"'_update'"
op|')'
name|'as'
name|'update_mock'
op|':'
newline|'\n'
indent|'            '
name|'with'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'self'
op|'.'
name|'instance'
op|','
string|"'save'"
op|')'
op|':'
newline|'\n'
indent|'                '
name|'self'
op|'.'
name|'rt'
op|'.'
name|'instance_claim'
op|'('
name|'self'
op|'.'
name|'ctx'
op|','
name|'self'
op|'.'
name|'instance'
op|','
name|'None'
op|')'
newline|'\n'
dedent|''
name|'update_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'self'
op|'.'
name|'elevated'
op|')'
newline|'\n'
name|'pci_manager_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'mock'
op|'.'
name|'ANY'
op|','
comment|'# context...'
nl|'\n'
name|'pci_mock'
op|'.'
name|'return_value'
op|','
nl|'\n'
name|'None'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertTrue'
op|'('
name|'obj_base'
op|'.'
name|'obj_equal_prims'
op|'('
name|'expected'
op|','
nl|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|')'
op|')'
newline|'\n'
nl|'\n'
dedent|''
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.InstancePCIRequests.get_by_instance_uuid'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.MigrationList.get_in_progress_by_host_and_node'"
op|')'
newline|'\n'
DECL|member|test_claim_abort_context_manager
name|'def'
name|'test_claim_abort_context_manager'
op|'('
name|'self'
op|','
name|'migr_mock'
op|','
name|'pci_mock'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'pci_mock'
op|'.'
name|'return_value'
op|'='
name|'objects'
op|'.'
name|'InstancePCIRequests'
op|'('
name|'requests'
op|'='
op|'['
op|']'
op|')'
newline|'\n'
nl|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
number|'0'
op|','
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|'.'
name|'local_gb_used'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
number|'0'
op|','
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|'.'
name|'memory_mb_used'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
number|'0'
op|','
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|'.'
name|'running_vms'
op|')'
newline|'\n'
nl|'\n'
name|'mock_save'
op|'='
name|'mock'
op|'.'
name|'MagicMock'
op|'('
op|')'
newline|'\n'
name|'mock_clear_numa'
op|'='
name|'mock'
op|'.'
name|'MagicMock'
op|'('
op|')'
newline|'\n'
nl|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'self'
op|'.'
name|'instance'
op|','
string|"'save'"
op|','
name|'mock_save'
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'self'
op|'.'
name|'instance'
op|','
string|"'clear_numa_topology'"
op|','
nl|'\n'
name|'mock_clear_numa'
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'objects'
op|'.'
name|'Instance'
op|','
string|"'obj_clone'"
op|','
nl|'\n'
name|'return_value'
op|'='
name|'self'
op|'.'
name|'instance'
op|')'
newline|'\n'
DECL|function|_doit
name|'def'
name|'_doit'
op|'('
name|'mock_clone'
op|')'
op|':'
newline|'\n'
indent|'            '
name|'with'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'instance_claim'
op|'('
name|'self'
op|'.'
name|'ctx'
op|','
name|'self'
op|'.'
name|'instance'
op|','
name|'None'
op|')'
op|':'
newline|'\n'
comment|'# Raise an exception. Just make sure below that the abort()'
nl|'\n'
comment|'# method of the claim object was called (and the resulting'
nl|'\n'
comment|'# resources reset to the pre-claimed amounts)'
nl|'\n'
indent|'                '
name|'raise'
name|'test'
op|'.'
name|'TestingException'
op|'('
op|')'
newline|'\n'
nl|'\n'
dedent|''
dedent|''
name|'self'
op|'.'
name|'assertRaises'
op|'('
name|'test'
op|'.'
name|'TestingException'
op|','
name|'_doit'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
number|'2'
op|','
name|'mock_save'
op|'.'
name|'call_count'
op|')'
newline|'\n'
name|'mock_clear_numa'
op|'.'
name|'assert_called_once_with'
op|'('
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertIsNone'
op|'('
name|'self'
op|'.'
name|'instance'
op|'.'
name|'host'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertIsNone'
op|'('
name|'self'
op|'.'
name|'instance'
op|'.'
name|'node'
op|')'
newline|'\n'
nl|'\n'
comment|'# Assert that the resources claimed by the Claim() constructor'
nl|'\n'
comment|"# are returned to the resource tracker due to the claim's abort()"
nl|'\n'
comment|'# method being called when triggered by the exception raised above.'
nl|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
number|'0'
op|','
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|'.'
name|'local_gb_used'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
number|'0'
op|','
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|'.'
name|'memory_mb_used'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
number|'0'
op|','
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|'.'
name|'running_vms'
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.InstancePCIRequests.get_by_instance_uuid'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.MigrationList.get_in_progress_by_host_and_node'"
op|')'
newline|'\n'
DECL|member|test_claim_abort
name|'def'
name|'test_claim_abort'
op|'('
name|'self'
op|','
name|'migr_mock'
op|','
name|'pci_mock'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'pci_mock'
op|'.'
name|'return_value'
op|'='
name|'objects'
op|'.'
name|'InstancePCIRequests'
op|'('
name|'requests'
op|'='
op|'['
op|']'
op|')'
newline|'\n'
name|'disk_used'
op|'='
name|'self'
op|'.'
name|'instance'
op|'.'
name|'root_gb'
op|'+'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'ephemeral_gb'
newline|'\n'
nl|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'objects'
op|'.'
name|'Instance'
op|','
string|"'obj_clone'"
op|','
nl|'\n'
name|'return_value'
op|'='
name|'self'
op|'.'
name|'instance'
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'self'
op|'.'
name|'instance'
op|','
string|"'save'"
op|')'
newline|'\n'
DECL|function|_claim
name|'def'
name|'_claim'
op|'('
name|'mock_save'
op|','
name|'mock_clone'
op|')'
op|':'
newline|'\n'
indent|'            '
name|'return'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'instance_claim'
op|'('
name|'self'
op|'.'
name|'ctx'
op|','
name|'self'
op|'.'
name|'instance'
op|','
name|'None'
op|')'
newline|'\n'
nl|'\n'
dedent|''
name|'claim'
op|'='
name|'_claim'
op|'('
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
name|'disk_used'
op|','
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|'.'
name|'local_gb_used'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
name|'self'
op|'.'
name|'instance'
op|'.'
name|'memory_mb'
op|','
nl|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|'.'
name|'memory_mb_used'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
number|'1'
op|','
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|'.'
name|'running_vms'
op|')'
newline|'\n'
nl|'\n'
name|'mock_save'
op|'='
name|'mock'
op|'.'
name|'MagicMock'
op|'('
op|')'
newline|'\n'
name|'mock_clear_numa'
op|'='
name|'mock'
op|'.'
name|'MagicMock'
op|'('
op|')'
newline|'\n'
nl|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'self'
op|'.'
name|'instance'
op|','
string|"'save'"
op|','
name|'mock_save'
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'self'
op|'.'
name|'instance'
op|','
string|"'clear_numa_topology'"
op|','
nl|'\n'
name|'mock_clear_numa'
op|')'
newline|'\n'
DECL|function|_abort
name|'def'
name|'_abort'
op|'('
op|')'
op|':'
newline|'\n'
indent|'            '
name|'claim'
op|'.'
name|'abort'
op|'('
op|')'
newline|'\n'
nl|'\n'
dedent|''
name|'_abort'
op|'('
op|')'
newline|'\n'
name|'mock_save'
op|'.'
name|'assert_called_once_with'
op|'('
op|')'
newline|'\n'
name|'mock_clear_numa'
op|'.'
name|'assert_called_once_with'
op|'('
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertIsNone'
op|'('
name|'self'
op|'.'
name|'instance'
op|'.'
name|'host'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertIsNone'
op|'('
name|'self'
op|'.'
name|'instance'
op|'.'
name|'node'
op|')'
newline|'\n'
nl|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
number|'0'
op|','
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|'.'
name|'local_gb_used'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
number|'0'
op|','
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|'.'
name|'memory_mb_used'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
number|'0'
op|','
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|'.'
name|'running_vms'
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.InstancePCIRequests.get_by_instance_uuid'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.MigrationList.get_in_progress_by_host_and_node'"
op|')'
newline|'\n'
DECL|member|test_claim_limits
name|'def'
name|'test_claim_limits'
op|'('
name|'self'
op|','
name|'migr_mock'
op|','
name|'pci_mock'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'self'
op|'.'
name|'assertFalse'
op|'('
name|'self'
op|'.'
name|'rt'
op|'.'
name|'disabled'
op|')'
newline|'\n'
nl|'\n'
name|'pci_mock'
op|'.'
name|'return_value'
op|'='
name|'objects'
op|'.'
name|'InstancePCIRequests'
op|'('
name|'requests'
op|'='
op|'['
op|']'
op|')'
newline|'\n'
nl|'\n'
name|'good_limits'
op|'='
op|'{'
nl|'\n'
string|"'memory_mb'"
op|':'
name|'_COMPUTE_NODE_FIXTURES'
op|'['
number|'0'
op|']'
op|'.'
name|'memory_mb'
op|','
nl|'\n'
string|"'disk_gb'"
op|':'
name|'_COMPUTE_NODE_FIXTURES'
op|'['
number|'0'
op|']'
op|'.'
name|'local_gb'
op|','
nl|'\n'
string|"'vcpu'"
op|':'
name|'_COMPUTE_NODE_FIXTURES'
op|'['
number|'0'
op|']'
op|'.'
name|'vcpus'
op|','
nl|'\n'
op|'}'
newline|'\n'
name|'for'
name|'key'
name|'in'
name|'good_limits'
op|'.'
name|'keys'
op|'('
op|')'
op|':'
newline|'\n'
indent|'            '
name|'bad_limits'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'good_limits'
op|')'
newline|'\n'
name|'bad_limits'
op|'['
name|'key'
op|']'
op|'='
number|'0'
newline|'\n'
nl|'\n'
name|'self'
op|'.'
name|'assertRaises'
op|'('
name|'exc'
op|'.'
name|'ComputeResourcesUnavailable'
op|','
nl|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'instance_claim'
op|','
nl|'\n'
name|'self'
op|'.'
name|'ctx'
op|','
name|'self'
op|'.'
name|'instance'
op|','
name|'bad_limits'
op|')'
newline|'\n'
nl|'\n'
dedent|''
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.InstancePCIRequests.get_by_instance_uuid'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.MigrationList.get_in_progress_by_host_and_node'"
op|')'
newline|'\n'
DECL|member|test_claim_numa
name|'def'
name|'test_claim_numa'
op|'('
name|'self'
op|','
name|'migr_mock'
op|','
name|'pci_mock'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'self'
op|'.'
name|'assertFalse'
op|'('
name|'self'
op|'.'
name|'rt'
op|'.'
name|'disabled'
op|')'
newline|'\n'
nl|'\n'
name|'pci_mock'
op|'.'
name|'return_value'
op|'='
name|'objects'
op|'.'
name|'InstancePCIRequests'
op|'('
name|'requests'
op|'='
op|'['
op|']'
op|')'
newline|'\n'
nl|'\n'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'numa_topology'
op|'='
name|'_INSTANCE_NUMA_TOPOLOGIES'
op|'['
string|"'2mb'"
op|']'
newline|'\n'
name|'host_topology'
op|'='
name|'_NUMA_HOST_TOPOLOGIES'
op|'['
string|"'2mb'"
op|']'
newline|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|'.'
name|'numa_topology'
op|'='
name|'host_topology'
op|'.'
name|'_to_json'
op|'('
op|')'
newline|'\n'
name|'limits'
op|'='
op|'{'
string|"'numa_topology'"
op|':'
name|'_NUMA_LIMIT_TOPOLOGIES'
op|'['
string|"'2mb'"
op|']'
op|'}'
newline|'\n'
nl|'\n'
name|'expected_numa'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'host_topology'
op|')'
newline|'\n'
name|'for'
name|'cell'
name|'in'
name|'expected_numa'
op|'.'
name|'cells'
op|':'
newline|'\n'
indent|'            '
name|'cell'
op|'.'
name|'memory_usage'
op|'+='
name|'_2MB'
newline|'\n'
name|'cell'
op|'.'
name|'cpu_usage'
op|'+='
number|'1'
newline|'\n'
dedent|''
name|'with'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'self'
op|'.'
name|'rt'
op|','
string|"'_update'"
op|')'
name|'as'
name|'update_mock'
op|':'
newline|'\n'
indent|'            '
name|'with'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'self'
op|'.'
name|'instance'
op|','
string|"'save'"
op|')'
op|':'
newline|'\n'
indent|'                '
name|'self'
op|'.'
name|'rt'
op|'.'
name|'instance_claim'
op|'('
name|'self'
op|'.'
name|'ctx'
op|','
name|'self'
op|'.'
name|'instance'
op|','
name|'limits'
op|')'
newline|'\n'
dedent|''
name|'update_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'self'
op|'.'
name|'ctx'
op|'.'
name|'elevated'
op|'('
op|')'
op|')'
newline|'\n'
name|'updated_compute_node'
op|'='
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
newline|'\n'
name|'new_numa'
op|'='
name|'updated_compute_node'
op|'.'
name|'numa_topology'
newline|'\n'
name|'new_numa'
op|'='
name|'objects'
op|'.'
name|'NUMATopology'
op|'.'
name|'obj_from_db_obj'
op|'('
name|'new_numa'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqualNUMAHostTopology'
op|'('
name|'expected_numa'
op|','
name|'new_numa'
op|')'
newline|'\n'
nl|'\n'
nl|'\n'
dedent|''
dedent|''
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.Instance.save'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.MigrationList.get_in_progress_by_host_and_node'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.Instance.get_by_uuid'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.InstanceList.get_by_host_and_node'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.InstancePCIRequests.get_by_instance_uuid'"
op|')'
newline|'\n'
DECL|class|TestMoveClaim
name|'class'
name|'TestMoveClaim'
op|'('
name|'BaseTestCase'
op|')'
op|':'
newline|'\n'
DECL|member|setUp
indent|'    '
name|'def'
name|'setUp'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'super'
op|'('
name|'TestMoveClaim'
op|','
name|'self'
op|')'
op|'.'
name|'setUp'
op|'('
op|')'
newline|'\n'
nl|'\n'
name|'self'
op|'.'
name|'_setup_rt'
op|'('
op|')'
newline|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'_COMPUTE_NODE_FIXTURES'
op|'['
number|'0'
op|']'
op|')'
newline|'\n'
nl|'\n'
name|'self'
op|'.'
name|'instance'
op|'='
name|'_INSTANCE_FIXTURES'
op|'['
number|'0'
op|']'
op|'.'
name|'obj_clone'
op|'('
op|')'
newline|'\n'
name|'self'
op|'.'
name|'flavor'
op|'='
name|'_INSTANCE_TYPE_OBJ_FIXTURES'
op|'['
number|'1'
op|']'
newline|'\n'
name|'self'
op|'.'
name|'limits'
op|'='
op|'{'
op|'}'
newline|'\n'
nl|'\n'
comment|'# not using mock.sentinel.ctx because resize_claim calls #elevated'
nl|'\n'
name|'self'
op|'.'
name|'ctx'
op|'='
name|'mock'
op|'.'
name|'MagicMock'
op|'('
op|')'
newline|'\n'
name|'self'
op|'.'
name|'elevated'
op|'='
name|'mock'
op|'.'
name|'MagicMock'
op|'('
op|')'
newline|'\n'
name|'self'
op|'.'
name|'ctx'
op|'.'
name|'elevated'
op|'.'
name|'return_value'
op|'='
name|'self'
op|'.'
name|'elevated'
newline|'\n'
nl|'\n'
comment|'# Initialise extensible resource trackers'
nl|'\n'
name|'self'
op|'.'
name|'flags'
op|'('
name|'reserved_host_disk_mb'
op|'='
number|'0'
op|','
name|'reserved_host_memory_mb'
op|'='
number|'0'
op|')'
newline|'\n'
name|'with'
name|'test'
op|'.'
name|'nested'
op|'('
nl|'\n'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.InstanceList.get_by_host_and_node'"
op|')'
op|','
nl|'\n'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.MigrationList.'"
nl|'\n'
string|"'get_in_progress_by_host_and_node'"
op|')'
nl|'\n'
op|')'
name|'as'
op|'('
name|'inst_list_mock'
op|','
name|'migr_mock'
op|')'
op|':'
newline|'\n'
indent|'            '
name|'inst_list_mock'
op|'.'
name|'return_value'
op|'='
name|'objects'
op|'.'
name|'InstanceList'
op|'('
name|'objects'
op|'='
op|'['
op|']'
op|')'
newline|'\n'
name|'migr_mock'
op|'.'
name|'return_value'
op|'='
name|'objects'
op|'.'
name|'MigrationList'
op|'('
name|'objects'
op|'='
op|'['
op|']'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'update_available_resource'
op|'('
name|'self'
op|'.'
name|'ctx'
op|')'
newline|'\n'
nl|'\n'
DECL|member|register_mocks
dedent|''
dedent|''
name|'def'
name|'register_mocks'
op|'('
name|'self'
op|','
name|'pci_mock'
op|','
name|'inst_list_mock'
op|','
name|'inst_by_uuid'
op|','
nl|'\n'
name|'migr_mock'
op|','
name|'inst_save_mock'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'pci_mock'
op|'.'
name|'return_value'
op|'='
name|'objects'
op|'.'
name|'InstancePCIRequests'
op|'('
name|'requests'
op|'='
op|'['
op|']'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'inst_list_mock'
op|'='
name|'inst_list_mock'
newline|'\n'
name|'self'
op|'.'
name|'inst_by_uuid'
op|'='
name|'inst_by_uuid'
newline|'\n'
name|'self'
op|'.'
name|'migr_mock'
op|'='
name|'migr_mock'
newline|'\n'
name|'self'
op|'.'
name|'inst_save_mock'
op|'='
name|'inst_save_mock'
newline|'\n'
nl|'\n'
DECL|member|audit
dedent|''
name|'def'
name|'audit'
op|'('
name|'self'
op|','
name|'rt'
op|','
name|'instances'
op|','
name|'migrations'
op|','
name|'migr_inst'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'self'
op|'.'
name|'inst_list_mock'
op|'.'
name|'return_value'
op|'='
name|'objects'
op|'.'
name|'InstanceList'
op|'('
name|'objects'
op|'='
name|'instances'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'migr_mock'
op|'.'
name|'return_value'
op|'='
name|'objects'
op|'.'
name|'MigrationList'
op|'('
name|'objects'
op|'='
name|'migrations'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'inst_by_uuid'
op|'.'
name|'return_value'
op|'='
name|'migr_inst'
newline|'\n'
name|'rt'
op|'.'
name|'update_available_resource'
op|'('
name|'self'
op|'.'
name|'ctx'
op|')'
newline|'\n'
nl|'\n'
DECL|member|assertEqual
dedent|''
name|'def'
name|'assertEqual'
op|'('
name|'self'
op|','
name|'expected'
op|','
name|'actual'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'if'
name|'type'
op|'('
name|'expected'
op|')'
op|'!='
name|'dict'
name|'or'
name|'type'
op|'('
name|'actual'
op|')'
op|'!='
name|'dict'
op|':'
newline|'\n'
indent|'            '
name|'super'
op|'('
name|'TestMoveClaim'
op|','
name|'self'
op|')'
op|'.'
name|'assertEqual'
op|'('
name|'expected'
op|','
name|'actual'
op|')'
newline|'\n'
name|'return'
newline|'\n'
dedent|''
name|'fail'
op|'='
name|'False'
newline|'\n'
name|'for'
name|'k'
op|','
name|'e'
name|'in'
name|'expected'
op|'.'
name|'items'
op|'('
op|')'
op|':'
newline|'\n'
indent|'            '
name|'a'
op|'='
name|'actual'
op|'['
name|'k'
op|']'
newline|'\n'
name|'if'
name|'e'
op|'!='
name|'a'
op|':'
newline|'\n'
indent|'                '
name|'print'
op|'('
string|'"%s: %s != %s"'
op|'%'
op|'('
name|'k'
op|','
name|'e'
op|','
name|'a'
op|')'
op|')'
newline|'\n'
name|'fail'
op|'='
name|'True'
newline|'\n'
dedent|''
dedent|''
name|'if'
name|'fail'
op|':'
newline|'\n'
indent|'            '
name|'self'
op|'.'
name|'fail'
op|'('
op|')'
newline|'\n'
nl|'\n'
DECL|member|adjust_expected
dedent|''
dedent|''
name|'def'
name|'adjust_expected'
op|'('
name|'self'
op|','
name|'expected'
op|','
name|'flavor'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'disk_used'
op|'='
name|'flavor'
op|'['
string|"'root_gb'"
op|']'
op|'+'
name|'flavor'
op|'['
string|"'ephemeral_gb'"
op|']'
newline|'\n'
name|'expected'
op|'.'
name|'free_disk_gb'
op|'-='
name|'disk_used'
newline|'\n'
name|'expected'
op|'.'
name|'local_gb_used'
op|'+='
name|'disk_used'
newline|'\n'
name|'expected'
op|'.'
name|'free_ram_mb'
op|'-='
name|'flavor'
op|'['
string|"'memory_mb'"
op|']'
newline|'\n'
name|'expected'
op|'.'
name|'memory_mb_used'
op|'+='
name|'flavor'
op|'['
string|"'memory_mb'"
op|']'
newline|'\n'
name|'expected'
op|'.'
name|'vcpus_used'
op|'+='
name|'flavor'
op|'['
string|"'vcpus'"
op|']'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.Flavor.get_by_id'"
op|')'
newline|'\n'
DECL|member|test_claim
name|'def'
name|'test_claim'
op|'('
name|'self'
op|','
name|'flavor_mock'
op|','
name|'pci_mock'
op|','
name|'inst_list_mock'
op|','
name|'inst_by_uuid'
op|','
nl|'\n'
name|'migr_mock'
op|','
name|'inst_save_mock'
op|')'
op|':'
newline|'\n'
indent|'        '
string|'"""Resize self.instance and check that the expected quantities of each\n        resource have been consumed.\n        """'
newline|'\n'
nl|'\n'
name|'self'
op|'.'
name|'register_mocks'
op|'('
name|'pci_mock'
op|','
name|'inst_list_mock'
op|','
name|'inst_by_uuid'
op|','
name|'migr_mock'
op|','
nl|'\n'
name|'inst_save_mock'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'driver_mock'
op|'.'
name|'get_host_ip_addr'
op|'.'
name|'return_value'
op|'='
string|'"fake-ip"'
newline|'\n'
name|'flavor_mock'
op|'.'
name|'return_value'
op|'='
name|'objects'
op|'.'
name|'Flavor'
op|'('
op|'**'
name|'self'
op|'.'
name|'flavor'
op|')'
newline|'\n'
name|'mig_context_obj'
op|'='
name|'_MIGRATION_CONTEXT_FIXTURES'
op|'['
name|'self'
op|'.'
name|'instance'
op|'.'
name|'uuid'
op|']'
newline|'\n'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'migration_context'
op|'='
name|'mig_context_obj'
newline|'\n'
nl|'\n'
name|'expected'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'adjust_expected'
op|'('
name|'expected'
op|','
name|'self'
op|'.'
name|'flavor'
op|')'
newline|'\n'
nl|'\n'
name|'create_mig_mock'
op|'='
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'self'
op|'.'
name|'rt'
op|','
string|"'_create_migration'"
op|')'
newline|'\n'
name|'mig_ctxt_mock'
op|'='
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.MigrationContext'"
op|','
nl|'\n'
name|'return_value'
op|'='
name|'mig_context_obj'
op|')'
newline|'\n'
name|'with'
name|'create_mig_mock'
name|'as'
name|'migr_mock'
op|','
name|'mig_ctxt_mock'
name|'as'
name|'ctxt_mock'
op|':'
newline|'\n'
indent|'            '
name|'migr_mock'
op|'.'
name|'return_value'
op|'='
name|'_MIGRATION_FIXTURES'
op|'['
string|"'source-only'"
op|']'
newline|'\n'
name|'claim'
op|'='
name|'self'
op|'.'
name|'rt'
op|'.'
name|'resize_claim'
op|'('
nl|'\n'
name|'self'
op|'.'
name|'ctx'
op|','
name|'self'
op|'.'
name|'instance'
op|','
name|'self'
op|'.'
name|'flavor'
op|','
name|'None'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
number|'1'
op|','
name|'ctxt_mock'
op|'.'
name|'call_count'
op|')'
newline|'\n'
nl|'\n'
dedent|''
name|'self'
op|'.'
name|'assertIsInstance'
op|'('
name|'claim'
op|','
name|'claims'
op|'.'
name|'MoveClaim'
op|')'
newline|'\n'
name|'inst_save_mock'
op|'.'
name|'assert_called_once_with'
op|'('
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertTrue'
op|'('
name|'obj_base'
op|'.'
name|'obj_equal_prims'
op|'('
name|'expected'
op|','
nl|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|')'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_claim_abort
dedent|''
name|'def'
name|'test_claim_abort'
op|'('
name|'self'
op|','
name|'pci_mock'
op|','
name|'inst_list_mock'
op|','
nl|'\n'
name|'inst_by_uuid'
op|','
name|'migr_mock'
op|','
name|'inst_save_mock'
op|')'
op|':'
newline|'\n'
comment|'# Resize self.instance and check that the expected quantities of each'
nl|'\n'
comment|'# resource have been consumed. The abort the resize claim and check'
nl|'\n'
comment|'# that the resources have been set back to their original values.'
nl|'\n'
indent|'        '
name|'self'
op|'.'
name|'register_mocks'
op|'('
name|'pci_mock'
op|','
name|'inst_list_mock'
op|','
name|'inst_by_uuid'
op|','
name|'migr_mock'
op|','
nl|'\n'
name|'inst_save_mock'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'driver_mock'
op|'.'
name|'get_host_ip_addr'
op|'.'
name|'return_value'
op|'='
string|'"fake-host"'
newline|'\n'
name|'migr_obj'
op|'='
name|'_MIGRATION_FIXTURES'
op|'['
string|"'dest-only'"
op|']'
newline|'\n'
name|'self'
op|'.'
name|'instance'
op|'='
name|'_MIGRATION_INSTANCE_FIXTURES'
op|'['
name|'migr_obj'
op|'['
string|"'instance_uuid'"
op|']'
op|']'
newline|'\n'
name|'mig_context_obj'
op|'='
name|'_MIGRATION_CONTEXT_FIXTURES'
op|'['
name|'self'
op|'.'
name|'instance'
op|'.'
name|'uuid'
op|']'
newline|'\n'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'migration_context'
op|'='
name|'mig_context_obj'
newline|'\n'
name|'self'
op|'.'
name|'flavor'
op|'='
name|'_INSTANCE_TYPE_OBJ_FIXTURES'
op|'['
number|'2'
op|']'
newline|'\n'
nl|'\n'
name|'with'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'self'
op|'.'
name|'rt'
op|','
string|"'_create_migration'"
op|')'
name|'as'
name|'migr_mock'
op|':'
newline|'\n'
indent|'            '
name|'migr_mock'
op|'.'
name|'return_value'
op|'='
name|'migr_obj'
newline|'\n'
name|'claim'
op|'='
name|'self'
op|'.'
name|'rt'
op|'.'
name|'resize_claim'
op|'('
nl|'\n'
name|'self'
op|'.'
name|'ctx'
op|','
name|'self'
op|'.'
name|'instance'
op|','
name|'self'
op|'.'
name|'flavor'
op|','
name|'None'
op|')'
newline|'\n'
nl|'\n'
dedent|''
name|'self'
op|'.'
name|'assertIsInstance'
op|'('
name|'claim'
op|','
name|'claims'
op|'.'
name|'MoveClaim'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
number|'5'
op|','
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|'.'
name|'local_gb_used'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
number|'256'
op|','
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|'.'
name|'memory_mb_used'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
number|'1'
op|','
name|'len'
op|'('
name|'self'
op|'.'
name|'rt'
op|'.'
name|'tracked_migrations'
op|')'
op|')'
newline|'\n'
nl|'\n'
name|'with'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.Instance.'"
nl|'\n'
string|"'drop_migration_context'"
op|')'
name|'as'
name|'drop_migr_mock'
op|':'
newline|'\n'
indent|'            '
name|'claim'
op|'.'
name|'abort'
op|'('
op|')'
newline|'\n'
name|'drop_migr_mock'
op|'.'
name|'assert_called_once_with'
op|'('
op|')'
newline|'\n'
nl|'\n'
dedent|''
name|'self'
op|'.'
name|'assertEqual'
op|'('
number|'0'
op|','
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|'.'
name|'local_gb_used'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
number|'0'
op|','
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|'.'
name|'memory_mb_used'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
number|'0'
op|','
name|'len'
op|'('
name|'self'
op|'.'
name|'rt'
op|'.'
name|'tracked_migrations'
op|')'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_same_host
dedent|''
name|'def'
name|'test_same_host'
op|'('
name|'self'
op|','
name|'pci_mock'
op|','
name|'inst_list_mock'
op|','
name|'inst_by_uuid'
op|','
nl|'\n'
name|'migr_mock'
op|','
name|'inst_save_mock'
op|')'
op|':'
newline|'\n'
indent|'        '
string|'"""Resize self.instance to the same host but with a different flavor.\n        Then abort the claim. Check that the same amount of resources are\n        available afterwards as we started with.\n        """'
newline|'\n'
nl|'\n'
name|'self'
op|'.'
name|'register_mocks'
op|'('
name|'pci_mock'
op|','
name|'inst_list_mock'
op|','
name|'inst_by_uuid'
op|','
name|'migr_mock'
op|','
nl|'\n'
name|'inst_save_mock'
op|')'
newline|'\n'
name|'migr_obj'
op|'='
name|'_MIGRATION_FIXTURES'
op|'['
string|"'source-and-dest'"
op|']'
newline|'\n'
name|'self'
op|'.'
name|'instance'
op|'='
name|'_MIGRATION_INSTANCE_FIXTURES'
op|'['
name|'migr_obj'
op|'['
string|"'instance_uuid'"
op|']'
op|']'
newline|'\n'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'_context'
op|'='
name|'self'
op|'.'
name|'ctx'
newline|'\n'
name|'mig_context_obj'
op|'='
name|'_MIGRATION_CONTEXT_FIXTURES'
op|'['
name|'self'
op|'.'
name|'instance'
op|'.'
name|'uuid'
op|']'
newline|'\n'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'migration_context'
op|'='
name|'mig_context_obj'
newline|'\n'
nl|'\n'
name|'with'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'self'
op|'.'
name|'instance'
op|','
string|"'save'"
op|')'
op|':'
newline|'\n'
indent|'            '
name|'self'
op|'.'
name|'rt'
op|'.'
name|'instance_claim'
op|'('
name|'self'
op|'.'
name|'ctx'
op|','
name|'self'
op|'.'
name|'instance'
op|','
name|'None'
op|')'
newline|'\n'
dedent|''
name|'expected'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|')'
newline|'\n'
nl|'\n'
name|'create_mig_mock'
op|'='
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'self'
op|'.'
name|'rt'
op|','
string|"'_create_migration'"
op|')'
newline|'\n'
name|'mig_ctxt_mock'
op|'='
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.MigrationContext'"
op|','
nl|'\n'
name|'return_value'
op|'='
name|'mig_context_obj'
op|')'
newline|'\n'
nl|'\n'
name|'with'
name|'create_mig_mock'
name|'as'
name|'migr_mock'
op|','
name|'mig_ctxt_mock'
name|'as'
name|'ctxt_mock'
op|':'
newline|'\n'
indent|'            '
name|'migr_mock'
op|'.'
name|'return_value'
op|'='
name|'migr_obj'
newline|'\n'
name|'claim'
op|'='
name|'self'
op|'.'
name|'rt'
op|'.'
name|'resize_claim'
op|'('
name|'self'
op|'.'
name|'ctx'
op|','
name|'self'
op|'.'
name|'instance'
op|','
nl|'\n'
name|'_INSTANCE_TYPE_OBJ_FIXTURES'
op|'['
number|'1'
op|']'
op|','
name|'None'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
number|'1'
op|','
name|'ctxt_mock'
op|'.'
name|'call_count'
op|')'
newline|'\n'
nl|'\n'
dedent|''
name|'self'
op|'.'
name|'audit'
op|'('
name|'self'
op|'.'
name|'rt'
op|','
op|'['
name|'self'
op|'.'
name|'instance'
op|']'
op|','
op|'['
name|'migr_obj'
op|']'
op|','
name|'self'
op|'.'
name|'instance'
op|')'
newline|'\n'
name|'inst_save_mock'
op|'.'
name|'assert_called_once_with'
op|'('
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertNotEqual'
op|'('
name|'expected'
op|','
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|')'
newline|'\n'
nl|'\n'
name|'claim'
op|'.'
name|'instance'
op|'.'
name|'migration_context'
op|'='
name|'mig_context_obj'
newline|'\n'
name|'with'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.MigrationContext._destroy'"
op|')'
name|'as'
name|'destroy_m'
op|':'
newline|'\n'
indent|'            '
name|'claim'
op|'.'
name|'abort'
op|'('
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertTrue'
op|'('
name|'obj_base'
op|'.'
name|'obj_equal_prims'
op|'('
name|'expected'
op|','
nl|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|')'
op|')'
newline|'\n'
name|'destroy_m'
op|'.'
name|'assert_called_once_with'
op|'('
name|'self'
op|'.'
name|'ctx'
op|','
name|'claim'
op|'.'
name|'instance'
op|'.'
name|'uuid'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_revert_reserve_source
dedent|''
dedent|''
name|'def'
name|'test_revert_reserve_source'
op|'('
nl|'\n'
name|'self'
op|','
name|'pci_mock'
op|','
name|'inst_list_mock'
op|','
name|'inst_by_uuid'
op|','
name|'migr_mock'
op|','
nl|'\n'
name|'inst_save_mock'
op|')'
op|':'
newline|'\n'
indent|'        '
string|'"""Check that the source node of an instance migration reserves\n        resources until the migration has completed, even if the migration is\n        reverted.\n        """'
newline|'\n'
nl|'\n'
name|'self'
op|'.'
name|'register_mocks'
op|'('
name|'pci_mock'
op|','
name|'inst_list_mock'
op|','
name|'inst_by_uuid'
op|','
name|'migr_mock'
op|','
nl|'\n'
name|'inst_save_mock'
op|')'
newline|'\n'
nl|'\n'
comment|'# Get our migrations, instances and itypes in a row'
nl|'\n'
name|'src_migr'
op|'='
name|'_MIGRATION_FIXTURES'
op|'['
string|"'source-only'"
op|']'
newline|'\n'
name|'src_instance'
op|'='
op|'('
nl|'\n'
name|'_MIGRATION_INSTANCE_FIXTURES'
op|'['
name|'src_migr'
op|'['
string|"'instance_uuid'"
op|']'
op|']'
op|'.'
name|'obj_clone'
op|'('
op|')'
nl|'\n'
op|')'
newline|'\n'
name|'src_instance'
op|'.'
name|'migration_context'
op|'='
op|'('
nl|'\n'
name|'_MIGRATION_CONTEXT_FIXTURES'
op|'['
name|'src_instance'
op|'.'
name|'uuid'
op|']'
op|')'
newline|'\n'
name|'old_itype'
op|'='
name|'_INSTANCE_TYPE_FIXTURES'
op|'['
name|'src_migr'
op|'['
string|"'old_instance_type_id'"
op|']'
op|']'
newline|'\n'
name|'dst_migr'
op|'='
name|'_MIGRATION_FIXTURES'
op|'['
string|"'dest-only'"
op|']'
newline|'\n'
name|'dst_instance'
op|'='
op|'('
nl|'\n'
name|'_MIGRATION_INSTANCE_FIXTURES'
op|'['
name|'dst_migr'
op|'['
string|"'instance_uuid'"
op|']'
op|']'
op|'.'
name|'obj_clone'
op|'('
op|')'
nl|'\n'
op|')'
newline|'\n'
name|'new_itype'
op|'='
name|'_INSTANCE_TYPE_FIXTURES'
op|'['
name|'dst_migr'
op|'['
string|"'new_instance_type_id'"
op|']'
op|']'
newline|'\n'
name|'dst_instance'
op|'.'
name|'migration_context'
op|'='
op|'('
nl|'\n'
name|'_MIGRATION_CONTEXT_FIXTURES'
op|'['
name|'dst_instance'
op|'.'
name|'uuid'
op|']'
op|')'
newline|'\n'
nl|'\n'
comment|'# Set up the destination resource tracker'
nl|'\n'
comment|'# update_available_resource to initialise extensible resource trackers'
nl|'\n'
name|'src_rt'
op|'='
name|'self'
op|'.'
name|'rt'
newline|'\n'
op|'('
name|'dst_rt'
op|','
name|'_'
op|','
name|'_'
op|')'
op|'='
name|'setup_rt'
op|'('
string|'"other-host"'
op|','
string|'"other-node"'
op|')'
newline|'\n'
name|'dst_rt'
op|'.'
name|'compute_node'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'_COMPUTE_NODE_FIXTURES'
op|'['
number|'0'
op|']'
op|')'
newline|'\n'
name|'inst_list_mock'
op|'.'
name|'return_value'
op|'='
name|'objects'
op|'.'
name|'InstanceList'
op|'('
name|'objects'
op|'='
op|'['
op|']'
op|')'
newline|'\n'
name|'dst_rt'
op|'.'
name|'update_available_resource'
op|'('
name|'self'
op|'.'
name|'ctx'
op|')'
newline|'\n'
nl|'\n'
comment|'# Register the instance with dst_rt'
nl|'\n'
name|'expected'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'dst_rt'
op|'.'
name|'compute_node'
op|')'
newline|'\n'
name|'with'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'dst_instance'
op|','
string|"'save'"
op|')'
op|':'
newline|'\n'
indent|'            '
name|'dst_rt'
op|'.'
name|'instance_claim'
op|'('
name|'self'
op|'.'
name|'ctx'
op|','
name|'dst_instance'
op|')'
newline|'\n'
dedent|''
name|'self'
op|'.'
name|'adjust_expected'
op|'('
name|'expected'
op|','
name|'new_itype'
op|')'
newline|'\n'
name|'expected'
op|'.'
name|'stats'
op|'='
op|'{'
string|"'num_task_resize_migrating'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'io_workload'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'num_instances'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'num_proj_fake-project'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'num_vm_active'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'num_os_type_fake-os'"
op|':'
number|'1'
op|'}'
newline|'\n'
name|'expected'
op|'.'
name|'current_workload'
op|'='
number|'1'
newline|'\n'
name|'expected'
op|'.'
name|'running_vms'
op|'='
number|'1'
newline|'\n'
name|'self'
op|'.'
name|'assertTrue'
op|'('
name|'obj_base'
op|'.'
name|'obj_equal_prims'
op|'('
name|'expected'
op|','
nl|'\n'
name|'dst_rt'
op|'.'
name|'compute_node'
op|')'
op|')'
newline|'\n'
nl|'\n'
comment|'# Provide the migration via a mock, then audit dst_rt to check that'
nl|'\n'
comment|'# the instance + migration resources are not double-counted'
nl|'\n'
name|'self'
op|'.'
name|'audit'
op|'('
name|'dst_rt'
op|','
op|'['
name|'dst_instance'
op|']'
op|','
op|'['
name|'dst_migr'
op|']'
op|','
name|'dst_instance'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertTrue'
op|'('
name|'obj_base'
op|'.'
name|'obj_equal_prims'
op|'('
name|'expected'
op|','
nl|'\n'
name|'dst_rt'
op|'.'
name|'compute_node'
op|')'
op|')'
newline|'\n'
nl|'\n'
comment|'# Audit src_rt with src_migr'
nl|'\n'
name|'expected'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'src_rt'
op|'.'
name|'compute_node'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'adjust_expected'
op|'('
name|'expected'
op|','
name|'old_itype'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'audit'
op|'('
name|'src_rt'
op|','
op|'['
op|']'
op|','
op|'['
name|'src_migr'
op|']'
op|','
name|'src_instance'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertTrue'
op|'('
name|'obj_base'
op|'.'
name|'obj_equal_prims'
op|'('
name|'expected'
op|','
nl|'\n'
name|'src_rt'
op|'.'
name|'compute_node'
op|')'
op|')'
newline|'\n'
nl|'\n'
comment|'# Flag the instance as reverting and re-audit'
nl|'\n'
name|'src_instance'
op|'['
string|"'vm_state'"
op|']'
op|'='
name|'vm_states'
op|'.'
name|'RESIZED'
newline|'\n'
name|'src_instance'
op|'['
string|"'task_state'"
op|']'
op|'='
name|'task_states'
op|'.'
name|'RESIZE_REVERTING'
newline|'\n'
name|'self'
op|'.'
name|'audit'
op|'('
name|'src_rt'
op|','
op|'['
op|']'
op|','
op|'['
name|'src_migr'
op|']'
op|','
name|'src_instance'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertTrue'
op|'('
name|'obj_base'
op|'.'
name|'obj_equal_prims'
op|'('
name|'expected'
op|','
nl|'\n'
name|'src_rt'
op|'.'
name|'compute_node'
op|')'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_update_available_resources_migration_no_context
dedent|''
name|'def'
name|'test_update_available_resources_migration_no_context'
op|'('
name|'self'
op|','
name|'pci_mock'
op|','
nl|'\n'
name|'inst_list_mock'
op|','
name|'inst_by_uuid'
op|','
name|'migr_mock'
op|','
name|'inst_save_mock'
op|')'
op|':'
newline|'\n'
indent|'        '
string|'"""When migrating onto older nodes - it is possible for the\n        migration_context record to be missing. Confirm resource audit works\n        regardless.\n        """'
newline|'\n'
name|'self'
op|'.'
name|'register_mocks'
op|'('
name|'pci_mock'
op|','
name|'inst_list_mock'
op|','
name|'inst_by_uuid'
op|','
name|'migr_mock'
op|','
nl|'\n'
name|'inst_save_mock'
op|')'
newline|'\n'
name|'migr_obj'
op|'='
name|'_MIGRATION_FIXTURES'
op|'['
string|"'source-and-dest'"
op|']'
newline|'\n'
name|'self'
op|'.'
name|'instance'
op|'='
name|'_MIGRATION_INSTANCE_FIXTURES'
op|'['
name|'migr_obj'
op|'['
string|"'instance_uuid'"
op|']'
op|']'
newline|'\n'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'migration_context'
op|'='
name|'None'
newline|'\n'
nl|'\n'
name|'expected'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'adjust_expected'
op|'('
name|'expected'
op|','
name|'self'
op|'.'
name|'flavor'
op|')'
newline|'\n'
nl|'\n'
name|'self'
op|'.'
name|'audit'
op|'('
name|'self'
op|'.'
name|'rt'
op|','
op|'['
op|']'
op|','
op|'['
name|'migr_obj'
op|']'
op|','
name|'self'
op|'.'
name|'instance'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertTrue'
op|'('
name|'obj_base'
op|'.'
name|'obj_equal_prims'
op|'('
name|'expected'
op|','
nl|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|')'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_dupe_filter
dedent|''
name|'def'
name|'test_dupe_filter'
op|'('
name|'self'
op|','
name|'pci_mock'
op|','
name|'inst_list_mock'
op|','
name|'inst_by_uuid'
op|','
nl|'\n'
name|'migr_mock'
op|','
name|'inst_save_mock'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'self'
op|'.'
name|'register_mocks'
op|'('
name|'pci_mock'
op|','
name|'inst_list_mock'
op|','
name|'inst_by_uuid'
op|','
name|'migr_mock'
op|','
nl|'\n'
name|'inst_save_mock'
op|')'
newline|'\n'
nl|'\n'
name|'migr_obj'
op|'='
name|'_MIGRATION_FIXTURES'
op|'['
string|"'source-and-dest'"
op|']'
newline|'\n'
comment|'# This is good enough to prevent a lazy-load; value is unimportant'
nl|'\n'
name|'migr_obj'
op|'['
string|"'updated_at'"
op|']'
op|'='
name|'None'
newline|'\n'
name|'self'
op|'.'
name|'instance'
op|'='
name|'_MIGRATION_INSTANCE_FIXTURES'
op|'['
name|'migr_obj'
op|'['
string|"'instance_uuid'"
op|']'
op|']'
newline|'\n'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'migration_context'
op|'='
op|'('
nl|'\n'
name|'_MIGRATION_CONTEXT_FIXTURES'
op|'['
name|'self'
op|'.'
name|'instance'
op|'.'
name|'uuid'
op|']'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'audit'
op|'('
name|'self'
op|'.'
name|'rt'
op|','
op|'['
op|']'
op|','
op|'['
name|'migr_obj'
op|','
name|'migr_obj'
op|']'
op|','
name|'self'
op|'.'
name|'instance'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
number|'1'
op|','
name|'len'
op|'('
name|'self'
op|'.'
name|'rt'
op|'.'
name|'tracked_migrations'
op|')'
op|')'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|class|TestInstanceInResizeState
dedent|''
dedent|''
name|'class'
name|'TestInstanceInResizeState'
op|'('
name|'test'
op|'.'
name|'NoDBTestCase'
op|')'
op|':'
newline|'\n'
DECL|member|test_active_suspending
indent|'    '
name|'def'
name|'test_active_suspending'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'instance'
op|'='
name|'objects'
op|'.'
name|'Instance'
op|'('
name|'vm_state'
op|'='
name|'vm_states'
op|'.'
name|'ACTIVE'
op|','
nl|'\n'
name|'task_state'
op|'='
name|'task_states'
op|'.'
name|'SUSPENDING'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertFalse'
op|'('
name|'resource_tracker'
op|'.'
name|'_instance_in_resize_state'
op|'('
name|'instance'
op|')'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_resized_suspending
dedent|''
name|'def'
name|'test_resized_suspending'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'instance'
op|'='
name|'objects'
op|'.'
name|'Instance'
op|'('
name|'vm_state'
op|'='
name|'vm_states'
op|'.'
name|'RESIZED'
op|','
nl|'\n'
name|'task_state'
op|'='
name|'task_states'
op|'.'
name|'SUSPENDING'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertTrue'
op|'('
name|'resource_tracker'
op|'.'
name|'_instance_in_resize_state'
op|'('
name|'instance'
op|')'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_resized_resize_migrating
dedent|''
name|'def'
name|'test_resized_resize_migrating'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'instance'
op|'='
name|'objects'
op|'.'
name|'Instance'
op|'('
name|'vm_state'
op|'='
name|'vm_states'
op|'.'
name|'RESIZED'
op|','
nl|'\n'
name|'task_state'
op|'='
name|'task_states'
op|'.'
name|'RESIZE_MIGRATING'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertTrue'
op|'('
name|'resource_tracker'
op|'.'
name|'_instance_in_resize_state'
op|'('
name|'instance'
op|')'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_resized_resize_finish
dedent|''
name|'def'
name|'test_resized_resize_finish'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'instance'
op|'='
name|'objects'
op|'.'
name|'Instance'
op|'('
name|'vm_state'
op|'='
name|'vm_states'
op|'.'
name|'RESIZED'
op|','
nl|'\n'
name|'task_state'
op|'='
name|'task_states'
op|'.'
name|'RESIZE_FINISH'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertTrue'
op|'('
name|'resource_tracker'
op|'.'
name|'_instance_in_resize_state'
op|'('
name|'instance'
op|')'
op|')'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|function|_update_compute_node
dedent|''
dedent|''
name|'def'
name|'_update_compute_node'
op|'('
name|'node'
op|','
op|'**'
name|'kwargs'
op|')'
op|':'
newline|'\n'
indent|'    '
name|'for'
name|'key'
op|','
name|'value'
name|'in'
name|'kwargs'
op|'.'
name|'items'
op|'('
op|')'
op|':'
newline|'\n'
indent|'        '
name|'setattr'
op|'('
name|'node'
op|','
name|'key'
op|','
name|'value'
op|')'
newline|'\n'
dedent|''
dedent|''
endmarker|''
end_unit

begin_unit
comment|'#    Licensed under the Apache License, Version 2.0 (the "License"); you may'
nl|'\n'
comment|'#    not use this file except in compliance with the License. You may obtain'
nl|'\n'
comment|'#    a copy of the License at'
nl|'\n'
comment|'#'
nl|'\n'
comment|'#         http://www.apache.org/licenses/LICENSE-2.0'
nl|'\n'
comment|'#'
nl|'\n'
comment|'#    Unless required by applicable law or agreed to in writing, software'
nl|'\n'
comment|'#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT'
nl|'\n'
comment|'#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the'
nl|'\n'
comment|'#    License for the specific language governing permissions and limitations'
nl|'\n'
comment|'#    under the License.'
nl|'\n'
nl|'\n'
name|'import'
name|'copy'
newline|'\n'
nl|'\n'
name|'import'
name|'mock'
newline|'\n'
name|'from'
name|'oslo_utils'
name|'import'
name|'units'
newline|'\n'
nl|'\n'
name|'from'
name|'nova'
op|'.'
name|'compute'
name|'import'
name|'arch'
newline|'\n'
name|'from'
name|'nova'
op|'.'
name|'compute'
name|'import'
name|'claims'
newline|'\n'
name|'from'
name|'nova'
op|'.'
name|'compute'
name|'import'
name|'hv_type'
newline|'\n'
name|'from'
name|'nova'
op|'.'
name|'compute'
name|'import'
name|'power_state'
newline|'\n'
name|'from'
name|'nova'
op|'.'
name|'compute'
name|'import'
name|'resource_tracker'
newline|'\n'
name|'from'
name|'nova'
op|'.'
name|'compute'
name|'import'
name|'task_states'
newline|'\n'
name|'from'
name|'nova'
op|'.'
name|'compute'
name|'import'
name|'vm_mode'
newline|'\n'
name|'from'
name|'nova'
op|'.'
name|'compute'
name|'import'
name|'vm_states'
newline|'\n'
name|'from'
name|'nova'
name|'import'
name|'exception'
name|'as'
name|'exc'
newline|'\n'
name|'from'
name|'nova'
name|'import'
name|'objects'
newline|'\n'
name|'from'
name|'nova'
op|'.'
name|'objects'
name|'import'
name|'base'
name|'as'
name|'obj_base'
newline|'\n'
name|'from'
name|'nova'
op|'.'
name|'pci'
name|'import'
name|'manager'
name|'as'
name|'pci_manager'
newline|'\n'
name|'from'
name|'nova'
name|'import'
name|'test'
newline|'\n'
nl|'\n'
DECL|variable|_VIRT_DRIVER_AVAIL_RESOURCES
name|'_VIRT_DRIVER_AVAIL_RESOURCES'
op|'='
op|'{'
nl|'\n'
string|"'vcpus'"
op|':'
number|'4'
op|','
nl|'\n'
string|"'memory_mb'"
op|':'
number|'512'
op|','
nl|'\n'
string|"'local_gb'"
op|':'
number|'6'
op|','
nl|'\n'
string|"'vcpus_used'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'memory_mb_used'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'local_gb_used'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'hypervisor_type'"
op|':'
string|"'fake'"
op|','
nl|'\n'
string|"'hypervisor_version'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'hypervisor_hostname'"
op|':'
string|"'fakehost'"
op|','
nl|'\n'
string|"'cpu_info'"
op|':'
string|"''"
op|','
nl|'\n'
string|"'numa_topology'"
op|':'
name|'None'
op|','
nl|'\n'
op|'}'
newline|'\n'
nl|'\n'
DECL|variable|_COMPUTE_NODE_FIXTURES
name|'_COMPUTE_NODE_FIXTURES'
op|'='
op|'['
nl|'\n'
name|'objects'
op|'.'
name|'ComputeNode'
op|'('
nl|'\n'
DECL|variable|id
name|'id'
op|'='
number|'1'
op|','
nl|'\n'
DECL|variable|host
name|'host'
op|'='
string|"'fake-host'"
op|','
nl|'\n'
DECL|variable|vcpus
name|'vcpus'
op|'='
name|'_VIRT_DRIVER_AVAIL_RESOURCES'
op|'['
string|"'vcpus'"
op|']'
op|','
nl|'\n'
DECL|variable|memory_mb
name|'memory_mb'
op|'='
name|'_VIRT_DRIVER_AVAIL_RESOURCES'
op|'['
string|"'memory_mb'"
op|']'
op|','
nl|'\n'
DECL|variable|local_gb
name|'local_gb'
op|'='
name|'_VIRT_DRIVER_AVAIL_RESOURCES'
op|'['
string|"'local_gb'"
op|']'
op|','
nl|'\n'
DECL|variable|vcpus_used
name|'vcpus_used'
op|'='
name|'_VIRT_DRIVER_AVAIL_RESOURCES'
op|'['
string|"'vcpus_used'"
op|']'
op|','
nl|'\n'
DECL|variable|memory_mb_used
name|'memory_mb_used'
op|'='
name|'_VIRT_DRIVER_AVAIL_RESOURCES'
op|'['
string|"'memory_mb_used'"
op|']'
op|','
nl|'\n'
DECL|variable|local_gb_used
name|'local_gb_used'
op|'='
name|'_VIRT_DRIVER_AVAIL_RESOURCES'
op|'['
string|"'local_gb_used'"
op|']'
op|','
nl|'\n'
DECL|variable|hypervisor_type
name|'hypervisor_type'
op|'='
string|"'fake'"
op|','
nl|'\n'
DECL|variable|hypervisor_version
name|'hypervisor_version'
op|'='
number|'0'
op|','
nl|'\n'
DECL|variable|hypervisor_hostname
name|'hypervisor_hostname'
op|'='
string|"'fake-host'"
op|','
nl|'\n'
DECL|variable|free_ram_mb
name|'free_ram_mb'
op|'='
op|'('
name|'_VIRT_DRIVER_AVAIL_RESOURCES'
op|'['
string|"'memory_mb'"
op|']'
op|'-'
nl|'\n'
name|'_VIRT_DRIVER_AVAIL_RESOURCES'
op|'['
string|"'memory_mb_used'"
op|']'
op|')'
op|','
nl|'\n'
DECL|variable|free_disk_gb
name|'free_disk_gb'
op|'='
op|'('
name|'_VIRT_DRIVER_AVAIL_RESOURCES'
op|'['
string|"'local_gb'"
op|']'
op|'-'
nl|'\n'
name|'_VIRT_DRIVER_AVAIL_RESOURCES'
op|'['
string|"'local_gb_used'"
op|']'
op|')'
op|','
nl|'\n'
DECL|variable|current_workload
name|'current_workload'
op|'='
number|'0'
op|','
nl|'\n'
DECL|variable|running_vms
name|'running_vms'
op|'='
number|'0'
op|','
nl|'\n'
DECL|variable|cpu_info
name|'cpu_info'
op|'='
string|"'{}'"
op|','
nl|'\n'
DECL|variable|disk_available_least
name|'disk_available_least'
op|'='
number|'0'
op|','
nl|'\n'
DECL|variable|host_ip
name|'host_ip'
op|'='
string|"'1.1.1.1'"
op|','
nl|'\n'
DECL|variable|supported_hv_specs
name|'supported_hv_specs'
op|'='
op|'['
nl|'\n'
name|'objects'
op|'.'
name|'HVSpec'
op|'.'
name|'from_list'
op|'('
op|'['
name|'arch'
op|'.'
name|'I686'
op|','
name|'hv_type'
op|'.'
name|'KVM'
op|','
name|'vm_mode'
op|'.'
name|'HVM'
op|']'
op|')'
nl|'\n'
op|']'
op|','
nl|'\n'
DECL|variable|metrics
name|'metrics'
op|'='
name|'None'
op|','
nl|'\n'
DECL|variable|pci_device_pools
name|'pci_device_pools'
op|'='
name|'None'
op|','
nl|'\n'
DECL|variable|extra_resources
name|'extra_resources'
op|'='
name|'None'
op|','
nl|'\n'
DECL|variable|stats
name|'stats'
op|'='
op|'{'
op|'}'
op|','
nl|'\n'
DECL|variable|numa_topology
name|'numa_topology'
op|'='
name|'None'
op|','
nl|'\n'
DECL|variable|cpu_allocation_ratio
name|'cpu_allocation_ratio'
op|'='
number|'16.0'
op|','
nl|'\n'
DECL|variable|ram_allocation_ratio
name|'ram_allocation_ratio'
op|'='
number|'1.5'
op|','
nl|'\n'
DECL|variable|disk_allocation_ratio
name|'disk_allocation_ratio'
op|'='
number|'1.0'
op|','
nl|'\n'
op|')'
op|','
nl|'\n'
op|']'
newline|'\n'
nl|'\n'
DECL|variable|_INSTANCE_TYPE_FIXTURES
name|'_INSTANCE_TYPE_FIXTURES'
op|'='
op|'{'
nl|'\n'
number|'1'
op|':'
op|'{'
nl|'\n'
string|"'id'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'flavorid'"
op|':'
string|"'fakeid-1'"
op|','
nl|'\n'
string|"'name'"
op|':'
string|"'fake1.small'"
op|','
nl|'\n'
string|"'memory_mb'"
op|':'
number|'128'
op|','
nl|'\n'
string|"'vcpus'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'root_gb'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'ephemeral_gb'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'swap'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'rxtx_factor'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'vcpu_weight'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'extra_specs'"
op|':'
op|'{'
op|'}'
op|','
nl|'\n'
op|'}'
op|','
nl|'\n'
number|'2'
op|':'
op|'{'
nl|'\n'
string|"'id'"
op|':'
number|'2'
op|','
nl|'\n'
string|"'flavorid'"
op|':'
string|"'fakeid-2'"
op|','
nl|'\n'
string|"'name'"
op|':'
string|"'fake1.medium'"
op|','
nl|'\n'
string|"'memory_mb'"
op|':'
number|'256'
op|','
nl|'\n'
string|"'vcpus'"
op|':'
number|'2'
op|','
nl|'\n'
string|"'root_gb'"
op|':'
number|'5'
op|','
nl|'\n'
string|"'ephemeral_gb'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'swap'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'rxtx_factor'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'vcpu_weight'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'extra_specs'"
op|':'
op|'{'
op|'}'
op|','
nl|'\n'
op|'}'
op|','
nl|'\n'
op|'}'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|variable|_INSTANCE_TYPE_OBJ_FIXTURES
name|'_INSTANCE_TYPE_OBJ_FIXTURES'
op|'='
op|'{'
nl|'\n'
number|'1'
op|':'
name|'objects'
op|'.'
name|'Flavor'
op|'('
name|'id'
op|'='
number|'1'
op|','
name|'flavorid'
op|'='
string|"'fakeid-1'"
op|','
name|'name'
op|'='
string|"'fake1.small'"
op|','
nl|'\n'
name|'memory_mb'
op|'='
number|'128'
op|','
name|'vcpus'
op|'='
number|'1'
op|','
name|'root_gb'
op|'='
number|'1'
op|','
nl|'\n'
name|'ephemeral_gb'
op|'='
number|'0'
op|','
name|'swap'
op|'='
number|'0'
op|','
name|'rxtx_factor'
op|'='
number|'0'
op|','
nl|'\n'
name|'vcpu_weight'
op|'='
number|'1'
op|','
name|'extra_specs'
op|'='
op|'{'
op|'}'
op|')'
op|','
nl|'\n'
number|'2'
op|':'
name|'objects'
op|'.'
name|'Flavor'
op|'('
name|'id'
op|'='
number|'2'
op|','
name|'flavorid'
op|'='
string|"'fakeid-2'"
op|','
name|'name'
op|'='
string|"'fake1.medium'"
op|','
nl|'\n'
name|'memory_mb'
op|'='
number|'256'
op|','
name|'vcpus'
op|'='
number|'2'
op|','
name|'root_gb'
op|'='
number|'5'
op|','
nl|'\n'
name|'ephemeral_gb'
op|'='
number|'0'
op|','
name|'swap'
op|'='
number|'0'
op|','
name|'rxtx_factor'
op|'='
number|'0'
op|','
nl|'\n'
name|'vcpu_weight'
op|'='
number|'1'
op|','
name|'extra_specs'
op|'='
op|'{'
op|'}'
op|')'
op|','
nl|'\n'
op|'}'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|variable|_2MB
name|'_2MB'
op|'='
number|'2'
op|'*'
name|'units'
op|'.'
name|'Mi'
op|'/'
name|'units'
op|'.'
name|'Ki'
newline|'\n'
nl|'\n'
DECL|variable|_INSTANCE_NUMA_TOPOLOGIES
name|'_INSTANCE_NUMA_TOPOLOGIES'
op|'='
op|'{'
nl|'\n'
string|"'2mb'"
op|':'
name|'objects'
op|'.'
name|'InstanceNUMATopology'
op|'('
name|'cells'
op|'='
op|'['
nl|'\n'
name|'objects'
op|'.'
name|'InstanceNUMACell'
op|'('
nl|'\n'
name|'id'
op|'='
number|'0'
op|','
name|'cpuset'
op|'='
name|'set'
op|'('
op|'['
number|'1'
op|']'
op|')'
op|','
name|'memory'
op|'='
name|'_2MB'
op|','
name|'pagesize'
op|'='
number|'0'
op|')'
op|','
nl|'\n'
name|'objects'
op|'.'
name|'InstanceNUMACell'
op|'('
nl|'\n'
name|'id'
op|'='
number|'1'
op|','
name|'cpuset'
op|'='
name|'set'
op|'('
op|'['
number|'3'
op|']'
op|')'
op|','
name|'memory'
op|'='
name|'_2MB'
op|','
name|'pagesize'
op|'='
number|'0'
op|')'
op|']'
op|')'
op|','
nl|'\n'
op|'}'
newline|'\n'
nl|'\n'
DECL|variable|_NUMA_LIMIT_TOPOLOGIES
name|'_NUMA_LIMIT_TOPOLOGIES'
op|'='
op|'{'
nl|'\n'
string|"'2mb'"
op|':'
name|'objects'
op|'.'
name|'NUMATopologyLimits'
op|'('
name|'id'
op|'='
number|'0'
op|','
nl|'\n'
DECL|variable|cpu_allocation_ratio
name|'cpu_allocation_ratio'
op|'='
number|'1.0'
op|','
nl|'\n'
DECL|variable|ram_allocation_ratio
name|'ram_allocation_ratio'
op|'='
number|'1.0'
op|')'
op|','
nl|'\n'
op|'}'
newline|'\n'
nl|'\n'
DECL|variable|_NUMA_PAGE_TOPOLOGIES
name|'_NUMA_PAGE_TOPOLOGIES'
op|'='
op|'{'
nl|'\n'
string|"'2kb*8'"
op|':'
name|'objects'
op|'.'
name|'NUMAPagesTopology'
op|'('
name|'size_kb'
op|'='
number|'2'
op|','
name|'total'
op|'='
number|'8'
op|','
name|'used'
op|'='
number|'0'
op|')'
nl|'\n'
op|'}'
newline|'\n'
nl|'\n'
DECL|variable|_NUMA_HOST_TOPOLOGIES
name|'_NUMA_HOST_TOPOLOGIES'
op|'='
op|'{'
nl|'\n'
string|"'2mb'"
op|':'
name|'objects'
op|'.'
name|'NUMATopology'
op|'('
name|'cells'
op|'='
op|'['
nl|'\n'
name|'objects'
op|'.'
name|'NUMACell'
op|'('
name|'id'
op|'='
number|'0'
op|','
name|'cpuset'
op|'='
name|'set'
op|'('
op|'['
number|'1'
op|','
number|'2'
op|']'
op|')'
op|','
name|'memory'
op|'='
name|'_2MB'
op|','
nl|'\n'
name|'cpu_usage'
op|'='
number|'0'
op|','
name|'memory_usage'
op|'='
number|'0'
op|','
nl|'\n'
DECL|variable|mempages
name|'mempages'
op|'='
op|'['
name|'_NUMA_PAGE_TOPOLOGIES'
op|'['
string|"'2kb*8'"
op|']'
op|']'
op|','
nl|'\n'
name|'siblings'
op|'='
op|'['
op|']'
op|','
name|'pinned_cpus'
op|'='
name|'set'
op|'('
op|'['
op|']'
op|')'
op|')'
op|','
nl|'\n'
name|'objects'
op|'.'
name|'NUMACell'
op|'('
name|'id'
op|'='
number|'1'
op|','
name|'cpuset'
op|'='
name|'set'
op|'('
op|'['
number|'3'
op|','
number|'4'
op|']'
op|')'
op|','
name|'memory'
op|'='
name|'_2MB'
op|','
nl|'\n'
name|'cpu_usage'
op|'='
number|'0'
op|','
name|'memory_usage'
op|'='
number|'0'
op|','
nl|'\n'
DECL|variable|mempages
name|'mempages'
op|'='
op|'['
name|'_NUMA_PAGE_TOPOLOGIES'
op|'['
string|"'2kb*8'"
op|']'
op|']'
op|','
nl|'\n'
name|'siblings'
op|'='
op|'['
op|']'
op|','
name|'pinned_cpus'
op|'='
name|'set'
op|'('
op|'['
op|']'
op|')'
op|')'
op|']'
op|')'
op|','
nl|'\n'
op|'}'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|variable|_INSTANCE_FIXTURES
name|'_INSTANCE_FIXTURES'
op|'='
op|'['
nl|'\n'
name|'objects'
op|'.'
name|'Instance'
op|'('
nl|'\n'
DECL|variable|id
name|'id'
op|'='
number|'1'
op|','
nl|'\n'
DECL|variable|host
name|'host'
op|'='
name|'None'
op|','
comment|'# prevent RT trying to lazy-load this'
nl|'\n'
DECL|variable|node
name|'node'
op|'='
name|'None'
op|','
nl|'\n'
DECL|variable|uuid
name|'uuid'
op|'='
string|"'c17741a5-6f3d-44a8-ade8-773dc8c29124'"
op|','
nl|'\n'
DECL|variable|memory_mb
name|'memory_mb'
op|'='
name|'_INSTANCE_TYPE_FIXTURES'
op|'['
number|'1'
op|']'
op|'['
string|"'memory_mb'"
op|']'
op|','
nl|'\n'
DECL|variable|vcpus
name|'vcpus'
op|'='
name|'_INSTANCE_TYPE_FIXTURES'
op|'['
number|'1'
op|']'
op|'['
string|"'vcpus'"
op|']'
op|','
nl|'\n'
DECL|variable|root_gb
name|'root_gb'
op|'='
name|'_INSTANCE_TYPE_FIXTURES'
op|'['
number|'1'
op|']'
op|'['
string|"'root_gb'"
op|']'
op|','
nl|'\n'
DECL|variable|ephemeral_gb
name|'ephemeral_gb'
op|'='
name|'_INSTANCE_TYPE_FIXTURES'
op|'['
number|'1'
op|']'
op|'['
string|"'ephemeral_gb'"
op|']'
op|','
nl|'\n'
DECL|variable|numa_topology
name|'numa_topology'
op|'='
name|'_INSTANCE_NUMA_TOPOLOGIES'
op|'['
string|"'2mb'"
op|']'
op|','
nl|'\n'
DECL|variable|instance_type_id
name|'instance_type_id'
op|'='
number|'1'
op|','
nl|'\n'
DECL|variable|vm_state
name|'vm_state'
op|'='
name|'vm_states'
op|'.'
name|'ACTIVE'
op|','
nl|'\n'
DECL|variable|power_state
name|'power_state'
op|'='
name|'power_state'
op|'.'
name|'RUNNING'
op|','
nl|'\n'
DECL|variable|task_state
name|'task_state'
op|'='
name|'None'
op|','
nl|'\n'
DECL|variable|os_type
name|'os_type'
op|'='
string|"'fake-os'"
op|','
comment|'# Used by the stats collector.'
nl|'\n'
DECL|variable|project_id
name|'project_id'
op|'='
string|"'fake-project'"
op|','
comment|'# Used by the stats collector.'
nl|'\n'
DECL|variable|flavor
name|'flavor'
op|'='
name|'_INSTANCE_TYPE_OBJ_FIXTURES'
op|'['
number|'1'
op|']'
op|','
nl|'\n'
DECL|variable|old_flavor
name|'old_flavor'
op|'='
name|'_INSTANCE_TYPE_OBJ_FIXTURES'
op|'['
number|'1'
op|']'
op|','
nl|'\n'
DECL|variable|new_flavor
name|'new_flavor'
op|'='
name|'_INSTANCE_TYPE_OBJ_FIXTURES'
op|'['
number|'1'
op|']'
op|','
nl|'\n'
op|')'
op|','
nl|'\n'
name|'objects'
op|'.'
name|'Instance'
op|'('
nl|'\n'
DECL|variable|id
name|'id'
op|'='
number|'2'
op|','
nl|'\n'
DECL|variable|host
name|'host'
op|'='
name|'None'
op|','
nl|'\n'
DECL|variable|node
name|'node'
op|'='
name|'None'
op|','
nl|'\n'
DECL|variable|uuid
name|'uuid'
op|'='
string|"'33805b54-dea6-47b8-acb2-22aeb1b57919'"
op|','
nl|'\n'
DECL|variable|memory_mb
name|'memory_mb'
op|'='
name|'_INSTANCE_TYPE_FIXTURES'
op|'['
number|'2'
op|']'
op|'['
string|"'memory_mb'"
op|']'
op|','
nl|'\n'
DECL|variable|vcpus
name|'vcpus'
op|'='
name|'_INSTANCE_TYPE_FIXTURES'
op|'['
number|'2'
op|']'
op|'['
string|"'vcpus'"
op|']'
op|','
nl|'\n'
DECL|variable|root_gb
name|'root_gb'
op|'='
name|'_INSTANCE_TYPE_FIXTURES'
op|'['
number|'2'
op|']'
op|'['
string|"'root_gb'"
op|']'
op|','
nl|'\n'
DECL|variable|ephemeral_gb
name|'ephemeral_gb'
op|'='
name|'_INSTANCE_TYPE_FIXTURES'
op|'['
number|'2'
op|']'
op|'['
string|"'ephemeral_gb'"
op|']'
op|','
nl|'\n'
DECL|variable|numa_topology
name|'numa_topology'
op|'='
name|'None'
op|','
nl|'\n'
DECL|variable|instance_type_id
name|'instance_type_id'
op|'='
number|'2'
op|','
nl|'\n'
DECL|variable|vm_state
name|'vm_state'
op|'='
name|'vm_states'
op|'.'
name|'DELETED'
op|','
nl|'\n'
DECL|variable|power_state
name|'power_state'
op|'='
name|'power_state'
op|'.'
name|'SHUTDOWN'
op|','
nl|'\n'
DECL|variable|task_state
name|'task_state'
op|'='
name|'None'
op|','
nl|'\n'
DECL|variable|os_type
name|'os_type'
op|'='
string|"'fake-os'"
op|','
nl|'\n'
DECL|variable|project_id
name|'project_id'
op|'='
string|"'fake-project-2'"
op|','
nl|'\n'
DECL|variable|flavor
name|'flavor'
op|'='
name|'_INSTANCE_TYPE_OBJ_FIXTURES'
op|'['
number|'2'
op|']'
op|','
nl|'\n'
DECL|variable|old_flavor
name|'old_flavor'
op|'='
name|'_INSTANCE_TYPE_OBJ_FIXTURES'
op|'['
number|'2'
op|']'
op|','
nl|'\n'
DECL|variable|new_flavor
name|'new_flavor'
op|'='
name|'_INSTANCE_TYPE_OBJ_FIXTURES'
op|'['
number|'2'
op|']'
op|','
nl|'\n'
op|')'
op|','
nl|'\n'
op|']'
newline|'\n'
nl|'\n'
DECL|variable|_MIGRATION_FIXTURES
name|'_MIGRATION_FIXTURES'
op|'='
op|'{'
nl|'\n'
comment|'# A migration that has only this compute node as the source host'
nl|'\n'
string|"'source-only'"
op|':'
name|'objects'
op|'.'
name|'Migration'
op|'('
nl|'\n'
DECL|variable|id
name|'id'
op|'='
number|'1'
op|','
nl|'\n'
DECL|variable|instance_uuid
name|'instance_uuid'
op|'='
string|"'f15ecfb0-9bf6-42db-9837-706eb2c4bf08'"
op|','
nl|'\n'
DECL|variable|source_compute
name|'source_compute'
op|'='
string|"'fake-host'"
op|','
nl|'\n'
DECL|variable|dest_compute
name|'dest_compute'
op|'='
string|"'other-host'"
op|','
nl|'\n'
DECL|variable|source_node
name|'source_node'
op|'='
string|"'fake-node'"
op|','
nl|'\n'
DECL|variable|dest_node
name|'dest_node'
op|'='
string|"'other-node'"
op|','
nl|'\n'
DECL|variable|old_instance_type_id
name|'old_instance_type_id'
op|'='
number|'1'
op|','
nl|'\n'
DECL|variable|new_instance_type_id
name|'new_instance_type_id'
op|'='
number|'2'
op|','
nl|'\n'
DECL|variable|migration_type
name|'migration_type'
op|'='
string|"'resize'"
op|','
nl|'\n'
DECL|variable|status
name|'status'
op|'='
string|"'migrating'"
nl|'\n'
op|')'
op|','
nl|'\n'
comment|'# A migration that has only this compute node as the dest host'
nl|'\n'
string|"'dest-only'"
op|':'
name|'objects'
op|'.'
name|'Migration'
op|'('
nl|'\n'
DECL|variable|id
name|'id'
op|'='
number|'2'
op|','
nl|'\n'
DECL|variable|instance_uuid
name|'instance_uuid'
op|'='
string|"'f6ed631a-8645-4b12-8e1e-2fff55795765'"
op|','
nl|'\n'
DECL|variable|source_compute
name|'source_compute'
op|'='
string|"'other-host'"
op|','
nl|'\n'
DECL|variable|dest_compute
name|'dest_compute'
op|'='
string|"'fake-host'"
op|','
nl|'\n'
DECL|variable|source_node
name|'source_node'
op|'='
string|"'other-node'"
op|','
nl|'\n'
DECL|variable|dest_node
name|'dest_node'
op|'='
string|"'fake-node'"
op|','
nl|'\n'
DECL|variable|old_instance_type_id
name|'old_instance_type_id'
op|'='
number|'1'
op|','
nl|'\n'
DECL|variable|new_instance_type_id
name|'new_instance_type_id'
op|'='
number|'2'
op|','
nl|'\n'
DECL|variable|migration_type
name|'migration_type'
op|'='
string|"'resize'"
op|','
nl|'\n'
DECL|variable|status
name|'status'
op|'='
string|"'migrating'"
nl|'\n'
op|')'
op|','
nl|'\n'
comment|'# A migration that has this compute node as both the source and dest host'
nl|'\n'
string|"'source-and-dest'"
op|':'
name|'objects'
op|'.'
name|'Migration'
op|'('
nl|'\n'
DECL|variable|id
name|'id'
op|'='
number|'3'
op|','
nl|'\n'
DECL|variable|instance_uuid
name|'instance_uuid'
op|'='
string|"'f4f0bfea-fe7e-4264-b598-01cb13ef1997'"
op|','
nl|'\n'
DECL|variable|source_compute
name|'source_compute'
op|'='
string|"'fake-host'"
op|','
nl|'\n'
DECL|variable|dest_compute
name|'dest_compute'
op|'='
string|"'fake-host'"
op|','
nl|'\n'
DECL|variable|source_node
name|'source_node'
op|'='
string|"'fake-node'"
op|','
nl|'\n'
DECL|variable|dest_node
name|'dest_node'
op|'='
string|"'fake-node'"
op|','
nl|'\n'
DECL|variable|old_instance_type_id
name|'old_instance_type_id'
op|'='
number|'1'
op|','
nl|'\n'
DECL|variable|new_instance_type_id
name|'new_instance_type_id'
op|'='
number|'2'
op|','
nl|'\n'
DECL|variable|migration_type
name|'migration_type'
op|'='
string|"'resize'"
op|','
nl|'\n'
DECL|variable|status
name|'status'
op|'='
string|"'migrating'"
nl|'\n'
op|')'
op|','
nl|'\n'
comment|'# A migration that has this compute node as destination and is an evac'
nl|'\n'
string|"'dest-only-evac'"
op|':'
name|'objects'
op|'.'
name|'Migration'
op|'('
nl|'\n'
DECL|variable|id
name|'id'
op|'='
number|'4'
op|','
nl|'\n'
DECL|variable|instance_uuid
name|'instance_uuid'
op|'='
string|"'077fb63a-bdc8-4330-90ef-f012082703dc'"
op|','
nl|'\n'
DECL|variable|source_compute
name|'source_compute'
op|'='
string|"'other-host'"
op|','
nl|'\n'
DECL|variable|dest_compute
name|'dest_compute'
op|'='
string|"'fake-host'"
op|','
nl|'\n'
DECL|variable|source_node
name|'source_node'
op|'='
string|"'other-node'"
op|','
nl|'\n'
DECL|variable|dest_node
name|'dest_node'
op|'='
string|"'fake-node'"
op|','
nl|'\n'
DECL|variable|old_instance_type_id
name|'old_instance_type_id'
op|'='
number|'2'
op|','
nl|'\n'
DECL|variable|new_instance_type_id
name|'new_instance_type_id'
op|'='
name|'None'
op|','
nl|'\n'
DECL|variable|migration_type
name|'migration_type'
op|'='
string|"'evacuation'"
op|','
nl|'\n'
DECL|variable|status
name|'status'
op|'='
string|"'pre-migrating'"
nl|'\n'
op|')'
op|','
nl|'\n'
op|'}'
newline|'\n'
nl|'\n'
DECL|variable|_MIGRATION_INSTANCE_FIXTURES
name|'_MIGRATION_INSTANCE_FIXTURES'
op|'='
op|'{'
nl|'\n'
comment|'# source-only'
nl|'\n'
string|"'f15ecfb0-9bf6-42db-9837-706eb2c4bf08'"
op|':'
name|'objects'
op|'.'
name|'Instance'
op|'('
nl|'\n'
DECL|variable|id
name|'id'
op|'='
number|'101'
op|','
nl|'\n'
DECL|variable|host
name|'host'
op|'='
name|'None'
op|','
comment|'# prevent RT trying to lazy-load this'
nl|'\n'
DECL|variable|node
name|'node'
op|'='
name|'None'
op|','
nl|'\n'
DECL|variable|uuid
name|'uuid'
op|'='
string|"'f15ecfb0-9bf6-42db-9837-706eb2c4bf08'"
op|','
nl|'\n'
DECL|variable|memory_mb
name|'memory_mb'
op|'='
name|'_INSTANCE_TYPE_FIXTURES'
op|'['
number|'1'
op|']'
op|'['
string|"'memory_mb'"
op|']'
op|','
nl|'\n'
DECL|variable|vcpus
name|'vcpus'
op|'='
name|'_INSTANCE_TYPE_FIXTURES'
op|'['
number|'1'
op|']'
op|'['
string|"'vcpus'"
op|']'
op|','
nl|'\n'
DECL|variable|root_gb
name|'root_gb'
op|'='
name|'_INSTANCE_TYPE_FIXTURES'
op|'['
number|'1'
op|']'
op|'['
string|"'root_gb'"
op|']'
op|','
nl|'\n'
DECL|variable|ephemeral_gb
name|'ephemeral_gb'
op|'='
name|'_INSTANCE_TYPE_FIXTURES'
op|'['
number|'1'
op|']'
op|'['
string|"'ephemeral_gb'"
op|']'
op|','
nl|'\n'
DECL|variable|numa_topology
name|'numa_topology'
op|'='
name|'_INSTANCE_NUMA_TOPOLOGIES'
op|'['
string|"'2mb'"
op|']'
op|','
nl|'\n'
DECL|variable|instance_type_id
name|'instance_type_id'
op|'='
number|'1'
op|','
nl|'\n'
DECL|variable|vm_state
name|'vm_state'
op|'='
name|'vm_states'
op|'.'
name|'ACTIVE'
op|','
nl|'\n'
DECL|variable|power_state
name|'power_state'
op|'='
name|'power_state'
op|'.'
name|'RUNNING'
op|','
nl|'\n'
DECL|variable|task_state
name|'task_state'
op|'='
name|'task_states'
op|'.'
name|'RESIZE_MIGRATING'
op|','
nl|'\n'
DECL|variable|system_metadata
name|'system_metadata'
op|'='
op|'{'
op|'}'
op|','
nl|'\n'
DECL|variable|os_type
name|'os_type'
op|'='
string|"'fake-os'"
op|','
nl|'\n'
DECL|variable|project_id
name|'project_id'
op|'='
string|"'fake-project'"
op|','
nl|'\n'
DECL|variable|flavor
name|'flavor'
op|'='
name|'_INSTANCE_TYPE_OBJ_FIXTURES'
op|'['
number|'1'
op|']'
op|','
nl|'\n'
DECL|variable|old_flavor
name|'old_flavor'
op|'='
name|'_INSTANCE_TYPE_OBJ_FIXTURES'
op|'['
number|'1'
op|']'
op|','
nl|'\n'
DECL|variable|new_flavor
name|'new_flavor'
op|'='
name|'_INSTANCE_TYPE_OBJ_FIXTURES'
op|'['
number|'2'
op|']'
op|','
nl|'\n'
op|')'
op|','
nl|'\n'
comment|'# dest-only'
nl|'\n'
string|"'f6ed631a-8645-4b12-8e1e-2fff55795765'"
op|':'
name|'objects'
op|'.'
name|'Instance'
op|'('
nl|'\n'
DECL|variable|id
name|'id'
op|'='
number|'102'
op|','
nl|'\n'
DECL|variable|host
name|'host'
op|'='
name|'None'
op|','
comment|'# prevent RT trying to lazy-load this'
nl|'\n'
DECL|variable|node
name|'node'
op|'='
name|'None'
op|','
nl|'\n'
DECL|variable|uuid
name|'uuid'
op|'='
string|"'f6ed631a-8645-4b12-8e1e-2fff55795765'"
op|','
nl|'\n'
DECL|variable|memory_mb
name|'memory_mb'
op|'='
name|'_INSTANCE_TYPE_FIXTURES'
op|'['
number|'2'
op|']'
op|'['
string|"'memory_mb'"
op|']'
op|','
nl|'\n'
DECL|variable|vcpus
name|'vcpus'
op|'='
name|'_INSTANCE_TYPE_FIXTURES'
op|'['
number|'2'
op|']'
op|'['
string|"'vcpus'"
op|']'
op|','
nl|'\n'
DECL|variable|root_gb
name|'root_gb'
op|'='
name|'_INSTANCE_TYPE_FIXTURES'
op|'['
number|'2'
op|']'
op|'['
string|"'root_gb'"
op|']'
op|','
nl|'\n'
DECL|variable|ephemeral_gb
name|'ephemeral_gb'
op|'='
name|'_INSTANCE_TYPE_FIXTURES'
op|'['
number|'2'
op|']'
op|'['
string|"'ephemeral_gb'"
op|']'
op|','
nl|'\n'
DECL|variable|numa_topology
name|'numa_topology'
op|'='
name|'None'
op|','
nl|'\n'
DECL|variable|instance_type_id
name|'instance_type_id'
op|'='
number|'2'
op|','
nl|'\n'
DECL|variable|vm_state
name|'vm_state'
op|'='
name|'vm_states'
op|'.'
name|'ACTIVE'
op|','
nl|'\n'
DECL|variable|power_state
name|'power_state'
op|'='
name|'power_state'
op|'.'
name|'RUNNING'
op|','
nl|'\n'
DECL|variable|task_state
name|'task_state'
op|'='
name|'task_states'
op|'.'
name|'RESIZE_MIGRATING'
op|','
nl|'\n'
DECL|variable|system_metadata
name|'system_metadata'
op|'='
op|'{'
op|'}'
op|','
nl|'\n'
DECL|variable|os_type
name|'os_type'
op|'='
string|"'fake-os'"
op|','
nl|'\n'
DECL|variable|project_id
name|'project_id'
op|'='
string|"'fake-project'"
op|','
nl|'\n'
DECL|variable|flavor
name|'flavor'
op|'='
name|'_INSTANCE_TYPE_OBJ_FIXTURES'
op|'['
number|'2'
op|']'
op|','
nl|'\n'
DECL|variable|old_flavor
name|'old_flavor'
op|'='
name|'_INSTANCE_TYPE_OBJ_FIXTURES'
op|'['
number|'1'
op|']'
op|','
nl|'\n'
DECL|variable|new_flavor
name|'new_flavor'
op|'='
name|'_INSTANCE_TYPE_OBJ_FIXTURES'
op|'['
number|'2'
op|']'
op|','
nl|'\n'
op|')'
op|','
nl|'\n'
comment|'# source-and-dest'
nl|'\n'
string|"'f4f0bfea-fe7e-4264-b598-01cb13ef1997'"
op|':'
name|'objects'
op|'.'
name|'Instance'
op|'('
nl|'\n'
DECL|variable|id
name|'id'
op|'='
number|'3'
op|','
nl|'\n'
DECL|variable|host
name|'host'
op|'='
name|'None'
op|','
comment|'# prevent RT trying to lazy-load this'
nl|'\n'
DECL|variable|node
name|'node'
op|'='
name|'None'
op|','
nl|'\n'
DECL|variable|uuid
name|'uuid'
op|'='
string|"'f4f0bfea-fe7e-4264-b598-01cb13ef1997'"
op|','
nl|'\n'
DECL|variable|memory_mb
name|'memory_mb'
op|'='
name|'_INSTANCE_TYPE_FIXTURES'
op|'['
number|'2'
op|']'
op|'['
string|"'memory_mb'"
op|']'
op|','
nl|'\n'
DECL|variable|vcpus
name|'vcpus'
op|'='
name|'_INSTANCE_TYPE_FIXTURES'
op|'['
number|'2'
op|']'
op|'['
string|"'vcpus'"
op|']'
op|','
nl|'\n'
DECL|variable|root_gb
name|'root_gb'
op|'='
name|'_INSTANCE_TYPE_FIXTURES'
op|'['
number|'2'
op|']'
op|'['
string|"'root_gb'"
op|']'
op|','
nl|'\n'
DECL|variable|ephemeral_gb
name|'ephemeral_gb'
op|'='
name|'_INSTANCE_TYPE_FIXTURES'
op|'['
number|'2'
op|']'
op|'['
string|"'ephemeral_gb'"
op|']'
op|','
nl|'\n'
DECL|variable|numa_topology
name|'numa_topology'
op|'='
name|'None'
op|','
nl|'\n'
DECL|variable|instance_type_id
name|'instance_type_id'
op|'='
number|'2'
op|','
nl|'\n'
DECL|variable|vm_state
name|'vm_state'
op|'='
name|'vm_states'
op|'.'
name|'ACTIVE'
op|','
nl|'\n'
DECL|variable|power_state
name|'power_state'
op|'='
name|'power_state'
op|'.'
name|'RUNNING'
op|','
nl|'\n'
DECL|variable|task_state
name|'task_state'
op|'='
name|'task_states'
op|'.'
name|'RESIZE_MIGRATING'
op|','
nl|'\n'
DECL|variable|system_metadata
name|'system_metadata'
op|'='
op|'{'
op|'}'
op|','
nl|'\n'
DECL|variable|os_type
name|'os_type'
op|'='
string|"'fake-os'"
op|','
nl|'\n'
DECL|variable|project_id
name|'project_id'
op|'='
string|"'fake-project'"
op|','
nl|'\n'
DECL|variable|flavor
name|'flavor'
op|'='
name|'_INSTANCE_TYPE_OBJ_FIXTURES'
op|'['
number|'2'
op|']'
op|','
nl|'\n'
DECL|variable|old_flavor
name|'old_flavor'
op|'='
name|'_INSTANCE_TYPE_OBJ_FIXTURES'
op|'['
number|'1'
op|']'
op|','
nl|'\n'
DECL|variable|new_flavor
name|'new_flavor'
op|'='
name|'_INSTANCE_TYPE_OBJ_FIXTURES'
op|'['
number|'2'
op|']'
op|','
nl|'\n'
op|')'
op|','
nl|'\n'
comment|'# dest-only-evac'
nl|'\n'
string|"'077fb63a-bdc8-4330-90ef-f012082703dc'"
op|':'
name|'objects'
op|'.'
name|'Instance'
op|'('
nl|'\n'
DECL|variable|id
name|'id'
op|'='
number|'102'
op|','
nl|'\n'
DECL|variable|host
name|'host'
op|'='
name|'None'
op|','
comment|'# prevent RT trying to lazy-load this'
nl|'\n'
DECL|variable|node
name|'node'
op|'='
name|'None'
op|','
nl|'\n'
DECL|variable|uuid
name|'uuid'
op|'='
string|"'077fb63a-bdc8-4330-90ef-f012082703dc'"
op|','
nl|'\n'
DECL|variable|memory_mb
name|'memory_mb'
op|'='
name|'_INSTANCE_TYPE_FIXTURES'
op|'['
number|'2'
op|']'
op|'['
string|"'memory_mb'"
op|']'
op|','
nl|'\n'
DECL|variable|vcpus
name|'vcpus'
op|'='
name|'_INSTANCE_TYPE_FIXTURES'
op|'['
number|'2'
op|']'
op|'['
string|"'vcpus'"
op|']'
op|','
nl|'\n'
DECL|variable|root_gb
name|'root_gb'
op|'='
name|'_INSTANCE_TYPE_FIXTURES'
op|'['
number|'2'
op|']'
op|'['
string|"'root_gb'"
op|']'
op|','
nl|'\n'
DECL|variable|ephemeral_gb
name|'ephemeral_gb'
op|'='
name|'_INSTANCE_TYPE_FIXTURES'
op|'['
number|'2'
op|']'
op|'['
string|"'ephemeral_gb'"
op|']'
op|','
nl|'\n'
DECL|variable|numa_topology
name|'numa_topology'
op|'='
name|'None'
op|','
nl|'\n'
DECL|variable|instance_type_id
name|'instance_type_id'
op|'='
number|'2'
op|','
nl|'\n'
DECL|variable|vm_state
name|'vm_state'
op|'='
name|'vm_states'
op|'.'
name|'ACTIVE'
op|','
nl|'\n'
DECL|variable|power_state
name|'power_state'
op|'='
name|'power_state'
op|'.'
name|'RUNNING'
op|','
nl|'\n'
DECL|variable|task_state
name|'task_state'
op|'='
name|'task_states'
op|'.'
name|'REBUILDING'
op|','
nl|'\n'
DECL|variable|system_metadata
name|'system_metadata'
op|'='
op|'{'
op|'}'
op|','
nl|'\n'
DECL|variable|os_type
name|'os_type'
op|'='
string|"'fake-os'"
op|','
nl|'\n'
DECL|variable|project_id
name|'project_id'
op|'='
string|"'fake-project'"
op|','
nl|'\n'
DECL|variable|flavor
name|'flavor'
op|'='
name|'_INSTANCE_TYPE_OBJ_FIXTURES'
op|'['
number|'2'
op|']'
op|','
nl|'\n'
DECL|variable|old_flavor
name|'old_flavor'
op|'='
name|'_INSTANCE_TYPE_OBJ_FIXTURES'
op|'['
number|'1'
op|']'
op|','
nl|'\n'
DECL|variable|new_flavor
name|'new_flavor'
op|'='
name|'_INSTANCE_TYPE_OBJ_FIXTURES'
op|'['
number|'2'
op|']'
op|','
nl|'\n'
op|')'
op|','
nl|'\n'
op|'}'
newline|'\n'
nl|'\n'
DECL|variable|_MIGRATION_CONTEXT_FIXTURES
name|'_MIGRATION_CONTEXT_FIXTURES'
op|'='
op|'{'
nl|'\n'
string|"'f4f0bfea-fe7e-4264-b598-01cb13ef1997'"
op|':'
name|'objects'
op|'.'
name|'MigrationContext'
op|'('
nl|'\n'
DECL|variable|instance_uuid
name|'instance_uuid'
op|'='
string|"'f4f0bfea-fe7e-4264-b598-01cb13ef1997'"
op|','
nl|'\n'
DECL|variable|migration_id
name|'migration_id'
op|'='
number|'3'
op|','
nl|'\n'
DECL|variable|new_numa_topology
name|'new_numa_topology'
op|'='
name|'None'
op|','
nl|'\n'
DECL|variable|old_numa_topology
name|'old_numa_topology'
op|'='
name|'None'
op|')'
op|','
nl|'\n'
string|"'c17741a5-6f3d-44a8-ade8-773dc8c29124'"
op|':'
name|'objects'
op|'.'
name|'MigrationContext'
op|'('
nl|'\n'
DECL|variable|instance_uuid
name|'instance_uuid'
op|'='
string|"'c17741a5-6f3d-44a8-ade8-773dc8c29124'"
op|','
nl|'\n'
DECL|variable|migration_id
name|'migration_id'
op|'='
number|'3'
op|','
nl|'\n'
DECL|variable|new_numa_topology
name|'new_numa_topology'
op|'='
name|'None'
op|','
nl|'\n'
DECL|variable|old_numa_topology
name|'old_numa_topology'
op|'='
name|'None'
op|')'
op|','
nl|'\n'
string|"'f15ecfb0-9bf6-42db-9837-706eb2c4bf08'"
op|':'
name|'objects'
op|'.'
name|'MigrationContext'
op|'('
nl|'\n'
DECL|variable|instance_uuid
name|'instance_uuid'
op|'='
string|"'f15ecfb0-9bf6-42db-9837-706eb2c4bf08'"
op|','
nl|'\n'
DECL|variable|migration_id
name|'migration_id'
op|'='
number|'1'
op|','
nl|'\n'
DECL|variable|new_numa_topology
name|'new_numa_topology'
op|'='
name|'None'
op|','
nl|'\n'
DECL|variable|old_numa_topology
name|'old_numa_topology'
op|'='
name|'_INSTANCE_NUMA_TOPOLOGIES'
op|'['
string|"'2mb'"
op|']'
op|')'
op|','
nl|'\n'
string|"'f6ed631a-8645-4b12-8e1e-2fff55795765'"
op|':'
name|'objects'
op|'.'
name|'MigrationContext'
op|'('
nl|'\n'
DECL|variable|instance_uuid
name|'instance_uuid'
op|'='
string|"'f6ed631a-8645-4b12-8e1e-2fff55795765'"
op|','
nl|'\n'
DECL|variable|migration_id
name|'migration_id'
op|'='
number|'2'
op|','
nl|'\n'
DECL|variable|new_numa_topology
name|'new_numa_topology'
op|'='
name|'_INSTANCE_NUMA_TOPOLOGIES'
op|'['
string|"'2mb'"
op|']'
op|','
nl|'\n'
DECL|variable|old_numa_topology
name|'old_numa_topology'
op|'='
name|'None'
op|')'
op|','
nl|'\n'
string|"'077fb63a-bdc8-4330-90ef-f012082703dc'"
op|':'
name|'objects'
op|'.'
name|'MigrationContext'
op|'('
nl|'\n'
DECL|variable|instance_uuid
name|'instance_uuid'
op|'='
string|"'077fb63a-bdc8-4330-90ef-f012082703dc'"
op|','
nl|'\n'
DECL|variable|migration_id
name|'migration_id'
op|'='
number|'2'
op|','
nl|'\n'
DECL|variable|new_numa_topology
name|'new_numa_topology'
op|'='
name|'None'
op|','
nl|'\n'
DECL|variable|old_numa_topology
name|'old_numa_topology'
op|'='
name|'None'
op|')'
op|','
nl|'\n'
op|'}'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|function|overhead_zero
name|'def'
name|'overhead_zero'
op|'('
name|'instance'
op|')'
op|':'
newline|'\n'
comment|'# Emulate that the driver does not adjust the memory'
nl|'\n'
comment|'# of the instance...'
nl|'\n'
indent|'    '
name|'return'
op|'{'
nl|'\n'
string|"'memory_mb'"
op|':'
number|'0'
nl|'\n'
op|'}'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|function|setup_rt
dedent|''
name|'def'
name|'setup_rt'
op|'('
name|'hostname'
op|','
name|'nodename'
op|','
name|'virt_resources'
op|'='
name|'_VIRT_DRIVER_AVAIL_RESOURCES'
op|','
nl|'\n'
name|'estimate_overhead'
op|'='
name|'overhead_zero'
op|')'
op|':'
newline|'\n'
indent|'    '
string|'"""Sets up the resource tracker instance with mock fixtures.\n\n    :param virt_resources: Optional override of the resource representation\n                           returned by the virt driver\'s\n                           `get_available_resource()` method.\n    :param estimate_overhead: Optional override of a function that should\n                              return overhead of memory given an instance\n                              object. Defaults to returning zero overhead.\n    """'
newline|'\n'
name|'sched_client_mock'
op|'='
name|'mock'
op|'.'
name|'MagicMock'
op|'('
op|')'
newline|'\n'
name|'notifier_mock'
op|'='
name|'mock'
op|'.'
name|'MagicMock'
op|'('
op|')'
newline|'\n'
name|'vd'
op|'='
name|'mock'
op|'.'
name|'MagicMock'
op|'('
op|')'
newline|'\n'
comment|"# Make sure we don't change any global fixtures during tests"
nl|'\n'
name|'virt_resources'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'virt_resources'
op|')'
newline|'\n'
name|'vd'
op|'.'
name|'get_available_resource'
op|'.'
name|'return_value'
op|'='
name|'virt_resources'
newline|'\n'
name|'vd'
op|'.'
name|'estimate_instance_overhead'
op|'.'
name|'side_effect'
op|'='
name|'estimate_overhead'
newline|'\n'
nl|'\n'
name|'with'
name|'test'
op|'.'
name|'nested'
op|'('
nl|'\n'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.scheduler.client.SchedulerClient'"
op|','
nl|'\n'
name|'return_value'
op|'='
name|'sched_client_mock'
op|')'
op|','
nl|'\n'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.rpc.get_notifier'"
op|','
name|'return_value'
op|'='
name|'notifier_mock'
op|')'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'rt'
op|'='
name|'resource_tracker'
op|'.'
name|'ResourceTracker'
op|'('
name|'hostname'
op|','
name|'vd'
op|','
name|'nodename'
op|')'
newline|'\n'
dedent|''
name|'return'
op|'('
name|'rt'
op|','
name|'sched_client_mock'
op|','
name|'vd'
op|')'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|class|BaseTestCase
dedent|''
name|'class'
name|'BaseTestCase'
op|'('
name|'test'
op|'.'
name|'NoDBTestCase'
op|')'
op|':'
newline|'\n'
nl|'\n'
DECL|member|setUp
indent|'    '
name|'def'
name|'setUp'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'super'
op|'('
name|'BaseTestCase'
op|','
name|'self'
op|')'
op|'.'
name|'setUp'
op|'('
op|')'
newline|'\n'
name|'self'
op|'.'
name|'rt'
op|'='
name|'None'
newline|'\n'
name|'self'
op|'.'
name|'flags'
op|'('
name|'my_ip'
op|'='
string|"'1.1.1.1'"
op|')'
newline|'\n'
nl|'\n'
DECL|member|_setup_rt
dedent|''
name|'def'
name|'_setup_rt'
op|'('
name|'self'
op|','
name|'virt_resources'
op|'='
name|'_VIRT_DRIVER_AVAIL_RESOURCES'
op|','
nl|'\n'
name|'estimate_overhead'
op|'='
name|'overhead_zero'
op|')'
op|':'
newline|'\n'
indent|'        '
op|'('
name|'self'
op|'.'
name|'rt'
op|','
name|'self'
op|'.'
name|'sched_client_mock'
op|','
nl|'\n'
name|'self'
op|'.'
name|'driver_mock'
op|')'
op|'='
name|'setup_rt'
op|'('
nl|'\n'
string|"'fake-host'"
op|','
string|"'fake-node'"
op|','
name|'virt_resources'
op|','
name|'estimate_overhead'
op|')'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|class|TestUpdateAvailableResources
dedent|''
dedent|''
name|'class'
name|'TestUpdateAvailableResources'
op|'('
name|'BaseTestCase'
op|')'
op|':'
newline|'\n'
nl|'\n'
DECL|member|_update_available_resources
indent|'    '
name|'def'
name|'_update_available_resources'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
comment|'# We test RT._update separately, since the complexity'
nl|'\n'
comment|'# of the update_available_resource() function is high enough as'
nl|'\n'
comment|'# it is, we just want to focus here on testing the resources'
nl|'\n'
comment|'# parameter that update_available_resource() eventually passes'
nl|'\n'
comment|'# to _update().'
nl|'\n'
indent|'        '
name|'with'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'self'
op|'.'
name|'rt'
op|','
string|"'_update'"
op|')'
name|'as'
name|'update_mock'
op|':'
newline|'\n'
indent|'            '
name|'self'
op|'.'
name|'rt'
op|'.'
name|'update_available_resource'
op|'('
name|'mock'
op|'.'
name|'sentinel'
op|'.'
name|'ctx'
op|')'
newline|'\n'
dedent|''
name|'return'
name|'update_mock'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.ComputeNode.get_by_host_and_nodename'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.MigrationList.get_in_progress_by_host_and_node'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.InstanceList.get_by_host_and_node'"
op|')'
newline|'\n'
DECL|member|test_no_instances_no_migrations_no_reserved
name|'def'
name|'test_no_instances_no_migrations_no_reserved'
op|'('
name|'self'
op|','
name|'get_mock'
op|','
name|'migr_mock'
op|','
nl|'\n'
name|'get_cn_mock'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'self'
op|'.'
name|'flags'
op|'('
name|'reserved_host_disk_mb'
op|'='
number|'0'
op|','
nl|'\n'
name|'reserved_host_memory_mb'
op|'='
number|'0'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'_setup_rt'
op|'('
op|')'
newline|'\n'
nl|'\n'
name|'get_mock'
op|'.'
name|'return_value'
op|'='
op|'['
op|']'
newline|'\n'
name|'migr_mock'
op|'.'
name|'return_value'
op|'='
op|'['
op|']'
newline|'\n'
name|'get_cn_mock'
op|'.'
name|'return_value'
op|'='
name|'_COMPUTE_NODE_FIXTURES'
op|'['
number|'0'
op|']'
newline|'\n'
nl|'\n'
name|'update_mock'
op|'='
name|'self'
op|'.'
name|'_update_available_resources'
op|'('
op|')'
newline|'\n'
nl|'\n'
name|'vd'
op|'='
name|'self'
op|'.'
name|'driver_mock'
newline|'\n'
name|'vd'
op|'.'
name|'get_available_resource'
op|'.'
name|'assert_called_once_with'
op|'('
string|"'fake-node'"
op|')'
newline|'\n'
name|'get_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'mock'
op|'.'
name|'sentinel'
op|'.'
name|'ctx'
op|','
string|"'fake-host'"
op|','
nl|'\n'
string|"'fake-node'"
op|','
nl|'\n'
name|'expected_attrs'
op|'='
op|'['
nl|'\n'
string|"'system_metadata'"
op|','
nl|'\n'
string|"'numa_topology'"
op|','
nl|'\n'
string|"'flavor'"
op|','
nl|'\n'
string|"'migration_context'"
op|']'
op|')'
newline|'\n'
name|'get_cn_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'mock'
op|'.'
name|'sentinel'
op|'.'
name|'ctx'
op|','
string|"'fake-host'"
op|','
nl|'\n'
string|"'fake-node'"
op|')'
newline|'\n'
name|'migr_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'mock'
op|'.'
name|'sentinel'
op|'.'
name|'ctx'
op|','
string|"'fake-host'"
op|','
nl|'\n'
string|"'fake-node'"
op|')'
newline|'\n'
nl|'\n'
name|'expected_resources'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'_COMPUTE_NODE_FIXTURES'
op|'['
number|'0'
op|']'
op|')'
newline|'\n'
name|'vals'
op|'='
op|'{'
nl|'\n'
comment|'# host is added in update_available_resources()'
nl|'\n'
comment|'# before calling _update()'
nl|'\n'
string|"'host'"
op|':'
string|"'fake-host'"
op|','
nl|'\n'
string|"'host_ip'"
op|':'
string|"'1.1.1.1'"
op|','
nl|'\n'
string|"'numa_topology'"
op|':'
name|'None'
op|','
nl|'\n'
string|"'metrics'"
op|':'
string|"'[]'"
op|','
nl|'\n'
string|"'cpu_info'"
op|':'
string|"''"
op|','
nl|'\n'
string|"'hypervisor_hostname'"
op|':'
string|"'fakehost'"
op|','
nl|'\n'
string|"'free_disk_gb'"
op|':'
number|'6'
op|','
nl|'\n'
string|"'hypervisor_version'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'local_gb'"
op|':'
number|'6'
op|','
nl|'\n'
string|"'free_ram_mb'"
op|':'
number|'512'
op|','
nl|'\n'
string|"'memory_mb_used'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'pci_device_pools'"
op|':'
name|'objects'
op|'.'
name|'PciDevicePoolList'
op|'('
op|')'
op|','
nl|'\n'
string|"'vcpus_used'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'hypervisor_type'"
op|':'
string|"'fake'"
op|','
nl|'\n'
string|"'local_gb_used'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'memory_mb'"
op|':'
number|'512'
op|','
nl|'\n'
string|"'current_workload'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'vcpus'"
op|':'
number|'4'
op|','
nl|'\n'
string|"'running_vms'"
op|':'
number|'0'
nl|'\n'
op|'}'
newline|'\n'
name|'_update_compute_node'
op|'('
name|'expected_resources'
op|','
op|'**'
name|'vals'
op|')'
newline|'\n'
name|'update_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'mock'
op|'.'
name|'sentinel'
op|'.'
name|'ctx'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertTrue'
op|'('
name|'obj_base'
op|'.'
name|'obj_equal_prims'
op|'('
name|'expected_resources'
op|','
nl|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|')'
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.ComputeNode.get_by_host_and_nodename'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.MigrationList.get_in_progress_by_host_and_node'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.InstanceList.get_by_host_and_node'"
op|')'
newline|'\n'
DECL|member|test_no_instances_no_migrations_reserved_disk_and_ram
name|'def'
name|'test_no_instances_no_migrations_reserved_disk_and_ram'
op|'('
nl|'\n'
name|'self'
op|','
name|'get_mock'
op|','
name|'migr_mock'
op|','
name|'get_cn_mock'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'self'
op|'.'
name|'flags'
op|'('
name|'reserved_host_disk_mb'
op|'='
number|'1024'
op|','
nl|'\n'
name|'reserved_host_memory_mb'
op|'='
number|'512'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'_setup_rt'
op|'('
op|')'
newline|'\n'
nl|'\n'
name|'get_mock'
op|'.'
name|'return_value'
op|'='
op|'['
op|']'
newline|'\n'
name|'migr_mock'
op|'.'
name|'return_value'
op|'='
op|'['
op|']'
newline|'\n'
name|'get_cn_mock'
op|'.'
name|'return_value'
op|'='
name|'_COMPUTE_NODE_FIXTURES'
op|'['
number|'0'
op|']'
newline|'\n'
nl|'\n'
name|'update_mock'
op|'='
name|'self'
op|'.'
name|'_update_available_resources'
op|'('
op|')'
newline|'\n'
nl|'\n'
name|'get_cn_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'mock'
op|'.'
name|'sentinel'
op|'.'
name|'ctx'
op|','
string|"'fake-host'"
op|','
nl|'\n'
string|"'fake-node'"
op|')'
newline|'\n'
name|'expected_resources'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'_COMPUTE_NODE_FIXTURES'
op|'['
number|'0'
op|']'
op|')'
newline|'\n'
name|'vals'
op|'='
op|'{'
nl|'\n'
comment|'# host is added in update_available_resources()'
nl|'\n'
comment|'# before calling _update()'
nl|'\n'
string|"'host'"
op|':'
string|"'fake-host'"
op|','
nl|'\n'
string|"'host_ip'"
op|':'
string|"'1.1.1.1'"
op|','
nl|'\n'
string|"'numa_topology'"
op|':'
name|'None'
op|','
nl|'\n'
string|"'metrics'"
op|':'
string|"'[]'"
op|','
nl|'\n'
string|"'cpu_info'"
op|':'
string|"''"
op|','
nl|'\n'
string|"'hypervisor_hostname'"
op|':'
string|"'fakehost'"
op|','
nl|'\n'
string|"'free_disk_gb'"
op|':'
number|'5'
op|','
comment|'# 6GB avail - 1 GB reserved'
nl|'\n'
string|"'hypervisor_version'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'local_gb'"
op|':'
number|'6'
op|','
nl|'\n'
string|"'free_ram_mb'"
op|':'
number|'0'
op|','
comment|'# 512MB avail - 512MB reserved'
nl|'\n'
string|"'memory_mb_used'"
op|':'
number|'512'
op|','
comment|'# 0MB used + 512MB reserved'
nl|'\n'
string|"'pci_device_pools'"
op|':'
name|'objects'
op|'.'
name|'PciDevicePoolList'
op|'('
op|')'
op|','
nl|'\n'
string|"'vcpus_used'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'hypervisor_type'"
op|':'
string|"'fake'"
op|','
nl|'\n'
string|"'local_gb_used'"
op|':'
number|'1'
op|','
comment|'# 0GB used + 1 GB reserved'
nl|'\n'
string|"'memory_mb'"
op|':'
number|'512'
op|','
nl|'\n'
string|"'current_workload'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'vcpus'"
op|':'
number|'4'
op|','
nl|'\n'
string|"'running_vms'"
op|':'
number|'0'
nl|'\n'
op|'}'
newline|'\n'
name|'_update_compute_node'
op|'('
name|'expected_resources'
op|','
op|'**'
name|'vals'
op|')'
newline|'\n'
name|'update_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'mock'
op|'.'
name|'sentinel'
op|'.'
name|'ctx'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertTrue'
op|'('
name|'obj_base'
op|'.'
name|'obj_equal_prims'
op|'('
name|'expected_resources'
op|','
nl|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|')'
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.ComputeNode.get_by_host_and_nodename'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.MigrationList.get_in_progress_by_host_and_node'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.InstanceList.get_by_host_and_node'"
op|')'
newline|'\n'
DECL|member|test_some_instances_no_migrations
name|'def'
name|'test_some_instances_no_migrations'
op|'('
name|'self'
op|','
name|'get_mock'
op|','
name|'migr_mock'
op|','
nl|'\n'
name|'get_cn_mock'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'self'
op|'.'
name|'flags'
op|'('
name|'reserved_host_disk_mb'
op|'='
number|'0'
op|','
nl|'\n'
name|'reserved_host_memory_mb'
op|'='
number|'0'
op|')'
newline|'\n'
nl|'\n'
comment|'# Setup virt resources to match used resources to number'
nl|'\n'
comment|'# of defined instances on the hypervisor'
nl|'\n'
name|'virt_resources'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'_VIRT_DRIVER_AVAIL_RESOURCES'
op|')'
newline|'\n'
name|'virt_resources'
op|'.'
name|'update'
op|'('
name|'vcpus_used'
op|'='
number|'1'
op|','
nl|'\n'
name|'memory_mb_used'
op|'='
number|'128'
op|','
nl|'\n'
name|'local_gb_used'
op|'='
number|'1'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'_setup_rt'
op|'('
name|'virt_resources'
op|'='
name|'virt_resources'
op|')'
newline|'\n'
nl|'\n'
name|'get_mock'
op|'.'
name|'return_value'
op|'='
name|'_INSTANCE_FIXTURES'
newline|'\n'
name|'migr_mock'
op|'.'
name|'return_value'
op|'='
op|'['
op|']'
newline|'\n'
name|'get_cn_mock'
op|'.'
name|'return_value'
op|'='
name|'_COMPUTE_NODE_FIXTURES'
op|'['
number|'0'
op|']'
newline|'\n'
nl|'\n'
name|'update_mock'
op|'='
name|'self'
op|'.'
name|'_update_available_resources'
op|'('
op|')'
newline|'\n'
nl|'\n'
name|'get_cn_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'mock'
op|'.'
name|'sentinel'
op|'.'
name|'ctx'
op|','
string|"'fake-host'"
op|','
nl|'\n'
string|"'fake-node'"
op|')'
newline|'\n'
name|'expected_resources'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'_COMPUTE_NODE_FIXTURES'
op|'['
number|'0'
op|']'
op|')'
newline|'\n'
name|'vals'
op|'='
op|'{'
nl|'\n'
comment|'# host is added in update_available_resources()'
nl|'\n'
comment|'# before calling _update()'
nl|'\n'
string|"'host'"
op|':'
string|"'fake-host'"
op|','
nl|'\n'
string|"'host_ip'"
op|':'
string|"'1.1.1.1'"
op|','
nl|'\n'
string|"'numa_topology'"
op|':'
name|'None'
op|','
nl|'\n'
string|"'metrics'"
op|':'
string|"'[]'"
op|','
nl|'\n'
string|"'cpu_info'"
op|':'
string|"''"
op|','
nl|'\n'
string|"'hypervisor_hostname'"
op|':'
string|"'fakehost'"
op|','
nl|'\n'
string|"'free_disk_gb'"
op|':'
number|'5'
op|','
comment|'# 6 - 1 used'
nl|'\n'
string|"'hypervisor_version'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'local_gb'"
op|':'
number|'6'
op|','
nl|'\n'
string|"'free_ram_mb'"
op|':'
number|'384'
op|','
comment|'# 512 - 128 used'
nl|'\n'
string|"'memory_mb_used'"
op|':'
number|'128'
op|','
nl|'\n'
string|"'pci_device_pools'"
op|':'
name|'objects'
op|'.'
name|'PciDevicePoolList'
op|'('
op|')'
op|','
nl|'\n'
string|"'vcpus_used'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'hypervisor_type'"
op|':'
string|"'fake'"
op|','
nl|'\n'
string|"'local_gb_used'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'memory_mb'"
op|':'
number|'512'
op|','
nl|'\n'
string|"'current_workload'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'vcpus'"
op|':'
number|'4'
op|','
nl|'\n'
string|"'running_vms'"
op|':'
number|'1'
comment|'# One active instance'
nl|'\n'
op|'}'
newline|'\n'
name|'_update_compute_node'
op|'('
name|'expected_resources'
op|','
op|'**'
name|'vals'
op|')'
newline|'\n'
name|'update_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'mock'
op|'.'
name|'sentinel'
op|'.'
name|'ctx'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertTrue'
op|'('
name|'obj_base'
op|'.'
name|'obj_equal_prims'
op|'('
name|'expected_resources'
op|','
nl|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|')'
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.ComputeNode.get_by_host_and_nodename'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.MigrationList.get_in_progress_by_host_and_node'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.InstanceList.get_by_host_and_node'"
op|')'
newline|'\n'
DECL|member|test_orphaned_instances_no_migrations
name|'def'
name|'test_orphaned_instances_no_migrations'
op|'('
name|'self'
op|','
name|'get_mock'
op|','
name|'migr_mock'
op|','
nl|'\n'
name|'get_cn_mock'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'self'
op|'.'
name|'flags'
op|'('
name|'reserved_host_disk_mb'
op|'='
number|'0'
op|','
nl|'\n'
name|'reserved_host_memory_mb'
op|'='
number|'0'
op|')'
newline|'\n'
nl|'\n'
comment|'# Setup virt resources to match used resources to number'
nl|'\n'
comment|'# of defined instances on the hypervisor'
nl|'\n'
name|'virt_resources'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'_VIRT_DRIVER_AVAIL_RESOURCES'
op|')'
newline|'\n'
name|'virt_resources'
op|'.'
name|'update'
op|'('
name|'memory_mb_used'
op|'='
number|'64'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'_setup_rt'
op|'('
name|'virt_resources'
op|'='
name|'virt_resources'
op|')'
newline|'\n'
nl|'\n'
name|'get_mock'
op|'.'
name|'return_value'
op|'='
op|'['
op|']'
newline|'\n'
name|'migr_mock'
op|'.'
name|'return_value'
op|'='
op|'['
op|']'
newline|'\n'
name|'get_cn_mock'
op|'.'
name|'return_value'
op|'='
name|'_COMPUTE_NODE_FIXTURES'
op|'['
number|'0'
op|']'
newline|'\n'
nl|'\n'
comment|'# Orphaned instances are those that the virt driver has on'
nl|'\n'
comment|'# record as consuming resources on the compute node, but the'
nl|'\n'
comment|'# Nova database has no record of the instance being active'
nl|'\n'
comment|'# on the host. For some reason, the resource tracker only'
nl|'\n'
comment|"# considers orphaned instance's memory usage in its calculations"
nl|'\n'
comment|'# of free resources...'
nl|'\n'
name|'orphaned_usages'
op|'='
op|'{'
nl|'\n'
string|"'71ed7ef6-9d2e-4c65-9f4e-90bb6b76261d'"
op|':'
op|'{'
nl|'\n'
comment|'# Yes, the return result format of get_per_instance_usage'
nl|'\n'
comment|'# is indeed this stupid and redundant. Also note that the'
nl|'\n'
comment|'# libvirt driver just returns an empty dict always for this'
nl|'\n'
comment|'# method and so who the heck knows whether this stuff'
nl|'\n'
comment|'# actually works.'
nl|'\n'
string|"'uuid'"
op|':'
string|"'71ed7ef6-9d2e-4c65-9f4e-90bb6b76261d'"
op|','
nl|'\n'
string|"'memory_mb'"
op|':'
number|'64'
nl|'\n'
op|'}'
nl|'\n'
op|'}'
newline|'\n'
name|'vd'
op|'='
name|'self'
op|'.'
name|'driver_mock'
newline|'\n'
name|'vd'
op|'.'
name|'get_per_instance_usage'
op|'.'
name|'return_value'
op|'='
name|'orphaned_usages'
newline|'\n'
nl|'\n'
name|'update_mock'
op|'='
name|'self'
op|'.'
name|'_update_available_resources'
op|'('
op|')'
newline|'\n'
nl|'\n'
name|'get_cn_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'mock'
op|'.'
name|'sentinel'
op|'.'
name|'ctx'
op|','
string|"'fake-host'"
op|','
nl|'\n'
string|"'fake-node'"
op|')'
newline|'\n'
name|'expected_resources'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'_COMPUTE_NODE_FIXTURES'
op|'['
number|'0'
op|']'
op|')'
newline|'\n'
name|'vals'
op|'='
op|'{'
nl|'\n'
comment|'# host is added in update_available_resources()'
nl|'\n'
comment|'# before calling _update()'
nl|'\n'
string|"'host'"
op|':'
string|"'fake-host'"
op|','
nl|'\n'
string|"'host_ip'"
op|':'
string|"'1.1.1.1'"
op|','
nl|'\n'
string|"'numa_topology'"
op|':'
name|'None'
op|','
nl|'\n'
string|"'metrics'"
op|':'
string|"'[]'"
op|','
nl|'\n'
string|"'cpu_info'"
op|':'
string|"''"
op|','
nl|'\n'
string|"'hypervisor_hostname'"
op|':'
string|"'fakehost'"
op|','
nl|'\n'
string|"'free_disk_gb'"
op|':'
number|'6'
op|','
nl|'\n'
string|"'hypervisor_version'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'local_gb'"
op|':'
number|'6'
op|','
nl|'\n'
string|"'free_ram_mb'"
op|':'
number|'448'
op|','
comment|'# 512 - 64 orphaned usage'
nl|'\n'
string|"'memory_mb_used'"
op|':'
number|'64'
op|','
nl|'\n'
string|"'pci_device_pools'"
op|':'
name|'objects'
op|'.'
name|'PciDevicePoolList'
op|'('
op|')'
op|','
nl|'\n'
string|"'vcpus_used'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'hypervisor_type'"
op|':'
string|"'fake'"
op|','
nl|'\n'
string|"'local_gb_used'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'memory_mb'"
op|':'
number|'512'
op|','
nl|'\n'
string|"'current_workload'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'vcpus'"
op|':'
number|'4'
op|','
nl|'\n'
comment|'# Yep, for some reason, orphaned instances are not counted'
nl|'\n'
comment|'# as running VMs...'
nl|'\n'
string|"'running_vms'"
op|':'
number|'0'
nl|'\n'
op|'}'
newline|'\n'
name|'_update_compute_node'
op|'('
name|'expected_resources'
op|','
op|'**'
name|'vals'
op|')'
newline|'\n'
name|'update_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'mock'
op|'.'
name|'sentinel'
op|'.'
name|'ctx'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertTrue'
op|'('
name|'obj_base'
op|'.'
name|'obj_equal_prims'
op|'('
name|'expected_resources'
op|','
nl|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|')'
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.ComputeNode.get_by_host_and_nodename'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.MigrationList.get_in_progress_by_host_and_node'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.Instance.get_by_uuid'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.InstanceList.get_by_host_and_node'"
op|')'
newline|'\n'
DECL|member|test_no_instances_source_migration
name|'def'
name|'test_no_instances_source_migration'
op|'('
name|'self'
op|','
name|'get_mock'
op|','
name|'get_inst_mock'
op|','
nl|'\n'
name|'migr_mock'
op|','
name|'get_cn_mock'
op|')'
op|':'
newline|'\n'
comment|'# We test the behavior of update_available_resource() when'
nl|'\n'
comment|'# there is an active migration that involves this compute node'
nl|'\n'
comment|'# as the source host not the destination host, and the resource'
nl|'\n'
comment|'# tracker does not have any instances assigned to it. This is'
nl|'\n'
comment|'# the case when a migration from this compute host to another'
nl|'\n'
comment|'# has been completed, but the user has not confirmed the resize'
nl|'\n'
comment|'# yet, so the resource tracker must continue to keep the resources'
nl|'\n'
comment|'# for the original instance type available on the source compute'
nl|'\n'
comment|'# node in case of a revert of the resize.'
nl|'\n'
indent|'        '
name|'self'
op|'.'
name|'flags'
op|'('
name|'reserved_host_disk_mb'
op|'='
number|'0'
op|','
nl|'\n'
name|'reserved_host_memory_mb'
op|'='
number|'0'
op|')'
newline|'\n'
nl|'\n'
comment|'# Setup virt resources to match used resources to number'
nl|'\n'
comment|'# of defined instances on the hypervisor'
nl|'\n'
name|'virt_resources'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'_VIRT_DRIVER_AVAIL_RESOURCES'
op|')'
newline|'\n'
name|'virt_resources'
op|'.'
name|'update'
op|'('
name|'vcpus_used'
op|'='
number|'4'
op|','
nl|'\n'
name|'memory_mb_used'
op|'='
number|'128'
op|','
nl|'\n'
name|'local_gb_used'
op|'='
number|'1'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'_setup_rt'
op|'('
name|'virt_resources'
op|'='
name|'virt_resources'
op|')'
newline|'\n'
nl|'\n'
name|'get_mock'
op|'.'
name|'return_value'
op|'='
op|'['
op|']'
newline|'\n'
name|'migr_obj'
op|'='
name|'_MIGRATION_FIXTURES'
op|'['
string|"'source-only'"
op|']'
newline|'\n'
name|'migr_mock'
op|'.'
name|'return_value'
op|'='
op|'['
name|'migr_obj'
op|']'
newline|'\n'
name|'get_cn_mock'
op|'.'
name|'return_value'
op|'='
name|'_COMPUTE_NODE_FIXTURES'
op|'['
number|'0'
op|']'
newline|'\n'
comment|'# Migration.instance property is accessed in the migration'
nl|'\n'
comment|'# processing code, and this property calls'
nl|'\n'
comment|'# objects.Instance.get_by_uuid, so we have the migration return'
nl|'\n'
name|'inst_uuid'
op|'='
name|'migr_obj'
op|'.'
name|'instance_uuid'
newline|'\n'
name|'instance'
op|'='
name|'_MIGRATION_INSTANCE_FIXTURES'
op|'['
name|'inst_uuid'
op|']'
op|'.'
name|'obj_clone'
op|'('
op|')'
newline|'\n'
name|'get_inst_mock'
op|'.'
name|'return_value'
op|'='
name|'instance'
newline|'\n'
name|'instance'
op|'.'
name|'migration_context'
op|'='
name|'_MIGRATION_CONTEXT_FIXTURES'
op|'['
name|'inst_uuid'
op|']'
newline|'\n'
nl|'\n'
name|'update_mock'
op|'='
name|'self'
op|'.'
name|'_update_available_resources'
op|'('
op|')'
newline|'\n'
nl|'\n'
name|'get_cn_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'mock'
op|'.'
name|'sentinel'
op|'.'
name|'ctx'
op|','
string|"'fake-host'"
op|','
nl|'\n'
string|"'fake-node'"
op|')'
newline|'\n'
name|'expected_resources'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'_COMPUTE_NODE_FIXTURES'
op|'['
number|'0'
op|']'
op|')'
newline|'\n'
name|'vals'
op|'='
op|'{'
nl|'\n'
comment|'# host is added in update_available_resources()'
nl|'\n'
comment|'# before calling _update()'
nl|'\n'
string|"'host'"
op|':'
string|"'fake-host'"
op|','
nl|'\n'
string|"'host_ip'"
op|':'
string|"'1.1.1.1'"
op|','
nl|'\n'
string|"'numa_topology'"
op|':'
name|'None'
op|','
nl|'\n'
string|"'metrics'"
op|':'
string|"'[]'"
op|','
nl|'\n'
string|"'cpu_info'"
op|':'
string|"''"
op|','
nl|'\n'
string|"'hypervisor_hostname'"
op|':'
string|"'fakehost'"
op|','
nl|'\n'
string|"'free_disk_gb'"
op|':'
number|'5'
op|','
nl|'\n'
string|"'hypervisor_version'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'local_gb'"
op|':'
number|'6'
op|','
nl|'\n'
string|"'free_ram_mb'"
op|':'
number|'384'
op|','
comment|'# 512 total - 128 for possible revert of orig'
nl|'\n'
string|"'memory_mb_used'"
op|':'
number|'128'
op|','
comment|'# 128 possible revert amount'
nl|'\n'
string|"'pci_device_pools'"
op|':'
name|'objects'
op|'.'
name|'PciDevicePoolList'
op|'('
op|')'
op|','
nl|'\n'
string|"'vcpus_used'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'hypervisor_type'"
op|':'
string|"'fake'"
op|','
nl|'\n'
string|"'local_gb_used'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'memory_mb'"
op|':'
number|'512'
op|','
nl|'\n'
string|"'current_workload'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'vcpus'"
op|':'
number|'4'
op|','
nl|'\n'
string|"'running_vms'"
op|':'
number|'0'
nl|'\n'
op|'}'
newline|'\n'
name|'_update_compute_node'
op|'('
name|'expected_resources'
op|','
op|'**'
name|'vals'
op|')'
newline|'\n'
name|'update_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'mock'
op|'.'
name|'sentinel'
op|'.'
name|'ctx'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertTrue'
op|'('
name|'obj_base'
op|'.'
name|'obj_equal_prims'
op|'('
name|'expected_resources'
op|','
nl|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|')'
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.ComputeNode.get_by_host_and_nodename'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.MigrationList.get_in_progress_by_host_and_node'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.Instance.get_by_uuid'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.InstanceList.get_by_host_and_node'"
op|')'
newline|'\n'
DECL|member|test_no_instances_dest_migration
name|'def'
name|'test_no_instances_dest_migration'
op|'('
name|'self'
op|','
name|'get_mock'
op|','
name|'get_inst_mock'
op|','
nl|'\n'
name|'migr_mock'
op|','
name|'get_cn_mock'
op|')'
op|':'
newline|'\n'
comment|'# We test the behavior of update_available_resource() when'
nl|'\n'
comment|'# there is an active migration that involves this compute node'
nl|'\n'
comment|'# as the destination host not the source host, and the resource'
nl|'\n'
comment|'# tracker does not yet have any instances assigned to it. This is'
nl|'\n'
comment|'# the case when a migration to this compute host from another host'
nl|'\n'
comment|'# is in progress, but the user has not confirmed the resize'
nl|'\n'
comment|'# yet, so the resource tracker must reserve the resources'
nl|'\n'
comment|"# for the possibly-to-be-confirmed instance's instance type"
nl|'\n'
comment|'# node in case of a confirm of the resize.'
nl|'\n'
indent|'        '
name|'self'
op|'.'
name|'flags'
op|'('
name|'reserved_host_disk_mb'
op|'='
number|'0'
op|','
nl|'\n'
name|'reserved_host_memory_mb'
op|'='
number|'0'
op|')'
newline|'\n'
nl|'\n'
comment|'# Setup virt resources to match used resources to number'
nl|'\n'
comment|'# of defined instances on the hypervisor'
nl|'\n'
name|'virt_resources'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'_VIRT_DRIVER_AVAIL_RESOURCES'
op|')'
newline|'\n'
name|'virt_resources'
op|'.'
name|'update'
op|'('
name|'vcpus_used'
op|'='
number|'2'
op|','
nl|'\n'
name|'memory_mb_used'
op|'='
number|'256'
op|','
nl|'\n'
name|'local_gb_used'
op|'='
number|'5'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'_setup_rt'
op|'('
name|'virt_resources'
op|'='
name|'virt_resources'
op|')'
newline|'\n'
nl|'\n'
name|'get_mock'
op|'.'
name|'return_value'
op|'='
op|'['
op|']'
newline|'\n'
name|'migr_obj'
op|'='
name|'_MIGRATION_FIXTURES'
op|'['
string|"'dest-only'"
op|']'
newline|'\n'
name|'migr_mock'
op|'.'
name|'return_value'
op|'='
op|'['
name|'migr_obj'
op|']'
newline|'\n'
name|'inst_uuid'
op|'='
name|'migr_obj'
op|'.'
name|'instance_uuid'
newline|'\n'
name|'instance'
op|'='
name|'_MIGRATION_INSTANCE_FIXTURES'
op|'['
name|'inst_uuid'
op|']'
op|'.'
name|'obj_clone'
op|'('
op|')'
newline|'\n'
name|'get_inst_mock'
op|'.'
name|'return_value'
op|'='
name|'instance'
newline|'\n'
name|'get_cn_mock'
op|'.'
name|'return_value'
op|'='
name|'_COMPUTE_NODE_FIXTURES'
op|'['
number|'0'
op|']'
newline|'\n'
name|'instance'
op|'.'
name|'migration_context'
op|'='
name|'_MIGRATION_CONTEXT_FIXTURES'
op|'['
name|'inst_uuid'
op|']'
newline|'\n'
nl|'\n'
name|'update_mock'
op|'='
name|'self'
op|'.'
name|'_update_available_resources'
op|'('
op|')'
newline|'\n'
nl|'\n'
name|'get_cn_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'mock'
op|'.'
name|'sentinel'
op|'.'
name|'ctx'
op|','
string|"'fake-host'"
op|','
nl|'\n'
string|"'fake-node'"
op|')'
newline|'\n'
name|'expected_resources'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'_COMPUTE_NODE_FIXTURES'
op|'['
number|'0'
op|']'
op|')'
newline|'\n'
name|'vals'
op|'='
op|'{'
nl|'\n'
comment|'# host is added in update_available_resources()'
nl|'\n'
comment|'# before calling _update()'
nl|'\n'
string|"'host'"
op|':'
string|"'fake-host'"
op|','
nl|'\n'
string|"'host_ip'"
op|':'
string|"'1.1.1.1'"
op|','
nl|'\n'
string|"'numa_topology'"
op|':'
name|'None'
op|','
nl|'\n'
string|"'metrics'"
op|':'
string|"'[]'"
op|','
nl|'\n'
string|"'cpu_info'"
op|':'
string|"''"
op|','
nl|'\n'
string|"'hypervisor_hostname'"
op|':'
string|"'fakehost'"
op|','
nl|'\n'
string|"'free_disk_gb'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'hypervisor_version'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'local_gb'"
op|':'
number|'6'
op|','
nl|'\n'
string|"'free_ram_mb'"
op|':'
number|'256'
op|','
comment|'# 512 total - 256 for possible confirm of new'
nl|'\n'
string|"'memory_mb_used'"
op|':'
number|'256'
op|','
comment|'# 256 possible confirmed amount'
nl|'\n'
string|"'pci_device_pools'"
op|':'
name|'objects'
op|'.'
name|'PciDevicePoolList'
op|'('
op|')'
op|','
nl|'\n'
string|"'vcpus_used'"
op|':'
number|'2'
op|','
nl|'\n'
string|"'hypervisor_type'"
op|':'
string|"'fake'"
op|','
nl|'\n'
string|"'local_gb_used'"
op|':'
number|'5'
op|','
nl|'\n'
string|"'memory_mb'"
op|':'
number|'512'
op|','
nl|'\n'
string|"'current_workload'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'vcpus'"
op|':'
number|'4'
op|','
nl|'\n'
string|"'running_vms'"
op|':'
number|'0'
nl|'\n'
op|'}'
newline|'\n'
name|'_update_compute_node'
op|'('
name|'expected_resources'
op|','
op|'**'
name|'vals'
op|')'
newline|'\n'
name|'update_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'mock'
op|'.'
name|'sentinel'
op|'.'
name|'ctx'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertTrue'
op|'('
name|'obj_base'
op|'.'
name|'obj_equal_prims'
op|'('
name|'expected_resources'
op|','
nl|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|')'
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.ComputeNode.get_by_host_and_nodename'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.MigrationList.get_in_progress_by_host_and_node'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.Instance.get_by_uuid'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.InstanceList.get_by_host_and_node'"
op|')'
newline|'\n'
DECL|member|test_no_instances_dest_evacuation
name|'def'
name|'test_no_instances_dest_evacuation'
op|'('
name|'self'
op|','
name|'get_mock'
op|','
name|'get_inst_mock'
op|','
nl|'\n'
name|'migr_mock'
op|','
name|'get_cn_mock'
op|')'
op|':'
newline|'\n'
comment|'# We test the behavior of update_available_resource() when'
nl|'\n'
comment|'# there is an active evacuation that involves this compute node'
nl|'\n'
comment|'# as the destination host not the source host, and the resource'
nl|'\n'
comment|'# tracker does not yet have any instances assigned to it. This is'
nl|'\n'
comment|'# the case when a migration to this compute host from another host'
nl|'\n'
comment|'# is in progress, but not finished yet.'
nl|'\n'
indent|'        '
name|'self'
op|'.'
name|'flags'
op|'('
name|'reserved_host_disk_mb'
op|'='
number|'0'
op|','
nl|'\n'
name|'reserved_host_memory_mb'
op|'='
number|'0'
op|')'
newline|'\n'
nl|'\n'
comment|'# Setup virt resources to match used resources to number'
nl|'\n'
comment|'# of defined instances on the hypervisor'
nl|'\n'
name|'virt_resources'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'_VIRT_DRIVER_AVAIL_RESOURCES'
op|')'
newline|'\n'
name|'virt_resources'
op|'.'
name|'update'
op|'('
name|'vcpus_used'
op|'='
number|'2'
op|','
nl|'\n'
name|'memory_mb_used'
op|'='
number|'256'
op|','
nl|'\n'
name|'local_gb_used'
op|'='
number|'5'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'_setup_rt'
op|'('
name|'virt_resources'
op|'='
name|'virt_resources'
op|')'
newline|'\n'
nl|'\n'
name|'get_mock'
op|'.'
name|'return_value'
op|'='
op|'['
op|']'
newline|'\n'
name|'migr_obj'
op|'='
name|'_MIGRATION_FIXTURES'
op|'['
string|"'dest-only-evac'"
op|']'
newline|'\n'
name|'migr_mock'
op|'.'
name|'return_value'
op|'='
op|'['
name|'migr_obj'
op|']'
newline|'\n'
name|'inst_uuid'
op|'='
name|'migr_obj'
op|'.'
name|'instance_uuid'
newline|'\n'
name|'instance'
op|'='
name|'_MIGRATION_INSTANCE_FIXTURES'
op|'['
name|'inst_uuid'
op|']'
op|'.'
name|'obj_clone'
op|'('
op|')'
newline|'\n'
name|'get_inst_mock'
op|'.'
name|'return_value'
op|'='
name|'instance'
newline|'\n'
name|'get_cn_mock'
op|'.'
name|'return_value'
op|'='
name|'_COMPUTE_NODE_FIXTURES'
op|'['
number|'0'
op|']'
newline|'\n'
name|'instance'
op|'.'
name|'migration_context'
op|'='
name|'_MIGRATION_CONTEXT_FIXTURES'
op|'['
name|'inst_uuid'
op|']'
newline|'\n'
nl|'\n'
name|'update_mock'
op|'='
name|'self'
op|'.'
name|'_update_available_resources'
op|'('
op|')'
newline|'\n'
nl|'\n'
name|'get_cn_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'mock'
op|'.'
name|'sentinel'
op|'.'
name|'ctx'
op|','
string|"'fake-host'"
op|','
nl|'\n'
string|"'fake-node'"
op|')'
newline|'\n'
name|'expected_resources'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'_COMPUTE_NODE_FIXTURES'
op|'['
number|'0'
op|']'
op|')'
newline|'\n'
name|'vals'
op|'='
op|'{'
nl|'\n'
comment|'# host is added in update_available_resources()'
nl|'\n'
comment|'# before calling _update()'
nl|'\n'
string|"'host'"
op|':'
string|"'fake-host'"
op|','
nl|'\n'
string|"'host_ip'"
op|':'
string|"'1.1.1.1'"
op|','
nl|'\n'
string|"'numa_topology'"
op|':'
name|'None'
op|','
nl|'\n'
string|"'metrics'"
op|':'
string|"'[]'"
op|','
nl|'\n'
string|"'cpu_info'"
op|':'
string|"''"
op|','
nl|'\n'
string|"'hypervisor_hostname'"
op|':'
string|"'fakehost'"
op|','
nl|'\n'
string|"'free_disk_gb'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'hypervisor_version'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'local_gb'"
op|':'
number|'6'
op|','
nl|'\n'
string|"'free_ram_mb'"
op|':'
number|'256'
op|','
comment|'# 512 total - 256 for possible confirm of new'
nl|'\n'
string|"'memory_mb_used'"
op|':'
number|'256'
op|','
comment|'# 256 possible confirmed amount'
nl|'\n'
string|"'pci_device_pools'"
op|':'
name|'objects'
op|'.'
name|'PciDevicePoolList'
op|'('
op|')'
op|','
nl|'\n'
string|"'vcpus_used'"
op|':'
number|'2'
op|','
nl|'\n'
string|"'hypervisor_type'"
op|':'
string|"'fake'"
op|','
nl|'\n'
string|"'local_gb_used'"
op|':'
number|'5'
op|','
nl|'\n'
string|"'memory_mb'"
op|':'
number|'512'
op|','
nl|'\n'
string|"'current_workload'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'vcpus'"
op|':'
number|'4'
op|','
nl|'\n'
string|"'running_vms'"
op|':'
number|'0'
nl|'\n'
op|'}'
newline|'\n'
name|'_update_compute_node'
op|'('
name|'expected_resources'
op|','
op|'**'
name|'vals'
op|')'
newline|'\n'
name|'update_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'mock'
op|'.'
name|'sentinel'
op|'.'
name|'ctx'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertTrue'
op|'('
name|'obj_base'
op|'.'
name|'obj_equal_prims'
op|'('
name|'expected_resources'
op|','
nl|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|')'
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.MigrationContext.get_by_instance_uuid'"
op|','
nl|'\n'
name|'return_value'
op|'='
name|'None'
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.ComputeNode.get_by_host_and_nodename'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.MigrationList.get_in_progress_by_host_and_node'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.Instance.get_by_uuid'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.InstanceList.get_by_host_and_node'"
op|')'
newline|'\n'
DECL|member|test_some_instances_source_and_dest_migration
name|'def'
name|'test_some_instances_source_and_dest_migration'
op|'('
name|'self'
op|','
name|'get_mock'
op|','
nl|'\n'
name|'get_inst_mock'
op|','
name|'migr_mock'
op|','
nl|'\n'
name|'get_cn_mock'
op|','
nl|'\n'
name|'get_mig_ctxt_mock'
op|')'
op|':'
newline|'\n'
comment|'# We test the behavior of update_available_resource() when'
nl|'\n'
comment|'# there is an active migration that involves this compute node'
nl|'\n'
comment|'# as the destination host AND the source host, and the resource'
nl|'\n'
comment|'# tracker has a few instances assigned to it, including the'
nl|'\n'
comment|'# instance that is resizing to this same compute node. The tracking'
nl|'\n'
comment|'# of resource amounts takes into account both the old and new'
nl|'\n'
comment|'# resize instance types as taking up space on the node.'
nl|'\n'
indent|'        '
name|'self'
op|'.'
name|'flags'
op|'('
name|'reserved_host_disk_mb'
op|'='
number|'0'
op|','
nl|'\n'
name|'reserved_host_memory_mb'
op|'='
number|'0'
op|')'
newline|'\n'
nl|'\n'
comment|'# Setup virt resources to match used resources to number'
nl|'\n'
comment|'# of defined instances on the hypervisor'
nl|'\n'
name|'virt_resources'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'_VIRT_DRIVER_AVAIL_RESOURCES'
op|')'
newline|'\n'
name|'virt_resources'
op|'.'
name|'update'
op|'('
name|'vcpus_used'
op|'='
number|'4'
op|','
nl|'\n'
name|'memory_mb_used'
op|'='
number|'512'
op|','
nl|'\n'
name|'local_gb_used'
op|'='
number|'7'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'_setup_rt'
op|'('
name|'virt_resources'
op|'='
name|'virt_resources'
op|')'
newline|'\n'
nl|'\n'
name|'migr_obj'
op|'='
name|'_MIGRATION_FIXTURES'
op|'['
string|"'source-and-dest'"
op|']'
newline|'\n'
name|'migr_mock'
op|'.'
name|'return_value'
op|'='
op|'['
name|'migr_obj'
op|']'
newline|'\n'
name|'inst_uuid'
op|'='
name|'migr_obj'
op|'.'
name|'instance_uuid'
newline|'\n'
comment|'# The resizing instance has already had its instance type'
nl|'\n'
comment|'# changed to the *new* instance type (the bigger one, instance type 2)'
nl|'\n'
name|'resizing_instance'
op|'='
name|'_MIGRATION_INSTANCE_FIXTURES'
op|'['
name|'inst_uuid'
op|']'
op|'.'
name|'obj_clone'
op|'('
op|')'
newline|'\n'
name|'resizing_instance'
op|'.'
name|'migration_context'
op|'='
op|'('
nl|'\n'
name|'_MIGRATION_CONTEXT_FIXTURES'
op|'['
name|'resizing_instance'
op|'.'
name|'uuid'
op|']'
op|')'
newline|'\n'
name|'all_instances'
op|'='
name|'_INSTANCE_FIXTURES'
op|'+'
op|'['
name|'resizing_instance'
op|']'
newline|'\n'
name|'get_mock'
op|'.'
name|'return_value'
op|'='
name|'all_instances'
newline|'\n'
name|'get_inst_mock'
op|'.'
name|'return_value'
op|'='
name|'resizing_instance'
newline|'\n'
name|'get_cn_mock'
op|'.'
name|'return_value'
op|'='
name|'_COMPUTE_NODE_FIXTURES'
op|'['
number|'0'
op|']'
newline|'\n'
nl|'\n'
name|'update_mock'
op|'='
name|'self'
op|'.'
name|'_update_available_resources'
op|'('
op|')'
newline|'\n'
nl|'\n'
name|'get_cn_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'mock'
op|'.'
name|'sentinel'
op|'.'
name|'ctx'
op|','
string|"'fake-host'"
op|','
nl|'\n'
string|"'fake-node'"
op|')'
newline|'\n'
name|'expected_resources'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'_COMPUTE_NODE_FIXTURES'
op|'['
number|'0'
op|']'
op|')'
newline|'\n'
name|'vals'
op|'='
op|'{'
nl|'\n'
comment|'# host is added in update_available_resources()'
nl|'\n'
comment|'# before calling _update()'
nl|'\n'
string|"'host'"
op|':'
string|"'fake-host'"
op|','
nl|'\n'
string|"'host_ip'"
op|':'
string|"'1.1.1.1'"
op|','
nl|'\n'
string|"'numa_topology'"
op|':'
name|'None'
op|','
nl|'\n'
string|"'metrics'"
op|':'
string|"'[]'"
op|','
nl|'\n'
string|"'cpu_info'"
op|':'
string|"''"
op|','
nl|'\n'
string|"'hypervisor_hostname'"
op|':'
string|"'fakehost'"
op|','
nl|'\n'
comment|'# 6 total - 1G existing - 5G new flav - 1G old flav'
nl|'\n'
string|"'free_disk_gb'"
op|':'
op|'-'
number|'1'
op|','
nl|'\n'
string|"'hypervisor_version'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'local_gb'"
op|':'
number|'6'
op|','
nl|'\n'
comment|'# 512 total - 128 existing - 256 new flav - 128 old flav'
nl|'\n'
string|"'free_ram_mb'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'memory_mb_used'"
op|':'
number|'512'
op|','
comment|'# 128 exist + 256 new flav + 128 old flav'
nl|'\n'
string|"'pci_device_pools'"
op|':'
name|'objects'
op|'.'
name|'PciDevicePoolList'
op|'('
op|')'
op|','
nl|'\n'
string|"'vcpus_used'"
op|':'
number|'4'
op|','
nl|'\n'
string|"'hypervisor_type'"
op|':'
string|"'fake'"
op|','
nl|'\n'
string|"'local_gb_used'"
op|':'
number|'7'
op|','
comment|'# 1G existing, 5G new flav + 1 old flav'
nl|'\n'
string|"'memory_mb'"
op|':'
number|'512'
op|','
nl|'\n'
string|"'current_workload'"
op|':'
number|'1'
op|','
comment|'# One migrating instance...'
nl|'\n'
string|"'vcpus'"
op|':'
number|'4'
op|','
nl|'\n'
string|"'running_vms'"
op|':'
number|'2'
nl|'\n'
op|'}'
newline|'\n'
name|'_update_compute_node'
op|'('
name|'expected_resources'
op|','
op|'**'
name|'vals'
op|')'
newline|'\n'
name|'update_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'mock'
op|'.'
name|'sentinel'
op|'.'
name|'ctx'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertTrue'
op|'('
name|'obj_base'
op|'.'
name|'obj_equal_prims'
op|'('
name|'expected_resources'
op|','
nl|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|')'
op|')'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|class|TestInitComputeNode
dedent|''
dedent|''
name|'class'
name|'TestInitComputeNode'
op|'('
name|'BaseTestCase'
op|')'
op|':'
newline|'\n'
nl|'\n'
indent|'    '
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.ComputeNode.create'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.Service.get_by_compute_host'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.ComputeNode.get_by_host_and_nodename'"
op|')'
newline|'\n'
DECL|member|test_no_op_init_compute_node
name|'def'
name|'test_no_op_init_compute_node'
op|'('
name|'self'
op|','
name|'get_mock'
op|','
name|'service_mock'
op|','
nl|'\n'
name|'create_mock'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'self'
op|'.'
name|'_setup_rt'
op|'('
op|')'
newline|'\n'
nl|'\n'
name|'resources'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'_VIRT_DRIVER_AVAIL_RESOURCES'
op|')'
newline|'\n'
name|'compute_node'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'_COMPUTE_NODE_FIXTURES'
op|'['
number|'0'
op|']'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|'='
name|'compute_node'
newline|'\n'
nl|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'_init_compute_node'
op|'('
name|'mock'
op|'.'
name|'sentinel'
op|'.'
name|'ctx'
op|','
name|'resources'
op|')'
newline|'\n'
nl|'\n'
name|'self'
op|'.'
name|'assertFalse'
op|'('
name|'service_mock'
op|'.'
name|'called'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertFalse'
op|'('
name|'get_mock'
op|'.'
name|'called'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertFalse'
op|'('
name|'create_mock'
op|'.'
name|'called'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertFalse'
op|'('
name|'self'
op|'.'
name|'rt'
op|'.'
name|'disabled'
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.ComputeNode.create'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.ComputeNode.get_by_host_and_nodename'"
op|')'
newline|'\n'
DECL|member|test_compute_node_loaded
name|'def'
name|'test_compute_node_loaded'
op|'('
name|'self'
op|','
name|'get_mock'
op|','
name|'create_mock'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'self'
op|'.'
name|'_setup_rt'
op|'('
op|')'
newline|'\n'
nl|'\n'
DECL|function|fake_get_node
name|'def'
name|'fake_get_node'
op|'('
name|'_ctx'
op|','
name|'host'
op|','
name|'node'
op|')'
op|':'
newline|'\n'
indent|'            '
name|'res'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'_COMPUTE_NODE_FIXTURES'
op|'['
number|'0'
op|']'
op|')'
newline|'\n'
name|'return'
name|'res'
newline|'\n'
nl|'\n'
dedent|''
name|'get_mock'
op|'.'
name|'side_effect'
op|'='
name|'fake_get_node'
newline|'\n'
name|'resources'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'_VIRT_DRIVER_AVAIL_RESOURCES'
op|')'
newline|'\n'
nl|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'_init_compute_node'
op|'('
name|'mock'
op|'.'
name|'sentinel'
op|'.'
name|'ctx'
op|','
name|'resources'
op|')'
newline|'\n'
nl|'\n'
name|'get_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'mock'
op|'.'
name|'sentinel'
op|'.'
name|'ctx'
op|','
string|"'fake-host'"
op|','
nl|'\n'
string|"'fake-node'"
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertFalse'
op|'('
name|'create_mock'
op|'.'
name|'called'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertFalse'
op|'('
name|'self'
op|'.'
name|'rt'
op|'.'
name|'disabled'
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.ComputeNode.create'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.ComputeNode.get_by_host_and_nodename'"
op|')'
newline|'\n'
DECL|member|test_compute_node_created_on_empty
name|'def'
name|'test_compute_node_created_on_empty'
op|'('
name|'self'
op|','
name|'get_mock'
op|','
name|'create_mock'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'self'
op|'.'
name|'_setup_rt'
op|'('
op|')'
newline|'\n'
nl|'\n'
name|'get_mock'
op|'.'
name|'side_effect'
op|'='
name|'exc'
op|'.'
name|'NotFound'
newline|'\n'
name|'cpu_alloc_ratio'
op|'='
number|'1.0'
newline|'\n'
name|'ram_alloc_ratio'
op|'='
number|'1.0'
newline|'\n'
name|'disk_alloc_ratio'
op|'='
number|'1.0'
newline|'\n'
nl|'\n'
name|'resources'
op|'='
op|'{'
nl|'\n'
string|"'host_ip'"
op|':'
string|"'1.1.1.1'"
op|','
nl|'\n'
string|"'numa_topology'"
op|':'
name|'None'
op|','
nl|'\n'
string|"'metrics'"
op|':'
string|"'[]'"
op|','
nl|'\n'
string|"'cpu_info'"
op|':'
string|"''"
op|','
nl|'\n'
string|"'hypervisor_hostname'"
op|':'
string|"'fakehost'"
op|','
nl|'\n'
string|"'free_disk_gb'"
op|':'
number|'6'
op|','
nl|'\n'
string|"'hypervisor_version'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'local_gb'"
op|':'
number|'6'
op|','
nl|'\n'
string|"'free_ram_mb'"
op|':'
number|'512'
op|','
nl|'\n'
string|"'memory_mb_used'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'pci_device_pools'"
op|':'
op|'['
op|']'
op|','
nl|'\n'
string|"'vcpus_used'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'hypervisor_type'"
op|':'
string|"'fake'"
op|','
nl|'\n'
string|"'local_gb_used'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'memory_mb'"
op|':'
number|'512'
op|','
nl|'\n'
string|"'current_workload'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'vcpus'"
op|':'
number|'4'
op|','
nl|'\n'
string|"'running_vms'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'pci_passthrough_devices'"
op|':'
string|"'[]'"
nl|'\n'
op|'}'
newline|'\n'
comment|'# The expected compute represents the initial values used'
nl|'\n'
comment|'# when creating a compute node.'
nl|'\n'
name|'expected_compute'
op|'='
name|'objects'
op|'.'
name|'ComputeNode'
op|'('
nl|'\n'
name|'host_ip'
op|'='
name|'resources'
op|'['
string|"'host_ip'"
op|']'
op|','
nl|'\n'
name|'vcpus'
op|'='
name|'resources'
op|'['
string|"'vcpus'"
op|']'
op|','
nl|'\n'
name|'memory_mb'
op|'='
name|'resources'
op|'['
string|"'memory_mb'"
op|']'
op|','
nl|'\n'
name|'local_gb'
op|'='
name|'resources'
op|'['
string|"'local_gb'"
op|']'
op|','
nl|'\n'
name|'cpu_info'
op|'='
name|'resources'
op|'['
string|"'cpu_info'"
op|']'
op|','
nl|'\n'
name|'vcpus_used'
op|'='
name|'resources'
op|'['
string|"'vcpus_used'"
op|']'
op|','
nl|'\n'
name|'memory_mb_used'
op|'='
name|'resources'
op|'['
string|"'memory_mb_used'"
op|']'
op|','
nl|'\n'
name|'local_gb_used'
op|'='
name|'resources'
op|'['
string|"'local_gb_used'"
op|']'
op|','
nl|'\n'
name|'numa_topology'
op|'='
name|'resources'
op|'['
string|"'numa_topology'"
op|']'
op|','
nl|'\n'
name|'hypervisor_type'
op|'='
name|'resources'
op|'['
string|"'hypervisor_type'"
op|']'
op|','
nl|'\n'
name|'hypervisor_version'
op|'='
name|'resources'
op|'['
string|"'hypervisor_version'"
op|']'
op|','
nl|'\n'
name|'hypervisor_hostname'
op|'='
name|'resources'
op|'['
string|"'hypervisor_hostname'"
op|']'
op|','
nl|'\n'
comment|'# NOTE(sbauza): ResourceTracker adds host field'
nl|'\n'
name|'host'
op|'='
string|"'fake-host'"
op|','
nl|'\n'
comment|'# NOTE(sbauza): ResourceTracker adds CONF allocation ratios'
nl|'\n'
name|'ram_allocation_ratio'
op|'='
name|'ram_alloc_ratio'
op|','
nl|'\n'
name|'cpu_allocation_ratio'
op|'='
name|'cpu_alloc_ratio'
op|','
nl|'\n'
name|'disk_allocation_ratio'
op|'='
name|'disk_alloc_ratio'
op|','
nl|'\n'
name|'stats'
op|'='
op|'{'
op|'}'
op|','
nl|'\n'
op|')'
newline|'\n'
nl|'\n'
comment|'# Forcing the flags to the values we know'
nl|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'ram_allocation_ratio'
op|'='
name|'ram_alloc_ratio'
newline|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'cpu_allocation_ratio'
op|'='
name|'cpu_alloc_ratio'
newline|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'disk_allocation_ratio'
op|'='
name|'disk_alloc_ratio'
newline|'\n'
nl|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'_init_compute_node'
op|'('
name|'mock'
op|'.'
name|'sentinel'
op|'.'
name|'ctx'
op|','
name|'resources'
op|')'
newline|'\n'
nl|'\n'
name|'self'
op|'.'
name|'assertFalse'
op|'('
name|'self'
op|'.'
name|'rt'
op|'.'
name|'disabled'
op|')'
newline|'\n'
name|'get_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'mock'
op|'.'
name|'sentinel'
op|'.'
name|'ctx'
op|','
string|"'fake-host'"
op|','
nl|'\n'
string|"'fake-node'"
op|')'
newline|'\n'
name|'create_mock'
op|'.'
name|'assert_called_once_with'
op|'('
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertTrue'
op|'('
name|'obj_base'
op|'.'
name|'obj_equal_prims'
op|'('
name|'expected_compute'
op|','
nl|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|')'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_copy_resources_adds_allocation_ratios
dedent|''
name|'def'
name|'test_copy_resources_adds_allocation_ratios'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'self'
op|'.'
name|'flags'
op|'('
name|'cpu_allocation_ratio'
op|'='
number|'4.0'
op|','
name|'ram_allocation_ratio'
op|'='
number|'3.0'
op|','
nl|'\n'
name|'disk_allocation_ratio'
op|'='
number|'2.0'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'_setup_rt'
op|'('
op|')'
newline|'\n'
nl|'\n'
name|'resources'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'_VIRT_DRIVER_AVAIL_RESOURCES'
op|')'
newline|'\n'
name|'compute_node'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'_COMPUTE_NODE_FIXTURES'
op|'['
number|'0'
op|']'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|'='
name|'compute_node'
newline|'\n'
nl|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'_copy_resources'
op|'('
name|'resources'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
number|'4.0'
op|','
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|'.'
name|'cpu_allocation_ratio'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
number|'3.0'
op|','
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|'.'
name|'ram_allocation_ratio'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
number|'2.0'
op|','
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|'.'
name|'disk_allocation_ratio'
op|')'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|class|TestUpdateComputeNode
dedent|''
dedent|''
name|'class'
name|'TestUpdateComputeNode'
op|'('
name|'BaseTestCase'
op|')'
op|':'
newline|'\n'
nl|'\n'
indent|'    '
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.Service.get_by_compute_host'"
op|')'
newline|'\n'
DECL|member|test_existing_compute_node_updated_same_resources
name|'def'
name|'test_existing_compute_node_updated_same_resources'
op|'('
name|'self'
op|','
name|'service_mock'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'self'
op|'.'
name|'_setup_rt'
op|'('
op|')'
newline|'\n'
nl|'\n'
comment|'# This is the same set of resources as the fixture, deliberately. We'
nl|'\n'
comment|'# are checking below to see that update_resource_stats() is not'
nl|'\n'
comment|"# needlessly called when the resources don't actually change."
nl|'\n'
name|'compute'
op|'='
name|'objects'
op|'.'
name|'ComputeNode'
op|'('
nl|'\n'
name|'host_ip'
op|'='
string|"'1.1.1.1'"
op|','
nl|'\n'
name|'numa_topology'
op|'='
name|'None'
op|','
nl|'\n'
name|'metrics'
op|'='
string|"'[]'"
op|','
nl|'\n'
name|'cpu_info'
op|'='
string|"''"
op|','
nl|'\n'
name|'hypervisor_hostname'
op|'='
string|"'fakehost'"
op|','
nl|'\n'
name|'free_disk_gb'
op|'='
number|'6'
op|','
nl|'\n'
name|'hypervisor_version'
op|'='
number|'0'
op|','
nl|'\n'
name|'local_gb'
op|'='
number|'6'
op|','
nl|'\n'
name|'free_ram_mb'
op|'='
number|'512'
op|','
nl|'\n'
name|'memory_mb_used'
op|'='
number|'0'
op|','
nl|'\n'
name|'pci_device_pools'
op|'='
name|'objects'
op|'.'
name|'PciDevicePoolList'
op|'('
op|')'
op|','
nl|'\n'
name|'vcpus_used'
op|'='
number|'0'
op|','
nl|'\n'
name|'hypervisor_type'
op|'='
string|"'fake'"
op|','
nl|'\n'
name|'local_gb_used'
op|'='
number|'0'
op|','
nl|'\n'
name|'memory_mb'
op|'='
number|'512'
op|','
nl|'\n'
name|'current_workload'
op|'='
number|'0'
op|','
nl|'\n'
name|'vcpus'
op|'='
number|'4'
op|','
nl|'\n'
name|'running_vms'
op|'='
number|'0'
op|','
nl|'\n'
name|'cpu_allocation_ratio'
op|'='
number|'16.0'
op|','
nl|'\n'
name|'ram_allocation_ratio'
op|'='
number|'1.5'
op|','
nl|'\n'
name|'disk_allocation_ratio'
op|'='
number|'1.0'
op|','
nl|'\n'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|'='
name|'compute'
newline|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'_update'
op|'('
name|'mock'
op|'.'
name|'sentinel'
op|'.'
name|'ctx'
op|')'
newline|'\n'
nl|'\n'
name|'self'
op|'.'
name|'assertFalse'
op|'('
name|'self'
op|'.'
name|'rt'
op|'.'
name|'disabled'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertFalse'
op|'('
name|'service_mock'
op|'.'
name|'called'
op|')'
newline|'\n'
nl|'\n'
comment|'# The above call to _update() will populate the'
nl|'\n'
comment|'# RT.old_resources collection with the resources. Here, we check that'
nl|'\n'
comment|'# if we call _update() again with the same resources, that'
nl|'\n'
comment|"# the scheduler client won't be called again to update those"
nl|'\n'
comment|'# (unchanged) resources for the compute node'
nl|'\n'
name|'self'
op|'.'
name|'sched_client_mock'
op|'.'
name|'reset_mock'
op|'('
op|')'
newline|'\n'
name|'urs_mock'
op|'='
name|'self'
op|'.'
name|'sched_client_mock'
op|'.'
name|'update_resource_stats'
newline|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'_update'
op|'('
name|'mock'
op|'.'
name|'sentinel'
op|'.'
name|'ctx'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertFalse'
op|'('
name|'urs_mock'
op|'.'
name|'called'
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.Service.get_by_compute_host'"
op|')'
newline|'\n'
DECL|member|test_existing_compute_node_updated_new_resources
name|'def'
name|'test_existing_compute_node_updated_new_resources'
op|'('
name|'self'
op|','
name|'service_mock'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'self'
op|'.'
name|'_setup_rt'
op|'('
op|')'
newline|'\n'
nl|'\n'
comment|'# Deliberately changing local_gb_used, vcpus_used, and memory_mb_used'
nl|'\n'
comment|"# below to be different from the compute node fixture's base usages."
nl|'\n'
comment|'# We want to check that the code paths update the stored compute node'
nl|'\n'
comment|'# usage records with what is supplied to _update().'
nl|'\n'
name|'compute'
op|'='
name|'objects'
op|'.'
name|'ComputeNode'
op|'('
nl|'\n'
name|'host'
op|'='
string|"'fake-host'"
op|','
nl|'\n'
name|'host_ip'
op|'='
string|"'1.1.1.1'"
op|','
nl|'\n'
name|'numa_topology'
op|'='
name|'None'
op|','
nl|'\n'
name|'metrics'
op|'='
string|"'[]'"
op|','
nl|'\n'
name|'cpu_info'
op|'='
string|"''"
op|','
nl|'\n'
name|'hypervisor_hostname'
op|'='
string|"'fakehost'"
op|','
nl|'\n'
name|'free_disk_gb'
op|'='
number|'2'
op|','
nl|'\n'
name|'hypervisor_version'
op|'='
number|'0'
op|','
nl|'\n'
name|'local_gb'
op|'='
number|'6'
op|','
nl|'\n'
name|'free_ram_mb'
op|'='
number|'384'
op|','
nl|'\n'
name|'memory_mb_used'
op|'='
number|'128'
op|','
nl|'\n'
name|'pci_device_pools'
op|'='
name|'objects'
op|'.'
name|'PciDevicePoolList'
op|'('
op|')'
op|','
nl|'\n'
name|'vcpus_used'
op|'='
number|'2'
op|','
nl|'\n'
name|'hypervisor_type'
op|'='
string|"'fake'"
op|','
nl|'\n'
name|'local_gb_used'
op|'='
number|'4'
op|','
nl|'\n'
name|'memory_mb'
op|'='
number|'512'
op|','
nl|'\n'
name|'current_workload'
op|'='
number|'0'
op|','
nl|'\n'
name|'vcpus'
op|'='
number|'4'
op|','
nl|'\n'
name|'running_vms'
op|'='
number|'0'
op|','
nl|'\n'
name|'cpu_allocation_ratio'
op|'='
number|'16.0'
op|','
nl|'\n'
name|'ram_allocation_ratio'
op|'='
number|'1.5'
op|','
nl|'\n'
name|'disk_allocation_ratio'
op|'='
number|'1.0'
op|','
nl|'\n'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|'='
name|'compute'
newline|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'_update'
op|'('
name|'mock'
op|'.'
name|'sentinel'
op|'.'
name|'ctx'
op|')'
newline|'\n'
nl|'\n'
name|'self'
op|'.'
name|'assertFalse'
op|'('
name|'self'
op|'.'
name|'rt'
op|'.'
name|'disabled'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertFalse'
op|'('
name|'service_mock'
op|'.'
name|'called'
op|')'
newline|'\n'
name|'urs_mock'
op|'='
name|'self'
op|'.'
name|'sched_client_mock'
op|'.'
name|'update_resource_stats'
newline|'\n'
name|'urs_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|')'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|class|TestInstanceClaim
dedent|''
dedent|''
name|'class'
name|'TestInstanceClaim'
op|'('
name|'BaseTestCase'
op|')'
op|':'
newline|'\n'
nl|'\n'
DECL|member|setUp
indent|'    '
name|'def'
name|'setUp'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'super'
op|'('
name|'TestInstanceClaim'
op|','
name|'self'
op|')'
op|'.'
name|'setUp'
op|'('
op|')'
newline|'\n'
name|'self'
op|'.'
name|'flags'
op|'('
name|'reserved_host_disk_mb'
op|'='
number|'0'
op|','
name|'reserved_host_memory_mb'
op|'='
number|'0'
op|')'
newline|'\n'
nl|'\n'
name|'self'
op|'.'
name|'_setup_rt'
op|'('
op|')'
newline|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'_COMPUTE_NODE_FIXTURES'
op|'['
number|'0'
op|']'
op|')'
newline|'\n'
nl|'\n'
comment|'# not using mock.sentinel.ctx because instance_claim calls #elevated'
nl|'\n'
name|'self'
op|'.'
name|'ctx'
op|'='
name|'mock'
op|'.'
name|'MagicMock'
op|'('
op|')'
newline|'\n'
name|'self'
op|'.'
name|'elevated'
op|'='
name|'mock'
op|'.'
name|'MagicMock'
op|'('
op|')'
newline|'\n'
name|'self'
op|'.'
name|'ctx'
op|'.'
name|'elevated'
op|'.'
name|'return_value'
op|'='
name|'self'
op|'.'
name|'elevated'
newline|'\n'
nl|'\n'
name|'self'
op|'.'
name|'instance'
op|'='
name|'_INSTANCE_FIXTURES'
op|'['
number|'0'
op|']'
op|'.'
name|'obj_clone'
op|'('
op|')'
newline|'\n'
nl|'\n'
DECL|member|assertEqualNUMAHostTopology
dedent|''
name|'def'
name|'assertEqualNUMAHostTopology'
op|'('
name|'self'
op|','
name|'expected'
op|','
name|'got'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'attrs'
op|'='
op|'('
string|"'cpuset'"
op|','
string|"'memory'"
op|','
string|"'id'"
op|','
string|"'cpu_usage'"
op|','
string|"'memory_usage'"
op|')'
newline|'\n'
name|'if'
name|'None'
name|'in'
op|'('
name|'expected'
op|','
name|'got'
op|')'
op|':'
newline|'\n'
indent|'            '
name|'if'
name|'expected'
op|'!='
name|'got'
op|':'
newline|'\n'
indent|'                '
name|'raise'
name|'AssertionError'
op|'('
string|'"Topologies don\'t match. Expected: "'
nl|'\n'
string|'"%(expected)s, but got: %(got)s"'
op|'%'
nl|'\n'
op|'{'
string|"'expected'"
op|':'
name|'expected'
op|','
string|"'got'"
op|':'
name|'got'
op|'}'
op|')'
newline|'\n'
dedent|''
name|'else'
op|':'
newline|'\n'
indent|'                '
name|'return'
newline|'\n'
nl|'\n'
dedent|''
dedent|''
name|'if'
name|'len'
op|'('
name|'expected'
op|')'
op|'!='
name|'len'
op|'('
name|'got'
op|')'
op|':'
newline|'\n'
indent|'            '
name|'raise'
name|'AssertionError'
op|'('
string|'"Topologies don\'t match due to different "'
nl|'\n'
string|'"number of cells. Expected: "'
nl|'\n'
string|'"%(expected)s, but got: %(got)s"'
op|'%'
nl|'\n'
op|'{'
string|"'expected'"
op|':'
name|'expected'
op|','
string|"'got'"
op|':'
name|'got'
op|'}'
op|')'
newline|'\n'
dedent|''
name|'for'
name|'exp_cell'
op|','
name|'got_cell'
name|'in'
name|'zip'
op|'('
name|'expected'
op|'.'
name|'cells'
op|','
name|'got'
op|'.'
name|'cells'
op|')'
op|':'
newline|'\n'
indent|'            '
name|'for'
name|'attr'
name|'in'
name|'attrs'
op|':'
newline|'\n'
indent|'                '
name|'if'
name|'getattr'
op|'('
name|'exp_cell'
op|','
name|'attr'
op|')'
op|'!='
name|'getattr'
op|'('
name|'got_cell'
op|','
name|'attr'
op|')'
op|':'
newline|'\n'
indent|'                    '
name|'raise'
name|'AssertionError'
op|'('
string|'"Topologies don\'t match. Expected: "'
nl|'\n'
string|'"%(expected)s, but got: %(got)s"'
op|'%'
nl|'\n'
op|'{'
string|"'expected'"
op|':'
name|'expected'
op|','
string|"'got'"
op|':'
name|'got'
op|'}'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_claim_disabled
dedent|''
dedent|''
dedent|''
dedent|''
name|'def'
name|'test_claim_disabled'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|'='
name|'None'
newline|'\n'
name|'self'
op|'.'
name|'assertTrue'
op|'('
name|'self'
op|'.'
name|'rt'
op|'.'
name|'disabled'
op|')'
newline|'\n'
nl|'\n'
name|'with'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'self'
op|'.'
name|'instance'
op|','
string|"'save'"
op|')'
op|':'
newline|'\n'
indent|'            '
name|'claim'
op|'='
name|'self'
op|'.'
name|'rt'
op|'.'
name|'instance_claim'
op|'('
name|'mock'
op|'.'
name|'sentinel'
op|'.'
name|'ctx'
op|','
name|'self'
op|'.'
name|'instance'
op|','
nl|'\n'
name|'None'
op|')'
newline|'\n'
nl|'\n'
dedent|''
name|'self'
op|'.'
name|'assertEqual'
op|'('
name|'self'
op|'.'
name|'rt'
op|'.'
name|'host'
op|','
name|'self'
op|'.'
name|'instance'
op|'.'
name|'host'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
name|'self'
op|'.'
name|'rt'
op|'.'
name|'host'
op|','
name|'self'
op|'.'
name|'instance'
op|'.'
name|'launched_on'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
name|'self'
op|'.'
name|'rt'
op|'.'
name|'nodename'
op|','
name|'self'
op|'.'
name|'instance'
op|'.'
name|'node'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertIsInstance'
op|'('
name|'claim'
op|','
name|'claims'
op|'.'
name|'NopClaim'
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.InstancePCIRequests.get_by_instance_uuid'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.MigrationList.get_in_progress_by_host_and_node'"
op|')'
newline|'\n'
DECL|member|test_update_usage_with_claim
name|'def'
name|'test_update_usage_with_claim'
op|'('
name|'self'
op|','
name|'migr_mock'
op|','
name|'pci_mock'
op|')'
op|':'
newline|'\n'
comment|'# Test that RT.update_usage() only changes the compute node'
nl|'\n'
comment|'# resources if there has been a claim first.'
nl|'\n'
indent|'        '
name|'pci_mock'
op|'.'
name|'return_value'
op|'='
name|'objects'
op|'.'
name|'InstancePCIRequests'
op|'('
name|'requests'
op|'='
op|'['
op|']'
op|')'
newline|'\n'
nl|'\n'
name|'expected'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'_COMPUTE_NODE_FIXTURES'
op|'['
number|'0'
op|']'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'update_usage'
op|'('
name|'self'
op|'.'
name|'ctx'
op|','
name|'self'
op|'.'
name|'instance'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertTrue'
op|'('
name|'obj_base'
op|'.'
name|'obj_equal_prims'
op|'('
name|'expected'
op|','
nl|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|')'
op|')'
newline|'\n'
nl|'\n'
name|'disk_used'
op|'='
name|'self'
op|'.'
name|'instance'
op|'.'
name|'root_gb'
op|'+'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'ephemeral_gb'
newline|'\n'
name|'vals'
op|'='
op|'{'
nl|'\n'
string|"'local_gb_used'"
op|':'
name|'disk_used'
op|','
nl|'\n'
string|"'memory_mb_used'"
op|':'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'memory_mb'
op|','
nl|'\n'
string|"'free_disk_gb'"
op|':'
name|'expected'
op|'.'
name|'local_gb'
op|'-'
name|'disk_used'
op|','
nl|'\n'
string|'"free_ram_mb"'
op|':'
name|'expected'
op|'.'
name|'memory_mb'
op|'-'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'memory_mb'
op|','
nl|'\n'
string|"'running_vms'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'vcpus_used'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'pci_device_pools'"
op|':'
name|'objects'
op|'.'
name|'PciDevicePoolList'
op|'('
op|')'
op|','
nl|'\n'
string|"'stats'"
op|':'
op|'{'
nl|'\n'
string|"'io_workload'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'num_instances'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'num_task_None'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'num_os_type_'"
op|'+'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'os_type'
op|':'
number|'1'
op|','
nl|'\n'
string|"'num_proj_'"
op|'+'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'project_id'
op|':'
number|'1'
op|','
nl|'\n'
string|"'num_vm_'"
op|'+'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'vm_state'
op|':'
number|'1'
op|','
nl|'\n'
op|'}'
op|','
nl|'\n'
op|'}'
newline|'\n'
name|'_update_compute_node'
op|'('
name|'expected'
op|','
op|'**'
name|'vals'
op|')'
newline|'\n'
name|'with'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'self'
op|'.'
name|'rt'
op|','
string|"'_update'"
op|')'
name|'as'
name|'update_mock'
op|':'
newline|'\n'
indent|'            '
name|'with'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'self'
op|'.'
name|'instance'
op|','
string|"'save'"
op|')'
op|':'
newline|'\n'
indent|'                '
name|'self'
op|'.'
name|'rt'
op|'.'
name|'instance_claim'
op|'('
name|'self'
op|'.'
name|'ctx'
op|','
name|'self'
op|'.'
name|'instance'
op|','
name|'None'
op|')'
newline|'\n'
dedent|''
name|'update_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'self'
op|'.'
name|'elevated'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertTrue'
op|'('
name|'obj_base'
op|'.'
name|'obj_equal_prims'
op|'('
name|'expected'
op|','
nl|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|')'
op|')'
newline|'\n'
nl|'\n'
dedent|''
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.InstancePCIRequests.get_by_instance_uuid'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.MigrationList.get_in_progress_by_host_and_node'"
op|')'
newline|'\n'
DECL|member|test_update_usage_removed
name|'def'
name|'test_update_usage_removed'
op|'('
name|'self'
op|','
name|'migr_mock'
op|','
name|'pci_mock'
op|')'
op|':'
newline|'\n'
comment|'# Test that RT.update_usage() removes the instance when update is'
nl|'\n'
comment|'# called in a removed state'
nl|'\n'
indent|'        '
name|'pci_mock'
op|'.'
name|'return_value'
op|'='
name|'objects'
op|'.'
name|'InstancePCIRequests'
op|'('
name|'requests'
op|'='
op|'['
op|']'
op|')'
newline|'\n'
nl|'\n'
name|'expected'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'_COMPUTE_NODE_FIXTURES'
op|'['
number|'0'
op|']'
op|')'
newline|'\n'
name|'disk_used'
op|'='
name|'self'
op|'.'
name|'instance'
op|'.'
name|'root_gb'
op|'+'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'ephemeral_gb'
newline|'\n'
name|'vals'
op|'='
op|'{'
nl|'\n'
string|"'local_gb_used'"
op|':'
name|'disk_used'
op|','
nl|'\n'
string|"'memory_mb_used'"
op|':'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'memory_mb'
op|','
nl|'\n'
string|"'free_disk_gb'"
op|':'
name|'expected'
op|'.'
name|'local_gb'
op|'-'
name|'disk_used'
op|','
nl|'\n'
string|'"free_ram_mb"'
op|':'
name|'expected'
op|'.'
name|'memory_mb'
op|'-'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'memory_mb'
op|','
nl|'\n'
string|"'running_vms'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'vcpus_used'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'pci_device_pools'"
op|':'
name|'objects'
op|'.'
name|'PciDevicePoolList'
op|'('
op|')'
op|','
nl|'\n'
string|"'stats'"
op|':'
op|'{'
nl|'\n'
string|"'io_workload'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'num_instances'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'num_task_None'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'num_os_type_'"
op|'+'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'os_type'
op|':'
number|'1'
op|','
nl|'\n'
string|"'num_proj_'"
op|'+'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'project_id'
op|':'
number|'1'
op|','
nl|'\n'
string|"'num_vm_'"
op|'+'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'vm_state'
op|':'
number|'1'
op|','
nl|'\n'
op|'}'
op|','
nl|'\n'
op|'}'
newline|'\n'
name|'_update_compute_node'
op|'('
name|'expected'
op|','
op|'**'
name|'vals'
op|')'
newline|'\n'
name|'with'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'self'
op|'.'
name|'rt'
op|','
string|"'_update'"
op|')'
name|'as'
name|'update_mock'
op|':'
newline|'\n'
indent|'            '
name|'with'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'self'
op|'.'
name|'instance'
op|','
string|"'save'"
op|')'
op|':'
newline|'\n'
indent|'                '
name|'self'
op|'.'
name|'rt'
op|'.'
name|'instance_claim'
op|'('
name|'self'
op|'.'
name|'ctx'
op|','
name|'self'
op|'.'
name|'instance'
op|','
name|'None'
op|')'
newline|'\n'
dedent|''
name|'update_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'self'
op|'.'
name|'elevated'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertTrue'
op|'('
name|'obj_base'
op|'.'
name|'obj_equal_prims'
op|'('
name|'expected'
op|','
nl|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|')'
op|')'
newline|'\n'
nl|'\n'
dedent|''
name|'expected_updated'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'_COMPUTE_NODE_FIXTURES'
op|'['
number|'0'
op|']'
op|')'
newline|'\n'
name|'vals'
op|'='
op|'{'
nl|'\n'
string|"'pci_device_pools'"
op|':'
name|'objects'
op|'.'
name|'PciDevicePoolList'
op|'('
op|')'
op|','
nl|'\n'
string|"'stats'"
op|':'
op|'{'
nl|'\n'
string|"'io_workload'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'num_instances'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'num_task_None'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'num_os_type_'"
op|'+'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'os_type'
op|':'
number|'0'
op|','
nl|'\n'
string|"'num_proj_'"
op|'+'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'project_id'
op|':'
number|'0'
op|','
nl|'\n'
string|"'num_vm_'"
op|'+'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'vm_state'
op|':'
number|'0'
op|','
nl|'\n'
op|'}'
op|','
nl|'\n'
op|'}'
newline|'\n'
name|'_update_compute_node'
op|'('
name|'expected_updated'
op|','
op|'**'
name|'vals'
op|')'
newline|'\n'
nl|'\n'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'vm_state'
op|'='
name|'vm_states'
op|'.'
name|'SHELVED_OFFLOADED'
newline|'\n'
name|'with'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'self'
op|'.'
name|'rt'
op|','
string|"'_update'"
op|')'
name|'as'
name|'update_mock'
op|':'
newline|'\n'
indent|'            '
name|'self'
op|'.'
name|'rt'
op|'.'
name|'update_usage'
op|'('
name|'self'
op|'.'
name|'ctx'
op|','
name|'self'
op|'.'
name|'instance'
op|')'
newline|'\n'
dedent|''
name|'self'
op|'.'
name|'assertTrue'
op|'('
name|'obj_base'
op|'.'
name|'obj_equal_prims'
op|'('
name|'expected_updated'
op|','
nl|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|')'
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.InstancePCIRequests.get_by_instance_uuid'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.MigrationList.get_in_progress_by_host_and_node'"
op|')'
newline|'\n'
DECL|member|test_claim
name|'def'
name|'test_claim'
op|'('
name|'self'
op|','
name|'migr_mock'
op|','
name|'pci_mock'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'self'
op|'.'
name|'assertFalse'
op|'('
name|'self'
op|'.'
name|'rt'
op|'.'
name|'disabled'
op|')'
newline|'\n'
nl|'\n'
name|'pci_mock'
op|'.'
name|'return_value'
op|'='
name|'objects'
op|'.'
name|'InstancePCIRequests'
op|'('
name|'requests'
op|'='
op|'['
op|']'
op|')'
newline|'\n'
nl|'\n'
name|'disk_used'
op|'='
name|'self'
op|'.'
name|'instance'
op|'.'
name|'root_gb'
op|'+'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'ephemeral_gb'
newline|'\n'
name|'expected'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'_COMPUTE_NODE_FIXTURES'
op|'['
number|'0'
op|']'
op|')'
newline|'\n'
name|'vals'
op|'='
op|'{'
nl|'\n'
string|"'local_gb_used'"
op|':'
name|'disk_used'
op|','
nl|'\n'
string|"'memory_mb_used'"
op|':'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'memory_mb'
op|','
nl|'\n'
string|"'free_disk_gb'"
op|':'
name|'expected'
op|'.'
name|'local_gb'
op|'-'
name|'disk_used'
op|','
nl|'\n'
string|'"free_ram_mb"'
op|':'
name|'expected'
op|'.'
name|'memory_mb'
op|'-'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'memory_mb'
op|','
nl|'\n'
string|"'running_vms'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'vcpus_used'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'pci_device_pools'"
op|':'
name|'objects'
op|'.'
name|'PciDevicePoolList'
op|'('
op|')'
op|','
nl|'\n'
string|"'stats'"
op|':'
op|'{'
nl|'\n'
string|"'io_workload'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'num_instances'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'num_task_None'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'num_os_type_'"
op|'+'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'os_type'
op|':'
number|'1'
op|','
nl|'\n'
string|"'num_proj_'"
op|'+'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'project_id'
op|':'
number|'1'
op|','
nl|'\n'
string|"'num_vm_'"
op|'+'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'vm_state'
op|':'
number|'1'
op|','
nl|'\n'
op|'}'
op|','
nl|'\n'
op|'}'
newline|'\n'
name|'_update_compute_node'
op|'('
name|'expected'
op|','
op|'**'
name|'vals'
op|')'
newline|'\n'
name|'with'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'self'
op|'.'
name|'rt'
op|','
string|"'_update'"
op|')'
name|'as'
name|'update_mock'
op|':'
newline|'\n'
indent|'            '
name|'with'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'self'
op|'.'
name|'instance'
op|','
string|"'save'"
op|')'
op|':'
newline|'\n'
indent|'                '
name|'self'
op|'.'
name|'rt'
op|'.'
name|'instance_claim'
op|'('
name|'self'
op|'.'
name|'ctx'
op|','
name|'self'
op|'.'
name|'instance'
op|','
name|'None'
op|')'
newline|'\n'
dedent|''
name|'update_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'self'
op|'.'
name|'elevated'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertTrue'
op|'('
name|'obj_base'
op|'.'
name|'obj_equal_prims'
op|'('
name|'expected'
op|','
nl|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|')'
op|')'
newline|'\n'
nl|'\n'
dedent|''
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.pci.stats.PciDeviceStats.support_requests'"
op|','
nl|'\n'
name|'return_value'
op|'='
name|'True'
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.pci.manager.PciDevTracker.claim_instance'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.InstancePCIRequests.get_by_instance_uuid'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.MigrationList.get_in_progress_by_host_and_node'"
op|')'
newline|'\n'
DECL|member|test_claim_with_pci
name|'def'
name|'test_claim_with_pci'
op|'('
name|'self'
op|','
name|'migr_mock'
op|','
name|'pci_mock'
op|','
nl|'\n'
name|'pci_manager_mock'
op|','
name|'pci_stats_mock'
op|')'
op|':'
newline|'\n'
comment|'# Test that a claim involving PCI requests correctly claims'
nl|'\n'
comment|'# PCI devices on the host and sends an updated pci_device_pools'
nl|'\n'
comment|'# attribute of the ComputeNode object.'
nl|'\n'
indent|'        '
name|'self'
op|'.'
name|'assertFalse'
op|'('
name|'self'
op|'.'
name|'rt'
op|'.'
name|'disabled'
op|')'
newline|'\n'
nl|'\n'
comment|'# TODO(jaypipes): Remove once the PCI tracker is always created'
nl|'\n'
comment|'# upon the resource tracker being initialized...'
nl|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'pci_tracker'
op|'='
name|'pci_manager'
op|'.'
name|'PciDevTracker'
op|'('
name|'mock'
op|'.'
name|'sentinel'
op|'.'
name|'ctx'
op|')'
newline|'\n'
nl|'\n'
name|'pci_pools'
op|'='
name|'objects'
op|'.'
name|'PciDevicePoolList'
op|'('
op|')'
newline|'\n'
name|'pci_manager_mock'
op|'.'
name|'return_value'
op|'='
name|'pci_pools'
newline|'\n'
nl|'\n'
name|'request'
op|'='
name|'objects'
op|'.'
name|'InstancePCIRequest'
op|'('
name|'count'
op|'='
number|'1'
op|','
nl|'\n'
name|'spec'
op|'='
op|'['
op|'{'
string|"'vendor_id'"
op|':'
string|"'v'"
op|','
string|"'product_id'"
op|':'
string|"'p'"
op|'}'
op|']'
op|')'
newline|'\n'
name|'pci_mock'
op|'.'
name|'return_value'
op|'='
name|'objects'
op|'.'
name|'InstancePCIRequests'
op|'('
name|'requests'
op|'='
op|'['
name|'request'
op|']'
op|')'
newline|'\n'
nl|'\n'
name|'disk_used'
op|'='
name|'self'
op|'.'
name|'instance'
op|'.'
name|'root_gb'
op|'+'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'ephemeral_gb'
newline|'\n'
name|'expected'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'_COMPUTE_NODE_FIXTURES'
op|'['
number|'0'
op|']'
op|')'
newline|'\n'
name|'vals'
op|'='
op|'{'
nl|'\n'
string|"'local_gb_used'"
op|':'
name|'disk_used'
op|','
nl|'\n'
string|"'memory_mb_used'"
op|':'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'memory_mb'
op|','
nl|'\n'
string|"'free_disk_gb'"
op|':'
name|'expected'
op|'.'
name|'local_gb'
op|'-'
name|'disk_used'
op|','
nl|'\n'
string|'"free_ram_mb"'
op|':'
name|'expected'
op|'.'
name|'memory_mb'
op|'-'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'memory_mb'
op|','
nl|'\n'
string|"'running_vms'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'vcpus_used'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'pci_device_pools'"
op|':'
name|'pci_pools'
op|','
nl|'\n'
string|"'stats'"
op|':'
op|'{'
nl|'\n'
string|"'io_workload'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'num_instances'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'num_task_None'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'num_os_type_'"
op|'+'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'os_type'
op|':'
number|'1'
op|','
nl|'\n'
string|"'num_proj_'"
op|'+'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'project_id'
op|':'
number|'1'
op|','
nl|'\n'
string|"'num_vm_'"
op|'+'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'vm_state'
op|':'
number|'1'
op|','
nl|'\n'
op|'}'
op|','
nl|'\n'
op|'}'
newline|'\n'
name|'_update_compute_node'
op|'('
name|'expected'
op|','
op|'**'
name|'vals'
op|')'
newline|'\n'
name|'with'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'self'
op|'.'
name|'rt'
op|','
string|"'_update'"
op|')'
name|'as'
name|'update_mock'
op|':'
newline|'\n'
indent|'            '
name|'with'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'self'
op|'.'
name|'instance'
op|','
string|"'save'"
op|')'
op|':'
newline|'\n'
indent|'                '
name|'self'
op|'.'
name|'rt'
op|'.'
name|'instance_claim'
op|'('
name|'self'
op|'.'
name|'ctx'
op|','
name|'self'
op|'.'
name|'instance'
op|','
name|'None'
op|')'
newline|'\n'
dedent|''
name|'update_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'self'
op|'.'
name|'elevated'
op|')'
newline|'\n'
name|'pci_manager_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'mock'
op|'.'
name|'ANY'
op|','
comment|'# context...'
nl|'\n'
name|'pci_mock'
op|'.'
name|'return_value'
op|','
nl|'\n'
name|'None'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertTrue'
op|'('
name|'obj_base'
op|'.'
name|'obj_equal_prims'
op|'('
name|'expected'
op|','
nl|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|')'
op|')'
newline|'\n'
nl|'\n'
dedent|''
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.InstancePCIRequests.get_by_instance_uuid'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.MigrationList.get_in_progress_by_host_and_node'"
op|')'
newline|'\n'
DECL|member|test_claim_abort_context_manager
name|'def'
name|'test_claim_abort_context_manager'
op|'('
name|'self'
op|','
name|'migr_mock'
op|','
name|'pci_mock'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'pci_mock'
op|'.'
name|'return_value'
op|'='
name|'objects'
op|'.'
name|'InstancePCIRequests'
op|'('
name|'requests'
op|'='
op|'['
op|']'
op|')'
newline|'\n'
nl|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
number|'0'
op|','
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|'.'
name|'local_gb_used'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
number|'0'
op|','
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|'.'
name|'memory_mb_used'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
number|'0'
op|','
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|'.'
name|'running_vms'
op|')'
newline|'\n'
nl|'\n'
name|'mock_save'
op|'='
name|'mock'
op|'.'
name|'MagicMock'
op|'('
op|')'
newline|'\n'
name|'mock_clear_numa'
op|'='
name|'mock'
op|'.'
name|'MagicMock'
op|'('
op|')'
newline|'\n'
nl|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'self'
op|'.'
name|'instance'
op|','
string|"'save'"
op|','
name|'mock_save'
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'self'
op|'.'
name|'instance'
op|','
string|"'clear_numa_topology'"
op|','
nl|'\n'
name|'mock_clear_numa'
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'objects'
op|'.'
name|'Instance'
op|','
string|"'obj_clone'"
op|','
nl|'\n'
name|'return_value'
op|'='
name|'self'
op|'.'
name|'instance'
op|')'
newline|'\n'
DECL|function|_doit
name|'def'
name|'_doit'
op|'('
name|'mock_clone'
op|')'
op|':'
newline|'\n'
indent|'            '
name|'with'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'instance_claim'
op|'('
name|'self'
op|'.'
name|'ctx'
op|','
name|'self'
op|'.'
name|'instance'
op|','
name|'None'
op|')'
op|':'
newline|'\n'
comment|'# Raise an exception. Just make sure below that the abort()'
nl|'\n'
comment|'# method of the claim object was called (and the resulting'
nl|'\n'
comment|'# resources reset to the pre-claimed amounts)'
nl|'\n'
indent|'                '
name|'raise'
name|'test'
op|'.'
name|'TestingException'
op|'('
op|')'
newline|'\n'
nl|'\n'
dedent|''
dedent|''
name|'self'
op|'.'
name|'assertRaises'
op|'('
name|'test'
op|'.'
name|'TestingException'
op|','
name|'_doit'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
number|'2'
op|','
name|'mock_save'
op|'.'
name|'call_count'
op|')'
newline|'\n'
name|'mock_clear_numa'
op|'.'
name|'assert_called_once_with'
op|'('
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertIsNone'
op|'('
name|'self'
op|'.'
name|'instance'
op|'.'
name|'host'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertIsNone'
op|'('
name|'self'
op|'.'
name|'instance'
op|'.'
name|'node'
op|')'
newline|'\n'
nl|'\n'
comment|'# Assert that the resources claimed by the Claim() constructor'
nl|'\n'
comment|"# are returned to the resource tracker due to the claim's abort()"
nl|'\n'
comment|'# method being called when triggered by the exception raised above.'
nl|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
number|'0'
op|','
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|'.'
name|'local_gb_used'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
number|'0'
op|','
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|'.'
name|'memory_mb_used'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
number|'0'
op|','
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|'.'
name|'running_vms'
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.InstancePCIRequests.get_by_instance_uuid'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.MigrationList.get_in_progress_by_host_and_node'"
op|')'
newline|'\n'
DECL|member|test_claim_abort
name|'def'
name|'test_claim_abort'
op|'('
name|'self'
op|','
name|'migr_mock'
op|','
name|'pci_mock'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'pci_mock'
op|'.'
name|'return_value'
op|'='
name|'objects'
op|'.'
name|'InstancePCIRequests'
op|'('
name|'requests'
op|'='
op|'['
op|']'
op|')'
newline|'\n'
name|'disk_used'
op|'='
name|'self'
op|'.'
name|'instance'
op|'.'
name|'root_gb'
op|'+'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'ephemeral_gb'
newline|'\n'
nl|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'objects'
op|'.'
name|'Instance'
op|','
string|"'obj_clone'"
op|','
nl|'\n'
name|'return_value'
op|'='
name|'self'
op|'.'
name|'instance'
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'self'
op|'.'
name|'instance'
op|','
string|"'save'"
op|')'
newline|'\n'
DECL|function|_claim
name|'def'
name|'_claim'
op|'('
name|'mock_save'
op|','
name|'mock_clone'
op|')'
op|':'
newline|'\n'
indent|'            '
name|'return'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'instance_claim'
op|'('
name|'self'
op|'.'
name|'ctx'
op|','
name|'self'
op|'.'
name|'instance'
op|','
name|'None'
op|')'
newline|'\n'
nl|'\n'
dedent|''
name|'claim'
op|'='
name|'_claim'
op|'('
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
name|'disk_used'
op|','
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|'.'
name|'local_gb_used'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
name|'self'
op|'.'
name|'instance'
op|'.'
name|'memory_mb'
op|','
nl|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|'.'
name|'memory_mb_used'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
number|'1'
op|','
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|'.'
name|'running_vms'
op|')'
newline|'\n'
nl|'\n'
name|'mock_save'
op|'='
name|'mock'
op|'.'
name|'MagicMock'
op|'('
op|')'
newline|'\n'
name|'mock_clear_numa'
op|'='
name|'mock'
op|'.'
name|'MagicMock'
op|'('
op|')'
newline|'\n'
nl|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'self'
op|'.'
name|'instance'
op|','
string|"'save'"
op|','
name|'mock_save'
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'self'
op|'.'
name|'instance'
op|','
string|"'clear_numa_topology'"
op|','
nl|'\n'
name|'mock_clear_numa'
op|')'
newline|'\n'
DECL|function|_abort
name|'def'
name|'_abort'
op|'('
op|')'
op|':'
newline|'\n'
indent|'            '
name|'claim'
op|'.'
name|'abort'
op|'('
op|')'
newline|'\n'
nl|'\n'
dedent|''
name|'_abort'
op|'('
op|')'
newline|'\n'
name|'mock_save'
op|'.'
name|'assert_called_once_with'
op|'('
op|')'
newline|'\n'
name|'mock_clear_numa'
op|'.'
name|'assert_called_once_with'
op|'('
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertIsNone'
op|'('
name|'self'
op|'.'
name|'instance'
op|'.'
name|'host'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertIsNone'
op|'('
name|'self'
op|'.'
name|'instance'
op|'.'
name|'node'
op|')'
newline|'\n'
nl|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
number|'0'
op|','
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|'.'
name|'local_gb_used'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
number|'0'
op|','
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|'.'
name|'memory_mb_used'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
number|'0'
op|','
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|'.'
name|'running_vms'
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.InstancePCIRequests.get_by_instance_uuid'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.MigrationList.get_in_progress_by_host_and_node'"
op|')'
newline|'\n'
DECL|member|test_claim_limits
name|'def'
name|'test_claim_limits'
op|'('
name|'self'
op|','
name|'migr_mock'
op|','
name|'pci_mock'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'self'
op|'.'
name|'assertFalse'
op|'('
name|'self'
op|'.'
name|'rt'
op|'.'
name|'disabled'
op|')'
newline|'\n'
nl|'\n'
name|'pci_mock'
op|'.'
name|'return_value'
op|'='
name|'objects'
op|'.'
name|'InstancePCIRequests'
op|'('
name|'requests'
op|'='
op|'['
op|']'
op|')'
newline|'\n'
nl|'\n'
name|'good_limits'
op|'='
op|'{'
nl|'\n'
string|"'memory_mb'"
op|':'
name|'_COMPUTE_NODE_FIXTURES'
op|'['
number|'0'
op|']'
op|'.'
name|'memory_mb'
op|','
nl|'\n'
string|"'disk_gb'"
op|':'
name|'_COMPUTE_NODE_FIXTURES'
op|'['
number|'0'
op|']'
op|'.'
name|'local_gb'
op|','
nl|'\n'
string|"'vcpu'"
op|':'
name|'_COMPUTE_NODE_FIXTURES'
op|'['
number|'0'
op|']'
op|'.'
name|'vcpus'
op|','
nl|'\n'
op|'}'
newline|'\n'
name|'for'
name|'key'
name|'in'
name|'good_limits'
op|'.'
name|'keys'
op|'('
op|')'
op|':'
newline|'\n'
indent|'            '
name|'bad_limits'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'good_limits'
op|')'
newline|'\n'
name|'bad_limits'
op|'['
name|'key'
op|']'
op|'='
number|'0'
newline|'\n'
nl|'\n'
name|'self'
op|'.'
name|'assertRaises'
op|'('
name|'exc'
op|'.'
name|'ComputeResourcesUnavailable'
op|','
nl|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'instance_claim'
op|','
nl|'\n'
name|'self'
op|'.'
name|'ctx'
op|','
name|'self'
op|'.'
name|'instance'
op|','
name|'bad_limits'
op|')'
newline|'\n'
nl|'\n'
dedent|''
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.InstancePCIRequests.get_by_instance_uuid'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.MigrationList.get_in_progress_by_host_and_node'"
op|')'
newline|'\n'
DECL|member|test_claim_numa
name|'def'
name|'test_claim_numa'
op|'('
name|'self'
op|','
name|'migr_mock'
op|','
name|'pci_mock'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'self'
op|'.'
name|'assertFalse'
op|'('
name|'self'
op|'.'
name|'rt'
op|'.'
name|'disabled'
op|')'
newline|'\n'
nl|'\n'
name|'pci_mock'
op|'.'
name|'return_value'
op|'='
name|'objects'
op|'.'
name|'InstancePCIRequests'
op|'('
name|'requests'
op|'='
op|'['
op|']'
op|')'
newline|'\n'
nl|'\n'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'numa_topology'
op|'='
name|'_INSTANCE_NUMA_TOPOLOGIES'
op|'['
string|"'2mb'"
op|']'
newline|'\n'
name|'host_topology'
op|'='
name|'_NUMA_HOST_TOPOLOGIES'
op|'['
string|"'2mb'"
op|']'
newline|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|'.'
name|'numa_topology'
op|'='
name|'host_topology'
op|'.'
name|'_to_json'
op|'('
op|')'
newline|'\n'
name|'limits'
op|'='
op|'{'
string|"'numa_topology'"
op|':'
name|'_NUMA_LIMIT_TOPOLOGIES'
op|'['
string|"'2mb'"
op|']'
op|'}'
newline|'\n'
nl|'\n'
name|'expected_numa'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'host_topology'
op|')'
newline|'\n'
name|'for'
name|'cell'
name|'in'
name|'expected_numa'
op|'.'
name|'cells'
op|':'
newline|'\n'
indent|'            '
name|'cell'
op|'.'
name|'memory_usage'
op|'+='
name|'_2MB'
newline|'\n'
name|'cell'
op|'.'
name|'cpu_usage'
op|'+='
number|'1'
newline|'\n'
dedent|''
name|'with'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'self'
op|'.'
name|'rt'
op|','
string|"'_update'"
op|')'
name|'as'
name|'update_mock'
op|':'
newline|'\n'
indent|'            '
name|'with'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'self'
op|'.'
name|'instance'
op|','
string|"'save'"
op|')'
op|':'
newline|'\n'
indent|'                '
name|'self'
op|'.'
name|'rt'
op|'.'
name|'instance_claim'
op|'('
name|'self'
op|'.'
name|'ctx'
op|','
name|'self'
op|'.'
name|'instance'
op|','
name|'limits'
op|')'
newline|'\n'
dedent|''
name|'update_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'self'
op|'.'
name|'ctx'
op|'.'
name|'elevated'
op|'('
op|')'
op|')'
newline|'\n'
name|'updated_compute_node'
op|'='
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
newline|'\n'
name|'new_numa'
op|'='
name|'updated_compute_node'
op|'.'
name|'numa_topology'
newline|'\n'
name|'new_numa'
op|'='
name|'objects'
op|'.'
name|'NUMATopology'
op|'.'
name|'obj_from_db_obj'
op|'('
name|'new_numa'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqualNUMAHostTopology'
op|'('
name|'expected_numa'
op|','
name|'new_numa'
op|')'
newline|'\n'
nl|'\n'
nl|'\n'
dedent|''
dedent|''
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.Instance.save'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.MigrationList.get_in_progress_by_host_and_node'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.Instance.get_by_uuid'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.InstanceList.get_by_host_and_node'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.InstancePCIRequests.get_by_instance_uuid'"
op|')'
newline|'\n'
DECL|class|TestMoveClaim
name|'class'
name|'TestMoveClaim'
op|'('
name|'BaseTestCase'
op|')'
op|':'
newline|'\n'
DECL|member|setUp
indent|'    '
name|'def'
name|'setUp'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'super'
op|'('
name|'TestMoveClaim'
op|','
name|'self'
op|')'
op|'.'
name|'setUp'
op|'('
op|')'
newline|'\n'
nl|'\n'
name|'self'
op|'.'
name|'_setup_rt'
op|'('
op|')'
newline|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'_COMPUTE_NODE_FIXTURES'
op|'['
number|'0'
op|']'
op|')'
newline|'\n'
nl|'\n'
name|'self'
op|'.'
name|'instance'
op|'='
name|'_INSTANCE_FIXTURES'
op|'['
number|'0'
op|']'
op|'.'
name|'obj_clone'
op|'('
op|')'
newline|'\n'
name|'self'
op|'.'
name|'flavor'
op|'='
name|'_INSTANCE_TYPE_OBJ_FIXTURES'
op|'['
number|'1'
op|']'
newline|'\n'
name|'self'
op|'.'
name|'limits'
op|'='
op|'{'
op|'}'
newline|'\n'
nl|'\n'
comment|'# not using mock.sentinel.ctx because resize_claim calls #elevated'
nl|'\n'
name|'self'
op|'.'
name|'ctx'
op|'='
name|'mock'
op|'.'
name|'MagicMock'
op|'('
op|')'
newline|'\n'
name|'self'
op|'.'
name|'elevated'
op|'='
name|'mock'
op|'.'
name|'MagicMock'
op|'('
op|')'
newline|'\n'
name|'self'
op|'.'
name|'ctx'
op|'.'
name|'elevated'
op|'.'
name|'return_value'
op|'='
name|'self'
op|'.'
name|'elevated'
newline|'\n'
nl|'\n'
comment|'# Initialise extensible resource trackers'
nl|'\n'
name|'self'
op|'.'
name|'flags'
op|'('
name|'reserved_host_disk_mb'
op|'='
number|'0'
op|','
name|'reserved_host_memory_mb'
op|'='
number|'0'
op|')'
newline|'\n'
name|'with'
name|'test'
op|'.'
name|'nested'
op|'('
nl|'\n'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.InstanceList.get_by_host_and_node'"
op|')'
op|','
nl|'\n'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.MigrationList.'"
nl|'\n'
string|"'get_in_progress_by_host_and_node'"
op|')'
nl|'\n'
op|')'
name|'as'
op|'('
name|'inst_list_mock'
op|','
name|'migr_mock'
op|')'
op|':'
newline|'\n'
indent|'            '
name|'inst_list_mock'
op|'.'
name|'return_value'
op|'='
name|'objects'
op|'.'
name|'InstanceList'
op|'('
name|'objects'
op|'='
op|'['
op|']'
op|')'
newline|'\n'
name|'migr_mock'
op|'.'
name|'return_value'
op|'='
name|'objects'
op|'.'
name|'MigrationList'
op|'('
name|'objects'
op|'='
op|'['
op|']'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'update_available_resource'
op|'('
name|'self'
op|'.'
name|'ctx'
op|')'
newline|'\n'
nl|'\n'
DECL|member|register_mocks
dedent|''
dedent|''
name|'def'
name|'register_mocks'
op|'('
name|'self'
op|','
name|'pci_mock'
op|','
name|'inst_list_mock'
op|','
name|'inst_by_uuid'
op|','
nl|'\n'
name|'migr_mock'
op|','
name|'inst_save_mock'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'pci_mock'
op|'.'
name|'return_value'
op|'='
name|'objects'
op|'.'
name|'InstancePCIRequests'
op|'('
name|'requests'
op|'='
op|'['
op|']'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'inst_list_mock'
op|'='
name|'inst_list_mock'
newline|'\n'
name|'self'
op|'.'
name|'inst_by_uuid'
op|'='
name|'inst_by_uuid'
newline|'\n'
name|'self'
op|'.'
name|'migr_mock'
op|'='
name|'migr_mock'
newline|'\n'
name|'self'
op|'.'
name|'inst_save_mock'
op|'='
name|'inst_save_mock'
newline|'\n'
nl|'\n'
DECL|member|audit
dedent|''
name|'def'
name|'audit'
op|'('
name|'self'
op|','
name|'rt'
op|','
name|'instances'
op|','
name|'migrations'
op|','
name|'migr_inst'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'self'
op|'.'
name|'inst_list_mock'
op|'.'
name|'return_value'
op|'='
name|'objects'
op|'.'
name|'InstanceList'
op|'('
name|'objects'
op|'='
name|'instances'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'migr_mock'
op|'.'
name|'return_value'
op|'='
name|'objects'
op|'.'
name|'MigrationList'
op|'('
name|'objects'
op|'='
name|'migrations'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'inst_by_uuid'
op|'.'
name|'return_value'
op|'='
name|'migr_inst'
newline|'\n'
name|'rt'
op|'.'
name|'update_available_resource'
op|'('
name|'self'
op|'.'
name|'ctx'
op|')'
newline|'\n'
nl|'\n'
DECL|member|assertEqual
dedent|''
name|'def'
name|'assertEqual'
op|'('
name|'self'
op|','
name|'expected'
op|','
name|'actual'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'if'
name|'type'
op|'('
name|'expected'
op|')'
op|'!='
name|'dict'
name|'or'
name|'type'
op|'('
name|'actual'
op|')'
op|'!='
name|'dict'
op|':'
newline|'\n'
indent|'            '
name|'super'
op|'('
name|'TestMoveClaim'
op|','
name|'self'
op|')'
op|'.'
name|'assertEqual'
op|'('
name|'expected'
op|','
name|'actual'
op|')'
newline|'\n'
name|'return'
newline|'\n'
dedent|''
name|'fail'
op|'='
name|'False'
newline|'\n'
name|'for'
name|'k'
op|','
name|'e'
name|'in'
name|'expected'
op|'.'
name|'items'
op|'('
op|')'
op|':'
newline|'\n'
indent|'            '
name|'a'
op|'='
name|'actual'
op|'['
name|'k'
op|']'
newline|'\n'
name|'if'
name|'e'
op|'!='
name|'a'
op|':'
newline|'\n'
indent|'                '
name|'print'
op|'('
string|'"%s: %s != %s"'
op|'%'
op|'('
name|'k'
op|','
name|'e'
op|','
name|'a'
op|')'
op|')'
newline|'\n'
name|'fail'
op|'='
name|'True'
newline|'\n'
dedent|''
dedent|''
name|'if'
name|'fail'
op|':'
newline|'\n'
indent|'            '
name|'self'
op|'.'
name|'fail'
op|'('
op|')'
newline|'\n'
nl|'\n'
DECL|member|adjust_expected
dedent|''
dedent|''
name|'def'
name|'adjust_expected'
op|'('
name|'self'
op|','
name|'expected'
op|','
name|'flavor'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'disk_used'
op|'='
name|'flavor'
op|'['
string|"'root_gb'"
op|']'
op|'+'
name|'flavor'
op|'['
string|"'ephemeral_gb'"
op|']'
newline|'\n'
name|'expected'
op|'.'
name|'free_disk_gb'
op|'-='
name|'disk_used'
newline|'\n'
name|'expected'
op|'.'
name|'local_gb_used'
op|'+='
name|'disk_used'
newline|'\n'
name|'expected'
op|'.'
name|'free_ram_mb'
op|'-='
name|'flavor'
op|'['
string|"'memory_mb'"
op|']'
newline|'\n'
name|'expected'
op|'.'
name|'memory_mb_used'
op|'+='
name|'flavor'
op|'['
string|"'memory_mb'"
op|']'
newline|'\n'
name|'expected'
op|'.'
name|'vcpus_used'
op|'+='
name|'flavor'
op|'['
string|"'vcpus'"
op|']'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.Flavor.get_by_id'"
op|')'
newline|'\n'
DECL|member|test_claim
name|'def'
name|'test_claim'
op|'('
name|'self'
op|','
name|'flavor_mock'
op|','
name|'pci_mock'
op|','
name|'inst_list_mock'
op|','
name|'inst_by_uuid'
op|','
nl|'\n'
name|'migr_mock'
op|','
name|'inst_save_mock'
op|')'
op|':'
newline|'\n'
indent|'        '
string|'"""Resize self.instance and check that the expected quantities of each\n        resource have been consumed.\n        """'
newline|'\n'
nl|'\n'
name|'self'
op|'.'
name|'register_mocks'
op|'('
name|'pci_mock'
op|','
name|'inst_list_mock'
op|','
name|'inst_by_uuid'
op|','
name|'migr_mock'
op|','
nl|'\n'
name|'inst_save_mock'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'driver_mock'
op|'.'
name|'get_host_ip_addr'
op|'.'
name|'return_value'
op|'='
string|'"fake-ip"'
newline|'\n'
name|'flavor_mock'
op|'.'
name|'return_value'
op|'='
name|'objects'
op|'.'
name|'Flavor'
op|'('
op|'**'
name|'self'
op|'.'
name|'flavor'
op|')'
newline|'\n'
name|'mig_context_obj'
op|'='
name|'_MIGRATION_CONTEXT_FIXTURES'
op|'['
name|'self'
op|'.'
name|'instance'
op|'.'
name|'uuid'
op|']'
newline|'\n'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'migration_context'
op|'='
name|'mig_context_obj'
newline|'\n'
nl|'\n'
name|'expected'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'adjust_expected'
op|'('
name|'expected'
op|','
name|'self'
op|'.'
name|'flavor'
op|')'
newline|'\n'
nl|'\n'
name|'create_mig_mock'
op|'='
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'self'
op|'.'
name|'rt'
op|','
string|"'_create_migration'"
op|')'
newline|'\n'
name|'mig_ctxt_mock'
op|'='
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.MigrationContext'"
op|','
nl|'\n'
name|'return_value'
op|'='
name|'mig_context_obj'
op|')'
newline|'\n'
name|'with'
name|'create_mig_mock'
name|'as'
name|'migr_mock'
op|','
name|'mig_ctxt_mock'
name|'as'
name|'ctxt_mock'
op|':'
newline|'\n'
indent|'            '
name|'migr_mock'
op|'.'
name|'return_value'
op|'='
name|'_MIGRATION_FIXTURES'
op|'['
string|"'source-only'"
op|']'
newline|'\n'
name|'claim'
op|'='
name|'self'
op|'.'
name|'rt'
op|'.'
name|'resize_claim'
op|'('
nl|'\n'
name|'self'
op|'.'
name|'ctx'
op|','
name|'self'
op|'.'
name|'instance'
op|','
name|'self'
op|'.'
name|'flavor'
op|','
name|'None'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
number|'1'
op|','
name|'ctxt_mock'
op|'.'
name|'call_count'
op|')'
newline|'\n'
nl|'\n'
dedent|''
name|'self'
op|'.'
name|'assertIsInstance'
op|'('
name|'claim'
op|','
name|'claims'
op|'.'
name|'MoveClaim'
op|')'
newline|'\n'
name|'inst_save_mock'
op|'.'
name|'assert_called_once_with'
op|'('
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertTrue'
op|'('
name|'obj_base'
op|'.'
name|'obj_equal_prims'
op|'('
name|'expected'
op|','
nl|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|')'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_claim_abort
dedent|''
name|'def'
name|'test_claim_abort'
op|'('
name|'self'
op|','
name|'pci_mock'
op|','
name|'inst_list_mock'
op|','
nl|'\n'
name|'inst_by_uuid'
op|','
name|'migr_mock'
op|','
name|'inst_save_mock'
op|')'
op|':'
newline|'\n'
comment|'# Resize self.instance and check that the expected quantities of each'
nl|'\n'
comment|'# resource have been consumed. The abort the resize claim and check'
nl|'\n'
comment|'# that the resources have been set back to their original values.'
nl|'\n'
indent|'        '
name|'self'
op|'.'
name|'register_mocks'
op|'('
name|'pci_mock'
op|','
name|'inst_list_mock'
op|','
name|'inst_by_uuid'
op|','
name|'migr_mock'
op|','
nl|'\n'
name|'inst_save_mock'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'driver_mock'
op|'.'
name|'get_host_ip_addr'
op|'.'
name|'return_value'
op|'='
string|'"fake-host"'
newline|'\n'
name|'migr_obj'
op|'='
name|'_MIGRATION_FIXTURES'
op|'['
string|"'dest-only'"
op|']'
newline|'\n'
name|'self'
op|'.'
name|'instance'
op|'='
name|'_MIGRATION_INSTANCE_FIXTURES'
op|'['
name|'migr_obj'
op|'['
string|"'instance_uuid'"
op|']'
op|']'
newline|'\n'
name|'mig_context_obj'
op|'='
name|'_MIGRATION_CONTEXT_FIXTURES'
op|'['
name|'self'
op|'.'
name|'instance'
op|'.'
name|'uuid'
op|']'
newline|'\n'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'migration_context'
op|'='
name|'mig_context_obj'
newline|'\n'
name|'self'
op|'.'
name|'flavor'
op|'='
name|'_INSTANCE_TYPE_OBJ_FIXTURES'
op|'['
number|'2'
op|']'
newline|'\n'
nl|'\n'
name|'with'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'self'
op|'.'
name|'rt'
op|','
string|"'_create_migration'"
op|')'
name|'as'
name|'migr_mock'
op|':'
newline|'\n'
indent|'            '
name|'migr_mock'
op|'.'
name|'return_value'
op|'='
name|'migr_obj'
newline|'\n'
name|'claim'
op|'='
name|'self'
op|'.'
name|'rt'
op|'.'
name|'resize_claim'
op|'('
nl|'\n'
name|'self'
op|'.'
name|'ctx'
op|','
name|'self'
op|'.'
name|'instance'
op|','
name|'self'
op|'.'
name|'flavor'
op|','
name|'None'
op|')'
newline|'\n'
nl|'\n'
dedent|''
name|'self'
op|'.'
name|'assertIsInstance'
op|'('
name|'claim'
op|','
name|'claims'
op|'.'
name|'MoveClaim'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
number|'5'
op|','
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|'.'
name|'local_gb_used'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
number|'256'
op|','
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|'.'
name|'memory_mb_used'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
number|'1'
op|','
name|'len'
op|'('
name|'self'
op|'.'
name|'rt'
op|'.'
name|'tracked_migrations'
op|')'
op|')'
newline|'\n'
nl|'\n'
name|'with'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.Instance.'"
nl|'\n'
string|"'drop_migration_context'"
op|')'
name|'as'
name|'drop_migr_mock'
op|':'
newline|'\n'
indent|'            '
name|'claim'
op|'.'
name|'abort'
op|'('
op|')'
newline|'\n'
name|'drop_migr_mock'
op|'.'
name|'assert_called_once_with'
op|'('
op|')'
newline|'\n'
nl|'\n'
dedent|''
name|'self'
op|'.'
name|'assertEqual'
op|'('
number|'0'
op|','
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|'.'
name|'local_gb_used'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
number|'0'
op|','
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|'.'
name|'memory_mb_used'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
number|'0'
op|','
name|'len'
op|'('
name|'self'
op|'.'
name|'rt'
op|'.'
name|'tracked_migrations'
op|')'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_same_host
dedent|''
name|'def'
name|'test_same_host'
op|'('
name|'self'
op|','
name|'pci_mock'
op|','
name|'inst_list_mock'
op|','
name|'inst_by_uuid'
op|','
nl|'\n'
name|'migr_mock'
op|','
name|'inst_save_mock'
op|')'
op|':'
newline|'\n'
indent|'        '
string|'"""Resize self.instance to the same host but with a different flavor.\n        Then abort the claim. Check that the same amount of resources are\n        available afterwards as we started with.\n        """'
newline|'\n'
nl|'\n'
name|'self'
op|'.'
name|'register_mocks'
op|'('
name|'pci_mock'
op|','
name|'inst_list_mock'
op|','
name|'inst_by_uuid'
op|','
name|'migr_mock'
op|','
nl|'\n'
name|'inst_save_mock'
op|')'
newline|'\n'
name|'migr_obj'
op|'='
name|'_MIGRATION_FIXTURES'
op|'['
string|"'source-and-dest'"
op|']'
newline|'\n'
name|'self'
op|'.'
name|'instance'
op|'='
name|'_MIGRATION_INSTANCE_FIXTURES'
op|'['
name|'migr_obj'
op|'['
string|"'instance_uuid'"
op|']'
op|']'
newline|'\n'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'_context'
op|'='
name|'self'
op|'.'
name|'ctx'
newline|'\n'
name|'mig_context_obj'
op|'='
name|'_MIGRATION_CONTEXT_FIXTURES'
op|'['
name|'self'
op|'.'
name|'instance'
op|'.'
name|'uuid'
op|']'
newline|'\n'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'migration_context'
op|'='
name|'mig_context_obj'
newline|'\n'
nl|'\n'
name|'with'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'self'
op|'.'
name|'instance'
op|','
string|"'save'"
op|')'
op|':'
newline|'\n'
indent|'            '
name|'self'
op|'.'
name|'rt'
op|'.'
name|'instance_claim'
op|'('
name|'self'
op|'.'
name|'ctx'
op|','
name|'self'
op|'.'
name|'instance'
op|','
name|'None'
op|')'
newline|'\n'
dedent|''
name|'expected'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|')'
newline|'\n'
nl|'\n'
name|'create_mig_mock'
op|'='
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'self'
op|'.'
name|'rt'
op|','
string|"'_create_migration'"
op|')'
newline|'\n'
name|'mig_ctxt_mock'
op|'='
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.MigrationContext'"
op|','
nl|'\n'
name|'return_value'
op|'='
name|'mig_context_obj'
op|')'
newline|'\n'
nl|'\n'
name|'with'
name|'create_mig_mock'
name|'as'
name|'migr_mock'
op|','
name|'mig_ctxt_mock'
name|'as'
name|'ctxt_mock'
op|':'
newline|'\n'
indent|'            '
name|'migr_mock'
op|'.'
name|'return_value'
op|'='
name|'migr_obj'
newline|'\n'
name|'claim'
op|'='
name|'self'
op|'.'
name|'rt'
op|'.'
name|'resize_claim'
op|'('
name|'self'
op|'.'
name|'ctx'
op|','
name|'self'
op|'.'
name|'instance'
op|','
nl|'\n'
name|'_INSTANCE_TYPE_OBJ_FIXTURES'
op|'['
number|'1'
op|']'
op|','
name|'None'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
number|'1'
op|','
name|'ctxt_mock'
op|'.'
name|'call_count'
op|')'
newline|'\n'
nl|'\n'
dedent|''
name|'self'
op|'.'
name|'audit'
op|'('
name|'self'
op|'.'
name|'rt'
op|','
op|'['
name|'self'
op|'.'
name|'instance'
op|']'
op|','
op|'['
name|'migr_obj'
op|']'
op|','
name|'self'
op|'.'
name|'instance'
op|')'
newline|'\n'
name|'inst_save_mock'
op|'.'
name|'assert_called_once_with'
op|'('
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertNotEqual'
op|'('
name|'expected'
op|','
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|')'
newline|'\n'
nl|'\n'
name|'claim'
op|'.'
name|'instance'
op|'.'
name|'migration_context'
op|'='
name|'mig_context_obj'
newline|'\n'
name|'with'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.MigrationContext._destroy'"
op|')'
name|'as'
name|'destroy_m'
op|':'
newline|'\n'
indent|'            '
name|'claim'
op|'.'
name|'abort'
op|'('
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertTrue'
op|'('
name|'obj_base'
op|'.'
name|'obj_equal_prims'
op|'('
name|'expected'
op|','
nl|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|')'
op|')'
newline|'\n'
name|'destroy_m'
op|'.'
name|'assert_called_once_with'
op|'('
name|'self'
op|'.'
name|'ctx'
op|','
name|'claim'
op|'.'
name|'instance'
op|'.'
name|'uuid'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_revert_reserve_source
dedent|''
dedent|''
name|'def'
name|'test_revert_reserve_source'
op|'('
nl|'\n'
name|'self'
op|','
name|'pci_mock'
op|','
name|'inst_list_mock'
op|','
name|'inst_by_uuid'
op|','
name|'migr_mock'
op|','
nl|'\n'
name|'inst_save_mock'
op|')'
op|':'
newline|'\n'
indent|'        '
string|'"""Check that the source node of an instance migration reserves\n        resources until the migration has completed, even if the migration is\n        reverted.\n        """'
newline|'\n'
nl|'\n'
name|'self'
op|'.'
name|'register_mocks'
op|'('
name|'pci_mock'
op|','
name|'inst_list_mock'
op|','
name|'inst_by_uuid'
op|','
name|'migr_mock'
op|','
nl|'\n'
name|'inst_save_mock'
op|')'
newline|'\n'
nl|'\n'
comment|'# Get our migrations, instances and itypes in a row'
nl|'\n'
name|'src_migr'
op|'='
name|'_MIGRATION_FIXTURES'
op|'['
string|"'source-only'"
op|']'
newline|'\n'
name|'src_instance'
op|'='
op|'('
nl|'\n'
name|'_MIGRATION_INSTANCE_FIXTURES'
op|'['
name|'src_migr'
op|'['
string|"'instance_uuid'"
op|']'
op|']'
op|'.'
name|'obj_clone'
op|'('
op|')'
nl|'\n'
op|')'
newline|'\n'
name|'src_instance'
op|'.'
name|'migration_context'
op|'='
op|'('
nl|'\n'
name|'_MIGRATION_CONTEXT_FIXTURES'
op|'['
name|'src_instance'
op|'.'
name|'uuid'
op|']'
op|')'
newline|'\n'
name|'old_itype'
op|'='
name|'_INSTANCE_TYPE_FIXTURES'
op|'['
name|'src_migr'
op|'['
string|"'old_instance_type_id'"
op|']'
op|']'
newline|'\n'
name|'dst_migr'
op|'='
name|'_MIGRATION_FIXTURES'
op|'['
string|"'dest-only'"
op|']'
newline|'\n'
name|'dst_instance'
op|'='
op|'('
nl|'\n'
name|'_MIGRATION_INSTANCE_FIXTURES'
op|'['
name|'dst_migr'
op|'['
string|"'instance_uuid'"
op|']'
op|']'
op|'.'
name|'obj_clone'
op|'('
op|')'
nl|'\n'
op|')'
newline|'\n'
name|'new_itype'
op|'='
name|'_INSTANCE_TYPE_FIXTURES'
op|'['
name|'dst_migr'
op|'['
string|"'new_instance_type_id'"
op|']'
op|']'
newline|'\n'
name|'dst_instance'
op|'.'
name|'migration_context'
op|'='
op|'('
nl|'\n'
name|'_MIGRATION_CONTEXT_FIXTURES'
op|'['
name|'dst_instance'
op|'.'
name|'uuid'
op|']'
op|')'
newline|'\n'
nl|'\n'
comment|'# Set up the destination resource tracker'
nl|'\n'
comment|'# update_available_resource to initialise extensible resource trackers'
nl|'\n'
name|'src_rt'
op|'='
name|'self'
op|'.'
name|'rt'
newline|'\n'
op|'('
name|'dst_rt'
op|','
name|'_'
op|','
name|'_'
op|')'
op|'='
name|'setup_rt'
op|'('
string|'"other-host"'
op|','
string|'"other-node"'
op|')'
newline|'\n'
name|'dst_rt'
op|'.'
name|'compute_node'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'_COMPUTE_NODE_FIXTURES'
op|'['
number|'0'
op|']'
op|')'
newline|'\n'
name|'inst_list_mock'
op|'.'
name|'return_value'
op|'='
name|'objects'
op|'.'
name|'InstanceList'
op|'('
name|'objects'
op|'='
op|'['
op|']'
op|')'
newline|'\n'
name|'dst_rt'
op|'.'
name|'update_available_resource'
op|'('
name|'self'
op|'.'
name|'ctx'
op|')'
newline|'\n'
nl|'\n'
comment|'# Register the instance with dst_rt'
nl|'\n'
name|'expected'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'dst_rt'
op|'.'
name|'compute_node'
op|')'
newline|'\n'
name|'with'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'dst_instance'
op|','
string|"'save'"
op|')'
op|':'
newline|'\n'
indent|'            '
name|'dst_rt'
op|'.'
name|'instance_claim'
op|'('
name|'self'
op|'.'
name|'ctx'
op|','
name|'dst_instance'
op|')'
newline|'\n'
dedent|''
name|'self'
op|'.'
name|'adjust_expected'
op|'('
name|'expected'
op|','
name|'new_itype'
op|')'
newline|'\n'
name|'expected'
op|'.'
name|'stats'
op|'='
op|'{'
string|"'num_task_resize_migrating'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'io_workload'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'num_instances'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'num_proj_fake-project'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'num_vm_active'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'num_os_type_fake-os'"
op|':'
number|'1'
op|'}'
newline|'\n'
name|'expected'
op|'.'
name|'current_workload'
op|'='
number|'1'
newline|'\n'
name|'expected'
op|'.'
name|'running_vms'
op|'='
number|'1'
newline|'\n'
name|'self'
op|'.'
name|'assertTrue'
op|'('
name|'obj_base'
op|'.'
name|'obj_equal_prims'
op|'('
name|'expected'
op|','
nl|'\n'
name|'dst_rt'
op|'.'
name|'compute_node'
op|')'
op|')'
newline|'\n'
nl|'\n'
comment|'# Provide the migration via a mock, then audit dst_rt to check that'
nl|'\n'
comment|'# the instance + migration resources are not double-counted'
nl|'\n'
name|'self'
op|'.'
name|'audit'
op|'('
name|'dst_rt'
op|','
op|'['
name|'dst_instance'
op|']'
op|','
op|'['
name|'dst_migr'
op|']'
op|','
name|'dst_instance'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertTrue'
op|'('
name|'obj_base'
op|'.'
name|'obj_equal_prims'
op|'('
name|'expected'
op|','
nl|'\n'
name|'dst_rt'
op|'.'
name|'compute_node'
op|')'
op|')'
newline|'\n'
nl|'\n'
comment|'# Audit src_rt with src_migr'
nl|'\n'
name|'expected'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'src_rt'
op|'.'
name|'compute_node'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'adjust_expected'
op|'('
name|'expected'
op|','
name|'old_itype'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'audit'
op|'('
name|'src_rt'
op|','
op|'['
op|']'
op|','
op|'['
name|'src_migr'
op|']'
op|','
name|'src_instance'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertTrue'
op|'('
name|'obj_base'
op|'.'
name|'obj_equal_prims'
op|'('
name|'expected'
op|','
nl|'\n'
name|'src_rt'
op|'.'
name|'compute_node'
op|')'
op|')'
newline|'\n'
nl|'\n'
comment|'# Flag the instance as reverting and re-audit'
nl|'\n'
name|'src_instance'
op|'['
string|"'vm_state'"
op|']'
op|'='
name|'vm_states'
op|'.'
name|'RESIZED'
newline|'\n'
name|'src_instance'
op|'['
string|"'task_state'"
op|']'
op|'='
name|'task_states'
op|'.'
name|'RESIZE_REVERTING'
newline|'\n'
name|'self'
op|'.'
name|'audit'
op|'('
name|'src_rt'
op|','
op|'['
op|']'
op|','
op|'['
name|'src_migr'
op|']'
op|','
name|'src_instance'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertTrue'
op|'('
name|'obj_base'
op|'.'
name|'obj_equal_prims'
op|'('
name|'expected'
op|','
nl|'\n'
name|'src_rt'
op|'.'
name|'compute_node'
op|')'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_update_available_resources_migration_no_context
dedent|''
name|'def'
name|'test_update_available_resources_migration_no_context'
op|'('
name|'self'
op|','
name|'pci_mock'
op|','
nl|'\n'
name|'inst_list_mock'
op|','
name|'inst_by_uuid'
op|','
name|'migr_mock'
op|','
name|'inst_save_mock'
op|')'
op|':'
newline|'\n'
indent|'        '
string|'"""When migrating onto older nodes - it is possible for the\n        migration_context record to be missing. Confirm resource audit works\n        regardless.\n        """'
newline|'\n'
name|'self'
op|'.'
name|'register_mocks'
op|'('
name|'pci_mock'
op|','
name|'inst_list_mock'
op|','
name|'inst_by_uuid'
op|','
name|'migr_mock'
op|','
nl|'\n'
name|'inst_save_mock'
op|')'
newline|'\n'
name|'migr_obj'
op|'='
name|'_MIGRATION_FIXTURES'
op|'['
string|"'source-and-dest'"
op|']'
newline|'\n'
name|'self'
op|'.'
name|'instance'
op|'='
name|'_MIGRATION_INSTANCE_FIXTURES'
op|'['
name|'migr_obj'
op|'['
string|"'instance_uuid'"
op|']'
op|']'
newline|'\n'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'migration_context'
op|'='
name|'None'
newline|'\n'
nl|'\n'
name|'expected'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'adjust_expected'
op|'('
name|'expected'
op|','
name|'self'
op|'.'
name|'flavor'
op|')'
newline|'\n'
nl|'\n'
name|'self'
op|'.'
name|'audit'
op|'('
name|'self'
op|'.'
name|'rt'
op|','
op|'['
op|']'
op|','
op|'['
name|'migr_obj'
op|']'
op|','
name|'self'
op|'.'
name|'instance'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertTrue'
op|'('
name|'obj_base'
op|'.'
name|'obj_equal_prims'
op|'('
name|'expected'
op|','
nl|'\n'
name|'self'
op|'.'
name|'rt'
op|'.'
name|'compute_node'
op|')'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_dupe_filter
dedent|''
name|'def'
name|'test_dupe_filter'
op|'('
name|'self'
op|','
name|'pci_mock'
op|','
name|'inst_list_mock'
op|','
name|'inst_by_uuid'
op|','
nl|'\n'
name|'migr_mock'
op|','
name|'inst_save_mock'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'self'
op|'.'
name|'register_mocks'
op|'('
name|'pci_mock'
op|','
name|'inst_list_mock'
op|','
name|'inst_by_uuid'
op|','
name|'migr_mock'
op|','
nl|'\n'
name|'inst_save_mock'
op|')'
newline|'\n'
nl|'\n'
name|'migr_obj'
op|'='
name|'_MIGRATION_FIXTURES'
op|'['
string|"'source-and-dest'"
op|']'
newline|'\n'
comment|'# This is good enough to prevent a lazy-load; value is unimportant'
nl|'\n'
name|'migr_obj'
op|'['
string|"'updated_at'"
op|']'
op|'='
name|'None'
newline|'\n'
name|'self'
op|'.'
name|'instance'
op|'='
name|'_MIGRATION_INSTANCE_FIXTURES'
op|'['
name|'migr_obj'
op|'['
string|"'instance_uuid'"
op|']'
op|']'
newline|'\n'
name|'self'
op|'.'
name|'instance'
op|'.'
name|'migration_context'
op|'='
op|'('
nl|'\n'
name|'_MIGRATION_CONTEXT_FIXTURES'
op|'['
name|'self'
op|'.'
name|'instance'
op|'.'
name|'uuid'
op|']'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'audit'
op|'('
name|'self'
op|'.'
name|'rt'
op|','
op|'['
op|']'
op|','
op|'['
name|'migr_obj'
op|','
name|'migr_obj'
op|']'
op|','
name|'self'
op|'.'
name|'instance'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
number|'1'
op|','
name|'len'
op|'('
name|'self'
op|'.'
name|'rt'
op|'.'
name|'tracked_migrations'
op|')'
op|')'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|class|TestInstanceInResizeState
dedent|''
dedent|''
name|'class'
name|'TestInstanceInResizeState'
op|'('
name|'test'
op|'.'
name|'NoDBTestCase'
op|')'
op|':'
newline|'\n'
DECL|member|test_active_suspending
indent|'    '
name|'def'
name|'test_active_suspending'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'instance'
op|'='
name|'objects'
op|'.'
name|'Instance'
op|'('
name|'vm_state'
op|'='
name|'vm_states'
op|'.'
name|'ACTIVE'
op|','
nl|'\n'
name|'task_state'
op|'='
name|'task_states'
op|'.'
name|'SUSPENDING'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertFalse'
op|'('
name|'resource_tracker'
op|'.'
name|'_instance_in_resize_state'
op|'('
name|'instance'
op|')'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_resized_suspending
dedent|''
name|'def'
name|'test_resized_suspending'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'instance'
op|'='
name|'objects'
op|'.'
name|'Instance'
op|'('
name|'vm_state'
op|'='
name|'vm_states'
op|'.'
name|'RESIZED'
op|','
nl|'\n'
name|'task_state'
op|'='
name|'task_states'
op|'.'
name|'SUSPENDING'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertTrue'
op|'('
name|'resource_tracker'
op|'.'
name|'_instance_in_resize_state'
op|'('
name|'instance'
op|')'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_resized_resize_migrating
dedent|''
name|'def'
name|'test_resized_resize_migrating'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'instance'
op|'='
name|'objects'
op|'.'
name|'Instance'
op|'('
name|'vm_state'
op|'='
name|'vm_states'
op|'.'
name|'RESIZED'
op|','
nl|'\n'
name|'task_state'
op|'='
name|'task_states'
op|'.'
name|'RESIZE_MIGRATING'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertTrue'
op|'('
name|'resource_tracker'
op|'.'
name|'_instance_in_resize_state'
op|'('
name|'instance'
op|')'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_resized_resize_finish
dedent|''
name|'def'
name|'test_resized_resize_finish'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'instance'
op|'='
name|'objects'
op|'.'
name|'Instance'
op|'('
name|'vm_state'
op|'='
name|'vm_states'
op|'.'
name|'RESIZED'
op|','
nl|'\n'
name|'task_state'
op|'='
name|'task_states'
op|'.'
name|'RESIZE_FINISH'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertTrue'
op|'('
name|'resource_tracker'
op|'.'
name|'_instance_in_resize_state'
op|'('
name|'instance'
op|')'
op|')'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|function|_update_compute_node
dedent|''
dedent|''
name|'def'
name|'_update_compute_node'
op|'('
name|'node'
op|','
op|'**'
name|'kwargs'
op|')'
op|':'
newline|'\n'
indent|'    '
name|'for'
name|'key'
op|','
name|'value'
name|'in'
name|'kwargs'
op|'.'
name|'items'
op|'('
op|')'
op|':'
newline|'\n'
indent|'        '
name|'setattr'
op|'('
name|'node'
op|','
name|'key'
op|','
name|'value'
op|')'
newline|'\n'
dedent|''
dedent|''
endmarker|''
end_unit

Sets up the resource tracker instance with mock fixtures.\n\n    :param virt_resources: Optional override of the resource representation\n                           returned by the virt driver\'s\n                           `get_available_resource()` method.\n    :param estimate_overhead: Optional override of a function that should\n                              return overhead of memory given an instance\n                              object. Defaults to returning zero overhead.\n #elevated' #elevated' Resize self.instance and check that the expected quantities of each\n        resource have been consumed.\n Resize self.instance to the same host but with a different flavor.\n        Then abort the claim. Check that the same amount of resources are\n        available afterwards as we started with.\n Check that the source node of an instance migration reserves\n        resources until the migration has completed, even if the migration is\n        reverted.\n When migrating onto older nodes - it is possible for the\n        migration_context record to be missing. Confirm resource audit works\n        regardless.\n