Add tenant_id attribute on FWaaS resources
This commit is contained in:
parent
0ab06af410
commit
cfd3329e00
|
@ -45,6 +45,11 @@ func resourceFWFirewallV2() *schema.Resource {
|
|||
Optional: true,
|
||||
Default: true,
|
||||
},
|
||||
"tenant_id": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -64,6 +69,7 @@ func resourceFirewallCreate(d *schema.ResourceData, meta interface{}) error {
|
|||
Description: d.Get("description").(string),
|
||||
PolicyID: d.Get("policy_id").(string),
|
||||
AdminStateUp: &adminStateUp,
|
||||
TenantID: d.Get("tenant_id").(string),
|
||||
}
|
||||
|
||||
log.Printf("[DEBUG] Create firewall: %#v", firewallConfiguration)
|
||||
|
@ -90,6 +96,7 @@ func resourceFirewallCreate(d *schema.ResourceData, meta interface{}) error {
|
|||
d.Set("description", firewall.Description)
|
||||
d.Set("policy_id", firewall.PolicyID)
|
||||
d.Set("admin_state_up", firewall.AdminStateUp)
|
||||
d.Set("tenant_id", firewall.TenantID)
|
||||
|
||||
_, err = stateConf.WaitForState()
|
||||
|
||||
|
|
|
@ -43,6 +43,11 @@ func resourceFWPolicyV2() *schema.Resource {
|
|||
Optional: true,
|
||||
Default: false,
|
||||
},
|
||||
"tenant_id": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
"rules": &schema.Schema{
|
||||
Type: schema.TypeSet,
|
||||
Optional: true,
|
||||
|
@ -76,12 +81,16 @@ func resourceFirewallPolicyCreate(d *schema.ResourceData, meta interface{}) erro
|
|||
rules[i] = v.(string)
|
||||
}
|
||||
|
||||
audited := d.Get("audited").(bool)
|
||||
shared := d.Get("shared").(bool)
|
||||
|
||||
opts := policies.CreateOpts{
|
||||
Name: d.Get("name").(string),
|
||||
Description: d.Get("description").(string),
|
||||
// Audited: d.Get("audited").(bool),
|
||||
// Shared: d.Get("shared").(bool),
|
||||
Rules: rules,
|
||||
Audited: &audited,
|
||||
Shared: &shared,
|
||||
TenantID: d.Get("tenant_id").(string),
|
||||
Rules: rules,
|
||||
}
|
||||
|
||||
log.Printf("[DEBUG] Create firewall policy: %#v", opts)
|
||||
|
@ -122,6 +131,10 @@ func resourceFirewallPolicyRead(d *schema.ResourceData, meta interface{}) error
|
|||
}
|
||||
|
||||
d.Set("name", policy.Name)
|
||||
d.Set("description", policy.Description)
|
||||
d.Set("shared", policy.Shared)
|
||||
d.Set("audited", policy.Audited)
|
||||
d.Set("tenant_id", policy.TenantID)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -117,6 +117,9 @@ func testAccCheckFirewallPolicyExists(n string, expected *policies.Policy) resou
|
|||
}
|
||||
|
||||
expected.ID = found.ID
|
||||
// Erase the tenant id because we don't want to compare
|
||||
// it as long it is not present in the expected
|
||||
found.TenantID = ""
|
||||
|
||||
if !reflect.DeepEqual(expected, found) {
|
||||
return fmt.Errorf("Expected:\n%#v\nFound:\n%#v", expected, found)
|
||||
|
|
|
@ -65,6 +65,11 @@ func resourceFWRuleV2() *schema.Resource {
|
|||
Optional: true,
|
||||
Default: true,
|
||||
},
|
||||
"tenant_id": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -90,6 +95,7 @@ func resourceFirewallRuleCreate(d *schema.ResourceData, meta interface{}) error
|
|||
SourcePort: d.Get("source_port").(string),
|
||||
DestinationPort: d.Get("destination_port").(string),
|
||||
Enabled: &enabled,
|
||||
TenantID: d.Get("tenant_id").(string),
|
||||
}
|
||||
|
||||
log.Printf("[DEBUG] Create firewall rule: %#v", ruleConfiguration)
|
||||
|
@ -114,6 +120,7 @@ func resourceFirewallRuleCreate(d *schema.ResourceData, meta interface{}) error
|
|||
d.Set("source_port", rule.SourcePort)
|
||||
d.Set("destination_port", rule.DestinationPort)
|
||||
d.Set("enabled", rule.Enabled)
|
||||
d.Set("tenant_id", rule.TenantID)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -135,6 +135,9 @@ func testAccCheckFirewallRuleExists(n string, expected *rules.Rule) resource.Tes
|
|||
}
|
||||
|
||||
expected.ID = found.ID
|
||||
// Erase the tenant id because we don't want to compare
|
||||
// it as long it is not present in the expected
|
||||
found.TenantID = ""
|
||||
|
||||
if !reflect.DeepEqual(expected, found) {
|
||||
return fmt.Errorf("Expected:\n%#v\nFound:\n%#v", expected, found)
|
||||
|
|
Loading…
Reference in New Issue