-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from crusoecloud/infiniband
Infiniband
- Loading branch information
Showing
13 changed files
with
350 additions
and
14 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# By default, all Crusoe Cloud devs are codeowners of a file | ||
* @crusoeenergy/island | ||
|
||
.gitlab/CODEOWNERS @lanwall12 @nitper @ksosnowski3 | ||
|
||
# More restrictive ownership for adding dependencies and changing ci/builds | ||
Makefile @lanwall12 @nitper @imackenzie @ksosnowski3 @agutierrez8 | ||
.golangci.yml @lanwall12 @nitper @imackenzie @ksosnowski3 @agutierrez8 | ||
.goreleaser.yml @lanwall12 @nitper @imackenzie @ksosnowski3 @agutierrez8 | ||
go.mod @lanwall12 @nitper @imackenzie @ksosnowski3 @agutierrez8 | ||
go.sum @lanwall12 @nitper @imackenzie @ksosnowski3 @agutierrez8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
terraform { | ||
required_providers { | ||
crusoe = { | ||
source = "registry.terraform.io/crusoecloud/crusoe" | ||
} | ||
} | ||
} | ||
|
||
locals { | ||
my_ssh_key = file("~/.ssh/id_ed25519.pub") | ||
} | ||
|
||
# list IB networks | ||
data "crusoe_ib_networks" "ib_networks" {} | ||
output "crusoe_ib" { | ||
value = data.crusoe_ib_networks.ib_networks | ||
} | ||
|
||
# create an IB partition to deploy VMs in | ||
resource "crusoe_ib_partition" "my_partition" { | ||
name = "my-ib-partition" | ||
|
||
# available IB network IDs can be listed by using the output | ||
# above. alternatively, they can be obtain with the CLI by | ||
# crusoe networking ib-network list | ||
ib_network_id = "<ib_network_id>" | ||
} | ||
|
||
# create two VMs, both in the same Infiniband partition | ||
resource "crusoe_compute_instance" "my_vm1" { | ||
count = 2 | ||
|
||
name = "ib-vm-${count.index}" | ||
type = "h100-80gb-hgx.8x" # IB enabled VM type | ||
ib_partition_id = crusoe_ib_partition.my_partition.id | ||
ssh_key = local.my_ssh_key | ||
|
||
disks = [ | ||
// disk attached at startup | ||
crusoe_storage_disk.data_disk | ||
] | ||
} | ||
|
||
# attached storage disk | ||
resource "crusoe_storage_disk" "data_disk" { | ||
name = "data-disk" | ||
size = "1TiB" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -211,10 +211,10 @@ func (r *firewallRuleResource) Read(ctx context.Context, req resource.ReadReques | |
//nolint:gocritic // Implements Terraform defined interface | ||
func (r *firewallRuleResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { | ||
// This should be unreachable, since all properties are marked as needing replacement on update. | ||
resp.Diagnostics.AddWarning("Updates not supported", | ||
"Updating firewall rules is not currently supported. If you're seeing this message, please reach out to"+ | ||
" [email protected] and let us know. In the meantime, you should be able to update your rule by"+ | ||
" deleting it and then creating a new one.") | ||
resp.Diagnostics.AddWarning("In-place updates not supported", | ||
"Updating firewall rules in-place is not currently supported. If you're seeing this message, please reach"+ | ||
" out to [email protected] and let us know. In the meantime, you should be able to update your"+ | ||
" rule by deleting it and then creating a new one.") | ||
} | ||
|
||
//nolint:gocritic // Implements Terraform defined interface | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
//nolint:gocritic // Implements Terraform defined interface | ||
package ib_network | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/hashicorp/terraform-plugin-framework/datasource" | ||
"github.com/hashicorp/terraform-plugin-framework/datasource/schema" | ||
|
||
swagger "github.com/crusoecloud/client-go/swagger/v1alpha4" | ||
"github.com/crusoecloud/terraform-provider-crusoe/internal" | ||
) | ||
|
||
type ibNetworksDataSource struct { | ||
client *swagger.APIClient | ||
} | ||
|
||
type ibNetworksDataSourceModel struct { | ||
IBNetworks []ibNetworkModel `tfsdk:"ib_networks"` | ||
} | ||
|
||
type ibNetworkModel struct { | ||
ID string `tfsdk:"id"` | ||
Name string `tfsdk:"name"` | ||
Location string `tfsdk:"location"` | ||
} | ||
|
||
func NewIBNetworkDataSource() datasource.DataSource { | ||
return &ibNetworksDataSource{} | ||
} | ||
|
||
// Configure adds the provider configured client to the data source. | ||
func (ds *ibNetworksDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { | ||
if req.ProviderData == nil { | ||
return | ||
} | ||
|
||
client, ok := req.ProviderData.(*swagger.APIClient) | ||
if !ok { | ||
resp.Diagnostics.AddError("Failed to initialize provider", internal.ErrorMsgProviderInitFailed) | ||
|
||
return | ||
} | ||
|
||
ds.client = client | ||
} | ||
|
||
func (ds *ibNetworksDataSource) Metadata(ctx context.Context, request datasource.MetadataRequest, response *datasource.MetadataResponse) { | ||
response.TypeName = request.ProviderTypeName + "_ib_networks" | ||
} | ||
|
||
func (ds *ibNetworksDataSource) Schema(ctx context.Context, request datasource.SchemaRequest, response *datasource.SchemaResponse) { | ||
response.Schema = schema.Schema{Attributes: map[string]schema.Attribute{ | ||
"ib_networks": schema.ListNestedAttribute{ | ||
Computed: true, | ||
NestedObject: schema.NestedAttributeObject{ | ||
Attributes: map[string]schema.Attribute{ | ||
"id": schema.StringAttribute{ | ||
Computed: true, | ||
}, | ||
"name": schema.StringAttribute{ | ||
Computed: true, | ||
}, | ||
"location": schema.StringAttribute{ | ||
Computed: true, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}} | ||
} | ||
|
||
func (ds *ibNetworksDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { | ||
dataResp, httpResp, err := ds.client.IBNetworksApi.GetIBNetworks(ctx) | ||
if err != nil { | ||
resp.Diagnostics.AddError("Failed to Fetch IB Networks", | ||
fmt.Sprintf("Could not fetch Infiniband network data at this time: %v", err)) | ||
|
||
return | ||
} | ||
defer httpResp.Body.Close() | ||
|
||
var state ibNetworksDataSourceModel | ||
for i := range dataResp.IbNetworks { | ||
state.IBNetworks = append(state.IBNetworks, ibNetworkModel{ | ||
ID: dataResp.IbNetworks[i].Id, | ||
Name: dataResp.IbNetworks[i].Name, | ||
Location: dataResp.IbNetworks[i].Location, | ||
}) | ||
} | ||
|
||
diags := resp.State.Set(ctx, &state) | ||
resp.Diagnostics.Append(diags...) | ||
} |
Oops, something went wrong.