Compare commits

...

13 Commits

Author SHA1 Message Date
OpenDev Sysadmins
8d5e816eaa OpenDev Migration Patch
This commit was bulk generated and pushed by the OpenDev sysadmins
as a part of the Git hosting and code review systems migration
detailed in these mailing list posts:

http://lists.openstack.org/pipermail/openstack-discuss/2019-March/003603.html
http://lists.openstack.org/pipermail/openstack-discuss/2019-April/004920.html

Attempts have been made to correct repository namespaces and
hostnames based on simple pattern matching, but it's possible some
were updated incorrectly or missed entirely. Please reach out to us
via the contact information listed at https://opendev.org/ with any
questions you may have.
2019-04-19 19:40:45 +00:00
Ian Wienand
9c3736cb1b Replace openstack.org git:// URLs with https://
This is a mechanically generated change to replace openstack.org
git:// URLs with https:// equivalents.

This is in aid of a planned future move of the git hosting
infrastructure to a self-hosted instance of gitea (https://gitea.io),
which does not support the git wire protocol at this stage.

This update should result in no functional change.

For more information see the thread at

 http://lists.openstack.org/pipermail/openstack-discuss/2019-March/003825.html

Change-Id: I9e141aa8e7387a2a8d96fce1d3f54a159d33f4d9
2019-03-24 20:36:25 +00:00
Nguyen Hai
520cdb3c51 import zuul job settings from project-config
This is a mechanically generated patch to complete step 1 of moving
the zuul job settings out of project-config and into each project
repository.

Because there will be a separate patch on each branch, the branch
specifiers for branch-specific jobs have been removed.

Because this patch is generated by a script, there may be some
cosmetic changes to the layout of the YAML file(s) as the contents are
normalized.

See the python3-first goal document for details:
https://governance.openstack.org/tc/goals/stein/python3-first.html

Change-Id: I3e87bc419d17348c71733c79016a27fa6c00955c
Story: #2002586
Task: #24344
2018-08-19 00:58:37 +09:00
OpenStack Proposal Bot
4d8d1cd356 Updated from global requirements
Change-Id: I8c3d97e4003ecc5aeeb1b5304fcb36a58367fa9f
2017-05-15 23:41:13 +00:00
OpenStack Proposal Bot
6d4fb3c3eb Updated from global requirements
Change-Id: Idb62b9824ccd8cad7a4084bd085ccf014d5610fa
2017-03-09 18:26:17 +00:00
Jenkins
1caf89686c Merge "Add checking audit state" into stable/ocata 2017-02-16 13:53:58 +00:00
Hidekazu Nakamura
ed3224835a Add checking audit state
This patch adds checking audit state when updating an existing audit
in accordance with audit state machine.

Closes-Bug: #1662406

Change-Id: I20610c83169b77f141974a5cebe33818a4bf0728
(cherry picked from commit 0d83354c57)
2017-02-16 13:16:06 +00:00
ericxiett
8a7e316f73 Fix that remove 'strategy' attribute does not work.
The 'strategy_id' attribute is the one that not exposes
to API. But the 'PATCH' API always update this attribute.
So this change does not work when choose 'remove' op.
This patch sets value for 'strategy_id' attribute.

Change-Id: I1597fb5d4985bb8271ad3cea7ea5f0adb7de65f4
Closes-Bug: #1662395
(cherry picked from commit e55c73be0e)
2017-02-16 13:15:48 +00:00
Jenkins
112ac3bbdf Merge "Fix log level error to warning" into stable/ocata 2017-02-14 10:27:17 +00:00
licanwei
d1ab697612 Fix the mapping between the instance and the node
The argument to the add_edge function should be instance.uuid
and node.uuid, not instance and node

Change-Id: Ida694f9158d3eb26e7f31062a18844472ea3c6fa
Closes-Bug: #1662810
2017-02-08 15:37:01 +00:00
Hidekazu Nakamura
095ca0ffb2 Fix log level error to warning
When action plan is currently running, new action plan is set as
SUPERSEDED and error log reported. This patch changes log level
from error to warning.

Change-Id: I931218843d8f09340bd5363256164807d514446b
Closes-Bug: #1662450
(cherry picked from commit 58711aaaec)
2017-02-08 00:05:44 +00:00
OpenStack Release Bot
e1131a65d8 Update UPPER_CONSTRAINTS_FILE for stable/ocata
Change-Id: Ie56e3186f2c9e42aff817fc7c71c4da93abb1c5f
2017-02-02 18:23:36 +00:00
OpenStack Release Bot
5e507e56f4 Update .gitreview for stable/ocata
Change-Id: I5a431c04e85183baf05736de3920d6610d4add03
2017-02-02 18:23:36 +00:00
13 changed files with 177 additions and 12 deletions

View File

@@ -1,4 +1,5 @@
[gerrit] [gerrit]
host=review.openstack.org host=review.opendev.org
port=29418 port=29418
project=openstack/watcher.git project=openstack/watcher.git
defaultbranch=stable/ocata

9
.zuul.yaml Normal file
View File

@@ -0,0 +1,9 @@
- project:
templates:
- openstack-python-jobs
- openstack-python35-jobs
- publish-openstack-sphinx-docs
- check-requirements
- release-notes-jobs
gate:
queue: watcher

View File

@@ -35,7 +35,7 @@ VNCSERVER_PROXYCLIENT_ADDRESS=$HOST_IP
NOVA_INSTANCES_PATH=/opt/stack/data/instances NOVA_INSTANCES_PATH=/opt/stack/data/instances
# Enable the Ceilometer plugin for the compute agent # Enable the Ceilometer plugin for the compute agent
enable_plugin ceilometer git://git.openstack.org/openstack/ceilometer enable_plugin ceilometer https://git.openstack.org/openstack/ceilometer
disable_service ceilometer-acentral,ceilometer-collector,ceilometer-api disable_service ceilometer-acentral,ceilometer-collector,ceilometer-api
LOGFILE=$DEST/logs/stack.sh.log LOGFILE=$DEST/logs/stack.sh.log

View File

@@ -28,13 +28,13 @@ ENABLED_SERVICES+=,q-svc,q-dhcp,q-meta,q-agt,q-l3,neutron
enable_service n-cauth enable_service n-cauth
# Enable the Watcher Dashboard plugin # Enable the Watcher Dashboard plugin
# enable_plugin watcher-dashboard git://git.openstack.org/openstack/watcher-dashboard # enable_plugin watcher-dashboard https://git.openstack.org/openstack/watcher-dashboard
# Enable the Watcher plugin # Enable the Watcher plugin
enable_plugin watcher git://git.openstack.org/openstack/watcher enable_plugin watcher https://git.openstack.org/openstack/watcher
# Enable the Ceilometer plugin # Enable the Ceilometer plugin
enable_plugin ceilometer git://git.openstack.org/openstack/ceilometer enable_plugin ceilometer https://git.openstack.org/openstack/ceilometer
# This is the controller node, so disable the ceilometer compute agent # This is the controller node, so disable the ceilometer compute agent
disable_service ceilometer-acompute disable_service ceilometer-acompute

View File

@@ -165,7 +165,7 @@ You can easily generate and update a sample configuration file
named :ref:`watcher.conf.sample <watcher_sample_configuration_files>` by using named :ref:`watcher.conf.sample <watcher_sample_configuration_files>` by using
these following commands:: these following commands::
$ git clone git://git.openstack.org/openstack/watcher $ git clone https://git.openstack.org/openstack/watcher
$ cd watcher/ $ cd watcher/
$ tox -e genconfig $ tox -e genconfig
$ vi etc/watcher/watcher.conf.sample $ vi etc/watcher/watcher.conf.sample

View File

@@ -19,7 +19,7 @@ model. To enable the Watcher plugin with DevStack, add the following to the
`[[local|localrc]]` section of your controller's `local.conf` to enable the `[[local|localrc]]` section of your controller's `local.conf` to enable the
Watcher plugin:: Watcher plugin::
enable_plugin watcher git://git.openstack.org/openstack/watcher enable_plugin watcher https://git.openstack.org/openstack/watcher
For more detailed instructions, see `Detailed DevStack Instructions`_. Check For more detailed instructions, see `Detailed DevStack Instructions`_. Check
out the `DevStack documentation`_ for more information regarding DevStack. out the `DevStack documentation`_ for more information regarding DevStack.

View File

@@ -6,7 +6,7 @@ skipsdist = True
[testenv] [testenv]
usedevelop = True usedevelop = True
whitelist_externals = find whitelist_externals = find
install_command = pip install -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt} {opts} {packages} install_command = pip install -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt?h=stable/ocata} {opts} {packages}
setenv = setenv =
VIRTUAL_ENV={envdir} VIRTUAL_ENV={envdir}
deps = -r{toxinidir}/test-requirements.txt deps = -r{toxinidir}/test-requirements.txt

