From 58f8fd6d960b679e8a16e3935d655298203eb168 Mon Sep 17 00:00:00 2001 From: Abhishek Chanda Date: Tue, 7 Oct 2014 23:06:36 -0700 Subject: [PATCH] Use new style classes everywhere Old style classes has been deprecated and should not be used anymore https://docs.python.org/2/reference/datamodel.html#new-style-and-classic-classes Change-Id: I8f85f5a63af7c6500d6efcde5efe8a1fd1456ff0 Closes-Bug: #1378021 --- sahara/api/middleware/auth_valid.py | 2 +- sahara/plugins/hdp/ambariplugin.py | 2 +- sahara/plugins/hdp/clusterspec.py | 18 +++++++++--------- sahara/plugins/hdp/configprovider.py | 2 +- sahara/plugins/hdp/hadoopserver.py | 4 ++-- .../hdp/versions/abstractversionhandler.py | 2 +- .../versions/version_1_3_2/versionhandler.py | 2 +- .../versions/version_2_0_6/versionhandler.py | 2 +- .../hdp/versions/versionhandlerfactory.py | 2 +- .../plugins/vanilla/abstractversionhandler.py | 2 +- sahara/plugins/vanilla/versionfactory.py | 2 +- sahara/service/engine.py | 2 +- sahara/tests/integration/configs/config.py | 2 +- sahara/tests/unit/plugins/hdp/hdp_test_base.py | 16 ++++++++-------- .../unit/plugins/hdp/test_ambariplugin.py | 2 +- .../tests/unit/plugins/hdp/test_clusterspec.py | 4 ++-- .../unit/plugins/hdp/test_clusterspec_hdp2.py | 4 ++-- .../plugins/vanilla/hadoop2/test_configs.py | 2 +- sahara/tests/unit/service/test_ops.py | 4 ++-- sahara/tests/unit/service/test_volumes.py | 2 +- sahara/tests/unit/service/validation/utils.py | 4 ++-- sahara/tests/unit/utils/test_heat.py | 2 +- sahara/tests/unit/utils/test_neutron.py | 2 +- sahara/utils/openstack/neutron.py | 4 ++-- 24 files changed, 45 insertions(+), 45 deletions(-) diff --git a/sahara/api/middleware/auth_valid.py b/sahara/api/middleware/auth_valid.py index 3420b939..d54a7245 100644 --- a/sahara/api/middleware/auth_valid.py +++ b/sahara/api/middleware/auth_valid.py @@ -25,7 +25,7 @@ import sahara.openstack.commons as commons LOG = logging.getLogger(__name__) -class AuthValidator: +class AuthValidator(object): """Handles token auth results and tenants.""" def __init__(self, app): diff --git a/sahara/plugins/hdp/ambariplugin.py b/sahara/plugins/hdp/ambariplugin.py index e7351e4a..aa929ec2 100644 --- a/sahara/plugins/hdp/ambariplugin.py +++ b/sahara/plugins/hdp/ambariplugin.py @@ -363,7 +363,7 @@ class AmbariPlugin(p.ProvisioningPluginBase): server.configure_topology(topology_str) -class AmbariInfo(): +class AmbariInfo(object): def __init__(self, host, port, user, password): self.host = host self.port = port diff --git a/sahara/plugins/hdp/clusterspec.py b/sahara/plugins/hdp/clusterspec.py index 280fd9d8..9db63646 100644 --- a/sahara/plugins/hdp/clusterspec.py +++ b/sahara/plugins/hdp/clusterspec.py @@ -24,7 +24,7 @@ from sahara.plugins.hdp.versions import versionhandlerfactory as vhf LOG = logging.getLogger(__name__) -class ClusterSpec(): +class ClusterSpec(object): def __init__(self, config, version='1.3.2'): self._config_template = config self.services = [] @@ -215,14 +215,14 @@ class ClusterSpec(): config_map[user_input.config.name] = user_input.value -class Component(): +class Component(object): def __init__(self, name, component_type, cardinality): self.name = name self.type = component_type self.cardinality = cardinality -class NodeGroup(): +class NodeGroup(object): def __init__(self, name): self.id = None self.name = name @@ -240,14 +240,14 @@ class NodeGroup(): return self.ng_storage_paths -class User(): +class User(object): def __init__(self, name, password, groups): self.name = name self.password = password self.groups = groups -class Instance(): +class Instance(object): def __init__(self, sahara_instance): self.inst_fqdn = sahara_instance.fqdn() self.management_ip = sahara_instance.management_ip @@ -267,7 +267,7 @@ class Instance(): return self.fqdn() == other.fqdn() -class NormalizedClusterConfig(): +class NormalizedClusterConfig(object): def __init__(self, cluster_spec): self.hadoop_version = cluster_spec.version self.cluster_configs = [] @@ -319,7 +319,7 @@ class NormalizedClusterConfig(): {"property": prop, "value": value}) -class NormalizedConfig(): +class NormalizedConfig(object): def __init__(self, name, config_type, default_value, target, scope): self.name = name self.description = None @@ -330,13 +330,13 @@ class NormalizedConfig(): self.scope = scope -class NormalizedConfigEntry(): +class NormalizedConfigEntry(object): def __init__(self, config, value): self.config = config self.value = value -class NormalizedNodeGroup(): +class NormalizedNodeGroup(object): def __init__(self, node_group): self.name = node_group.name self.node_processes = node_group.components diff --git a/sahara/plugins/hdp/configprovider.py b/sahara/plugins/hdp/configprovider.py index 3d40b9f5..25c16554 100644 --- a/sahara/plugins/hdp/configprovider.py +++ b/sahara/plugins/hdp/configprovider.py @@ -18,7 +18,7 @@ from sahara.i18n import _ from sahara.plugins import provisioning as p -class ConfigurationProvider: +class ConfigurationProvider(object): def __init__(self, config): self.config = config self.config_mapper = {} diff --git a/sahara/plugins/hdp/hadoopserver.py b/sahara/plugins/hdp/hadoopserver.py index 51de53da..5edae16b 100644 --- a/sahara/plugins/hdp/hadoopserver.py +++ b/sahara/plugins/hdp/hadoopserver.py @@ -37,7 +37,7 @@ HADOOP_SWIFT_LOCAL_RPM = ('/opt/hdp-local-repos/hadoop-swift/' LOG = logging.getLogger(__name__) -class HadoopServer: +class HadoopServer(object): _master_ip = None def __init__(self, instance, node_group, ambari_rpm=None): @@ -211,7 +211,7 @@ class HadoopServer: return self._is_component_available('GANGLIA_MONITOR') -class DefaultPromptMatcher(): +class DefaultPromptMatcher(object): prompt_pattern = re.compile('(.*\()(.)(\)\?\s*$)', re.DOTALL) def __init__(self, terminal_token): diff --git a/sahara/plugins/hdp/versions/abstractversionhandler.py b/sahara/plugins/hdp/versions/abstractversionhandler.py index 00494719..539a6d63 100644 --- a/sahara/plugins/hdp/versions/abstractversionhandler.py +++ b/sahara/plugins/hdp/versions/abstractversionhandler.py @@ -19,7 +19,7 @@ import six @six.add_metaclass(abc.ABCMeta) -class AbstractVersionHandler(): +class AbstractVersionHandler(object): @abc.abstractmethod def get_config_items(self): diff --git a/sahara/plugins/hdp/versions/version_1_3_2/versionhandler.py b/sahara/plugins/hdp/versions/version_1_3_2/versionhandler.py index af07c2e9..04d02c9f 100644 --- a/sahara/plugins/hdp/versions/version_1_3_2/versionhandler.py +++ b/sahara/plugins/hdp/versions/version_1_3_2/versionhandler.py @@ -126,7 +126,7 @@ class VersionHandler(avm.AbstractVersionHandler): return None -class AmbariClient(): +class AmbariClient(object): def __init__(self, handler): # add an argument for neutron discovery diff --git a/sahara/plugins/hdp/versions/version_2_0_6/versionhandler.py b/sahara/plugins/hdp/versions/version_2_0_6/versionhandler.py index b925d740..078bc4d3 100644 --- a/sahara/plugins/hdp/versions/version_2_0_6/versionhandler.py +++ b/sahara/plugins/hdp/versions/version_2_0_6/versionhandler.py @@ -114,7 +114,7 @@ class VersionHandler(avm.AbstractVersionHandler): return None -class AmbariClient(): +class AmbariClient(object): def __init__(self, handler): # add an argument for neutron discovery diff --git a/sahara/plugins/hdp/versions/versionhandlerfactory.py b/sahara/plugins/hdp/versions/versionhandlerfactory.py index 2654457d..42572f01 100644 --- a/sahara/plugins/hdp/versions/versionhandlerfactory.py +++ b/sahara/plugins/hdp/versions/versionhandlerfactory.py @@ -18,7 +18,7 @@ import os from sahara.utils import general -class VersionHandlerFactory(): +class VersionHandlerFactory(object): versions = None modules = None initialized = False diff --git a/sahara/plugins/vanilla/abstractversionhandler.py b/sahara/plugins/vanilla/abstractversionhandler.py index b691cde5..4e022c08 100644 --- a/sahara/plugins/vanilla/abstractversionhandler.py +++ b/sahara/plugins/vanilla/abstractversionhandler.py @@ -19,7 +19,7 @@ import six @six.add_metaclass(abc.ABCMeta) -class AbstractVersionHandler(): +class AbstractVersionHandler(object): @abc.abstractmethod def get_node_processes(self): diff --git a/sahara/plugins/vanilla/versionfactory.py b/sahara/plugins/vanilla/versionfactory.py index fbd64d0d..6532b8b0 100644 --- a/sahara/plugins/vanilla/versionfactory.py +++ b/sahara/plugins/vanilla/versionfactory.py @@ -19,7 +19,7 @@ import re from sahara.utils import general -class VersionFactory(): +class VersionFactory(object): versions = None modules = None initialized = False diff --git a/sahara/service/engine.py b/sahara/service/engine.py index e6fa53b1..6d9faeca 100644 --- a/sahara/service/engine.py +++ b/sahara/service/engine.py @@ -37,7 +37,7 @@ conductor = c.API @six.add_metaclass(abc.ABCMeta) -class Engine: +class Engine(object): @abc.abstractmethod def create_cluster(self, cluster): pass diff --git a/sahara/tests/integration/configs/config.py b/sahara/tests/integration/configs/config.py index a7e947f4..754caaef 100644 --- a/sahara/tests/integration/configs/config.py +++ b/sahara/tests/integration/configs/config.py @@ -616,7 +616,7 @@ def register_config(config, config_group, config_opts): @singleton -class ITConfig: +class ITConfig(object): def __init__(self): config = 'itest.conf' config_files = [] diff --git a/sahara/tests/unit/plugins/hdp/hdp_test_base.py b/sahara/tests/unit/plugins/hdp/hdp_test_base.py index fd8afa01..f01f4b7c 100644 --- a/sahara/tests/unit/plugins/hdp/hdp_test_base.py +++ b/sahara/tests/unit/plugins/hdp/hdp_test_base.py @@ -19,7 +19,7 @@ from sahara.plugins.hdp import clusterspec as cs from sahara import version -class TestServer: +class TestServer(object): def __init__(self, hostname, role, img, flavor, public_ip, private_ip): self.inst_fqdn = hostname self.role = role @@ -51,7 +51,7 @@ def create_clusterspec(hdp_version='1.3.2'): return cs.ClusterSpec(cluster_config_file, version=hdp_version) -class InstanceInfo: +class InstanceInfo(object): def __init__(self, hostname, image, flavor, management_ip, internal_ip): self.image = image self.flavor = flavor @@ -59,7 +59,7 @@ class InstanceInfo: self.internal_ip = internal_ip -class TestCluster(): +class TestCluster(object): def __init__(self, node_groups): self.plugin_name = 'hdp' self.hadoop_version = None @@ -68,7 +68,7 @@ class TestCluster(): self.default_image_id = '11111' -class TestNodeGroup: +class TestNodeGroup(object): def __init__(self, name, instances, node_processes, count=1): self.name = name self.instances = instances @@ -84,14 +84,14 @@ class TestNodeGroup: return self.ng_storage_paths -class TestUserInputConfig: +class TestUserInputConfig(object): def __init__(self, tag, target, name): self.tag = tag self.applicable_target = target self.name = name -class TestRequest: +class TestRequest(object): def put(self, url, data=None, auth=None, headers=None): self.url = url self.data = data @@ -120,13 +120,13 @@ class TestRequest: return TestResult(200) -class TestResult: +class TestResult(object): def __init__(self, status): self.status_code = status self.text = '' -class TestUserInput: +class TestUserInput(object): def __init__(self, config, value): self.config = config self.value = value diff --git a/sahara/tests/unit/plugins/hdp/test_ambariplugin.py b/sahara/tests/unit/plugins/hdp/test_ambariplugin.py index 95b7ebd5..9b35db8f 100644 --- a/sahara/tests/unit/plugins/hdp/test_ambariplugin.py +++ b/sahara/tests/unit/plugins/hdp/test_ambariplugin.py @@ -347,7 +347,7 @@ class AmbariPluginTest(sahara_base.SaharaTestCase): return request -class TestHost: +class TestHost(object): def __init__(self, management_ip, role=None): self.management_ip = management_ip self.role = role diff --git a/sahara/tests/unit/plugins/hdp/test_clusterspec.py b/sahara/tests/unit/plugins/hdp/test_clusterspec.py index 4a6b2eef..78cc3129 100644 --- a/sahara/tests/unit/plugins/hdp/test_clusterspec.py +++ b/sahara/tests/unit/plugins/hdp/test_clusterspec.py @@ -1534,7 +1534,7 @@ class ClusterSpecTest(sahara_base.SaharaTestCase): self.assertIn('hbase-site', configurations) -class TestNodeGroup: +class TestNodeGroup(object): def __init__(self, name, instances, node_processes, count=1): self.name = name self.instances = instances @@ -1548,7 +1548,7 @@ class TestNodeGroup: return [''] -class TestUserInputConfig: +class TestUserInputConfig(object): def __init__(self, tag, target, name): self.tag = tag self.applicable_target = target diff --git a/sahara/tests/unit/plugins/hdp/test_clusterspec_hdp2.py b/sahara/tests/unit/plugins/hdp/test_clusterspec_hdp2.py index c5e864a4..2000da9b 100644 --- a/sahara/tests/unit/plugins/hdp/test_clusterspec_hdp2.py +++ b/sahara/tests/unit/plugins/hdp/test_clusterspec_hdp2.py @@ -1918,7 +1918,7 @@ class ClusterSpecTestForHDP2(sahara_base.SaharaTestCase): self.assertIn('hue-oozie-site', configurations) -class TestNodeGroup: +class TestNodeGroup(object): def __init__(self, name, instances, node_processes, count=1): self.name = name self.instances = instances @@ -1932,7 +1932,7 @@ class TestNodeGroup: return [''] -class TestUserInputConfig: +class TestUserInputConfig(object): def __init__(self, tag, target, name): self.tag = tag self.applicable_target = target diff --git a/sahara/tests/unit/plugins/vanilla/hadoop2/test_configs.py b/sahara/tests/unit/plugins/vanilla/hadoop2/test_configs.py index 8ed53cd8..30c27a03 100644 --- a/sahara/tests/unit/plugins/vanilla/hadoop2/test_configs.py +++ b/sahara/tests/unit/plugins/vanilla/hadoop2/test_configs.py @@ -63,7 +63,7 @@ class VanillaTwoConfigTestCase(base.SaharaTestCase): self.assertEqual(res, expected) -class FakeNG(): +class FakeNG(object): def __init__(self, storage_paths=None): self.paths = storage_paths diff --git a/sahara/tests/unit/service/test_ops.py b/sahara/tests/unit/service/test_ops.py index 76e40507..be7c027d 100644 --- a/sahara/tests/unit/service/test_ops.py +++ b/sahara/tests/unit/service/test_ops.py @@ -20,7 +20,7 @@ from sahara.service import ops from sahara.tests.unit import base -class FakeNodeGroup(): +class FakeNodeGroup(object): id = 'id' count = 2 instances = [1, 2] @@ -51,7 +51,7 @@ class FakePlugin(mock.Mock): TestOPS.SEQUENCE.append('cluster_destroy') -class FakeINFRA(): +class FakeINFRA(object): def create_cluster(self, cluster): TestOPS.SEQUENCE.append('create_cluster') diff --git a/sahara/tests/unit/service/test_volumes.py b/sahara/tests/unit/service/test_volumes.py index f205c4e7..0b894381 100644 --- a/sahara/tests/unit/service/test_volumes.py +++ b/sahara/tests/unit/service/test_volumes.py @@ -45,7 +45,7 @@ class TestAttachVolume(base.SaharaWithDbTestCase): @mock.patch('cinderclient.v1.volumes.Volume.detach') @mock.patch('sahara.utils.openstack.cinder.get_volume') def test_detach_volumes(self, p_get_volume, p_detach, p_delete, p_cond): - class Instance: + class Instance(object): def __init__(self): self.instance_id = '123454321' self.volumes = [123] diff --git a/sahara/tests/unit/service/validation/utils.py b/sahara/tests/unit/service/validation/utils.py index ab289268..57f72edb 100644 --- a/sahara/tests/unit/service/validation/utils.py +++ b/sahara/tests/unit/service/validation/utils.py @@ -160,7 +160,7 @@ def start_patch(patch_templates=True): heat = heat_p.start() heat().stacks.list.side_effect = _get_heat_stack_list - class Service: + class Service(object): @property def name(self): return 'cinder' @@ -170,7 +170,7 @@ def start_patch(patch_templates=True): keystone().services.list.side_effect = _services_list - class Image: + class Image(object): def __init__(self, name='test'): self.name = name diff --git a/sahara/tests/unit/utils/test_heat.py b/sahara/tests/unit/utils/test_heat.py index d0dd0f73..788d4ea2 100644 --- a/sahara/tests/unit/utils/test_heat.py +++ b/sahara/tests/unit/utils/test_heat.py @@ -230,7 +230,7 @@ class TestClusterStack(testtools.TestCase): h.wait_stack_completion(stack) -class FakeHeatStack(): +class FakeHeatStack(object): def __init__(self, stack_status=None, new_status=None, stack_name=None): self.stack_status = stack_status or '' self.new_status = new_status or '' diff --git a/sahara/tests/unit/utils/test_neutron.py b/sahara/tests/unit/utils/test_neutron.py index 3aafed7b..33683c00 100644 --- a/sahara/tests/unit/utils/test_neutron.py +++ b/sahara/tests/unit/utils/test_neutron.py @@ -33,7 +33,7 @@ def _test_get_neutron_client(api_version, *args, **kwargs): return FakeNeutronClient() -class FakeNeutronClient(): +class FakeNeutronClient(object): def list_routers(self): return {"routers": [{"status": "ACTIVE", "external_gateway_info": { "network_id": "61f95d3f-495e-4409-8c29-0b806283c81e"}, diff --git a/sahara/utils/openstack/neutron.py b/sahara/utils/openstack/neutron.py index 91ccd2db..49e94ac4 100644 --- a/sahara/utils/openstack/neutron.py +++ b/sahara/utils/openstack/neutron.py @@ -43,7 +43,7 @@ def client(): return neutron_cli.Client('2.0', **args) -class NeutronClientRemoteWrapper(): +class NeutronClientRemoteWrapper(object): neutron = None adapters = {} routers = {} @@ -155,7 +155,7 @@ class NeutronHttpAdapter(adapters.HTTPAdapter): return NetcatSocket(self.cmd) -class NetcatSocket: +class NetcatSocket(object): def _create_process(self): self.process = e_subprocess.Popen(self.cmd,