func TestCreateOpts(t *testing.T) { opts := CreateOpts{ Name: "createdserver", ImageRef: "image-id", FlavorRef: "flavor-id", KeyPair: "mykey", DiskConfig: diskconfig.Manual, } expected := ` { "server": { "name": "createdserver", "imageRef": "image-id", "flavorRef": "flavor-id", "flavorName": "", "imageName": "", "key_name": "mykey", "OS-DCF:diskConfig": "MANUAL" } } ` actual, err := opts.ToServerCreateMap() th.AssertNoErr(t, err) th.CheckJSONEquals(t, expected, actual) }
func TestCreateOpts(t *testing.T) { base := servers.CreateOpts{ Name: "createdserver", ImageRef: "asdfasdfasdf", FlavorRef: "performance1-1", } ext := CreateOptsExt{ CreateOptsBuilder: base, DiskConfig: Manual, } expected := ` { "server": { "name": "createdserver", "imageRef": "asdfasdfasdf", "flavorRef": "performance1-1", "flavorName": "", "imageName": "", "OS-DCF:diskConfig": "MANUAL" } } ` actual, err := ext.ToServerCreateMap() th.AssertNoErr(t, err) th.CheckJSONEquals(t, expected, actual) }
func TestRebuildOpts(t *testing.T) { base := servers.RebuildOpts{ Name: "rebuiltserver", AdminPass: "******", ImageID: "asdfasdfasdf", } ext := RebuildOptsExt{ RebuildOptsBuilder: base, DiskConfig: Auto, } actual, err := ext.ToServerRebuildMap() th.AssertNoErr(t, err) expected := ` { "rebuild": { "name": "rebuiltserver", "imageRef": "asdfasdfasdf", "adminPass": "******", "OS-DCF:diskConfig": "AUTO" } } ` th.CheckJSONEquals(t, expected, actual) }
func TestCreateOpts(t *testing.T) { base := servers.CreateOpts{ Name: "createdserver", ImageRef: "asdfasdfasdf", FlavorRef: "performance1-1", } ext := osBFV.CreateOptsExt{ CreateOptsBuilder: base, BlockDevice: []osBFV.BlockDevice{ osBFV.BlockDevice{ UUID: "123456", SourceType: osBFV.Image, DestinationType: "volume", VolumeSize: 10, }, }, } expected := ` { "server": { "name": "createdserver", "imageRef": "asdfasdfasdf", "flavorRef": "performance1-1", "flavorName": "", "imageName": "", "block_device_mapping_v2":[ { "uuid":"123456", "source_type":"image", "destination_type":"volume", "boot_index": "0", "delete_on_termination": "false", "volume_size": "10" } ] } } ` actual, err := ext.ToServerCreateMap() th.AssertNoErr(t, err) th.CheckJSONEquals(t, expected, actual) }
func TestRebuildOpts(t *testing.T) { opts := RebuildOpts{ Name: "rebuiltserver", AdminPass: "******", ImageID: "asdfasdfasdf", DiskConfig: diskconfig.Auto, } actual, err := opts.ToServerRebuildMap() th.AssertNoErr(t, err) expected := ` { "rebuild": { "name": "rebuiltserver", "imageRef": "asdfasdfasdf", "adminPass": "******", "OS-DCF:diskConfig": "AUTO" } } ` th.CheckJSONEquals(t, expected, actual) }
func TestResizeOpts(t *testing.T) { base := servers.ResizeOpts{ FlavorRef: "performance1-8", } ext := ResizeOptsExt{ ResizeOptsBuilder: base, DiskConfig: Auto, } actual, err := ext.ToServerResizeMap() th.AssertNoErr(t, err) expected := ` { "resize": { "flavorRef": "performance1-8", "OS-DCF:diskConfig": "AUTO" } } ` th.CheckJSONEquals(t, expected, actual) }