Add provider/cloudstack: add security_group_ids
This commit is contained in:
parent
d7e7a45ec6
commit
b4c7a274fa
|
@ -89,6 +89,16 @@ func resourceCloudStackInstance() *schema.Resource {
|
||||||
ConflictsWith: []string{"affinity_group_ids"},
|
ConflictsWith: []string{"affinity_group_ids"},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"security_group_ids": &schema.Schema{
|
||||||
|
Type: schema.TypeSet,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
ForceNew: true,
|
||||||
|
Elem: &schema.Schema{Type: schema.TypeString},
|
||||||
|
Set: schema.HashString,
|
||||||
|
ConflictsWith: []string{"security_group_names"},
|
||||||
|
},
|
||||||
|
|
||||||
"security_group_names": &schema.Schema{
|
"security_group_names": &schema.Schema{
|
||||||
Type: schema.TypeSet,
|
Type: schema.TypeSet,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
|
@ -96,6 +106,7 @@ func resourceCloudStackInstance() *schema.Resource {
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
Elem: &schema.Schema{Type: schema.TypeString},
|
Elem: &schema.Schema{Type: schema.TypeString},
|
||||||
Set: schema.HashString,
|
Set: schema.HashString,
|
||||||
|
ConflictsWith: []string{"security_group_ids"},
|
||||||
},
|
},
|
||||||
|
|
||||||
"project": &schema.Schema{
|
"project": &schema.Schema{
|
||||||
|
@ -249,6 +260,17 @@ func resourceCloudStackInstanceCreate(d *schema.ResourceData, meta interface{})
|
||||||
p.SetAffinitygroupnames(groups)
|
p.SetAffinitygroupnames(groups)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If there is a security_group_ids supplied, add it to the parameter struct
|
||||||
|
if sgids := d.Get("security_group_ids").(*schema.Set); sgids.Len() > 0 {
|
||||||
|
var groups []string
|
||||||
|
|
||||||
|
for _, group := range sgids.List() {
|
||||||
|
groups = append(groups, group.(string))
|
||||||
|
}
|
||||||
|
|
||||||
|
p.SetSecuritygroupids(groups)
|
||||||
|
}
|
||||||
|
|
||||||
// If there is a security_group_names supplied, add it to the parameter struct
|
// If there is a security_group_names supplied, add it to the parameter struct
|
||||||
if sgns := d.Get("security_group_names").(*schema.Set); sgns.Len() > 0 {
|
if sgns := d.Get("security_group_names").(*schema.Set); sgns.Len() > 0 {
|
||||||
var groups []string
|
var groups []string
|
||||||
|
@ -367,6 +389,15 @@ func resourceCloudStackInstanceRead(d *schema.ResourceData, meta interface{}) er
|
||||||
d.Set("affinity_group_names", agns)
|
d.Set("affinity_group_names", agns)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sgids := &schema.Set{F: schema.HashString}
|
||||||
|
for _, group := range vm.Securitygroup {
|
||||||
|
sgids.Add(group.Id)
|
||||||
|
}
|
||||||
|
|
||||||
|
if sgids.Len() > 0 {
|
||||||
|
d.Set("security_group_ids", sgids)
|
||||||
|
}
|
||||||
|
|
||||||
sgns := &schema.Set{F: schema.HashString}
|
sgns := &schema.Set{F: schema.HashString}
|
||||||
for _, group := range vm.Securitygroup {
|
for _, group := range vm.Securitygroup {
|
||||||
sgns.Add(group.Name)
|
sgns.Add(group.Name)
|
||||||
|
|
|
@ -73,6 +73,9 @@ The following arguments are supported:
|
||||||
* `affinity_group_names` - (Optional) List of affinity groups to apply to this
|
* `affinity_group_names` - (Optional) List of affinity groups to apply to this
|
||||||
instance. Changing this forces a new resource to be created.
|
instance. Changing this forces a new resource to be created.
|
||||||
|
|
||||||
|
* `security_group_ids` - (Optional) List of security groups id to apply to this
|
||||||
|
isnstance. Changing this forces a new resource to be created.
|
||||||
|
|
||||||
* `security_group_names` - (Optional) List of security groups to apply to this
|
* `security_group_names` - (Optional) List of security groups to apply to this
|
||||||
isnstance. Changing this forces a new resource to be created.
|
isnstance. Changing this forces a new resource to be created.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue