parent
92528adf2b
commit
2f4be0b92a
@ -0,0 +1,136 @@
|
|||||||
|
/*
|
||||||
|
Copyright (c) 2019-2021 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
|
Author: Sergey Shubin, <sergey.shubin@digitalenergy.online>, <svs1370@gmail.com>
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration
|
||||||
|
Technology platfom.
|
||||||
|
|
||||||
|
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package decort
|
||||||
|
|
||||||
|
import (
|
||||||
|
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"log"
|
||||||
|
// "net/url"
|
||||||
|
|
||||||
|
"github.com/hashicorp/terraform/helper/schema"
|
||||||
|
"github.com/hashicorp/terraform/helper/validation"
|
||||||
|
)
|
||||||
|
|
||||||
|
func flattenAccount(d *schema.ResourceData, acc_facts string) error {
|
||||||
|
// NOTE: this function modifies ResourceData argument - as such it should never be called
|
||||||
|
// from resourceAccountExists(...) method
|
||||||
|
|
||||||
|
// log.Debugf("flattenAccount: ready to decode response body from %q", CloudspacesGetAPI)
|
||||||
|
details := AccountRecord{}
|
||||||
|
err := json.Unmarshal([]byte(rg_facts), &details)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Debugf("flattenAccount: decoded Account name %q / ID %d, status %q",
|
||||||
|
details.Name, details.ID, details.Status)
|
||||||
|
|
||||||
|
d.SetId(fmt.Sprintf("%d", details.ID))
|
||||||
|
d.Set("name", details.Name)
|
||||||
|
d.Set("status", details.Status)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func dataSourceAccountRead(d *schema.ResourceData, m interface{}) error {
|
||||||
|
acc_facts, err := utilityAccountCheckPresence(d, m)
|
||||||
|
if acc_facts == "" {
|
||||||
|
// if empty string is returned from utilityAccountCheckPresence then there is no
|
||||||
|
// such account and err tells so - just return it to the calling party
|
||||||
|
d.SetId("") // ensure ID is empty in this case
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return flattenAccount(d, acc_facts)
|
||||||
|
}
|
||||||
|
|
||||||
|
func dataSourceAccount() *schema.Resource {
|
||||||
|
return &schema.Resource{
|
||||||
|
SchemaVersion: 1,
|
||||||
|
|
||||||
|
Read: dataSourceAccountRead,
|
||||||
|
|
||||||
|
Timeouts: &schema.ResourceTimeout{
|
||||||
|
Read: &Timeout30s,
|
||||||
|
Default: &Timeout60s,
|
||||||
|
},
|
||||||
|
|
||||||
|
Schema: map[string]*schema.Schema{
|
||||||
|
"name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Name of the account. Names are case sensitive and unique.",
|
||||||
|
},
|
||||||
|
|
||||||
|
"account_id": &schema.Schema{
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Unique ID of the account. If account ID is specified, then account name is ignored.",
|
||||||
|
},
|
||||||
|
|
||||||
|
"status": &schema.Schema{
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
Description: "Current status of the account."
|
||||||
|
}
|
||||||
|
|
||||||
|
/* We keep the following attributes commented out, as we are not implementing account
|
||||||
|
management with Terraform plugin, so we do not need this extra info.
|
||||||
|
|
||||||
|
"quota": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Optional: true,
|
||||||
|
MaxItems: 1,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: quotaRgSubresourceSchema(), // this is a dictionary
|
||||||
|
},
|
||||||
|
Description: "Quotas on the resources for this account and all its resource groups.",
|
||||||
|
},
|
||||||
|
|
||||||
|
"resource_groups": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Schema {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
},
|
||||||
|
Description: "IDs of resource groups in this account."
|
||||||
|
},
|
||||||
|
|
||||||
|
"vins": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Schema {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
},
|
||||||
|
Description: "IDs of VINSes created at the account level."
|
||||||
|
},
|
||||||
|
*/
|
||||||
|
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,153 @@
|
|||||||
|
/*
|
||||||
|
Copyright (c) 2019-2021 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
|
Author: Sergey Shubin, <sergey.shubin@digitalenergy.online>, <svs1370@gmail.com>
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration
|
||||||
|
Technology platfom.
|
||||||
|
|
||||||
|
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package decort
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"log"
|
||||||
|
"net/url"
|
||||||
|
|
||||||
|
// "strconv"
|
||||||
|
|
||||||
|
"github.com/hashicorp/terraform/helper/schema"
|
||||||
|
// "github.com/hashicorp/terraform/helper/validation"
|
||||||
|
)
|
||||||
|
|
||||||
|
func utilityAccountCheckPresence(d *schema.ResourceData, m interface{}) (string, error) {
|
||||||
|
controller := m.(*ControllerCfg)
|
||||||
|
url_values := &url.Values{}
|
||||||
|
|
||||||
|
acc_id, arg_set := d.GetOk("account_id")
|
||||||
|
if arg_set {
|
||||||
|
// get Account right away by its ID
|
||||||
|
log.Debugf("utilityAccountCheckPresence: locating Account by its ID %d", acc_id.(int))
|
||||||
|
url_values.Add("accountId", fmt.Sprintf("%d", acc_id.(int)))
|
||||||
|
api_resp, err := controller.decortAPICall("POST", AccountsGetAPI, url_values)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
return api_resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
acc_name, arg_set := d.GetOk("name")
|
||||||
|
if !arg_set {
|
||||||
|
// neither ID nor name - no account for you!
|
||||||
|
return "", fmt.Error("Cannot check account presence if name is empty and no account ID specified.")
|
||||||
|
}
|
||||||
|
|
||||||
|
api_resp, err := controller.decortAPICall("POST", AccountsListAPI, url_values)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
// log.Debugf("%s", api_resp)
|
||||||
|
// log.Debugf("utilityAccountCheckPresence: ready to decode response body from %q", AccountsListAPI)
|
||||||
|
acc_list := AccountsListResp{}
|
||||||
|
err = json.Unmarshal([]byte(api_resp), &acc_list)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Debugf("utilityAccountCheckPresence: traversing decoded Json of length %d", len(model))
|
||||||
|
for index, item := range acc_list {
|
||||||
|
// match by account name
|
||||||
|
if item.Name == acc_name.(string) {
|
||||||
|
log.Debugf("utilityAccountCheckPresence: match account name %q / ID %d at index %d",
|
||||||
|
item.Name, item.ID, index)
|
||||||
|
|
||||||
|
// NB: unlike accounts/get API, accounts/list API returns abridged set of account info,
|
||||||
|
// for instance it does not return quotas
|
||||||
|
|
||||||
|
reencoded_item, err := json.Marshal(item)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
return reencoded_item.(string), nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return "", fmt.Errorf("Cannot find account name %q owned by account ID %d", name, validated_account_id)
|
||||||
|
}
|
||||||
|
|
||||||
|
func utilityGetAccountIdBySchema(d *schema.ResourceData, m interface{}) (int, error) {
|
||||||
|
/*
|
||||||
|
This function expects schema that contains the following two elements:
|
||||||
|
|
||||||
|
"account_name": &schema.Schema{
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Required: Optional,
|
||||||
|
Description: "Name of the account, ....",
|
||||||
|
},
|
||||||
|
|
||||||
|
"account_id": &schema.Schema{
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Unique ID of the account, ....",
|
||||||
|
},
|
||||||
|
|
||||||
|
Then it will check, which argument is set, and if account name is present, it will
|
||||||
|
initiate API calls to the DECORT cloud controller and try to match relevant account
|
||||||
|
by the name.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
account_id, arg_set := d.GetOk("account_id")
|
||||||
|
if arg_set {
|
||||||
|
if account_id.(int) > 0 {
|
||||||
|
return account_id.(int), nil
|
||||||
|
}
|
||||||
|
return 0, fmt.Error("Account ID must be positive, if set.")
|
||||||
|
}
|
||||||
|
|
||||||
|
account_name, arg_set := d.GetOk("account_name")
|
||||||
|
if !arg_set {
|
||||||
|
return 0, fmt.Error("Non-empty account name or positive account ID must be specified.")
|
||||||
|
}
|
||||||
|
|
||||||
|
controller := m.(*ControllerCfg)
|
||||||
|
url_values := &url.Values{}
|
||||||
|
body_string, err := controller.decortAPICall("POST", AccountsListAPI, url_values)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
model := AccountsListResp{}
|
||||||
|
err = json.Unmarshal([]byte(body_string), &model)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Debugf("utilityGetAccountIdBySchema: traversing decoded Json of length %d", len(model))
|
||||||
|
for index, item := range model {
|
||||||
|
// need to match Account by name
|
||||||
|
if item.Name == account_name.(string) {
|
||||||
|
log.Debugf("utilityGetAccountIdBySchema: match Account name %q / ID %d at index %d",
|
||||||
|
item.Name, item.ID, index)
|
||||||
|
return item.ID, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0, fmt.Errorf("Cannot find account %q for the current user. Check account name and your access rights", account_name.(string))
|
||||||
|
}
|
@ -0,0 +1,330 @@
|
|||||||
|
/*
|
||||||
|
Copyright (c) 2019-2021 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
|
Author: Sergey Shubin, <sergey.shubin@digitalenergy.online>, <svs1370@gmail.com>
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
This file contains definitions and code for handling Interface component of Compute schema
|
||||||
|
*/
|
||||||
|
|
||||||
|
package decort
|
||||||
|
|
||||||
|
import (
|
||||||
|
"log"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/hashicorp/terraform/helper/schema"
|
||||||
|
"github.com/hashicorp/terraform/helper/validation"
|
||||||
|
)
|
||||||
|
|
||||||
|
func interfaceSubresourceSchemaMake() map[string]*schema.Schema {
|
||||||
|
rets := map[string]*schema.Schema{
|
||||||
|
"net_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
Description: "ID of the network entity this interface is connected to.",
|
||||||
|
},
|
||||||
|
|
||||||
|
"net_type": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
Description: "Type of the network entity this interface is connected to.",
|
||||||
|
},
|
||||||
|
|
||||||
|
"ip_address": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
Description: "IP addresses assigned to this interface.",
|
||||||
|
},
|
||||||
|
|
||||||
|
"netmask": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
Description: "Network mask to be used with this interface.",
|
||||||
|
},
|
||||||
|
|
||||||
|
"mac": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
Description: "MAC address of this interface.",
|
||||||
|
},
|
||||||
|
|
||||||
|
"default_gw": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
Description: "Default gateway associated with this interface.",
|
||||||
|
},
|
||||||
|
|
||||||
|
"name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
Description: "Interface name.",
|
||||||
|
},
|
||||||
|
|
||||||
|
"connection_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
Description: "VxLAN or VLAN ID this interface is connected to.",
|
||||||
|
},
|
||||||
|
|
||||||
|
"connection_type": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
Description: "Type of the segment (VLAN or VxLAN) this interface is connected to.",
|
||||||
|
},
|
||||||
|
|
||||||
|
"qos": {
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: interfaceQosSubresourceSchemaMake(),
|
||||||
|
},
|
||||||
|
Description: "Details about the guest OS users provisioned together with this compute instance.",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
return rets
|
||||||
|
}
|
||||||
|
|
||||||
|
func interfaceQosSubresourceSchemaMake() map[string]*schema.Schema {
|
||||||
|
rets := map[string]*schema.Schema{
|
||||||
|
"egress_rate": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
Description: "Egress rate limit on this interface.",
|
||||||
|
},
|
||||||
|
|
||||||
|
"ingress_burst": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
Description: "Ingress burst limit on this interface.",
|
||||||
|
},
|
||||||
|
|
||||||
|
"ingress_rate": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
Description: "Ingress rate limit on this interface.",
|
||||||
|
},
|
||||||
|
|
||||||
|
"guid": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
Description: "GUID of this QoS record.",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
return rets
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
func flattenNetworks(nets []NicRecord) []interface{} {
|
||||||
|
// this function expects an array of NicRecord as returned by machines/get API call
|
||||||
|
// NOTE: it does NOT expect a strucutre as returned by externalnetwork/list
|
||||||
|
var length = 0
|
||||||
|
var strarray []string
|
||||||
|
|
||||||
|
for _, value := range nets {
|
||||||
|
if value.NicType == "PUBLIC" {
|
||||||
|
length += 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log.Printf("flattenNetworks: found %d NICs with PUBLIC type", length)
|
||||||
|
|
||||||
|
result := make([]interface{}, length)
|
||||||
|
if length == 0 {
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
elem := make(map[string]interface{})
|
||||||
|
|
||||||
|
var subindex = 0
|
||||||
|
for index, value := range nets {
|
||||||
|
if value.NicType == "PUBLIC" {
|
||||||
|
// this will be changed as network segments entity
|
||||||
|
// value.Params for ext net comes in a form "gateway:176.118.165.1 externalnetworkId:6"
|
||||||
|
// for network_id we need to extract from this string
|
||||||
|
strarray = strings.Split(value.Params, " ")
|
||||||
|
substr := strings.Split(strarray[1], ":")
|
||||||
|
elem["network_id"], _ = strconv.Atoi(substr[1])
|
||||||
|
elem["ip_range"] = value.IPAddress
|
||||||
|
// elem["label"] = ... - should be uncommented for the future release
|
||||||
|
log.Printf("flattenNetworks: parsed element %d - network_id %d, ip_range %q",
|
||||||
|
index, elem["network_id"].(int), value.IPAddress)
|
||||||
|
result[subindex] = elem
|
||||||
|
subindex += 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
func makePortforwardsConfig(arg_list []interface{}) (pfws []PortforwardConfig, count int) {
|
||||||
|
count = len(arg_list)
|
||||||
|
if count < 1 {
|
||||||
|
return nil, 0
|
||||||
|
}
|
||||||
|
|
||||||
|
pfws = make([]PortforwardConfig, count)
|
||||||
|
var subres_data map[string]interface{}
|
||||||
|
for index, value := range arg_list {
|
||||||
|
subres_data = value.(map[string]interface{})
|
||||||
|
// pfws[index].Label = subres_data["label"].(string) - should be uncommented for future release
|
||||||
|
pfws[index].ExtPort = subres_data["ext_port"].(int)
|
||||||
|
pfws[index].IntPort = subres_data["int_port"].(int)
|
||||||
|
pfws[index].Proto = subres_data["proto"].(string)
|
||||||
|
}
|
||||||
|
|
||||||
|
return pfws, count
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenPortforwards(pfws []PortforwardRecord) []interface{} {
|
||||||
|
result := make([]interface{}, len(pfws))
|
||||||
|
elem := make(map[string]interface{})
|
||||||
|
var port_num int
|
||||||
|
|
||||||
|
for index, value := range pfws {
|
||||||
|
// elem["label"] = ... - should be uncommented for the future release
|
||||||
|
|
||||||
|
// external port field is of TypeInt in the portforwardSubresourceSchema, but string is returned
|
||||||
|
// by portforwards/list API, so we need conversion here
|
||||||
|
port_num, _ = strconv.Atoi(value.ExtPort)
|
||||||
|
elem["ext_port"] = port_num
|
||||||
|
// internal port field is of TypeInt in the portforwardSubresourceSchema, but string is returned
|
||||||
|
// by portforwards/list API, so we need conversion here
|
||||||
|
port_num, _ = strconv.Atoi(value.IntPort)
|
||||||
|
elem["int_port"] = port_num
|
||||||
|
elem["proto"] = value.Proto
|
||||||
|
elem["ext_ip"] = value.ExtIP
|
||||||
|
elem["int_ip"] = value.IntIP
|
||||||
|
result[index] = elem
|
||||||
|
}
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
func portforwardSubresourceSchema() map[string]*schema.Schema {
|
||||||
|
rets := map[string]*schema.Schema{
|
||||||
|
/* this should be uncommented for the future release
|
||||||
|
"label": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Required: true,
|
||||||
|
Description: "Unique label of this network connection to identify it amnong other connections for this VM.",
|
||||||
|
},
|
||||||
|
*/
|
||||||
|
|
||||||
|
"ext_port": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Required: true,
|
||||||
|
ValidateFunc: validation.IntBetween(1, 65535),
|
||||||
|
Description: "External port number for this port forwarding rule.",
|
||||||
|
},
|
||||||
|
|
||||||
|
"int_port": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Required: true,
|
||||||
|
ValidateFunc: validation.IntBetween(1, 65535),
|
||||||
|
Description: "Internal port number for this port forwarding rule.",
|
||||||
|
},
|
||||||
|
|
||||||
|
"proto": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Required: true,
|
||||||
|
// ValidateFunc: validation.IntBetween(1, ),
|
||||||
|
Description: "Protocol type for this port forwarding rule. Should be either 'tcp' or 'udp'.",
|
||||||
|
},
|
||||||
|
|
||||||
|
"ext_ip": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
Description: ".",
|
||||||
|
},
|
||||||
|
|
||||||
|
"int_ip": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
Description: ".",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
return rets
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenNICs(nics []NicRecord) []interface{} {
|
||||||
|
var result = make([]interface{}, len(nics))
|
||||||
|
elem := make(map[string]interface{})
|
||||||
|
|
||||||
|
for index, value := range nics {
|
||||||
|
elem["status"] = value.Status
|
||||||
|
elem["type"] = value.NicType
|
||||||
|
elem["mac"] = value.MacAddress
|
||||||
|
elem["ip_address"] = value.IPAddress
|
||||||
|
elem["parameters"] = value.Params
|
||||||
|
elem["reference_id"] = value.ReferenceID
|
||||||
|
elem["network_id"] = value.NetworkID
|
||||||
|
result[index] = elem
|
||||||
|
}
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
func nicSubresourceSchema() map[string]*schema.Schema {
|
||||||
|
rets := map[string]*schema.Schema{
|
||||||
|
"status": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
Description: "Current status of this NIC.",
|
||||||
|
},
|
||||||
|
|
||||||
|
"type": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
Description: "Type of this NIC.",
|
||||||
|
},
|
||||||
|
|
||||||
|
"mac": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
Description: "MAC address assigned to this NIC.",
|
||||||
|
},
|
||||||
|
|
||||||
|
"ip_address": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
Description: "IP address assigned to this NIC.",
|
||||||
|
},
|
||||||
|
|
||||||
|
"parameters": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
Description: "Additional NIC parameters.",
|
||||||
|
},
|
||||||
|
|
||||||
|
"reference_id": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
Description: "Reference ID of this NIC.",
|
||||||
|
},
|
||||||
|
|
||||||
|
"network_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
Description: "Network ID which this NIC is connected to.",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
return rets
|
||||||
|
}
|
||||||
|
|
||||||
|
*/
|
Loading…
Reference in new issue