Skip to content

Commit fc9cf47

Browse files
github-actions[bot]geoffrmatttrach
authored
feat: Support Openstack Server Groups affinity (#2223)
Co-authored-by: Geoff Robertson <robertson.gg@gmail.com> Co-authored-by: Matt Trachier <matt.trachier@suse.com>
1 parent 2a01fcc commit fc9cf47

4 files changed

Lines changed: 22 additions & 0 deletions

File tree

docs/resources/machine_config_v2.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,8 @@ The following attributes are exported:
279279
* `password` - (Optional/Sensitive) OpenStack password. Mandatory on Rancher v2.0.x and v2.1.x. Use `rancher2_cloud_credential` from Rancher v2.2.x (string)
280280
* `private_key_file` - (Optional/Sensitive) Private key content to use for SSH (string)
281281
* `sec_groups` - (Optional) OpenStack comma separated security groups for the machine (string)
282+
* `server_group_id` - (Optional) OpenStack server group id to use for the instance (string)
283+
* `server_group_name` - (Optional) OpenStack server group name to use for the instance (string)
282284
* `ssh_port` - (Optional) OpenStack SSH port * Default `22` (string)
283285
* `ssh_user` - (Optional) OpenStack SSH user * Default: `root` (string)
284286
* `tenant_id` - (Required++) OpenStack tenant id. Conflicts with `tenant_name` (string)

docs/resources/node_template.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,8 @@ The following attributes are exported:
392392
* `password` - (Optional/Sensitive) OpenStack password. Mandatory on Rancher v2.0.x and v2.1.x. Use `rancher2_cloud_credential` from Rancher v2.2.x (string)
393393
* `private_key_file` - (Optional/Sensitive) Private key content to use for SSH (string)
394394
* `sec_groups` - (Optional) OpenStack comma separated security groups for the machine (string)
395+
* `server_group_id` - (Optional) OpenStack server group id to use for the instance (string)
396+
* `server_group_name` - (Optional) OpenStack server group name to use for the instance (string)
395397
* `ssh_port` - (Optional) OpenStack SSH port * Default `22` (string)
396398
* `ssh_user` - (Optional) OpenStack SSH user * Default: `root` (string)
397399
* `tenant_id` - (Required**) OpenStack tenant id. Conflicts with `tenant_name` (string)

rancher2/schema_machine_config_v2_openstack.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,14 @@ func machineConfigV2OpenstackFields() map[string]*schema.Schema {
111111
Type: schema.TypeString,
112112
Optional: true,
113113
},
114+
"server_group_id": {
115+
Type: schema.TypeString,
116+
Optional: true,
117+
},
118+
"server_group_name": {
119+
Type: schema.TypeString,
120+
Optional: true,
121+
},
114122
"ssh_port": {
115123
Type: schema.TypeString,
116124
Optional: true,

rancher2/structure_machine_config_v2_openstack.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ type machineConfigV2Openstack struct {
4040
PrivateKeyFile string `json:"privateKeyFile,omitempty" yaml:"privateKeyFile,omitempty"`
4141
Region string `json:"region,omitempty" yaml:"region,omitempty"`
4242
SecGroups string `json:"secGroups,omitempty" yaml:"secGroups,omitempty"`
43+
ServerGroupID string `json:"serverGroupId,omitempty" yaml:"serverGroupId,omitempty"`
44+
ServerGroupName string `json:"serverGroupName,omitempty" yaml:"serverGroupName,omitempty"`
4345
SSHPort string `json:"sshPort,omitempty" yaml:"sshPort,omitempty"`
4446
SSHUser string `json:"sshUser,omitempty" yaml:"sshUser,omitempty"`
4547
TenantID string `json:"tenantId,omitempty" yaml:"tenantId,omitempty"`
@@ -98,6 +100,8 @@ func flattenMachineConfigV2Openstack(in *MachineConfigV2Openstack) []interface{}
98100
obj["private_key_file"] = in.PrivateKeyFile
99101
obj["region"] = in.Region
100102
obj["sec_groups"] = in.SecGroups
103+
obj["server_group_name"] = in.ServerGroupName
104+
obj["server_group_id"] = in.ServerGroupID
101105
obj["ssh_port"] = in.SSHPort
102106
obj["ssh_user"] = in.SSHUser
103107
obj["tenant_id"] = in.TenantID
@@ -211,6 +215,12 @@ func expandMachineConfigV2Openstack(p []interface{}, source *MachineConfigV2) *M
211215
if v, ok := in["sec_groups"].(string); ok && len(v) > 0 {
212216
obj.SecGroups = v
213217
}
218+
if v, ok := in["server_group_id"].(string); ok && len(v) > 0 {
219+
obj.ServerGroupID = v
220+
}
221+
if v, ok := in["server_group_name"].(string); ok && len(v) > 0 {
222+
obj.ServerGroupName = v
223+
}
214224
if v, ok := in["ssh_port"].(string); ok && len(v) > 0 {
215225
obj.SSHPort = v
216226
}

0 commit comments

Comments
 (0)