feat: describe-availbility-zones (#25)

This commit is contained in:
Julian Sommer
2026-02-09 09:47:20 +11:00
committed by GitHub
parent 1c2174a10f
commit ef87b41858
6 changed files with 70 additions and 23 deletions
+2 -2
View File
@@ -134,8 +134,8 @@ Instance `dmesg`:
| Command | Implemented Flags | Missing Flags | Prerequisites | Basic Logic | Test Cases | Status |
|---------|-------------------|---------------|---------------|-------------|------------|--------|
| `describe-regions` | *(returns configured region from config — all input params ignored)* | `--region-names`, `--filters`, `--all-regions`, `--dry-run` | None | Return configured region from hive init config (e.g. us-east-1) → local-only response, no NATS | 1. List all regions<br>2. Filter by region name<br>3. Verify endpoint URL returned | **DONE** |
| `describe-availability-zones` | — | `--zone-names`, `--filters`, `--all-availability-zones` | None | Return configured AZ from hive init (e.g. ap-southeast-2a) → single AZ for Hive v1 | 1. List all AZs<br>2. Filter by zone name<br>3. Verify zone state is available | **NOT STARTED** |
| `describe-regions` | *(returns configured region, endpoint, opt-in status from config — input params ignored)* | `--region-names`, `--filters`, `--all-regions`, `--dry-run` | None | Return configured region from hive init config with Endpoint and OptInStatus → local-only response, no NATS | 1. List all regions<br>2. Filter by region name<br>3. Verify endpoint URL returned<br>4. Verify OptInStatus returned | **DONE** |
| `describe-availability-zones` | *(returns configured AZ, region, zone ID, state, opt-in status from config — input params ignored)* | `--zone-names`, `--filters`, `--all-availability-zones` | None | Return configured AZ from hive init config with zone ID, state, group name, network border group → local-only response, no NATS | 1. List all AZs<br>2. Filter by zone name<br>3. Verify zone state is available<br>4. Verify region name matches config | **DONE** |
### EC2 - VPC Networking (Core)
+24 -2
View File
@@ -10,8 +10,8 @@ import (
gateway_ec2_image "github.com/mulgadc/hive/hive/gateway/ec2/image"
gateway_ec2_instance "github.com/mulgadc/hive/hive/gateway/ec2/instance"
gateway_ec2_key "github.com/mulgadc/hive/hive/gateway/ec2/key"
gateway_ec2_regions "github.com/mulgadc/hive/hive/gateway/ec2/regions"
gateway_ec2_volume "github.com/mulgadc/hive/hive/gateway/ec2/volume"
gateway_ec2_zone "github.com/mulgadc/hive/hive/gateway/ec2/zone"
"github.com/mulgadc/hive/hive/utils"
)
@@ -291,7 +291,7 @@ func (gw *GatewayConfig) EC2_Request(ctx *fiber.Ctx) error {
return err
}
output, err := gateway_ec2_regions.DescribeRegions(input, gw.Region)
output, err := gateway_ec2_zone.DescribeRegions(input, gw.Region)
if err != nil {
return err
@@ -305,6 +305,28 @@ func (gw *GatewayConfig) EC2_Request(ctx *fiber.Ctx) error {
return errors.New("failed to marshal response to XML")
}
case "DescribeAvailabilityZones":
var input = &ec2.DescribeAvailabilityZonesInput{}
err = awsec2query.QueryParamsToStruct(queryArgs, input)
if err != nil {
return err
}
output, err := gateway_ec2_zone.DescribeAvailabilityZones(input, gw.Region, gw.AZ)
if err != nil {
return err
}
// Convert to XML
payload := utils.GenerateXMLPayload("DescribeAvailabilityZonesResponse", output)
xmlOutput, err = utils.MarshalToXML(payload)
if err != nil {
return errors.New("failed to marshal response to XML")
}
case "DescribeVolumes":
var input = &ec2.DescribeVolumesInput{}
err = awsec2query.QueryParamsToStruct(queryArgs, input)
@@ -1,19 +0,0 @@
package gateway_ec2_regions
import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/ec2"
)
// uses the loaded config file to get the region.
func DescribeRegions(input *ec2.DescribeRegionsInput, region string) (output *ec2.DescribeRegionsOutput, err error) {
output = &ec2.DescribeRegionsOutput{
Regions: []*ec2.Region{
{
RegionName: aws.String(region),
},
}}
return output, nil
}
+42
View File
@@ -0,0 +1,42 @@
package gateway_ec2_zone
import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/ec2"
)
func DescribeAvailabilityZones(input *ec2.DescribeAvailabilityZonesInput, region string, az string) (output *ec2.DescribeAvailabilityZonesOutput, err error) {
output = &ec2.DescribeAvailabilityZonesOutput{
AvailabilityZones: []*ec2.AvailabilityZone{
{
State: aws.String("available"),
OptInStatus: aws.String("opt-in-not-required"),
RegionName: aws.String(region),
ZoneName: aws.String(az),
ZoneId: aws.String("hivez1"),
GroupName: aws.String(region),
NetworkBorderGroup: aws.String(region),
ZoneType: aws.String("availability-zone"),
Messages: []*ec2.AvailabilityZoneMessage{},
},
},
}
return output, nil
}
func DescribeRegions(input *ec2.DescribeRegionsInput, region string) (output *ec2.DescribeRegionsOutput, err error) {
output = &ec2.DescribeRegionsOutput{
Regions: []*ec2.Region{
{
Endpoint: aws.String("https://localhost:9999"),
RegionName: aws.String(region),
OptInStatus: aws.String("opt-in-not-required"),
},
},
}
return output, nil
}
+1
View File
@@ -26,6 +26,7 @@ type GatewayConfig struct {
Config string // Shared AWS Gateway config for S3 auth
ExpectedNodes int // Number of expected hive nodes for multi-node operations
Region string // Region this gateway is running in
AZ string // Availability zone this gateway is running in
AccessKey string // AWS Access Key ID for authentication
SecretKey string // AWS Secret Access Key for authentication
}
+1
View File
@@ -92,6 +92,7 @@ func launchService(config *config.ClusterConfig) (err error) {
Config: nodeConfig.AWSGW.Config,
ExpectedNodes: len(config.Nodes),
Region: nodeConfig.Region,
AZ: nodeConfig.AZ,
AccessKey: nodeConfig.AccessKey,
SecretKey: nodeConfig.SecretKey,
}