Add Postgres command
Change-Id: I416eb4404393e516d660f80568ff468f8adc6a8c
This commit is contained in:
parent
7f58f90750
commit
829fd59afd
|
@ -245,6 +245,12 @@ class ShellCommand(DockerMixin, ssh.SSHMixin, command.BaseCommand):
|
|||
'docker', 'exec', self.get_docker_id()
|
||||
] + list(commands)
|
||||
|
||||
def container_command_interactive(self, *commands):
|
||||
return [
|
||||
#'lxc-attach', '--name', self.get_full_docker_id()
|
||||
'docker', 'exec', '-it', self.get_docker_id()
|
||||
] + list(commands)
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super(ShellCommand, self).get_parser(prog_name)
|
||||
|
||||
|
@ -269,7 +275,9 @@ class ShellCommand(DockerMixin, ssh.SSHMixin, command.BaseCommand):
|
|||
if not command:
|
||||
command = '/bin/bash'
|
||||
|
||||
return self.ssh_command_interactive(*self.container_command(command))
|
||||
return self.ssh_command_interactive(
|
||||
*self.container_command_interactive(command)
|
||||
)
|
||||
|
||||
|
||||
class StartCommand(DockerMixin, ssh.SSHMixin, command.BaseCommand):
|
||||
|
|
|
@ -0,0 +1,73 @@
|
|||
# Copyright 2015 Mirantis, Inc.
|
||||
#
|
||||
# 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 six
|
||||
import subprocess
|
||||
|
||||
from fuel_dev_tools import docker
|
||||
from fuel_dev_tools import info
|
||||
|
||||
|
||||
class DockerPostgresMixin(object):
|
||||
container = 'postgres'
|
||||
default_command = 'su - postgres -c "psql -d nailgun"'
|
||||
|
||||
def get_log_directory(self):
|
||||
return '/var/log/docker-logs/postgres'
|
||||
|
||||
|
||||
class PostgresInfo(DockerPostgresMixin, info.BasicInfo):
|
||||
@classmethod
|
||||
def get_info(cls):
|
||||
return 'TODO: add info about DB recreation'
|
||||
|
||||
|
||||
class Id(DockerPostgresMixin, docker.IdCommand):
|
||||
"""Print Docker container id."""
|
||||
|
||||
|
||||
class Config(DockerPostgresMixin, docker.ConfigCommand):
|
||||
"""Print Docker container config."""
|
||||
|
||||
|
||||
class Dir(DockerPostgresMixin, docker.DirCommand):
|
||||
"""Print Docker container directory on master."""
|
||||
|
||||
|
||||
class Log(DockerPostgresMixin, docker.LogCommand):
|
||||
"""Display logs for container."""
|
||||
|
||||
|
||||
class Restart(DockerPostgresMixin, docker.RestartCommand):
|
||||
"""Restart Docker container."""
|
||||
|
||||
|
||||
class Start(DockerPostgresMixin, docker.StartCommand):
|
||||
"""Start Docker container."""
|
||||
|
||||
|
||||
class Stop(DockerPostgresMixin, docker.StopCommand):
|
||||
"""Stop Docker container."""
|
||||
|
||||
|
||||
class Shell(DockerPostgresMixin, docker.ShellCommand):
|
||||
"""Shell into a nailgun Docker container."""
|
||||
|
||||
|
||||
class Tail(DockerPostgresMixin, docker.TailCommand):
|
||||
"""Display logs for container."""
|
||||
|
||||
|
||||
class Volumes(DockerPostgresMixin, docker.VolumesCommand):
|
||||
"""Print all volumes of a container."""
|
|
@ -30,6 +30,7 @@ from cliff import commandmanager
|
|||
from fuel_dev_tools.docker import astute
|
||||
from fuel_dev_tools.docker import nailgun
|
||||
from fuel_dev_tools.docker import nginx
|
||||
from fuel_dev_tools.docker import postgres
|
||||
from fuel_dev_tools import exc
|
||||
from fuel_dev_tools import info
|
||||
from fuel_dev_tools import ssh
|
||||
|
@ -63,6 +64,17 @@ COMMANDS = {
|
|||
'nailgun-stop': nailgun.Stop,
|
||||
'nailgun-tail': nailgun.Tail,
|
||||
'nailgun-volumes': nailgun.Volumes,
|
||||
|
||||
'postgres-id': postgres.Id,
|
||||
'postgres-config': postgres.Config,
|
||||
'postgres-dir': postgres.Dir,
|
||||
'postgres-log': postgres.Log,
|
||||
'postgres-restart': postgres.Restart,
|
||||
'postgres-shell': postgres.Shell,
|
||||
'postgres-start': postgres.Start,
|
||||
'postgres-stop': postgres.Stop,
|
||||
'postgres-tail': postgres.Tail,
|
||||
'postgres-volumes': postgres.Volumes,
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue