summaryrefslogtreecommitdiffstats
path: root/cyborg_enhancement/mitaka_version/cyborg/cyborg/cmd
diff options
context:
space:
mode:
authorbobzhou <zhoubo8@lenovo.com>2018-12-17 17:41:39 +0800
committerbobzhou <zhoubo8@lenovo.com>2018-12-17 17:41:39 +0800
commit31560e9a26e6a7e2e65d18924c938ee7a7683fb3 (patch)
tree26ec12331a2ec612a0f51c7866fbe41262ca0fe1 /cyborg_enhancement/mitaka_version/cyborg/cyborg/cmd
parentfc1b7908a77b5cce763f92b3d314057345f3ab7a (diff)
upload cyborg base mitaka version
Change-Id: Iff52024026c9eff899246be70cc89fe6e65befff Signed-off-by: bobzhou <zhoubo8@lenovo.com>
Diffstat (limited to 'cyborg_enhancement/mitaka_version/cyborg/cyborg/cmd')
-rw-r--r--cyborg_enhancement/mitaka_version/cyborg/cyborg/cmd/__init__.py19
-rw-r--r--cyborg_enhancement/mitaka_version/cyborg/cyborg/cmd/agent.py37
-rw-r--r--cyborg_enhancement/mitaka_version/cyborg/cyborg/cmd/api.py36
-rw-r--r--cyborg_enhancement/mitaka_version/cyborg/cyborg/cmd/conductor.py39
-rw-r--r--cyborg_enhancement/mitaka_version/cyborg/cyborg/cmd/dbsync.py91
5 files changed, 222 insertions, 0 deletions
diff --git a/cyborg_enhancement/mitaka_version/cyborg/cyborg/cmd/__init__.py b/cyborg_enhancement/mitaka_version/cyborg/cyborg/cmd/__init__.py
new file mode 100644
index 0000000..b90e7b3
--- /dev/null
+++ b/cyborg_enhancement/mitaka_version/cyborg/cyborg/cmd/__init__.py
@@ -0,0 +1,19 @@
+# Copyright 2017 Huawei Technologies Co.,LTD.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+import oslo_i18n as i18n
+
+
+i18n.install('cyborg')
diff --git a/cyborg_enhancement/mitaka_version/cyborg/cyborg/cmd/agent.py b/cyborg_enhancement/mitaka_version/cyborg/cyborg/cmd/agent.py
new file mode 100644
index 0000000..8663bd1
--- /dev/null
+++ b/cyborg_enhancement/mitaka_version/cyborg/cyborg/cmd/agent.py
@@ -0,0 +1,37 @@
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+"""The Cyborg Agent Service."""
+
+import sys
+
+from oslo_config import cfg
+from oslo_service import service
+
+from cyborg.common import constants
+from cyborg.common import service as cyborg_service
+
+
+CONF = cfg.CONF
+
+
+def main():
+ # Parse config file and command line options, then start logging
+ cyborg_service.prepare_service(sys.argv)
+
+ mgr = cyborg_service.RPCService('cyborg.agent.manager',
+ 'AgentManager',
+ constants.AGENT_TOPIC)
+
+ launcher = service.launch(CONF, mgr)
+ launcher.wait()
diff --git a/cyborg_enhancement/mitaka_version/cyborg/cyborg/cmd/api.py b/cyborg_enhancement/mitaka_version/cyborg/cyborg/cmd/api.py
new file mode 100644
index 0000000..7199e7b
--- /dev/null
+++ b/cyborg_enhancement/mitaka_version/cyborg/cyborg/cmd/api.py
@@ -0,0 +1,36 @@
+# Copyright 2017 Huawei Technologies Co.,LTD.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+"""The Cyborg Service API."""
+
+import sys
+
+from oslo_config import cfg
+
+from cyborg.common import service as cyborg_service
+
+
+CONF = cfg.CONF
+
+
+def main():
+ # Parse config file and command line options, then start logging
+ cyborg_service.prepare_service(sys.argv)
+
+ # Build and start the WSGI app
+ launcher = cyborg_service.process_launcher()
+ server = cyborg_service.WSGIService('cyborg_api', CONF.api.enable_ssl_api)
+ launcher.launch_service(server, workers=server.workers)
+ launcher.wait()
diff --git a/cyborg_enhancement/mitaka_version/cyborg/cyborg/cmd/conductor.py b/cyborg_enhancement/mitaka_version/cyborg/cyborg/cmd/conductor.py
new file mode 100644
index 0000000..eb04dc2
--- /dev/null
+++ b/cyborg_enhancement/mitaka_version/cyborg/cyborg/cmd/conductor.py
@@ -0,0 +1,39 @@
+# Copyright 2017 Huawei Technologies Co.,LTD.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+"""The Cyborg Conductor Service."""
+
+import sys
+
+from oslo_config import cfg
+from oslo_service import service
+
+from cyborg.common import constants
+from cyborg.common import service as cyborg_service
+
+
+CONF = cfg.CONF
+
+
+def main():
+ # Parse config file and command line options, then start logging
+ cyborg_service.prepare_service(sys.argv)
+
+ mgr = cyborg_service.RPCService('cyborg.conductor.manager',
+ 'ConductorManager',
+ constants.CONDUCTOR_TOPIC)
+
+ launcher = service.launch(CONF, mgr)
+ launcher.wait()
diff --git a/cyborg_enhancement/mitaka_version/cyborg/cyborg/cmd/dbsync.py b/cyborg_enhancement/mitaka_version/cyborg/cyborg/cmd/dbsync.py
new file mode 100644
index 0000000..08facbf
--- /dev/null
+++ b/cyborg_enhancement/mitaka_version/cyborg/cyborg/cmd/dbsync.py
@@ -0,0 +1,91 @@
+# Copyright 2017 Huawei Technologies Co.,LTD.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+"""
+Run storage database migration.
+"""
+
+import sys
+
+from oslo_config import cfg
+
+from cyborg.common.i18n import _
+from cyborg.common import service
+from cyborg.conf import CONF
+from cyborg.db import migration
+
+
+class DBCommand(object):
+
+ def upgrade(self):
+ migration.upgrade(CONF.command.revision)
+
+ def revision(self):
+ migration.revision(CONF.command.message, CONF.command.autogenerate)
+
+ def stamp(self):
+ migration.stamp(CONF.command.revision)
+
+ def version(self):
+ print(migration.version())
+
+ def create_schema(self):
+ migration.create_schema()
+
+
+def add_command_parsers(subparsers):
+ command_object = DBCommand()
+
+ parser = subparsers.add_parser(
+ 'upgrade',
+ help=_("Upgrade the database schema to the latest version. "
+ "Optionally, use --revision to specify an alembic revision "
+ "string to upgrade to."))
+ parser.set_defaults(func=command_object.upgrade)
+ parser.add_argument('--revision', nargs='?')
+
+ parser = subparsers.add_parser(
+ 'revision',
+ help=_("Create a new alembic revision. "
+ "Use --message to set the message string."))
+ parser.set_defaults(func=command_object.revision)
+ parser.add_argument('-m', '--message')
+ parser.add_argument('--autogenerate', action='store_true')
+
+ parser = subparsers.add_parser('stamp')
+ parser.set_defaults(func=command_object.stamp)
+ parser.add_argument('--revision', nargs='?')
+
+ parser = subparsers.add_parser(
+ 'version',
+ help=_("Print the current version information and exit."))
+ parser.set_defaults(func=command_object.version)
+
+ parser = subparsers.add_parser(
+ 'create_schema',
+ help=_("Create the database schema."))
+ parser.set_defaults(func=command_object.create_schema)
+
+
+def main():
+ command_opt = cfg.SubCommandOpt('command',
+ title='Command',
+ help=_('Available commands'),
+ handler=add_command_parsers)
+
+ CONF.register_cli_opt(command_opt)
+
+ service.prepare_service(sys.argv)
+ CONF.command.func()