Convert vmwareapi code to UNIX style line endings
It's the only code in the codebase using evil CRLF line endings. Change-Id: I8b1a2b12a5707fbd4d32588c081599beaa34aca5
This commit is contained in:
@@ -1,21 +1,21 @@
|
|||||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
|
|
||||||
# Copyright (c) 2011 Citrix Systems, Inc.
|
# Copyright (c) 2011 Citrix Systems, Inc.
|
||||||
# Copyright 2011 OpenStack LLC.
|
# Copyright 2011 OpenStack LLC.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
# not use this file except in compliance with the License. You may obtain
|
# not use this file except in compliance with the License. You may obtain
|
||||||
# a copy of the License at
|
# a copy of the License at
|
||||||
#
|
#
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
#
|
#
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
:mod:`vmwareapi` -- Stubs for VMware API
|
:mod:`vmwareapi` -- Stubs for VMware API
|
||||||
=======================================
|
=======================================
|
||||||
"""
|
"""
|
||||||
|
@@ -1,109 +1,109 @@
|
|||||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
|
|
||||||
# Copyright (c) 2011 Citrix Systems, Inc.
|
# Copyright (c) 2011 Citrix Systems, Inc.
|
||||||
# Copyright 2011 OpenStack LLC.
|
# Copyright 2011 OpenStack LLC.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
# not use this file except in compliance with the License. You may obtain
|
# not use this file except in compliance with the License. You may obtain
|
||||||
# a copy of the License at
|
# a copy of the License at
|
||||||
#
|
#
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
#
|
#
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Stubouts, mocks and fixtures for the test suite
|
Stubouts, mocks and fixtures for the test suite
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from nova import db
|
from nova import db
|
||||||
from nova import utils
|
from nova import utils
|
||||||
from nova.compute import task_states
|
from nova.compute import task_states
|
||||||
from nova.compute import vm_states
|
from nova.compute import vm_states
|
||||||
|
|
||||||
|
|
||||||
def stub_out_db_instance_api(stubs):
|
def stub_out_db_instance_api(stubs):
|
||||||
"""Stubs out the db API for creating Instances."""
|
"""Stubs out the db API for creating Instances."""
|
||||||
|
|
||||||
INSTANCE_TYPES = {
|
INSTANCE_TYPES = {
|
||||||
'm1.tiny': dict(memory_mb=512, vcpus=1, root_gb=0, flavorid=1),
|
'm1.tiny': dict(memory_mb=512, vcpus=1, root_gb=0, flavorid=1),
|
||||||
'm1.small': dict(memory_mb=2048, vcpus=1, root_gb=20, flavorid=2),
|
'm1.small': dict(memory_mb=2048, vcpus=1, root_gb=20, flavorid=2),
|
||||||
'm1.medium':
|
'm1.medium':
|
||||||
dict(memory_mb=4096, vcpus=2, root_gb=40, flavorid=3),
|
dict(memory_mb=4096, vcpus=2, root_gb=40, flavorid=3),
|
||||||
'm1.large': dict(memory_mb=8192, vcpus=4, root_gb=80, flavorid=4),
|
'm1.large': dict(memory_mb=8192, vcpus=4, root_gb=80, flavorid=4),
|
||||||
'm1.xlarge':
|
'm1.xlarge':
|
||||||
dict(memory_mb=16384, vcpus=8, root_gb=160, flavorid=5)}
|
dict(memory_mb=16384, vcpus=8, root_gb=160, flavorid=5)}
|
||||||
|
|
||||||
class FakeModel(object):
|
class FakeModel(object):
|
||||||
"""Stubs out for model."""
|
"""Stubs out for model."""
|
||||||
|
|
||||||
def __init__(self, values):
|
def __init__(self, values):
|
||||||
self.values = values
|
self.values = values
|
||||||
|
|
||||||
def __getattr__(self, name):
|
def __getattr__(self, name):
|
||||||
return self.values[name]
|
return self.values[name]
|
||||||
|
|
||||||
def __getitem__(self, key):
|
def __getitem__(self, key):
|
||||||
if key in self.values:
|
if key in self.values:
|
||||||
return self.values[key]
|
return self.values[key]
|
||||||
else:
|
else:
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
def fake_instance_create(context, values):
|
def fake_instance_create(context, values):
|
||||||
"""Stubs out the db.instance_create method."""
|
"""Stubs out the db.instance_create method."""
|
||||||
|
|
||||||
type_data = INSTANCE_TYPES[values['instance_type']]
|
type_data = INSTANCE_TYPES[values['instance_type']]
|
||||||
|
|
||||||
base_options = {
|
base_options = {
|
||||||
'name': values['name'],
|
'name': values['name'],
|
||||||
'id': values['id'],
|
'id': values['id'],
|
||||||
'uuid': utils.gen_uuid(),
|
'uuid': utils.gen_uuid(),
|
||||||
'reservation_id': utils.generate_uid('r'),
|
'reservation_id': utils.generate_uid('r'),
|
||||||
'image_ref': values['image_ref'],
|
'image_ref': values['image_ref'],
|
||||||
'kernel_id': values['kernel_id'],
|
'kernel_id': values['kernel_id'],
|
||||||
'ramdisk_id': values['ramdisk_id'],
|
'ramdisk_id': values['ramdisk_id'],
|
||||||
'vm_state': vm_states.BUILDING,
|
'vm_state': vm_states.BUILDING,
|
||||||
'task_state': task_states.SCHEDULING,
|
'task_state': task_states.SCHEDULING,
|
||||||
'user_id': values['user_id'],
|
'user_id': values['user_id'],
|
||||||
'project_id': values['project_id'],
|
'project_id': values['project_id'],
|
||||||
'launch_time': time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime()),
|
'launch_time': time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime()),
|
||||||
'instance_type': values['instance_type'],
|
'instance_type': values['instance_type'],
|
||||||
'memory_mb': type_data['memory_mb'],
|
'memory_mb': type_data['memory_mb'],
|
||||||
'vcpus': type_data['vcpus'],
|
'vcpus': type_data['vcpus'],
|
||||||
'mac_addresses': [{'address': values['mac_address']}],
|
'mac_addresses': [{'address': values['mac_address']}],
|
||||||
'root_gb': type_data['root_gb'],
|
'root_gb': type_data['root_gb'],
|
||||||
}
|
}
|
||||||
return FakeModel(base_options)
|
return FakeModel(base_options)
|
||||||
|
|
||||||
def fake_network_get_by_instance(context, instance_id):
|
def fake_network_get_by_instance(context, instance_id):
|
||||||
"""Stubs out the db.network_get_by_instance method."""
|
"""Stubs out the db.network_get_by_instance method."""
|
||||||
|
|
||||||
fields = {
|
fields = {
|
||||||
'bridge': 'vmnet0',
|
'bridge': 'vmnet0',
|
||||||
'netmask': '255.255.255.0',
|
'netmask': '255.255.255.0',
|
||||||
'gateway': '10.10.10.1',
|
'gateway': '10.10.10.1',
|
||||||
'broadcast': '10.10.10.255',
|
'broadcast': '10.10.10.255',
|
||||||
'dns1': 'fake',
|
'dns1': 'fake',
|
||||||
'vlan': 100}
|
'vlan': 100}
|
||||||
return FakeModel(fields)
|
return FakeModel(fields)
|
||||||
|
|
||||||
def fake_instance_action_create(context, action):
|
def fake_instance_action_create(context, action):
|
||||||
"""Stubs out the db.instance_action_create method."""
|
"""Stubs out the db.instance_action_create method."""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def fake_instance_type_get_all(context, inactive=0, filters=None):
|
def fake_instance_type_get_all(context, inactive=0, filters=None):
|
||||||
return INSTANCE_TYPES.values()
|
return INSTANCE_TYPES.values()
|
||||||
|
|
||||||
def fake_instance_type_get_by_name(context, name):
|
def fake_instance_type_get_by_name(context, name):
|
||||||
return INSTANCE_TYPES[name]
|
return INSTANCE_TYPES[name]
|
||||||
|
|
||||||
stubs.Set(db, 'instance_create', fake_instance_create)
|
stubs.Set(db, 'instance_create', fake_instance_create)
|
||||||
stubs.Set(db, 'network_get_by_instance', fake_network_get_by_instance)
|
stubs.Set(db, 'network_get_by_instance', fake_network_get_by_instance)
|
||||||
stubs.Set(db, 'instance_action_create', fake_instance_action_create)
|
stubs.Set(db, 'instance_action_create', fake_instance_action_create)
|
||||||
stubs.Set(db, 'instance_type_get_all', fake_instance_type_get_all)
|
stubs.Set(db, 'instance_type_get_all', fake_instance_type_get_all)
|
||||||
stubs.Set(db, 'instance_type_get_by_name', fake_instance_type_get_by_name)
|
stubs.Set(db, 'instance_type_get_by_name', fake_instance_type_get_by_name)
|
||||||
|
@@ -1,51 +1,51 @@
|
|||||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
|
|
||||||
# Copyright (c) 2011 Citrix Systems, Inc.
|
# Copyright (c) 2011 Citrix Systems, Inc.
|
||||||
# Copyright 2011 OpenStack LLC.
|
# Copyright 2011 OpenStack LLC.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
# not use this file except in compliance with the License. You may obtain
|
# not use this file except in compliance with the License. You may obtain
|
||||||
# a copy of the License at
|
# a copy of the License at
|
||||||
#
|
#
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
#
|
#
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Stubouts for the test suite
|
Stubouts for the test suite
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from nova.virt import vmwareapi_conn
|
from nova.virt import vmwareapi_conn
|
||||||
from nova.virt.vmwareapi import fake
|
from nova.virt.vmwareapi import fake
|
||||||
from nova.virt.vmwareapi import vmware_images
|
from nova.virt.vmwareapi import vmware_images
|
||||||
from nova.virt.vmwareapi import vmops
|
from nova.virt.vmwareapi import vmops
|
||||||
from nova.virt.vmwareapi import network_utils
|
from nova.virt.vmwareapi import network_utils
|
||||||
|
|
||||||
|
|
||||||
def fake_get_vim_object(arg):
|
def fake_get_vim_object(arg):
|
||||||
"""Stubs out the VMWareAPISession's get_vim_object method."""
|
"""Stubs out the VMWareAPISession's get_vim_object method."""
|
||||||
return fake.FakeVim()
|
return fake.FakeVim()
|
||||||
|
|
||||||
|
|
||||||
def fake_is_vim_object(arg, module):
|
def fake_is_vim_object(arg, module):
|
||||||
"""Stubs out the VMWareAPISession's is_vim_object method."""
|
"""Stubs out the VMWareAPISession's is_vim_object method."""
|
||||||
return isinstance(module, fake.FakeVim)
|
return isinstance(module, fake.FakeVim)
|
||||||
|
|
||||||
|
|
||||||
def set_stubs(stubs):
|
def set_stubs(stubs):
|
||||||
"""Set the stubs."""
|
"""Set the stubs."""
|
||||||
stubs.Set(vmops.VMWareVMOps, 'plug_vifs', fake.fake_plug_vifs)
|
stubs.Set(vmops.VMWareVMOps, 'plug_vifs', fake.fake_plug_vifs)
|
||||||
stubs.Set(network_utils, 'get_network_with_the_name',
|
stubs.Set(network_utils, 'get_network_with_the_name',
|
||||||
fake.fake_get_network)
|
fake.fake_get_network)
|
||||||
stubs.Set(vmware_images, 'fetch_image', fake.fake_fetch_image)
|
stubs.Set(vmware_images, 'fetch_image', fake.fake_fetch_image)
|
||||||
stubs.Set(vmware_images, 'get_vmdk_size_and_properties',
|
stubs.Set(vmware_images, 'get_vmdk_size_and_properties',
|
||||||
fake.fake_get_vmdk_size_and_properties)
|
fake.fake_get_vmdk_size_and_properties)
|
||||||
stubs.Set(vmware_images, 'upload_image', fake.fake_upload_image)
|
stubs.Set(vmware_images, 'upload_image', fake.fake_upload_image)
|
||||||
stubs.Set(vmwareapi_conn.VMWareAPISession, "_get_vim_object",
|
stubs.Set(vmwareapi_conn.VMWareAPISession, "_get_vim_object",
|
||||||
fake_get_vim_object)
|
fake_get_vim_object)
|
||||||
stubs.Set(vmwareapi_conn.VMWareAPISession, "_is_vim_object",
|
stubs.Set(vmwareapi_conn.VMWareAPISession, "_is_vim_object",
|
||||||
fake_is_vim_object)
|
fake_is_vim_object)
|
||||||
|
Reference in New Issue
Block a user