Skip to content

Commit

Permalink
Removes dead code, prepares vswitch resource stubs with new Terraform…
Browse files Browse the repository at this point in the history
… plugin API
  • Loading branch information
c4milo committed Sep 19, 2014
1 parent 0d583f9 commit 391b6b0
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 123 deletions.
9 changes: 0 additions & 9 deletions provider/config.go

This file was deleted.

17 changes: 15 additions & 2 deletions provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,24 @@
package provider

import (
"fmt"
"log"
"os"

"github.com/hashicorp/terraform/helper/schema"
)

type Config struct {
Product string
VerifySSL bool
}

func init() {
// Terraform is already adding the timestamp for us
log.SetFlags(log.Lshortfile)
log.SetPrefix(fmt.Sprintf("pid-%d-", os.Getpid()))
}

func Provider() *schema.Provider {
return &schema.Provider{
Schema: map[string]*schema.Schema{
Expand All @@ -23,8 +36,8 @@ func Provider() *schema.Provider {
},

ResourcesMap: map[string]*schema.Resource{
"vix_vm": resourceVixVm(),
//"vix_vswitch": resourceVixVSwitch(),
"vix_vm": resourceVIXVM(),
"vix_vswitch": resourceVIXVSwitch(),
},

ConfigureFunc: providerConfigure,
Expand Down
22 changes: 11 additions & 11 deletions provider/resource_vix_vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ import (
"github.com/hashicorp/terraform/helper/schema"
)

func resourceVixVm() *schema.Resource {
func resourceVIXVM() *schema.Resource {
return &schema.Resource{
Create: resourceVixVmCreate,
Read: resourceVixVmRead,
Update: resourceVixVmUpdate,
Delete: resourceVixVmDelete,
Create: resourceVIXVMCreate,
Read: resourceVIXVMRead,
Update: resourceVIXVMUpdate,
Delete: resourceVIXVMDelete,

Schema: map[string]*schema.Schema{
"name": &schema.Schema{
Expand Down Expand Up @@ -400,7 +400,7 @@ func net_vix_to_tf(vm *vix.VM, d *schema.ResourceData) error {
return nil
}

func resourceVixVmCreate(d *schema.ResourceData, meta interface{}) error {
func resourceVIXVMCreate(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)

vm := new(vix.VM)
Expand All @@ -425,10 +425,10 @@ func resourceVixVmCreate(d *schema.ResourceData, meta interface{}) error {
"host": vm.IPAddress,
})

return resourceVixVmRead(d, meta)
return resourceVIXVMRead(d, meta)
}

func resourceVixVmUpdate(d *schema.ResourceData, meta interface{}) error {
func resourceVIXVMUpdate(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)

vm := new(vix.VM)
Expand All @@ -443,10 +443,10 @@ func resourceVixVmUpdate(d *schema.ResourceData, meta interface{}) error {
return err
}

return resourceVixVmRead(d, meta)
return resourceVIXVMRead(d, meta)
}

func resourceVixVmDelete(d *schema.ResourceData, meta interface{}) error {
func resourceVIXVMDelete(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
vmxFile := d.Id()

Expand All @@ -461,7 +461,7 @@ func resourceVixVmDelete(d *schema.ResourceData, meta interface{}) error {
return vm.Destroy(vmxFile)
}

func resourceVixVmRead(d *schema.ResourceData, meta interface{}) error {
func resourceVIXVMRead(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)

vmxFile := d.Id()
Expand Down
110 changes: 44 additions & 66 deletions provider/resource_vix_vswitch.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,84 +3,62 @@
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
package provider

import (
"github.com/cloudescape/govix"
"github.com/hashicorp/terraform/helper/config"
"github.com/hashicorp/terraform/helper/diff"
"github.com/hashicorp/terraform/terraform"
)

func resource_vix_vswitch_validation() *config.Validator {
return &config.Validator{
Required: []string{
"name",
},

Optional: []string{
"nat",
"dhcp",
"range",
"host_access",
import "github.com/hashicorp/terraform/helper/schema"

func resourceVIXVSwitch() *schema.Resource {
return &schema.Resource{
Create: resourceVIXVSwitchCreate,
Read: resourceVIXVSwitchRead,
Update: resourceVIXVSwitchUpdate,
Delete: resourceVIXVSwitchDelete,

Schema: map[string]*schema.Schema{
"name": &schema.Schema{
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"nat": &schema.Schema{
Type: schema.TypeBool,
Optional: true,
Default: true,
},
"dhcp": &schema.Schema{
Type: schema.TypeBool,
Optional: true,
Default: true,
},
"host_access": &schema.Schema{
Type: schema.TypeBool,
Optional: true,
Default: true,
},
"range": &schema.Schema{
Type: schema.TypeString,
Optional: true,
},
},
}
}

func resource_vix_vswitch_create(
s *terraform.ResourceState,
d *terraform.ResourceDiff,
meta interface{}) (*terraform.ResourceState, error) {
//p := meta.(*ResourceProvider)

return nil, nil
}

func resource_vix_vswitch_update(
s *terraform.ResourceState,
d *terraform.ResourceDiff,
meta interface{}) (*terraform.ResourceState, error) {
//p := meta.(*ResourceProvider)

return nil, nil
}

func resource_vix_vswitch_destroy(
s *terraform.ResourceState,
meta interface{}) error {
// p := meta.(*ResourceProvider)
// client := p.client
func resourceVIXVSwitchCreate(d *schema.ResourceData, meta interface{}) error {
//config := meta.(*Config)

return nil
}

func resource_vix_vswitch_diff(
s *terraform.ResourceState,
c *terraform.ResourceConfig,
meta interface{}) (*terraform.ResourceDiff, error) {

b := &diff.ResourceBuilder{
// We have to choose whether a change in an attribute triggers a new
// resource creation or updates the existing resource.
Attrs: map[string]diff.AttrType{
"nat": diff.AttrTypeUpdate,
"dhcp": diff.AttrTypeUpdate,
"range": diff.AttrTypeUpdate,
"host_access": diff.AttrTypeUpdate,
},
}

return b.Diff(s, c)
func resourceVIXVSwitchRead(d *schema.ResourceData, meta interface{}) error {
return nil
}

func resource_vix_vswitch_refresh(
s *terraform.ResourceState,
meta interface{}) (*terraform.ResourceState, error) {
func resourceVIXVSwitchUpdate(d *schema.ResourceData, meta interface{}) error {
//config := meta.(*Config)

return nil, nil
return nil
}

func resource_vix_vswitch_update_state(
s *terraform.ResourceState,
vswitch *vix.VSwitch) (*terraform.ResourceState, error) {
func resourceVIXVSwitchDelete(d *schema.ResourceData, meta interface{}) error {
//config := meta.(*Config)

return nil, nil
return nil
}
35 changes: 0 additions & 35 deletions provider/resources.go

This file was deleted.

0 comments on commit 391b6b0

Please sign in to comment.