View File

@@ -50,6 +50,21 @@ from watcher.decision_engine import rpcapi
from watcher import objects from watcher import objects
ALLOWED_AUDIT_TRANSITIONS = {
objects.audit.State.PENDING:
[objects.audit.State.ONGOING, objects.audit.State.CANCELLED],
objects.audit.State.ONGOING:
[objects.audit.State.FAILED, objects.audit.State.SUCCEEDED,
objects.audit.State.CANCELLED],
objects.audit.State.FAILED:
[objects.audit.State.DELETED],
objects.audit.State.SUCCEEDED:
[objects.audit.State.DELETED],
objects.audit.State.CANCELLED:
[objects.audit.State.DELETED]
}
class AuditPostType(wtypes.Base): class AuditPostType(wtypes.Base):
audit_template_uuid = wtypes.wsattr(types.uuid, mandatory=False) audit_template_uuid = wtypes.wsattr(types.uuid, mandatory=False)
@@ -561,6 +576,17 @@ class AuditsController(rest.RestController):
except api_utils.JSONPATCH_EXCEPTIONS as e: except api_utils.JSONPATCH_EXCEPTIONS as e:
raise exception.PatchError(patch=patch, reason=e) raise exception.PatchError(patch=patch, reason=e)
initial_state = audit_dict['state']
new_state = api_utils.get_patch_value(patch, 'state')
allowed_states = ALLOWED_AUDIT_TRANSITIONS.get(initial_state, [])
if new_state is not None and new_state not in allowed_states:
error_message = _("State transition not allowed: "
"(%(initial_state)s -> %(new_state)s)")
raise exception.PatchError(
patch=patch,
reason=error_message % dict(
initial_state=initial_state, new_state=new_state))
# Update only the fields that have changed # Update only the fields that have changed
for field in objects.Audit.fields: for field in objects.Audit.fields:
try: try:

