pull/3660/head
jasminSPC 10 years ago
parent fc4c88dc6d
commit fdffa25028

369
Godeps/Godeps.json generated

@ -1,5 +1,5 @@
{
"ImportPath": "github.com/mitchellh/packer",
"ImportPath": "github.com/StackPointCloud/packer",
"GoVersion": "go1.6",
"GodepVersion": "v74",
"Deps": [
@ -379,6 +379,371 @@
"ImportPath": "github.com/mitchellh/multistep",
"Rev": "162146fc57112954184d90266f4733e900ed05a5"
},
{
"ImportPath": "github.com/mitchellh/packer/builder/amazon/chroot",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/builder/amazon/common",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/builder/amazon/ebs",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/builder/amazon/instance",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/builder/azure/arm",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/builder/azure/common",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/builder/azure/common/constants",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/builder/azure/common/lin",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/builder/azure/common/logutil",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/builder/azure/common/template",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/builder/azure/pkcs12",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/builder/azure/pkcs12/rc2",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/builder/digitalocean",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/builder/docker",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/builder/file",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/builder/googlecompute",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/builder/null",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/builder/openstack",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/builder/parallels/common",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/builder/parallels/iso",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/builder/parallels/pvm",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/builder/qemu",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/builder/virtualbox/common",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/builder/virtualbox/iso",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/builder/virtualbox/ovf",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/builder/vmware/common",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/builder/vmware/iso",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/builder/vmware/vmx",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/command",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/common",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/common/ssh",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/common/uuid",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/communicator/none",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/communicator/ssh",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/communicator/winrm",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/fix",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/helper/communicator",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/helper/config",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/helper/flag-kv",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/helper/flag-slice",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/packer",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/packer/plugin",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/packer/rpc",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/post-processor/amazon-import",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/post-processor/artifice",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/post-processor/atlas",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/post-processor/checksum",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/post-processor/compress",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/post-processor/docker-import",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/post-processor/docker-push",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/post-processor/docker-save",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/post-processor/docker-tag",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/post-processor/shell-local",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/post-processor/vagrant",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/post-processor/vagrant-cloud",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/post-processor/vsphere",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/provisioner",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/provisioner/ansible",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/provisioner/ansible-local",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/provisioner/chef-client",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/provisioner/chef-solo",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/provisioner/file",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/provisioner/powershell",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/provisioner/puppet-masterless",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/provisioner/puppet-server",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/provisioner/salt-masterless",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/provisioner/shell",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/provisioner/shell-local",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/provisioner/windows-restart",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/provisioner/windows-shell",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/template",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/template/interpolate",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/packer/version",
"Comment": "v0.10.1-120-gc8f68af",
"Rev": "c8f68afa5c3b39259fd7ec74877ab80640358e0f"
},
{
"ImportPath": "github.com/mitchellh/panicwrap",
"Rev": "a1e50bc201f387747a45ffff020f1af2d8759e88"
@ -635,7 +1000,7 @@
},
{
"ImportPath": "github.com/profitbricks/profitbricks-sdk-go",
"Rev": "04e83add0882eb67a163231899300f97b91f248d"
"Rev": "9dea2c24a0dc0740d93fd621ce845a1faede6826"
}
]
}

@ -22,3 +22,12 @@ _testmain.go
*.exe
*.test
*.prof
/.idea/
.idea/compiler.xml
.idea/copyright/
.idea/encodings.xml
.idea/misc.xml
.idea/modules.xml
.idea/profitbricks-sdk-go.iml
.idea/vcs.xml
.idea/workspace.xml

