예제 #1
0
 def post_start(self):
     if not sh.isfile(self.init_fn) and self.get_bool_option('do-init'):
         self.wait_active()
         LOG.info("Running commands to initialize keystone.")
         (fn, contents) = utils.load_template(self.name, INIT_WHAT_FN)
         LOG.debug("Initializing with contents of %s", fn)
         params = {}
         params['keystone'] = khelper.get_shared_params(**utils.merge_dicts(self.options, khelper.get_shared_passwords(self)))
         params['glance'] = ghelper.get_shared_params(ip=self.get_option('ip'), **self.get_option('glance'))
         params['nova'] = nhelper.get_shared_params(ip=self.get_option('ip'), **self.get_option('nova'))
         params['neutron'] = net_helper.get_shared_params(ip=self.get_option('ip'), **self.get_option('neutron'))
         params['cinder'] = chelper.get_shared_params(ip=self.get_option('ip'), **self.get_option('cinder'))
         wait_urls = [
             params['keystone']['endpoints']['admin']['uri'],
             params['keystone']['endpoints']['public']['uri'],
         ]
         for url in wait_urls:
             utils.wait_for_url(url)
         init_what = utils.load_yaml_text(contents)
         init_what = utils.expand_template_deep(init_what, params)
         try:
             init_how = khelper.Initializer(params['keystone']['service_token'],
                                            params['keystone']['endpoints']['admin']['uri'])
             init_how.initialize(**init_what)
         except RuntimeError:
             LOG.exception("Failed to initialize keystone, is the keystone client library available?")
         else:
             # Writing this makes sure that we don't init again
             sh.write_file(self.init_fn, utils.prettify_yaml(init_what))
             LOG.info("If you wish to re-run initialization, delete %s", colorizer.quote(self.init_fn))
예제 #2
0
 def post_start(self):
     if not sh.isfile(self.init_fn) and self.get_bool_option('do-init'):
         self.wait_active()
         LOG.info("Running commands to initialize keystone.")
         (fn, contents) = utils.load_template(self.name, INIT_WHAT_FN)
         LOG.debug("Initializing with contents of %s", fn)
         params = {}
         params['keystone'] = khelper.get_shared_params(**utils.merge_dicts(self.options, khelper.get_shared_passwords(self)))
         params['glance'] = ghelper.get_shared_params(ip=self.get_option('ip'), **self.get_option('glance'))
         params['nova'] = nhelper.get_shared_params(ip=self.get_option('ip'), **self.get_option('nova'))
         params['quantum'] = qhelper.get_shared_params(ip=self.get_option('ip'), **self.get_option('quantum'))
         params['cinder'] = chelper.get_shared_params(ip=self.get_option('ip'), **self.get_option('cinder'))
         wait_urls = [
             params['keystone']['endpoints']['admin']['uri'],
             params['keystone']['endpoints']['public']['uri'],
         ]
         for url in wait_urls:
             utils.wait_for_url(url)
         init_what = utils.load_yaml_text(contents)
         init_what = utils.expand_template_deep(self._filter_init(init_what), params)
         khelper.Initializer(params['keystone']['service_token'],
                             params['keystone']['endpoints']['admin']['uri']).initialize(**init_what)
         # Writing this makes sure that we don't init again
         sh.write_file(self.init_fn, utils.prettify_yaml(init_what))
         LOG.info("If you wish to re-run initialization, delete %s", colorizer.quote(self.init_fn))
