mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-11 16:15:33 -06:00
Merge pull request #3035 from vmfarms/master
Add project parameter to more Cloudstack resources
This commit is contained in:
commit
23c1dba7a3
@ -61,6 +61,12 @@ func resourceCloudStackDisk() *schema.Resource {
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
|
||||
"project": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -74,6 +80,17 @@ func resourceCloudStackDiskCreate(d *schema.ResourceData, meta interface{}) erro
|
||||
// Create a new parameter struct
|
||||
p := cs.Volume.NewCreateVolumeParams(name)
|
||||
|
||||
// If there is a project supplied, we retreive and set the project id
|
||||
if project, ok := d.GetOk("project"); ok {
|
||||
// Retrieve the project UUID
|
||||
projectid, e := retrieveUUID(cs, "project", project.(string))
|
||||
if e != nil {
|
||||
return e.Error()
|
||||
}
|
||||
// Set the default project ID
|
||||
p.SetProjectid(projectid)
|
||||
}
|
||||
|
||||
// Retrieve the disk_offering UUID
|
||||
diskofferingid, e := retrieveUUID(cs, "disk_offering", d.Get("disk_offering").(string))
|
||||
if e != nil {
|
||||
@ -144,6 +161,7 @@ func resourceCloudStackDiskRead(d *schema.ResourceData, meta interface{}) error
|
||||
|
||||
setValueOrUUID(d, "disk_offering", v.Diskofferingname, v.Diskofferingid)
|
||||
setValueOrUUID(d, "zone", v.Zonename, v.Zoneid)
|
||||
setValueOrUUID(d, "project", v.Project, v.Projectid)
|
||||
|
||||
if v.Attached != "" {
|
||||
// Get the virtual machine details
|
||||
|
@ -32,6 +32,12 @@ func resourceCloudStackIPAddress() *schema.Resource {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
|
||||
"project": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -46,6 +52,17 @@ func resourceCloudStackIPAddressCreate(d *schema.ResourceData, meta interface{})
|
||||
// Create a new parameter struct
|
||||
p := cs.Address.NewAssociateIpAddressParams()
|
||||
|
||||
// If there is a project supplied, we retreive and set the project id
|
||||
if project, ok := d.GetOk("project"); ok {
|
||||
// Retrieve the project UUID
|
||||
projectid, e := retrieveUUID(cs, "project", project.(string))
|
||||
if e != nil {
|
||||
return e.Error()
|
||||
}
|
||||
// Set the default project ID
|
||||
p.SetProjectid(projectid)
|
||||
}
|
||||
|
||||
if network, ok := d.GetOk("network"); ok {
|
||||
// Retrieve the network UUID
|
||||
networkid, e := retrieveUUID(cs, "network", network.(string))
|
||||
@ -118,6 +135,8 @@ func resourceCloudStackIPAddressRead(d *schema.ResourceData, meta interface{}) e
|
||||
setValueOrUUID(d, "vpc", v.Name, f.Vpcid)
|
||||
}
|
||||
|
||||
setValueOrUUID(d, "project", f.Project, f.Projectid)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -57,6 +57,12 @@ func resourceCloudStackNetwork() *schema.Resource {
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
|
||||
"project": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -87,6 +93,17 @@ func resourceCloudStackNetworkCreate(d *schema.ResourceData, meta interface{}) e
|
||||
// Create a new parameter struct
|
||||
p := cs.Network.NewCreateNetworkParams(displaytext.(string), name, networkofferingid, zoneid)
|
||||
|
||||
// If there is a project supplied, we retreive and set the project id
|
||||
if project, ok := d.GetOk("project"); ok {
|
||||
// Retrieve the project UUID
|
||||
projectid, e := retrieveUUID(cs, "project", project.(string))
|
||||
if e != nil {
|
||||
return e.Error()
|
||||
}
|
||||
// Set the default project ID
|
||||
p.SetProjectid(projectid)
|
||||
}
|
||||
|
||||
// Get the network details from the CIDR
|
||||
m, err := parseCIDR(d.Get("cidr").(string))
|
||||
if err != nil {
|
||||
@ -152,6 +169,7 @@ func resourceCloudStackNetworkRead(d *schema.ResourceData, meta interface{}) err
|
||||
|
||||
setValueOrUUID(d, "network_offering", n.Networkofferingname, n.Networkofferingid)
|
||||
setValueOrUUID(d, "zone", n.Zonename, n.Zoneid)
|
||||
setValueOrUUID(d, "project", n.Project, n.Projectid)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -45,6 +45,11 @@ func resourceCloudStackVPC() *schema.Resource {
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
"project": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -75,6 +80,17 @@ func resourceCloudStackVPCCreate(d *schema.ResourceData, meta interface{}) error
|
||||
// Create a new parameter struct
|
||||
p := cs.VPC.NewCreateVPCParams(d.Get("cidr").(string), displaytext.(string), name, vpcofferingid, zoneid)
|
||||
|
||||
// If there is a project supplied, we retreive and set the project id
|
||||
if project, ok := d.GetOk("project"); ok {
|
||||
// Retrieve the project UUID
|
||||
projectid, e := retrieveUUID(cs, "project", project.(string))
|
||||
if e != nil {
|
||||
return e.Error()
|
||||
}
|
||||
// Set the default project ID
|
||||
p.SetProjectid(projectid)
|
||||
}
|
||||
|
||||
// Create the new VPC
|
||||
r, err := cs.VPC.CreateVPC(p)
|
||||
if err != nil {
|
||||
@ -115,6 +131,7 @@ func resourceCloudStackVPCRead(d *schema.ResourceData, meta interface{}) error {
|
||||
}
|
||||
|
||||
setValueOrUUID(d, "vpc_offering", o.Name, v.Vpcofferingid)
|
||||
setValueOrUUID(d, "project", v.Project, v.Projectid)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user