View File

@@ -333,6 +333,7 @@ class AuditTemplate(base.APIBase):
self.fields.append('goal_id') self.fields.append('goal_id')
self.fields.append('strategy_id') self.fields.append('strategy_id')
setattr(self, 'strategy_id', kwargs.get('strategy_id', wtypes.Unset))
# goal_uuid & strategy_uuid are not part of # goal_uuid & strategy_uuid are not part of
# objects.AuditTemplate.fields because they're API-only attributes. # objects.AuditTemplate.fields because they're API-only attributes.

View File

@@ -73,6 +73,12 @@ def apply_jsonpatch(doc, patch):
return jsonpatch.apply_patch(doc, jsonpatch.JsonPatch(patch)) return jsonpatch.apply_patch(doc, jsonpatch.JsonPatch(patch))
def get_patch_value(patch, key):
for p in patch:
if p['op'] == 'replace' and p['path'] == '/%s' % key:
return p['value']
def as_filters_dict(**filters): def as_filters_dict(**filters):
filters_dict = {} filters_dict = {}
for filter_name, filter_value in filters.items(): for filter_name, filter_value in filters.items():

View File

@@ -129,7 +129,7 @@ class AuditHandler(BaseAuditHandler):
solution = self.do_execute(audit, request_context) solution = self.do_execute(audit, request_context)
self.post_execute(audit, solution, request_context) self.post_execute(audit, solution, request_context)
except exception.ActionPlanIsOngoing as e: except exception.ActionPlanIsOngoing as e:
LOG.exception(e) LOG.warning(e)
if audit.audit_type == objects.audit.AuditType.ONESHOT.value: if audit.audit_type == objects.audit.AuditType.ONESHOT.value:
self.update_audit_state(audit, objects.audit.State.CANCELLED) self.update_audit_state(audit, objects.audit.State.CANCELLED)
except Exception as e: except Exception as e:

View File

@@ -215,8 +215,7 @@ class ModelBuilder(object):
compute_node = self.model.get_node_by_uuid( compute_node = self.model.get_node_by_uuid(
cnode_uuid) cnode_uuid)
# Connect the instance to its compute node # Connect the instance to its compute node
self.model.add_edge( self.model.map_instance(instance, compute_node)
instance, compute_node, label='RUNS_ON')
except exception.ComputeNodeNotFound: except exception.ComputeNodeNotFound:
continue continue

View File

