-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ds): Add new datasource
routeros_system_routerboard
Please provide a /system/routerboard datasource Fixes #588
- Loading branch information
Showing
4 changed files
with
105 additions
and
0 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
examples/data-sources/routeros_system_routerboard/data-source.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
data "routeros_system_routerboard" "data" {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package routeros | ||
|
||
import ( | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
) | ||
|
||
/* | ||
{ | ||
"current-firmware":"7.11.2", | ||
"factory-firmware":"6.48.6", | ||
"firmware-type":"qca9531L", | ||
"model":"CRS312-4C+8XG", | ||
"revision":"r2", | ||
"routerboard":"true", | ||
"serial-number":"XXXXXXXXXX", | ||
"upgrade-firmware":"7.11.2" | ||
} | ||
*/ | ||
|
||
// https://help.mikrotik.com/docs/display/ROS/ | ||
func DatasourceSystemRouterboard() *schema.Resource { | ||
resSchema := map[string]*schema.Schema{ | ||
MetaResourcePath: PropResourcePath("/system/routerboard"), | ||
MetaId: PropId(Id), | ||
|
||
"current_firmware": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
}, | ||
"factory_firmware": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
}, | ||
"firmware_type": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
}, | ||
"model": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
}, | ||
"routerboard": { | ||
Type: schema.TypeBool, | ||
Computed: true, | ||
}, | ||
"serial_number": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
}, | ||
"upgrade_firmware": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
}, | ||
} | ||
|
||
return &schema.Resource{ | ||
ReadContext: DefaultSystemDatasourceRead(resSchema), | ||
Schema: resSchema, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package routeros | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
const testDatasourceSystemRouterboard = "data.routeros_system_routerboard.data" | ||
|
||
func TestAccDatasourceSystemRouterboardTest_basic(t *testing.T) { | ||
t.Log("The test is skipped, the resource is only available on real hardware.") | ||
/* | ||
t.Parallel() | ||
for _, name := range testNames { | ||
t.Run(name, func(t *testing.T) { | ||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { | ||
testAccPreCheck(t) | ||
testSetTransportEnv(t, name) | ||
}, | ||
ProviderFactories: testAccProviderFactories, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccDatasourceSystemRouterboardConfig(), | ||
Check: resource.ComposeTestCheckFunc( | ||
testResourcePrimaryInstanceId(testDatasourceSystemRouterboard), | ||
), | ||
}, | ||
}, | ||
}) | ||
}) | ||
} | ||
*/ | ||
} | ||
|
||
/* | ||
func testAccDatasourceSystemRouterboardConfig() string { | ||
return providerConfig + ` | ||
data "routeros_system_routerboard" "data" {} | ||
` | ||
} | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters