def ensure(self):
        self.clear_cache()
        to_ensure = dict(self)

        try:
            # PATCH instead of POST
            if self.exists() and self.resource_name != 'interfaces':
                self.logger.debug('[%s] Patching', self.identifier)
                to_ensure['id'] = self.existing_resource()['id']
                self.resource.patch([to_ensure])
                self.logger.info('[%s] has been patched!', self.identifier)
                self.clear_cache()
                return True

            else:  # POST for initially creating
                self.logger.debug('[%s] Creating', self.identifier)
                self.resource.post([to_ensure])
                self.logger.info('[%s] has been created!', self.identifier)
                return True
        except Exception as e:
            self.log_error(e)
            self.clear_cache()
            return False
Ensure object in current state exists in NSoT
dataset/ETHPy150Open dropbox/pynsot/pynsot/models.py/Resource.ensure