Skip to content

Commit afb4eaf

Browse files
committed
Improvement: Add instance resource hook_script attribute
1 parent 9d9a6df commit afb4eaf

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

zstack/provider/resource_zstack_instance.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ type vmInstanceDataSourceModel struct {
8383
UserData types.String `tfsdk:"user_data"`
8484
VMNics types.List `tfsdk:"vm_nics"`
8585
Expunge types.Bool `tfsdk:"expunge"`
86+
HookScript types.String `tfsdk:"hook_script"`
8687
}
8788

8889
type NicsModel struct {
@@ -338,6 +339,10 @@ func (r *vmResource) Schema(ctx context.Context, _ resource.SchemaRequest, resp
338339
Optional: true,
339340
Description: "Indicates whether the VM instance is a marketplace instance.",
340341
},
342+
"hook_script": schema.StringAttribute{
343+
Optional: true,
344+
Description: "The uuid of hook script. Create Instance with custom xml Hook.",
345+
},
341346
},
342347
}
343348
}
@@ -358,6 +363,7 @@ func (r *vmResource) Create(ctx context.Context, req resource.CreateRequest, res
358363
hostUuid := ""
359364
clusterUuid := ""
360365
zoneUuid := ""
366+
//hook_script := ""
361367
var rootDiskSystemTags []string
362368
var dataDiskSizes []int64
363369
var dataDiskOfferingUuids []string
@@ -481,6 +487,11 @@ func (r *vmResource) Create(ctx context.Context, req resource.CreateRequest, res
481487
})
482488
}
483489

490+
//SET XML HOOK SCRIPT
491+
if !plan.HookScript.IsNull() && plan.HookScript.ValueString() != "" {
492+
systemTags = append(systemTags, fmt.Sprintf("xmlHook::%s", plan.HookScript.ValueString()))
493+
}
494+
484495
// SET IMAGE
485496
image, err := r.client.GetImage(plan.ImageUuid.ValueString())
486497
if err != nil {

0 commit comments

Comments
 (0)