From f221bcf20e33aeac4cc9b26bc516495f0093f3f1 Mon Sep 17 00:00:00 2001 From: Alex Crawford Date: Fri, 10 Jun 2016 16:14:12 -0700 Subject: [PATCH 1/2] oem/azure: dynamically determine storage endpoint Apparently this differs between clouds. --- oem/azure/common.sh | 17 +++++++++++++++-- oem/azure/publish.sh | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/oem/azure/common.sh b/oem/azure/common.sh index 5cbb513a73..a0cb3f80f9 100644 --- a/oem/azure/common.sh +++ b/oem/azure/common.sh @@ -1,4 +1,3 @@ -AZURE_ENVIRONMENT=AzureCloud REGIONS=( "West Europe" "North Europe" @@ -24,11 +23,25 @@ REGIONS=( "UK South 2" ) +getAzureEnvironment() { + azure account show --json | \ + jq '.[0].environmentName' --raw-output +} + getManagementEndpoint() { - azure account env show --environment=$AZURE_ENVIRONMENT --json | \ + azure account env show --environment=$(getAzureEnvironment) --json | \ jq '.managementEndpointUrl' --raw-output } +getStorageEndpointPrefix() { + azure account env show --environment=$(getAzureEnvironment) --json | \ + jq '.storageEndpointSuffix' --raw-output +} + +getBlobStorageEndpoint() { + echo "blob$(getStorageEndpointPrefix)" +} + getSubscriptionId() { azure account show --json | \ jq '.[0].id' --raw-output diff --git a/oem/azure/publish.sh b/oem/azure/publish.sh index 43f680f800..b65ff781ef 100755 --- a/oem/azure/publish.sh +++ b/oem/azure/publish.sh @@ -61,7 +61,7 @@ azure storage blob copy start \ echo "Creating Azure image from blob..." azure vm image create \ - --blob-url="https://coreos.blob.core.windows.net/publish/coreos-${VERSION}-${LGROUP}.vhd" \ + --blob-url="https://coreos.$(getBlobStorageEndpoint)/publish/coreos-${VERSION}-${LGROUP}.vhd" \ --os="linux" \ --label="CoreOS ${UGROUP}" \ "CoreOS-${UGROUP}-${VERSION}" From 0cc64350dae33e776efd4fe13f41d5a0a90d1283 Mon Sep 17 00:00:00 2001 From: Alex Crawford Date: Fri, 10 Jun 2016 16:32:05 -0700 Subject: [PATCH 2/2] oem/azure: dynamically determine regions Rather than keeping this list up-to-date, we should just publish everywhere we can. --- oem/azure/common.sh | 29 ++++------------------------- oem/azure/replicate-image.sh | 2 +- 2 files changed, 5 insertions(+), 26 deletions(-) diff --git a/oem/azure/common.sh b/oem/azure/common.sh index a0cb3f80f9..08e040629f 100644 --- a/oem/azure/common.sh +++ b/oem/azure/common.sh @@ -1,28 +1,3 @@ -REGIONS=( - "West Europe" - "North Europe" - "East Asia" - "Southeast Asia" - "East US" - "West US" - "Japan East" - "Japan West" - "Central US" - "East US 2" - "Brazil South" - "North Central US" - "South Central US" - "Australia East" - "Australia Southeast" - "Central India" - "West India" - "South India" - "Canada Central" - "Canada East" - "UK North" - "UK South 2" -) - getAzureEnvironment() { azure account show --json | \ jq '.[0].environmentName' --raw-output @@ -46,3 +21,7 @@ getSubscriptionId() { azure account show --json | \ jq '.[0].id' --raw-output } + +getRegions() { + azure vm location list --json | jq '.[].name' --raw-output +} diff --git a/oem/azure/replicate-image.sh b/oem/azure/replicate-image.sh index 4de54a74cb..b47de4634b 100755 --- a/oem/azure/replicate-image.sh +++ b/oem/azure/replicate-image.sh @@ -27,7 +27,7 @@ fi requestBody=" " -for region in "${REGIONS[@]}"; do +for region in $(getRegions); do requestBody+="\n\t\t$region" done requestBody+="