provider/openstack: gophercloud migration: Refactor existing resources to use 'MapValueSpecs' function

This commit is contained in:
Gavin Williams 2016-10-05 17:29:40 +01:00 committed by Joe Topjian
parent ffd5370213
commit 56cc232956
3 changed files with 3 additions and 27 deletions

View File

@ -107,7 +107,7 @@ func resourceNetworkingNetworkV2Create(d *schema.ResourceData, meta interface{})
createOpts := NetworkCreateOpts{
Name: d.Get("name").(string),
TenantID: d.Get("tenant_id").(string),
ValueSpecs: networkValueSpecs(d),
ValueSpecs: MapValueSpecs(d),
}
asuRaw := d.Get("admin_state_up").(string)
@ -284,11 +284,3 @@ func waitForNetworkDelete(networkingClient *gophercloud.ServiceClient, networkId
return n, "ACTIVE", nil
}
}
func networkValueSpecs(d *schema.ResourceData) map[string]string {
m := make(map[string]string)
for key, val := range d.Get("value_specs").(map[string]interface{}) {
m[key] = val.(string)
}
return m
}

View File

@ -117,7 +117,7 @@ func resourceNetworkingRouterV2Create(d *schema.ResourceData, meta interface{})
createOpts := RouterCreateOpts{
Name: d.Get("name").(string),
TenantID: d.Get("tenant_id").(string),
ValueSpecs: routerValueSpecs(d),
ValueSpecs: MapValueSpecs(d),
}
if asuRaw, ok := d.GetOk("admin_state_up"); ok {
@ -292,11 +292,3 @@ func waitForRouterDelete(networkingClient *gophercloud.ServiceClient, routerId s
return r, "ACTIVE", nil
}
}
func routerValueSpecs(d *schema.ResourceData) map[string]string {
m := make(map[string]string)
for key, val := range d.Get("value_specs").(map[string]interface{}) {
m[key] = val.(string)
}
return m
}

View File

@ -141,7 +141,7 @@ func resourceNetworkingSubnetV2Create(d *schema.ResourceData, meta interface{})
HostRoutes: resourceSubnetHostRoutesV2(d),
EnableDHCP: nil,
},
subnetValueSpecs(d),
MapValueSpecs(d),
}
if v, ok := d.GetOk("gateway_ip"); ok {
@ -384,11 +384,3 @@ func waitForSubnetDelete(networkingClient *gophercloud.ServiceClient, subnetId s
return s, "ACTIVE", nil
}
}
func subnetValueSpecs(d *schema.ResourceData) map[string]string {
m := make(map[string]string)
for key, val := range d.Get("value_specs").(map[string]interface{}) {
m[key] = val.(string)
}
return m
}