Skip to content

Commit

Permalink
adapt attribute calls to new default/default_conf_str syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
ctheune committed Nov 30, 2021
1 parent 4f74430 commit a875a4f
Show file tree
Hide file tree
Showing 18 changed files with 39 additions and 37 deletions.
2 changes: 1 addition & 1 deletion src/batou_ext/fcio.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class DNSAliases(batou.component.Component):
api_key = None

# How long to wait for aliases (seconds). 0: do not wait
wait_for_aliases = batou.component.Attribute(int, 0)
wait_for_aliases = batou.component.Attribute(int, default=0)

# class variable:
calls = []
Expand Down
2 changes: 1 addition & 1 deletion src/batou_ext/geoip.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class GeoIPDatabase(batou.component.Component):
license_key = None
download_url = batou.component.Attribute(
str,
"https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-City&suffix=tar.gz&license_key={{component.license_key}}" # noqa: E501 line too long
default_conf_string="https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-City&suffix=tar.gz&license_key={{component.license_key}}" # noqa: E501 line too long
)

def configure(self):
Expand Down
4 changes: 2 additions & 2 deletions src/batou_ext/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ class HTTPBasicAuth(batou.component.Component):
"""

env_name = None
fcio_auth = batou.component.Attribute("literal", False)
fcio_auth = batou.component.Attribute("literal", default=False)
username = None
password = None
basic_auth_string = None
providing = batou.component.Attribute("literal", True)
providing = batou.component.Attribute("literal", default=True)

def configure(self):
if self.providing:
Expand Down
4 changes: 2 additions & 2 deletions src/batou_ext/keypair.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ class KeyPair(Component):
crt = None
key = None

base_path = Attribute(str, '')
provide_itself = Attribute(bool, True)
base_path = Attribute(str, default_conf_string='')
provide_itself = Attribute(bool, default=True)

def configure(self):
self.crt_file = File(
Expand Down
12 changes: 6 additions & 6 deletions src/batou_ext/mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ class PostfixRelay(batou.component.Component):
"""

smtp_relay_host = batou.component.Attribute(str)
smtp_relay_port = batou.component.Attribute(int, 587)
smtp_tls = batou.component.Attribute("literal", "True")
smtp_relay_host = batou.component.Attribute(str, default='')
smtp_relay_port = batou.component.Attribute(int, default=587)
smtp_tls = batou.component.Attribute("literal", default=True)

smtp_auth = batou.component.Attribute("literal", "True")
smtp_auth = batou.component.Attribute("literal", default=True)
smtp_user = batou.component.Attribute(str)
smtp_password = batou.component.Attribute(str)

Expand Down Expand Up @@ -109,10 +109,10 @@ class Mailhog(batou.component.Component):

key_content = None
crt_content = None
letsencrypt = batou.component.Attribute("literal", True)
letsencrypt = batou.component.Attribute("literal", default=True)
docroot = None

http_auth_enable = batou.component.Attribute("literal", False)
http_auth_enable = batou.component.Attribute("literal", default=False)
http_basic_auth = None

provide_as = None # (optional) str to self.provide()
Expand Down
2 changes: 1 addition & 1 deletion src/batou_ext/memcached.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Memcached(batou.component.Component):
port=11211,
custom_config=dict(foo='baa', zzz=11))
"""
port = batou.component.Attribute(int, 11211)
port = batou.component.Attribute(int, default=11211)

# A additional dict
custom_config = {}
Expand Down
12 changes: 6 additions & 6 deletions src/batou_ext/mirror.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,27 +39,27 @@ class Mirror(batou.component.Component):

public_name = None
base = batou.component.Attribute(
str, '{protocol}://{credentials}@{public_name}')
protocol = batou.component.Attribute(str, 'https')
str, default='{protocol}://{credentials}@{public_name}')
protocol = batou.component.Attribute(str, default='https')

# Whether Nginx-configuration should be provided
nginx_enable = batou.component.Attribute('literal', False)
nginx_enable = batou.component.Attribute('literal', default=False)
nginx_config_path = None
nginx_docroot = None

# Define non-default reload command for Nginx used e.g. on renewal
# of SSL-certificate if possible
nginx_reload_command = batou.component.Attribute(
str, 'sudo systemctl reload nginx')
str, default='sudo systemctl reload nginx')

provide_itself = batou.component.Attribute('literal', True)
provide_itself = batou.component.Attribute('literal', default=True)

credentials = None
authstring = None

# Whether we shall run let's encrypt for Nginx configuration
# If set to 'False', a self-signed certificate will be deployed instead
use_letsencrypt = batou.component.Attribute('literal', True)
use_letsencrypt = batou.component.Attribute('literal', default=True)

def configure(self):

Expand Down
2 changes: 1 addition & 1 deletion src/batou_ext/mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class MySQLGeneric(batou.component.Component):
admin_password = None

# Used for GRANT-string
allow_from_hostname = batou.component.Attribute(str, 'localhost')
allow_from_hostname = batou.component.Attribute(str, default='localhost')

def configure(self):
self.provide('mysql', self)
Expand Down
7 changes: 4 additions & 3 deletions src/batou_ext/nfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ class NFS(batou.component.Component):
"""

