<gh_stars>0
begin_unit
comment|'# Copyright (c) 2012 OpenStack Foundation'
nl|'\n'
comment|'# All Rights Reserved.'
nl|'\n'
comment|'#'
nl|'\n'
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'
name|'import'
name|'mock'
newline|'\n'
name|'import'
name|'netaddr'
newline|'\n'
name|'from'
name|'webob'
name|'import'
name|'exc'
newline|'\n'
nl|'\n'
name|'from'
name|'nova'
op|'.'
name|'api'
op|'.'
name|'openstack'
op|'.'
name|'compute'
name|'import'
name|'hypervisors'
name|'as'
name|'hypervisors_v21'
newline|'\n'
name|'from'
name|'nova'
op|'.'
name|'cells'
name|'import'
name|'utils'
name|'as'
name|'cells_utils'
newline|'\n'
name|'from'
name|'nova'
name|'import'
name|'exception'
newline|'\n'
name|'from'
name|'nova'
name|'import'
name|'objects'
newline|'\n'
name|'from'
name|'nova'
name|'import'
name|'test'
newline|'\n'
name|'from'
name|'nova'
op|'.'
name|'tests'
op|'.'
name|'unit'
op|'.'
name|'api'
op|'.'
name|'openstack'
name|'import'
name|'fakes'
newline|'\n'
name|'from'
name|'nova'
op|'.'
name|'tests'
op|'.'
name|'unit'
name|'import'
name|'fake_instance'
newline|'\n'
name|'from'
name|'nova'
op|'.'
name|'tests'
name|'import'
name|'uuidsentinel'
name|'as'
name|'uuids'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|variable|TEST_HYPERS
name|'TEST_HYPERS'
op|'='
op|'['
nl|'\n'
name|'dict'
op|'('
name|'id'
op|'='
number|'1'
op|','
nl|'\n'
DECL|variable|service_id
name|'service_id'
op|'='
number|'1'
op|','
nl|'\n'
DECL|variable|host
name|'host'
op|'='
string|'"compute1"'
op|','
nl|'\n'
DECL|variable|vcpus
name|'vcpus'
op|'='
number|'4'
op|','
nl|'\n'
DECL|variable|memory_mb
name|'memory_mb'
op|'='
number|'10'
op|'*'
number|'1024'
op|','
nl|'\n'
DECL|variable|local_gb
name|'local_gb'
op|'='
number|'250'
op|','
nl|'\n'
DECL|variable|vcpus_used
name|'vcpus_used'
op|'='
number|'2'
op|','
nl|'\n'
DECL|variable|memory_mb_used
name|'memory_mb_used'
op|'='
number|'5'
op|'*'
number|'1024'
op|','
nl|'\n'
DECL|variable|local_gb_used
name|'local_gb_used'
op|'='
number|'125'
op|','
nl|'\n'
DECL|variable|hypervisor_type
name|'hypervisor_type'
op|'='
string|'"xen"'
op|','
nl|'\n'
DECL|variable|hypervisor_version
name|'hypervisor_version'
op|'='
number|'3'
op|','
nl|'\n'
DECL|variable|hypervisor_hostname
name|'hypervisor_hostname'
op|'='
string|'"hyper1"'
op|','
nl|'\n'
DECL|variable|free_ram_mb
name|'free_ram_mb'
op|'='
number|'5'
op|'*'
number|'1024'
op|','
nl|'\n'
DECL|variable|free_disk_gb
name|'free_disk_gb'
op|'='
number|'125'
op|','
nl|'\n'
DECL|variable|current_workload
name|'current_workload'
op|'='
number|'2'
op|','
nl|'\n'
DECL|variable|running_vms
name|'running_vms'
op|'='
number|'2'
op|','
nl|'\n'
DECL|variable|cpu_info
name|'cpu_info'
op|'='
string|"'cpu_info'"
op|','
nl|'\n'
DECL|variable|disk_available_least
name|'disk_available_least'
op|'='
number|'100'
op|','
nl|'\n'
DECL|variable|host_ip
name|'host_ip'
op|'='
name|'netaddr'
op|'.'
name|'IPAddress'
op|'('
string|"'1.1.1.1'"
op|')'
op|')'
op|','
nl|'\n'
name|'dict'
op|'('
name|'id'
op|'='
number|'2'
op|','
nl|'\n'
DECL|variable|service_id
name|'service_id'
op|'='
number|'2'
op|','
nl|'\n'
DECL|variable|host
name|'host'
op|'='
string|'"compute2"'
op|','
nl|'\n'
DECL|variable|vcpus
name|'vcpus'
op|'='
number|'4'
op|','
nl|'\n'
DECL|variable|memory_mb
name|'memory_mb'
op|'='
number|'10'
op|'*'
number|'1024'
op|','
nl|'\n'
DECL|variable|local_gb
name|'local_gb'
op|'='
number|'250'
op|','
nl|'\n'
DECL|variable|vcpus_used
name|'vcpus_used'
op|'='
number|'2'
op|','
nl|'\n'
DECL|variable|memory_mb_used
name|'memory_mb_used'
op|'='
number|'5'
op|'*'
number|'1024'
op|','
nl|'\n'
DECL|variable|local_gb_used
name|'local_gb_used'
op|'='
number|'125'
op|','
nl|'\n'
DECL|variable|hypervisor_type
name|'hypervisor_type'
op|'='
string|'"xen"'
op|','
nl|'\n'
DECL|variable|hypervisor_version
name|'hypervisor_version'
op|'='
number|'3'
op|','
nl|'\n'
DECL|variable|hypervisor_hostname
name|'hypervisor_hostname'
op|'='
string|'"hyper2"'
op|','
nl|'\n'
DECL|variable|free_ram_mb
name|'free_ram_mb'
op|'='
number|'5'
op|'*'
number|'1024'
op|','
nl|'\n'
DECL|variable|free_disk_gb
name|'free_disk_gb'
op|'='
number|'125'
op|','
nl|'\n'
DECL|variable|current_workload
name|'current_workload'
op|'='
number|'2'
op|','
nl|'\n'
DECL|variable|running_vms
name|'running_vms'
op|'='
number|'2'
op|','
nl|'\n'
DECL|variable|cpu_info
name|'cpu_info'
op|'='
string|"'cpu_info'"
op|','
nl|'\n'
DECL|variable|disk_available_least
name|'disk_available_least'
op|'='
number|'100'
op|','
nl|'\n'
DECL|variable|host_ip
name|'host_ip'
op|'='
name|'netaddr'
op|'.'
name|'IPAddress'
op|'('
string|"'2.2.2.2'"
op|')'
op|')'
op|']'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|variable|TEST_SERVICES
name|'TEST_SERVICES'
op|'='
op|'['
nl|'\n'
name|'objects'
op|'.'
name|'Service'
op|'('
name|'id'
op|'='
number|'1'
op|','
nl|'\n'
DECL|variable|host
name|'host'
op|'='
string|'"compute1"'
op|','
nl|'\n'
DECL|variable|binary
name|'binary'
op|'='
string|'"nova-compute"'
op|','
nl|'\n'
DECL|variable|topic
name|'topic'
op|'='
string|'"compute_topic"'
op|','
nl|'\n'
DECL|variable|report_count
name|'report_count'
op|'='
number|'5'
op|','
nl|'\n'
DECL|variable|disabled
name|'disabled'
op|'='
name|'False'
op|','
nl|'\n'
DECL|variable|disabled_reason
name|'disabled_reason'
op|'='
name|'None'
op|','
nl|'\n'
DECL|variable|availability_zone
name|'availability_zone'
op|'='
string|'"nova"'
op|')'
op|','
nl|'\n'
name|'objects'
op|'.'
name|'Service'
op|'('
name|'id'
op|'='
number|'2'
op|','
nl|'\n'
DECL|variable|host
name|'host'
op|'='
string|'"compute2"'
op|','
nl|'\n'
DECL|variable|binary
name|'binary'
op|'='
string|'"nova-compute"'
op|','
nl|'\n'
DECL|variable|topic
name|'topic'
op|'='
string|'"compute_topic"'
op|','
nl|'\n'
DECL|variable|report_count
name|'report_count'
op|'='
number|'5'
op|','
nl|'\n'
DECL|variable|disabled
name|'disabled'
op|'='
name|'False'
op|','
nl|'\n'
DECL|variable|disabled_reason
name|'disabled_reason'
op|'='
name|'None'
op|','
nl|'\n'
DECL|variable|availability_zone
name|'availability_zone'
op|'='
string|'"nova"'
op|')'
op|','
nl|'\n'
op|']'
newline|'\n'
nl|'\n'
DECL|variable|TEST_HYPERS_OBJ
name|'TEST_HYPERS_OBJ'
op|'='
op|'['
name|'objects'
op|'.'
name|'ComputeNode'
op|'('
op|'**'
name|'hyper_dct'
op|')'
nl|'\n'
name|'for'
name|'hyper_dct'
name|'in'
name|'TEST_HYPERS'
op|']'
newline|'\n'
nl|'\n'
name|'TEST_HYPERS'
op|'['
number|'0'
op|']'
op|'.'
name|'update'
op|'('
op|'{'
string|"'service'"
op|':'
name|'TEST_SERVICES'
op|'['
number|'0'
op|']'
op|'}'
op|')'
newline|'\n'
name|'TEST_HYPERS'
op|'['
number|'1'
op|']'
op|'.'
name|'update'
op|'('
op|'{'
string|"'service'"
op|':'
name|'TEST_SERVICES'
op|'['
number|'1'
op|']'
op|'}'
op|')'
newline|'\n'
nl|'\n'
DECL|variable|TEST_SERVERS
name|'TEST_SERVERS'
op|'='
op|'['
name|'dict'
op|'('
name|'name'
op|'='
string|'"inst1"'
op|','
name|'uuid'
op|'='
name|'uuids'
op|'.'
name|'instance_1'
op|','
name|'host'
op|'='
string|'"compute1"'
op|')'
op|','
nl|'\n'
name|'dict'
op|'('
name|'name'
op|'='
string|'"inst2"'
op|','
name|'uuid'
op|'='
name|'uuids'
op|'.'
name|'instance_2'
op|','
name|'host'
op|'='
string|'"compute2"'
op|')'
op|','
nl|'\n'
name|'dict'
op|'('
name|'name'
op|'='
string|'"inst3"'
op|','
name|'uuid'
op|'='
name|'uuids'
op|'.'
name|'instance_3'
op|','
name|'host'
op|'='
string|'"compute1"'
op|')'
op|','
nl|'\n'
name|'dict'
op|'('
name|'name'
op|'='
string|'"inst4"'
op|','
name|'uuid'
op|'='
name|'uuids'
op|'.'
name|'instance_4'
op|','
name|'host'
op|'='
string|'"compute2"'
op|')'
op|']'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|function|fake_compute_node_get_all
name|'def'
name|'fake_compute_node_get_all'
op|'('
name|'context'
op|')'
op|':'
newline|'\n'
indent|'    '
name|'return'
name|'TEST_HYPERS_OBJ'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|function|fake_compute_node_search_by_hypervisor
dedent|''
name|'def'
name|'fake_compute_node_search_by_hypervisor'
op|'('
name|'context'
op|','
name|'hypervisor_re'
op|')'
op|':'
newline|'\n'
indent|'    '
name|'return'
name|'TEST_HYPERS_OBJ'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|function|fake_compute_node_get
dedent|''
name|'def'
name|'fake_compute_node_get'
op|'('
name|'context'
op|','
name|'compute_id'
op|')'
op|':'
newline|'\n'
indent|'    '
name|'for'
name|'hyper'
name|'in'
name|'TEST_HYPERS_OBJ'
op|':'
newline|'\n'
indent|'        '
name|'if'
name|'hyper'
op|'.'
name|'id'
op|'=='
name|'int'
op|'('
name|'compute_id'
op|')'
op|':'
newline|'\n'
indent|'            '
name|'return'
name|'hyper'
newline|'\n'
dedent|''
dedent|''
name|'raise'
name|'exception'
op|'.'
name|'ComputeHostNotFound'
op|'('
name|'host'
op|'='
name|'compute_id'
op|')'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|function|fake_service_get_by_compute_host
dedent|''
name|'def'
name|'fake_service_get_by_compute_host'
op|'('
name|'context'
op|','
name|'host'
op|')'
op|':'
newline|'\n'
indent|'    '
name|'for'
name|'service'
name|'in'
name|'TEST_SERVICES'
op|':'
newline|'\n'
indent|'        '
name|'if'
name|'service'
op|'.'
name|'host'
op|'=='
name|'host'
op|':'
newline|'\n'
indent|'            '
name|'return'
name|'service'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|function|fake_compute_node_statistics
dedent|''
dedent|''
dedent|''
name|'def'
name|'fake_compute_node_statistics'
op|'('
name|'context'
op|')'
op|':'
newline|'\n'
indent|'    '
name|'result'
op|'='
name|'dict'
op|'('
nl|'\n'
name|'count'
op|'='
number|'0'
op|','
nl|'\n'
name|'vcpus'
op|'='
number|'0'
op|','
nl|'\n'
name|'memory_mb'
op|'='
number|'0'
op|','
nl|'\n'
name|'local_gb'
op|'='
number|'0'
op|','
nl|'\n'
name|'vcpus_used'
op|'='
number|'0'
op|','
nl|'\n'
name|'memory_mb_used'
op|'='
number|'0'
op|','
nl|'\n'
name|'local_gb_used'
op|'='
number|'0'
op|','
nl|'\n'
name|'free_ram_mb'
op|'='
number|'0'
op|','
nl|'\n'
name|'free_disk_gb'
op|'='
number|'0'
op|','
nl|'\n'
name|'current_workload'
op|'='
number|'0'
op|','
nl|'\n'
name|'running_vms'
op|'='
number|'0'
op|','
nl|'\n'
name|'disk_available_least'
op|'='
number|'0'
op|','
nl|'\n'
op|')'
newline|'\n'
nl|'\n'
name|'for'
name|'hyper'
name|'in'
name|'TEST_HYPERS_OBJ'
op|':'
newline|'\n'
indent|'        '
name|'for'
name|'key'
name|'in'
name|'result'
op|':'
newline|'\n'
indent|'            '
name|'if'
name|'key'
op|'=='
string|"'count'"
op|':'
newline|'\n'
indent|'                '
name|'result'
op|'['
name|'key'
op|']'
op|'+='
number|'1'
newline|'\n'
dedent|''
name|'else'
op|':'
newline|'\n'
indent|'                '
name|'result'
op|'['
name|'key'
op|']'
op|'+='
name|'getattr'
op|'('
name|'hyper'
op|','
name|'key'
op|')'
newline|'\n'
nl|'\n'
dedent|''
dedent|''
dedent|''
name|'return'
name|'result'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|function|fake_instance_get_all_by_host
dedent|''
name|'def'
name|'fake_instance_get_all_by_host'
op|'('
name|'context'
op|','
name|'host'
op|')'
op|':'
newline|'\n'
indent|'    '
name|'results'
op|'='
op|'['
op|']'
newline|'\n'
name|'for'
name|'inst'
name|'in'
name|'TEST_SERVERS'
op|':'
newline|'\n'
indent|'        '
name|'if'
name|'inst'
op|'['
string|"'host'"
op|']'
op|'=='
name|'host'
op|':'
newline|'\n'
indent|'            '
name|'inst_obj'
op|'='
name|'fake_instance'
op|'.'
name|'fake_instance_obj'
op|'('
name|'context'
op|','
op|'**'
name|'inst'
op|')'
newline|'\n'
name|'results'
op|'.'
name|'append'
op|'('
name|'inst_obj'
op|')'
newline|'\n'
dedent|''
dedent|''
name|'return'
name|'results'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|class|HypervisorsTestV21
dedent|''
name|'class'
name|'HypervisorsTestV21'
op|'('
name|'test'
op|'.'
name|'NoDBTestCase'
op|')'
op|':'
newline|'\n'
comment|'# copying the objects locally so the cells testcases can provide their own'
nl|'\n'
DECL|variable|TEST_HYPERS_OBJ
indent|'    '
name|'TEST_HYPERS_OBJ'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'TEST_HYPERS_OBJ'
op|')'
newline|'\n'
DECL|variable|TEST_SERVICES
name|'TEST_SERVICES'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'TEST_SERVICES'
op|')'
newline|'\n'
DECL|variable|TEST_SERVERS
name|'TEST_SERVERS'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'TEST_SERVERS'
op|')'
newline|'\n'
nl|'\n'
DECL|variable|DETAIL_HYPERS_DICTS
name|'DETAIL_HYPERS_DICTS'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'TEST_HYPERS'
op|')'
newline|'\n'
name|'del'
name|'DETAIL_HYPERS_DICTS'
op|'['
number|'0'
op|']'
op|'['
string|"'service_id'"
op|']'
newline|'\n'
name|'del'
name|'DETAIL_HYPERS_DICTS'
op|'['
number|'1'
op|']'
op|'['
string|"'service_id'"
op|']'
newline|'\n'
name|'del'
name|'DETAIL_HYPERS_DICTS'
op|'['
number|'0'
op|']'
op|'['
string|"'host'"
op|']'
newline|'\n'
name|'del'
name|'DETAIL_HYPERS_DICTS'
op|'['
number|'1'
op|']'
op|'['
string|"'host'"
op|']'
newline|'\n'
name|'DETAIL_HYPERS_DICTS'
op|'['
number|'0'
op|']'
op|'.'
name|'update'
op|'('
op|'{'
string|"'state'"
op|':'
string|"'up'"
op|','
nl|'\n'
string|"'status'"
op|':'
string|"'enabled'"
op|','
nl|'\n'
string|"'service'"
op|':'
name|'dict'
op|'('
name|'id'
op|'='
number|'1'
op|','
name|'host'
op|'='
string|"'compute1'"
op|','
nl|'\n'
DECL|variable|disabled_reason
name|'disabled_reason'
op|'='
name|'None'
op|')'
op|'}'
op|')'
newline|'\n'
name|'DETAIL_HYPERS_DICTS'
op|'['
number|'1'
op|']'
op|'.'
name|'update'
op|'('
op|'{'
string|"'state'"
op|':'
string|"'up'"
op|','
nl|'\n'
string|"'status'"
op|':'
string|"'enabled'"
op|','
nl|'\n'
string|"'service'"
op|':'
name|'dict'
op|'('
name|'id'
op|'='
number|'2'
op|','
name|'host'
op|'='
string|"'compute2'"
op|','
nl|'\n'
DECL|variable|disabled_reason
name|'disabled_reason'
op|'='
name|'None'
op|')'
op|'}'
op|')'
newline|'\n'
nl|'\n'
DECL|variable|INDEX_HYPER_DICTS
name|'INDEX_HYPER_DICTS'
op|'='
op|'['
nl|'\n'
name|'dict'
op|'('
name|'id'
op|'='
number|'1'
op|','
name|'hypervisor_hostname'
op|'='
string|'"hyper1"'
op|','
nl|'\n'
name|'state'
op|'='
string|"'up'"
op|','
name|'status'
op|'='
string|"'enabled'"
op|')'
op|','
nl|'\n'
name|'dict'
op|'('
name|'id'
op|'='
number|'2'
op|','
name|'hypervisor_hostname'
op|'='
string|'"hyper2"'
op|','
nl|'\n'
name|'state'
op|'='
string|"'up'"
op|','
name|'status'
op|'='
string|"'enabled'"
op|')'
op|']'
newline|'\n'
nl|'\n'
DECL|member|_get_request
name|'def'
name|'_get_request'
op|'('
name|'self'
op|','
name|'use_admin_context'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'return'
name|'fakes'
op|'.'
name|'HTTPRequest'
op|'.'
name|'blank'
op|'('
string|"''"
op|','
name|'use_admin_context'
op|'='
name|'use_admin_context'
op|')'
newline|'\n'
nl|'\n'
DECL|member|_set_up_controller
dedent|''
name|'def'
name|'_set_up_controller'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'self'
op|'.'
name|'controller'
op|'='
name|'hypervisors_v21'
op|'.'
name|'HypervisorsController'
op|'('
op|')'
newline|'\n'
name|'self'
op|'.'
name|'controller'
op|'.'
name|'servicegroup_api'
op|'.'
name|'service_is_up'
op|'='
name|'mock'
op|'.'
name|'MagicMock'
op|'('
nl|'\n'
name|'return_value'
op|'='
name|'True'
op|')'
newline|'\n'
nl|'\n'
DECL|member|setUp
dedent|''
name|'def'
name|'setUp'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'super'
op|'('
name|'HypervisorsTestV21'
op|','
name|'self'
op|')'
op|'.'
name|'setUp'
op|'('
op|')'
newline|'\n'
name|'self'
op|'.'
name|'_set_up_controller'
op|'('
op|')'
newline|'\n'
name|'self'
op|'.'
name|'rule_hyp_show'
op|'='
string|'"os_compute_api:os-hypervisors"'
newline|'\n'
name|'self'
op|'.'
name|'stubs'
op|'.'
name|'Set'
op|'('
name|'self'
op|'.'
name|'controller'
op|'.'
name|'host_api'
op|','
string|"'compute_node_get_all'"
op|','
nl|'\n'
name|'fake_compute_node_get_all'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'stubs'
op|'.'
name|'Set'
op|'('
name|'self'
op|'.'
name|'controller'
op|'.'
name|'host_api'
op|','
string|"'service_get_by_compute_host'"
op|','
nl|'\n'
name|'fake_service_get_by_compute_host'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'stubs'
op|'.'
name|'Set'
op|'('
name|'self'
op|'.'
name|'controller'
op|'.'
name|'host_api'
op|','
nl|'\n'
string|"'compute_node_search_by_hypervisor'"
op|','
nl|'\n'
name|'fake_compute_node_search_by_hypervisor'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'stubs'
op|'.'
name|'Set'
op|'('
name|'self'
op|'.'
name|'controller'
op|'.'
name|'host_api'
op|','
string|"'compute_node_get'"
op|','
nl|'\n'
name|'fake_compute_node_get'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'stub_out'
op|'('
string|"'nova.db.compute_node_statistics'"
op|','
nl|'\n'
name|'fake_compute_node_statistics'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_view_hypervisor_nodetail_noservers
dedent|''
name|'def'
name|'test_view_hypervisor_nodetail_noservers'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'result'
op|'='
name|'self'
op|'.'
name|'controller'
op|'.'
name|'_view_hypervisor'
op|'('
nl|'\n'
name|'self'
op|'.'
name|'TEST_HYPERS_OBJ'
op|'['
number|'0'
op|']'
op|','
name|'self'
op|'.'
name|'TEST_SERVICES'
op|'['
number|'0'
op|']'
op|','
name|'False'
op|')'
newline|'\n'
nl|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
name|'result'
op|','
name|'self'
op|'.'
name|'INDEX_HYPER_DICTS'
op|'['
number|'0'
op|']'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_view_hypervisor_detail_noservers
dedent|''
name|'def'
name|'test_view_hypervisor_detail_noservers'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'result'
op|'='
name|'self'
op|'.'
name|'controller'
op|'.'
name|'_view_hypervisor'
op|'('
nl|'\n'
name|'self'
op|'.'
name|'TEST_HYPERS_OBJ'
op|'['
number|'0'
op|']'
op|','
name|'self'
op|'.'
name|'TEST_SERVICES'
op|'['
number|'0'
op|']'
op|','
name|'True'
op|')'
newline|'\n'
nl|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
name|'result'
op|','
name|'self'
op|'.'
name|'DETAIL_HYPERS_DICTS'
op|'['
number|'0'
op|']'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_view_hypervisor_servers
dedent|''
name|'def'
name|'test_view_hypervisor_servers'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'result'
op|'='
name|'self'
op|'.'
name|'controller'
op|'.'
name|'_view_hypervisor'
op|'('
name|'self'
op|'.'
name|'TEST_HYPERS_OBJ'
op|'['
number|'0'
op|']'
op|','
nl|'\n'
name|'self'
op|'.'
name|'TEST_SERVICES'
op|'['
number|'0'
op|']'
op|','
nl|'\n'
name|'False'
op|','
name|'self'
op|'.'
name|'TEST_SERVERS'
op|')'
newline|'\n'
name|'expected_dict'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'self'
op|'.'
name|'INDEX_HYPER_DICTS'
op|'['
number|'0'
op|']'
op|')'
newline|'\n'
name|'expected_dict'
op|'.'
name|'update'
op|'('
op|'{'
string|"'servers'"
op|':'
op|'['
nl|'\n'
name|'dict'
op|'('
name|'name'
op|'='
string|'"inst1"'
op|','
name|'uuid'
op|'='
name|'uuids'
op|'.'
name|'instance_1'
op|')'
op|','
nl|'\n'
name|'dict'
op|'('
name|'name'
op|'='
string|'"inst2"'
op|','
name|'uuid'
op|'='
name|'uuids'
op|'.'
name|'instance_2'
op|')'
op|','
nl|'\n'
name|'dict'
op|'('
name|'name'
op|'='
string|'"inst3"'
op|','
name|'uuid'
op|'='
name|'uuids'
op|'.'
name|'instance_3'
op|')'
op|','
nl|'\n'
name|'dict'
op|'('
name|'name'
op|'='
string|'"inst4"'
op|','
name|'uuid'
op|'='
name|'uuids'
op|'.'
name|'instance_4'
op|')'
op|']'
op|'}'
op|')'
newline|'\n'
nl|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
name|'result'
op|','
name|'expected_dict'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_index
dedent|''
name|'def'
name|'test_index'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'req'
op|'='
name|'self'
op|'.'
name|'_get_request'
op|'('
name|'True'
op|')'
newline|'\n'
name|'result'
op|'='
name|'self'
op|'.'
name|'controller'
op|'.'
name|'index'
op|'('
name|'req'
op|')'
newline|'\n'
nl|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
name|'result'
op|','
name|'dict'
op|'('
name|'hypervisors'
op|'='
name|'self'
op|'.'
name|'INDEX_HYPER_DICTS'
op|')'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_index_non_admin
dedent|''
name|'def'
name|'test_index_non_admin'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'req'
op|'='
name|'self'
op|'.'
name|'_get_request'
op|'('
name|'False'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertRaises'
op|'('
name|'exception'
op|'.'
name|'PolicyNotAuthorized'
op|','
nl|'\n'
name|'self'
op|'.'
name|'controller'
op|'.'
name|'index'
op|','
name|'req'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_detail
dedent|''
name|'def'
name|'test_detail'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'req'
op|'='
name|'self'
op|'.'
name|'_get_request'
op|'('
name|'True'
op|')'
newline|'\n'
name|'result'
op|'='
name|'self'
op|'.'
name|'controller'
op|'.'
name|'detail'
op|'('
name|'req'
op|')'
newline|'\n'
nl|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
name|'result'
op|','
name|'dict'
op|'('
name|'hypervisors'
op|'='
name|'self'
op|'.'
name|'DETAIL_HYPERS_DICTS'
op|')'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_detail_non_admin
dedent|''
name|'def'
name|'test_detail_non_admin'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'req'
op|'='
name|'self'
op|'.'
name|'_get_request'
op|'('
name|'False'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertRaises'
op|'('
name|'exception'
op|'.'
name|'PolicyNotAuthorized'
op|','
nl|'\n'
name|'self'
op|'.'
name|'controller'
op|'.'
name|'detail'
op|','
name|'req'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_show_noid
dedent|''
name|'def'
name|'test_show_noid'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'req'
op|'='
name|'self'
op|'.'
name|'_get_request'
op|'('
name|'True'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertRaises'
op|'('
name|'exc'
op|'.'
name|'HTTPNotFound'
op|','
name|'self'
op|'.'
name|'controller'
op|'.'
name|'show'
op|','
name|'req'
op|','
string|"'3'"
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_show_non_integer_id
dedent|''
name|'def'
name|'test_show_non_integer_id'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'req'
op|'='
name|'self'
op|'.'
name|'_get_request'
op|'('
name|'True'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertRaises'
op|'('
name|'exc'
op|'.'
name|'HTTPNotFound'
op|','
name|'self'
op|'.'
name|'controller'
op|'.'
name|'show'
op|','
name|'req'
op|','
string|"'abc'"
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_show_withid
dedent|''
name|'def'
name|'test_show_withid'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'req'
op|'='
name|'self'
op|'.'
name|'_get_request'
op|'('
name|'True'
op|')'
newline|'\n'
name|'result'
op|'='
name|'self'
op|'.'
name|'controller'
op|'.'
name|'show'
op|'('
name|'req'
op|','
name|'self'
op|'.'
name|'TEST_HYPERS_OBJ'
op|'['
number|'0'
op|']'
op|'.'
name|'id'
op|')'
newline|'\n'
nl|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
name|'result'
op|','
name|'dict'
op|'('
name|'hypervisor'
op|'='
name|'self'
op|'.'
name|'DETAIL_HYPERS_DICTS'
op|'['
number|'0'
op|']'
op|')'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_show_non_admin
dedent|''
name|'def'
name|'test_show_non_admin'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'req'
op|'='
name|'self'
op|'.'
name|'_get_request'
op|'('
name|'False'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertRaises'
op|'('
name|'exception'
op|'.'
name|'PolicyNotAuthorized'
op|','
nl|'\n'
name|'self'
op|'.'
name|'controller'
op|'.'
name|'show'
op|','
name|'req'
op|','
nl|'\n'
name|'self'
op|'.'
name|'TEST_HYPERS_OBJ'
op|'['
number|'0'
op|']'
op|'.'
name|'id'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_uptime_noid
dedent|''
name|'def'
name|'test_uptime_noid'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'req'
op|'='
name|'self'
op|'.'
name|'_get_request'
op|'('
name|'True'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertRaises'
op|'('
name|'exc'
op|'.'
name|'HTTPNotFound'
op|','
name|'self'
op|'.'
name|'controller'
op|'.'
name|'uptime'
op|','
name|'req'
op|','
string|"'3'"
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_uptime_notimplemented
dedent|''
name|'def'
name|'test_uptime_notimplemented'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
DECL|function|fake_get_host_uptime
indent|'        '
name|'def'
name|'fake_get_host_uptime'
op|'('
name|'context'
op|','
name|'hyp'
op|')'
op|':'
newline|'\n'
indent|'            '
name|'raise'
name|'exc'
op|'.'
name|'HTTPNotImplemented'
op|'('
op|')'
newline|'\n'
nl|'\n'
dedent|''
name|'self'
op|'.'
name|'stubs'
op|'.'
name|'Set'
op|'('
name|'self'
op|'.'
name|'controller'
op|'.'
name|'host_api'
op|','
string|"'get_host_uptime'"
op|','
nl|'\n'
name|'fake_get_host_uptime'
op|')'
newline|'\n'
nl|'\n'
name|'req'
op|'='
name|'self'
op|'.'
name|'_get_request'
op|'('
name|'True'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertRaises'
op|'('
name|'exc'
op|'.'
name|'HTTPNotImplemented'
op|','
nl|'\n'
name|'self'
op|'.'
name|'controller'
op|'.'
name|'uptime'
op|','
name|'req'
op|','
nl|'\n'
name|'self'
op|'.'
name|'TEST_HYPERS_OBJ'
op|'['
number|'0'
op|']'
op|'.'
name|'id'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_uptime_implemented
dedent|''
name|'def'
name|'test_uptime_implemented'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
DECL|function|fake_get_host_uptime
indent|'        '
name|'def'
name|'fake_get_host_uptime'
op|'('
name|'context'
op|','
name|'hyp'
op|')'
op|':'
newline|'\n'
indent|'            '
name|'return'
string|'"fake uptime"'
newline|'\n'
nl|'\n'
dedent|''
name|'self'
op|'.'
name|'stubs'
op|'.'
name|'Set'
op|'('
name|'self'
op|'.'
name|'controller'
op|'.'
name|'host_api'
op|','
string|"'get_host_uptime'"
op|','
nl|'\n'
name|'fake_get_host_uptime'
op|')'
newline|'\n'
nl|'\n'
name|'req'
op|'='
name|'self'
op|'.'
name|'_get_request'
op|'('
name|'True'
op|')'
newline|'\n'
name|'result'
op|'='
name|'self'
op|'.'
name|'controller'
op|'.'
name|'uptime'
op|'('
name|'req'
op|','
name|'self'
op|'.'
name|'TEST_HYPERS_OBJ'
op|'['
number|'0'
op|']'
op|'.'
name|'id'
op|')'
newline|'\n'
nl|'\n'
name|'expected_dict'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'self'
op|'.'
name|'INDEX_HYPER_DICTS'
op|'['
number|'0'
op|']'
op|')'
newline|'\n'
name|'expected_dict'
op|'.'
name|'update'
op|'('
op|'{'
string|"'uptime'"
op|':'
string|'"fake uptime"'
op|'}'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
name|'result'
op|','
name|'dict'
op|'('
name|'hypervisor'
op|'='
name|'expected_dict'
op|')'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_uptime_non_integer_id
dedent|''
name|'def'
name|'test_uptime_non_integer_id'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'req'
op|'='
name|'self'
op|'.'
name|'_get_request'
op|'('
name|'True'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertRaises'
op|'('
name|'exc'
op|'.'
name|'HTTPNotFound'
op|','
name|'self'
op|'.'
name|'controller'
op|'.'
name|'uptime'
op|','
name|'req'
op|','
string|"'abc'"
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_uptime_non_admin
dedent|''
name|'def'
name|'test_uptime_non_admin'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'req'
op|'='
name|'self'
op|'.'
name|'_get_request'
op|'('
name|'False'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertRaises'
op|'('
name|'exception'
op|'.'
name|'PolicyNotAuthorized'
op|','
nl|'\n'
name|'self'
op|'.'
name|'controller'
op|'.'
name|'uptime'
op|','
name|'req'
op|','
nl|'\n'
name|'self'
op|'.'
name|'TEST_HYPERS_OBJ'
op|'['
number|'0'
op|']'
op|'.'
name|'id'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_uptime_hypervisor_down
dedent|''
name|'def'
name|'test_uptime_hypervisor_down'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
DECL|function|fake_get_host_uptime
indent|'        '
name|'def'
name|'fake_get_host_uptime'
op|'('
name|'context'
op|','
name|'hyp'
op|')'
op|':'
newline|'\n'
indent|'            '
name|'raise'
name|'exception'
op|'.'
name|'ComputeServiceUnavailable'
op|'('
name|'host'
op|'='
string|"'dummy'"
op|')'
newline|'\n'
nl|'\n'
dedent|''
name|'self'
op|'.'
name|'stubs'
op|'.'
name|'Set'
op|'('
name|'self'
op|'.'
name|'controller'
op|'.'
name|'host_api'
op|','
string|"'get_host_uptime'"
op|','
nl|'\n'
name|'fake_get_host_uptime'
op|')'
newline|'\n'
nl|'\n'
name|'req'
op|'='
name|'self'
op|'.'
name|'_get_request'
op|'('
name|'True'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertRaises'
op|'('
name|'exc'
op|'.'
name|'HTTPBadRequest'
op|','
nl|'\n'
name|'self'
op|'.'
name|'controller'
op|'.'
name|'uptime'
op|','
name|'req'
op|','
nl|'\n'
name|'self'
op|'.'
name|'TEST_HYPERS_OBJ'
op|'['
number|'0'
op|']'
op|'.'
name|'id'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_search
dedent|''
name|'def'
name|'test_search'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'req'
op|'='
name|'self'
op|'.'
name|'_get_request'
op|'('
name|'True'
op|')'
newline|'\n'
name|'result'
op|'='
name|'self'
op|'.'
name|'controller'
op|'.'
name|'search'
op|'('
name|'req'
op|','
string|"'hyper'"
op|')'
newline|'\n'
nl|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
name|'result'
op|','
name|'dict'
op|'('
name|'hypervisors'
op|'='
name|'self'
op|'.'
name|'INDEX_HYPER_DICTS'
op|')'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_search_non_admin
dedent|''
name|'def'
name|'test_search_non_admin'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'req'
op|'='
name|'self'
op|'.'
name|'_get_request'
op|'('
name|'False'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertRaises'
op|'('
name|'exception'
op|'.'
name|'PolicyNotAuthorized'
op|','
nl|'\n'
name|'self'
op|'.'
name|'controller'
op|'.'
name|'search'
op|','
name|'req'
op|','
nl|'\n'
name|'self'
op|'.'
name|'TEST_HYPERS_OBJ'
op|'['
number|'0'
op|']'
op|'.'
name|'id'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_search_non_exist
dedent|''
name|'def'
name|'test_search_non_exist'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
DECL|function|fake_compute_node_search_by_hypervisor_return_empty
indent|'        '
name|'def'
name|'fake_compute_node_search_by_hypervisor_return_empty'
op|'('
name|'context'
op|','
nl|'\n'
name|'hypervisor_re'
op|')'
op|':'
newline|'\n'
indent|'            '
name|'return'
op|'['
op|']'
newline|'\n'
dedent|''
name|'self'
op|'.'
name|'stubs'
op|'.'
name|'Set'
op|'('
name|'self'
op|'.'
name|'controller'
op|'.'
name|'host_api'
op|','
nl|'\n'
string|"'compute_node_search_by_hypervisor'"
op|','
nl|'\n'
name|'fake_compute_node_search_by_hypervisor_return_empty'
op|')'
newline|'\n'
name|'req'
op|'='
name|'self'
op|'.'
name|'_get_request'
op|'('
name|'True'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertRaises'
op|'('
name|'exc'
op|'.'
name|'HTTPNotFound'
op|','
name|'self'
op|'.'
name|'controller'
op|'.'
name|'search'
op|','
name|'req'
op|','
string|"'a'"
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'objects'
op|'.'
name|'InstanceList'
op|','
string|"'get_by_host'"
op|','
nl|'\n'
name|'side_effect'
op|'='
name|'fake_instance_get_all_by_host'
op|')'
newline|'\n'
DECL|member|test_servers
name|'def'
name|'test_servers'
op|'('
name|'self'
op|','
name|'mock_get'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'req'
op|'='
name|'self'
op|'.'
name|'_get_request'
op|'('
name|'True'
op|')'
newline|'\n'
name|'result'
op|'='
name|'self'
op|'.'
name|'controller'
op|'.'
name|'servers'
op|'('
name|'req'
op|','
string|"'hyper'"
op|')'
newline|'\n'
nl|'\n'
name|'expected_dict'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'self'
op|'.'
name|'INDEX_HYPER_DICTS'
op|')'
newline|'\n'
name|'expected_dict'
op|'['
number|'0'
op|']'
op|'.'
name|'update'
op|'('
op|'{'
string|"'servers'"
op|':'
op|'['
nl|'\n'
name|'dict'
op|'('
name|'uuid'
op|'='
name|'uuids'
op|'.'
name|'instance_1'
op|')'
op|','
nl|'\n'
name|'dict'
op|'('
name|'uuid'
op|'='
name|'uuids'
op|'.'
name|'instance_3'
op|')'
op|']'
op|'}'
op|')'
newline|'\n'
name|'expected_dict'
op|'['
number|'1'
op|']'
op|'.'
name|'update'
op|'('
op|'{'
string|"'servers'"
op|':'
op|'['
nl|'\n'
name|'dict'
op|'('
name|'uuid'
op|'='
name|'uuids'
op|'.'
name|'instance_2'
op|')'
op|','
nl|'\n'
name|'dict'
op|'('
name|'uuid'
op|'='
name|'uuids'
op|'.'
name|'instance_4'
op|')'
op|']'
op|'}'
op|')'
newline|'\n'
nl|'\n'
name|'for'
name|'output'
name|'in'
name|'result'
op|'['
string|"'hypervisors'"
op|']'
op|':'
newline|'\n'
indent|'            '
name|'servers'
op|'='
name|'output'
op|'['
string|"'servers'"
op|']'
newline|'\n'
name|'for'
name|'server'
name|'in'
name|'servers'
op|':'
newline|'\n'
indent|'                '
name|'del'
name|'server'
op|'['
string|"'name'"
op|']'
newline|'\n'
dedent|''
dedent|''
name|'self'
op|'.'
name|'assertEqual'
op|'('
name|'result'
op|','
name|'dict'
op|'('
name|'hypervisors'
op|'='
name|'expected_dict'
op|')'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_servers_non_id
dedent|''
name|'def'
name|'test_servers_non_id'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
DECL|function|fake_compute_node_search_by_hypervisor_return_empty
indent|'        '
name|'def'
name|'fake_compute_node_search_by_hypervisor_return_empty'
op|'('
name|'context'
op|','
nl|'\n'
name|'hypervisor_re'
op|')'
op|':'
newline|'\n'
indent|'            '
name|'return'
op|'['
op|']'
newline|'\n'
dedent|''
name|'self'
op|'.'
name|'stubs'
op|'.'
name|'Set'
op|'('
name|'self'
op|'.'
name|'controller'
op|'.'
name|'host_api'
op|','
nl|'\n'
string|"'compute_node_search_by_hypervisor'"
op|','
nl|'\n'
name|'fake_compute_node_search_by_hypervisor_return_empty'
op|')'
newline|'\n'
nl|'\n'
name|'req'
op|'='
name|'self'
op|'.'
name|'_get_request'
op|'('
name|'True'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertRaises'
op|'('
name|'exc'
op|'.'
name|'HTTPNotFound'
op|','
nl|'\n'
name|'self'
op|'.'
name|'controller'
op|'.'
name|'servers'
op|','
nl|'\n'
name|'req'
op|','
string|"'115'"
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_servers_non_admin
dedent|''
name|'def'
name|'test_servers_non_admin'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'req'
op|'='
name|'self'
op|'.'
name|'_get_request'
op|'('
name|'False'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertRaises'
op|'('
name|'exception'
op|'.'
name|'PolicyNotAuthorized'
op|','
nl|'\n'
name|'self'
op|'.'
name|'controller'
op|'.'
name|'servers'
op|','
name|'req'
op|','
nl|'\n'
name|'self'
op|'.'
name|'TEST_HYPERS_OBJ'
op|'['
number|'0'
op|']'
op|'.'
name|'id'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_servers_with_non_integer_hypervisor_id
dedent|''
name|'def'
name|'test_servers_with_non_integer_hypervisor_id'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
DECL|function|fake_compute_node_search_by_hypervisor_return_empty
indent|'        '
name|'def'
name|'fake_compute_node_search_by_hypervisor_return_empty'
op|'('
name|'context'
op|','
nl|'\n'
name|'hypervisor_re'
op|')'
op|':'
newline|'\n'
indent|'            '
name|'return'
op|'['
op|']'
newline|'\n'
dedent|''
name|'self'
op|'.'
name|'stubs'
op|'.'
name|'Set'
op|'('
name|'self'
op|'.'
name|'controller'
op|'.'
name|'host_api'
op|','
nl|'\n'
string|"'compute_node_search_by_hypervisor'"
op|','
nl|'\n'
name|'fake_compute_node_search_by_hypervisor_return_empty'
op|')'
newline|'\n'
nl|'\n'
name|'req'
op|'='
name|'self'
op|'.'
name|'_get_request'
op|'('
name|'True'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertRaises'
op|'('
name|'exc'
op|'.'
name|'HTTPNotFound'
op|','
nl|'\n'
name|'self'
op|'.'
name|'controller'
op|'.'
name|'servers'
op|','
name|'req'
op|','
string|"'abc'"
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_servers_with_no_server
dedent|''
name|'def'
name|'test_servers_with_no_server'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
DECL|function|fake_instance_get_all_by_host_return_empty
indent|'        '
name|'def'
name|'fake_instance_get_all_by_host_return_empty'
op|'('
name|'context'
op|','
name|'hypervisor_re'
op|')'
op|':'
newline|'\n'
indent|'            '
name|'return'
op|'['
op|']'
newline|'\n'
dedent|''
name|'self'
op|'.'
name|'stubs'
op|'.'
name|'Set'
op|'('
name|'self'
op|'.'
name|'controller'
op|'.'
name|'host_api'
op|','
string|"'instance_get_all_by_host'"
op|','
nl|'\n'
name|'fake_instance_get_all_by_host_return_empty'
op|')'
newline|'\n'
name|'req'
op|'='
name|'self'
op|'.'
name|'_get_request'
op|'('
name|'True'
op|')'
newline|'\n'
name|'result'
op|'='
name|'self'
op|'.'
name|'controller'
op|'.'
name|'servers'
op|'('
name|'req'
op|','
name|'self'
op|'.'
name|'TEST_HYPERS_OBJ'
op|'['
number|'0'
op|']'
op|'.'
name|'id'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
name|'result'
op|','
name|'dict'
op|'('
name|'hypervisors'
op|'='
name|'self'
op|'.'
name|'INDEX_HYPER_DICTS'
op|')'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_statistics
dedent|''
name|'def'
name|'test_statistics'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'req'
op|'='
name|'self'
op|'.'
name|'_get_request'
op|'('
name|'True'
op|')'
newline|'\n'
name|'result'
op|'='
name|'self'
op|'.'
name|'controller'
op|'.'
name|'statistics'
op|'('
name|'req'
op|')'
newline|'\n'
nl|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
name|'result'
op|','
name|'dict'
op|'('
name|'hypervisor_statistics'
op|'='
name|'dict'
op|'('
nl|'\n'
name|'count'
op|'='
number|'2'
op|','
nl|'\n'
name|'vcpus'
op|'='
number|'8'
op|','
nl|'\n'
name|'memory_mb'
op|'='
number|'20'
op|'*'
number|'1024'
op|','
nl|'\n'
name|'local_gb'
op|'='
number|'500'
op|','
nl|'\n'
name|'vcpus_used'
op|'='
number|'4'
op|','
nl|'\n'
name|'memory_mb_used'
op|'='
number|'10'
op|'*'
number|'1024'
op|','
nl|'\n'
name|'local_gb_used'
op|'='
number|'250'
op|','
nl|'\n'
name|'free_ram_mb'
op|'='
number|'10'
op|'*'
number|'1024'
op|','
nl|'\n'
name|'free_disk_gb'
op|'='
number|'250'
op|','
nl|'\n'
name|'current_workload'
op|'='
number|'4'
op|','
nl|'\n'
name|'running_vms'
op|'='
number|'4'
op|','
nl|'\n'
name|'disk_available_least'
op|'='
number|'200'
op|')'
op|')'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_statistics_non_admin
dedent|''
name|'def'
name|'test_statistics_non_admin'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'req'
op|'='
name|'self'
op|'.'
name|'_get_request'
op|'('
name|'False'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertRaises'
op|'('
name|'exception'
op|'.'
name|'PolicyNotAuthorized'
op|','
nl|'\n'
name|'self'
op|'.'
name|'controller'
op|'.'
name|'statistics'
op|','
name|'req'
op|')'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|variable|_CELL_PATH
dedent|''
dedent|''
name|'_CELL_PATH'
op|'='
string|"'cell1'"
newline|'\n'
nl|'\n'
nl|'\n'
DECL|class|CellHypervisorsTestV21
name|'class'
name|'CellHypervisorsTestV21'
op|'('
name|'HypervisorsTestV21'
op|')'
op|':'
newline|'\n'
DECL|variable|TEST_HYPERS_OBJ
indent|'    '
name|'TEST_HYPERS_OBJ'
op|'='
op|'['
name|'cells_utils'
op|'.'
name|'ComputeNodeProxy'
op|'('
name|'obj'
op|','
name|'_CELL_PATH'
op|')'
nl|'\n'
name|'for'
name|'obj'
name|'in'
name|'TEST_HYPERS_OBJ'
op|']'
newline|'\n'
DECL|variable|TEST_SERVICES
name|'TEST_SERVICES'
op|'='
op|'['
name|'cells_utils'
op|'.'
name|'ServiceProxy'
op|'('
name|'obj'
op|','
name|'_CELL_PATH'
op|')'
nl|'\n'
name|'for'
name|'obj'
name|'in'
name|'TEST_SERVICES'
op|']'
newline|'\n'
nl|'\n'
DECL|variable|TEST_SERVERS
name|'TEST_SERVERS'
op|'='
op|'['
name|'dict'
op|'('
name|'server'
op|','
nl|'\n'
DECL|variable|host
name|'host'
op|'='
name|'cells_utils'
op|'.'
name|'cell_with_item'
op|'('
name|'_CELL_PATH'
op|','
nl|'\n'
name|'server'
op|'['
string|"'host'"
op|']'
op|')'
op|')'
nl|'\n'
name|'for'
name|'server'
name|'in'
name|'TEST_SERVERS'
op|']'
newline|'\n'
nl|'\n'
DECL|variable|DETAIL_HYPERS_DICTS
name|'DETAIL_HYPERS_DICTS'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'HypervisorsTestV21'
op|'.'
name|'DETAIL_HYPERS_DICTS'
op|')'
newline|'\n'
DECL|variable|DETAIL_HYPERS_DICTS
name|'DETAIL_HYPERS_DICTS'
op|'='
op|'['
name|'dict'
op|'('
name|'hyp'
op|','
name|'id'
op|'='
name|'cells_utils'
op|'.'
name|'cell_with_item'
op|'('
name|'_CELL_PATH'
op|','
nl|'\n'
name|'hyp'
op|'['
string|"'id'"
op|']'
op|')'
op|','
nl|'\n'
DECL|variable|service
name|'service'
op|'='
name|'dict'
op|'('
name|'hyp'
op|'['
string|"'service'"
op|']'
op|','
nl|'\n'
DECL|variable|id
name|'id'
op|'='
name|'cells_utils'
op|'.'
name|'cell_with_item'
op|'('
nl|'\n'
name|'_CELL_PATH'
op|','
nl|'\n'
name|'hyp'
op|'['
string|"'service'"
op|']'
op|'['
string|"'id'"
op|']'
op|')'
op|','
nl|'\n'
DECL|variable|host
name|'host'
op|'='
name|'cells_utils'
op|'.'
name|'cell_with_item'
op|'('
nl|'\n'
name|'_CELL_PATH'
op|','
nl|'\n'
name|'hyp'
op|'['
string|"'service'"
op|']'
op|'['
string|"'host'"
op|']'
op|')'
op|')'
op|')'
nl|'\n'
name|'for'
name|'hyp'
name|'in'
name|'DETAIL_HYPERS_DICTS'
op|']'
newline|'\n'
nl|'\n'
DECL|variable|INDEX_HYPER_DICTS
name|'INDEX_HYPER_DICTS'
op|'='
name|'copy'
op|'.'
name|'deepcopy'
op|'('
name|'HypervisorsTestV21'
op|'.'
name|'INDEX_HYPER_DICTS'
op|')'
newline|'\n'
DECL|variable|INDEX_HYPER_DICTS
name|'INDEX_HYPER_DICTS'
op|'='
op|'['
name|'dict'
op|'('
name|'hyp'
op|','
name|'id'
op|'='
name|'cells_utils'
op|'.'
name|'cell_with_item'
op|'('
name|'_CELL_PATH'
op|','
nl|'\n'
name|'hyp'
op|'['
string|"'id'"
op|']'
op|')'
op|')'
nl|'\n'
name|'for'
name|'hyp'
name|'in'
name|'INDEX_HYPER_DICTS'
op|']'
newline|'\n'
nl|'\n'
op|'@'
name|'classmethod'
newline|'\n'
DECL|member|fake_compute_node_get_all
name|'def'
name|'fake_compute_node_get_all'
op|'('
name|'cls'
op|','
name|'context'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'return'
name|'cls'
op|'.'
name|'TEST_HYPERS_OBJ'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'classmethod'
newline|'\n'
DECL|member|fake_compute_node_search_by_hypervisor
name|'def'
name|'fake_compute_node_search_by_hypervisor'
op|'('
name|'cls'
op|','
name|'context'
op|','
name|'hypervisor_re'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'return'
name|'cls'
op|'.'
name|'TEST_HYPERS_OBJ'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'classmethod'
newline|'\n'
DECL|member|fake_compute_node_get
name|'def'
name|'fake_compute_node_get'
op|'('
name|'cls'
op|','
name|'context'
op|','
name|'compute_id'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'for'
name|'hyper'
name|'in'
name|'cls'
op|'.'
name|'TEST_HYPERS_OBJ'
op|':'
newline|'\n'
indent|'            '
name|'if'
name|'hyper'
op|'.'
name|'id'
op|'=='
name|'compute_id'
op|':'
newline|'\n'
indent|'                '
name|'return'
name|'hyper'
newline|'\n'
dedent|''
dedent|''
name|'raise'
name|'exception'
op|'.'
name|'ComputeHostNotFound'
op|'('
name|'host'
op|'='
name|'compute_id'
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'classmethod'
newline|'\n'
DECL|member|fake_service_get_by_compute_host
name|'def'
name|'fake_service_get_by_compute_host'
op|'('
name|'cls'
op|','
name|'context'
op|','
name|'host'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'for'
name|'service'
name|'in'
name|'cls'
op|'.'
name|'TEST_SERVICES'
op|':'
newline|'\n'
indent|'            '
name|'if'
name|'service'
op|'.'
name|'host'
op|'=='
name|'host'
op|':'
newline|'\n'
indent|'                '
name|'return'
name|'service'
newline|'\n'
nl|'\n'
dedent|''
dedent|''
dedent|''
op|'@'
name|'classmethod'
newline|'\n'
DECL|member|fake_instance_get_all_by_host
name|'def'
name|'fake_instance_get_all_by_host'
op|'('
name|'cls'
op|','
name|'context'
op|','
name|'host'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'results'
op|'='
op|'['
op|']'
newline|'\n'
name|'for'
name|'inst'
name|'in'
name|'cls'
op|'.'
name|'TEST_SERVERS'
op|':'
newline|'\n'
indent|'            '
name|'if'
name|'inst'
op|'['
string|"'host'"
op|']'
op|'=='
name|'host'
op|':'
newline|'\n'
indent|'                '
name|'results'
op|'.'
name|'append'
op|'('
name|'inst'
op|')'
newline|'\n'
dedent|''
dedent|''
name|'return'
name|'results'
newline|'\n'
nl|'\n'
DECL|member|setUp
dedent|''
name|'def'
name|'setUp'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
nl|'\n'
indent|'        '
name|'self'
op|'.'
name|'flags'
op|'('
name|'enable'
op|'='
name|'True'
op|','
name|'cell_type'
op|'='
string|"'api'"
op|','
name|'group'
op|'='
string|"'cells'"
op|')'
newline|'\n'
nl|'\n'
name|'super'
op|'('
name|'CellHypervisorsTestV21'
op|','
name|'self'
op|')'
op|'.'
name|'setUp'
op|'('
op|')'
newline|'\n'
nl|'\n'
name|'self'
op|'.'
name|'stubs'
op|'.'
name|'Set'
op|'('
name|'self'
op|'.'
name|'controller'
op|'.'
name|'host_api'
op|','
string|"'compute_node_get_all'"
op|','
nl|'\n'
name|'self'
op|'.'
name|'fake_compute_node_get_all'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'stubs'
op|'.'
name|'Set'
op|'('
name|'self'
op|'.'
name|'controller'
op|'.'
name|'host_api'
op|','
string|"'service_get_by_compute_host'"
op|','
nl|'\n'
name|'self'
op|'.'
name|'fake_service_get_by_compute_host'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'stubs'
op|'.'
name|'Set'
op|'('
name|'self'
op|'.'
name|'controller'
op|'.'
name|'host_api'
op|','
nl|'\n'
string|"'compute_node_search_by_hypervisor'"
op|','
nl|'\n'
name|'self'
op|'.'
name|'fake_compute_node_search_by_hypervisor'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'stubs'
op|'.'
name|'Set'
op|'('
name|'self'
op|'.'
name|'controller'
op|'.'
name|'host_api'
op|','
string|"'compute_node_get'"
op|','
nl|'\n'
name|'self'
op|'.'
name|'fake_compute_node_get'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'stubs'
op|'.'
name|'Set'
op|'('
name|'self'
op|'.'
name|'controller'
op|'.'
name|'host_api'
op|','
string|"'compute_node_statistics'"
op|','
nl|'\n'
name|'fake_compute_node_statistics'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'stubs'
op|'.'
name|'Set'
op|'('
name|'self'
op|'.'
name|'controller'
op|'.'
name|'host_api'
op|','
string|"'instance_get_all_by_host'"
op|','
nl|'\n'
name|'self'
op|'.'
name|'fake_instance_get_all_by_host'
op|')'
newline|'\n'
dedent|''
dedent|''
endmarker|''
end_unit
