github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/compute/v2/extensions/bootfromvolume/testing/fixtures.go (about)

     1  package testing
     2  
     3  import (
     4  	"github.com/huaweicloud/golangsdk/openstack/compute/v2/extensions/bootfromvolume"
     5  	"github.com/huaweicloud/golangsdk/openstack/compute/v2/servers"
     6  )
     7  
     8  var BaseCreateOpts = servers.CreateOpts{
     9  	Name:      "createdserver",
    10  	FlavorRef: "performance1-1",
    11  }
    12  
    13  var BaseCreateOptsWithImageRef = servers.CreateOpts{
    14  	Name:      "createdserver",
    15  	FlavorRef: "performance1-1",
    16  	ImageRef:  "asdfasdfasdf",
    17  }
    18  
    19  const ExpectedNewVolumeRequest = `
    20  {
    21  	"server": {
    22  		"name":"createdserver",
    23  		"flavorRef":"performance1-1",
    24  		"imageRef":"",
    25  		"block_device_mapping_v2":[
    26  			{
    27  				"uuid":"123456",
    28  				"source_type":"image",
    29  				"destination_type":"volume",
    30  				"boot_index": 0,
    31  				"delete_on_termination": true,
    32  				"volume_size": 10
    33  			}
    34  		]
    35  	}
    36  }
    37  `
    38  
    39  var NewVolumeRequest = bootfromvolume.CreateOptsExt{
    40  	CreateOptsBuilder: BaseCreateOpts,
    41  	BlockDevice: []bootfromvolume.BlockDevice{
    42  		{
    43  			UUID:                "123456",
    44  			SourceType:          bootfromvolume.SourceImage,
    45  			DestinationType:     bootfromvolume.DestinationVolume,
    46  			VolumeSize:          10,
    47  			DeleteOnTermination: true,
    48  		},
    49  	},
    50  }
    51  
    52  const ExpectedExistingVolumeRequest = `
    53  {
    54  	"server": {
    55  		"name":"createdserver",
    56  		"flavorRef":"performance1-1",
    57  		"imageRef":"",
    58  		"block_device_mapping_v2":[
    59  			{
    60  				"uuid":"123456",
    61  				"source_type":"volume",
    62  				"destination_type":"volume",
    63  				"boot_index": 0,
    64  				"delete_on_termination": true
    65  			}
    66  		]
    67  	}
    68  }
    69  `
    70  
    71  var ExistingVolumeRequest = bootfromvolume.CreateOptsExt{
    72  	CreateOptsBuilder: BaseCreateOpts,
    73  	BlockDevice: []bootfromvolume.BlockDevice{
    74  		{
    75  			UUID:                "123456",
    76  			SourceType:          bootfromvolume.SourceVolume,
    77  			DestinationType:     bootfromvolume.DestinationVolume,
    78  			DeleteOnTermination: true,
    79  		},
    80  	},
    81  }
    82  
    83  const ExpectedImageRequest = `
    84  {
    85  	"server": {
    86  		"name": "createdserver",
    87  		"imageRef": "asdfasdfasdf",
    88  		"flavorRef": "performance1-1",
    89  		"block_device_mapping_v2":[
    90  			{
    91  				"boot_index": 0,
    92  				"delete_on_termination": true,
    93  				"destination_type":"local",
    94  				"source_type":"image",
    95  				"uuid":"asdfasdfasdf"
    96  			}
    97  		]
    98  	}
    99  }
   100  `
   101  
   102  var ImageRequest = bootfromvolume.CreateOptsExt{
   103  	CreateOptsBuilder: BaseCreateOptsWithImageRef,
   104  	BlockDevice: []bootfromvolume.BlockDevice{
   105  		{
   106  			BootIndex:           0,
   107  			DeleteOnTermination: true,
   108  			DestinationType:     bootfromvolume.DestinationLocal,
   109  			SourceType:          bootfromvolume.SourceImage,
   110  			UUID:                "asdfasdfasdf",
   111  		},
   112  	},
   113  }
   114  
   115  const ExpectedMultiEphemeralRequest = `
   116  {
   117  	"server": {
   118  		"name": "createdserver",
   119  		"imageRef": "asdfasdfasdf",
   120  		"flavorRef": "performance1-1",
   121  		"block_device_mapping_v2":[
   122  			{
   123  				"boot_index": 0,
   124  				"delete_on_termination": true,
   125  				"destination_type":"local",
   126  				"source_type":"image",
   127  				"uuid":"asdfasdfasdf"
   128  			},
   129  			{
   130  				"boot_index": -1,
   131  				"delete_on_termination": true,
   132  				"destination_type":"local",
   133  				"guest_format":"ext4",
   134  				"source_type":"blank",
   135  				"volume_size": 1
   136  			},
   137  			{
   138  				"boot_index": -1,
   139  				"delete_on_termination": true,
   140  				"destination_type":"local",
   141  				"guest_format":"ext4",
   142  				"source_type":"blank",
   143  				"volume_size": 1
   144  			}
   145  		]
   146  	}
   147  }
   148  `
   149  
   150  var MultiEphemeralRequest = bootfromvolume.CreateOptsExt{
   151  	CreateOptsBuilder: BaseCreateOptsWithImageRef,
   152  	BlockDevice: []bootfromvolume.BlockDevice{
   153  		{
   154  			BootIndex:           0,
   155  			DeleteOnTermination: true,
   156  			DestinationType:     bootfromvolume.DestinationLocal,
   157  			SourceType:          bootfromvolume.SourceImage,
   158  			UUID:                "asdfasdfasdf",
   159  		},
   160  		{
   161  			BootIndex:           -1,
   162  			DeleteOnTermination: true,
   163  			DestinationType:     bootfromvolume.DestinationLocal,
   164  			GuestFormat:         "ext4",
   165  			SourceType:          bootfromvolume.SourceBlank,
   166  			VolumeSize:          1,
   167  		},
   168  		{
   169  			BootIndex:           -1,
   170  			DeleteOnTermination: true,
   171  			DestinationType:     bootfromvolume.DestinationLocal,
   172  			GuestFormat:         "ext4",
   173  			SourceType:          bootfromvolume.SourceBlank,
   174  			VolumeSize:          1,
   175  		},
   176  	},
   177  }
   178  
   179  const ExpectedImageAndNewVolumeRequest = `
   180  {
   181  	"server": {
   182  		"name": "createdserver",
   183  		"imageRef": "asdfasdfasdf",
   184  		"flavorRef": "performance1-1",
   185  		"block_device_mapping_v2":[
   186  			{
   187  				"boot_index": 0,
   188  				"delete_on_termination": true,
   189  				"destination_type":"local",
   190  				"source_type":"image",
   191  				"uuid":"asdfasdfasdf"
   192  			},
   193  			{
   194  				"boot_index": 1,
   195  				"delete_on_termination": true,
   196  				"destination_type":"volume",
   197  				"source_type":"blank",
   198  				"volume_size": 1,
   199  				"device_type": "disk",
   200  				"disk_bus": "scsi"
   201  			}
   202  		]
   203  	}
   204  }
   205  `
   206  
   207  var ImageAndNewVolumeRequest = bootfromvolume.CreateOptsExt{
   208  	CreateOptsBuilder: BaseCreateOptsWithImageRef,
   209  	BlockDevice: []bootfromvolume.BlockDevice{
   210  		{
   211  			BootIndex:           0,
   212  			DeleteOnTermination: true,
   213  			DestinationType:     bootfromvolume.DestinationLocal,
   214  			SourceType:          bootfromvolume.SourceImage,
   215  			UUID:                "asdfasdfasdf",
   216  		},
   217  		{
   218  			BootIndex:           1,
   219  			DeleteOnTermination: true,
   220  			DestinationType:     bootfromvolume.DestinationVolume,
   221  			SourceType:          bootfromvolume.SourceBlank,
   222  			VolumeSize:          1,
   223  			DeviceType:          "disk",
   224  			DiskBus:             "scsi",
   225  		},
   226  	},
   227  }
   228  
   229  const ExpectedImageAndExistingVolumeRequest = `
   230  {
   231  	"server": {
   232  		"name": "createdserver",
   233  		"imageRef": "asdfasdfasdf",
   234  		"flavorRef": "performance1-1",
   235  		"block_device_mapping_v2":[
   236  			{
   237  				"boot_index": 0,
   238  				"delete_on_termination": true,
   239  				"destination_type":"local",
   240  				"source_type":"image",
   241  				"uuid":"asdfasdfasdf"
   242  			},
   243  			{
   244  				"boot_index": 1,
   245  				"delete_on_termination": true,
   246  				"destination_type":"volume",
   247  				"source_type":"volume",
   248  				"uuid":"123456",
   249  				"volume_size": 1
   250  			}
   251  		]
   252  	}
   253  }
   254  `
   255  
   256  var ImageAndExistingVolumeRequest = bootfromvolume.CreateOptsExt{
   257  	CreateOptsBuilder: BaseCreateOptsWithImageRef,
   258  	BlockDevice: []bootfromvolume.BlockDevice{
   259  		{
   260  			BootIndex:           0,
   261  			DeleteOnTermination: true,
   262  			DestinationType:     bootfromvolume.DestinationLocal,
   263  			SourceType:          bootfromvolume.SourceImage,
   264  			UUID:                "asdfasdfasdf",
   265  		},
   266  		{
   267  			BootIndex:           1,
   268  			DeleteOnTermination: true,
   269  			DestinationType:     bootfromvolume.DestinationVolume,
   270  			SourceType:          bootfromvolume.SourceVolume,
   271  			UUID:                "123456",
   272  			VolumeSize:          1,
   273  		},
   274  	},
   275  }