4.11.0
This commit is contained in:
@@ -69,20 +69,6 @@ func resourceSepCreate(ctx context.Context, d *schema.ResourceData, m interface{
|
||||
req.Enable = enable.(bool)
|
||||
}
|
||||
|
||||
var consumedNIDs []uint64
|
||||
for _, item := range d.Get("consumed_by").(*schema.Set).List() {
|
||||
consumedNIDs = append(consumedNIDs, uint64(item.(int)))
|
||||
}
|
||||
|
||||
req.ConsumerNIDs = consumedNIDs
|
||||
|
||||
var providerNIDs []uint64
|
||||
for _, item := range d.Get("provided_by").([]interface{}) {
|
||||
providerNIDs = append(providerNIDs, uint64(item.(int)))
|
||||
}
|
||||
|
||||
req.ProviderNIDs = providerNIDs
|
||||
|
||||
sepId, err := c.CloudBroker().SEP().Create(ctx, req)
|
||||
if err != nil {
|
||||
d.SetId("")
|
||||
@@ -126,6 +112,22 @@ func resourceSepCreate(ctx context.Context, d *schema.ResourceData, m interface{
|
||||
}
|
||||
}
|
||||
|
||||
if consumedBy, ok := d.GetOk("consumed_by"); ok && consumedBy.(*schema.Set).Len() > 0 {
|
||||
log.Debugf("resourceSepCreate, consumed_by: consumed_by=%v sep_id %d after completing its resource configuration", consumedBy, sepId)
|
||||
err := resourceSepAddConsumerNodes(ctx, d, m)
|
||||
if err != nil {
|
||||
warnings.Add(err)
|
||||
}
|
||||
}
|
||||
|
||||
if providedBy, ok := d.GetOk("provided_by"); ok && len(providedBy.([]interface{})) > 0 {
|
||||
log.Debugf("resourceSepCreate, provided_by: provided_by=%v sep_id %d after completing its resource configuration", providedBy, sepId)
|
||||
err := resourceSepAddProviderNodes(ctx, d, m)
|
||||
if err != nil {
|
||||
warnings.Add(err)
|
||||
}
|
||||
}
|
||||
|
||||
return append(resourceSepRead(ctx, d, m), warnings.Get()...)
|
||||
}
|
||||
|
||||
@@ -483,6 +485,52 @@ func resourceSepUpdateProviders(ctx context.Context, d *schema.ResourceData, m i
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceSepAddConsumerNodes(ctx context.Context, d *schema.ResourceData, m interface{}) error {
|
||||
log.Debugf("resourceSepAddConsumerNodes: called for %s, id: %d", d.Get("name").(string), d.Get("sep_id").(int))
|
||||
c := m.(*controller.ControllerCfg)
|
||||
|
||||
var consumerNIDs []uint64
|
||||
for _, item := range d.Get("consumed_by").(*schema.Set).List() {
|
||||
consumerNIDs = append(consumerNIDs, uint64(item.(int)))
|
||||
}
|
||||
|
||||
if len(consumerNIDs) > 0 {
|
||||
reqAdd := sep.AddConsumerNodesRequest{
|
||||
SEPID: uint64(d.Get("sep_id").(int)),
|
||||
ConsumerNIDs: consumerNIDs,
|
||||
}
|
||||
_, err := c.CloudBroker().SEP().AddConsumerNodes(ctx, reqAdd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceSepAddProviderNodes(ctx context.Context, d *schema.ResourceData, m interface{}) error {
|
||||
log.Debugf("resourceSepAddProviderNodes: called for %s, id: %d", d.Get("name").(string), d.Get("sep_id").(int))
|
||||
c := m.(*controller.ControllerCfg)
|
||||
|
||||
var providerNIDs []uint64
|
||||
for _, item := range d.Get("provided_by").([]interface{}) {
|
||||
providerNIDs = append(providerNIDs, uint64(item.(int)))
|
||||
}
|
||||
|
||||
if len(providerNIDs) > 0 {
|
||||
reqAdd := sep.AddProviderNodesRequest{
|
||||
SEPID: uint64(d.Get("sep_id").(int)),
|
||||
ProviderNIDs: providerNIDs,
|
||||
}
|
||||
_, err := c.CloudBroker().SEP().AddProviderNodes(ctx, reqAdd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func ResourceSep() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
|
||||
@@ -109,7 +109,7 @@ func dataSourceSepTemplateSchemaMake() map[string]*schema.Schema {
|
||||
"sep_type": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ValidateFunc: validation.StringInSlice([]string{"hitachi", "dorado", "tatlin", "shared", "local", "des"}, false),
|
||||
ValidateFunc: validation.StringInSlice([]string{"des", "hitachi", "dorado", "tatlin", "shared", "local", "ustor"}, false),
|
||||
Description: "type of sep",
|
||||
},
|
||||
"lang": {
|
||||
@@ -305,6 +305,14 @@ func dataSourceSepListSchemaMake() map[string]*schema.Schema {
|
||||
Optional: true,
|
||||
Description: "page size",
|
||||
},
|
||||
"sep_ids": {
|
||||
Type: schema.TypeList,
|
||||
Optional: true,
|
||||
Description: "sort by list of SEP identifiers",
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeInt,
|
||||
},
|
||||
},
|
||||
"items": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
@@ -503,9 +511,10 @@ func resourceSepSchemaMake() map[string]*schema.Schema {
|
||||
Description: "SEP name",
|
||||
},
|
||||
"type": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
Description: "type of storage",
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ValidateFunc: validation.StringInSlice([]string{"des", "hitachi", "dorado", "tatlin", "shared", "local", "ustor"}, false),
|
||||
Description: "type of storage",
|
||||
},
|
||||
"access_to_pool": {
|
||||
Type: schema.TypeSet,
|
||||
|
||||
@@ -76,6 +76,12 @@ func utilitySepListCheckPresence(ctx context.Context, d *schema.ResourceData, m
|
||||
if size, ok := d.GetOk("size"); ok {
|
||||
req.Size = uint64(size.(int))
|
||||
}
|
||||
if sepIds, ok := d.GetOk("sep_ids"); ok {
|
||||
ids := sepIds.([]interface{})
|
||||
for _, id := range ids {
|
||||
req.SepIDs = append(req.SepIDs, uint64(id.(int)))
|
||||
}
|
||||
}
|
||||
|
||||
log.Debugf("utilitySepListCheckPresence: load image list")
|
||||
sepList, err := c.CloudBroker().SEP().List(ctx, req)
|
||||
|
||||
Reference in New Issue
Block a user