Merge "Plugin sync added to new CLI"
This commit is contained in:
commit
9f0c5c86eb
|
@ -52,6 +52,7 @@ def get_client(resource, version='v1'):
|
|||
'fuel-version': v1.fuelversion,
|
||||
'network-group': v1.network_group,
|
||||
'node': v1.node,
|
||||
'plugins': v1.plugins,
|
||||
'task': v1.task,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
# 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 fuelclient.commands import base
|
||||
|
||||
|
||||
class PluginsMixIn(object):
|
||||
entity_name = 'plugins'
|
||||
|
||||
|
||||
class PluginsSync(PluginsMixIn, base.BaseCommand):
|
||||
"""Synchronise plugins on file system with plugins in API service."""
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super(PluginsSync, self).get_parser(prog_name)
|
||||
parser.add_argument(
|
||||
'ids',
|
||||
type=int,
|
||||
nargs='*',
|
||||
metavar='plugin-id',
|
||||
help='Synchronise only plugins with specified ids')
|
||||
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
ids = parsed_args.ids if len(parsed_args.ids) > 0 else None
|
||||
self.client.sync(ids=ids)
|
||||
self.app.stdout.write("Plugins were successfully synchronized.")
|
|
@ -26,3 +26,4 @@ from fuelclient.objects.task import SnapshotTask
|
|||
from fuelclient.objects.task import Task
|
||||
from fuelclient.objects.fuelversion import FuelVersion
|
||||
from fuelclient.objects.network_group import NetworkGroup
|
||||
from fuelclient.objects.plugins import Plugins
|
||||
|
|
|
@ -290,7 +290,7 @@ class Plugins(base.BaseObject):
|
|||
:returns: None
|
||||
"""
|
||||
post_data = None
|
||||
if plugin_ids:
|
||||
if plugin_ids is not None:
|
||||
post_data = {'ids': plugin_ids}
|
||||
|
||||
cls.connection.post_request(
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# 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 mock
|
||||
|
||||
from fuelclient.tests.unit.v2.cli import test_engine
|
||||
|
||||
|
||||
class TestPluginsCommand(test_engine.BaseCLITest):
|
||||
"""Tests for fuel2 node * commands."""
|
||||
|
||||
def setUp(self):
|
||||
super(TestPluginsCommand, self).setUp()
|
||||
|
||||
def test_plugins_sync_all(self):
|
||||
args = 'plugins sync'
|
||||
self.exec_command(args)
|
||||
|
||||
self.m_get_client.assert_called_once_with('plugins', mock.ANY)
|
||||
self.m_client.sync.assert_called_once_with(ids=None)
|
||||
|
||||
def test_plugins_sync_specified_plugins(self):
|
||||
ids = [1, 2]
|
||||
args = 'plugins sync {ids}'.format(ids=' '.join(map(str, ids)))
|
||||
self.exec_command(args)
|
||||
|
||||
self.m_get_client.assert_called_once_with('plugins', mock.ANY)
|
||||
self.m_client.sync.assert_called_once_with(ids=ids)
|
|
@ -0,0 +1,55 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# 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 fuelclient
|
||||
from fuelclient.tests.unit.v2.lib import test_api
|
||||
|
||||
|
||||
class TestPluginsFacade(test_api.BaseLibTest):
|
||||
|
||||
def setUp(self):
|
||||
super(TestPluginsFacade, self).setUp()
|
||||
|
||||
self.version = 'v1'
|
||||
self.client = fuelclient.get_client('plugins', self.version)
|
||||
|
||||
def test_sync_plugins(self):
|
||||
expected_uri = '/api/{version}/plugins/sync/'.format(
|
||||
version=self.version
|
||||
)
|
||||
matcher = self.m_request.post(expected_uri, json={})
|
||||
self.client.sync(None)
|
||||
self.assertTrue(matcher.called)
|
||||
self.assertIsNone(matcher.last_request.body)
|
||||
|
||||
def test_sync_plugins_empty_ids(self):
|
||||
expected_uri = '/api/{version}/plugins/sync/'.format(
|
||||
version=self.version
|
||||
)
|
||||
matcher = self.m_request.post(expected_uri, json={})
|
||||
self.client.sync([])
|
||||
self.assertTrue(matcher.called)
|
||||
self.assertEqual([], matcher.last_request.json()['ids'])
|
||||
|
||||
def test_sync_specified_plugins(self):
|
||||
expected_uri = '/api/{version}/plugins/sync/'.format(
|
||||
version=self.version
|
||||
)
|
||||
ids = [1, 2]
|
||||
matcher = self.m_request.post(expected_uri, json={})
|
||||
self.client.sync(ids=ids)
|
||||
self.assertTrue(matcher.called)
|
||||
self.assertEqual(ids, matcher.last_request.json()['ids'])
|
|
@ -17,11 +17,12 @@ from fuelclient.v1 import fuelversion
|
|||
from fuelclient.v1 import network_group
|
||||
from fuelclient.v1 import node
|
||||
from fuelclient.v1 import task
|
||||
|
||||
from fuelclient.v1 import plugins
|
||||
|
||||
# Please keeps the list in alphabetical order
|
||||
__all__ = ('environment',
|
||||
'fuelversion',
|
||||
'network_group',
|
||||
'node',
|
||||
'task')
|
||||
'plugins',
|
||||
'task',)
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
# 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 fuelclient import objects
|
||||
from fuelclient.v1 import base_v1
|
||||
|
||||
|
||||
class PluginsClient(base_v1.BaseV1Client):
|
||||
|
||||
_entity_wrapper = objects.Plugins
|
||||
|
||||
def sync(self, ids):
|
||||
"""Synchronise plugins on file system with plugins in API service.
|
||||
|
||||
:param ids: List of ids for filtering plugins
|
||||
:type ids: list
|
||||
"""
|
||||
|
||||
self._entity_wrapper.sync(plugin_ids=ids)
|
||||
|
||||
|
||||
def get_client():
|
||||
return PluginsClient()
|
41
setup.cfg
41
setup.cfg
|
@ -30,34 +30,35 @@ console_scripts =
|
|||
fuel2=fuelclient.main:main
|
||||
|
||||
fuelclient =
|
||||
env_list=fuelclient.commands.environment:EnvList
|
||||
env_add_nodes=fuelclient.commands.environment:EnvAddNodes
|
||||
env_create=fuelclient.commands.environment:EnvCreate
|
||||
env_show=fuelclient.commands.environment:EnvShow
|
||||
env_delete=fuelclient.commands.environment:EnvDelete
|
||||
env_deploy=fuelclient.commands.environment:EnvDeploy
|
||||
env_list=fuelclient.commands.environment:EnvList
|
||||
env_show=fuelclient.commands.environment:EnvShow
|
||||
env_spawn-vms=fuelclient.commands.environment:EnvSpawnVms
|
||||
env_update=fuelclient.commands.environment:EnvUpdate
|
||||
env_upgrade=fuelclient.commands.environment:EnvUpgrade
|
||||
env_deploy=fuelclient.commands.environment:EnvDeploy
|
||||
env_add_nodes=fuelclient.commands.environment:EnvAddNodes
|
||||
env_spawn-vms=fuelclient.commands.environment:EnvSpawnVms
|
||||
node_list=fuelclient.commands.node:NodeList
|
||||
node_show=fuelclient.commands.node:NodeShow
|
||||
node_list-vms-conf=fuelclient.commands.node:NodeVmsList
|
||||
node_create-vms-conf=fuelclient.commands.node:NodeCreateVMsConf
|
||||
node_update=fuelclient.commands.node:NodeUpdate
|
||||
node_label_list=fuelclient.commands.node:NodeLabelList
|
||||
node_label_set=fuelclient.commands.node:NodeLabelSet
|
||||
node_label_delete=fuelclient.commands.node:NodeLabelDelete
|
||||
task_list=fuelclient.commands.task:TaskList
|
||||
task_show=fuelclient.commands.task:TaskShow
|
||||
fuel-version=fuelclient.commands.fuelversion:FuelVersion
|
||||
network-template_upload=fuelclient.commands.network_template:NetworkTemplateUpload
|
||||
network-template_download=fuelclient.commands.network_template:NetworkTemplateDownload
|
||||
network-template_delete=fuelclient.commands.network_template:NetworkTemplateDelete
|
||||
network-group_create=fuelclient.commands.network_group:NetworkGroupCreate
|
||||
network-group_delete=fuelclient.commands.network_group:NetworkGroupDelete
|
||||
network-group_list=fuelclient.commands.network_group:NetworkGroupList
|
||||
network-group_show=fuelclient.commands.network_group:NetworkGroupShow
|
||||
network-group_create=fuelclient.commands.network_group:NetworkGroupCreate
|
||||
network-group_update=fuelclient.commands.network_group:NetworkGroupUpdate
|
||||
network-group_delete=fuelclient.commands.network_group:NetworkGroupDelete
|
||||
network-template_delete=fuelclient.commands.network_template:NetworkTemplateDelete
|
||||
network-template_download=fuelclient.commands.network_template:NetworkTemplateDownload
|
||||
network-template_upload=fuelclient.commands.network_template:NetworkTemplateUpload
|
||||
node_create-vms-conf=fuelclient.commands.node:NodeCreateVMsConf
|
||||
node_label_delete=fuelclient.commands.node:NodeLabelDelete
|
||||
node_label_list=fuelclient.commands.node:NodeLabelList
|
||||
node_label_set=fuelclient.commands.node:NodeLabelSet
|
||||
node_list-vms-conf=fuelclient.commands.node:NodeVmsList
|
||||
node_list=fuelclient.commands.node:NodeList
|
||||
node_show=fuelclient.commands.node:NodeShow
|
||||
node_update=fuelclient.commands.node:NodeUpdate
|
||||
plugins_sync=fuelclient.commands.plugins:PluginsSync
|
||||
task_list=fuelclient.commands.task:TaskList
|
||||
task_show=fuelclient.commands.task:TaskShow
|
||||
|
||||
[global]
|
||||
setup-hooks =
|
||||
|
|
Loading…
Reference in New Issue