Skip to content

Commit 6849ab4

Browse files
alexng-canuckrcohenma
authored andcommitted
Add computed field for maintenance reboot times in instances
1 parent 1b8dc75 commit 6849ab4

File tree

7 files changed

+31
-1
lines changed

7 files changed

+31
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
- Support for encrypting the contents of an Object Storage bucket using a Key Management Service key
1111
- Support for specifying a Key Management Service key when launching a compute instance in the Compute service
1212
- Support for specifying a Key Management Service key when backing up or restoring a block storage volume in the Block Volume service
13-
- Support for cost tracking in tags
13+
- Support enabling cost tracking for tags using `is_cost_tracking` field
14+
- Support returning maintenance reboot time for compute instances using `time_maintenance_reboot_due` field
1415

1516
### Fixed
1617
- Data type for properties with type as TypeSet to TypeList in following datasources: `oci_core_route_tables`, `oci_core_security_lists`, `oci_core_volume`, and `oci_core_service_gateways` to allow referencing by indexes in Terraform configs.

oci/core_instance_data_source.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,10 @@ func InstanceDataSource() *schema.Resource {
156156
Type: schema.TypeString,
157157
Computed: true,
158158
},
159+
"time_maintenance_reboot_due": {
160+
Type: schema.TypeString,
161+
Computed: true,
162+
},
159163
// Legacy custom computed convenience values
160164
"public_ip": {
161165
Type: schema.TypeString,
@@ -323,6 +327,10 @@ func (s *InstanceDataSourceCrud) SetData() error {
323327
s.D.Set("time_created", s.Res.TimeCreated.String())
324328
}
325329

330+
if s.Res.TimeMaintenanceRebootDue != nil {
331+
s.D.Set("time_maintenance_reboot_due", s.Res.TimeMaintenanceRebootDue.String())
332+
}
333+
326334
if s.Res.LifecycleState == oci_core.InstanceLifecycleStateRunning {
327335
vnic, vnicError := s.getPrimaryVnic()
328336
if vnicError != nil || vnic == nil {

oci/core_instance_resource.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,10 @@ func InstanceResource() *schema.Resource {
300300
Type: schema.TypeString,
301301
Computed: true,
302302
},
303+
"time_maintenance_reboot_due": {
304+
Type: schema.TypeString,
305+
Computed: true,
306+
},
303307
// Legacy custom computed convenience values
304308
"public_ip": {
305309
Type: schema.TypeString,
@@ -707,6 +711,14 @@ func (s *InstanceResourceCrud) SetData() error {
707711
s.D.Set("time_created", s.Res.TimeCreated.String())
708712
}
709713

714+
if s.Res.TimeMaintenanceRebootDue != nil {
715+
s.D.Set("time_maintenance_reboot_due", s.Res.TimeMaintenanceRebootDue.String())
716+
} else {
717+
// If the maintenance time is cleared after reboot, the service will return a nil.
718+
// We should explicitly zero it out to avoid returning the previously cached reboot time.
719+
s.D.Set("time_maintenance_reboot_due", "")
720+
}
721+
710722
if s.Res.LifecycleState == oci_core.InstanceLifecycleStateRunning {
711723
vnic, vnicError := s.getPrimaryVnic()
712724
if vnicError != nil || vnic == nil {

oci/core_instances_data_source.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,10 @@ func (s *InstancesDataSourceCrud) SetData() error {
196196
instance["time_created"] = r.TimeCreated.String()
197197
}
198198

199+
if r.TimeMaintenanceRebootDue != nil {
200+
instance["time_maintenance_reboot_due"] = r.TimeMaintenanceRebootDue.String()
201+
}
202+
199203
resources = append(resources, instance)
200204
}
201205

website/docs/d/core_instance.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,5 @@ The following attributes are exported:
100100
* `source_type` - The source type for the instance. Use `image` when specifying the image OCID. Use `bootVolume` when specifying the boot volume OCID.
101101
* `state` - The current state of the instance.
102102
* `time_created` - The date and time the instance was created, in the format defined by RFC3339. Example: `2016-08-25T21:10:29.600Z`
103+
* `time_maintenance_reboot_due` - The date and time the instance is expected to be stopped / started, in the format defined by RFC3339. After that time if instance hasn't been rebooted, Oracle will reboot the instance within 24 hours of the due time. Regardless of how the instance was stopped, the flag will be reset to empty as soon as instance reaches Stopped state. Example: `2018-05-25T21:10:29.600Z`
103104

website/docs/d/core_instances.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,4 +112,5 @@ The following attributes are exported:
112112
* `source_type` - The source type for the instance. Use `image` when specifying the image OCID. Use `bootVolume` when specifying the boot volume OCID.
113113
* `state` - The current state of the instance.
114114
* `time_created` - The date and time the instance was created, in the format defined by RFC3339. Example: `2016-08-25T21:10:29.600Z`
115+
* `time_maintenance_reboot_due` - The date and time the instance is expected to be stopped / started, in the format defined by RFC3339. After that time if instance hasn't been rebooted, Oracle will reboot the instance within 24 hours of the due time. Regardless of how the instance was stopped, the flag will be reset to empty as soon as instance reaches Stopped state. Example: `2018-05-25T21:10:29.600Z`
115116

website/docs/r/core_instance.html.markdown

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ The following arguments are supported:
132132

133133
If you do not specify the fault domain, the system selects one for you. To change the fault domain for an instance, terminate it and launch a new instance in the preferred fault domain.
134134

135+
To get a list of fault domains, use the [ListFaultDomains](https://docs.cloud.oracle.com/iaas/api/#/en/identity/20160918/FaultDomain/ListFaultDomains) operation in the Identity and Access Management Service API.
136+
135137
Example: `FAULT-DOMAIN-1`
136138
* `freeform_tags` - (Optional) (Updatable) Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see [Resource Tags](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). Example: `{"Department": "Finance"}`
137139
* `hostname_label` - (Optional) Deprecated. Instead use `hostnameLabel` in [CreateVnicDetails](https://docs.cloud.oracle.com/iaas/api/#/en/iaas/20160918/CreateVnicDetails/). If you provide both, the values must match.
@@ -264,6 +266,7 @@ The following attributes are exported:
264266
* `source_type` - The source type for the instance. Use `image` when specifying the image OCID. Use `bootVolume` when specifying the boot volume OCID.
265267
* `state` - The current state of the instance.
266268
* `time_created` - The date and time the instance was created, in the format defined by RFC3339. Example: `2016-08-25T21:10:29.600Z`
269+
* `time_maintenance_reboot_due` - The date and time the instance is expected to be stopped / started, in the format defined by RFC3339. After that time if instance hasn't been rebooted, Oracle will reboot the instance within 24 hours of the due time. Regardless of how the instance was stopped, the flag will be reset to empty as soon as instance reaches Stopped state. Example: `2018-05-25T21:10:29.600Z`
267270

268271
## Import
269272

0 commit comments

Comments
 (0)