diff --git a/doc/source/command-objects/compute-agent.rst b/doc/source/command-objects/compute-agent.rst new file mode 100644 index 0000000000..395ee4f372 --- /dev/null +++ b/doc/source/command-objects/compute-agent.rst @@ -0,0 +1,100 @@ +============= +compute agent +============= + +Compute v2 + +compute agent create +-------------------- + +Create compute agent + +.. program:: compute agent create +.. code:: bash + + os compute agent create + + + +.. _compute_agent-create: +.. describe:: + + Type of OS + +.. describe:: + + Type of architecture + +.. describe:: + + Version + +.. describe:: + + URL + +.. describe:: + + MD5 hash + +.. describe:: + + Type of hypervisor + +compute agent delete +-------------------- + +Delete compute agent command + +.. program:: compute agent delete +.. code:: bash + + os compute agent delete + +.. _compute_agent-delete: +.. describe:: + + ID of agent to delete + +compute agent list +------------------ + +List compute agent command + +.. program:: compute agent list +.. code:: bash + + os compute agent list [--hypervisor ] + +.. _compute_agent-list: +.. describe:: --hypervisor + + Optional type of hypervisor + +compute agent set +----------------- + +Set compute agent command + +.. program:: agent set +.. code:: bash + + os compute agent set + + +.. _compute_agent-set: +.. describe:: + + ID of the agent + +.. describe:: + + Version of the agent + +.. describe:: + + URL + +.. describe:: + + MD5 hash diff --git a/doc/source/command-objects/compute-service.rst b/doc/source/command-objects/compute-service.rst new file mode 100644 index 0000000000..95a77bdf29 --- /dev/null +++ b/doc/source/command-objects/compute-service.rst @@ -0,0 +1,73 @@ +=============== +compute service +=============== + +Compute v2 + +compute service delete +---------------------- + +Delete service command + +.. program:: compute service delete +.. code:: bash + + os compute service delete + + +.. _compute-service-delete: +.. describe:: + + Compute service to delete (ID only) + +compute service list +-------------------- + +List service command + +.. program:: compute service list +.. code:: bash + + os compute service list + [--host ] + [--service ] + +.. _compute-service-list: +.. describe:: --host + + Name of host + +.. describe:: --service + + Name of service + + +compute service set +------------------- + +Set service command + +.. program:: compute service set +.. code:: bash + + os compute service list + [--enable | --disable] + + +.. _compute-service-set: +.. describe:: --enable + + Enable service + +.. describe:: --disable + + Disable service + +.. describe:: + + Name of host + +.. describe:: + + Name of service + diff --git a/openstackclient/compute/v2/service.py b/openstackclient/compute/v2/service.py index 3a031bff25..c2d51c2aa3 100644 --- a/openstackclient/compute/v2/service.py +++ b/openstackclient/compute/v2/service.py @@ -17,11 +17,33 @@ import logging +from cliff import command from cliff import lister from openstackclient.common import utils +class DeleteService(command.Command): + """Delete service command""" + + log = logging.getLogger(__name__ + ".DeleteService") + + def get_parser(self, prog_name): + parser = super(DeleteService, self).get_parser(prog_name) + parser.add_argument( + "service", + metavar="", + help="Compute service to delete (ID only)") + return parser + + def take_action(self, parsed_args): + self.log.debug("take_action(%s)", parsed_args) + compute_client = self.app.client_manager.compute + + compute_client.services.delete(parsed_args.service) + return + + class ListService(lister.Lister): """List service command""" diff --git a/openstackclient/tests/compute/v2/fakes.py b/openstackclient/tests/compute/v2/fakes.py index e798bd4036..08eb5afa8e 100644 --- a/openstackclient/tests/compute/v2/fakes.py +++ b/openstackclient/tests/compute/v2/fakes.py @@ -25,6 +25,8 @@ from openstackclient.tests import utils server_id = 'serv1' server_name = 'waiter' +service_id = '1' + SERVER = { 'id': server_id, 'name': server_name, @@ -85,6 +87,8 @@ class FakeComputev2Client(object): self.images.resource_class = fakes.FakeResource(None, {}) self.servers = mock.Mock() self.servers.resource_class = fakes.FakeResource(None, {}) + self.services = mock.Mock() + self.services.resource_class = fakes.FakeResource(None, {}) self.extensions = mock.Mock() self.extensions.resource_class = fakes.FakeResource(None, {}) self.flavors = mock.Mock() diff --git a/openstackclient/tests/compute/v2/test_service.py b/openstackclient/tests/compute/v2/test_service.py new file mode 100644 index 0000000000..c6db30ac27 --- /dev/null +++ b/openstackclient/tests/compute/v2/test_service.py @@ -0,0 +1,54 @@ +# 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. +# + +from openstackclient.compute.v2 import service +from openstackclient.tests.compute.v2 import fakes as compute_fakes + + +class TestService(compute_fakes.TestComputev2): + + def setUp(self): + super(TestService, self).setUp() + + # Get a shortcut to the ServiceManager Mock + self.service_mock = self.app.client_manager.compute.services + self.service_mock.reset_mock() + + +class TestServiceDelete(TestService): + + def setUp(self): + super(TestServiceDelete, self).setUp() + + self.service_mock.delete.return_value = None + + # Get the command object to test + self.cmd = service.DeleteService(self.app, None) + + def test_service_delete_no_options(self): + arglist = [ + compute_fakes.service_id, + ] + verifylist = [ + ('service', compute_fakes.service_id), + ] + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + + # DisplayCommandBase.take_action() returns two tuples + self.cmd.take_action(parsed_args) + + self.service_mock.delete.assert_called_with( + compute_fakes.service_id, + ) diff --git a/setup.cfg b/setup.cfg index d917f04210..b59b8474f6 100644 --- a/setup.cfg +++ b/setup.cfg @@ -66,6 +66,7 @@ openstack.compute.v2 = aggregate_set = openstackclient.compute.v2.aggregate:SetAggregate aggregate_show = openstackclient.compute.v2.aggregate:ShowAggregate + compute_service_delete = openstackclient.compute.v2.service:DeleteService compute_service_list = openstackclient.compute.v2.service:ListService compute_service_set = openstackclient.compute.v2.service:SetService