summaryrefslogtreecommitdiff
path: root/openstackclient/compute
diff options
context:
space:
mode:
Diffstat (limited to 'openstackclient/compute')
-rw-r--r--openstackclient/compute/v2/aggregate.py31
-rw-r--r--openstackclient/compute/v2/flavor.py6
-rw-r--r--openstackclient/compute/v2/floatingip.py23
-rw-r--r--openstackclient/compute/v2/host.py57
-rw-r--r--openstackclient/compute/v2/keypair.py3
-rw-r--r--openstackclient/compute/v2/security_group.py65
-rw-r--r--openstackclient/compute/v2/server.py2
-rw-r--r--openstackclient/compute/v2/service.py13
8 files changed, 102 insertions, 98 deletions
diff --git a/openstackclient/compute/v2/aggregate.py b/openstackclient/compute/v2/aggregate.py
index e47c13a7..1a02a388 100644
--- a/openstackclient/compute/v2/aggregate.py
+++ b/openstackclient/compute/v2/aggregate.py
@@ -290,3 +290,34 @@ class ShowAggregate(command.ShowOne):
info = {}
info.update(data._info)
return zip(*sorted(six.iteritems(info)))
+
+
+class UnsetAggregate(command.Command):
+ """Unset aggregate properties"""
+
+ def get_parser(self, prog_name):
+ parser = super(UnsetAggregate, self).get_parser(prog_name)
+ parser.add_argument(
+ "aggregate",
+ metavar="<aggregate>",
+ help="Aggregate to modify (name or ID)",
+ )
+ parser.add_argument(
+ "--property",
+ metavar="<key>",
+ action='append',
+ help='Property to remove from aggregate '
+ '(repeat option to remove multiple properties)',
+ required=True,
+ )
+ return parser
+
+ def take_action(self, parsed_args):
+ compute_client = self.app.client_manager.compute
+ aggregate = utils.find_resource(
+ compute_client.aggregates,
+ parsed_args.aggregate)
+
+ unset_property = {key: None for key in parsed_args.property}
+ compute_client.aggregates.set_metadata(aggregate,
+ unset_property)
diff --git a/openstackclient/compute/v2/flavor.py b/openstackclient/compute/v2/flavor.py
index b5a7c60c..29e0e9d4 100644
--- a/openstackclient/compute/v2/flavor.py
+++ b/openstackclient/compute/v2/flavor.py
@@ -76,10 +76,10 @@ class CreateFlavor(command.ShowOne):
)
parser.add_argument(
"--rxtx-factor",
- type=int,
+ type=float,
metavar="<factor>",
- default=1,
- help="RX/TX factor (default 1)",
+ default=1.0,
+ help="RX/TX factor (default 1.0)",
)
public_group = parser.add_mutually_exclusive_group()
public_group.add_argument(
diff --git a/openstackclient/compute/v2/floatingip.py b/openstackclient/compute/v2/floatingip.py
index 6212989f..fac4d2e3 100644
--- a/openstackclient/compute/v2/floatingip.py
+++ b/openstackclient/compute/v2/floatingip.py
@@ -15,8 +15,6 @@
"""Floating IP action implementations"""
-import six
-
from openstackclient.common import command
from openstackclient.common import utils
@@ -47,27 +45,6 @@ class AddFloatingIP(command.Command):
server.add_floating_ip(parsed_args.ip_address)
-class CreateFloatingIP(command.ShowOne):
- """Create new floating IP address"""
-
- def get_parser(self, prog_name):
- parser = super(CreateFloatingIP, self).get_parser(prog_name)
- parser.add_argument(
- 'pool',
- metavar='<pool>',
- help='Pool to fetch IP address from (name or ID)',
- )
- return parser
-
- def take_action(self, parsed_args):
- compute_client = self.app.client_manager.compute
- floating_ip = compute_client.floating_ips.create(parsed_args.pool)
-
- info = {}
- info.update(floating_ip._info)
- return zip(*sorted(six.iteritems(info)))
-
-
class RemoveFloatingIP(command.Command):
"""Remove floating IP address from server"""
diff --git a/openstackclient/compute/v2/host.py b/openstackclient/compute/v2/host.py
index f2257d12..5af25310 100644
--- a/openstackclient/compute/v2/host.py
+++ b/openstackclient/compute/v2/host.py
@@ -44,6 +44,63 @@ class ListHost(command.Lister):
) for s in data))
+class SetHost(command.Command):
+ """Set host properties"""
+ def get_parser(self, prog_name):
+ parser = super(SetHost, self).get_parser(prog_name)
+ parser.add_argument(
+ "host",
+ metavar="<host>",
+ help="The host to modify (name or ID)"
+ )
+ status = parser.add_mutually_exclusive_group()
+ status.add_argument(
+ '--enable',
+ action='store_true',
+ help='Enable the host'
+ )
+ status.add_argument(
+ '--disable',
+ action='store_true',
+ help='Disable the host'
+ )
+ maintenance = parser.add_mutually_exclusive_group()
+ maintenance.add_argument(
+ '--enable-maintenance',
+ action='store_true',
+ help='Enable maintenance mode for the host'
+ )
+ maintenance.add_argument(
+ '--disable-maintenance',
+ action='store_true',
+ help='Disable maintenance mode for the host',
+ )
+ return parser
+
+ def take_action(self, parsed_args):
+ kwargs = {}
+
+ if parsed_args.enable:
+ kwargs['status'] = True
+ if parsed_args.disable:
+ kwargs['status'] = False
+ if parsed_args.enable_maintenance:
+ kwargs['maintenance_mode'] = True
+ if parsed_args.disable_maintenance:
+ kwargs['maintenance_mode'] = False
+
+ compute_client = self.app.client_manager.compute
+ foundhost = utils.find_resource(
+ compute_client.hosts,
+ parsed_args.host
+ )
+
+ compute_client.hosts.update(
+ foundhost.id,
+ kwargs
+ )
+
+
class ShowHost(command.Lister):
"""Show host command"""
diff --git a/openstackclient/compute/v2/keypair.py b/openstackclient/compute/v2/keypair.py
index 22d918a4..1db0f942 100644
--- a/openstackclient/compute/v2/keypair.py
+++ b/openstackclient/compute/v2/keypair.py
@@ -48,8 +48,7 @@ class CreateKeypair(command.ShowOne):
public_key = parsed_args.public_key
if public_key:
try:
- with io.open(os.path.expanduser(parsed_args.public_key),
- "rb") as p:
+ with io.open(os.path.expanduser(parsed_args.public_key)) as p:
public_key = p.read()
except IOError as e:
msg = "Key file %s not found: %s"
diff --git a/openstackclient/compute/v2/security_group.py b/openstackclient/compute/v2/security_group.py
index 734bd78e..ca3bf5dc 100644
--- a/openstackclient/compute/v2/security_group.py
+++ b/openstackclient/compute/v2/security_group.py
@@ -16,15 +16,12 @@
"""Compute v2 Security Group action implementations"""
-import six
-
try:
from novaclient.v2 import security_group_rules
except ImportError:
from novaclient.v1_1 import security_group_rules
from openstackclient.common import command
-from openstackclient.common import parseractions
from openstackclient.common import utils
@@ -56,68 +53,6 @@ def _xform_security_group_rule(sgroup):
return info
-class CreateSecurityGroupRule(command.ShowOne):
- """Create a new security group rule"""
-
- def get_parser(self, prog_name):
- parser = super(CreateSecurityGroupRule, self).get_parser(prog_name)
- parser.add_argument(
- 'group',
- metavar='<group>',
- help='Create rule in this security group (name or ID)',
- )
- parser.add_argument(
- "--proto",
- metavar="<proto>",
- default="tcp",
- help="IP protocol (icmp, tcp, udp; default: tcp)",
- )
- source_group = parser.add_mutually_exclusive_group()
- source_group.add_argument(
- "--src-ip",
- metavar="<ip-address>",
- default="0.0.0.0/0",
- help="Source IP address block (may use CIDR notation; default: "
- "0.0.0.0/0)",
- )
- source_group.add_argument(
- "--src-group",
- metavar="<group>",
- help="Source security group (ID only)",
- )
- parser.add_argument(
- "--dst-port",
- metavar="<port-range>",
- default=(0, 0),
- action=parseractions.RangeAction,
- help="Destination port, may be a range: 137:139 (default: 0; "
- "only required for proto tcp and udp)",
- )
- return parser
-
- def take_action(self, parsed_args):
- compute_client = self.app.client_manager.compute
- group = utils.find_resource(
- compute_client.security_groups,
- parsed_args.group,
- )
- if parsed_args.proto.lower() == 'icmp':
- from_port, to_port = -1, -1
- else:
- from_port, to_port = parsed_args.dst_port
- data = compute_client.security_group_rules.create(
- group.id,
- parsed_args.proto,
- from_port,
- to_port,
- parsed_args.src_ip,
- parsed_args.src_group,
- )
-
- info = _xform_security_group_rule(data._info)
- return zip(*sorted(six.iteritems(info)))
-
-
class ListSecurityGroupRule(command.Lister):
"""List security group rules"""
diff --git a/openstackclient/compute/v2/server.py b/openstackclient/compute/v2/server.py
index 58174018..d3b601b0 100644
--- a/openstackclient/compute/v2/server.py
+++ b/openstackclient/compute/v2/server.py
@@ -1738,7 +1738,7 @@ class UnsetServer(command.Command):
action='append',
default=[],
help=_('Property key to remove from server '
- '(repeat to unset multiple values)'),
+ '(repeat to remove multiple values)'),
)
return parser
diff --git a/openstackclient/compute/v2/service.py b/openstackclient/compute/v2/service.py
index 89f5cad9..2b51af3d 100644
--- a/openstackclient/compute/v2/service.py
+++ b/openstackclient/compute/v2/service.py
@@ -17,6 +17,7 @@
from openstackclient.common import command
from openstackclient.common import utils
+from openstackclient.i18n import _ # noqa
class DeleteService(command.Command):
@@ -44,11 +45,11 @@ class ListService(command.Lister):
parser.add_argument(
"--host",
metavar="<host>",
- help="Name of host")
+ help="List services on specified host (name only)")
parser.add_argument(
"--service",
metavar="<service>",
- help="Name of service")
+ help="List only specified service (name only)")
parser.add_argument(
"--long",
action="store_true",
@@ -117,8 +118,8 @@ class SetService(command.Command):
"--disable-reason",
default=None,
metavar="<reason>",
- help="Reason for disabling the service (in quotas)"
- )
+ help="Reason for disabling the service (in quotas). Note that "
+ "when the service is enabled, this option is ignored.")
return parser
def take_action(self, parsed_args):
@@ -133,4 +134,8 @@ class SetService(command.Command):
else:
cs.disable(parsed_args.host, parsed_args.service)
else:
+ if parsed_args.disable_reason:
+ msg = _("argument --disable-reason has been ignored")
+ self.log.info(msg)
+
cs.enable(parsed_args.host, parsed_args.service)