vi /usr/lib/python2.7/json/encoder.py
import datetime (4 line 추가)
...
...
elif isinstance(o, datetime.datetime): (431 line 추가)
pass
elif o.__module__.startswith('nova'):
yield str(o)
Json 으로 변환하여 print 하기
import json
import nova.openstack.common import jsonutils (json 혹은 jsonutils 사용)
...
LOG.debug("image_service = %s", jsonutils.dumps(jsonutils.to_primitive(vars(image_service)), indent=2))
nova.api.openstack.compute.servers.py >> Controller >> create()inst_type = {
"memory_mb": 512,
"root_gb": 0,
"deleted_at": null,
"name": "m1.tiny",
"deleted": false,
"created_at": null,
"ephemeral_gb": 0,
"updated_at": null,
"disabled": false,
"vcpus": 1,
"extra_specs": {},
"swap": 0,
"rxtx_factor": 1.0,
"is_public": true,
"flavorid": "1",
"vcpu_weight": null,
"id": 2
}
image_href = "5c4c2339-55bd-4e9b-86cb-23694e3b9b17"
display_name = "test02"
display_description = "test02"
key_name = "mykey"
metadata = {}
access_ip_v4 = null
access_ip_v6 = null
injected_files = []
admin_password = "TbvbCd2NgA5S"
min_count = 1
max_count = 1
requested_networks = [
[
"0802c791-d4aa-473b-94a8-46d2b4aff91b",
"192.168.100.5"
]
]
security_group = [
"default"
]
user_data = null
availability_zone = null
config_drive = null
block_device_mapping = []
auto_disk_config = null
scheduler_hints = {}
nova.compute.api.py >> API >> _create_instance()
[ DB 신규 row 입력 ]
create_db_entry_for_new_instance
image_service = <nova.image.glance.GlanceImageService object at 0x588c450>
image_id = "5c4c2339-55bd-4e9b-86cb-23694e3b9b17"
image = {
"status": "active",
"name": "tty-linux",
"deleted": false,
"container_format": "ami",
"created_at": ,
"disk_format": "ami",
"updated_at": ,
"id": "5c4c2339-55bd-4e9b-86cb-23694e3b9b17",
"owner": "2ffae825c88b448bad4ef4d14f5c1204",
"min_ram": 0,
"checksum": "10047a119149e08fb206eea89832eee0",
"min_disk": 0,
"is_public": false,
"deleted_at": null,
"properties": {
"kernel_id": "f14c0936-e591-4291-901f-239bc41fd3d6",
"ramdisk_id": "cc111638-8590-4b5b-8759-f551017ea269"
},
"size": 25165824
}
context = {
"project_name": "service",
"user_id": "fa8ecb2a7110435daa10a5e9e459c7ca",
"roles": [
"admin",
"member"
],
"_read_deleted": "no",
"timestamp": "2012-12-26T14:49:00.820425",
"auth_token": "1f31ccc31d324ba88802826270772522",
"remote_address": "192.168.75.137",
"quota_class": null,
"is_admin": true,
"service_catalog": [
{
"endpoints_links": [],
"endpoints": [
{
"adminURL": "http://192.168.75.137:8776/v1/2ffae825c88b448bad4ef4d14f5c1204/v2.0",
"region": "RegionOne",
"publicURL": "http://192.168.75.137:8776/v1/2ffae825c88b448bad4ef4d14f5c1204",
"id": "82d6c5ae2899473c8aa77bd2ae99881b",
"internalURL": "http://192.168.75.137:8776/v1/2ffae825c88b448bad4ef4d14f5c1204"
}
],
"type": "volume",
"name": "volume"
},
{
"endpoints_links": [],
"endpoints": [
{
"adminURL": "http://192.168.75.137:9292/v1",
"region": "RegionOne",
"publicURL": "http://192.168.75.137:9292/v1",
"id": "2e65219ddb4143b9b0a89c334a5177dc",
"internalURL": "http://192.168.75.137:9292/v1"
}
],
"type": "image",
"name": "glance"
},
{
"endpoints_links": [],
"endpoints": [
{
"adminURL": "http://192.168.75.137:8774/v2/2ffae825c88b448bad4ef4d14f5c1204",
"region": "RegionOne",
"publicURL": "http://192.168.75.137:8774/v2/2ffae825c88b448bad4ef4d14f5c1204",
"id": "0e82d644a5cb47b1890f81bf67b43dec",
"internalURL": "http://192.168.75.137:8774/v2/2ffae825c88b448bad4ef4d14f5c1204"
}
],
"type": "compute",
"name": "nova"
},
{
"endpoints_links": [],
"endpoints": [
{
"adminURL": "http://192.168.75.137:35357/v2.0",
"region": "RegionOne",
"publicURL": "http://192.168.75.137:5000/v2.0",
"id": "2d85bf25bb7e4e6a82efa67063d51ac1",
"internalURL": "http://192.168.75.137:5000/v2.0"
}
],
"type": "identity",
"name": "keystone"
}
],
"request_id": "req-bda14315-16de-4b23-8d53-24745f87fdad",
"instance_lock_checked": false,
"project_id": "2ffae825c88b448bad4ef4d14f5c1204",
"user_name": "admin"
}
request_spec = {
"block_device_mapping": [],
"image": {
"status": "active",
"name": "tty-linux",
"deleted": false,
"container_format": "ami",
"created_at": "2012-11-30T07:51:06.000000",
"disk_format": "ami",
"updated_at": "2012-11-30T07:51:07.000000",
"properties": {
"kernel_id": "f14c0936-e591-4291-901f-239bc41fd3d6",
"ramdisk_id": "cc111638-8590-4b5b-8759-f551017ea269"
},
"min_disk": 0,
"min_ram": 0,
"checksum": "10047a119149e08fb206eea89832eee0",
"owner": "2ffae825c88b448bad4ef4d14f5c1204",
"is_public": false,
"deleted_at": null,
"id": "5c4c2339-55bd-4e9b-86cb-23694e3b9b17",
"size": 25165824
},
"instance_type": {
"memory_mb": 512,
"root_gb": 0,
"deleted_at": null,
"name": "m1.tiny",
"deleted": false,
"created_at": null,
"ephemeral_gb": 0,
"updated_at": null,
"disabled": false,
"vcpus": 1,
"extra_specs": {},
"swap": 0,
"rxtx_factor": 1.0,
"is_public": true,
"flavorid": "1",
"vcpu_weight": null,
"id": 2
},
"instance_properties": {
"vm_state": "building",
"availability_zone": null,
"ramdisk_id": "cc111638-8590-4b5b-8759-f551017ea269",
"instance_type_id": 2,
"user_data": null,
"vm_mode": null,
"reservation_id": "r-sviqmkvr",
"user_id": "fa8ecb2a7110435daa10a5e9e459c7ca",
"display_description": "test02",
"key_data": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDDPrhT0VICqukep0Zl3lz+ZvzZOKVwBEa9IFk2rUcDnjse9zGPy9bZHorEoGYwiywOTTC+Q422rIhAJQvev7OKF4qViyndbLPrlZudeA7oFBc2I0rqUmSwrmQv1Pz4h8jrMdgelgWS1QDPgyFp3O72sS9wP0yQMZIneSdLIV2SxrxVxsISYL5GhbF/A7G9ejSRmLoZgQoDmDW+CtIHFX8EsDDC9K94Dz9F3UCMZwCGGRO4S2o+wValsAuE0xLUF8U6VJ86NrILEJYvNVXPeKyQl9Ktuow0LWqjxtnLv78R/5ayKff+bX/7cekNzG8yeTog7it4kdKaitIb+G5j+h7T nova@ubuntu\n",
"power_state": 0,
"progress": 0,
"project_id": "2ffae825c88b448bad4ef4d14f5c1204",
"config_drive": "",
"ephemeral_gb": 0,
"access_ip_v6": null,
"access_ip_v4": null,
"kernel_id": "f14c0936-e591-4291-901f-239bc41fd3d6",
"key_name": "mykey",
"display_name": "test02",
"config_drive_id": "",
"architecture": null,
"root_gb": 0,
"locked": false,
"launch_time": "2012-12-26T14:42:55Z",
"memory_mb": 512,
"vcpus": 1,
"image_ref": "5c4c2339-55bd-4e9b-86cb-23694e3b9b17",
"root_device_name": null,
"auto_disk_config": null,
"os_type": null,
"metadata": {}
},
"security_group": [
"default"
],
"instance_uuids": [
"55c4f897-11a7-457b-9b70-c8ef28549711"
]
}
admin_password = "5godsYKky8AR"
injected_files = []
requested_networks = [
[
"0802c791-d4aa-473b-94a8-46d2b4aff91b",
"192.168.100.5"
]
]
filter_properties = {
"scheduler_hints": {}
}
nova.sheduler.filter_scheduler.py >> FilterScheduler >> schedule_run_instance()
nova.compute.manager.py >> ComputeManager >> _run_instance()
request_spec = {
"block_device_mapping": [],
"image": {
"status": "active",
"name": "tty-linux",
"deleted": false,
"container_format": "ami",
"created_at": "2012-12-16T10:37:48.000000",
"disk_format": "ami",
"updated_at": "2012-12-16T10:37:49.000000",
"properties": {
"kernel_id": "619a49c6-e653-4ca2-93f0-2e0e8cb50e78",
"ramdisk_id": "619a49c6-e653-4ca2-93f0-2e0e8cb50e78"
},
"min_disk": 0,
"min_ram": 0,
"checksum": "10047a119149e08fb206eea89832eee0",
"owner": "0c74b5d96202433196af2faa9bff4bde",
"is_public": false,
"deleted_at": null,
"id": "011a6a61-70fa-470b-a9cc-fbc7753833fb",
"size": 25165824
},
"instance_type": {
"memory_mb": 512,
"root_gb": 0,
"deleted_at": null,
"name": "m1.tiny",
"deleted": false,
"created_at": null,
"ephemeral_gb": 0,
"updated_at": null,
"disabled": false,
"vcpus": 1,
"extra_specs": {},
"swap": 0,
"rxtx_factor": 1.0,
"is_public": true,
"flavorid": "1",
"vcpu_weight": null,
"id": 2
},
"instance_properties": {
"vm_state": "building",
"availability_zone": null,
"launch_time": "2012-12-24T16:45:50Z",
"ramdisk_id": "619a49c6-e653-4ca2-93f0-2e0e8cb50e78",
"instance_type_id": 2,
"user_data": null,
"vm_mode": null,
"reservation_id": "r-gzio9556",
"user_id": "034120010ad64ecfb1eeb2ac5f16854d",
"display_description": "test01",
"key_data": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCiyiud+EmmdRZ50aPPbC7Ys3Td19qp6q3Xnl+W8aFHJ21IbdnCNXZo3pXpeTJy8rvFTitYxpvD5WzGlmPdXoEryJibA6hbPg6hPLINul+SwtuXlqv6pucy+eMVuWhi9MfOKv/uuJpCFIwZuEHGHg3xeW6uVyWSURW9FGH/E6tKdGrB9T2afkPaROOBnK2BRy3Bj55ExZq8qjfsYKDibwoDPddW9rR5zRn7N3pY6rhnULjyWJAd7Ll3UltKMkl3V2BZV0cyvd3c+TMtVtaa8hE9ComrxKOucd84d2+dOyUaV8hr3N3sfe/oXnvlK23Uo9TKwmYfXvTykOtAtaYRss/z nova@folsom\n",
"power_state": 0,
"progress": 0,
"project_id": "0c74b5d96202433196af2faa9bff4bde",
"config_drive": "",
"ephemeral_gb": 0,
"access_ip_v6": null,
"access_ip_v4": null,
"kernel_id": "619a49c6-e653-4ca2-93f0-2e0e8cb50e78",
"key_name": "mykey",
"display_name": "test01",
"config_drive_id": "",
"architecture": null,
"root_gb": 0,
"locked": false,
"launch_index": 0,
"memory_mb": 512,
"vcpus": 1,
"image_ref": "011a6a61-70fa-470b-a9cc-fbc7753833fb",
"root_device_name": null,
"auto_disk_config": null,
"os_type": null,
"metadata": {}
},
"security_group": [
"default"
],
"instance_uuids": [
"1be889ba-fe3b-4eb6-8730-157db1582f88"
]
}
filter_properties = {
"config_options": {},
"limits": {
"memory_mb": 3000.0
},
"request_spec": {
"block_device_mapping": [],
"image": {
"status": "active",
"name": "tty-linux",
"deleted": false,
"container_format": "ami",
"created_at": "2012-12-16T10:37:48.000000",
"disk_format": "ami",
"updated_at": "2012-12-16T10:37:49.000000",
"properties": {
"kernel_id": "619a49c6-e653-4ca2-93f0-2e0e8cb50e78",
"ramdisk_id": "619a49c6-e653-4ca2-93f0-2e0e8cb50e78"
},
"min_disk": 0,
"min_ram": 0,
"checksum": "10047a119149e08fb206eea89832eee0",
"owner": "0c74b5d96202433196af2faa9bff4bde",
"is_public": false,
"deleted_at": null,
"id": "011a6a61-70fa-470b-a9cc-fbc7753833fb",
"size": 25165824
},
"instance_type": {
"memory_mb": 512,
"root_gb": 0,
"deleted_at": null,
"name": "m1.tiny",
"deleted": false,
"created_at": null,
"ephemeral_gb": 0,
"updated_at": null,
"disabled": false,
"vcpus": 1,
"extra_specs": {},
"swap": 0,
"rxtx_factor": 1.0,
"is_public": true,
"flavorid": "1",
"vcpu_weight": null,
"id": 2
},
"instance_properties": {
"vm_state": "building",
"availability_zone": null,
"launch_time": "2012-12-24T16:45:50Z",
"ramdisk_id": "619a49c6-e653-4ca2-93f0-2e0e8cb50e78",
"instance_type_id": 2,
"user_data": null,
"vm_mode": null,
"reservation_id": "r-gzio9556",
"user_id": "034120010ad64ecfb1eeb2ac5f16854d",
"display_description": "test01",
"key_data": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCiyiud+EmmdRZ50aPPbC7Ys3Td19qp6q3Xnl+W8aFHJ21IbdnCNXZo3pXpeTJy8rvFTitYxpvD5WzGlmPdXoEryJibA6hbPg6hPLINul+SwtuXlqv6pucy+eMVuWhi9MfOKv/uuJpCFIwZuEHGHg3xeW6uVyWSURW9FGH/E6tKdGrB9T2afkPaROOBnK2BRy3Bj55ExZq8qjfsYKDibwoDPddW9rR5zRn7N3pY6rhnULjyWJAd7Ll3UltKMkl3V2BZV0cyvd3c+TMtVtaa8hE9ComrxKOucd84d2+dOyUaV8hr3N3sfe/oXnvlK23Uo9TKwmYfXvTykOtAtaYRss/z nova@folsom\n",
"power_state": 0,
"progress": 0,
"project_id": "0c74b5d96202433196af2faa9bff4bde",
"config_drive": "",
"ephemeral_gb": 0,
"access_ip_v6": null,
"access_ip_v4": null,
"kernel_id": "619a49c6-e653-4ca2-93f0-2e0e8cb50e78",
"key_name": "mykey",
"display_name": "test01",
"config_drive_id": "",
"architecture": null,
"root_gb": 0,
"locked": false,
"launch_index": 0,
"memory_mb": 512,
"vcpus": 1,
"image_ref": "011a6a61-70fa-470b-a9cc-fbc7753833fb",
"root_device_name": null,
"auto_disk_config": null,
"os_type": null,
"metadata": {}
},
"security_group": [
"default"
],
"instance_uuids": [
"1be889ba-fe3b-4eb6-8730-157db1582f88"
]
},
"instance_type": {
"memory_mb": 512,
"root_gb": 0,
"deleted_at": null,
"name": "m1.tiny",
"deleted": false,
"created_at": null,
"ephemeral_gb": 0,
"updated_at": null,
"disabled": false,
"vcpus": 1,
"extra_specs": {},
"swap": 0,
"rxtx_factor": 1.0,
"is_public": true,
"flavorid": "1",
"vcpu_weight": null,
"id": 2
},
"retry": {
"num_attempts": 1,
"hosts": [
"folsom"
]
},
"scheduler_hints": {}
}
requested_networks = [
[
"0802c791-d4aa-473b-94a8-46d2b4aff91b",
"192.168.100.5"
]
]
injected_files = []
admin_password = "6Ty7wZA9wc5w"
is_first_time = true
instance = {
"vm_state": "building",
"availability_zone": null,
"terminated_at": null,
"ephemeral_gb": 0,
"instance_type_id": 2,
"user_data": null,
"vm_mode": null,
"deleted_at": null,
"reservation_id": "r-gzio9556",
"id": 4,
"security_groups": [
{
"project_id": "0c74b5d96202433196af2faa9bff4bde",
"user_id": "034120010ad64ecfb1eeb2ac5f16854d",
"name": "default",
"deleted": false,
"created_at": "2012-12-16T11:47:01.000000",
"updated_at": null,
"rules": [
{
"from_port": 22,
"protocol": "tcp",
"deleted": false,
"created_at": "2012-12-16T11:47:26.000000",
"updated_at": null,
"id": 1,
"to_port": 22,
"parent_group_id": 1,
"cidr": "0.0.0.0/0",
"deleted_at": null,
"group_id": null
},
{
"from_port": -1,
"protocol": "icmp",
"deleted": false,
"created_at": "2012-12-16T11:47:41.000000",
"updated_at": null,
"id": 2,
"to_port": -1,
"parent_group_id": 1,
"cidr": "0.0.0.0/0",
"deleted_at": null,
"group_id": null
}
],
"deleted_at": null,
"id": 1,
"description": "default"
}
],
"disable_terminate": false,
"root_device_name": null,
"user_id": "034120010ad64ecfb1eeb2ac5f16854d",
"uuid": "1be889ba-fe3b-4eb6-8730-157db1582f88",
"server_name": null,
"default_swap_device": null,
"info_cache": {
"instance_uuid": "1be889ba-fe3b-4eb6-8730-157db1582f88",
"deleted": false,
"created_at": "2012-12-24T16:45:50.000000",
"updated_at": null,
"network_info": "[]",
"deleted_at": null,
"id": 4
},
"hostname": "test01",
"launched_on": null,
"display_description": "test01",
"key_data": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCiyiud+EmmdRZ50aPPbC7Ys3Td19qp6q3Xnl+W8aFHJ21IbdnCNXZo3pXpeTJy8rvFTitYxpvD5WzGlmPdXoEryJibA6hbPg6hPLINul+SwtuXlqv6pucy+eMVuWhi9MfOKv/uuJpCFIwZuEHGHg3xeW6uVyWSURW9FGH/E6tKdGrB9T2afkPaROOBnK2BRy3Bj55ExZq8qjfsYKDibwoDPddW9rR5zRn7N3pY6rhnULjyWJAd7Ll3UltKMkl3V2BZV0cyvd3c+TMtVtaa8hE9ComrxKOucd84d2+dOyUaV8hr3N3sfe/oXnvlK23Uo9TKwmYfXvTykOtAtaYRss/z nova@folsom\n",
"deleted": false,
"scheduled_at": "2012-12-24T16:45:50.413093",
"power_state": 0,
"default_ephemeral_device": null,
"progress": 0,
"project_id": "0c74b5d96202433196af2faa9bff4bde",
"launched_at": null,
"config_drive": "",
"ramdisk_id": "619a49c6-e653-4ca2-93f0-2e0e8cb50e78",
"access_ip_v6": null,
"access_ip_v4": null,
"kernel_id": "619a49c6-e653-4ca2-93f0-2e0e8cb50e78",
"key_name": "mykey",
"updated_at": "2012-12-24T16:45:50.441013",
"host": null,
"display_name": "test01",
"task_state": "scheduling",
"shutdown_terminate": false,
"root_gb": 0,
"locked": false,
"name": "instance-00000004",
"created_at": "2012-12-24T16:45:50.000000",
"launch_index": 0,
"memory_mb": 512,
"instance_type": {
"memory_mb": 512,
"root_gb": 0,
"name": "m1.tiny",
"deleted": false,
"created_at": null,
"ephemeral_gb": 0,
"updated_at": null,
"disabled": false,
"vcpus": 1,
"flavorid": "1",
"swap": 0,
"rxtx_factor": 1.0,
"is_public": true,
"deleted_at": null,
"vcpu_weight": null,
"id": 2
},
"vcpus": 1,
"image_ref": "011a6a61-70fa-470b-a9cc-fbc7753833fb",
"architecture": null,
"auto_disk_config": null,
"os_type": null,
"metadata": []
}
image_meta = {
"status": "active",
"name": "tty-linux",
"deleted": false,
"container_format": "ami",
"created_at": "2012-12-16T10:37:48.000000",
"disk_format": "ami",
"updated_at": "2012-12-16T10:37:49.000000",
"properties": {
"kernel_id": "619a49c6-e653-4ca2-93f0-2e0e8cb50e78",
"ramdisk_id": "619a49c6-e653-4ca2-93f0-2e0e8cb50e78"
},
"min_disk": 0,
"min_ram": 0,
"checksum": "10047a119149e08fb206eea89832eee0",
"owner": "0c74b5d96202433196af2faa9bff4bde",
"is_public": false,
"deleted_at": null,
"id": "011a6a61-70fa-470b-a9cc-fbc7753833fb",
"size": 25165824
}
network_info = [
{
"network": {
"bridge": "br100",
"subnets": [
{
"ips": [
{
"meta": {},
"version": 4,
"type": "fixed",
"floating_ips": [],
"address": "192.168.100.2"
}
],
"version": 4,
"meta": {
"dhcp_server": "192.168.100.1"
},
"dns": [
{
"meta": {},
"version": 4,
"type": "dns",
"address": "8.8.8.8"
}
],
"routes": [],
"cidr": "192.168.100.0/24",
"gateway": {
"meta": {},
"version": 4,
"type": "gateway",
"address": "192.168.100.1"
}
},
{
"ips": [],
"version": null,
"meta": {
"dhcp_server": null
},
"dns": [],
"routes": [],
"cidr": null,
"gateway": {
"meta": {},
"version": null,
"type": "gateway",
"address": null
}
}
],
"meta": {
"tenant_id": null,
"should_create_bridge": true,
"bridge_interface": "br100"
},
"id": "da8b8d70-6522-495a-b9f7-9bfadb931a8f",
"label": "private"
},
"meta": {},
"id": "fe9cd80f-c807-4869-9933-cafce241ac0e",
"address": "fa:16:3e:31:f5:00"
}
]
block_device_info = {
"block_device_mapping": [],
"root_device_name": null,
"ephemerals": [],
"swap": null
}
injected_files = []
nova.compute.manager.py >> ComputeManager >> _allocate_network()
vm_states = BUILDING
task_states = NETWORKING
expected_task_states = None
nova.network.api.py >> API >> allocate_for_instance()
nova.network.manager.py >> NetworkManager >> allocate_for_instance()
nova.network.manager.py >> NetworkManager >> _allocate_mac_address()
nova.network.manager.py >> RPCAllocateFixedIP >> _allocate_fixed_ips()
nova.network.manager.py >> NetworkManager >> get_instance_nw_info()
nova.compute.manager.py >> ComputeManager >> _prep_block_device()
vm_states = BUILDING
task_states = BLOCK_DEVICE_MAPPING
nova.compute.manager.py >> ComputeManager >> _spawn()
[ VM 생성 시작할 때 ]
vm_states = BUILDING
task_states = SPAWNING
expected_task_states = BLOCK_DEVICE_MAPPING
[ 생성 종료된 후 ]
power_state = current_power_state
vm_state = ACTIVE
task_state = None
expected_task_states = SPAWNING
nova.virt.libvirt.driver.py >> LibvirtDriver >> spawn()