~dave-cheney/goose/003-fix-fd-leak

« back to all changes in this revision

Viewing changes to testservices/novaservice/service_http.go

  • Committer: Tarmac
  • Author(s): Ian Booth
  • Date: 2013-02-26 00:54:20 UTC
  • mfrom: (77.1.1 nova-double-server-id)
  • Revision ID: tarmac-20130226005420-ke5xcdb1e0qstf9e
[r=wallyworld] Fix server id gen for noav double

A quick change to generate the nova server id on the test double using a counter not a random value.

https://codereview.appspot.com/7396058/

Show diffs side-by-side

added added

removed removed

Lines of Context:
526
526
        return fmt.Sprintf("%x-%x-%x-%x-%x", uuid[0:4], uuid[4:6], uuid[6:8], uuid[8:10], uuid[10:]), nil
527
527
}
528
528
 
529
 
// NewId generates a random numeric id, encoded as a string.
530
 
func newId() (string, error) {
531
 
        buf := make([]byte, 1)
532
 
        _, err := io.ReadFull(rand.Reader, buf)
533
 
        if err != nil {
534
 
                panic(fmt.Sprintf("error from crypto rand: %v", err))
535
 
        }
536
 
        return fmt.Sprintf("%d", buf[0]), nil
537
 
}
538
 
 
539
529
// noGroupError constructs a bad request response for an invalid group.
540
530
func noGroupError(groupName, tenantId string) error {
541
531
        return &errorResponse{
571
561
        if req.Server.FlavorRef == "" {
572
562
                return errBadRequestSrvFlavor
573
563
        }
574
 
        id, err := newId()
575
 
        if err != nil {
576
 
                return err
577
 
        }
 
564
        n.nextServerId++
 
565
        id := strconv.Itoa(n.nextServerId)
578
566
        uuid, err := newUUID()
579
567
        if err != nil {
580
568
                return err