provider/cobbler: Profile and System Fixes (#12452)
* vendor: Updating cobblerclient for Cobbler * provider/cobbler: Fix Profile Repos This commit fixes a bug where adding repos would result in an error. This was due to the Cobbler API wanting a space-separated list of repos rather than an array. The Cobbler Service will split the string by space when used internally, but will always present the repos as a string. * provider/cobbler: System Interface Management Test This commit adds a test to verify that the Management parameter of System Interfaces works.
This commit is contained in:
parent
ce633f2321
commit
3759e36784
|
@ -3,6 +3,7 @@ package cobbler
|
|||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
cobbler "github.com/jtopjian/cobblerclient"
|
||||
|
@ -261,7 +262,6 @@ func resourceProfileRead(d *schema.ResourceData, meta interface{}) error {
|
|||
d.Set("proxy", profile.Proxy)
|
||||
d.Set("redhat_management_key", profile.RedHatManagementKey)
|
||||
d.Set("redhat_management_server", profile.RedHatManagementServer)
|
||||
d.Set("repos", profile.Repos)
|
||||
d.Set("template_files", profile.TemplateFiles)
|
||||
d.Set("template_remote_kickstarts", profile.TemplateRemoteKickstarts)
|
||||
d.Set("virt_auto_boot", profile.VirtAutoBoot)
|
||||
|
@ -273,6 +273,10 @@ func resourceProfileRead(d *schema.ResourceData, meta interface{}) error {
|
|||
d.Set("virt_ram", profile.VirtRam)
|
||||
d.Set("virt_type", profile.VirtType)
|
||||
|
||||
// Split repos into a list
|
||||
repos := strings.Split(profile.Repos, " ")
|
||||
d.Set("repos", repos)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -351,7 +355,7 @@ func buildProfile(d *schema.ResourceData, meta interface{}) cobbler.Profile {
|
|||
Proxy: d.Get("proxy").(string),
|
||||
RedHatManagementKey: d.Get("redhat_management_key").(string),
|
||||
RedHatManagementServer: d.Get("redhat_management_server").(string),
|
||||
Repos: repos,
|
||||
Repos: strings.Join(repos, " "),
|
||||
Server: d.Get("server").(string),
|
||||
TemplateFiles: d.Get("template_files").(string),
|
||||
TemplateRemoteKickstarts: d.Get("template_remote_kickstarts").(int),
|
||||
|
|
|
@ -57,6 +57,26 @@ func TestAccCobblerProfile_change(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
func TestAccCobblerProfile_withRepo(t *testing.T) {
|
||||
var distro cobbler.Distro
|
||||
var profile cobbler.Profile
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccCobblerPreCheck(t) },
|
||||
Providers: testAccCobblerProviders,
|
||||
CheckDestroy: testAccCobblerCheckProfileDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testAccCobblerProfile_withRepo,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCobblerCheckDistroExists(t, "cobbler_distro.foo", &distro),
|
||||
testAccCobblerCheckProfileExists(t, "cobbler_profile.foo", &profile),
|
||||
),
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func testAccCobblerCheckProfileDestroy(s *terraform.State) error {
|
||||
config := testAccCobblerProvider.Meta().(*Config)
|
||||
|
||||
|
@ -147,3 +167,20 @@ var testAccCobblerProfile_change_2 = `
|
|||
comment = "I am a profile again"
|
||||
distro = "${cobbler_distro.foo.name}"
|
||||
}`
|
||||
|
||||
var testAccCobblerProfile_withRepo = `
|
||||
resource "cobbler_distro" "foo" {
|
||||
name = "foo"
|
||||
breed = "ubuntu"
|
||||
os_version = "trusty"
|
||||
arch = "x86_64"
|
||||
kernel = "/var/www/cobbler/ks_mirror/Ubuntu-14.04/install/netboot/ubuntu-installer/amd64/linux"
|
||||
initrd = "/var/www/cobbler/ks_mirror/Ubuntu-14.04/install/netboot/ubuntu-installer/amd64/initrd.gz"
|
||||
}
|
||||
|
||||
resource "cobbler_profile" "foo" {
|
||||
name = "foo"
|
||||
comment = "I am a profile again"
|
||||
distro = "${cobbler_distro.foo.name}"
|
||||
repos = ["Ubuntu-14.04-x86_64"]
|
||||
}`
|
||||
|
|
|
@ -100,6 +100,8 @@ func TestAccCobblerSystem_removeInterface(t *testing.T) {
|
|||
testAccCobblerCheckDistroExists(t, "cobbler_distro.foo", &distro),
|
||||
testAccCobblerCheckProfileExists(t, "cobbler_profile.foo", &profile),
|
||||
testAccCobblerCheckSystemExists(t, "cobbler_system.foo", &system),
|
||||
resource.TestCheckResourceAttr(
|
||||
"cobbler_system.foo", "interface.586365610.management", "true"),
|
||||
),
|
||||
},
|
||||
resource.TestStep{
|
||||
|
@ -345,6 +347,7 @@ var testAccCobblerSystem_removeInterface_1 = `
|
|||
static = true
|
||||
ip_address = "1.2.3.5"
|
||||
netmask = "255.255.255.0"
|
||||
management = true
|
||||
}
|
||||
|
||||
}`
|
||||
|
|
|
@ -50,7 +50,7 @@ type Profile struct {
|
|||
Proxy string `mapstructure:"proxy"`
|
||||
RedHatManagementKey string `mapstructure:"redhat_management_key"`
|
||||
RedHatManagementServer string `mapstructure:"redhat_management_server"`
|
||||
Repos []string `mapstructure:"repos"`
|
||||
Repos string `mapstructure:"repos"`
|
||||
Server string `mapstructure:"server"`
|
||||
TemplateFiles string `mapstructure:"template_files"`
|
||||
TemplateRemoteKickstarts int `mapstructure:"template_remote_kickstarts"`
|
||||
|
|
|
@ -98,7 +98,7 @@ type Interface struct {
|
|||
IPv6StaticRoutes []string `mapstructure:"ipv6_static_routes" structs:"ipv6_static_routes"`
|
||||
IPv6DefaultGateway string `mapstructure:"ipv6_default_gateway structs:"ipv6_default_gateway"`
|
||||
MACAddress string `mapstructure:"mac_address" structs:"mac_address"`
|
||||
Management bool `mapstructure:"management" structs:"managment"`
|
||||
Management bool `mapstructure:"management" structs:"management"`
|
||||
Netmask string `mapstructure:"netmask" structs:"netmask"`
|
||||
Static bool `mapstructure:"static" structs:"static"`
|
||||
StaticRoutes []string `mapstructure:"static_routes" structs:"static_routes"`
|
||||
|
|
|
@ -2160,11 +2160,11 @@
|
|||
"revisionTime": "2016-06-16T18:50:15Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "N4M0qtTBHR2XBxTuPRL9ocdkQns=",
|
||||
"checksumSHA1": "YhQcOsGx8r2S/jkJ0Qt4cZ5BLCU=",
|
||||
"comment": "v0.3.0-33-g53d1c0a",
|
||||
"path": "github.com/jtopjian/cobblerclient",
|
||||
"revision": "53d1c0a0b003aabfa7ecfa848d856606cb481196",
|
||||
"revisionTime": "2016-04-01T00:38:02Z"
|
||||
"revision": "3b306e0a196ac0dc04751ad27130601a4533cce9",
|
||||
"revisionTime": "2017-03-05T20:21:00Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "sKheT5xw89Tbu2Q071FQO27CVmE=",
|
||||
|
|
Loading…
Reference in New Issue