@@ -11,6 +11,7 @@
# limitations under the License. # limitations under the License.
import datetime import datetime
import itertools
import mock import mock
from oslo_config import cfg from oslo_config import cfg
@@ -267,7 +268,7 @@ class TestPatch(api_base.FunctionalTest):
test_time = datetime.datetime(2000, 1, 1, 0, 0) test_time = datetime.datetime(2000, 1, 1, 0, 0)
mock_utcnow.return_value = test_time mock_utcnow.return_value = test_time
new_state = objects.audit.State.SUCCEEDED new_state = objects.audit.State.CANCELLED
response = self.get_json('/audits/%s' % self.audit.uuid) response = self.get_json('/audits/%s' % self.audit.uuid)
self.assertNotEqual(new_state, response['state']) self.assertNotEqual(new_state, response['state'])
@@ -343,6 +344,128 @@ class TestPatch(api_base.FunctionalTest):
self.assertTrue(response.json['error_message']) self.assertTrue(response.json['error_message'])
ALLOWED_TRANSITIONS = [
{"original_state": objects.audit.State.PENDING,
"new_state": objects.audit.State.ONGOING},
{"original_state": objects.audit.State.PENDING,
"new_state": objects.audit.State.CANCELLED},
{"original_state": objects.audit.State.ONGOING,
"new_state": objects.audit.State.FAILED},
{"original_state": objects.audit.State.ONGOING,
"new_state": objects.audit.State.SUCCEEDED},
{"original_state": objects.audit.State.ONGOING,
"new_state": objects.audit.State.CANCELLED},
{"original_state": objects.audit.State.FAILED,
"new_state": objects.audit.State.DELETED},
{"original_state": objects.audit.State.SUCCEEDED,
"new_state": objects.audit.State.DELETED},
{"original_state": objects.audit.State.CANCELLED,
"new_state": objects.audit.State.DELETED},
]
class TestPatchStateTransitionDenied(api_base.FunctionalTest):
STATES = [
ap_state for ap_state in objects.audit.State.__dict__
if not ap_state.startswith("_")
]
scenarios = [
(
"%s -> %s" % (original_state, new_state),
{"original_state": original_state,
"new_state": new_state},
)
for original_state, new_state
in list(itertools.product(STATES, STATES))
if original_state != new_state
and {"original_state": original_state,
"new_state": new_state} not in ALLOWED_TRANSITIONS
]
def setUp(self):
super(TestPatchStateTransitionDenied, self).setUp()
obj_utils.create_test_goal(self.context)
obj_utils.create_test_strategy(self.context)
obj_utils.create_test_audit_template(self.context)
self.audit = obj_utils.create_test_audit(self.context,
state=self.original_state)
p = mock.patch.object(db_api.BaseConnection, 'update_audit')
self.mock_audit_update = p.start()
self.mock_audit_update.side_effect = self._simulate_rpc_audit_update
self.addCleanup(p.stop)
def _simulate_rpc_audit_update(self, audit):
audit.save()
return audit
def test_replace_denied(self):
response = self.get_json('/audits/%s' % self.audit.uuid)
self.assertNotEqual(self.new_state, response['state'])
response = self.patch_json(
'/audits/%s' % self.audit.uuid,
[{'path': '/state', 'value': self.new_state,
'op': 'replace'}],
expect_errors=True)
self.assertEqual('application/json', response.content_type)
self.assertEqual(400, response.status_code)
self.assertTrue(response.json['error_message'])
response = self.get_json('/audits/%s' % self.audit.uuid)
self.assertEqual(self.original_state, response['state'])
class TestPatchStateTransitionOk(api_base.FunctionalTest):
scenarios = [
(
"%s -> %s" % (transition["original_state"],
transition["new_state"]),
transition
)
for transition in ALLOWED_TRANSITIONS
]
def setUp(self):
super(TestPatchStateTransitionOk, self).setUp()
obj_utils.create_test_goal(self.context)
obj_utils.create_test_strategy(self.context)
obj_utils.create_test_audit_template(self.context)
self.audit = obj_utils.create_test_audit(self.context,
state=self.original_state)
p = mock.patch.object(db_api.BaseConnection, 'update_audit')
self.mock_audit_update = p.start()
self.mock_audit_update.side_effect = self._simulate_rpc_audit_update
self.addCleanup(p.stop)
def _simulate_rpc_audit_update(self, audit):
audit.save()
return audit
@mock.patch('oslo_utils.timeutils.utcnow')
def test_replace_ok(self, mock_utcnow):
test_time = datetime.datetime(2000, 1, 1, 0, 0)
mock_utcnow.return_value = test_time
response = self.get_json('/audits/%s' % self.audit.uuid)
self.assertNotEqual(self.new_state, response['state'])
response = self.patch_json(
'/audits/%s' % self.audit.uuid,
[{'path': '/state', 'value': self.new_state,
'op': 'replace'}])
self.assertEqual('application/json', response.content_type)
self.assertEqual(200, response.status_code)
response = self.get_json('/audits/%s' % self.audit.uuid)
self.assertEqual(self.new_state, response['state'])
return_updated_at = timeutils.parse_isotime(
response['updated_at']).replace(tzinfo=None)
self.assertEqual(test_time, return_updated_at)
class TestPost(api_base.FunctionalTest): class TestPost(api_base.FunctionalTest):
def setUp(self): def setUp(self):