# Path where NFS on client is mounted on
basepath = batou.component.Attribute(str, '/mnt/nfs/shared/')
basepath = batou.component.Attribute(
str, default_conf_string='/mnt/nfs/shared/')

# Path where NFS-share is located on the NFS server
serverpath = batou.component.Attribute(str, '/srv/nfs/shared/')
serverpath = batou.component.Attribute(
str, default_conf_string='/srv/nfs/shared/')

def configure(self):

self.provide('nfs', self)
2 changes: 1 addition & 1 deletion src/batou_ext/nix.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ class SensuChecks(batou.component.Component):
"""

purge_old_batou_json = batou.component.Attribute("literal", True)
purge_old_batou_json = batou.component.Attribute("literal", default=True)

def configure(self):
self.services = self.require(
Expand Down
2 changes: 1 addition & 1 deletion src/batou_ext/php.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class FPM(batou.component.Component):
port = 9001

env = {} # Additional environmental values for FPM
keep_env = batou.component.Attribute('literal', False)
keep_env = batou.component.Attribute('literal', default=False)

dependency_strings = ()

Expand Down
2 changes: 1 addition & 1 deletion src/batou_ext/postfixadmin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class PFA(Component):
release = '2.92'
checksum = 'sha1:21481f6eb8f10ba05fc6fcd1fe0fd468062956f2'

address = Attribute(Address, '127.0.0.1:9001')
address = Attribute(Address, default_conf_string='127.0.0.1:9001')

admin_password = None
salt = 'ab8f1b639d31875b59fa047481c581fd'
Expand Down
2 changes: 1 addition & 1 deletion src/batou_ext/postfixadmin/postfix.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def resolve_v6(address):

class PFAPostfix(Component):

address = Attribute(Address, 'localhost:25')
address = Attribute(Address, default_conf_string='localhost:25')

def configure(self):
self.address.listen.host_v6 = resolve_v6(self.address)
Expand Down
2 changes: 1 addition & 1 deletion src/batou_ext/postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def configure(self):

class PostgresDataComponent(batou.component.Component):

command_prefix = batou.component.Attribute(str, "sudo -u postgres")
command_prefix = batou.component.Attribute(str, default="sudo -u postgres")

def configure(self):
try:
Expand Down
5 changes: 3 additions & 2 deletions src/batou_ext/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ class VirtualEnvRequirements(batou.component.Component):
requirements_path='/path/to/my/requirements.txt')
"""

version = batou.component.Attribute(str, '2.7')
requirements_path = batou.component.Attribute(str, 'requirements.txt')
version = batou.component.Attribute(str, default='2.7')
requirements_path = batou.component.Attribute(
str, default_conf_string='requirements.txt')

# Shell script to be sourced before creating VirtualEnv and pip
pre_run_script_path = None
Expand Down
2 changes: 1 addition & 1 deletion src/batou_ext/roundcube/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Roundcube(Component):
release = '1.1.4'
checksum = 'sha256:9bfe88255d4ffc288f5776de1cead78352469b1766d5ebaebe6e28043affe181' # noqa: E501 line too long

address = Attribute(Address, '127.0.0.1:9000')
address = Attribute(Address, default_conf_string='127.0.0.1:9000')
skin = 'larry'
support_url = 'http://localhost'

Expand Down
6 changes: 3 additions & 3 deletions src/batou_ext/ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ class SSHKeyPair(Component):
id_ed25519 = None
id_ed25519_pub = None

scan_hosts = Attribute('list', '')
provide_itself = Attribute('literal', True)
purge_unmanaged_keys = Attribute('literal', False)
scan_hosts = Attribute('list', default=[])
provide_itself = Attribute('literal', default=True)
purge_unmanaged_keys = Attribute('literal', default=False)

def configure(self):
if self.provide_itself:
Expand Down
6 changes: 3 additions & 3 deletions src/batou_ext/ssl.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class Certificate(batou.component.Component):
# OSCP stapling
trusted_crt_content = None

use_letsencrypt = batou.component.Attribute('literal', True)
use_letsencrypt = batou.component.Attribute('literal', default=True)

letsencrypt_ca = "https://acme-v02.api.letsencrypt.org/directory"
letsencrypt_challenge = "http-01"
Expand All @@ -92,7 +92,7 @@ class Certificate(batou.component.Component):

# Whether a certificate check should be deployed, too
# You will need something like nrpehost or sensuchecks on the host
enable_check = batou.component.Attribute('literal', True)
enable_check = batou.component.Attribute('literal', default=True)

_may_need_to_generate_certificates = False

Expand Down Expand Up @@ -246,7 +246,7 @@ class CertificateCheck(batou.component.Component):
critical_days = 14

# If HTTPS is not running on 443
port = batou.component.Attribute(int, 443)
port = batou.component.Attribute(int, default=443)

def configure(self):
self += batou.lib.nagios.ServiceCheck(
Expand Down

0 comments on commit a875a4f

Please sign in to comment.