github.com/mattyw/juju@v0.0.0-20140610034352-732aecd63861/provider/maas/export_test.go (about) 1 // Copyright 2012, 2013 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package maas 5 6 import ( 7 "strings" 8 9 gc "launchpad.net/gocheck" 10 "launchpad.net/gomaasapi" 11 12 "github.com/juju/juju/environs" 13 "github.com/juju/juju/environs/storage" 14 ) 15 16 var ( 17 ShortAttempt = &shortAttempt 18 APIVersion = apiVersion 19 NewCloudinitConfig = newCloudinitConfig 20 ) 21 22 func MAASAgentName(env environs.Environ) string { 23 return env.(*maasEnviron).ecfg().maasAgentName() 24 } 25 26 func GetMAASClient(env environs.Environ) *gomaasapi.MAASObject { 27 return env.(*maasEnviron).getMAASClient() 28 } 29 30 var indexData = ` 31 { 32 "index": { 33 "com.ubuntu.cloud:released:maas": { 34 "updated": "Fri, 14 Feb 2014 13:39:35 +0000", 35 "cloudname": "maas", 36 "datatype": "image-ids", 37 "format": "products:1.0", 38 "products": [ 39 "com.ubuntu.cloud:server:12.04:amd64" 40 ], 41 "path": "streams/v1/com.ubuntu.cloud:released:maas.json" 42 } 43 }, 44 "updated": "Fri, 14 Feb 2014 13:39:35 +0000", 45 "format": "index:1.0" 46 } 47 ` 48 49 var imagesData = ` 50 { 51 "content_id": "com.ubuntu.cloud:released:maas", 52 "format": "products:1.0", 53 "updated": "Fri, 14 Feb 2014 13:39:35 +0000", 54 "datatype": "image-ids", 55 "products": { 56 "com.ubuntu.cloud:server:12.04:amd64": { 57 "release": "precise", 58 "version": "12.04", 59 "arch": "amd64", 60 "versions": { 61 "20140214": { 62 "items": { 63 "11223344-0a0a-ff99-11bb-0a1b2c3d4e5f": { 64 "region": "some-region", 65 "id": "11223344-0a0a-ff99-11bb-0a1b2c3d4e5f", 66 "virt": "kvm" 67 } 68 }, 69 "pubname": "ubuntu-precise-12.04-amd64-server-20140214", 70 "label": "release" 71 } 72 } 73 } 74 } 75 } 76 ` 77 78 func UseTestImageMetadata(c *gc.C, stor storage.Storage) { 79 files := map[string]string{ 80 "images/streams/v1/index.json": indexData, 81 "images/streams/v1/com.ubuntu.cloud:released:maas.json": imagesData, 82 } 83 for f, d := range files { 84 rdr := strings.NewReader(d) 85 err := stor.Put(f, rdr, int64(len(d))) 86 c.Assert(err, gc.IsNil) 87 } 88 }