Guest User

Untitled

a guest
Nov 21st, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 KB | None | 0 0
  1. class CassandraEnvSh(cassandra_conf.base_config.BaseConfig):
  2.  
  3. def append_jinja_to_commented_option(self, commented_option_pattern, additional_jinja):
  4. compiled_pattern = re.compile(commented_option_pattern, re.MULTILINE)
  5. match = compiled_pattern.search(self.content)
  6. if match:
  7. replacement = match.group(0)
  8. replacement += additional_jinja
  9. self.content = compiled_pattern.sub(replacement, self.content)
  10.  
  11. def max_heap_size_new(self):
  12. self.append_jinja_to_commented_option(
  13. commented_option_pattern=r'^#\s*MAX_HEAP_SIZE=.*\n',
  14. additional_jinja=('{%- if cassandra_env_sh.max_heap_size is defined %}\n'
  15. 'MAX_HEAP_SIZE="{{ cassandra_env_sh.max_heap_size }}"\n'
  16. '{%- endif %}\n'))
  17.  
  18. def heap_newsize_new(self):
  19. self.append_jinja_to_commented_option(
  20. commented_option_pattern=r'^#\s*HEAP_NEWSIZE=.*\n',
  21. addtional_jinja=('{%- if cassandra_env_sh.heap_newsize is defined %}\n'
  22. 'HEAP_NEWSIZE="{{ cassandra_env_sh.heap_newsize }}"\n'
  23. '{%- endif %}\n'))
  24.  
  25. def max_heap_size_old(self):
  26. pattern = re.compile(r'^#\s*MAX_HEAP_SIZE=.*\n', re.MULTILINE)
  27. match = pattern.search(self.content)
  28. if match:
  29. replacement = match.group(0)
  30. replacement += '{%- if cassandra_env_sh.max_heap_size is defined %}\n'
  31. replacement += 'MAX_HEAP_SIZE="{{ cassandra_env_sh.max_heap_size }}"\n'
  32. replacement += '{%- endif %}\n'
  33. self.content = pattern.sub(replacement, self.content)
  34.  
  35. def heap_newsize_old(self):
  36. pattern = re.compile(r'^#\s*HEAP_NEWSIZE=.*\n', re.MULTILINE)
  37. match = pattern.search(self.content)
  38. if match:
  39. replacement = match.group(0)
  40. replacement += '{%- if cassandra_env_sh.heap_newsize is defined %}\n'
  41. replacement += 'HEAP_NEWSIZE="{{ cassandra_env_sh.heap_newsize }}"\n'
  42. replacement += '{%- endif %}\n'
  43. self.content = pattern.sub(replacement, self.content)
Add Comment
Please, Sign In to add comment