|
|
@ -47,8 +47,14 @@ func resourceDiskCreate(d *schema.ResourceData, m interface{}) error {
|
|
|
|
urlValues.Add("name", d.Get("name").(string))
|
|
|
|
urlValues.Add("name", d.Get("name").(string))
|
|
|
|
urlValues.Add("size", fmt.Sprintf("%d", d.Get("size").(int)))
|
|
|
|
urlValues.Add("size", fmt.Sprintf("%d", d.Get("size").(int)))
|
|
|
|
urlValues.Add("type", "D") // NOTE: only disks of Data type are managed via plugin
|
|
|
|
urlValues.Add("type", "D") // NOTE: only disks of Data type are managed via plugin
|
|
|
|
urlValues.Add("sep_id", fmt.Sprintf("%d", d.Get("sep_id").(int)))
|
|
|
|
|
|
|
|
urlValues.Add("pool", d.Get("pool").(string))
|
|
|
|
if sepId, ok := d.GetOk("sep_id"); ok {
|
|
|
|
|
|
|
|
urlValues.Add("sep_id", strconv.Itoa(sepId.(int)))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if poolName, ok := d.GetOk("pool"); ok {
|
|
|
|
|
|
|
|
urlValues.Add("pool", poolName.(string))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
argVal, argSet := d.GetOk("description")
|
|
|
|
argVal, argSet := d.GetOk("description")
|
|
|
|
if argSet {
|
|
|
|
if argSet {
|
|
|
@ -101,7 +107,7 @@ func resourceDiskUpdate(d *schema.ResourceData, m interface{}) error {
|
|
|
|
oldSize, newSize := d.GetChange("size")
|
|
|
|
oldSize, newSize := d.GetChange("size")
|
|
|
|
if oldSize.(int) < newSize.(int) {
|
|
|
|
if oldSize.(int) < newSize.(int) {
|
|
|
|
log.Debugf("resourceDiskUpdate: resizing disk ID %s - %d GB -> %d GB",
|
|
|
|
log.Debugf("resourceDiskUpdate: resizing disk ID %s - %d GB -> %d GB",
|
|
|
|
d.Id(), oldSize.(int), newSize.(int))
|
|
|
|
d.Id(), oldSize.(int), newSize.(int))
|
|
|
|
sizeParams := &url.Values{}
|
|
|
|
sizeParams := &url.Values{}
|
|
|
|
sizeParams.Add("diskId", d.Id())
|
|
|
|
sizeParams.Add("diskId", d.Id())
|
|
|
|
sizeParams.Add("size", fmt.Sprintf("%d", newSize.(int)))
|
|
|
|
sizeParams.Add("size", fmt.Sprintf("%d", newSize.(int)))
|
|
|
@ -117,7 +123,7 @@ func resourceDiskUpdate(d *schema.ResourceData, m interface{}) error {
|
|
|
|
oldName, newName := d.GetChange("name")
|
|
|
|
oldName, newName := d.GetChange("name")
|
|
|
|
if oldName.(string) != newName.(string) {
|
|
|
|
if oldName.(string) != newName.(string) {
|
|
|
|
log.Debugf("resourceDiskUpdate: renaming disk ID %d - %s -> %s",
|
|
|
|
log.Debugf("resourceDiskUpdate: renaming disk ID %d - %s -> %s",
|
|
|
|
d.Get("disk_id").(int), oldName.(string), newName.(string))
|
|
|
|
d.Get("disk_id").(int), oldName.(string), newName.(string))
|
|
|
|
renameParams := &url.Values{}
|
|
|
|
renameParams := &url.Values{}
|
|
|
|
renameParams.Add("diskId", d.Id())
|
|
|
|
renameParams.Add("diskId", d.Id())
|
|
|
|
renameParams.Add("name", newName.(string))
|
|
|
|
renameParams.Add("name", newName.(string))
|
|
|
@ -129,12 +135,12 @@ func resourceDiskUpdate(d *schema.ResourceData, m interface{}) error {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
NOTE: plugin will manage disks of type "Data" only, and type cannot be changed once disk is created
|
|
|
|
NOTE: plugin will manage disks of type "Data" only, and type cannot be changed once disk is created
|
|
|
|
|
|
|
|
|
|
|
|
oldType, newType := d.GetChange("type")
|
|
|
|
oldType, newType := d.GetChange("type")
|
|
|
|
if oldType.(string) != newType.(string) {
|
|
|
|
if oldType.(string) != newType.(string) {
|
|
|
|
return fmt.Errorf("resourceDiskUpdate: Disk ID %s - changing type of existing disk not allowed", d.Id())
|
|
|
|
return fmt.Errorf("resourceDiskUpdate: Disk ID %s - changing type of existing disk not allowed", d.Id())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
d.Partial(false)
|
|
|
|
d.Partial(false)
|
|
|
@ -198,7 +204,7 @@ func resourceDiskSchemaMake() map[string]*schema.Schema {
|
|
|
|
rets := map[string]*schema.Schema{
|
|
|
|
rets := map[string]*schema.Schema{
|
|
|
|
"name": {
|
|
|
|
"name": {
|
|
|
|
Type: schema.TypeString,
|
|
|
|
Type: schema.TypeString,
|
|
|
|
Optional: true,
|
|
|
|
Required: true,
|
|
|
|
Description: "Name of this disk. NOTE: disk names are NOT unique within an account. If disk ID is specified, disk name is ignored.",
|
|
|
|
Description: "Name of this disk. NOTE: disk names are NOT unique within an account. If disk ID is specified, disk name is ignored.",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
@ -210,31 +216,31 @@ func resourceDiskSchemaMake() map[string]*schema.Schema {
|
|
|
|
|
|
|
|
|
|
|
|
"account_id": {
|
|
|
|
"account_id": {
|
|
|
|
Type: schema.TypeInt,
|
|
|
|
Type: schema.TypeInt,
|
|
|
|
Optional: true,
|
|
|
|
Required: true,
|
|
|
|
Description: "ID of the account this disk belongs to.",
|
|
|
|
Description: "ID of the account this disk belongs to.",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
"sep_id": {
|
|
|
|
"sep_id": {
|
|
|
|
Type: schema.TypeInt,
|
|
|
|
Type: schema.TypeInt,
|
|
|
|
Required: true,
|
|
|
|
Optional: true,
|
|
|
|
|
|
|
|
Computed: true,
|
|
|
|
ForceNew: true,
|
|
|
|
ForceNew: true,
|
|
|
|
ValidateFunc: validation.IntAtLeast(1),
|
|
|
|
|
|
|
|
Description: "Storage end-point provider serving this disk. Cannot be changed for existing disk.",
|
|
|
|
Description: "Storage end-point provider serving this disk. Cannot be changed for existing disk.",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
"pool": {
|
|
|
|
"pool": {
|
|
|
|
Type: schema.TypeString,
|
|
|
|
Type: schema.TypeString,
|
|
|
|
Required: true,
|
|
|
|
Optional: true,
|
|
|
|
|
|
|
|
Computed: true,
|
|
|
|
ForceNew: true,
|
|
|
|
ForceNew: true,
|
|
|
|
ValidateFunc: validation.StringIsNotEmpty,
|
|
|
|
|
|
|
|
Description: "Pool where this disk is located. Cannot be changed for existing disk.",
|
|
|
|
Description: "Pool where this disk is located. Cannot be changed for existing disk.",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
"size": {
|
|
|
|
"size": {
|
|
|
|
Type: schema.TypeInt,
|
|
|
|
Type: schema.TypeInt,
|
|
|
|
Required: true,
|
|
|
|
Required: true,
|
|
|
|
ValidateFunc: validation.IntAtLeast(1),
|
|
|
|
ValidateFunc: validation.IntAtLeast(1),
|
|
|
|
Description: "Size of the disk in GB. Note, that existing disks can only be grown in size.",
|
|
|
|
Description: "Size of the disk in GB. Note, that existing disks can only be grown in size.",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/* We moved "type" attribute to computed attributes section, as plugin manages disks of only
|
|
|
|
/* We moved "type" attribute to computed attributes section, as plugin manages disks of only
|
|
|
@ -282,14 +288,14 @@ func resourceDiskSchemaMake() map[string]*schema.Schema {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
"snapshots": {
|
|
|
|
"snapshots": {
|
|
|
|
Type: schema.TypeList,
|
|
|
|
Type: schema.TypeList,
|
|
|
|
Computed: true,
|
|
|
|
Computed: true,
|
|
|
|
Elem: &schema.Resource {
|
|
|
|
Elem: &schema.Resource {
|
|
|
|
Schema: snapshotSubresourceSchemaMake(),
|
|
|
|
Schema: snapshotSubresourceSchemaMake(),
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
Description: "List of user-created snapshots for this disk."
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Description: "List of user-created snapshots for this disk."
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|