Notifications for flavor operations
This patch implements the versioned notifications for flavor create and destroy. Implement blueprint: flavor-notifications Change-Id: Icc2169b87ffba4e7e2079076a82029156c584c6a
This commit is contained in:
parent
6817d22826
commit
8d9b3d6b9d
@ -28,6 +28,7 @@ from nova.objects import base
|
||||
# Make sure that all the notification classes are defined so the
|
||||
# registration mechanism can pick them up later.
|
||||
from nova.notifications.objects import exception
|
||||
from nova.notifications.objects import flavor
|
||||
from nova.notifications.objects import instance
|
||||
from nova.notifications.objects import service
|
||||
|
||||
|
23
doc/notification_samples/flavor-create.json
Normal file
23
doc/notification_samples/flavor-create.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"priority": "INFO",
|
||||
"payload": {
|
||||
"nova_object.namespace": "nova",
|
||||
"nova_object.version": "1.1",
|
||||
"nova_object.name": "FlavorPayload",
|
||||
"nova_object.data": {
|
||||
"name": "test_flavor",
|
||||
"memory_mb": 1024,
|
||||
"ephemeral_gb": 0,
|
||||
"disabled": false,
|
||||
"vcpus": 2,
|
||||
"swap": 0,
|
||||
"rxtx_factor": 2.0,
|
||||
"is_public": true,
|
||||
"root_gb": 10,
|
||||
"vcpu_weight": 0,
|
||||
"flavorid": "a22d5517-147c-4147-a0d1-e698df5cd4e3"
|
||||
}
|
||||
},
|
||||
"event_type": "flavor.create",
|
||||
"publisher_id": "nova-api:fake-mini"
|
||||
}
|
23
doc/notification_samples/flavor-delete.json
Normal file
23
doc/notification_samples/flavor-delete.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"priority": "INFO",
|
||||
"payload": {
|
||||
"nova_object.namespace": "nova",
|
||||
"nova_object.version": "1.1",
|
||||
"nova_object.name": "FlavorPayload",
|
||||
"nova_object.data": {
|
||||
"name": "test_flavor",
|
||||
"memory_mb": 1024,
|
||||
"ephemeral_gb": 0,
|
||||
"disabled": false,
|
||||
"vcpus": 2,
|
||||
"swap": 0,
|
||||
"rxtx_factor": 2.0,
|
||||
"is_public": true,
|
||||
"root_gb": 10,
|
||||
"vcpu_weight": 0,
|
||||
"flavorid": "a22d5517-147c-4147-a0d1-e698df5cd4e3"
|
||||
}
|
||||
},
|
||||
"event_type": "flavor.delete",
|
||||
"publisher_id": "nova-api:fake-mini"
|
||||
}
|
@ -42,12 +42,18 @@
|
||||
"nova_object.name": "FlavorPayload",
|
||||
"nova_object.data": {
|
||||
"flavorid": "a22d5517-147c-4147-a0d1-e698df5cd4e3",
|
||||
"name": "test_flavor",
|
||||
"root_gb": 1,
|
||||
"vcpus": 1,
|
||||
"ephemeral_gb": 0,
|
||||
"memory_mb": 512
|
||||
"memory_mb": 512,
|
||||
"disabled": false,
|
||||
"rxtx_factor": 1.0,
|
||||
"swap": 0,
|
||||
"is_public": true,
|
||||
"vcpu_weight": 0
|
||||
},
|
||||
"nova_object.version": "1.0",
|
||||
"nova_object.version": "1.1",
|
||||
"nova_object.namespace": "nova"
|
||||
},
|
||||
"user_id":"fake",
|
||||
|
@ -39,12 +39,18 @@
|
||||
"nova_object.name": "FlavorPayload",
|
||||
"nova_object.data": {
|
||||
"flavorid": "a22d5517-147c-4147-a0d1-e698df5cd4e3",
|
||||
"name": "test_flavor",
|
||||
"root_gb": 1,
|
||||
"vcpus": 1,
|
||||
"ephemeral_gb": 0,
|
||||
"memory_mb": 512
|
||||
"memory_mb": 512,
|
||||
"disabled": false,
|
||||
"rxtx_factor": 1.0,
|
||||
"swap": 0,
|
||||
"is_public": true,
|
||||
"vcpu_weight": 0
|
||||
},
|
||||
"nova_object.version": "1.0",
|
||||
"nova_object.version": "1.1",
|
||||
"nova_object.namespace": "nova"
|
||||
},
|
||||
"user_id":"fake",
|
||||
|
@ -29,12 +29,18 @@
|
||||
"nova_object.name": "FlavorPayload",
|
||||
"nova_object.data": {
|
||||
"flavorid": "a22d5517-147c-4147-a0d1-e698df5cd4e3",
|
||||
"name": "test_flavor",
|
||||
"root_gb": 1,
|
||||
"vcpus": 1,
|
||||
"ephemeral_gb": 0,
|
||||
"memory_mb": 512
|
||||
"memory_mb": 512,
|
||||
"disabled": false,
|
||||
"rxtx_factor": 1.0,
|
||||
"swap": 0,
|
||||
"is_public": true,
|
||||
"vcpu_weight": 0
|
||||
},
|
||||
"nova_object.version": "1.0",
|
||||
"nova_object.version": "1.1",
|
||||
"nova_object.namespace": "nova"
|
||||
},
|
||||
"user_id":"fake",
|
||||
|
@ -29,12 +29,18 @@
|
||||
"nova_object.name": "FlavorPayload",
|
||||
"nova_object.data": {
|
||||
"flavorid": "a22d5517-147c-4147-a0d1-e698df5cd4e3",
|
||||
"name": "test_flavor",
|
||||
"root_gb": 1,
|
||||
"vcpus": 1,
|
||||
"ephemeral_gb": 0,
|
||||
"memory_mb": 512
|
||||
"memory_mb": 512,
|
||||
"disabled": false,
|
||||
"rxtx_factor": 1.0,
|
||||
"swap": 0,
|
||||
"is_public": true,
|
||||
"vcpu_weight": 0
|
||||
},
|
||||
"nova_object.version": "1.0",
|
||||
"nova_object.version": "1.1",
|
||||
"nova_object.namespace": "nova"
|
||||
},
|
||||
"user_id":"fake",
|
||||
|
@ -42,12 +42,18 @@
|
||||
"nova_object.name": "FlavorPayload",
|
||||
"nova_object.data": {
|
||||
"flavorid": "a22d5517-147c-4147-a0d1-e698df5cd4e3",
|
||||
"name": "test_flavor",
|
||||
"root_gb": 1,
|
||||
"vcpus": 1,
|
||||
"ephemeral_gb": 0,
|
||||
"memory_mb": 512
|
||||
"memory_mb": 512,
|
||||
"disabled": false,
|
||||
"rxtx_factor": 1.0,
|
||||
"swap": 0,
|
||||
"is_public": true,
|
||||
"vcpu_weight": 0
|
||||
},
|
||||
"nova_object.version": "1.0",
|
||||
"nova_object.version": "1.1",
|
||||
"nova_object.namespace": "nova"
|
||||
},
|
||||
"user_id":"fake",
|
||||
|
@ -42,12 +42,18 @@
|
||||
"nova_object.name": "FlavorPayload",
|
||||
"nova_object.data": {
|
||||
"flavorid": "a22d5517-147c-4147-a0d1-e698df5cd4e3",
|
||||
"name": "test_flavor",
|
||||
"root_gb": 1,
|
||||
"vcpus": 1,
|
||||
"ephemeral_gb": 0,
|
||||
"memory_mb": 512
|
||||
"memory_mb": 512,
|
||||
"disabled": false,
|
||||
"rxtx_factor": 1.0,
|
||||
"swap": 0,
|
||||
"is_public": true,
|
||||
"vcpu_weight": 0
|
||||
},
|
||||
"nova_object.version": "1.0",
|
||||
"nova_object.version": "1.1",
|
||||
"nova_object.namespace": "nova"
|
||||
},
|
||||
"user_id":"fake",
|
||||
|
@ -42,12 +42,18 @@
|
||||
"nova_object.name": "FlavorPayload",
|
||||
"nova_object.data": {
|
||||
"flavorid": "a22d5517-147c-4147-a0d1-e698df5cd4e3",
|
||||
"name": "test_flavor",
|
||||
"root_gb": 1,
|
||||
"vcpus": 1,
|
||||
"ephemeral_gb": 0,
|
||||
"memory_mb": 512
|
||||
"memory_mb": 512,
|
||||
"disabled": false,
|
||||
"rxtx_factor": 1.0,
|
||||
"swap": 0,
|
||||
"is_public": true,
|
||||
"vcpu_weight": 0
|
||||
},
|
||||
"nova_object.version": "1.0",
|
||||
"nova_object.version": "1.1",
|
||||
"nova_object.namespace": "nova"
|
||||
},
|
||||
"user_id":"fake",
|
||||
|
@ -42,12 +42,18 @@
|
||||
"nova_object.name": "FlavorPayload",
|
||||
"nova_object.data": {
|
||||
"flavorid": "a22d5517-147c-4147-a0d1-e698df5cd4e3",
|
||||
"name": "test_flavor",
|
||||
"root_gb": 1,
|
||||
"vcpus": 1,
|
||||
"ephemeral_gb": 0,
|
||||
"memory_mb": 512
|
||||
"memory_mb": 512,
|
||||
"disabled": false,
|
||||
"rxtx_factor": 1.0,
|
||||
"swap": 0,
|
||||
"is_public": true,
|
||||
"vcpu_weight": 0
|
||||
},
|
||||
"nova_object.version": "1.0",
|
||||
"nova_object.version": "1.1",
|
||||
"nova_object.namespace": "nova"
|
||||
},
|
||||
"user_id":"fake",
|
||||
|
@ -42,12 +42,18 @@
|
||||
"nova_object.name": "FlavorPayload",
|
||||
"nova_object.data": {
|
||||
"flavorid": "a22d5517-147c-4147-a0d1-e698df5cd4e3",
|
||||
"name": "test_flavor",
|
||||
"root_gb": 1,
|
||||
"vcpus": 1,
|
||||
"ephemeral_gb": 0,
|
||||
"memory_mb": 512
|
||||
"memory_mb": 512,
|
||||
"disabled": false,
|
||||
"rxtx_factor": 1.0,
|
||||
"swap": 0,
|
||||
"is_public": true,
|
||||
"vcpu_weight": 0
|
||||
},
|
||||
"nova_object.version": "1.0",
|
||||
"nova_object.version": "1.1",
|
||||
"nova_object.namespace": "nova"
|
||||
},
|
||||
"user_id":"fake",
|
||||
|
@ -42,12 +42,18 @@
|
||||
"nova_object.name": "FlavorPayload",
|
||||
"nova_object.data": {
|
||||
"flavorid": "a22d5517-147c-4147-a0d1-e698df5cd4e3",
|
||||
"name": "test_flavor",
|
||||
"root_gb": 1,
|
||||
"vcpus": 1,
|
||||
"ephemeral_gb": 0,
|
||||
"memory_mb": 512
|
||||
"memory_mb": 512,
|
||||
"disabled": false,
|
||||
"rxtx_factor": 1.0,
|
||||
"swap": 0,
|
||||
"is_public": true,
|
||||
"vcpu_weight": 0
|
||||
},
|
||||
"nova_object.version": "1.0",
|
||||
"nova_object.version": "1.1",
|
||||
"nova_object.namespace": "nova"
|
||||
},
|
||||
"user_id":"fake",
|
||||
|
@ -42,12 +42,18 @@
|
||||
"nova_object.name": "FlavorPayload",
|
||||
"nova_object.data": {
|
||||
"flavorid": "a22d5517-147c-4147-a0d1-e698df5cd4e3",
|
||||
"name": "test_flavor",
|
||||
"root_gb": 1,
|
||||
"vcpus": 1,
|
||||
"ephemeral_gb": 0,
|
||||
"memory_mb": 512
|
||||
"memory_mb": 512,
|
||||
"disabled": false,
|
||||
"rxtx_factor": 1.0,
|
||||
"swap": 0,
|
||||
"is_public": true,
|
||||
"vcpu_weight": 0
|
||||
},
|
||||
"nova_object.version": "1.0",
|
||||
"nova_object.version": "1.1",
|
||||
"nova_object.namespace": "nova"
|
||||
},
|
||||
"user_id":"fake",
|
||||
|
@ -42,12 +42,18 @@
|
||||
"nova_object.name": "FlavorPayload",
|
||||
"nova_object.data": {
|
||||
"flavorid": "a22d5517-147c-4147-a0d1-e698df5cd4e3",
|
||||
"name": "test_flavor",
|
||||
"root_gb": 1,
|
||||
"vcpus": 1,
|
||||
"ephemeral_gb": 0,
|
||||
"memory_mb": 512
|
||||
"memory_mb": 512,
|
||||
"disabled": false,
|
||||
"rxtx_factor": 1.0,
|
||||
"swap": 0,
|
||||
"is_public": true,
|
||||
"vcpu_weight": 0
|
||||
},
|
||||
"nova_object.version": "1.0",
|
||||
"nova_object.version": "1.1",
|
||||
"nova_object.namespace": "nova"
|
||||
},
|
||||
"user_id":"fake",
|
||||
|
@ -42,12 +42,18 @@
|
||||
"nova_object.name": "FlavorPayload",
|
||||
"nova_object.data": {
|
||||
"flavorid": "a22d5517-147c-4147-a0d1-e698df5cd4e3",
|
||||
"name": "test_flavor",
|
||||
"root_gb": 1,
|
||||
"vcpus": 1,
|
||||
"ephemeral_gb": 0,
|
||||
"memory_mb": 512
|
||||
"memory_mb": 512,
|
||||
"disabled": false,
|
||||
"rxtx_factor": 1.0,
|
||||
"swap": 0,
|
||||
"is_public": true,
|
||||
"vcpu_weight": 0
|
||||
},
|
||||
"nova_object.version": "1.0",
|
||||
"nova_object.version": "1.1",
|
||||
"nova_object.namespace": "nova"
|
||||
},
|
||||
"user_id":"fake",
|
||||
|
@ -42,12 +42,18 @@
|
||||
"nova_object.name": "FlavorPayload",
|
||||
"nova_object.data": {
|
||||
"flavorid": "d5a8bb54-365a-45ae-abdb-38d249df7845",
|
||||
"name": "other_flavor",
|
||||
"root_gb": 1,
|
||||
"vcpus": 1,
|
||||
"ephemeral_gb": 0,
|
||||
"memory_mb": 256
|
||||
"memory_mb": 256,
|
||||
"disabled": false,
|
||||
"rxtx_factor": 1.0,
|
||||
"swap": 0,
|
||||
"is_public": true,
|
||||
"vcpu_weight": 0
|
||||
},
|
||||
"nova_object.version": "1.0",
|
||||
"nova_object.version": "1.1",
|
||||
"nova_object.namespace": "nova"
|
||||
},
|
||||
"user_id":"fake",
|
||||
|
@ -42,12 +42,18 @@
|
||||
"nova_object.name": "FlavorPayload",
|
||||
"nova_object.data": {
|
||||
"flavorid": "d5a8bb54-365a-45ae-abdb-38d249df7845",
|
||||
"name": "other_flavor",
|
||||
"root_gb": 1,
|
||||
"vcpus": 1,
|
||||
"ephemeral_gb": 0,
|
||||
"memory_mb": 256
|
||||
"memory_mb": 256,
|
||||
"disabled": false,
|
||||
"rxtx_factor": 1.0,
|
||||
"swap": 0,
|
||||
"is_public": true,
|
||||
"vcpu_weight": 0
|
||||
},
|
||||
"nova_object.version": "1.0",
|
||||
"nova_object.version": "1.1",
|
||||
"nova_object.namespace": "nova"
|
||||
},
|
||||
"user_id":"fake",
|
||||
|
@ -42,12 +42,18 @@
|
||||
"nova_object.name": "FlavorPayload",
|
||||
"nova_object.data": {
|
||||
"flavorid": "a22d5517-147c-4147-a0d1-e698df5cd4e3",
|
||||
"name": "test_flavor",
|
||||
"root_gb": 1,
|
||||
"vcpus": 1,
|
||||
"ephemeral_gb": 0,
|
||||
"memory_mb": 512
|
||||
"memory_mb": 512,
|
||||
"disabled": false,
|
||||
"rxtx_factor": 1.0,
|
||||
"swap": 0,
|
||||
"is_public": true,
|
||||
"vcpu_weight": 0
|
||||
},
|
||||
"nova_object.version": "1.0",
|
||||
"nova_object.version": "1.1",
|
||||
"nova_object.namespace": "nova"
|
||||
},
|
||||
"user_id":"fake",
|
||||
|
@ -42,12 +42,18 @@
|
||||
"nova_object.name": "FlavorPayload",
|
||||
"nova_object.data": {
|
||||
"flavorid": "a22d5517-147c-4147-a0d1-e698df5cd4e3",
|
||||
"name": "test_flavor",
|
||||
"root_gb": 1,
|
||||
"vcpus": 1,
|
||||
"ephemeral_gb": 0,
|
||||
"memory_mb": 512
|
||||
"memory_mb": 512,
|
||||
"disabled": false,
|
||||
"rxtx_factor": 1.0,
|
||||
"swap": 0,
|
||||
"is_public": true,
|
||||
"vcpu_weight": 0
|
||||
},
|
||||
"nova_object.version": "1.0",
|
||||
"nova_object.version": "1.1",
|
||||
"nova_object.namespace": "nova"
|
||||
},
|
||||
"user_id":"fake",
|
||||
|
@ -42,12 +42,18 @@
|
||||
"nova_object.name": "FlavorPayload",
|
||||
"nova_object.data": {
|
||||
"flavorid": "a22d5517-147c-4147-a0d1-e698df5cd4e3",
|
||||
"name": "test_flavor",
|
||||
"root_gb": 1,
|
||||
"vcpus": 1,
|
||||
"ephemeral_gb": 0,
|
||||
"memory_mb": 512
|
||||
"memory_mb": 512,
|
||||
"disabled": false,
|
||||
"rxtx_factor": 1.0,
|
||||
"swap": 0,
|
||||
"is_public": true,
|
||||
"vcpu_weight": 0
|
||||
},
|
||||
"nova_object.version": "1.0",
|
||||
"nova_object.version": "1.1",
|
||||
"nova_object.namespace": "nova"
|
||||
},
|
||||
"user_id":"fake",
|
||||
|
@ -42,12 +42,18 @@
|
||||
"nova_object.name": "FlavorPayload",
|
||||
"nova_object.data": {
|
||||
"flavorid": "a22d5517-147c-4147-a0d1-e698df5cd4e3",
|
||||
"name": "test_flavor",
|
||||
"root_gb": 1,
|
||||
"vcpus": 1,
|
||||
"ephemeral_gb": 0,
|
||||
"memory_mb": 512
|
||||
"memory_mb": 512,
|
||||
"disabled": false,
|
||||
"rxtx_factor": 1.0,
|
||||
"swap": 0,
|
||||
"is_public": true,
|
||||
"vcpu_weight": 0
|
||||
},
|
||||
"nova_object.version": "1.0",
|
||||
"nova_object.version": "1.1",
|
||||
"nova_object.namespace": "nova"
|
||||
},
|
||||
"user_id":"fake",
|
||||
|
@ -42,12 +42,18 @@
|
||||
"nova_object.name": "FlavorPayload",
|
||||
"nova_object.data": {
|
||||
"flavorid": "a22d5517-147c-4147-a0d1-e698df5cd4e3",
|
||||
"name": "test_flavor",
|
||||
"root_gb": 1,
|
||||
"vcpus": 1,
|
||||
"ephemeral_gb": 0,
|
||||
"memory_mb": 512
|
||||
"memory_mb": 512,
|
||||
"disabled": false,
|
||||
"rxtx_factor": 1.0,
|
||||
"swap": 0,
|
||||
"is_public": true,
|
||||
"vcpu_weight": 0
|
||||
},
|
||||
"nova_object.version": "1.0",
|
||||
"nova_object.version": "1.1",
|
||||
"nova_object.namespace": "nova"
|
||||
},
|
||||
"user_id":"fake",
|
||||
|
@ -42,12 +42,18 @@
|
||||
"nova_object.name": "FlavorPayload",
|
||||
"nova_object.data": {
|
||||
"flavorid": "a22d5517-147c-4147-a0d1-e698df5cd4e3",
|
||||
"name": "test_flavor",
|
||||
"root_gb": 1,
|
||||
"vcpus": 1,
|
||||
"ephemeral_gb": 0,
|
||||
"memory_mb": 512
|
||||
"memory_mb": 512,
|
||||
"disabled": false,
|
||||
"rxtx_factor": 1.0,
|
||||
"swap": 0,
|
||||
"is_public": true,
|
||||
"vcpu_weight": 0
|
||||
},
|
||||
"nova_object.version": "1.0",
|
||||
"nova_object.version": "1.1",
|
||||
"nova_object.namespace": "nova"
|
||||
},
|
||||
"user_id":"fake",
|
||||
|
@ -42,12 +42,18 @@
|
||||
"nova_object.name": "FlavorPayload",
|
||||
"nova_object.data": {
|
||||
"flavorid": "a22d5517-147c-4147-a0d1-e698df5cd4e3",
|
||||
"name": "test_flavor",
|
||||
"root_gb": 1,
|
||||
"vcpus": 1,
|
||||
"ephemeral_gb": 0,
|
||||
"memory_mb": 512
|
||||
"memory_mb": 512,
|
||||
"disabled": false,
|
||||
"rxtx_factor": 1.0,
|
||||
"swap": 0,
|
||||
"is_public": true,
|
||||
"vcpu_weight": 0
|
||||
},
|
||||
"nova_object.version": "1.0",
|
||||
"nova_object.version": "1.1",
|
||||
"nova_object.namespace": "nova"
|
||||
},
|
||||
"user_id":"fake",
|
||||
|
@ -42,12 +42,18 @@
|
||||
"nova_object.name": "FlavorPayload",
|
||||
"nova_object.data": {
|
||||
"flavorid": "a22d5517-147c-4147-a0d1-e698df5cd4e3",
|
||||
"name": "test_flavor",
|
||||
"root_gb": 1,
|
||||
"vcpus": 1,
|
||||
"ephemeral_gb": 0,
|
||||
"memory_mb": 512
|
||||
"memory_mb": 512,
|
||||
"disabled": false,
|
||||
"rxtx_factor": 1.0,
|
||||
"swap": 0,
|
||||
"is_public": true,
|
||||
"vcpu_weight": 0
|
||||
},
|
||||
"nova_object.version": "1.0",
|
||||
"nova_object.version": "1.1",
|
||||
"nova_object.namespace": "nova"
|
||||
},
|
||||
"user_id":"fake",
|
||||
|
@ -42,12 +42,18 @@
|
||||
"nova_object.name": "FlavorPayload",
|
||||
"nova_object.data": {
|
||||
"flavorid": "a22d5517-147c-4147-a0d1-e698df5cd4e3",
|
||||
"name": "test_flavor",
|
||||
"root_gb": 1,
|
||||
"vcpus": 1,
|
||||
"ephemeral_gb": 0,
|
||||
"memory_mb": 512
|
||||
"memory_mb": 512,
|
||||
"disabled": false,
|
||||
"rxtx_factor": 1.0,
|
||||
"swap": 0,
|
||||
"is_public": true,
|
||||
"vcpu_weight": 0
|
||||
},
|
||||
"nova_object.version": "1.0",
|
||||
"nova_object.version": "1.1",
|
||||
"nova_object.namespace": "nova"
|
||||
},
|
||||
"user_id":"fake",
|
||||
|
@ -42,12 +42,18 @@
|
||||
"nova_object.name": "FlavorPayload",
|
||||
"nova_object.data": {
|
||||
"flavorid": "a22d5517-147c-4147-a0d1-e698df5cd4e3",
|
||||
"name": "test_flavor",
|
||||
"root_gb": 1,
|
||||
"vcpus": 1,
|
||||
"ephemeral_gb": 0,
|
||||
"memory_mb": 512
|
||||
"memory_mb": 512,
|
||||
"disabled": false,
|
||||
"rxtx_factor": 1.0,
|
||||
"swap": 0,
|
||||
"is_public": true,
|
||||
"vcpu_weight": 0
|
||||
},
|
||||
"nova_object.version": "1.0",
|
||||
"nova_object.version": "1.1",
|
||||
"nova_object.namespace": "nova"
|
||||
},
|
||||
"user_id":"fake",
|
||||
|
@ -42,12 +42,18 @@
|
||||
"nova_object.name": "FlavorPayload",
|
||||
"nova_object.data": {
|
||||
"flavorid": "a22d5517-147c-4147-a0d1-e698df5cd4e3",
|
||||
"name": "test_flavor",
|
||||
"root_gb": 1,
|
||||
"vcpus": 1,
|
||||
"ephemeral_gb": 0,
|
||||
"memory_mb": 512
|
||||
"memory_mb": 512,
|
||||
"disabled": false,
|
||||
"rxtx_factor": 1.0,
|
||||
"swap": 0,
|
||||
"is_public": true,
|
||||
"vcpu_weight": 0
|
||||
},
|
||||
"nova_object.version": "1.0",
|
||||
"nova_object.version": "1.1",
|
||||
"nova_object.namespace": "nova"
|
||||
},
|
||||
"user_id":"fake",
|
||||
|
@ -42,12 +42,18 @@
|
||||
"nova_object.name": "FlavorPayload",
|
||||
"nova_object.data": {
|
||||
"flavorid": "a22d5517-147c-4147-a0d1-e698df5cd4e3",
|
||||
"name": "test_flavor",
|
||||
"root_gb": 1,
|
||||
"vcpus": 1,
|
||||
"ephemeral_gb": 0,
|
||||
"memory_mb": 512
|
||||
"memory_mb": 512,
|
||||
"disabled": false,
|
||||
"rxtx_factor": 1.0,
|
||||
"swap": 0,
|
||||
"is_public": true,
|
||||
"vcpu_weight": 0
|
||||
},
|
||||
"nova_object.version": "1.0",
|
||||
"nova_object.version": "1.1",
|
||||
"nova_object.namespace": "nova"
|
||||
},
|
||||
"user_id":"fake",
|
||||
|
@ -42,12 +42,18 @@
|
||||
"nova_object.name": "FlavorPayload",
|
||||
"nova_object.data": {
|
||||
"flavorid": "a22d5517-147c-4147-a0d1-e698df5cd4e3",
|
||||
"name": "test_flavor",
|
||||
"root_gb": 1,
|
||||
"vcpus": 1,
|
||||
"ephemeral_gb": 0,
|
||||
"memory_mb": 512
|
||||
"memory_mb": 512,
|
||||
"disabled": false,
|
||||
"rxtx_factor": 1.0,
|
||||
"swap": 0,
|
||||
"is_public": true,
|
||||
"vcpu_weight": 0
|
||||
},
|
||||
"nova_object.version": "1.0",
|
||||
"nova_object.version": "1.1",
|
||||
"nova_object.namespace": "nova"
|
||||
},
|
||||
"user_id":"fake",
|
||||
|
@ -42,12 +42,18 @@
|
||||
"nova_object.name": "FlavorPayload",
|
||||
"nova_object.data": {
|
||||
"flavorid": "a22d5517-147c-4147-a0d1-e698df5cd4e3",
|
||||
"name": "test_flavor",
|
||||
"root_gb": 1,
|
||||
"vcpus": 1,
|
||||
"ephemeral_gb": 0,
|
||||
"memory_mb": 512
|
||||
"memory_mb": 512,
|
||||
"disabled": false,
|
||||
"rxtx_factor": 1.0,
|
||||
"swap": 0,
|
||||
"is_public": true,
|
||||
"vcpu_weight": 0
|
||||
},
|
||||
"nova_object.version": "1.0",
|
||||
"nova_object.version": "1.1",
|
||||
"nova_object.namespace": "nova"
|
||||
},
|
||||
"user_id":"fake",
|
||||
|
@ -42,12 +42,18 @@
|
||||
"nova_object.name": "FlavorPayload",
|
||||
"nova_object.data": {
|
||||
"flavorid": "a22d5517-147c-4147-a0d1-e698df5cd4e3",
|
||||
"name": "test_flavor",
|
||||
"root_gb": 1,
|
||||
"vcpus": 1,
|
||||
"ephemeral_gb": 0,
|
||||
"memory_mb": 512
|
||||
"memory_mb": 512,
|
||||
"disabled": false,
|
||||
"rxtx_factor": 1.0,
|
||||
"swap": 0,
|
||||
"is_public": true,
|
||||
"vcpu_weight": 0
|
||||
},
|
||||
"nova_object.version": "1.0",
|
||||
"nova_object.version": "1.1",
|
||||
"nova_object.namespace": "nova"
|
||||
},
|
||||
"user_id":"fake",
|
||||
|
@ -42,12 +42,18 @@
|
||||
"nova_object.name": "FlavorPayload",
|
||||
"nova_object.data": {
|
||||
"flavorid": "a22d5517-147c-4147-a0d1-e698df5cd4e3",
|
||||
"name": "test_flavor",
|
||||
"root_gb": 1,
|
||||
"vcpus": 1,
|
||||
"ephemeral_gb": 0,
|
||||
"memory_mb": 512
|
||||
"memory_mb": 512,
|
||||
"disabled": false,
|
||||
"rxtx_factor": 1.0,
|
||||
"swap": 0,
|
||||
"is_public": true,
|
||||
"vcpu_weight": 0
|
||||
},
|
||||
"nova_object.version": "1.0",
|
||||
"nova_object.version": "1.1",
|
||||
"nova_object.namespace": "nova"
|
||||
},
|
||||
"user_id":"fake",
|
||||
|
@ -42,12 +42,18 @@
|
||||
"nova_object.name": "FlavorPayload",
|
||||
"nova_object.data": {
|
||||
"flavorid": "a22d5517-147c-4147-a0d1-e698df5cd4e3",
|
||||
"name": "test_flavor",
|
||||
"root_gb": 1,
|
||||
"vcpus": 1,
|
||||
"ephemeral_gb": 0,
|
||||
"memory_mb": 512
|
||||
"memory_mb": 512,
|
||||
"disabled": false,
|
||||
"rxtx_factor": 1.0,
|
||||
"swap": 0,
|
||||
"is_public": true,
|
||||
"vcpu_weight": 0
|
||||
},
|
||||
"nova_object.version": "1.0",
|
||||
"nova_object.version": "1.1",
|
||||
"nova_object.namespace": "nova"
|
||||
},
|
||||
"user_id":"fake",
|
||||
|
@ -42,12 +42,18 @@
|
||||
"nova_object.name": "FlavorPayload",
|
||||
"nova_object.data": {
|
||||
"flavorid": "a22d5517-147c-4147-a0d1-e698df5cd4e3",
|
||||
"name": "test_flavor",
|
||||
"root_gb": 1,
|
||||
"vcpus": 1,
|
||||
"ephemeral_gb": 0,
|
||||
"memory_mb": 512
|
||||
"memory_mb": 512,
|
||||
"disabled": false,
|
||||
"rxtx_factor": 1.0,
|
||||
"swap": 0,
|
||||
"is_public": true,
|
||||
"vcpu_weight": 0
|
||||
},
|
||||
"nova_object.version": "1.0",
|
||||
"nova_object.version": "1.1",
|
||||
"nova_object.namespace": "nova"
|
||||
},
|
||||
"user_id":"fake",
|
||||
|
@ -47,12 +47,18 @@
|
||||
"nova_object.name": "FlavorPayload",
|
||||
"nova_object.data": {
|
||||
"flavorid": "a22d5517-147c-4147-a0d1-e698df5cd4e3",
|
||||
"name": "test_flavor",
|
||||
"root_gb": 1,
|
||||
"vcpus": 1,
|
||||
"ephemeral_gb": 0,
|
||||
"memory_mb": 512
|
||||
"memory_mb": 512,
|
||||
"disabled": false,
|
||||
"rxtx_factor": 1.0,
|
||||
"swap": 0,
|
||||
"is_public": true,
|
||||
"vcpu_weight": 0
|
||||
},
|
||||
"nova_object.version": "1.0",
|
||||
"nova_object.version": "1.1",
|
||||
"nova_object.namespace": "nova"
|
||||
},
|
||||
"user_id": "fake",
|
||||
|
@ -11,14 +11,20 @@
|
||||
"flavor": {
|
||||
"nova_object.data": {
|
||||
"flavorid": "a22d5517-147c-4147-a0d1-e698df5cd4e3",
|
||||
"name": "test_flavor",
|
||||
"root_gb": 1,
|
||||
"vcpus": 1,
|
||||
"ephemeral_gb": 0,
|
||||
"memory_mb": 512
|
||||
"memory_mb": 512,
|
||||
"disabled": false,
|
||||
"rxtx_factor": 1.0,
|
||||
"swap": 0,
|
||||
"is_public": true,
|
||||
"vcpu_weight": 0
|
||||
},
|
||||
"nova_object.name": "FlavorPayload",
|
||||
"nova_object.namespace": "nova",
|
||||
"nova_object.version": "1.0"
|
||||
"nova_object.version": "1.1"
|
||||
},
|
||||
"host": "compute",
|
||||
"host_name": "some-server",
|
||||
|
@ -21,14 +21,20 @@
|
||||
"flavor": {
|
||||
"nova_object.data": {
|
||||
"flavorid": "a22d5517-147c-4147-a0d1-e698df5cd4e3",
|
||||
"name": "test_flavor",
|
||||
"root_gb": 1,
|
||||
"vcpus": 1,
|
||||
"ephemeral_gb": 0,
|
||||
"memory_mb": 512
|
||||
"memory_mb": 512,
|
||||
"disabled": false,
|
||||
"rxtx_factor": 1.0,
|
||||
"swap": 0,
|
||||
"is_public": true,
|
||||
"vcpu_weight": 0
|
||||
},
|
||||
"nova_object.name": "FlavorPayload",
|
||||
"nova_object.namespace": "nova",
|
||||
"nova_object.version": "1.0"
|
||||
"nova_object.version": "1.1"
|
||||
},
|
||||
"host": "compute",
|
||||
"host_name": "some-server",
|
||||
|
@ -11,14 +11,20 @@
|
||||
"flavor": {
|
||||
"nova_object.data": {
|
||||
"flavorid": "a22d5517-147c-4147-a0d1-e698df5cd4e3",
|
||||
"name": "test_flavor",
|
||||
"root_gb": 1,
|
||||
"vcpus": 1,
|
||||
"ephemeral_gb": 0,
|
||||
"memory_mb": 512
|
||||
"memory_mb": 512,
|
||||
"disabled": false,
|
||||
"rxtx_factor": 1.0,
|
||||
"swap": 0,
|
||||
"is_public": true,
|
||||
"vcpu_weight": 0
|
||||
},
|
||||
"nova_object.name": "FlavorPayload",
|
||||
"nova_object.namespace": "nova",
|
||||
"nova_object.version": "1.0"
|
||||
"nova_object.version": "1.1"
|
||||
},
|
||||
"host": "compute",
|
||||
"host_name": "some-server",
|
||||
|
@ -364,7 +364,7 @@ def notify_about_instance_action(context, instance, host, action, phase=None,
|
||||
"""
|
||||
ips = _get_instance_ips(instance)
|
||||
|
||||
flavor = flavor_notification.FlavorPayload(instance=instance)
|
||||
flavor = flavor_notification.FlavorPayload(instance.flavor)
|
||||
fault, priority = _get_fault_and_priority_from_exc(exception)
|
||||
payload = instance_notification.InstanceActionPayload(
|
||||
instance=instance,
|
||||
@ -400,7 +400,7 @@ def notify_about_volume_swap(context, instance, host, action, phase,
|
||||
"""
|
||||
ips = _get_instance_ips(instance)
|
||||
|
||||
flavor = flavor_notification.FlavorPayload(instance=instance)
|
||||
flavor = flavor_notification.FlavorPayload(instance.flavor)
|
||||
|
||||
fault, priority = _get_fault_and_priority_from_exc(exception)
|
||||
payload = instance_notification.InstanceActionVolumeSwapPayload(
|
||||
|
@ -281,7 +281,7 @@ def _send_versioned_instance_update(context, instance, payload, host, service):
|
||||
for label, bw in payload['bandwidth'].items()]
|
||||
|
||||
network_info = instance.info_cache.network_info
|
||||
flavor = flavor_notification.FlavorPayload(instance=instance)
|
||||
flavor = flavor_notification.FlavorPayload(instance.flavor)
|
||||
|
||||
versioned_payload = instance_notification.InstanceUpdatePayload(
|
||||
instance=instance,
|
||||
|
@ -10,22 +10,45 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from oslo_utils import versionutils
|
||||
|
||||
from nova.notifications.objects import base
|
||||
from nova.objects import base as nova_base
|
||||
from nova.objects import fields
|
||||
|
||||
|
||||
@base.notification_sample('flavor-create.json')
|
||||
@base.notification_sample('flavor-delete.json')
|
||||
@nova_base.NovaObjectRegistry.register_notification
|
||||
class FlavorPayload(base.NotificationPayloadBase):
|
||||
class FlavorNotification(base.NotificationBase):
|
||||
# Version 1.0: Initial version
|
||||
VERSION = '1.0'
|
||||
|
||||
fields = {
|
||||
'payload': fields.ObjectField('FlavorPayload')
|
||||
}
|
||||
|
||||
|
||||
@nova_base.NovaObjectRegistry.register_notification
|
||||
class FlavorPayload(base.NotificationPayloadBase):
|
||||
# Version 1.0: Initial version
|
||||
# Version 1.1: Add other fields for Flavor
|
||||
VERSION = '1.1'
|
||||
|
||||
# NOTE: if we'd want to rename some fields(memory_mb->ram, root_gb->disk,
|
||||
# ephemeral_gb: ephemeral), bumping to payload version 2.0 will be needed.
|
||||
SCHEMA = {
|
||||
'flavorid': ('flavor', 'flavorid'),
|
||||
'memory_mb': ('flavor', 'memory_mb'),
|
||||
'vcpus': ('flavor', 'vcpus'),
|
||||
'root_gb': ('flavor', 'root_gb'),
|
||||
'ephemeral_gb': ('flavor', 'ephemeral_gb'),
|
||||
'name': ('flavor', 'name'),
|
||||
'swap': ('flavor', 'swap'),
|
||||
'rxtx_factor': ('flavor', 'rxtx_factor'),
|
||||
'vcpu_weight': ('flavor', 'vcpu_weight'),
|
||||
'disabled': ('flavor', 'disabled'),
|
||||
'is_public': ('flavor', 'is_public'),
|
||||
}
|
||||
|
||||
fields = {
|
||||
@ -34,8 +57,26 @@ class FlavorPayload(base.NotificationPayloadBase):
|
||||
'vcpus': fields.IntegerField(nullable=True),
|
||||
'root_gb': fields.IntegerField(nullable=True),
|
||||
'ephemeral_gb': fields.IntegerField(nullable=True),
|
||||
'name': fields.StringField(),
|
||||
'swap': fields.IntegerField(),
|
||||
'rxtx_factor': fields.FloatField(nullable=True),
|
||||
'vcpu_weight': fields.IntegerField(nullable=True),
|
||||
'disabled': fields.BooleanField(),
|
||||
'is_public': fields.BooleanField(),
|
||||
}
|
||||
|
||||
def __init__(self, instance, **kwargs):
|
||||
def __init__(self, flavor, **kwargs):
|
||||
super(FlavorPayload, self).__init__(**kwargs)
|
||||
self.populate_schema(instance=instance, flavor=instance.flavor)
|
||||
self.populate_schema(flavor=flavor)
|
||||
|
||||
def obj_make_compatible(self, primitive, target_version):
|
||||
super(FlavorPayload, self).obj_make_compatible(primitive,
|
||||
target_version)
|
||||
target_version = versionutils.convert_version_to_tuple(target_version)
|
||||
if target_version < (1, 1):
|
||||
primitive.pop('name', None)
|
||||
primitive.pop('swap', None)
|
||||
primitive.pop('rxtx_factor', None)
|
||||
primitive.pop('vcpu_weight', None)
|
||||
primitive.pop('disabled', None)
|
||||
primitive.pop('is_public', None)
|
||||
|
@ -22,6 +22,7 @@ from sqlalchemy.sql import func
|
||||
from sqlalchemy.sql import text
|
||||
from sqlalchemy.sql import true
|
||||
|
||||
import nova.conf
|
||||
from nova import db
|
||||
from nova.db.sqlalchemy import api as db_api
|
||||
from nova.db.sqlalchemy.api import require_context
|
||||
@ -29,6 +30,8 @@ from nova.db.sqlalchemy import api_models
|
||||
from nova.db.sqlalchemy import models as main_models
|
||||
from nova import exception
|
||||
from nova.i18n import _LW
|
||||
from nova.notifications.objects import base as notification
|
||||
from nova.notifications.objects import flavor as flavor_notification
|
||||
from nova import objects
|
||||
from nova.objects import base
|
||||
from nova.objects import fields
|
||||
@ -38,6 +41,8 @@ LOG = logging.getLogger(__name__)
|
||||
OPTIONAL_FIELDS = ['extra_specs', 'projects']
|
||||
DEPRECATED_FIELDS = ['deleted', 'deleted_at']
|
||||
|
||||
CONF = nova.conf.CONF
|
||||
|
||||
|
||||
def _dict_with_extra_specs(flavor_model):
|
||||
extra_specs = {x['key']: x['value']
|
||||
@ -185,6 +190,7 @@ def _flavor_destroy(context, flavor_id=None, flavorid=None):
|
||||
context.session.query(api_models.FlavorExtraSpecs).\
|
||||
filter_by(flavor_id=result.id).delete()
|
||||
context.session.delete(result)
|
||||
return result
|
||||
|
||||
|
||||
@db_api.pick_context_manager_reader
|
||||
@ -487,6 +493,7 @@ class Flavor(base.NovaPersistentObject, base.NovaObject,
|
||||
db_flavor = self._flavor_create(self._context, updates)
|
||||
self._from_db_object(self._context, self, db_flavor,
|
||||
expected_attrs=expected_attrs)
|
||||
self._send_notification(fields.NotificationAction.CREATE)
|
||||
|
||||
@base.remotable
|
||||
def save_projects(self, to_add=None, to_delete=None):
|
||||
@ -574,7 +581,7 @@ class Flavor(base.NovaPersistentObject, base.NovaObject,
|
||||
|
||||
@staticmethod
|
||||
def _flavor_destroy(context, flavor_id=None, flavorid=None):
|
||||
_flavor_destroy(context, flavor_id=flavor_id, flavorid=flavorid)
|
||||
return _flavor_destroy(context, flavor_id=flavor_id, flavorid=flavorid)
|
||||
|
||||
@base.remotable
|
||||
def destroy(self):
|
||||
@ -586,12 +593,29 @@ class Flavor(base.NovaPersistentObject, base.NovaObject,
|
||||
# far more specific.
|
||||
try:
|
||||
if 'id' in self:
|
||||
self._flavor_destroy(self._context, flavor_id=self.id)
|
||||
db_flavor = self._flavor_destroy(self._context,
|
||||
flavor_id=self.id)
|
||||
else:
|
||||
self._flavor_destroy(self._context, flavorid=self.flavorid)
|
||||
db_flavor = self._flavor_destroy(self._context,
|
||||
flavorid=self.flavorid)
|
||||
self._from_db_object(self._context, self, db_flavor)
|
||||
self._send_notification(fields.NotificationAction.DELETE)
|
||||
except exception.FlavorNotFound:
|
||||
db.flavor_destroy(self._context, self.flavorid)
|
||||
|
||||
def _send_notification(self, action):
|
||||
notification_type = flavor_notification.FlavorNotification
|
||||
payload_type = flavor_notification.FlavorPayload
|
||||
|
||||
payload = payload_type(self)
|
||||
notification_type(
|
||||
publisher=notification.NotificationPublisher(
|
||||
host=CONF.host, binary="nova-api"),
|
||||
event_type=notification.EventType(object="flavor",
|
||||
action=action),
|
||||
priority=fields.NotificationPriority.INFO,
|
||||
payload=payload).emit(self._context)
|
||||
|
||||
|
||||
@db_api.api_context_manager.reader
|
||||
def _flavor_get_all_from_db(context, inactive, filters, sort_key, sort_dir,
|
||||
|
@ -143,6 +143,8 @@ class NotificationSampleTestBase(test.TestCase,
|
||||
}}
|
||||
|
||||
flavor_id = self.api.post_flavor(flavor_body)['id']
|
||||
# Ignore the create flavor notification
|
||||
fake_notifier.reset()
|
||||
|
||||
server = self._build_minimal_create_server_request(
|
||||
self.api, 'some-server',
|
||||
|
@ -0,0 +1,51 @@
|
||||
# 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 nova.tests.functional.notification_sample_tests \
|
||||
import notification_sample_base
|
||||
from nova.tests.unit import fake_notifier
|
||||
|
||||
|
||||
class TestFlavorNotificationSample(
|
||||
notification_sample_base.NotificationSampleTestBase):
|
||||
|
||||
def test_flavor_create(self):
|
||||
body = {
|
||||
"flavor": {
|
||||
"name": "test_flavor",
|
||||
"ram": 1024,
|
||||
"vcpus": 2,
|
||||
"disk": 10,
|
||||
"id": "a22d5517-147c-4147-a0d1-e698df5cd4e3",
|
||||
"rxtx_factor": 2.0
|
||||
}
|
||||
}
|
||||
self.admin_api.api_post('flavors', body)
|
||||
self._verify_notification('flavor-create')
|
||||
|
||||
def test_flavor_destroy(self):
|
||||
body = {
|
||||
"flavor": {
|
||||
"name": "test_flavor",
|
||||
"ram": 1024,
|
||||
"vcpus": 2,
|
||||
"disk": 10,
|
||||
"id": "a22d5517-147c-4147-a0d1-e698df5cd4e3",
|
||||
"rxtx_factor": 2.0
|
||||
}
|
||||
}
|
||||
# Create a flavor.
|
||||
self.admin_api.api_post('flavors', body)
|
||||
self.admin_api.api_delete(
|
||||
'flavors/a22d5517-147c-4147-a0d1-e698df5cd4e3')
|
||||
self._verify_notification(
|
||||
'flavor-delete', actual=fake_notifier.VERSIONED_NOTIFICATIONS[1])
|
@ -487,6 +487,8 @@ class TestInstanceNotificationSample(
|
||||
}
|
||||
}
|
||||
other_flavor_id = self.api.post_flavor(other_flavor_body)['id']
|
||||
# Ignore the create flavor notification
|
||||
fake_notifier.reset()
|
||||
|
||||
post = {
|
||||
'resize': {
|
||||
|
103
nova/tests/unit/notifications/objects/test_flavor.py
Normal file
103
nova/tests/unit/notifications/objects/test_flavor.py
Normal file
@ -0,0 +1,103 @@
|
||||
# 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 copy
|
||||
import mock
|
||||
|
||||
from nova import context
|
||||
from nova.notifications.objects import flavor as flavor_notification
|
||||
from nova import objects
|
||||
from nova.objects import fields
|
||||
from nova import test
|
||||
from nova.tests.unit.objects.test_flavor import fake_flavor
|
||||
|
||||
|
||||
class TestFlavorNotification(test.TestCase):
|
||||
def setUp(self):
|
||||
self.ctxt = context.get_admin_context()
|
||||
super(TestFlavorNotification, self).setUp()
|
||||
|
||||
@mock.patch('nova.notifications.objects.flavor.FlavorNotification')
|
||||
def _verify_notification(self, flavor_obj, flavor, action,
|
||||
mock_notification):
|
||||
notification = mock_notification
|
||||
if action == "CREATE":
|
||||
flavor_obj.create()
|
||||
elif action == "DELETE":
|
||||
flavor_obj.destroy()
|
||||
else:
|
||||
raise Exception('Unsupported action: %s' % action)
|
||||
|
||||
self.assertTrue(notification.called)
|
||||
|
||||
event_type = notification.call_args[1]['event_type']
|
||||
priority = notification.call_args[1]['priority']
|
||||
publisher = notification.call_args[1]['publisher']
|
||||
payload = notification.call_args[1]['payload']
|
||||
|
||||
self.assertEqual("fake-mini", publisher.host)
|
||||
self.assertEqual("nova-api", publisher.binary)
|
||||
self.assertEqual(fields.NotificationPriority.INFO, priority)
|
||||
self.assertEqual('flavor', event_type.object)
|
||||
self.assertEqual(getattr(fields.NotificationAction, action),
|
||||
event_type.action)
|
||||
notification.return_value.emit.assert_called_once_with(self.ctxt)
|
||||
|
||||
schema = flavor_notification.FlavorPayload.SCHEMA
|
||||
for field in schema:
|
||||
if field in flavor:
|
||||
self.assertEqual(flavor[field], getattr(payload, field))
|
||||
|
||||
@mock.patch('nova.objects.Flavor._flavor_create')
|
||||
def test_flavor_create_with_notification(self, mock_create):
|
||||
flavor = copy.deepcopy(fake_flavor)
|
||||
flavor_obj = objects.Flavor(context=self.ctxt)
|
||||
flavor_obj.extra_specs = flavor['extra_specs']
|
||||
flavorid = '1'
|
||||
flavor['flavorid'] = flavorid
|
||||
flavor['id'] = flavorid
|
||||
mock_create.return_value = flavor
|
||||
self._verify_notification(flavor_obj, flavor, 'CREATE')
|
||||
|
||||
@mock.patch('nova.objects.Flavor._flavor_destroy')
|
||||
def test_flavor_destroy_with_notification(self, mock_destroy):
|
||||
flavor = copy.deepcopy(fake_flavor)
|
||||
flavorid = '1'
|
||||
flavor['flavorid'] = flavorid
|
||||
flavor['id'] = flavorid
|
||||
mock_destroy.return_value = flavor
|
||||
flavor_obj = objects.Flavor(context=self.ctxt, **flavor)
|
||||
flavor_obj.obj_reset_changes()
|
||||
self._verify_notification(flavor_obj, flavor, "DELETE")
|
||||
|
||||
def test_obj_make_compatible(self):
|
||||
flavor = copy.deepcopy(fake_flavor)
|
||||
flavorid = '1'
|
||||
flavor['flavorid'] = flavorid
|
||||
flavor['id'] = flavorid
|
||||
flavor_obj = objects.Flavor(context=self.ctxt, **flavor)
|
||||
flavor_payload = flavor_notification.FlavorPayload(flavor_obj)
|
||||
primitive = flavor_payload.obj_to_primitive()
|
||||
self.assertIn('name', primitive['nova_object.data'])
|
||||
self.assertIn('swap', primitive['nova_object.data'])
|
||||
self.assertIn('rxtx_factor', primitive['nova_object.data'])
|
||||
self.assertIn('vcpu_weight', primitive['nova_object.data'])
|
||||
self.assertIn('disabled', primitive['nova_object.data'])
|
||||
self.assertIn('is_public', primitive['nova_object.data'])
|
||||
flavor_payload.obj_make_compatible(primitive['nova_object.data'],
|
||||
'1.0')
|
||||
self.assertNotIn('name', primitive['nova_object.data'])
|
||||
self.assertNotIn('swap', primitive['nova_object.data'])
|
||||
self.assertNotIn('rxtx_factor', primitive['nova_object.data'])
|
||||
self.assertNotIn('vcpu_weight', primitive['nova_object.data'])
|
||||
self.assertNotIn('disabled', primitive['nova_object.data'])
|
||||
self.assertNotIn('is_public', primitive['nova_object.data'])
|
@ -262,7 +262,8 @@ notification_object_data = {
|
||||
'EventType': '1.4-da0f0fbcda143ca96c2ac1b93937c22c',
|
||||
'ExceptionNotification': '1.0-a73147b93b520ff0061865849d3dfa56',
|
||||
'ExceptionPayload': '1.0-27db46ee34cd97e39f2643ed92ad0cc5',
|
||||
'FlavorPayload': '1.0-89b17e778291bba22025b5956e072b66',
|
||||
'FlavorNotification': '1.0-a73147b93b520ff0061865849d3dfa56',
|
||||
'FlavorPayload': '1.1-e3892169e2c946f6784fe130deaeae4f',
|
||||
'InstanceActionNotification': '1.0-a73147b93b520ff0061865849d3dfa56',
|
||||
'InstanceActionPayload': '1.0-3145ac549217f46e88173c437917ca7a',
|
||||
'InstanceActionVolumeSwapNotification':
|
||||
|
@ -363,12 +363,14 @@ class _TestFlavor(object):
|
||||
|
||||
@mock.patch('nova.objects.Flavor._flavor_destroy')
|
||||
def test_destroy_api_by_id(self, mock_destroy):
|
||||
mock_destroy.return_value = dict(fake_flavor, id=123)
|
||||
flavor = flavor_obj.Flavor(context=self.context, id=123)
|
||||
flavor.destroy()
|
||||
mock_destroy.assert_called_once_with(self.context, flavor_id=flavor.id)
|
||||
|
||||
@mock.patch('nova.objects.Flavor._flavor_destroy')
|
||||
def test_destroy_api_by_flavorid(self, mock_destroy):
|
||||
mock_destroy.return_value = dict(fake_flavor, flavorid='foo')
|
||||
flavor = flavor_obj.Flavor(context=self.context, flavorid='foo')
|
||||
flavor.destroy()
|
||||
mock_destroy.assert_called_once_with(self.context,
|
||||
|
@ -317,7 +317,8 @@ class TestDatabaseAtVersionFixture(testtools.TestCase):
|
||||
|
||||
|
||||
class TestDefaultFlavorsFixture(testtools.TestCase):
|
||||
def test_flavors(self):
|
||||
@mock.patch("nova.objects.flavor.Flavor._send_notification")
|
||||
def test_flavors(self, mock_send_notification):
|
||||
self.useFixture(conf_fixture.ConfFixture())
|
||||
self.useFixture(fixtures.Database())
|
||||
self.useFixture(fixtures.Database(database='api'))
|
||||
|
@ -0,0 +1,4 @@
|
||||
---
|
||||
features:
|
||||
- Support versioned notifications for flavor operations like create and
|
||||
delete.
|
Loading…
Reference in New Issue
Block a user