Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Windows 2008
- isolated_images=4adc0cb2-f65d-4c70-ae02-522e3cf245ef=prodnc15,prodnc16
- # Windows 2003
- isolated_images=d2e845f4-b011-4f0d-8438-b5e799d8dd66=prodnc15,prodnc16
- # Oracle 11
- isolated_images=7aeef3a1-4ca4-4cc3-aba0-38b5a35804c2=prodnc15,prodnc16
- -------------
- class IsolatedHostsFilter(filters.BaseHostFilter):
- """Returns host."""
- def host_passes_legacy(self, host_state, filter_properties):
- spec = filter_properties.get('request_spec', {})
- props = spec.get('instance_properties', {})
- image_ref = props.get('image_ref')
- image_isolated = image_ref in FLAGS.isolated_images
- host_isolated = host_state.host in FLAGS.isolated_hosts
- return image_isolated == host_isolated
- def host_passes(self, host_state, filter_properties):
- if not isinstance(FLAGS.isolated_images, list):
- LOG.debug('Falling back to legacy...')
- return self.host_passes_legacy(host_state, filter_properties)
- # if current image not present in isolated_images return true
- # if current image IS present in isolated_images && my host is listed for that image return true
- # otherwise return false
- spec = filter_properties.get('request_spec', {})
- props = spec.get('instance_properties', {})
- image_ref = props.get('image_ref')
- #create dict
- d = {}
- for i in FLAGS.isolated_images:
- (img,hosts)=i.split('=')
- d[img]=hosts.split(',')
- if not image_ref in d:
- LOG.debug("didn't find image in dict!")
- return True
- if host_state.host in d[image_ref]:
- LOG.debug("found my host (%s) in d[%s]!" % (host_state.host, image_ref))
- return True
- return False
Advertisement
Add Comment
Please, Sign In to add comment