diff --git a/watcher/decision_engine/model/element/volume.py b/watcher/decision_engine/model/element/volume.py
index f96cd7cc5..ededef5e4 100644
--- a/watcher/decision_engine/model/element/volume.py
+++ b/watcher/decision_engine/model/element/volume.py
@@ -46,7 +46,7 @@ class Volume(storage_resource.StorageResource):
"attachments": wfields.FlexibleListOfDictField(),
"name": wfields.StringField(),
"multiattach": wfields.BooleanField(),
- "snapshot_id": wfields.UUIDField(),
+ "snapshot_id": wfields.UUIDField(nullable=True),
"project_id": wfields.UUIDField(),
"metadata": wfields.JsonField(),
"bootable": wfields.BooleanField()
diff --git a/watcher/objects/fields.py b/watcher/objects/fields.py
index 47a7b2942..94eeb5346 100644
--- a/watcher/objects/fields.py
+++ b/watcher/objects/fields.py
@@ -33,7 +33,14 @@ NonNegativeIntegerField = fields.NonNegativeIntegerField
ObjectField = fields.ObjectField
StringField = fields.StringField
UnspecifiedDefault = fields.UnspecifiedDefault
-UUIDField = fields.UUIDField
+
+
+class UUIDField(fields.UUIDField):
+ def coerce(self, obj, attr, value):
+ if value is None or value == "":
+ return self._null(obj, attr)
+ else:
+ return self._type.coerce(obj, attr, value)
class Numeric(fields.FieldType):
diff --git a/watcher/tests/api/base.py b/watcher/tests/api/base.py
index 82bc830c8..8ce145b84 100644
--- a/watcher/tests/api/base.py
+++ b/watcher/tests/api/base.py
@@ -79,7 +79,6 @@ class FunctionalTest(base.DbTestCase):
hooks.ContextHook(),
hooks.NoExceptionTracebackHook()
],
- 'static_root': '%s/public' % root_dir,
'template_path': '%s/api/templates' % root_dir,
'enable_acl': enable_acl,
'acl_public_routes': ['/', '/v1'],
diff --git a/watcher/tests/api/v1/test_actions.py b/watcher/tests/api/v1/test_actions.py
index 60d6bd0e9..b70861465 100644
--- a/watcher/tests/api/v1/test_actions.py
+++ b/watcher/tests/api/v1/test_actions.py
@@ -444,7 +444,7 @@ class TestListAction(api_base.FunctionalTest):
action = obj_utils.create_test_action(self.context, id=id_,
uuid=utils.generate_uuid(),
parents=parents)
- parents = [action.id]
+ parents = [action.uuid]
response = self.get_json('/actions/?limit=3')
self.assertEqual(3, len(response['actions']))
diff --git a/watcher/tests/decision_engine/cluster/test_cinder_cdmc.py b/watcher/tests/decision_engine/cluster/test_cinder_cdmc.py
index ef4f4cd0b..e539b2bfc 100644
--- a/watcher/tests/decision_engine/cluster/test_cinder_cdmc.py
+++ b/watcher/tests/decision_engine/cluster/test_cinder_cdmc.py
@@ -63,7 +63,8 @@ class TestCinderClusterDataModelCollector(base.TestCase):
bootable='false'
)
setattr(fake_volume, 'name', 'name')
- setattr(fake_volume, 'os-vol-tenant-attr:tenant_id', 'project_id')
+ setattr(fake_volume, 'os-vol-tenant-attr:tenant_id',
+ '0c003652-0cb1-4210-9005-fd5b92b1faa2')
setattr(fake_volume, 'os-vol-host-attr:host', 'host@backend#pool')
# storage node list
diff --git a/watcher/tests/decision_engine/model/data/scenario_1.xml b/watcher/tests/decision_engine/model/data/scenario_1.xml
index da8f7b2a0..a621f1a88 100644
--- a/watcher/tests/decision_engine/model/data/scenario_1.xml
+++ b/watcher/tests/decision_engine/model/data/scenario_1.xml
@@ -1,47 +1,47 @@
-
-
+
+
-
+
-
-
-
+
+
+
-
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/watcher/tests/decision_engine/model/data/scenario_1_with_1_node_unavailable.xml b/watcher/tests/decision_engine/model/data/scenario_1_with_1_node_unavailable.xml
index aad624bb9..13b951c1a 100644
--- a/watcher/tests/decision_engine/model/data/scenario_1_with_1_node_unavailable.xml
+++ b/watcher/tests/decision_engine/model/data/scenario_1_with_1_node_unavailable.xml
@@ -1,50 +1,50 @@
-
-
+
+
-
+
-
-
-
+
+
+
-
+
-
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/watcher/tests/decision_engine/model/data/scenario_1_with_metrics.xml b/watcher/tests/decision_engine/model/data/scenario_1_with_metrics.xml
index cc624882e..ba1ec169d 100644
--- a/watcher/tests/decision_engine/model/data/scenario_1_with_metrics.xml
+++ b/watcher/tests/decision_engine/model/data/scenario_1_with_metrics.xml
@@ -1,8 +1,8 @@
-
+
-
+
diff --git a/watcher/tests/decision_engine/model/data/scenario_2_with_metrics.xml b/watcher/tests/decision_engine/model/data/scenario_2_with_metrics.xml
index 177d3f249..dcfb00c4a 100644
--- a/watcher/tests/decision_engine/model/data/scenario_2_with_metrics.xml
+++ b/watcher/tests/decision_engine/model/data/scenario_2_with_metrics.xml
@@ -1,11 +1,11 @@
-
-
-
-
-
-
+
+
+
+
+
+
diff --git a/watcher/tests/decision_engine/model/data/scenario_3_with_2_nodes.xml b/watcher/tests/decision_engine/model/data/scenario_3_with_2_nodes.xml
index aa96f89ce..34bc4bf98 100644
--- a/watcher/tests/decision_engine/model/data/scenario_3_with_2_nodes.xml
+++ b/watcher/tests/decision_engine/model/data/scenario_3_with_2_nodes.xml
@@ -1,8 +1,8 @@
-
+
-
+
diff --git a/watcher/tests/decision_engine/model/data/scenario_3_with_metrics.xml b/watcher/tests/decision_engine/model/data/scenario_3_with_metrics.xml
index 996499d70..0f5819816 100644
--- a/watcher/tests/decision_engine/model/data/scenario_3_with_metrics.xml
+++ b/watcher/tests/decision_engine/model/data/scenario_3_with_metrics.xml
@@ -1,9 +1,9 @@
-
-
-
-
+
+
+
+
diff --git a/watcher/tests/decision_engine/model/data/scenario_5_with_instance_disk_0.xml b/watcher/tests/decision_engine/model/data/scenario_5_with_instance_disk_0.xml
index 5555d9bd0..409ecea08 100644
--- a/watcher/tests/decision_engine/model/data/scenario_5_with_instance_disk_0.xml
+++ b/watcher/tests/decision_engine/model/data/scenario_5_with_instance_disk_0.xml
@@ -1,5 +1,5 @@
-
+
diff --git a/watcher/tests/decision_engine/model/data/scenario_6_with_2_nodes.xml b/watcher/tests/decision_engine/model/data/scenario_6_with_2_nodes.xml
index bccc33e85..7eef3b85f 100644
--- a/watcher/tests/decision_engine/model/data/scenario_6_with_2_nodes.xml
+++ b/watcher/tests/decision_engine/model/data/scenario_6_with_2_nodes.xml
@@ -1,10 +1,10 @@
-
-
+
+
-
-
+
+
diff --git a/watcher/tests/decision_engine/model/data/scenario_7_with_2_nodes.xml b/watcher/tests/decision_engine/model/data/scenario_7_with_2_nodes.xml
index e66cb4cd2..1bd8846f3 100644
--- a/watcher/tests/decision_engine/model/data/scenario_7_with_2_nodes.xml
+++ b/watcher/tests/decision_engine/model/data/scenario_7_with_2_nodes.xml
@@ -1,10 +1,10 @@
-
-
+
+
-
-
+
+
diff --git a/watcher/tests/decision_engine/model/data/scenario_8_with_4_nodes.xml b/watcher/tests/decision_engine/model/data/scenario_8_with_4_nodes.xml
index aaa318980..894f49aa7 100644
--- a/watcher/tests/decision_engine/model/data/scenario_8_with_4_nodes.xml
+++ b/watcher/tests/decision_engine/model/data/scenario_8_with_4_nodes.xml
@@ -1,16 +1,16 @@
-
-
-
+
+
+
-
+
-
+
-
+
diff --git a/watcher/tests/decision_engine/model/data/scenario_9_with_3_active_plus_1_disabled_nodes.xml b/watcher/tests/decision_engine/model/data/scenario_9_with_3_active_plus_1_disabled_nodes.xml
index a87b9a37b..3db96679a 100644
--- a/watcher/tests/decision_engine/model/data/scenario_9_with_3_active_plus_1_disabled_nodes.xml
+++ b/watcher/tests/decision_engine/model/data/scenario_9_with_3_active_plus_1_disabled_nodes.xml
@@ -1,16 +1,16 @@
-
-
-
+
+
+
-
+
-
+
-
+
diff --git a/watcher/tests/decision_engine/model/data/storage_scenario_1.xml b/watcher/tests/decision_engine/model/data/storage_scenario_1.xml
index af2e4167c..bda7032d4 100644
--- a/watcher/tests/decision_engine/model/data/storage_scenario_1.xml
+++ b/watcher/tests/decision_engine/model/data/storage_scenario_1.xml
@@ -1,23 +1,23 @@
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
diff --git a/watcher/tests/decision_engine/model/faker_cluster_state.py b/watcher/tests/decision_engine/model/faker_cluster_state.py
index e5fc503c4..66f2a4147 100644
--- a/watcher/tests/decision_engine/model/faker_cluster_state.py
+++ b/watcher/tests/decision_engine/model/faker_cluster_state.py
@@ -26,6 +26,14 @@ from watcher.decision_engine.model import element
from watcher.decision_engine.model import model_root as modelroot
+volume_uuid_mapping = {
+ "volume_0": "5028b1eb-8749-48ae-a42c-5bdd1323976f",
+ "volume_1": "74454247-a064-4b34-8f43-89337987720e",
+ "volume_2": "a16c811e-2521-4fd3-8779-6a94ccb3be73",
+ "volume_3": "37856b95-5be4-4864-8a49-c83f55c66780",
+}
+
+
class FakerModelCollector(base.BaseClusterDataModelCollector):
def __init__(self, config=None, osc=None, audit_scope=None):
@@ -83,7 +91,12 @@ class FakerModelCollector(base.BaseClusterDataModelCollector):
for i in range(0, instance_count):
instance_uuid = "INSTANCE_{0}".format(i)
- project_id = "project_{0}".format(i)
+ if instance_uuid == "INSTANCE_1":
+ project_id = "26F03131-32CB-4697-9D61-9123F87A8147"
+ elif instance_uuid == "INSTANCE_2":
+ project_id = "109F7909-0607-4712-B32C-5CC6D49D2F15"
+ else:
+ project_id = "91FFFE30-78A0-4152-ACD2-8310FF274DC9"
instance_attributes = {
"uuid": instance_uuid,
"memory": 2,
@@ -229,10 +242,21 @@ class FakerStorageModelCollector(base.BaseClusterDataModelCollector):
model.get_node_by_name(node_name),
)
+ volume_uuid_mapping = [
+ "5028b1eb-8749-48ae-a42c-5bdd1323976f",
+ "74454247-a064-4b34-8f43-89337987720e",
+ "a16c811e-2521-4fd3-8779-6a94ccb3be73",
+ "37856b95-5be4-4864-8a49-c83f55c66780",
+ "694f8fb1-df96-46be-b67d-49f2c14a495e",
+ "66b094b0-8fc3-4a94-913f-a5f9312b11a5",
+ "e9013810-4b4c-4b94-a056-4c36702d51a3",
+ "07976191-6a57-4c35-9f3c-55b3b5ecd6d5",
+ "4d1c952d-95d0-4aac-82aa-c3cb509af9f3",
+ ]
+
for k in range(volume_count):
- uuid = "VOLUME_{0}".format(k)
+ uuid = volume_uuid_mapping[k]
name = "name_{0}".format(k)
- project_id = "project_{0}".format(k)
volume_attributes = {
"size": 40,
"status": "in-use",
@@ -242,7 +266,7 @@ class FakerStorageModelCollector(base.BaseClusterDataModelCollector):
"name": name,
"multiattach": 'True',
"snapshot_id": uuid,
- "project_id": project_id,
+ "project_id": "91FFFE30-78A0-4152-ACD2-8310FF274DC9",
"metadata": '{"readonly": false,"attached_mode": "rw"}',
"bootable": 'False'
}
@@ -250,14 +274,14 @@ class FakerStorageModelCollector(base.BaseClusterDataModelCollector):
model.add_volume(volume)
mappings = [
- ("VOLUME_0", "host_0@backend_0#pool_0"),
- ("VOLUME_1", "host_0@backend_0#pool_0"),
- ("VOLUME_2", "host_0@backend_0#pool_1"),
- ("VOLUME_3", "host_0@backend_0#pool_1"),
- ("VOLUME_4", "host_1@backend_1#pool_0"),
- ("VOLUME_5", "host_1@backend_1#pool_0"),
- ("VOLUME_6", "host_1@backend_1#pool_1"),
- ("VOLUME_7", "host_1@backend_1#pool_1"),
+ (volume_uuid_mapping[0], "host_0@backend_0#pool_0"),
+ (volume_uuid_mapping[1], "host_0@backend_0#pool_0"),
+ (volume_uuid_mapping[2], "host_0@backend_0#pool_1"),
+ (volume_uuid_mapping[3], "host_0@backend_0#pool_1"),
+ (volume_uuid_mapping[4], "host_1@backend_1#pool_0"),
+ (volume_uuid_mapping[5], "host_1@backend_1#pool_0"),
+ (volume_uuid_mapping[6], "host_1@backend_1#pool_1"),
+ (volume_uuid_mapping[7], "host_1@backend_1#pool_1"),
]
for volume_uuid, pool_name in mappings:
diff --git a/watcher/tests/decision_engine/model/notification/data/scenario_1_bootable-volume-create.json b/watcher/tests/decision_engine/model/notification/data/scenario_1_bootable-volume-create.json
index 4b0fe28d1..2f32d1fd8 100644
--- a/watcher/tests/decision_engine/model/notification/data/scenario_1_bootable-volume-create.json
+++ b/watcher/tests/decision_engine/model/notification/data/scenario_1_bootable-volume-create.json
@@ -4,13 +4,13 @@
"event_type": "volume.create.end",
"payload": {
"host": "host_0@backend_0#pool_0",
- "volume_id": "VOLUME_00",
+ "volume_id": "990a723f-6c19-4f83-8526-6383c9e9389f",
"display_name": "name_00",
"size": "40",
"status": "available",
"volume_attachment": [{"server_id": "server", "attachment_id": "attachment"}],
"snapshot_id": "",
- "tenant_id": "project_00",
+ "tenant_id": "52044438-21f2-4a48-add4-d48bab20f7e1",
"metadata": {"readonly": false, "attached_mode": "rw"},
"glance_metadata": {}
}
diff --git a/watcher/tests/decision_engine/model/notification/data/scenario_1_error-volume-create.json b/watcher/tests/decision_engine/model/notification/data/scenario_1_error-volume-create.json
index ac0739e9c..1bf77a84b 100644
--- a/watcher/tests/decision_engine/model/notification/data/scenario_1_error-volume-create.json
+++ b/watcher/tests/decision_engine/model/notification/data/scenario_1_error-volume-create.json
@@ -4,13 +4,13 @@
"event_type": "volume.create.end",
"payload": {
"host": "",
- "volume_id": "VOLUME_00",
+ "volume_id": "990a723f-6c19-4f83-8526-6383c9e9389f",
"display_name": "name_00",
"size": "40",
"status": "error",
"volume_attachment": [],
"snapshot_id": "",
- "tenant_id": "project_00",
+ "tenant_id": "52044438-21f2-4a48-add4-d48bab20f7e1",
"metadata": {}
}
}
diff --git a/watcher/tests/decision_engine/model/notification/data/scenario_1_volume-attach.json b/watcher/tests/decision_engine/model/notification/data/scenario_1_volume-attach.json
index 2f2a2a1ed..cd82c0bcd 100644
--- a/watcher/tests/decision_engine/model/notification/data/scenario_1_volume-attach.json
+++ b/watcher/tests/decision_engine/model/notification/data/scenario_1_volume-attach.json
@@ -4,13 +4,13 @@
"event_type": "volume.attach.end",
"payload": {
"host": "host_0@backend_0#pool_0",
- "volume_id": "VOLUME_0",
+ "volume_id": "5028b1eb-8749-48ae-a42c-5bdd1323976f",
"display_name": "name_0",
"size": "40",
"status": "in-use",
"volume_attachment": [{"server_id": "server", "attachment_id": "attachment"}],
"snapshot_id": "",
- "tenant_id": "project_0",
+ "tenant_id": "91FFFE30-78A0-4152-ACD2-8310FF274DC9",
"metadata": {"readonly": false, "attached_mode": "rw"}
}
}
diff --git a/watcher/tests/decision_engine/model/notification/data/scenario_1_volume-create.json b/watcher/tests/decision_engine/model/notification/data/scenario_1_volume-create.json
index 089da52e5..3146e200a 100644
--- a/watcher/tests/decision_engine/model/notification/data/scenario_1_volume-create.json
+++ b/watcher/tests/decision_engine/model/notification/data/scenario_1_volume-create.json
@@ -4,13 +4,13 @@
"event_type": "volume.create.end",
"payload": {
"host": "host_0@backend_0#pool_0",
- "volume_id": "VOLUME_00",
+ "volume_id": "990a723f-6c19-4f83-8526-6383c9e9389f",
"display_name": "name_00",
"size": "40",
"status": "available",
"volume_attachment": [{"server_id": "server", "attachment_id": "attachment"}],
"snapshot_id": "",
- "tenant_id": "project_00",
+ "tenant_id": "52044438-21f2-4a48-add4-d48bab20f7e1",
"metadata": {"readonly": false, "attached_mode": "rw"}
}
}
diff --git a/watcher/tests/decision_engine/model/notification/data/scenario_1_volume-create_pool_notfound.json b/watcher/tests/decision_engine/model/notification/data/scenario_1_volume-create_pool_notfound.json
index a772f3582..5e6e427b2 100644
--- a/watcher/tests/decision_engine/model/notification/data/scenario_1_volume-create_pool_notfound.json
+++ b/watcher/tests/decision_engine/model/notification/data/scenario_1_volume-create_pool_notfound.json
@@ -4,13 +4,13 @@
"event_type": "volume.create.end",
"payload": {
"host": "host_2@backend_2#pool_0",
- "volume_id": "VOLUME_00",
+ "volume_id": "990a723f-6c19-4f83-8526-6383c9e9389f",
"display_name": "name_00",
"size": "40",
"status": "available",
"volume_attachment": [{"server_id": "server", "attachment_id": "attachment"}],
"snapshot_id": "",
- "tenant_id": "project_00",
+ "tenant_id": "52044438-21f2-4a48-add4-d48bab20f7e1",
"metadata": {"readonly": false, "attached_mode": "rw"}
}
}
diff --git a/watcher/tests/decision_engine/model/notification/data/scenario_1_volume-delete.json b/watcher/tests/decision_engine/model/notification/data/scenario_1_volume-delete.json
index 6d09d7f44..65db5b1bb 100644
--- a/watcher/tests/decision_engine/model/notification/data/scenario_1_volume-delete.json
+++ b/watcher/tests/decision_engine/model/notification/data/scenario_1_volume-delete.json
@@ -4,13 +4,13 @@
"event_type": "volume.delete.end",
"payload": {
"host": "host_0@backend_0#pool_0",
- "volume_id": "VOLUME_0",
+ "volume_id": "5028b1eb-8749-48ae-a42c-5bdd1323976f",
"display_name": "name_0",
"size": "40",
"status": "deleting",
"volume_attachment": [{"server_id": "server", "attachment_id": "attachment"}],
"snapshot_id": "",
- "tenant_id": "project_0",
+ "tenant_id": "91FFFE30-78A0-4152-ACD2-8310FF274DC9",
"metadata": {"readonly": false, "attached_mode": "rw"}
}
}
diff --git a/watcher/tests/decision_engine/model/notification/data/scenario_1_volume-detach.json b/watcher/tests/decision_engine/model/notification/data/scenario_1_volume-detach.json
index f2d635d66..3b0be297c 100644
--- a/watcher/tests/decision_engine/model/notification/data/scenario_1_volume-detach.json
+++ b/watcher/tests/decision_engine/model/notification/data/scenario_1_volume-detach.json
@@ -4,13 +4,13 @@
"event_type": "volume.detach.end",
"payload": {
"host": "host_0@backend_0#pool_0",
- "volume_id": "VOLUME_0",
+ "volume_id": "5028b1eb-8749-48ae-a42c-5bdd1323976f",
"display_name": "name_0",
"size": "40",
"status": "available",
"volume_attachment": [],
"snapshot_id": "",
- "tenant_id": "project_0",
+ "tenant_id": "91FFFE30-78A0-4152-ACD2-8310FF274DC9",
"metadata": {}
}
}
diff --git a/watcher/tests/decision_engine/model/notification/data/scenario_1_volume-resize.json b/watcher/tests/decision_engine/model/notification/data/scenario_1_volume-resize.json
index 6b4597fdf..a8a0808df 100644
--- a/watcher/tests/decision_engine/model/notification/data/scenario_1_volume-resize.json
+++ b/watcher/tests/decision_engine/model/notification/data/scenario_1_volume-resize.json
@@ -4,13 +4,13 @@
"event_type": "volume.resize.end",
"payload": {
"host": "host_0@backend_0#pool_0",
- "volume_id": "VOLUME_0",
+ "volume_id": "5028b1eb-8749-48ae-a42c-5bdd1323976f",
"display_name": "name_0",
"size": "20",
"status": "in-use",
"volume_attachment": [{"server_id": "server", "attachment_id": "attachment"}],
"snapshot_id": "",
- "tenant_id": "project_0",
+ "tenant_id": "91FFFE30-78A0-4152-ACD2-8310FF274DC9",
"metadata": {"readonly": false, "attached_mode": "rw"}
}
}
diff --git a/watcher/tests/decision_engine/model/notification/data/scenario_1_volume-update.json b/watcher/tests/decision_engine/model/notification/data/scenario_1_volume-update.json
index b846ddc1f..b4c7657f6 100644
--- a/watcher/tests/decision_engine/model/notification/data/scenario_1_volume-update.json
+++ b/watcher/tests/decision_engine/model/notification/data/scenario_1_volume-update.json
@@ -4,13 +4,13 @@
"event_type": "volume.update.end",
"payload": {
"host": "host_0@backend_0#pool_0",
- "volume_id": "VOLUME_0",
+ "volume_id": "5028b1eb-8749-48ae-a42c-5bdd1323976f",
"display_name": "name_01",
"size": "40",
"status": "enabled",
"volume_attachment": [{"server_id": "server", "attachment_id": "attachment"}],
"snapshot_id": "",
- "tenant_id": "project_0",
+ "tenant_id": "91FFFE30-78A0-4152-ACD2-8310FF274DC9",
"metadata": {"readonly": false, "attached_mode": "rw"}
}
}
diff --git a/watcher/tests/decision_engine/model/notification/test_cinder_notifications.py b/watcher/tests/decision_engine/model/notification/test_cinder_notifications.py
index a3c11d531..f7956e081 100644
--- a/watcher/tests/decision_engine/model/notification/test_cinder_notifications.py
+++ b/watcher/tests/decision_engine/model/notification/test_cinder_notifications.py
@@ -358,7 +358,7 @@ class TestCinderNotifications(NotificationTestCase):
metadata=self.FAKE_METADATA,
)
# check that volume00 was added to the model
- volume_00_name = 'VOLUME_00'
+ volume_00_name = '990a723f-6c19-4f83-8526-6383c9e9389f'
volume_00 = storage_model.get_volume_by_uuid(volume_00_name)
self.assertEqual(volume_00_name, volume_00.uuid)
self.assertFalse(volume_00.bootable)
@@ -405,7 +405,7 @@ class TestCinderNotifications(NotificationTestCase):
metadata=self.FAKE_METADATA,
)
# check that volume00 was added to the model
- volume_00_name = 'VOLUME_00'
+ volume_00_name = '990a723f-6c19-4f83-8526-6383c9e9389f'
volume_00 = storage_model.get_volume_by_uuid(volume_00_name)
self.assertEqual(volume_00_name, volume_00.uuid)
self.assertTrue(volume_00.bootable)
@@ -469,7 +469,7 @@ class TestCinderNotifications(NotificationTestCase):
metadata=self.FAKE_METADATA,
)
# check that volume00 was added to the model
- volume_00_name = 'VOLUME_00'
+ volume_00_name = '990a723f-6c19-4f83-8526-6383c9e9389f'
volume_00 = storage_model.get_volume_by_uuid(volume_00_name)
self.assertEqual(volume_00_name, volume_00.uuid)
# check that capacity was updated
@@ -509,7 +509,7 @@ class TestCinderNotifications(NotificationTestCase):
# we do not call get_storage_pool_by_name
m_get_storage_pool_by_name.assert_not_called()
# check that volume00 was added to the model
- volume_00_name = 'VOLUME_00'
+ volume_00_name = '990a723f-6c19-4f83-8526-6383c9e9389f'
volume_00 = storage_model.get_volume_by_uuid(volume_00_name)
self.assertEqual(volume_00_name, volume_00.uuid)
@@ -521,7 +521,7 @@ class TestCinderNotifications(NotificationTestCase):
self.fake_cdmc.cluster_data_model = storage_model
handler = cnotification.VolumeUpdateEnd(self.fake_cdmc)
- volume_0_name = 'VOLUME_0'
+ volume_0_name = faker_cluster_state.volume_uuid_mapping['volume_0']
volume_0 = storage_model.get_volume_by_uuid(volume_0_name)
self.assertEqual('name_0', volume_0.name)
@@ -578,7 +578,7 @@ class TestCinderNotifications(NotificationTestCase):
handler = cnotification.VolumeDeleteEnd(self.fake_cdmc)
# volume exists before consuming
- volume_0_uuid = 'VOLUME_0'
+ volume_0_uuid = faker_cluster_state.volume_uuid_mapping['volume_0']
volume_0 = storage_model.get_volume_by_uuid(volume_0_uuid)
self.assertEqual(volume_0_uuid, volume_0.uuid)
diff --git a/watcher/tests/decision_engine/model/test_element.py b/watcher/tests/decision_engine/model/test_element.py
index aad2386bf..6f28ce861 100644
--- a/watcher/tests/decision_engine/model/test_element.py
+++ b/watcher/tests/decision_engine/model/test_element.py
@@ -115,7 +115,7 @@ class TestStorageElement(base.TestCase):
'name': 'name',
'multiattach': 'false',
'snapshot_id': '',
- 'project_id': 'project_id',
+ 'project_id': '8ea272ec-52d2-475e-9151-0f3ed8c674d1',
'metadata': '{"key": "value"}',
'bootable': 'false',
'human_id': 'human_id',
@@ -130,7 +130,7 @@ class TestStorageElement(base.TestCase):
'name': 'name',
'multiattach': 'false',
'snapshot_id': '',
- 'project_id': 'project_id',
+ 'project_id': '777d7968-9b61-4cc0-844d-a95a6fc22d8c',
'metadata': '{"key": "value"}',
'human_id': 'human_id',
})),
@@ -144,7 +144,7 @@ class TestStorageElement(base.TestCase):
'name': 'name',
'multiattach': 'false',
'snapshot_id': '',
- 'project_id': 'project_id',
+ 'project_id': '2e65af64-1898-4cee-bfee-af3fc7f76d16',
'metadata': '{"key": "value"}',
})),
]
diff --git a/watcher/tests/decision_engine/scope/fake_scopes.py b/watcher/tests/decision_engine/scope/fake_scopes.py
index 0d1b6b03f..607034f51 100644
--- a/watcher/tests/decision_engine/scope/fake_scopes.py
+++ b/watcher/tests/decision_engine/scope/fake_scopes.py
@@ -14,6 +14,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+from watcher.tests.decision_engine.model import faker_cluster_state
+
+vum = faker_cluster_state.volume_uuid_mapping
+
fake_scope_1 = [{'compute': [{'availability_zones': [{'name': 'AZ1'},
{'name': 'AZ3'}]},
{'exclude': [
@@ -40,7 +44,7 @@ compute_scope = [{'compute': [{'host_aggregates': [{'id': '*'}]},
fake_scope_2 = [{'storage': [{'availability_zones': [{'name': 'zone_0'}]},
{'exclude': [
{'volumes': [
- {'uuid': 'VOLUME_1'}]},
+ {'uuid': vum['volume_1']}]},
{'storage_pools': [
{'name': 'host_0@backend_0#pool_1'}]}
diff --git a/watcher/tests/decision_engine/scope/test_compute.py b/watcher/tests/decision_engine/scope/test_compute.py
index 41e91ea2a..9d77a1815 100644
--- a/watcher/tests/decision_engine/scope/test_compute.py
+++ b/watcher/tests/decision_engine/scope/test_compute.py
@@ -242,7 +242,8 @@ class TestComputeScope(base.TestCase):
def test_exclude_instances_with_given_project(self):
cluster = self.fake_cluster.generate_scenario_1()
instances_to_exclude = set()
- projects_to_exclude = ['project_1', 'project_2']
+ projects_to_exclude = ['26F03131-32CB-4697-9D61-9123F87A8147',
+ '109F7909-0607-4712-B32C-5CC6D49D2F15']
compute.ComputeScope(
[], mock.Mock(),
osc=mock.Mock()).exclude_instances_with_given_project(
diff --git a/watcher/tests/decision_engine/scope/test_storage.py b/watcher/tests/decision_engine/scope/test_storage.py
index 8b459acf1..e6caa0760 100644
--- a/watcher/tests/decision_engine/scope/test_storage.py
+++ b/watcher/tests/decision_engine/scope/test_storage.py
@@ -41,7 +41,8 @@ class TestStorageScope(base.TestCase):
for i in range(2)]
model = storage.StorageScope(audit_scope, mock.Mock(),
osc=mock.Mock()).get_scoped_model(cluster)
- expected_edges = [('VOLUME_0', 'host_0@backend_0#pool_0'),
+ expected_edges = [(faker_cluster_state.volume_uuid_mapping['volume_0'],
+ 'host_0@backend_0#pool_0'),
('host_0@backend_0#pool_0', 'host_0@backend_0')]
self.assertEqual(sorted(expected_edges), sorted(model.edges()))
@@ -152,7 +153,9 @@ class TestStorageScope(base.TestCase):
def test_exclude_volumes(self):
cluster = self.fake_cluster.generate_scenario_1()
- exclude = ['VOLUME_0', 'VOLUME_3']
+ exclude = [faker_cluster_state.volume_uuid_mapping['volume_0'],
+ faker_cluster_state.volume_uuid_mapping['volume_3'],
+ ]
storage.StorageScope([], mock.Mock(),
osc=mock.Mock()).exclude_volumes(exclude,
cluster)
@@ -206,6 +209,7 @@ class TestStorageScope(base.TestCase):
for i in range(2)]
model = storage.StorageScope(audit_scope, mock.Mock(),
osc=mock.Mock()).get_scoped_model(cluster)
- expected_edges = [('VOLUME_0', 'host_0@backend_0#pool_0'),
+ expected_edges = [(faker_cluster_state.volume_uuid_mapping['volume_0'],
+ 'host_0@backend_0#pool_0'),
('host_0@backend_0#pool_0', 'host_0@backend_0')]
self.assertEqual(sorted(expected_edges), sorted(model.edges()))
diff --git a/watcher/tests/decision_engine/strategy/strategies/test_zone_migration.py b/watcher/tests/decision_engine/strategy/strategies/test_zone_migration.py
index ba204d32a..9d29231cb 100644
--- a/watcher/tests/decision_engine/strategy/strategies/test_zone_migration.py
+++ b/watcher/tests/decision_engine/strategy/strategies/test_zone_migration.py
@@ -27,6 +27,9 @@ from watcher.tests import base
from watcher.tests.decision_engine.model import faker_cluster_state
+volume_uuid_mapping = faker_cluster_state.volume_uuid_mapping
+
+
class TestZoneMigration(base.TestCase):
def setUp(self):
@@ -218,11 +221,11 @@ class TestZoneMigration(base.TestCase):
def test_get_volumes(self):
volume_on_src1 = self.fake_volume(host="src1@back1#pool1",
- id="VOLUME_1")
+ id=volume_uuid_mapping["volume_1"])
volume_on_src2 = self.fake_volume(host="src2@back1#pool1",
- id="VOLUME_2")
+ id=volume_uuid_mapping["volume_2"])
volume_on_src3 = self.fake_volume(host="src3@back2#pool1",
- id="VOLUME_3")
+ id=volume_uuid_mapping["volume_3"])
self.m_c_helper.get_volume_list.return_value = [
volume_on_src1,
volume_on_src2,
@@ -276,7 +279,7 @@ class TestZoneMigration(base.TestCase):
def test_execute_migrate_volume(self):
volume_on_src1 = self.fake_volume(host="src1@back1#pool1",
- id="VOLUME_1")
+ id=volume_uuid_mapping["volume_1"])
self.m_c_helper.get_volume_list.return_value = [
volume_on_src1,
]
@@ -294,7 +297,7 @@ class TestZoneMigration(base.TestCase):
def test_execute_retype_volume(self):
volume_on_src2 = self.fake_volume(host="src2@back1#pool1",
- id="VOLUME_2")
+ id=volume_uuid_mapping["volume_2"])
self.m_c_helper.get_volume_list.return_value = [
volume_on_src2,
]
@@ -312,7 +315,7 @@ class TestZoneMigration(base.TestCase):
def test_execute_swap_volume(self):
volume_on_src1 = self.fake_volume(host="src1@back1#pool1",
- id="VOLUME_1")
+ id=volume_uuid_mapping["volume_1"])
volume_on_src1.status = "in-use"
self.m_c_helper.get_volume_list.return_value = [
volume_on_src1,
@@ -371,9 +374,9 @@ class TestZoneMigration(base.TestCase):
def test_execute_migrate_volume_parallel(self):
volume_on_src1_1 = self.fake_volume(host="src1@back1#pool1",
- id="VOLUME_1")
+ id=volume_uuid_mapping["volume_1"])
volume_on_src1_2 = self.fake_volume(host="src1@back1#pool1",
- id="VOLUME_2")
+ id=volume_uuid_mapping["volume_2"])
self.m_c_helper.get_volume_list.return_value = [
volume_on_src1_1,
volume_on_src1_2,
@@ -394,9 +397,9 @@ class TestZoneMigration(base.TestCase):
self.m_parallel_per_pool.return_value = 1
volume_on_src1_1 = self.fake_volume(host="src1@back1#pool1",
- id="VOLUME_1")
+ id=volume_uuid_mapping["volume_1"])
volume_on_src1_2 = self.fake_volume(host="src1@back1#pool1",
- id="VOLUME_2")
+ id=volume_uuid_mapping["volume_2"])
self.m_c_helper.get_volume_list.return_value = [
volume_on_src1_1,
volume_on_src1_2,
@@ -418,11 +421,11 @@ class TestZoneMigration(base.TestCase):
self.m_parallel_per_pool.return_value = 1
volume_on_src1_1 = self.fake_volume(host="src1@back1#pool1",
- id="VOLUME_1")
+ id=volume_uuid_mapping["volume_1"])
volume_on_src1_2 = self.fake_volume(host="src1@back1#pool1",
- id="VOLUME_2")
+ id=volume_uuid_mapping["volume_2"])
volume_on_src2_1 = self.fake_volume(host="src2@back1#pool1",
- id="VOLUME_3")
+ id=volume_uuid_mapping["volume_3"])
self.m_c_helper.get_volume_list.return_value = [
volume_on_src1_1,
volume_on_src1_2,
@@ -482,11 +485,11 @@ class TestZoneMigration(base.TestCase):
def test_filtered_targets_storage_pools(self):
volume_on_src1 = self.fake_volume(host="src1@back1#pool1",
- id="VOLUME_1")
+ id=volume_uuid_mapping["volume_1"])
volume_on_src2 = self.fake_volume(host="src2@back1#pool1",
- id="VOLUME_2")
+ id=volume_uuid_mapping["volume_2"])
volume_on_src3 = self.fake_volume(host="src3@back2#pool1",
- id="VOLUME_3")
+ id=volume_uuid_mapping["volume_3"])
self.m_c_helper.get_volume_list.return_value = [
volume_on_src1,
volume_on_src2,
@@ -521,11 +524,14 @@ class TestZoneMigration(base.TestCase):
self.m_c_helper.get_volume_list.return_value = []
volume_on_src1 = self.fake_volume(host="src1@back1#pool1",
- id="VOLUME_1", project_id="pj2")
+ id=volume_uuid_mapping["volume_1"],
+ project_id="pj2")
volume_on_src2 = self.fake_volume(host="src2@back1#pool1",
- id="VOLUME_2", project_id="pj1")
+ id=volume_uuid_mapping["volume_2"],
+ project_id="pj1")
volume_on_src3 = self.fake_volume(host="src3@back2#pool1",
- id="VOLUME_3", project_id="pj3")
+ id=volume_uuid_mapping["volume_3"],
+ project_id="pj3")
self.m_c_helper.get_volume_list.return_value = [
volume_on_src1,
@@ -670,12 +676,18 @@ class TestZoneMigration(base.TestCase):
# StorageSpecSortFilter #
def test_filtered_targets_storage_size(self):
- volume_on_src1 = self.fake_volume(host="src1@back1#pool1",
- size="1", id="VOLUME_1")
- volume_on_src2 = self.fake_volume(host="src2@back1#pool1",
- size="2", id="VOLUME_2")
- volume_on_src3 = self.fake_volume(host="src3@back2#pool1",
- size="3", id="VOLUME_3")
+ volume_on_src1 = self.fake_volume(
+ host="src1@back1#pool1",
+ size="1",
+ id=volume_uuid_mapping["volume_1"])
+ volume_on_src2 = self.fake_volume(
+ host="src2@back1#pool1",
+ size="2",
+ id=volume_uuid_mapping["volume_2"])
+ volume_on_src3 = self.fake_volume(
+ host="src3@back2#pool1",
+ size="3",
+ id=volume_uuid_mapping["volume_3"],)
self.m_c_helper.get_volume_list.return_value = [
volume_on_src1,
volume_on_src2,
@@ -694,13 +706,13 @@ class TestZoneMigration(base.TestCase):
def test_filtered_targets_storage_created_at(self):
volume_on_src1 = self.fake_volume(host="src1@back1#pool1",
- id="VOLUME_1",
+ id=volume_uuid_mapping["volume_1"],
created_at="2017-10-30T00:00:00")
volume_on_src2 = self.fake_volume(host="src2@back1#pool1",
- id="VOLUME_2",
+ id=volume_uuid_mapping["volume_2"],
created_at="1977-03-29T03:03:03")
volume_on_src3 = self.fake_volume(host="src3@back2#pool1",
- id="VOLUME_3",
+ id=volume_uuid_mapping["volume_3"],
created_at="1977-03-29T03:03:03")
self.m_c_helper.get_volume_list.return_value = [
volume_on_src1,