예제 #3
0
 def post_start(self):
     if not sh.isfile(self.init_fn) and self.get_bool_option("do-init"):
         self.wait_active()
         LOG.info("Running commands to initialize keystone.")
         (fn, contents) = utils.load_template(self.name, INIT_WHAT_FN)
         LOG.debug("Initializing with contents of %s", fn)
         params = {}
         params["keystone"] = khelper.get_shared_params(
             **utils.merge_dicts(self.options, khelper.get_shared_passwords(self))
         )
         params["glance"] = ghelper.get_shared_params(ip=self.get_option("ip"), **self.get_option("glance"))
         params["nova"] = nhelper.get_shared_params(ip=self.get_option("ip"), **self.get_option("nova"))
         wait_urls = [
             params["keystone"]["endpoints"]["admin"]["uri"],
             params["keystone"]["endpoints"]["public"]["uri"],
         ]
         for url in wait_urls:
             utils.wait_for_url(url)
         init_what = utils.load_yaml_text(contents)
         init_what = utils.expand_template_deep(self._filter_init(init_what), params)
         khelper.Initializer(
             params["keystone"]["service_token"], params["keystone"]["endpoints"]["admin"]["uri"]
         ).initialize(**init_what)
         # Writing this makes sure that we don't init again
         sh.write_file(self.init_fn, utils.prettify_yaml(init_what))
         LOG.info("If you wish to re-run initialization, delete %s", colorizer.quote(self.init_fn))
예제 #4
0
 def install(self, urls):
     am_installed = 0
     try:
         # Done at a function level since this module may be used
         # before these libraries actually exist...
         gclient_v1 = importer.import_module('glanceclient.v1.client')
         gexceptions = importer.import_module(
             'glanceclient.common.exceptions')
         kclient_v2 = importer.import_module('keystoneclient.v2_0.client')
         kexceptions = importer.import_module('keystoneclient.exceptions')
     except RuntimeError as e:
         LOG.exception("Failed at importing required client modules: %s", e)
         return am_installed
     if urls:
         try:
             # Ensure all services ok
             for params in [self.glance_params, self.keystone_params]:
                 utils.wait_for_url(params['endpoints']['public']['uri'])
             g_params = self.glance_params
             client = gclient_v1.Client(
                 endpoint=g_params['endpoints']['public']['uri'],
                 token=self._get_token(kclient_v2))
         except (RuntimeError, gexceptions.ClientException,
                 kexceptions.ClientException, IOError) as e:
             LOG.exception(
                 'Failed fetching needed clients for image calls due to: %s',
                 e)
             return am_installed
         utils.log_iterable(
             urls,
             logger=LOG,
             header="Attempting to download+extract+upload %s images" %
             len(urls))
         for url in urls:
             try:
                 img_handle = Image(client,
                                    url,
                                    is_public=self.is_public,
                                    cache_dir=self.cache_dir)
                 (name, img_id) = img_handle.install()
                 LOG.info("Installed image named %s with image id %s.",
                          colorizer.quote(name), colorizer.quote(img_id))
                 am_installed += 1
             except (IOError, tarfile.TarError, gexceptions.ClientException,
                     kexceptions.ClientException) as e:
                 LOG.exception('Installing %r failed due to: %s', url, e)
     return am_installed
예제 #5
0
 def install(self, urls):
     am_installed = 0
     try:
         gclient_v1 = importer.import_module('glanceclient.v1.client')
         gexceptions = importer.import_module(
             'glanceclient.common.exceptions')
         kclient_v2 = importer.import_module('keystoneclient.v2_0.client')
         kexceptions = importer.import_module('keystoneclient.exceptions')
     except RuntimeError as e:
         LOG.exception("Failed at importing required client modules: %s", e)
         return am_installed
     if urls:
         try:
             # Ensure all services ok
             for n in ['glance', 'keystone']:
                 params = self.params[n]
                 utils.wait_for_url(params['endpoints']['public']['uri'])
             params = self.params['glance']
             client = gclient_v1.Client(
                 endpoint=params['endpoints']['public']['uri'],
                 token=self._get_token(kclient_v2))
         except (RuntimeError, gexceptions.ClientException,
                 kexceptions.ClientException, IOError) as e:
             LOG.exception(
                 'Failed fetching needed clients for image calls due to: %s',
                 e)
             return am_installed
         utils.log_iterable(
             urls,
             logger=LOG,
             header="Attempting to download+extract+upload %s images" %
             len(urls))
         for url in urls:
             try:
                 img_handle = Image(client, url,
                                    self.params.get('public', True))
                 (name, img_id) = img_handle.install()
                 LOG.info("Installed image named %s with image id %s.",
                          colorizer.quote(name), colorizer.quote(img_id))
                 am_installed += 1
             except (IOError, tarfile.TarError, gexceptions.ClientException,
                     kexceptions.ClientException) as e:
                 LOG.exception('Installing %r failed due to: %s', url, e)
     return am_installed
