Merge pull request #11 from joyent/5-uuid
Don't _require_ CNS be activated
This commit is contained in:
		
						commit
						031e98e50a
					
				| @ -68,11 +68,28 @@ function currentProfile () { | |||||||
|         local profile_source='default; use `triton profile set <profile name>` to change' |         local profile_source='default; use `triton profile set <profile name>` to change' | ||||||
|     fi |     fi | ||||||
| 
 | 
 | ||||||
|     echo "Executing in '$(triton profile get | awk 'NR == 1 {print $2}')' (${profile_source})" |     # Get and the user's account information and CloudAPI URL for parsing later | ||||||
|  |     local triton_account="$(triton account get)" | ||||||
|  | 
 | ||||||
|  |     echo "Executing in '$(echo "${triton_account}" | awk 'NR == 1 {print $2}')' (${profile_source})" | ||||||
|  | 
 | ||||||
|  |     # Check if CNS is enabled, require it | ||||||
|  |     if [ ! "true" == "$(echo "${triton_account}" | awk -F": " '/^triton_cns_enabled:/{print $2}')" ] | ||||||
|  |     then | ||||||
|  |         echo | ||||||
|  |         tput rev  # reverse | ||||||
|  |         tput bold # bold | ||||||
|  |         echo 'Warning! Triton CNS is not enabled.' | ||||||
|  |         tput sgr0 # clear | ||||||
|  |         echo | ||||||
|  |         echo 'Please run the following to activate:' | ||||||
|  |         echo '  triton account update triton_cns_enabled=true' | ||||||
|  |         echo | ||||||
|  |     fi | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| # Set env vars to make using CNS easier | # Set env vars to make using CNS easier | ||||||
| function CnsEnvVars () { | function cnsEnvVars () { | ||||||
| 
 | 
 | ||||||
|     # If the CNS env vars are already set, don't bother continuing |     # If the CNS env vars are already set, don't bother continuing | ||||||
|     if [ -n "$TRITON_CNS_SEARCH_DOMAIN_PUBLIC" ] && [ -n "$TRITON_CNS_SEARCH_DOMAIN_PRIVATE" ] |     if [ -n "$TRITON_CNS_SEARCH_DOMAIN_PUBLIC" ] && [ -n "$TRITON_CNS_SEARCH_DOMAIN_PRIVATE" ] | ||||||
| @ -85,29 +102,13 @@ function CnsEnvVars () { | |||||||
|     local triton_url="$(triton profile get | awk -F"/" '/url:/{print $3}')" |     local triton_url="$(triton profile get | awk -F"/" '/url:/{print $3}')" | ||||||
| 
 | 
 | ||||||
|     # Do not continue if the target is not a Triton Public Cloud data center |     # Do not continue if the target is not a Triton Public Cloud data center | ||||||
|     if [ ! "api.joyent.com" == "$(echo "${triton_url}" | awk -F'.' '{print $2 "." $3 "." $4}')" ] |     if [ ! ".api.joyent.com" == "${triton_url: -15}" ] | ||||||
|     then |     then | ||||||
|         return |         return | ||||||
|     fi |     fi | ||||||
| 
 | 
 | ||||||
|     # Check if CNS is enabled, require it |  | ||||||
|     local triton_cns_enabled="$(echo "${triton_account}" | awk -F": " '/cns/{print $2}')" |  | ||||||
|     if [ ! "true" == "$triton_cns_enabled" ] |  | ||||||
|     then |  | ||||||
|         echo |  | ||||||
|         tput rev  # reverse |  | ||||||
|         tput bold # bold |  | ||||||
|         echo 'Error! Triton CNS is required and not enabled.' |  | ||||||
|         tput sgr0 # clear |  | ||||||
|         echo |  | ||||||
|         echo 'Please run:' |  | ||||||
|         echo '  triton account update triton_cns_enabled=true' |  | ||||||
|         echo |  | ||||||
|         exit 1 |  | ||||||
|     fi |  | ||||||
| 
 |  | ||||||
|     # Get the user's UUID |     # Get the user's UUID | ||||||
|     local triton_account_uuid="$(echo "${triton_account}" | awk -F": " '/id:/{print $2}')" |     local triton_account_uuid="$(echo "${triton_account}" | awk -F": " '/^id:/{print $2}')" | ||||||
| 
 | 
 | ||||||
|     # Get current data center name |     # Get current data center name | ||||||
|     # Note: this makes assumptions that work in our public cloud, but might not work elsewhere |     # Note: this makes assumptions that work in our public cloud, but might not work elsewhere | ||||||
| @ -115,6 +116,7 @@ function CnsEnvVars () { | |||||||
|     local triton_dc="$(echo "${triton_url}" | awk -F'.' '{print $1}')" |     local triton_dc="$(echo "${triton_url}" | awk -F'.' '{print $1}')" | ||||||
| 
 | 
 | ||||||
|     # Set the CNS base for public and private names |     # Set the CNS base for public and private names | ||||||
|  |     # Note, this also makes assumptions that only work in our public cloud | ||||||
|     export TRITON_CNS_SEARCH_DOMAIN_PUBLIC="${triton_account_uuid}.${triton_dc}.triton.zone" |     export TRITON_CNS_SEARCH_DOMAIN_PUBLIC="${triton_account_uuid}.${triton_dc}.triton.zone" | ||||||
|     export TRITON_CNS_SEARCH_DOMAIN_PRIVATE="${triton_account_uuid}.${triton_dc}.cns.joyent.com" |     export TRITON_CNS_SEARCH_DOMAIN_PRIVATE="${triton_account_uuid}.${triton_dc}.cns.joyent.com" | ||||||
| } | } | ||||||
| @ -137,14 +139,14 @@ case "$(basename $0)" in | |||||||
|     triton-docker) |     triton-docker) | ||||||
|         checkAll && |         checkAll && | ||||||
|         eval "$(triton env)" && |         eval "$(triton env)" && | ||||||
|         CnsEnvVars && |         cnsEnvVars && | ||||||
|         exec /usr/local/bin/triton-docker-helper $@ |         exec /usr/local/bin/triton-docker-helper $@ | ||||||
|         ;; |         ;; | ||||||
|     triton-compose) |     triton-compose) | ||||||
|         checkAll && |         checkAll && | ||||||
|         eval "$(triton env)" && |         eval "$(triton env)" && | ||||||
|         export COMPOSE_HTTP_TIMEOUT=750 && |         export COMPOSE_HTTP_TIMEOUT=750 && | ||||||
|         CnsEnvVars && |         cnsEnvVars && | ||||||
|         exec /usr/local/bin/triton-compose-helper $@ |         exec /usr/local/bin/triton-compose-helper $@ | ||||||
|         ;; |         ;; | ||||||
|     triton-docker-install) |     triton-docker-install) | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user