summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYue Luo <yueluo@google.com>2014-04-09 15:30:19 -0700
committerYue Luo <yueluo@google.com>2014-04-09 15:30:19 -0700
commit81d10811ad14c82fb7df02f36190b7fa14d4fd64 (patch)
treec2d9402dbcd0d61e0b355a2807d48bf0230fc696
parentcccaa77c11ca33ed3cf40ce35346256a2af56a74 (diff)
parent5a860dfce4bf7ffd7c270ae270a7176110272ebb (diff)
downloadgoogle-compute-image-packages-81d10811ad14c82fb7df02f36190b7fa14d4fd64.tar.gz
Merge pull request #61 from yueluog/master
Switch to IP address to access metadata server.
-rwxr-xr-xgcimagebundle/gcimagebundlelib/tests/image_bundle_test_base.py6
-rw-r--r--gcimagebundle/gcimagebundlelib/utils.py8
-rw-r--r--google-daemon/usr/share/google/google_daemon/address_manager.py2
-rwxr-xr-xgoogle-daemon/usr/share/google/google_daemon/desired_accounts.py7
-rw-r--r--google-startup-scripts/README.md2
-rwxr-xr-xgoogle-startup-scripts/usr/share/google/boto/boot_setup.py2
-rw-r--r--google-startup-scripts/usr/share/google/boto/boto_plugins/compute_auth.py2
-rwxr-xr-xgoogle-startup-scripts/usr/share/google/get_metadata_value2
8 files changed, 17 insertions, 14 deletions
diff --git a/gcimagebundle/gcimagebundlelib/tests/image_bundle_test_base.py b/gcimagebundle/gcimagebundlelib/tests/image_bundle_test_base.py
index a716a10..4c3c1ad 100755
--- a/gcimagebundle/gcimagebundlelib/tests/image_bundle_test_base.py
+++ b/gcimagebundle/gcimagebundlelib/tests/image_bundle_test_base.py
@@ -64,10 +64,10 @@ class MockHttp(utils.Http):
def Get(self, request):
"""Accepts an Http request and returns a precanned response."""
url = request.get_full_url()
- if url == 'http://metadata/computeMetadata/':
+ if url == utils.METADATA_URL_PREFIX:
return 'v1/'
- elif url.startswith('http://metadata/computeMetadata/v1/'):
- url = url.replace('http://metadata/computeMetadata/v1/', '')
+ elif url.startswith(utils.METADATA_V1_URL_PREFIX):
+ url = url.replace(utils.METADATA_V1_URL_PREFIX, '')
if url == 'instance/?recursive=true':
return self._instance_response
raise urllib2.HTTPError
diff --git a/gcimagebundle/gcimagebundlelib/utils.py b/gcimagebundle/gcimagebundlelib/utils.py
index bee7ad6..295b52d 100644
--- a/gcimagebundle/gcimagebundlelib/utils.py
+++ b/gcimagebundle/gcimagebundlelib/utils.py
@@ -21,6 +21,9 @@ import subprocess
import time
import urllib2
+METADATA_URL_PREFIX = 'http://169.254.169.254/computeMetadata/'
+METADATA_V1_URL_PREFIX = METADATA_URL_PREFIX + 'v1/'
+
class MakeFileSystemException(Exception):
"""Error occurred in file system creation."""
@@ -397,7 +400,7 @@ class Http(object):
Args:
url_path: The path of the metadata url after the api version.
- http://metadata/computeMetadata/v1/url_path
+ http://169.254.169.254/computeMetadata/v1/url_path
recursive: If set, returns the tree of metadata starting at url_path as
a json string.
Returns:
@@ -405,11 +408,10 @@ class Http(object):
"""
# Use the latest version of the metadata.
- base_url = 'http://metadata/computeMetadata/v1/'
suffix = ''
if recursive:
suffix = '?recursive=true'
- url = '{0}{1}{2}'.format(base_url, url_path, suffix)
+ url = '{0}{1}{2}'.format(METADATA_V1_URL_PREFIX, url_path, suffix)
request = urllib2.Request(url)
request.add_unredirected_header('X-Google-Metadata-Request', 'True')
return self.Get(request)
diff --git a/google-daemon/usr/share/google/google_daemon/address_manager.py b/google-daemon/usr/share/google/google_daemon/address_manager.py
index 1b3997c..71f8dd0 100644
--- a/google-daemon/usr/share/google/google_daemon/address_manager.py
+++ b/google-daemon/usr/share/google/google_daemon/address_manager.py
@@ -36,7 +36,7 @@ import time
import urllib2
PUBLIC_ENDPOINT_URL_PREFIX = (
-'http://metadata/computeMetadata/v1/instance/network-interfaces/0/forwarded-ips/?recursive=true&alt=text&wait_for_change=true&timeout_sec=60&last_etag=')
+'http://169.254.169.254/computeMetadata/v1/instance/network-interfaces/0/forwarded-ips/?recursive=true&alt=text&wait_for_change=true&timeout_sec=60&last_etag=')
GOOGLE_PROTO_ID = 66 # "GG"
class InputError(Exception):
diff --git a/google-daemon/usr/share/google/google_daemon/desired_accounts.py b/google-daemon/usr/share/google/google_daemon/desired_accounts.py
index 076e37a..702741d 100755
--- a/google-daemon/usr/share/google/google_daemon/desired_accounts.py
+++ b/google-daemon/usr/share/google/google_daemon/desired_accounts.py
@@ -20,11 +20,12 @@ import time
import urllib2
-ATTRIBUTES_URL = ('http://metadata/computeMetadata/v1/?recursive=true&%s')
+METADATA_V1_URL_PREFIX = 'http://169.254.169.254/computeMetadata/v1/'
+ATTRIBUTES_URL = METADATA_V1_URL_PREFIX + '?recursive=true&%s'
INSTANCE_SSHKEYS_URL = (
- 'http://metadata/computeMetadata/v1/instance/attributes/sshKeys?%s')
+ METADATA_V1_URL_PREFIX + 'instance/attributes/sshKeys?%s')
PROJECT_SSHKEYS_URL = (
- 'http://metadata/computeMetadata/v1/project/attributes/sshKeys?%s')
+ METADATA_V1_URL_PREFIX + 'project/attributes/sshKeys?%s')
WAIT_FOR_CHANGE = 'wait_for_change=true&last_etag=%s&timeout_sec=%s'
diff --git a/google-startup-scripts/README.md b/google-startup-scripts/README.md
index 76c79eb..b9199a7 100644
--- a/google-startup-scripts/README.md
+++ b/google-startup-scripts/README.md
@@ -35,7 +35,7 @@ Google startup scripts also perform the following actions:
Startup scripts check the value of the instance ID at:
- http://metadata/computeMetadata/v1/instance/id
+ http://169.254.169.254/computeMetadata/v1/instance/id
and compares it to the last instance ID the disk booted on.
diff --git a/google-startup-scripts/usr/share/google/boto/boot_setup.py b/google-startup-scripts/usr/share/google/boto/boot_setup.py
index 8ff772b..ed8d7b3 100755
--- a/google-startup-scripts/usr/share/google/boto/boot_setup.py
+++ b/google-startup-scripts/usr/share/google/boto/boot_setup.py
@@ -29,7 +29,7 @@ import sys
import textwrap
import urllib2
-NUMERIC_PROJECT_ID_URL=('http://metadata.google.internal/'
+NUMERIC_PROJECT_ID_URL=('http://169.254.169.254/'
'computeMetadata/v1/project/numeric-project-id')
SYSTEM_BOTO_CONFIG_TEMPLATE='/etc/boto.cfg.template'
SYSTEM_BOTO_CONFIG='/etc/boto.cfg'
diff --git a/google-startup-scripts/usr/share/google/boto/boto_plugins/compute_auth.py b/google-startup-scripts/usr/share/google/boto/boto_plugins/compute_auth.py
index 989d674..0cefa40 100644
--- a/google-startup-scripts/usr/share/google/boto/boto_plugins/compute_auth.py
+++ b/google-startup-scripts/usr/share/google/boto/boto_plugins/compute_auth.py
@@ -21,7 +21,7 @@ from boto.auth_handler import AuthHandler
from boto.auth_handler import NotReadyToAuthenticate
META_DATA_SERVER_BASE_URL=(
- 'http://metadata.google.internal/computeMetadata/v1')
+ 'http://169.254.169.254/computeMetadata/v1')
SERVICE_ACCOUNT_SCOPES_URL=(META_DATA_SERVER_BASE_URL +
'/instance/service-accounts/%s/scopes?alt=json')
diff --git a/google-startup-scripts/usr/share/google/get_metadata_value b/google-startup-scripts/usr/share/google/get_metadata_value
index fccf7be..14a80cd 100755
--- a/google-startup-scripts/usr/share/google/get_metadata_value
+++ b/google-startup-scripts/usr/share/google/get_metadata_value
@@ -16,7 +16,7 @@
# Get a metadata value from the metadata server.
declare -r VARNAME=$1
-declare -r MDS=http://metadata.google.internal/0.1/meta-data
+declare -r MDS=http://169.254.169.254/0.1/meta-data
declare -r MDS_TRIES=${MDS_TRIES:-100}
function get_metadata_value() {