This commit is contained in:
Nikita Sorokin
2023-09-28 16:08:15 +03:00
parent 739289fbb8
commit 83ca627cea
44 changed files with 1994 additions and 123 deletions

View File

@@ -30,6 +30,7 @@ func flattenResourceBasicServiceGroup(d *schema.ResourceData, bsg *bservice.Reco
d.Set("rg_name", bsg.RGName)
d.Set("role", bsg.Role)
d.Set("sep_id", bsg.SEPID)
d.Set("sep_pool", bsg.PoolName)
d.Set("seq_no", bsg.SeqNo)
d.Set("status", bsg.Status)
d.Set("tech_status", bsg.TechStatus)

View File

@@ -77,6 +77,23 @@ func resourceBasicServiceCreate(ctx context.Context, d *schema.ResourceData, m i
d.SetId(strconv.FormatUint(serviceId, 10))
d.Set("service_id", serviceId)
service, err := utilityBasicServiceCheckPresence(ctx, d, m)
if err != nil {
d.SetId("")
return diag.FromErr(err)
}
if d.Get("enable").(bool) && (service.Status == status.Disabled || service.Status == status.Created) {
log.Debugf("trying to enable bservice %v", serviceId)
_, err := c.CloudAPI().BService().Enable(ctx, bservice.EnableRequest{
ServiceID: serviceId,
})
if err != nil {
return diag.FromErr(err)
}
}
return resourceBasicServiceRead(ctx, d, m)
}

View File

@@ -68,6 +68,20 @@ func resourceBasicServiceGroupCreate(ctx context.Context, d *schema.ResourceData
req.TimeoutStart = uint64(timeoutStart.(int))
}
///4.4.0
if sepId, ok := d.GetOk("sep_id"); ok {
req.SEPID = uint64(sepId.(int))
}
if sepPool, ok := d.GetOk("sep_pool"); ok {
req.SEPPool = sepPool.(string)
}
if cloudInit, ok := d.GetOk("cloud_init"); ok {
req.UserData = cloudInit.(string)
}
///
if vinses, ok := d.GetOk("vinses"); ok {
res := []uint64{}
for _, vins := range vinses.([]interface{}) {
@@ -362,6 +376,25 @@ func resourceBasicServiceGroupSchemaMake() map[string]*schema.Schema {
Required: true,
Description: "compute driver like a KVM_X86, KVM_PPC, etc.",
},
///4.4.0
"sep_id": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
Description: "storage endpoint provider ID",
},
"sep_pool": {
Type: schema.TypeString,
Optional: true,
Computed: true,
Description: "pool to use if sepId is set, can be also empty if needed to be chosen by system",
},
"cloud_init": {
Type: schema.TypeString,
Optional: true,
Description: "Optional cloud_init parameters. Applied when creating new compute instance only, ignored in all other cases.",
},
///
"role": {
Type: schema.TypeString,
Optional: true,
@@ -524,10 +557,6 @@ func resourceBasicServiceGroupSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString,
Computed: true,
},
"sep_id": {
Type: schema.TypeInt,
Computed: true,
},
"seq_no": {
Type: schema.TypeInt,
Computed: true,