1 # Licensed to the Apache Software Foundation (ASF) under one or more
2 # contributor license agreements. See the NOTICE file distributed with
3 # this work for additional information regarding copyright ownership.
4 # The ASF licenses this file to You under the Apache License, Version 2.0
5 # (the "License"); you may not use this file except in compliance with
6 # the License. You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
16 from aria.orchestrator.workflows.builtin import workflows
19 def _assert_relationships(operations, expected_op_full_name, relationships=0):
22 :param operations: and iterable of operations
23 :param expected_op_full_name: Note that source/target doesn't really matter since they are
25 :param relationships: the number of relationships
28 expected_op_name = expected_op_full_name.rsplit('_', 1)[0]
29 for _ in xrange(relationships):
30 # Since the target and source operations start of the same way, we only need to retrieve the
32 operation = next(operations)
33 relationship_id_1 = operation.actor.id
34 _assert_cfg_interface_op(operation, expected_op_name)
36 operation = next(operations)
37 relationship_id_2 = operation.actor.id
38 _assert_cfg_interface_op(operation, expected_op_name)
40 assert relationship_id_1 == relationship_id_2
43 def assert_node_install_operations(operations, relationships=0):
44 operations = iter(operations)
46 _assert_std_interface_op(next(operations), workflows.NORMATIVE_CREATE)
47 _assert_relationships(operations, workflows.NORMATIVE_PRE_CONFIGURE_SOURCE, relationships)
48 _assert_std_interface_op(next(operations), workflows.NORMATIVE_CONFIGURE)
49 _assert_relationships(operations, workflows.NORMATIVE_POST_CONFIGURE_SOURCE, relationships)
50 _assert_std_interface_op(next(operations), workflows.NORMATIVE_START)
51 _assert_relationships(operations, workflows.NORMATIVE_ADD_SOURCE, relationships)
54 def assert_node_uninstall_operations(operations, relationships=0):
55 operations = iter(operations)
57 _assert_std_interface_op(next(operations), workflows.NORMATIVE_STOP)
58 _assert_relationships(operations, workflows.NORMATIVE_REMOVE_SOURCE, relationships)
59 _assert_std_interface_op(next(operations), workflows.NORMATIVE_DELETE)
62 def _assert_cfg_interface_op(op, operation_name):
63 # We need to remove the source/target
64 assert op.operation_name.rsplit('_', 1)[0] == operation_name
65 assert op.interface_name == workflows.NORMATIVE_CONFIGURE_INTERFACE
68 def _assert_std_interface_op(op, operation_name):
69 assert op.operation_name == operation_name
70 assert op.interface_name == workflows.NORMATIVE_STANDARD_INTERFACE