~go-bot/goose/trunk

« back to all changes in this revision

Viewing changes to swift/swift.go

  • Committer: Tarmac
  • Author(s): Patrick Sodre
  • Date: 2013-11-01 03:47:33 UTC
  • mfrom: (109.1.6 goose)
  • Revision ID: tarmac-20131101034733-zbirap24k6k8wjlg
[r=wallyworld],[bug=1209003],[bug=1246517] This is to fix bug #1209003 (bug #1246517 duplicate), and bug #1246517 

It splits container creation in two parts:
   i) the container is created with a PUT request
  ii) the ACL is set with a subsequent POST request.

The Swift listing requests in JSON format is addressed as follows:
   i) append the parameter "format=json" in swift.List.

Without this merge 'juju bootstrap' does not work in Havana using ceph-radosgw as a Swift back-end.

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
 
36
36
// CreateContainer creates a container with the given name.
37
37
func (c *Client) CreateContainer(containerName string, acl ACL) error {
 
38
        // [sodre]: Due to a possible bug in ceph-radosgw, we need to split the
 
39
        // creation of the bucket and the changing its ACL.
 
40
        requestData := goosehttp.RequestData{ExpectedStatus: []int{http.StatusAccepted, http.StatusCreated}}
 
41
        err := c.client.SendRequest(client.PUT, "object-store", containerName, &requestData)
 
42
        if err != nil {
 
43
                err = maybeNotFound(err, "failed to create container: %s", containerName)
 
44
                return err
 
45
        }
38
46
        // Normally accessing a container or objects within requires a token
39
47
        // for the tenant. Setting an ACL using the X-Container-Read header
40
48
        // can be used to allow unauthenticated HTTP access.
41
49
        headers := make(http.Header)
42
50
        headers.Add("X-Container-Read", string(acl))
43
 
        requestData := goosehttp.RequestData{ReqHeaders: headers, ExpectedStatus: []int{http.StatusAccepted, http.StatusCreated}}
44
 
        err := c.client.SendRequest(client.PUT, "object-store", containerName, &requestData)
 
51
        requestData = goosehttp.RequestData{ReqHeaders: headers,
 
52
                ExpectedStatus: []int{http.StatusAccepted, http.StatusNoContent}}
 
53
        err = c.client.SendRequest(client.POST, "object-store", containerName, &requestData)
45
54
        if err != nil {
46
 
                err = maybeNotFound(err, "failed to create container: %s", containerName)
 
55
                err = maybeNotFound(err, "failed to update container read acl: %s", containerName)
47
56
        }
48
57
        return err
49
58
}
134
143
        params.Add("prefix", prefix)
135
144
        params.Add("delimiter", delim)
136
145
        params.Add("marker", marker)
 
146
        params.Add("format", "json")
137
147
        if limit > 0 {
138
148
                params.Add("limit", fmt.Sprintf("%d", limit))
139
149
        }