@ -109,6 +109,63 @@ request := profitbricks.CreateDatacenterRequest{
response := profitbricks.CreateDatacenter(request)
```
## How To: Create Data Center with Multiple Resources
To create a complex Data Center you would do this. As you can see, you can create quite a few of the objects you will need later all in one request.:
```go
datacenter := model.Datacenter{
Properties: model.DatacenterProperties{
Name: "composite test",
Location:location,
},
Entities:model.DatacenterEntities{
Servers: &model.Servers{
Items:[]model.Server{
model.Server{
Properties: model.ServerProperties{
Name : "server1",
Ram: 2048,
Cores: 1,
},
Entities:model.ServerEntities{
Volumes: &model.AttachedVolumes{
Items:[]model.Volume{
model.Volume{
Properties: model.VolumeProperties{
Type_:"HDD",
Size:10,
Name:"volume1",
Image:"1f46a4a3-3f47-11e6-91c6-52540005ab80",
Bus:"VIRTIO",
ImagePassword:"test1234",
SshKeys: []string{"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCoLVLHON4BSK3D8L4H79aFo+0cj7VM2NiRR/K9wrfkK/XiTc7FlEU4Bs8WLZcsIOxbCGWn2zKZmrLaxYlY+/3aJrxDxXYCy8lRUMnqcQ2JCFY6tpZt/DylPhS9L6qYNpJ0F4FlqRsWxsjpF8TDdJi64k2JFJ8TkvX36P2/kqyFfI+N0/axgjhqV3BgNgApvMt9jxWB5gi8LgDpw9b+bHeMS7TrAVDE7bzT86dmfbTugtiME8cIday8YcRb4xAFgRH8XJVOcE3cs390V/dhgCKy1P5+TjQMjKbFIy2LJoxb7bd38kAl1yafZUIhI7F77i7eoRidKV71BpOZsaPEbWUP jasmin@Jasmins-MBP"},
},
},
},
},
Nics: &model.Nics{
Items: []model.Nic{
model.Nic{
Properties: model.NicProperties{
Name : "nic",
Lan : "1",
},
},
},
},
},
},
},
},
},
}
dc := CompositeCreateDatacenter(datacenter)
```
## How To: Delete Data Center
You will want to exercise a bit of caution here. Removing a data center will destroy all objects contained within that data center -- servers, volumes, snapshots, and so on.

@ -1,6 +1,9 @@
package profitbricks
import "encoding/json"
import (
"encoding/json"
"github.com/profitbricks/profitbricks-sdk-go/model"
)
type CreateDatacenterRequest struct {
DCProperties `json:"properties"`
@ -25,6 +28,12 @@ func CreateDatacenter(dc CreateDatacenterRequest) Instance {
return is_post(path, obj)
}
func CompositeCreateDatacenter(datacenter model.Datacenter) model.Datacenter {
obj, _ := json.Marshal(datacenter)
path := dc_col_path()
return is_composite_post(path, obj)
}
// GetDatacenter returns a Instance struct where id == dcid
func GetDatacenter(dcid string) Instance {
path := dc_path(dcid)

@ -0,0 +1,11 @@
package model
type AttachedVolumes struct {
Id string `json:"id,omitempty"`
Type_ string `json:"type,omitempty"`
Href string `json:"href,omitempty"`
Items []Volume `json:"items,omitempty"`
}

@ -0,0 +1,11 @@
package model
type BalancedNics struct {
Id string `json:"id,omitempty"`
Type_ string `json:"type,omitempty"`
Href string `json:"href,omitempty"`
Items []Nic `json:"items,omitempty"`
}

@ -0,0 +1,11 @@
package model
type Cdroms struct {
Id string `json:"id,omitempty"`
Type_ string `json:"type,omitempty"`
Href string `json:"href,omitempty"`
Items []Image `json:"items,omitempty"`
}

@ -0,0 +1,14 @@
package model
import "net/http"
type Datacenter struct {
Id string `json:"id,omitempty"`
Type_ string `json:"type,omitempty"`
Href string `json:"href,omitempty"`
Properties DatacenterProperties `json:"properties,omitempty"`
Entities DatacenterEntities `json:"entities,omitempty"`
Response string `json:"Response,omitempty"`
Headers *http.Header `json:"headers,omitempty"`
StatusCode int `json:"headers,omitempty"`
}

@ -0,0 +1,15 @@
package model
import (
"time"
)
type DatacenterElementMetadata struct {
CreatedDate time.Time `json:"createdDate,omitempty"`
CreatedBy string `json:"createdBy,omitempty"`
Etag string `json:"etag,omitempty"`
LastModifiedDate time.Time `json:"lastModifiedDate,omitempty"`
LastModifiedBy string `json:"lastModifiedBy,omitempty"`
State string `json:"state,omitempty"`
}

@ -0,0 +1,11 @@
package model
type DatacenterEntities struct {
Servers *Servers `json:"servers,omitempty"`
Volumes *Volumes `json:"volumes,omitempty"`
Loadbalancers *Loadbalancers `json:"loadbalancers,omitempty"`
Lans *Lans `json:"lans,omitempty"`
}

@ -0,0 +1,11 @@
package model
type DatacenterProperties struct {
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
Location string `json:"location,omitempty"`
Version int32 `json:"version,omitempty"`
}

@ -0,0 +1,11 @@
package model
type Datacenters struct {
Id string `json:"id,omitempty"`
Type_ string `json:"type,omitempty"`
Href string `json:"href,omitempty"`
Items []Datacenter `json:"items,omitempty"`
}

@ -0,0 +1,12 @@
package model
type FirewallRule struct {
Id string `json:"id,omitempty"`
Type_ string `json:"type,omitempty"`
Href string `json:"href,omitempty"`
Metadata DatacenterElementMetadata `json:"metadata,omitempty"`
Properties FirewallruleProperties `json:"properties,omitempty"`
}

@ -0,0 +1,11 @@
package model
type FirewallRules struct {
Id string `json:"id,omitempty"`
Type_ string `json:"type,omitempty"`
Href string `json:"href,omitempty"`
Items []FirewallRule `json:"items,omitempty"`
}

@ -0,0 +1,16 @@
package model
type FirewallruleProperties struct {
Name string `json:"name,omitempty"`
Protocol string `json:"protocol,omitempty"`
SourceMac string `json:"sourceMac,omitempty"`
SourceIp string `json:"sourceIp,omitempty"`
TargetIp string `json:"targetIp,omitempty"`
IcmpCode int32 `json:"icmpCode,omitempty"`
IcmpType int32 `json:"icmpType,omitempty"`
PortRangeStart int32 `json:"portRangeStart,omitempty"`
PortRangeEnd int32 `json:"portRangeEnd,omitempty"`
}

@ -0,0 +1,12 @@
package model
type Image struct {
Id string `json:"id,omitempty"`
Type_ string `json:"type,omitempty"`
Href string `json:"href,omitempty"`
Metadata DatacenterElementMetadata `json:"metadata,omitempty"`
Properties ImageProperties `json:"properties,omitempty"`
}

@ -0,0 +1,24 @@
package model
type ImageProperties struct {
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
Location string `json:"location,omitempty"`
Size int `json:"size,omitempty"`
CpuHotPlug bool `json:"cpuHotPlug,omitempty"`
CpuHotUnplug bool `json:"cpuHotUnplug,omitempty"`
RamHotPlug bool `json:"ramHotPlug,omitempty"`
RamHotUnplug bool `json:"ramHotUnplug,omitempty"`
NicHotPlug bool `json:"nicHotPlug,omitempty"`
NicHotUnplug bool `json:"nicHotUnplug,omitempty"`
DiscVirtioHotPlug bool `json:"discVirtioHotPlug,omitempty"`
DiscVirtioHotUnplug bool `json:"discVirtioHotUnplug,omitempty"`
DiscScsiHotPlug bool `json:"discScsiHotPlug,omitempty"`
DiscScsiHotUnplug bool `json:"discScsiHotUnplug,omitempty"`
LicenceType string `json:"licenceType,omitempty"`
ImageType string `json:"imageType,omitempty"`
Public bool `json:"public,omitempty"`
}

@ -0,0 +1,11 @@
package model
type Images struct {
Id string `json:"id,omitempty"`
Type_ string `json:"type,omitempty"`
Href string `json:"href,omitempty"`
Items []Image `json:"items,omitempty"`
}

@ -0,0 +1,13 @@
package model
type Lan struct {
Id string `json:"id,omitempty"`
Type_ string `json:"type,omitempty"`
Href string `json:"href,omitempty"`
Metadata DatacenterElementMetadata `json:"metadata,omitempty"`
Properties LanProperties `json:"properties,omitempty"`
Entities LanEntities `json:"entities,omitempty"`
}

@ -0,0 +1,8 @@
package model
type LanEntities struct {
Nics *LanNics `json:"nics,omitempty"`
}

@ -0,0 +1,11 @@
package model
type LanNics struct {
Id string `json:"id,omitempty"`
Type_ string `json:"type,omitempty"`
Href string `json:"href,omitempty"`
Items []Nic `json:"items,omitempty"`
}

@ -0,0 +1,9 @@
package model
type LanProperties struct {
Name string `json:"name,omitempty"`
Public bool `json:"public,omitempty"`
}

@ -0,0 +1,11 @@
package model
type Lans struct {
Id string `json:"id,omitempty"`
Type_ string `json:"type,omitempty"`
Href string `json:"href,omitempty"`
Items []Lan `json:"items,omitempty"`
}

@ -0,0 +1,13 @@
package model
type Loadbalancer struct {
Id string `json:"id,omitempty"`
Type_ string `json:"type,omitempty"`
Href string `json:"href,omitempty"`
Metadata DatacenterElementMetadata `json:"metadata,omitempty"`
Properties LoadbalancerProperties `json:"properties,omitempty"`
Entities LoadbalancerEntities `json:"entities,omitempty"`
}

@ -0,0 +1,8 @@
package model
type LoadbalancerEntities struct {
Balancednics *BalancedNics `json:"balancednics,omitempty"`
}

@ -0,0 +1,10 @@
package model
type LoadbalancerProperties struct {
Name string `json:"name,omitempty"`
Ip string `json:"ip,omitempty"`
Dhcp bool `json:"dhcp,omitempty"`
}

@ -0,0 +1,11 @@
package model
type Loadbalancers struct {
Id string `json:"id,omitempty"`
Type_ string `json:"type,omitempty"`
Href string `json:"href,omitempty"`
Items []Loadbalancer `json:"items,omitempty"`
}

@ -0,0 +1,10 @@
package model
type Nic struct {
Id string `json:"id,omitempty"`
Type_ string `json:"type,omitempty"`
Href string `json:"href,omitempty"`
// Metadata DatacenterElementMetadata `json:"metadata,omitempty"`
Properties NicProperties `json:"properties,omitempty"`
Entities *NicEntities `json:"entities,omitempty"`
}

@ -0,0 +1,5 @@
package model
type NicEntities struct {
Firewallrules *FirewallRules `json:"firewallrules,omitempty"`
}

@ -0,0 +1,13 @@
package model
type NicProperties struct {
Name string `json:"name,omitempty"`
Mac string `json:"mac,omitempty"`
Ips []string `json:"ips,omitempty"`
Dhcp bool `json:"dhcp,omitempty"`
Lan string `json:"lan,omitempty"`
FirewallActive bool `json:"firewallActive,omitempty"`
}

@ -0,0 +1,8 @@
package model
type Nics struct {
Id string `json:"id,omitempty"`
Type_ string `json:"type,omitempty"`
Href string `json:"href,omitempty"`
Items []Nic `json:"items,omitempty"`
}

@ -0,0 +1,5 @@
package model
type Properties struct {
Name string `json:"name,omitempty"`
}

@ -0,0 +1,7 @@
package model
type ResourceReference struct {
Id string `json:"id,omitempty"`
Type_ string `json:"type,omitempty"`
Href string `json:"href,omitempty"`
}

@ -0,0 +1,10 @@
package model
type Server struct {
Id string `json:"id,omitempty"`
Type_ string `json:"type,omitempty"`
Href string `json:"href,omitempty"`
//Metadata DatacenterElementMetadata `json:"metadata,omitempty"`
Properties ServerProperties `json:"properties,omitempty"`
Entities ServerEntities `json:"entities,omitempty"`
}

@ -0,0 +1,7 @@
package model
type ServerEntities struct {
Cdroms *Cdroms `json:"cdroms,omitempty"`
Volumes *AttachedVolumes `json:"volumes,omitempty"`
Nics *Nics `json:"nics,omitempty"`
}

@ -0,0 +1,9 @@
package model
type ServerProperties struct {
Name string `json:"name,omitempty"`
Cores int `json:"cores,omitempty"`
Ram int `json:"ram,omitempty"`
AvailabilityZone string `json:"availabilityZone,omitempty"`
VmState string `json:"vmState,omitempty"`
}

@ -0,0 +1,8 @@
package model
type Servers struct {
Id string `json:"id,omitempty"`
Type_ string `json:"type,omitempty"`
Href string `json:"href,omitempty"`
Items []Server `json:"items,omitempty"`
}

@ -0,0 +1,8 @@
package model
type Volume struct {
Id string `json:"id,omitempty"`
Type_ string `json:"type,omitempty"`
Href string `json:"href,omitempty"`
Properties VolumeProperties `json:"properties,omitempty"`
}

@ -0,0 +1,23 @@
package model
type VolumeProperties struct {
Name string `json:"name,omitempty"`
Type_ string `json:"type,omitempty"`
Size int `json:"size,omitempty"`
Image string `json:"image,omitempty"`
ImagePassword string `json:"imagePassword,omitempty"`
SshKeys []string `json:"sshKeys,omitempty"`
Bus string `json:"bus,omitempty"`
LicenceType string `json:"licenceType,omitempty"`
CpuHotPlug bool `json:"cpuHotPlug,omitempty"`
CpuHotUnplug bool `json:"cpuHotUnplug,omitempty"`
RamHotPlug bool `json:"ramHotPlug,omitempty"`
RamHotUnplug bool `json:"ramHotUnplug,omitempty"`
NicHotPlug bool `json:"nicHotPlug,omitempty"`
NicHotUnplug bool `json:"nicHotUnplug,omitempty"`
DiscVirtioHotPlug bool `json:"discVirtioHotPlug,omitempty"`
DiscVirtioHotUnplug bool `json:"discVirtioHotUnplug,omitempty"`
DiscScsiHotPlug bool `json:"discScsiHotPlug,omitempty"`
DiscScsiHotUnplug bool `json:"discScsiHotUnplug,omitempty"`
DeviceNumber int64 `json:"deviceNumber,omitempty"`
}

@ -0,0 +1,8 @@
package model
type Volumes struct {
Id string `json:"id,omitempty"`
Type_ string `json:"type,omitempty"`
Href string `json:"href,omitempty"`
Items []Volume `json:"items,omitempty"`
}

@ -6,6 +6,7 @@ import (
"io/ioutil"
"net/http"
"strings"
"github.com/profitbricks/profitbricks-sdk-go/model"
)
//FullHeader is the standard header to include with all http requests except is_patch and is_command
@ -110,6 +111,13 @@ func is_post(path string, jason []byte) Instance {
return toInstance(do(req))
}
func is_composite_post(path string, jason []byte) model.Datacenter {
url := mk_url(path)+ `?depth=` + Depth
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jason))
req.Header.Add("Content-Type", FullHeader)
return toDataCenter(do(req))
}
// is_command performs an http.NewRequest POST and returns a Resp struct
func is_command(path string, jason string) Resp {
url := mk_url(path)

@ -1,5 +1,5 @@
package profitbricks
func GetRequestStatus(path string) Instance {
func GetRequestStatus(path string)Instance{
return is_get(path)
}

@ -2,7 +2,10 @@ package profitbricks
import "net/http"
import "fmt"
import "encoding/json"
import (
"encoding/json"
"github.com/profitbricks/profitbricks-sdk-go/model"
)
func MkJson(i interface{}) string {
jason, err := json.MarshalIndent(&i, "", " ")
@ -52,6 +55,15 @@ func toInstance(resp Resp) Instance {
return ins
}
func toDataCenter(resp Resp) model.Datacenter {
var dc model.Datacenter
json.Unmarshal(resp.Body, &dc)
dc.Response = string(resp.Body)
dc.Headers = &resp.Headers
dc.StatusCode = resp.StatusCode
return dc
}
type Instance struct {
Id_Type_Href
MetaData StringMap `json:"metaData,omitempty"`

@ -49,12 +49,12 @@ func CreateSnapshot(dcid string, volid string, name string) Resp {
var path = volume_path(dcid, volid)
path = path + "/create-snapshot"
return is_command(path, "name="+name)
return is_command(path, "name=" + name)
}
func RestoreSnapshot(dcid string, volid string, snapshotId string) Resp {
var path = volume_path(dcid, volid)
path = path + "/restore-snapshot"
return is_command(path, "snapshotId="+snapshotId)
return is_command(path, "snapshotId=" + snapshotId)
}

Loading…
Cancel
Save