Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

B-2: Fix optional value update #11

Merged
merged 1 commit into from
Dec 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions opennebula/resource_opennebula_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ func resourceOpennebulaGroup() *schema.Resource {
"users": {
Type: schema.TypeList,
Optional: true,
Computed: true,
Description: "List of user IDs part of the group",
Elem: &schema.Schema{
Type: schema.TypeInt,
Expand All @@ -47,6 +48,7 @@ func resourceOpennebulaGroup() *schema.Resource {
"admins": {
Type: schema.TypeList,
Optional: true,
Computed: true,
Description: "List of Admin user IDs part of the group",
Elem: &schema.Schema{
Type: schema.TypeInt,
Expand All @@ -55,12 +57,14 @@ func resourceOpennebulaGroup() *schema.Resource {
"quotas": {
Type: schema.TypeSet,
Optional: true,
Computed: true,
Description: "Define group quota",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"datastore_quotas": {
Type: schema.TypeList,
Optional: true,
Computed: true,
Description: "Datastore quotas",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
Expand Down Expand Up @@ -107,6 +111,7 @@ func resourceOpennebulaGroup() *schema.Resource {
"image_quotas": {
Type: schema.TypeList,
Optional: true,
Computed: true,
Description: "Image quotas",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
Expand All @@ -127,6 +132,7 @@ func resourceOpennebulaGroup() *schema.Resource {
"vm_quotas": {
Type: schema.TypeSet,
Optional: true,
Computed: true,
Description: "VM quotas",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
Expand Down
1 change: 1 addition & 0 deletions opennebula/resource_opennebula_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ func resourceOpennebulaImage() *schema.Resource {
"description": {
Type: schema.TypeString,
Optional: true,
Computed: true,
Description: "Description of the Image, in OpenNebula's XML or String format",
},
"permissions": {
Expand Down
6 changes: 6 additions & 0 deletions opennebula/resource_opennebula_security_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func resourceOpennebulaSecurityGroup() *schema.Resource {
"description": {
Type: schema.TypeString,
Optional: true,
Computed: true,
Description: "Description of the Security Group Rule Set",
},
"permissions": {
Expand Down Expand Up @@ -139,26 +140,31 @@ func resourceOpennebulaSecurityGroup() *schema.Resource {
Type: schema.TypeString,
Description: "IP (or starting IP if used with 'size') to apply the rule to",
Optional: true,
Computed: true,
},
"size": {
Type: schema.TypeString,
Description: "Number of IPs to apply the rule from, starting with 'ip'",
Optional: true,
Computed: true,
},
"range": {
Type: schema.TypeString,
Description: "Comma separated list of ports and port ranges",
Optional: true,
Computed: true,
},
"icmp_type": {
Type: schema.TypeString,
Description: "Type of ICMP traffic to apply to when 'protocol' is ICMP",
Optional: true,
Computed: true,
},
"network_id": {
Type: schema.TypeString,
Description: "VNET ID to be used as the source/destination IP addresses",
Optional: true,
Computed: true,
},
},
},
Expand Down
5 changes: 5 additions & 0 deletions opennebula/resource_opennebula_virtual_data_center.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ func resourceOpennebulaVirtualDataCenter() *schema.Resource {
"group_ids": {
Type: schema.TypeList,
Optional: true,
Computed: true,
Description: "List of Group IDs to be added into the VDC",
Elem: &schema.Schema{
Type: schema.TypeInt,
Expand All @@ -66,6 +67,7 @@ func resourceOpennebulaVirtualDataCenter() *schema.Resource {
"host_ids": {
Type: schema.TypeList,
Optional: true,
Computed: true,
Description: "List of Host IDs from the Zone to add in the VDC",
Elem: &schema.Schema{
Type: schema.TypeInt,
Expand All @@ -74,6 +76,7 @@ func resourceOpennebulaVirtualDataCenter() *schema.Resource {
"datastore_ids": {
Type: schema.TypeList,
Optional: true,
Computed: true,
Description: "List of Datastore IDs from the Zone to add in the VDC",
Elem: &schema.Schema{
Type: schema.TypeInt,
Expand All @@ -82,6 +85,7 @@ func resourceOpennebulaVirtualDataCenter() *schema.Resource {
"vnet_ids": {
Type: schema.TypeList,
Optional: true,
Computed: true,
Description: "List of VNET IDs from the Zone to add in the VDC",
Elem: &schema.Schema{
Type: schema.TypeInt,
Expand All @@ -90,6 +94,7 @@ func resourceOpennebulaVirtualDataCenter() *schema.Resource {
"cluster_ids": {
Type: schema.TypeList,
Optional: true,
Computed: true,
Description: "List of cluster IDs from the Zone to add in the VDC",
Elem: &schema.Schema{
Type: schema.TypeInt,
Expand Down
56 changes: 30 additions & 26 deletions opennebula/resource_opennebula_virtual_machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,8 @@ func resourceOpennebulaVirtualMachine() *schema.Resource {
"name": {
Type: schema.TypeString,
Optional: true,
Description: "Name of the VM. If empty, defaults to 'templatename-<vmid>'",
},
"instance": {
Type: schema.TypeString,
Computed: true,
Description: "Final name of the VM instance",
Description: "Name of the VM. If empty, defaults to 'templatename-<vmid>'",
},
"template_id": {
Type: schema.TypeInt,
Expand Down Expand Up @@ -184,7 +180,7 @@ func resourceOpennebulaVirtualMachine() *schema.Resource {
},
"gid": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
Description: "ID of the group that will own the VM",
},
"uname": {
Expand All @@ -210,29 +206,31 @@ func resourceOpennebulaVirtualMachine() *schema.Resource {
"cpu": {
Type: schema.TypeFloat,
Optional: true,
Computed: true,
Description: "Amount of CPU quota assigned to the virtual machine",
},
"vcpu": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
Description: "Number of virtual CPUs assigned to the virtual machine",
},
"memory": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
Description: "Amount of memory (RAM) in MB assigned to the virtual machine",
},
"context": {
Type: schema.TypeMap,
Optional: true,
Computed: true,
Description: "Context variables",
},
"disk": {
Type: schema.TypeList,
Optional: true,
//Computed: true,
MinItems: 0,
MaxItems: 8,
Type: schema.TypeList,
Optional: true,
Computed: true,
Description: "Definition of disks assigned to the Virtual Machine",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
Expand All @@ -242,25 +240,28 @@ func resourceOpennebulaVirtualMachine() *schema.Resource {
},
"size": {
Type: schema.TypeInt,
Computed: true,
Optional: true,
},
"target": {
Type: schema.TypeString,
Computed: true,
Optional: true,
},
"driver": {
Type: schema.TypeString,
Computed: true,
Optional: true,
},
},
},
},
"graphics": {
Type: schema.TypeSet,
Optional: true,
MinItems: 0,
MaxItems: 1,
//Computed: true,
Type: schema.TypeSet,
Optional: true,
Computed: true,
MinItems: 0,
MaxItems: 1,
Description: "Definition of graphics adapter assigned to the Virtual Machine",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
Expand All @@ -270,6 +271,7 @@ func resourceOpennebulaVirtualMachine() *schema.Resource {
},
"port": {
Type: schema.TypeString,
Computed: true,
Optional: true,
},
"type": {
Expand All @@ -285,24 +287,25 @@ func resourceOpennebulaVirtualMachine() *schema.Resource {
},
},
"nic": {
Type: schema.TypeList,
Optional: true,
//Computed: true,
MinItems: 0,
MaxItems: 8,
Type: schema.TypeList,
Optional: true,
Computed: true,
Description: "Definition of network adapter(s) assigned to the Virtual Machine",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"ip": {
Type: schema.TypeString,
Computed: true,
Optional: true,
},
"mac": {
Type: schema.TypeString,
Computed: true,
Optional: true,
},
"model": {
Type: schema.TypeString,
Computed: true,
Optional: true,
},
"network_id": {
Expand All @@ -315,11 +318,13 @@ func resourceOpennebulaVirtualMachine() *schema.Resource {
},
"physical_device": {
Type: schema.TypeString,
Computed: true,
Optional: true,
},
"security_groups": {
Type: schema.TypeList,
Optional: true,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
},
Expand All @@ -334,6 +339,7 @@ func resourceOpennebulaVirtualMachine() *schema.Resource {
"os": {
Type: schema.TypeSet,
Optional: true,
Computed: true,
MaxItems: 1,
//Computed: true,
Description: "Definition of OS boot and type for the Virtual Machine",
Expand All @@ -356,10 +362,9 @@ func resourceOpennebulaVirtualMachine() *schema.Resource {
Description: "Primary IP address assigned by OpenNebula",
},
"group": {
Type: schema.TypeString,
Optional: true,
ConflictsWith: []string{"gid"},
Description: "Name of the Group that onws the VM, If empty, it uses caller group",
Type: schema.TypeString,
Optional: true,
Description: "Name of the Group that onws the VM, If empty, it uses caller group",
},
},
}
Expand Down Expand Up @@ -527,7 +532,6 @@ func resourceOpennebulaVirtualMachineRead(d *schema.ResourceData, meta interface
}

d.SetId(fmt.Sprintf("%v", vm.ID))
d.Set("instance", vm.Name)
d.Set("name", vm.Name)
d.Set("uid", vm.UID)
d.Set("gid", vm.GID)
Expand Down
9 changes: 2 additions & 7 deletions opennebula/resource_opennebula_virtual_machine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ func TestAccVirtualMachine(t *testing.T) {
CheckDestroy: testAccCheckVirtualMachineDestroy,
Steps: []resource.TestStep{
{
Config: testAccVirtualMachineTemplateConfigBasic,
ExpectNonEmptyPlan: true,
Config: testAccVirtualMachineTemplateConfigBasic,
Check: resource.ComposeTestCheckFunc(
testAccSetDSdummy(),
resource.TestCheckResourceAttr("opennebula_virtual_machine.test", "name", "test-virtual_machine"),
Expand All @@ -34,7 +33,6 @@ func TestAccVirtualMachine(t *testing.T) {
resource.TestCheckResourceAttrSet("opennebula_virtual_machine.test", "gid"),
resource.TestCheckResourceAttrSet("opennebula_virtual_machine.test", "uname"),
resource.TestCheckResourceAttrSet("opennebula_virtual_machine.test", "gname"),
resource.TestCheckResourceAttrSet("opennebula_virtual_machine.test", "instance"),
testAccCheckVirtualMachinePermissions(&shared.Permissions{
OwnerU: 1,
OwnerM: 1,
Expand All @@ -44,8 +42,7 @@ func TestAccVirtualMachine(t *testing.T) {
),
},
{
Config: testAccVirtualMachineConfigUpdate,
ExpectNonEmptyPlan: true,
Config: testAccVirtualMachineConfigUpdate,
Check: resource.ComposeTestCheckFunc(
testAccSetDSdummy(),
resource.TestCheckResourceAttr("opennebula_virtual_machine.test", "name", "test-virtual_machine-renamed"),
Expand All @@ -57,7 +54,6 @@ func TestAccVirtualMachine(t *testing.T) {
resource.TestCheckResourceAttrSet("opennebula_virtual_machine.test", "gid"),
resource.TestCheckResourceAttrSet("opennebula_virtual_machine.test", "uname"),
resource.TestCheckResourceAttrSet("opennebula_virtual_machine.test", "gname"),
resource.TestCheckResourceAttrSet("opennebula_virtual_machine.test", "instance"),
testAccCheckVirtualMachinePermissions(&shared.Permissions{
OwnerU: 1,
OwnerM: 1,
Expand Down Expand Up @@ -90,7 +86,6 @@ func TestAccVirtualMachinePending(t *testing.T) {
resource.TestCheckResourceAttrSet("opennebula_virtual_machine.test", "gid"),
resource.TestCheckResourceAttrSet("opennebula_virtual_machine.test", "uname"),
resource.TestCheckResourceAttrSet("opennebula_virtual_machine.test", "gname"),
resource.TestCheckResourceAttrSet("opennebula_virtual_machine.test", "instance"),
testAccCheckVirtualMachinePermissions(&shared.Permissions{
OwnerU: 1,
OwnerM: 1,
Expand Down
Loading