Skip to content
Snippets Groups Projects
Verified Commit c2e99b07 authored by Maarten de Waard's avatar Maarten de Waard :angel:
Browse files

Merge branch 'master' into 333-update-nextcloud-onlyoffice-version

parents a95b99cd 3d40f578
No related branches found
No related tags found
No related merge requests found
......@@ -3,16 +3,11 @@ environments:
values:
- "/etc/OpenAppStack/values/local.yaml"
# Note: needs helm-git plugin (https://github.com/aslafy-z/helm-git)
repositories:
- name: onlyoffice-documentserver
url: git+https://open.greenhost.net/openappstack/nextcloud@onlyoffice-documentserver?ref=22-increase-onlyoffice-maximum-upload-size
releases:
- name: "oas-{{ .Environment.Values.releaseName }}-files"
namespace: "oas-apps"
# Install from file path, so you don't run into https://github.com/roboll/helmfile/issues/726
chart: "../../repos/nextcloud/nextcloud-onlyoffice"
chart: "../../repos/nextcloud"
values:
- "../values/nextcloud.yaml.gotmpl"
- "/etc/OpenAppStack/values/apps/nextcloud.yaml.gotmpl"
......
......@@ -60,7 +60,8 @@ nextcloud:
successThreshold: 1
failureThreshold: 3
onlyoffice-documentserver:
onlyoffice:
server_name: "office.{{ .Environment.Values.domain }}"
ingress:
enabled: true
annotations:
......@@ -74,16 +75,7 @@ onlyoffice-documentserver:
- hosts:
- "office.{{ .Environment.Values.domain }}"
secretName: oas-{{ .Environment.Values.releaseName }}-office
onlyoffice:
server_name: "office.{{ .Environment.Values.domain }}"
jwtSecret: "{{ requiredEnv "ONLYOFFICE_JWT_SECRET" }}"
postgresql:
postgresqlPassword: "{{ requiredEnv "ONLYOFFICE_POSTGRESQL_PASSWORD" }}"
rabbitmq:
rabbitmq:
password: "{{ requiredEnv "ONLYOFFICE_RABBITMQ_PASSWORD" }}"
livenessProbe:
initialDelaySeconds: 120
timeoutSeconds: 20
......@@ -96,3 +88,10 @@ onlyoffice-documentserver:
periodSeconds: 30
successThreshold: 1
failureThreshold: 3
postgresql:
postgresqlPassword: "{{ requiredEnv "ONLYOFFICE_POSTGRESQL_PASSWORD" }}"
rabbitmq:
rabbitmq:
password: "{{ requiredEnv "ONLYOFFICE_RABBITMQ_PASSWORD" }}"
......@@ -52,11 +52,9 @@ def request_api(resource: str, request_type: str = 'GET',
if response.content:
log.debug('Response: %s\n', response.json())
return json.loads(response.content.decode('utf-8'))
else:
return None
else:
raise requests.HTTPError('WARNING: Got response code ',
response.status_code, response.text)
return None
raise requests.HTTPError('WARNING: Got response code ',
response.status_code, response.text)
# API calls
......@@ -93,7 +91,7 @@ def create_domain_record(domain: str, name: str, data: str,
return response['domain_record']
def create_droplet(name: str, ssh_key_id: int, region: str = 'ams1',
def create_droplet(name: str, ssh_key_id: int, region: str = 'ams1', # pylint: disable=too-many-arguments
size: int = 2048, disk: int = 20, image: int = 18):
"""Create a droplet.
......@@ -121,10 +119,10 @@ def create_droplet(name: str, ssh_key_id: int, region: str = 'ams1',
return response
def delete_domain_record(domain: str, id: int):
def delete_domain_record(domain: str, record_id: int):
"""Delete a domain record."""
log.info('Deleting domain record %s', id)
response = request_api('domains/{0}/records/{1}'.format(domain, id),
log.info('Deleting domain record %s', record_id)
response = request_api('domains/{0}/records/{1}'.format(domain, record_id),
'DELETE')
return response
......@@ -137,21 +135,21 @@ def delete_domain_records_by_name(domain: str, name_regex: str):
delete_domain_records_by_name('openappstack.net', '^ci-')
"""
all = get_domain_records_by_name(domain, name_regex)
for record in all:
all_records = get_domain_records_by_name(domain, name_regex)
for record in all_records:
delete_domain_record(domain, record['id'])
def delete_droplet(id: int):
def delete_droplet(droplet_id: int):
"""Delete a droplet. Droplet needs to be stopped first."""
log.info('Deleting %s', id)
response = request_api('droplets/{0}'.format(id), 'DELETE')
log.info('Deleting %s', droplet_id)
response = request_api('droplets/{0}'.format(droplet_id), 'DELETE')
return response
def get_domain_record(domain: str, id: int):
def get_domain_record(domain: str, droplet_id: int):
"""Get details for given domain record."""
response = request_api('domains/{0}/records/{1}'.format(domain, id))
response = request_api('domains/{0}/records/{1}'.format(domain, droplet_id))
return response['domain_record']
......@@ -209,13 +207,13 @@ def get_droplets_by_name(name_regex: str):
"""
all_droplets = get_droplets()
matching = [droplet for droplet in all_droplets
if re.match('^ci+', droplet['name'])]
if re.match(name_regex, droplet['name'])]
return matching
def get_droplet(id: int):
def get_droplet(droplet_id: int):
"""Get information about specified droplet."""
response = request_api('droplets/{0}'.format(id))
response = request_api('droplets/{0}'.format(droplet_id))
return response['droplet']
......@@ -225,9 +223,11 @@ def list_domain_records(domain: str):
log.debug(json.dumps(records, sort_keys=True, indent=2))
table_records = [[
record['id'], record['name'], record['type'], record['data']]
for record in records]
table_records = [
[
record['id'], record['name'], record['type'], record['data']
] for record in records
]
log.info(tabulate(table_records,
headers=['ID', 'Name', 'Type', 'Data']))
......@@ -251,25 +251,25 @@ def list_droplets():
headers=['ID', 'Name', 'IPv4', 'Status']))
def shutdown_droplet(id: int):
def shutdown_droplet(droplet_id: int):
"""Shut down specified droplet (through a power_off call)."""
log.info('Shutting down %s', id)
log.info('Shutting down %s', droplet_id)
data = {"type": "power_off"}
response = request_api('droplets/{0}/actions'.format(id), 'POST', data)
response = request_api('droplets/{0}/actions'.format(droplet_id), 'POST', data)
return response
def status_droplet(id: int):
def status_droplet(droplet_id: int):
"""Get status of specified droplet."""
response = get_droplet(id)
response = get_droplet(droplet_id)
return response['status']
def terminate_droplet(id: int):
def terminate_droplet(droplet_id: int):
"""Terminate a droplet by powering it down and deleting it."""
shutdown_droplet(id)
wait_for_state(id, 'stopped')
delete_droplet(id)
shutdown_droplet(droplet_id)
wait_for_state(droplet_id, 'stopped')
delete_droplet(droplet_id)
def terminate_droplets_by_name(name_regex: str, ndays: int = 0,
......@@ -287,51 +287,51 @@ def terminate_droplets_by_name(name_regex: str, ndays: int = 0,
threshold_time = (datetime.now(tz=timezone('Europe/Stockholm')) -
timedelta(days=ndays)).\
strftime("%Y-%m-%dT%H:%M:%S+00:00")
all = get_droplets()
all_droplets = get_droplets()
noterminate_droplets = []
if 'NO_TERMINATE_DROPLETS' in os.environ:
noterminate_droplets = os.environ['NO_TERMINATE_DROPLETS'].split(',')
for droplet in all:
for droplet in all_droplets:
if droplet['name'] not in noterminate_droplets:
if re.match(name_regex, droplet['name']):
if droplet['created_at'] < threshold_time:
delete_domain_records_by_name(
domain, '^\*.'+droplet['name'])
domain, r'^\*.'+droplet['name'])
delete_domain_records_by_name(domain, '^'+droplet['name'])
terminate_droplet(droplet['id'])
def wait_for_ssh(ip: str):
def wait_for_ssh(droplet_ip: str):
"""Wait for ssh to be reachable on port 22."""
log.info('Waiting for ssh to become available on ip %s', ip)
log.info('Waiting for ssh to become available on ip %s', droplet_ip)
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
while sock.connect_ex((ip, 22)) != 0:
while sock.connect_ex((droplet_ip, 22)) != 0:
sleep(1)
log.info('SSH became available on ip %s', ip)
log.info('SSH became available on ip %s', droplet_ip)
def wait_for_state(id: int, state):
def wait_for_state(droplet_id: int, state):
"""Wait for a droplet to reach a certain state."""
log.info('Waiting for droplet %s to reach %s state...', id, state)
status = status_droplet(id)
log.info('Waiting for droplet %s to reach %s state...', droplet_id, state)
status = status_droplet(droplet_id)
log.debug(status)
while status != state:
sleep(1)
status = status_droplet(id)
status = status_droplet(droplet_id)
# When called from from ipython, setup
# logging to console
try:
__IPYTHON__
log = logging.getLogger()
__IPYTHON__ # pylint: disable=pointless-statement
log = logging.getLogger() # pylint: disable=invalid-name
log.addHandler(logging.StreamHandler())
log.setLevel(logging.INFO)
except NameError:
log = logging.getLogger(__name__)
log = logging.getLogger(__name__) # pylint: disable=invalid-name
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment