update-entrypoints
diff --git a/requirements.txt b/requirements.txt
index 60f0516..4537d1c 100755
--- a/requirements.txt
+++ b/requirements.txt
@@ -10,3 +10,4 @@
oslo.db>=5.0.0
oslo.config>=8.1.0
oslo.service>=2.5.0
+oslo.log>=4.4.0 # Apache-2.0
diff --git a/staffeln/api/app.py b/staffeln/api/app.py
index 0d723f0..90f35df 100755
--- a/staffeln/api/app.py
+++ b/staffeln/api/app.py
@@ -16,3 +16,6 @@
input_json = request.get_json(force=True)
dictToReturn = {'text': input_json['text']}
return jsonify(dictToReturn)
+
+def run(host, port, ssl_context):
+ app.run(host=host, port=port, ssl_context=ssl_context)
diff --git a/staffeln/cmd/api.py b/staffeln/cmd/api.py
index cc7b760..f554354 100755
--- a/staffeln/cmd/api.py
+++ b/staffeln/cmd/api.py
@@ -3,7 +3,6 @@
import sys
from oslo_log import log as logging
-from oslo_reports import guru_meditation_report as gmr
from staffeln.api import app as api_app
from staffeln.common import service
@@ -36,7 +35,6 @@
def main():
service.prepare_service(sys.argv)
- gmr.TextGuruMeditation.setup_autorun(version, conf=CONF)
# SSL configuration
use_ssl = CONF.api.enabled_ssl
diff --git a/staffeln/common/config.py b/staffeln/common/config.py
index c90aa63..dd28201 100755
--- a/staffeln/common/config.py
+++ b/staffeln/common/config.py
@@ -1,6 +1,3 @@
-from oslo_middleware import cors
-from oslo_policy import opts
-
# from staffeln.common import rpc
import staffeln.conf
from staffeln import version
@@ -18,41 +15,4 @@
def set_config_defaults():
- """Update default value for configuration options from other namespace.
-
- Example, oslo lib config options. This is needed for
- config generator tool to pick these default value changes.
- https://docs.openstack.org/oslo.config/latest/cli/
- generator.html#modifying-defaults-from-other-namespaces
- """
-
- set_cors_middleware_defaults()
-
- # TODO(gmann): Remove setting the default value of config policy_file
- # once oslo_policy change the default value to 'policy.yaml'.
- # https://github.com/openstack/oslo.policy/blob/a626ad12fe5a3abd49d70e3e5b95589d279ab578/oslo_policy/opts.py#L49
- opts.set_defaults(CONF, 'policy.yaml')
-
-
-def set_cors_middleware_defaults():
- """Update default configuration options for oslo.middleware."""
- cors.set_defaults(
- allow_headers=['X-Auth-Token',
- 'X-Identity-Status',
- 'X-Roles',
- 'X-Service-Catalog',
- 'X-User-Id',
- 'X-Tenant-Id',
- 'X-OpenStack-Request-ID',
- 'X-Server-Management-Url'],
- expose_headers=['X-Auth-Token',
- 'X-Subject-Token',
- 'X-Service-Token',
- 'X-OpenStack-Request-ID',
- 'X-Server-Management-Url'],
- allow_methods=['GET',
- 'PUT',
- 'POST',
- 'DELETE',
- 'PATCH']
- )
+ pass
diff --git a/staffeln/conductor/__init__.py b/staffeln/conductor/__init__.py
new file mode 100755
index 0000000..94ff7c7
--- /dev/null
+++ b/staffeln/conductor/__init__.py
@@ -0,0 +1,37 @@
+import cotyledon
+from futurist import periodics
+from oslo_log import log
+import staffeln.conf
+import sys
+import threading
+
+
+LOG = log.getLogger(__name__)
+CONF = staffeln.conf.CONF
+
+
+class BackupService(cotyledon.Service):
+ name = "conductor"
+
+ def __init__(self, worker_id, conf):
+ super(BackupService, self).__init__(worker_id)
+ self._shutdown = threading.Event()
+ self.conf = conf
+ LOG.error("%s init" % self.name)
+
+ def run(self):
+ LOG.error("%s run" % self.name)
+ self._shutdown.wait()
+ interval = CONF.conductor.backup_period
+ @periodics.periodic(spacing=interval, run_immediately=True)
+ def backup_engine():
+ print("echo")
+ pass
+
+ def terminate(self):
+ LOG.error("%s terminate" % self.name)
+ self._shutdown.set()
+ sys.exit(42)
+
+ def reload(self):
+ LOG.error("%s reload" % self.name)
diff --git a/staffeln/conductor/manage.py b/staffeln/conductor/manage.py
index 7f18678..0e7174d 100755
--- a/staffeln/conductor/manage.py
+++ b/staffeln/conductor/manage.py
@@ -25,6 +25,7 @@
interval = CONF.conductor.backup_period
@periodics.periodic(spacing=interval, run_immediately=True)
def backup_engine():
+ print("echo")
pass
def terminate(self):
diff --git a/staffeln/conf/api.py b/staffeln/conf/api.py
index e146689..36baed2 100755
--- a/staffeln/conf/api.py
+++ b/staffeln/conf/api.py
@@ -7,17 +7,35 @@
help='Options under this group are used to define staffeln API.'
)
-
-test_opts = [
+connection_opts = [
cfg.StrOpt(
- 'api_test_option',
- default='test',
- deprecated_group='DEFAULT',
- help='test options'
+ 'host',
+ default="0.0.0.0",
+ help='IP address on which the staffeln API will listen.'
+ ),
+ cfg.PortOpt(
+ 'port',
+ default=8774,
+ help='Staffeln API listens on this port number for incoming requests.'
+ ),
+ cfg.BoolOpt(
+ 'enabled_ssl',
+ default=False,
+ help='ssl enabled'
+ ),
+ cfg.StrOpt(
+ 'ssl_key_file',
+ default=False,
+ help='ssl key file path'
+ ),
+ cfg.StrOpt(
+ 'ssl_cert_file',
+ default=False,
+ help='ssl cert file path'
),
]
-API_OPTS = (test_opts)
+API_OPTS = (connection_opts)
def register_opts(conf):
diff --git a/staffeln/conf/conductor.py b/staffeln/conf/conductor.py
index 47c86c0..ae89d38 100755
--- a/staffeln/conf/conductor.py
+++ b/staffeln/conf/conductor.py
@@ -10,6 +10,7 @@
backup_opts = [
cfg.IntOpt(
'workers',
+ default=1,
help='The maximum number of conductor processes to '
'fork and run. Default to number of CPUs on the host.'),
cfg.IntOpt(
@@ -32,9 +33,10 @@
def register_opts(conf):
conf.register_group(conductor_group)
- conf.register_opts(CONDUCTOR_OPTS, group=conductor_group)
+ conf.register_opts(backup_opts, group=conductor_group)
+ conf.register_opts(rotation_opts)
def list_opts():
- return {"DEFAULT": backup_opts,
- conductor_group: CONDUCTOR_OPTS}
+ return {"DEFAULT": rotation_opts,
+ conductor_group: backup_opts}