7078N/A#!/usr/bin/python2.7
7078N/A
7078N/A# Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
7078N/A#
7078N/A# Licensed under the Apache License, Version 2.0 (the "License"); you may
7078N/A# not use this file except in compliance with the License. You may obtain
7078N/A# a copy of the License at
7078N/A#
7078N/A# http://www.apache.org/licenses/LICENSE-2.0
7078N/A#
7078N/A# Unless required by applicable law or agreed to in writing, software
7078N/A# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
7078N/A# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
7078N/A# License for the specific language governing permissions and limitations
7078N/A# under the License.
7078N/A
7078N/Aimport ConfigParser
7078N/Aimport os
7078N/Aimport sys
7078N/Aimport urllib2
7078N/A
7078N/Aimport smf_include
7078N/A
7078N/A
7078N/Adef start():
7078N/A
7078N/A # verify metadata service is reachable
7078N/A try:
7078N/A parser = ConfigParser.ConfigParser()
7078N/A parser.read('/etc/cloudbase-init.conf')
7078N/A if parser.has_option('DEFAULT', 'metadata_base_url'):
7078N/A url = parser.get('DEFAULT', 'metadata_base_url')
7078N/A else:
7078N/A url = 'http://169.254.169.254'
7078N/A open_url = urllib2.urlopen(url, timeout=20)
7078N/A except Exception as err:
7078N/A print >> sys.stderr, 'No response from %s: %s' % (url, err)
7078N/A return smf_include.SMF_EXIT_ERR_FATAL
7078N/A
7078N/A # Initiate cloudbase-init service
7078N/A cmd_str = "/usr/bin/cloudbase-init --debug"
7078N/A smf_include.smf_subprocess(cmd_str)
7078N/A
7078N/Aif __name__ == "__main__":
7078N/A os.putenv("LC_ALL", "C")
7078N/A smf_include.smf_main()