Merge "Add compute service delete"

This commit is contained in:
Jenkins 2015-11-11 19:31:01 +00:00 committed by Gerrit Code Review
commit 0cc0b8d112
6 changed files with 254 additions and 0 deletions

View File

@ -0,0 +1,100 @@
=============
compute agent
=============
Compute v2
compute agent create
--------------------
Create compute agent
.. program:: compute agent create
.. code:: bash
os compute agent create
<os> <architecture> <version> <url> <md5hash>
<hypervisor>
.. _compute_agent-create:
.. describe:: <os>
Type of OS
.. describe:: <architecture>
Type of architecture
.. describe:: <version>
Version
.. describe:: <url>
URL
.. describe:: <md5hash>
MD5 hash
.. describe:: <hypervisor>
Type of hypervisor
compute agent delete
--------------------
Delete compute agent command
.. program:: compute agent delete
.. code:: bash
os compute agent delete <id>
.. _compute_agent-delete:
.. describe:: <id>
ID of agent to delete
compute agent list
------------------
List compute agent command
.. program:: compute agent list
.. code:: bash
os compute agent list [--hypervisor <hypervisor>]
.. _compute_agent-list:
.. describe:: --hypervisor <hypervisor>
Optional type of hypervisor
compute agent set
-----------------
Set compute agent command
.. program:: agent set
.. code:: bash
os compute agent set
<id> <version> <url> <md5hash>
.. _compute_agent-set:
.. describe:: <id>
ID of the agent
.. describe:: <version>
Version of the agent
.. describe:: <url>
URL
.. describe:: <md5hash>
MD5 hash

View File

@ -0,0 +1,73 @@
===============
compute service
===============
Compute v2
compute service delete
----------------------
Delete service command
.. program:: compute service delete
.. code:: bash
os compute service delete
<service>
.. _compute-service-delete:
.. describe:: <service>
Compute service to delete (ID only)
compute service list
--------------------
List service command
.. program:: compute service list
.. code:: bash
os compute service list
[--host <host>]
[--service <service>]
.. _compute-service-list:
.. describe:: --host <host>
Name of host
.. describe:: --service <service>
Name of service
compute service set
-------------------
Set service command
.. program:: compute service set
.. code:: bash
os compute service list
[--enable | --disable]
<host> <service>
.. _compute-service-set:
.. describe:: --enable
Enable service
.. describe:: --disable
Disable service
.. describe:: <host>
Name of host
.. describe:: <service>
Name of service

View File

@ -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="<service>",
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"""

View File

@ -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()

View File

@ -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,
)

View File

@ -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