|
|
|
@ -4,6 +4,7 @@ Authors:
|
|
|
|
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
|
|
|
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
|
|
|
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
|
|
|
|
Tim Tkachev, <tvtkachev@basistech.ru>
|
|
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
@ -77,14 +78,22 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if network, ok := d.GetOk("network"); ok {
|
|
|
|
|
networkData := network.(*schema.Set).List()[0].(map[string]interface{})
|
|
|
|
|
if networkData["net_type"].(string) == "VINS" {
|
|
|
|
|
if vinsId, ok := existVinsId(ctx, d, m); !ok {
|
|
|
|
|
return diag.Errorf("resourceComputeCreate: can't create compute because vins ID %d is not allowed or does not exist", vinsId)
|
|
|
|
|
}
|
|
|
|
|
} else if networkData["net_type"].(string) == "EXTNET" {
|
|
|
|
|
if extNetId, ok := existExtNetId(ctx, d, m); !ok {
|
|
|
|
|
return diag.Errorf("resourceComputeCreate: can't create compute because extnet ID %d is not allowed or does not exist", extNetId)
|
|
|
|
|
networkList := network.(*schema.Set).List()
|
|
|
|
|
for _, elem := range networkList {
|
|
|
|
|
networkData := elem.(map[string]interface{})
|
|
|
|
|
|
|
|
|
|
switch networkData["net_type"].(string) {
|
|
|
|
|
case "VINS":
|
|
|
|
|
if vinsId, ok := existVinsId(ctx, m, networkData["net_id"].(int)); !ok {
|
|
|
|
|
return diag.Errorf("resourceComputeCreate: can't create compute because vins ID %d is not allowed or does not exist", vinsId)
|
|
|
|
|
}
|
|
|
|
|
case "EXTNET":
|
|
|
|
|
if extNetId, ok := existExtNetId(ctx, m, networkData["net_id"].(int)); !ok {
|
|
|
|
|
return diag.Errorf("resourceComputeCreate: can't create compute because extnet ID %d is not allowed or does not exist", extNetId)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -557,14 +566,22 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if network, ok := d.GetOk("network"); ok {
|
|
|
|
|
networkData := network.(*schema.Set).List()[0].(map[string]interface{})
|
|
|
|
|
if networkData["net_type"].(string) == "VINS" {
|
|
|
|
|
if vinsId, ok := existVinsId(ctx, d, m); !ok {
|
|
|
|
|
return diag.Errorf("resourceComputeUpdate: can't create update because vins ID %d is not allowed or does not exist", vinsId)
|
|
|
|
|
}
|
|
|
|
|
} else if networkData["net_type"].(string) == "EXTNET" {
|
|
|
|
|
if extNetId, ok := existExtNetId(ctx, d, m); !ok {
|
|
|
|
|
return diag.Errorf("resourceComputeUpdate: can't create update because extnet ID %d is not allowed or does not exist", extNetId)
|
|
|
|
|
networkList := network.(*schema.Set).List()
|
|
|
|
|
for _, elem := range networkList {
|
|
|
|
|
networkData := elem.(map[string]interface{})
|
|
|
|
|
|
|
|
|
|
switch networkData["net_type"].(string) {
|
|
|
|
|
case "VINS":
|
|
|
|
|
if vinsId, ok := existVinsId(ctx, m, networkData["net_id"].(int)); !ok {
|
|
|
|
|
return diag.Errorf("resourceComputeUpdate: can't update compute because vins ID %d is not allowed or does not exist", vinsId)
|
|
|
|
|
}
|
|
|
|
|
case "EXTNET":
|
|
|
|
|
if extNetId, ok := existExtNetId(ctx, m, networkData["net_id"].(int)); !ok {
|
|
|
|
|
return diag.Errorf("resourceComputeUpdate: can't update compute because extnet ID %d is not allowed or does not exist", extNetId)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -1704,7 +1721,6 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
|
|
|
|
|
|
|
|
|
|
"network": {
|
|
|
|
|
Type: schema.TypeSet,
|
|
|
|
|
Computed: true,
|
|
|
|
|
Optional: true,
|
|
|
|
|
MinItems: 1,
|
|
|
|
|
MaxItems: constants.MaxNetworksPerCompute,
|
|
|
|
@ -1714,18 +1730,6 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
|
|
|
|
|
Description: "Optional network connection(s) for this compute. You may specify several network blocks, one for each connection.",
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
"ssh_keys": {
|
|
|
|
|
Type: schema.TypeList,
|
|
|
|
|
Optional: true,
|
|
|
|
|
MaxItems: MaxSshKeysPerCompute,
|
|
|
|
|
Elem: &schema.Resource{
|
|
|
|
|
Schema: sshSubresourceSchemaMake(),
|
|
|
|
|
},
|
|
|
|
|
Description: "SSH keys to authorize on this compute instance.",
|
|
|
|
|
},
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
"tags": {
|
|
|
|
|
Type: schema.TypeSet,
|
|
|
|
|
Optional: true,
|
|
|
|
|