Commit 2812936d authored by Justin Santa Barbara's avatar Justin Santa Barbara

Simplify logic of pd.go

parent 6a4153fc
......@@ -240,9 +240,9 @@ func newAWSCloud(config io.Reader, authFunc AuthFunc, instanceId string, metadat
ec2 := &goamzEC2{ec2: ec2.New(auth, region)}
awsCloud := &AWSCloud{
ec2: ec2,
cfg: cfg,
region: region,
ec2: ec2,
cfg: cfg,
region: region,
availabilityZone: zone,
}
......
......@@ -186,16 +186,14 @@ func createPD() (string, error) {
return "", err
}
return pdName, nil
} else if testContext.provider == "aws" {
} else {
volumes, ok := testContext.cloudConfig.Provider.(aws_cloud.Volumes)
if !ok {
return "", fmt.Errorf("Provider does not implement volumes interface")
return "", fmt.Errorf("Provider does not support volumes")
}
volumeOptions := &aws_cloud.VolumeOptions{}
volumeOptions.CapacityMB = 10 * 1024
return volumes.CreateVolume(volumeOptions)
} else {
return "", fmt.Errorf("Unsupported provider type")
}
}
......@@ -205,14 +203,12 @@ func deletePD(pdName string) error {
// TODO: make this hit the compute API directly.
return exec.Command("gcloud", "compute", "disks", "delete", "--zone="+zone, pdName).Run()
} else if testContext.provider == "aws" {
} else {
volumes, ok := testContext.cloudConfig.Provider.(aws_cloud.Volumes)
if !ok {
return fmt.Errorf("Provider does not implement volumes interface")
return "", fmt.Errorf("Provider does not support volumes")
}
return volumes.DeleteVolume(pdName)
} else {
return fmt.Errorf("Unsupported provider type")
}
}
......@@ -224,14 +220,12 @@ func detachPD(hostName, pdName string) error {
// TODO: make this hit the compute API directly.
return exec.Command("gcloud", "compute", "instances", "detach-disk", "--zone="+zone, "--disk="+pdName, instanceName).Run()
} else if testContext.provider == "aws" {
} else {
volumes, ok := testContext.cloudConfig.Provider.(aws_cloud.Volumes)
if !ok {
return fmt.Errorf("Provider does not implement volumes interface")
return "", fmt.Errorf("Provider does not support volumes")
}
return volumes.DetachDisk(hostName, pdName)
} else {
return fmt.Errorf("Unsupported provider type")
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment