drydock/drydock_provisioner/cli/design/commands.py
Scott Hussey 72adce3d38 Add Task persistence and KOTH
Implement logic to use SQLalchemy to persist and query
task information as well as manage multiple instances
with a king-of-the-hill algorithm via Postgres

- Implement leadership claim
- Implement task insert/update/query
- Implement status message inserts
- Implement integration tests w/ Postgres

Change-Id: Ic657afef3c7e1eb678629fb8b30969fa9f52585e
2017-10-26 14:56:13 -05:00

60 lines
1.8 KiB
Python

# Copyright 2017 AT&T Intellectual Property. All other 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.
"""cli.design.commands.
Contains commands related to designs
"""
import click
import json
from drydock_provisioner.cli.design.actions import DesignList
from drydock_provisioner.cli.design.actions import DesignShow
from drydock_provisioner.cli.design.actions import DesignCreate
@click.group()
def design():
"""Drydock design commands."""
pass
@design.command(name='create')
@click.option(
'--base-design',
'-b',
help='The base design to model this new design after')
@click.pass_context
def design_create(ctx, base_design=None):
"""Create a design."""
click.echo(
json.dumps(DesignCreate(ctx.obj['CLIENT'], base_design).invoke()))
@design.command(name='list')
@click.pass_context
def design_list(ctx):
"""List designs."""
click.echo(json.dumps(DesignList(ctx.obj['CLIENT']).invoke()))
@design.command(name='show')
@click.option('--design-id', '-i', help='The design id to show')
@click.pass_context
def design_show(ctx, design_id):
"""show designs."""
if not design_id:
ctx.fail('The design id must be specified by --design-id')
click.echo(json.dumps(DesignShow(ctx.obj['CLIENT'], design_id).invoke()))