Merge "Limit the amount of disk of container"
This commit is contained in:
@@ -158,8 +158,13 @@ class CreateContainer(command.ShowOne):
|
|||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--hostname',
|
'--hostname',
|
||||||
metavar='<hostname>',
|
metavar='<hostname>',
|
||||||
help='Container host name'
|
help='Container host name')
|
||||||
)
|
parser.add_argument(
|
||||||
|
'--disk',
|
||||||
|
metavar='<disk>',
|
||||||
|
type=int,
|
||||||
|
default=None,
|
||||||
|
help='The disk size in GiB for per container.')
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
@@ -189,6 +194,7 @@ class CreateContainer(command.ShowOne):
|
|||||||
opts['mounts'] = zun_utils.parse_mounts(parsed_args.mount)
|
opts['mounts'] = zun_utils.parse_mounts(parsed_args.mount)
|
||||||
opts['runtime'] = parsed_args.runtime
|
opts['runtime'] = parsed_args.runtime
|
||||||
opts['hostname'] = parsed_args.hostname
|
opts['hostname'] = parsed_args.hostname
|
||||||
|
opts['disk'] = parsed_args.disk
|
||||||
|
|
||||||
opts = zun_utils.remove_null_parms(**opts)
|
opts = zun_utils.remove_null_parms(**opts)
|
||||||
container = client.containers.create(**opts)
|
container = client.containers.create(**opts)
|
||||||
@@ -714,8 +720,13 @@ class RunContainer(command.ShowOne):
|
|||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--hostname',
|
'--hostname',
|
||||||
metavar='<hostname>',
|
metavar='<hostname>',
|
||||||
help='Container host name'
|
help='Container host name')
|
||||||
)
|
parser.add_argument(
|
||||||
|
'--disk',
|
||||||
|
metavar='<disk>',
|
||||||
|
type=int,
|
||||||
|
default=None,
|
||||||
|
help='The disk size in GiB for per container.')
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
@@ -745,6 +756,7 @@ class RunContainer(command.ShowOne):
|
|||||||
opts['mounts'] = zun_utils.parse_mounts(parsed_args.mount)
|
opts['mounts'] = zun_utils.parse_mounts(parsed_args.mount)
|
||||||
opts['runtime'] = parsed_args.runtime
|
opts['runtime'] = parsed_args.runtime
|
||||||
opts['hostname'] = parsed_args.hostname
|
opts['hostname'] = parsed_args.hostname
|
||||||
|
opts['disk'] = parsed_args.disk
|
||||||
|
|
||||||
opts = zun_utils.remove_null_parms(**opts)
|
opts = zun_utils.remove_null_parms(**opts)
|
||||||
container = client.containers.run(**opts)
|
container = client.containers.run(**opts)
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ CONTAINER1 = {'id': '1234',
|
|||||||
'auto_remove': True,
|
'auto_remove': True,
|
||||||
'runtime': 'runc',
|
'runtime': 'runc',
|
||||||
'hostname': 'testhost',
|
'hostname': 'testhost',
|
||||||
|
'disk': '20',
|
||||||
}
|
}
|
||||||
|
|
||||||
CONTAINER2 = {'id': '1235',
|
CONTAINER2 = {'id': '1235',
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ CREATION_ATTRIBUTES = ['name', 'image', 'command', 'cpu', 'memory',
|
|||||||
'environment', 'workdir', 'labels', 'image_pull_policy',
|
'environment', 'workdir', 'labels', 'image_pull_policy',
|
||||||
'restart_policy', 'interactive', 'image_driver',
|
'restart_policy', 'interactive', 'image_driver',
|
||||||
'security_groups', 'hints', 'nets', 'auto_remove',
|
'security_groups', 'hints', 'nets', 'auto_remove',
|
||||||
'runtime', 'hostname', 'mounts']
|
'runtime', 'hostname', 'mounts', 'disk']
|
||||||
|
|
||||||
|
|
||||||
class Container(base.Resource):
|
class Container(base.Resource):
|
||||||
|
|||||||
@@ -126,6 +126,11 @@ def _show_container(container):
|
|||||||
metavar='<hostname>',
|
metavar='<hostname>',
|
||||||
default=None,
|
default=None,
|
||||||
help='Container host name')
|
help='Container host name')
|
||||||
|
@utils.arg('--disk',
|
||||||
|
metavar='<disk>',
|
||||||
|
type=int,
|
||||||
|
default=None,
|
||||||
|
help='The disk size in GiB for per container.')
|
||||||
def do_create(cs, args):
|
def do_create(cs, args):
|
||||||
"""Create a container."""
|
"""Create a container."""
|
||||||
opts = {}
|
opts = {}
|
||||||
@@ -144,6 +149,7 @@ def do_create(cs, args):
|
|||||||
opts['mounts'] = zun_utils.parse_mounts(args.mount)
|
opts['mounts'] = zun_utils.parse_mounts(args.mount)
|
||||||
opts['runtime'] = args.runtime
|
opts['runtime'] = args.runtime
|
||||||
opts['hostname'] = args.hostname
|
opts['hostname'] = args.hostname
|
||||||
|
opts['disk'] = args.disk
|
||||||
|
|
||||||
if args.security_group:
|
if args.security_group:
|
||||||
opts['security_groups'] = args.security_group
|
opts['security_groups'] = args.security_group
|
||||||
@@ -527,6 +533,11 @@ def do_kill(cs, args):
|
|||||||
metavar='<hostname>',
|
metavar='<hostname>',
|
||||||
default=None,
|
default=None,
|
||||||
help='Container hostname')
|
help='Container hostname')
|
||||||
|
@utils.arg('--disk',
|
||||||
|
metavar='<disk>',
|
||||||
|
type=int,
|
||||||
|
default=None,
|
||||||
|
help='The disk size in GiB for per container.')
|
||||||
def do_run(cs, args):
|
def do_run(cs, args):
|
||||||
"""Run a command in a new container."""
|
"""Run a command in a new container."""
|
||||||
opts = {}
|
opts = {}
|
||||||
@@ -545,6 +556,7 @@ def do_run(cs, args):
|
|||||||
opts['mounts'] = zun_utils.parse_mounts(args.mount)
|
opts['mounts'] = zun_utils.parse_mounts(args.mount)
|
||||||
opts['runtime'] = args.runtime
|
opts['runtime'] = args.runtime
|
||||||
opts['hostname'] = args.hostname
|
opts['hostname'] = args.hostname
|
||||||
|
opts['disk'] = args.disk
|
||||||
|
|
||||||
if args.security_group:
|
if args.security_group:
|
||||||
opts['security_groups'] = args.security_group
|
opts['security_groups'] = args.security_group
|
||||||
|
|||||||
Reference in New Issue
Block a user