

class CloudConfig(object):
    def __init__(self, name, region, config):
        self.name = name
        self.region = region
        self.config = config

    def __getattr__(self, key):
        """Return arbitrary attributes."""

        if key.startswith('os_'):
            key = key[3:]

        if key in [attr.replace('-', '_') for attr in self.config]:
            return self.config[key]
        else:
            return None

    def __iter__(self):
        return self.config.__iter__()



class CloudConfig(object):
    def __init__(self, name, region, config):
        self.name = name
        self.region = region
        self.config = config

    def __getattr__(self, key):
        """Return arbitrary attributes."""

        if key.startswith('os_'):
            key = key[3:]

        if key in [attr.replace('-', '_') for attr in self.config]:
            return self.config[key]
        else:
            return None

    def __iter__(self):
        return self.config.__iter__()

    def __eq__(self, other):
        return (self.name == other.name and self.region == other.region
                and self.config == other.config)

Add an equality method for CloudConfig
Add an equality method for CloudConfig

In order to track if a config has changed, we need to be able to compare
the CloudConfig objects for equality.

Change-Id: Icdd9acede81bc5fba60d877194048e24a62c9e5d

  
  
  class CloudConfig(object):
      def __init__(self, name, region, config):
          self.name = name
          self.region = region
          self.config = config
  
      def __getattr__(self, key):
          """Return arbitrary attributes."""
  
          if key.startswith('os_'):
              key = key[3:]
  
          if key in [attr.replace('-', '_') for attr in self.config]:
              return self.config[key]
          else:
              return None
  
      def __iter__(self):
          return self.config.__iter__()
  
+     def __eq__(self, other):
+         return (self.name == other.name and self.region == other.region
+                 and self.config == other.config)
+ 
Add an equality method for CloudConfig
## Code Before:


class CloudConfig(object):
    def __init__(self, name, region, config):
        self.name = name
        self.region = region
        self.config = config

    def __getattr__(self, key):
        """Return arbitrary attributes."""

        if key.startswith('os_'):
            key = key[3:]

        if key in [attr.replace('-', '_') for attr in self.config]:
            return self.config[key]
        else:
            return None

    def __iter__(self):
        return self.config.__iter__()

## Instruction:
Add an equality method for CloudConfig
## Code After:


class CloudConfig(object):
    def __init__(self, name, region, config):
        self.name = name
        self.region = region
        self.config = config

    def __getattr__(self, key):
        """Return arbitrary attributes."""

        if key.startswith('os_'):
            key = key[3:]

        if key in [attr.replace('-', '_') for attr in self.config]:
            return self.config[key]
        else:
            return None

    def __iter__(self):
        return self.config.__iter__()

    def __eq__(self, other):
        return (self.name == other.name and self.region == other.region
                and self.config == other.config)
