~thomir-deactivatedaccount/autopkgtest-result-checker/snappy-proposed-migration-add-missing-payload-keys

« back to all changes in this revision

Viewing changes to core_result_checker/__init__.py

  • Committer: Thomi Richards
  • Date: 2015-04-06 23:23:22 UTC
  • mto: This revision was merged to the branch mainline in revision 11.
  • Revision ID: thomi.richards@canonical.com-20150406232322-2ceoij84e321zkx6
Check success of swift post operation, and log error as appropriate.

Show diffs side-by-side

added added

removed removed

Lines of Context:
59
59
        )
60
60
        try:
61
61
            self.swift_publisher.make_container_public(container_name)
62
 
        except Exception as e:
 
62
        except RuntimeError as e:
63
63
            logger.error(
64
64
                "Unable to publish swift container '%s'. Error: %s.",
65
65
                container_name,
104
104
        self.config = nova_config
105
105
 
106
106
    def make_container_public(self, container_name):
 
107
        """Make a swift contianer public.
 
108
 
 
109
        Raises RuntimeError on failure, returns None otherwise.
 
110
 
 
111
        """
107
112
        swift = SwiftService(self.config)
108
 
        swift.post(
 
113
        result = swift.post(
109
114
            container=container_name,
110
115
            options=dict(read_acl='.r:*')
111
116
        )
112
 
        return True
 
117
        if not result['success']:
 
118
            raise RuntimeError(
 
119
                "Unable to make swift container '%s' public: %s" % (
 
120
                    container_name,
 
121
                    result['error']
 
122
                )
 
123
            )
113
124
 
114
125
 
115
126
def main():