예제 #6
0
파일: glance.py 프로젝트: AsherBond/anvil
 def install(self, urls):
     am_installed = 0
     try:
         # Done at a function level since this module may be used
         # before these libraries actually exist.
         gclient_v1 = importer.import_module('glanceclient.v1.client')
         gexceptions = importer.import_module('glanceclient.common.exceptions')
         kclient_v2 = importer.import_module('keystoneclient.v2_0.client')
         kexceptions = importer.import_module('keystoneclient.exceptions')
     except RuntimeError as e:
         LOG.exception("Failed at importing required client modules: %s", e)
         return am_installed
     if urls:
         try:
             # Ensure all services are up
             for params in (self._glance_params, self._keystone_params):
                 utils.wait_for_url(params['endpoints']['public']['uri'])
             g_params = self._glance_params
             client = gclient_v1.Client(endpoint=g_params['endpoints']['public']['uri'],
                                        token=self._get_token(kclient_v2))
         except (RuntimeError, gexceptions.ClientException,
                 kexceptions.ClientException, IOError) as e:
             LOG.exception('Failed fetching needed clients for image calls due to: %s', e)
             return am_installed
         utils.log_iterable(urls, logger=LOG,
                            header="Attempting to download+extract+upload %s images" % len(urls))
         for url in urls:
             try:
                 img_handle = Image(client, url,
                                    is_public=self._is_public,
                                    cache_dir=self._cache_dir)
                 (name, img_id) = img_handle.install()
                 LOG.info("Installed image %s with id %s.",
                          colorizer.quote(name), colorizer.quote(img_id))
                 am_installed += 1
             except exc.DuplicateException as e:
                 LOG.warning(e)
             except (IOError,
                     tarfile.TarError,
                     gexceptions.ClientException,
                     kexceptions.ClientException) as e:
                 LOG.exception('Installing %r failed due to: %s', url, e)
     return am_installed
예제 #7
0
 def install(self, urls):
     am_installed = 0
     try:
         gclient_v1 = importer.import_module('glanceclient.v1.client')
         gexceptions = importer.import_module('glanceclient.common.exceptions')
         kclient_v2 = importer.import_module('keystoneclient.v2_0.client')
         kexceptions = importer.import_module('keystoneclient.exceptions')
     except RuntimeError as e:
         LOG.exception("Failed at importing required client modules: %s", e)
         return am_installed
     if urls:
         try:
             # Ensure all services ok
             for n in ['glance', 'keystone']:
                 params = self.params[n]
                 utils.wait_for_url(params['endpoints']['public']['uri'])
             params = self.params['glance']
             client = gclient_v1.Client(endpoint=params['endpoints']['public']['uri'],
                                        token=self._get_token(kclient_v2))
         except (RuntimeError, gexceptions.ClientException,
                 kexceptions.ClientException, IOError) as e:
             LOG.exception('Failed fetching needed clients for image calls due to: %s', e)
             return am_installed
         utils.log_iterable(urls, logger=LOG,
                             header="Attempting to download+extract+upload %s images" % len(urls))
         for url in urls:
             try:
                 img_handle = Image(client, url, self.params.get('public', True))
                 (name, img_id) = img_handle.install()
                 LOG.info("Installed image named %s with image id %s.", colorizer.quote(name), colorizer.quote(img_id))
                 am_installed += 1
             except (IOError,
                     tarfile.TarError,
                     gexceptions.ClientException,
                     kexceptions.ClientException) as e:
                 LOG.exception('Installing %r failed due to: %s', url, e)
     return am_installed