Refactor nova service creation in the VIM
Updates the VIM to avoid creating the nova-compute service, which required an extension to the nova API. Instead: - Nova is configured to automatically create new services and set them to disabled. - When a host configured with the nova-compute service is unlocked, the VIM will wait for the nova-compute service to be created and then enable it. These changes only apply to the kubernetes configuration. This commit also adds some robustness to the VIM's keystone token handling code to fail earlier when a token cannot be retrieved. Change-Id: If8ce4eea87a51451495517077ca2ea6fbc6b689d Story: 2004583 Task: 28387 Depends-On: Idb27a927de2ac91ebbb1df343a349bb14ec2f0d5 Signed-off-by: Bart Wensley <barton.wensley@windriver.com>
This commit is contained in:
parent
cab52fb0fa
commit
ce5786af07
|
@ -127,7 +127,8 @@ class NFVIBlockStorageAPI(nfvi.api.v1.NFVIBlockStorageAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
return
|
||||
|
||||
self._token = future.result.data
|
||||
|
@ -200,7 +201,8 @@ class NFVIBlockStorageAPI(nfvi.api.v1.NFVIBlockStorageAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
return
|
||||
|
||||
self._token = future.result.data
|
||||
|
@ -289,7 +291,8 @@ class NFVIBlockStorageAPI(nfvi.api.v1.NFVIBlockStorageAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
return
|
||||
|
||||
self._token = future.result.data
|
||||
|
@ -335,7 +338,8 @@ class NFVIBlockStorageAPI(nfvi.api.v1.NFVIBlockStorageAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
return
|
||||
|
||||
self._token = future.result.data
|
||||
|
@ -422,7 +426,8 @@ class NFVIBlockStorageAPI(nfvi.api.v1.NFVIBlockStorageAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
return
|
||||
|
||||
self._token = future.result.data
|
||||
|
@ -509,7 +514,8 @@ class NFVIBlockStorageAPI(nfvi.api.v1.NFVIBlockStorageAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
return
|
||||
|
||||
self._token = future.result.data
|
||||
|
|
|
@ -416,7 +416,8 @@ class NFVIComputeAPI(nfvi.api.v1.NFVIComputeAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
DLOG.error("OpenStack get-token did not complete, "
|
||||
"host_uuid=%s." % host_uuid)
|
||||
return
|
||||
|
@ -472,7 +473,8 @@ class NFVIComputeAPI(nfvi.api.v1.NFVIComputeAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
DLOG.error("OpenStack get-token did not complete, "
|
||||
"host_uuid=%s." % host_uuid)
|
||||
return
|
||||
|
@ -537,7 +539,8 @@ class NFVIComputeAPI(nfvi.api.v1.NFVIComputeAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
DLOG.error("OpenStack get-token did not complete, "
|
||||
"host_uuid=%s, host_name=%s." % (host_uuid,
|
||||
host_name))
|
||||
|
@ -633,7 +636,8 @@ class NFVIComputeAPI(nfvi.api.v1.NFVIComputeAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
DLOG.error("OpenStack get-token did not complete, "
|
||||
"host_uuid=%s, host_name=%s." % (host_uuid,
|
||||
host_name))
|
||||
|
@ -696,7 +700,8 @@ class NFVIComputeAPI(nfvi.api.v1.NFVIComputeAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
DLOG.error("OpenStack get-token did not complete, "
|
||||
"host_uuid=%s, host_name=%s." % (host_uuid,
|
||||
host_name))
|
||||
|
@ -769,7 +774,8 @@ class NFVIComputeAPI(nfvi.api.v1.NFVIComputeAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
DLOG.error("OpenStack get-token did not complete, "
|
||||
"host_uuid=%s, host_name=%s." % (host_uuid,
|
||||
host_name))
|
||||
|
@ -848,7 +854,8 @@ class NFVIComputeAPI(nfvi.api.v1.NFVIComputeAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
DLOG.error("OpenStack get-token did not complete, "
|
||||
"host_uuid=%s, host_name=%s." % (host_uuid,
|
||||
host_name))
|
||||
|
@ -985,7 +992,8 @@ class NFVIComputeAPI(nfvi.api.v1.NFVIComputeAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
return
|
||||
|
||||
self._token = future.result.data
|
||||
|
@ -1044,7 +1052,8 @@ class NFVIComputeAPI(nfvi.api.v1.NFVIComputeAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
return
|
||||
|
||||
self._token = future.result.data
|
||||
|
@ -1105,7 +1114,8 @@ class NFVIComputeAPI(nfvi.api.v1.NFVIComputeAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
return
|
||||
|
||||
self._token = future.result.data
|
||||
|
@ -1187,7 +1197,8 @@ class NFVIComputeAPI(nfvi.api.v1.NFVIComputeAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
return
|
||||
|
||||
self._token = future.result.data
|
||||
|
@ -1260,7 +1271,8 @@ class NFVIComputeAPI(nfvi.api.v1.NFVIComputeAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
return
|
||||
|
||||
self._token = future.result.data
|
||||
|
@ -1374,7 +1386,8 @@ class NFVIComputeAPI(nfvi.api.v1.NFVIComputeAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
return
|
||||
|
||||
self._token = future.result.data
|
||||
|
@ -1421,7 +1434,8 @@ class NFVIComputeAPI(nfvi.api.v1.NFVIComputeAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
return
|
||||
|
||||
self._token = future.result.data
|
||||
|
@ -1526,7 +1540,8 @@ class NFVIComputeAPI(nfvi.api.v1.NFVIComputeAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
return
|
||||
|
||||
self._token = future.result.data
|
||||
|
@ -1614,7 +1629,8 @@ class NFVIComputeAPI(nfvi.api.v1.NFVIComputeAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
return
|
||||
|
||||
self._token = future.result.data
|
||||
|
@ -1685,7 +1701,8 @@ class NFVIComputeAPI(nfvi.api.v1.NFVIComputeAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
return
|
||||
|
||||
self._token = future.result.data
|
||||
|
@ -1792,7 +1809,8 @@ class NFVIComputeAPI(nfvi.api.v1.NFVIComputeAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
return
|
||||
|
||||
self._token = future.result.data
|
||||
|
@ -1867,7 +1885,8 @@ class NFVIComputeAPI(nfvi.api.v1.NFVIComputeAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
return
|
||||
|
||||
self._token = future.result.data
|
||||
|
@ -1941,7 +1960,8 @@ class NFVIComputeAPI(nfvi.api.v1.NFVIComputeAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
return
|
||||
|
||||
self._token = future.result.data
|
||||
|
@ -2017,7 +2037,8 @@ class NFVIComputeAPI(nfvi.api.v1.NFVIComputeAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
return
|
||||
|
||||
self._token = future.result.data
|
||||
|
@ -2093,7 +2114,8 @@ class NFVIComputeAPI(nfvi.api.v1.NFVIComputeAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
return
|
||||
|
||||
self._token = future.result.data
|
||||
|
@ -2167,7 +2189,8 @@ class NFVIComputeAPI(nfvi.api.v1.NFVIComputeAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
return
|
||||
|
||||
self._token = future.result.data
|
||||
|
@ -2241,7 +2264,8 @@ class NFVIComputeAPI(nfvi.api.v1.NFVIComputeAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
return
|
||||
|
||||
self._token = future.result.data
|
||||
|
@ -2315,7 +2339,8 @@ class NFVIComputeAPI(nfvi.api.v1.NFVIComputeAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
return
|
||||
|
||||
self._token = future.result.data
|
||||
|
@ -2389,7 +2414,8 @@ class NFVIComputeAPI(nfvi.api.v1.NFVIComputeAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
return
|
||||
|
||||
self._token = future.result.data
|
||||
|
@ -2468,7 +2494,8 @@ class NFVIComputeAPI(nfvi.api.v1.NFVIComputeAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
return
|
||||
|
||||
self._token = future.result.data
|
||||
|
@ -2538,7 +2565,8 @@ class NFVIComputeAPI(nfvi.api.v1.NFVIComputeAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
return
|
||||
|
||||
self._token = future.result.data
|
||||
|
@ -2590,7 +2618,8 @@ class NFVIComputeAPI(nfvi.api.v1.NFVIComputeAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
return
|
||||
|
||||
self._token = future.result.data
|
||||
|
@ -2663,7 +2692,8 @@ class NFVIComputeAPI(nfvi.api.v1.NFVIComputeAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
return
|
||||
|
||||
self._token = future.result.data
|
||||
|
@ -2736,7 +2766,8 @@ class NFVIComputeAPI(nfvi.api.v1.NFVIComputeAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
return
|
||||
|
||||
self._token = future.result.data
|
||||
|
@ -2809,7 +2840,8 @@ class NFVIComputeAPI(nfvi.api.v1.NFVIComputeAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
return
|
||||
|
||||
self._token = future.result.data
|
||||
|
@ -2882,7 +2914,8 @@ class NFVIComputeAPI(nfvi.api.v1.NFVIComputeAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
return
|
||||
|
||||
self._token = future.result.data
|
||||
|
@ -2954,7 +2987,8 @@ class NFVIComputeAPI(nfvi.api.v1.NFVIComputeAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
return
|
||||
|
||||
self._token = future.result.data
|
||||
|
@ -3021,7 +3055,8 @@ class NFVIComputeAPI(nfvi.api.v1.NFVIComputeAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
return
|
||||
|
||||
self._token = future.result.data
|
||||
|
@ -3075,7 +3110,8 @@ class NFVIComputeAPI(nfvi.api.v1.NFVIComputeAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
return
|
||||
|
||||
self._token = future.result.data
|
||||
|
|
|
@ -236,7 +236,8 @@ class NFVIGuestAPI(nfvi.api.v1.NFVIGuestAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
DLOG.error("OpenStack get-token did not complete, "
|
||||
"instance_uuid=%s." % instance_uuid)
|
||||
return
|
||||
|
@ -287,7 +288,8 @@ class NFVIGuestAPI(nfvi.api.v1.NFVIGuestAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
DLOG.error("OpenStack get-token did not complete, "
|
||||
"instance_uuid=%s." % instance_uuid)
|
||||
return
|
||||
|
@ -361,7 +363,8 @@ class NFVIGuestAPI(nfvi.api.v1.NFVIGuestAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
DLOG.error("OpenStack get-token did not complete, "
|
||||
"instance_uuid=%s." % instance_uuid)
|
||||
return
|
||||
|
@ -416,7 +419,8 @@ class NFVIGuestAPI(nfvi.api.v1.NFVIGuestAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
DLOG.error("OpenStack get-token did not complete, "
|
||||
"instance_uuid=%s." % instance_uuid)
|
||||
return
|
||||
|
@ -492,7 +496,8 @@ class NFVIGuestAPI(nfvi.api.v1.NFVIGuestAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
DLOG.error("OpenStack get-token did not complete, "
|
||||
"instance_uuid=%s." % instance_uuid)
|
||||
return
|
||||
|
@ -552,7 +557,8 @@ class NFVIGuestAPI(nfvi.api.v1.NFVIGuestAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
DLOG.error("OpenStack get-token did not complete, "
|
||||
"instance_uuid=%s." % instance_uuid)
|
||||
return
|
||||
|
@ -617,7 +623,8 @@ class NFVIGuestAPI(nfvi.api.v1.NFVIGuestAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
DLOG.error("OpenStack get-token did not complete, "
|
||||
"host_uuid=%s, host_name=%s." % (host_uuid,
|
||||
host_name))
|
||||
|
@ -705,7 +712,8 @@ class NFVIGuestAPI(nfvi.api.v1.NFVIGuestAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
DLOG.error("OpenStack get-token did not complete, "
|
||||
"host_uuid=%s, host_name=%s." % (host_uuid,
|
||||
host_name))
|
||||
|
@ -774,7 +782,8 @@ class NFVIGuestAPI(nfvi.api.v1.NFVIGuestAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
DLOG.error("OpenStack get-token did not complete, "
|
||||
"host_uuid=%s, host_name=%s." % (host_uuid,
|
||||
host_name))
|
||||
|
@ -839,7 +848,8 @@ class NFVIGuestAPI(nfvi.api.v1.NFVIGuestAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
DLOG.error("OpenStack get-token did not complete, "
|
||||
"host_uuid=%s, host_name=%s." % (host_uuid,
|
||||
host_name))
|
||||
|
@ -909,7 +919,8 @@ class NFVIGuestAPI(nfvi.api.v1.NFVIGuestAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
DLOG.error("OpenStack get-token did not complete, "
|
||||
"host_uuid=%s, host_name=%s." % (host_uuid,
|
||||
host_name))
|
||||
|
|
|
@ -64,7 +64,8 @@ class NFVIIdentityAPI(nfvi.api.v1.NFVIIdentityAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
return
|
||||
|
||||
self._token = future.result.data
|
||||
|
|
|
@ -103,7 +103,8 @@ class NFVIImageAPI(nfvi.api.v1.NFVIImageAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
return
|
||||
|
||||
self._token = future.result.data
|
||||
|
@ -211,7 +212,8 @@ class NFVIImageAPI(nfvi.api.v1.NFVIImageAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
return
|
||||
|
||||
self._token = future.result.data
|
||||
|
@ -340,7 +342,8 @@ class NFVIImageAPI(nfvi.api.v1.NFVIImageAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
return
|
||||
|
||||
self._token = future.result.data
|
||||
|
@ -390,7 +393,8 @@ class NFVIImageAPI(nfvi.api.v1.NFVIImageAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
return
|
||||
|
||||
self._token = future.result.data
|
||||
|
@ -503,7 +507,8 @@ class NFVIImageAPI(nfvi.api.v1.NFVIImageAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
return
|
||||
|
||||
self._token = future.result.data
|
||||
|
|
|
@ -189,7 +189,8 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
|
|||
future.work(openstack.get_token, self._platform_directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
DLOG.error("OpenStack get-token did not complete.")
|
||||
return
|
||||
|
||||
|
@ -254,7 +255,8 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
|
|||
future.work(openstack.get_token, self._platform_directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
DLOG.error("OpenStack get-token did not complete.")
|
||||
return
|
||||
|
||||
|
@ -311,7 +313,8 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
|
|||
future.work(openstack.get_token, self._platform_directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
return
|
||||
|
||||
self._platform_token = future.result.data
|
||||
|
@ -455,7 +458,8 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
|
|||
future.work(openstack.get_token, self._platform_directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
DLOG.error("OpenStack get-token did not complete, "
|
||||
"host_uuid=%s." % host_uuid)
|
||||
return
|
||||
|
@ -567,7 +571,8 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
|
|||
future.work(openstack.get_token, self._platform_directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
DLOG.error("OpenStack get-token did not complete.")
|
||||
return
|
||||
|
||||
|
@ -631,7 +636,8 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
|
|||
future.work(openstack.get_token, self._platform_directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
DLOG.error("OpenStack get-token did not complete.")
|
||||
return
|
||||
|
||||
|
@ -687,7 +693,8 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
|
|||
future.work(openstack.get_token, self._platform_directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
DLOG.error("OpenStack get-token did not complete.")
|
||||
return
|
||||
|
||||
|
@ -743,7 +750,8 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
|
|||
future.work(openstack.get_token, self._platform_directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
DLOG.error("OpenStack get-token did not complete.")
|
||||
return
|
||||
|
||||
|
@ -934,7 +942,8 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
|
|||
future.work(openstack.get_token, self._platform_directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
DLOG.error("OpenStack get-token did not complete, "
|
||||
"host_uuid=%s." % host_uuid)
|
||||
return
|
||||
|
@ -1049,7 +1058,8 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
|
|||
future.work(openstack.get_token, self._platform_directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
DLOG.error("OpenStack get-token did not complete, "
|
||||
"host_uuid=%s." % host_uuid)
|
||||
return
|
||||
|
@ -1164,7 +1174,8 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
|
|||
future.work(openstack.get_token, self._platform_directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
DLOG.error("OpenStack get-token did not complete, "
|
||||
"host_uuid=%s." % host_uuid)
|
||||
return
|
||||
|
@ -1278,7 +1289,8 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
|
|||
future.work(openstack.get_token, self._platform_directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
DLOG.error("OpenStack get-token did not complete, "
|
||||
"host_uuid=%s." % host_uuid)
|
||||
return
|
||||
|
@ -1391,7 +1403,8 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
|
|||
future.work(openstack.get_token, self._platform_directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
DLOG.error("OpenStack get-token did not complete, "
|
||||
"host_uuid=%s." % host_uuid)
|
||||
return
|
||||
|
@ -1443,7 +1456,8 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
|
|||
future.work(openstack.get_token, self._platform_directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
DLOG.error("OpenStack get-token did not complete, "
|
||||
"host_uuid=%s." % host_uuid)
|
||||
return
|
||||
|
@ -1561,7 +1575,8 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
|
|||
future.work(openstack.get_token, self._platform_directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
DLOG.error("OpenStack get-token did not complete, "
|
||||
"host_uuid=%s, host_name=%s." % (host_uuid,
|
||||
host_name))
|
||||
|
@ -1618,7 +1633,8 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
|
|||
future.work(openstack.get_token, self._platform_directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
DLOG.error("OpenStack get-token did not complete, "
|
||||
"host_uuid=%s." % host_uuid)
|
||||
return
|
||||
|
@ -1670,7 +1686,8 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
|
|||
future.work(openstack.get_token, self._platform_directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
DLOG.error("OpenStack get-token did not complete, "
|
||||
"host_uuid=%s." % host_uuid)
|
||||
return
|
||||
|
@ -1722,7 +1739,8 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
|
|||
future.work(openstack.get_token, self._platform_directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
DLOG.error("OpenStack get-token did not complete, "
|
||||
"host_uuid=%s." % host_uuid)
|
||||
return
|
||||
|
@ -1774,7 +1792,8 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
|
|||
future.work(openstack.get_token, self._platform_directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
DLOG.error("OpenStack get-token did not complete, "
|
||||
"host_uuid=%s." % host_uuid)
|
||||
return
|
||||
|
@ -1826,7 +1845,8 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
|
|||
future.work(openstack.get_token, self._platform_directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
DLOG.error("OpenStack get-token did not complete, "
|
||||
"host_uuid=%s." % host_uuid)
|
||||
return
|
||||
|
@ -1876,7 +1896,8 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
|
|||
future.work(openstack.get_token, self._platform_directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
DLOG.error("OpenStack get-token did not complete.")
|
||||
return
|
||||
|
||||
|
@ -1935,7 +1956,8 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
|
|||
future.work(openstack.get_token, self._platform_directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
DLOG.error("OpenStack get-token did not complete.")
|
||||
return
|
||||
|
||||
|
@ -1984,7 +2006,8 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
|
|||
future.work(openstack.get_token, self._platform_directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
DLOG.error("OpenStack get-token did not complete.")
|
||||
return
|
||||
|
||||
|
|
|
@ -115,7 +115,8 @@ class NFVINetworkAPI(nfvi.api.v1.NFVINetworkAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
return
|
||||
|
||||
self._token = future.result.data
|
||||
|
@ -198,7 +199,8 @@ class NFVINetworkAPI(nfvi.api.v1.NFVINetworkAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
return
|
||||
|
||||
self._token = future.result.data
|
||||
|
@ -263,7 +265,8 @@ class NFVINetworkAPI(nfvi.api.v1.NFVINetworkAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
return
|
||||
|
||||
self._token = future.result.data
|
||||
|
@ -327,7 +330,8 @@ class NFVINetworkAPI(nfvi.api.v1.NFVINetworkAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
return
|
||||
|
||||
self._token = future.result.data
|
||||
|
@ -376,7 +380,8 @@ class NFVINetworkAPI(nfvi.api.v1.NFVINetworkAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
return
|
||||
|
||||
self._token = future.result.data
|
||||
|
@ -451,7 +456,8 @@ class NFVINetworkAPI(nfvi.api.v1.NFVINetworkAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
return
|
||||
|
||||
self._token = future.result.data
|
||||
|
@ -535,7 +541,8 @@ class NFVINetworkAPI(nfvi.api.v1.NFVINetworkAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
return
|
||||
|
||||
self._token = future.result.data
|
||||
|
@ -601,7 +608,8 @@ class NFVINetworkAPI(nfvi.api.v1.NFVINetworkAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
return
|
||||
|
||||
self._token = future.result.data
|
||||
|
@ -663,7 +671,8 @@ class NFVINetworkAPI(nfvi.api.v1.NFVINetworkAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
return
|
||||
|
||||
self._token = future.result.data
|
||||
|
@ -712,7 +721,8 @@ class NFVINetworkAPI(nfvi.api.v1.NFVINetworkAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
return
|
||||
|
||||
self._token = future.result.data
|
||||
|
@ -781,7 +791,8 @@ class NFVINetworkAPI(nfvi.api.v1.NFVINetworkAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
DLOG.error("OpenStack get-token did not complete, "
|
||||
"host_uuid=%s, host_name=%s." % (host_uuid,
|
||||
host_name))
|
||||
|
@ -908,7 +919,8 @@ class NFVINetworkAPI(nfvi.api.v1.NFVINetworkAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
DLOG.error("OpenStack get-token did not complete, "
|
||||
"host_uuid=%s, host_name=%s." % (host_uuid,
|
||||
host_name))
|
||||
|
@ -992,7 +1004,8 @@ class NFVINetworkAPI(nfvi.api.v1.NFVINetworkAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
DLOG.error("OpenStack get-token did not complete, "
|
||||
"host_uuid=%s, host_name=%s." % (host_uuid,
|
||||
host_name))
|
||||
|
@ -1078,7 +1091,8 @@ class NFVINetworkAPI(nfvi.api.v1.NFVINetworkAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
DLOG.error("OpenStack get-token did not complete, "
|
||||
"host_uuid=%s, host_name=%s." % (host_uuid,
|
||||
host_name))
|
||||
|
@ -1155,7 +1169,8 @@ class NFVINetworkAPI(nfvi.api.v1.NFVINetworkAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
DLOG.error("OpenStack get-token did not complete, "
|
||||
"host_uuid=%s." % host_uuid)
|
||||
return
|
||||
|
|
|
@ -62,7 +62,8 @@ class NFVISwMgmtAPI(nfvi.api.v1.NFVISwMgmtAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
return
|
||||
|
||||
self._token = future.result.data
|
||||
|
@ -120,7 +121,8 @@ class NFVISwMgmtAPI(nfvi.api.v1.NFVISwMgmtAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
return
|
||||
|
||||
self._token = future.result.data
|
||||
|
@ -179,7 +181,8 @@ class NFVISwMgmtAPI(nfvi.api.v1.NFVISwMgmtAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
return
|
||||
|
||||
self._token = future.result.data
|
||||
|
@ -228,7 +231,8 @@ class NFVISwMgmtAPI(nfvi.api.v1.NFVISwMgmtAPI):
|
|||
future.work(openstack.get_token, self._directory)
|
||||
future.result = (yield)
|
||||
|
||||
if not future.result.is_complete():
|
||||
if not future.result.is_complete() or \
|
||||
future.result.data is None:
|
||||
return
|
||||
|
||||
self._token = future.result.data
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
from nfv_common import debug
|
||||
from nfv_common import timers
|
||||
|
||||
from nfv_common.helpers import coroutine
|
||||
|
||||
from nfv_vim import nfvi
|
||||
|
@ -462,6 +464,21 @@ def _nfvi_guest_services_action_notify_callback(nfvi_instance_uuid,
|
|||
return True
|
||||
|
||||
|
||||
@timers.interval_timer('nfvi_periodic_timer_event', initial_delay_secs=10,
|
||||
interval_secs=10)
|
||||
def _nfvi_periodic_timer_event():
|
||||
"""
|
||||
Periodic timer for hosts
|
||||
"""
|
||||
while True:
|
||||
timer_id = (yield)
|
||||
DLOG.verbose("NFVI periodic timer called, timer_id=%s." % timer_id)
|
||||
|
||||
host_table = tables.tables_get_host_table()
|
||||
for host in host_table.values():
|
||||
host.periodic_timer()
|
||||
|
||||
|
||||
def vim_nfvi_events_initialize():
|
||||
"""
|
||||
Initialize listening for nfvi events
|
||||
|
@ -516,6 +533,8 @@ def vim_nfvi_events_initialize():
|
|||
nfvi.nfvi_register_guest_services_action_notify_callback(
|
||||
_nfvi_guest_services_action_notify_callback)
|
||||
|
||||
timers.timers_register_interval_timers([_nfvi_periodic_timer_event])
|
||||
|
||||
|
||||
def vim_nfvi_events_finalize():
|
||||
"""
|
||||
|
|
|
@ -39,6 +39,7 @@ class EventNames(Constants):
|
|||
ENABLE = Constant('enable')
|
||||
DISABLE = Constant('disable')
|
||||
AUDIT = Constant('audit')
|
||||
PERIODIC_TIMER = Constant('periodic-timer')
|
||||
TASK_COMPLETED = Constant('task-completed')
|
||||
TASK_FAILED = Constant('task-failed')
|
||||
TASK_TIMEOUT = Constant('task-timeout')
|
||||
|
|
|
@ -45,43 +45,49 @@ class EnablingState(state_machine.State):
|
|||
"""
|
||||
Handle event while in the enabling state
|
||||
"""
|
||||
if HOST_EVENT.DELETE == event:
|
||||
return HOST_STATE.DELETING
|
||||
handled = False
|
||||
|
||||
elif HOST_EVENT.ENABLE == event:
|
||||
if not host.task.inprogress():
|
||||
host.task = EnableHostTask(host)
|
||||
host.task.start()
|
||||
if host.task.inprogress():
|
||||
handled = host.task.handle_event(event, event_data)
|
||||
|
||||
elif host.task.is_failed() or host.task.timed_out():
|
||||
host.task.start()
|
||||
if not handled:
|
||||
if HOST_EVENT.DELETE == event:
|
||||
return HOST_STATE.DELETING
|
||||
|
||||
elif HOST_EVENT.LOCK == event or HOST_EVENT.DISABLE == event \
|
||||
or HOST_EVENT.UNLOCK == event:
|
||||
return HOST_STATE.DISABLING
|
||||
elif HOST_EVENT.ENABLE == event:
|
||||
if not host.task.inprogress():
|
||||
host.task = EnableHostTask(host)
|
||||
host.task.start()
|
||||
|
||||
elif HOST_EVENT.TASK_COMPLETED == event:
|
||||
return HOST_STATE.ENABLED
|
||||
elif host.task.is_failed() or host.task.timed_out():
|
||||
host.task.start()
|
||||
|
||||
elif HOST_EVENT.TASK_FAILED == event:
|
||||
DLOG.info("Enable failed for %s." % host.name)
|
||||
elif HOST_EVENT.LOCK == event or HOST_EVENT.DISABLE == event \
|
||||
or HOST_EVENT.UNLOCK == event:
|
||||
return HOST_STATE.DISABLING
|
||||
|
||||
elif HOST_EVENT.TASK_TIMEOUT == event:
|
||||
DLOG.info("Enable timed out for %s." % host.name)
|
||||
elif HOST_EVENT.TASK_COMPLETED == event:
|
||||
return HOST_STATE.ENABLED
|
||||
|
||||
elif HOST_EVENT.AUDIT == event:
|
||||
DLOG.verbose("Audit event for %s." % host.name)
|
||||
elif HOST_EVENT.TASK_FAILED == event:
|
||||
DLOG.info("Enable failed for %s." % host.name)
|
||||
|
||||
if not host.task.inprogress():
|
||||
DLOG.verbose("Attempt re-enable for %s." % host.name)
|
||||
host.task = EnableHostTask(host)
|
||||
host.task.start()
|
||||
elif HOST_EVENT.TASK_TIMEOUT == event:
|
||||
DLOG.info("Enable timed out for %s." % host.name)
|
||||
|
||||
elif host.task.is_failed() or host.task.timed_out():
|
||||
DLOG.verbose("Attempt re-enable for %s." % host.name)
|
||||
host.task.start()
|
||||
elif HOST_EVENT.AUDIT == event:
|
||||
DLOG.verbose("Audit event for %s." % host.name)
|
||||
|
||||
else:
|
||||
DLOG.verbose("Ignoring %s event for %s." % (event, host.name))
|
||||
if not host.task.inprogress():
|
||||
DLOG.verbose("Attempt re-enable for %s." % host.name)
|
||||
host.task = EnableHostTask(host)
|
||||
host.task.start()
|
||||
|
||||
elif host.task.is_failed() or host.task.timed_out():
|
||||
DLOG.verbose("Attempt re-enable for %s." % host.name)
|
||||
host.task.start()
|
||||
|
||||
else:
|
||||
DLOG.verbose("Ignoring %s event for %s." % (event, host.name))
|
||||
|
||||
return self.name
|
||||
|
|
|
@ -685,6 +685,94 @@ class DeleteHostServicesTaskWork(state_machine.StateTaskWork):
|
|||
return state_machine.STATE_TASK_WORK_RESULT.WAIT, empty_reason
|
||||
|
||||
|
||||
class WaitHostServicesCreatedTaskWork(state_machine.StateTaskWork):
|
||||
"""
|
||||
Wait Host Services Created Task Work
|
||||
"""
|
||||
def __init__(self, task, host, service):
|
||||
super(WaitHostServicesCreatedTaskWork, self).__init__(
|
||||
'wait-host-services-created_%s_%s' % (host.name, service), task,
|
||||
timeout_in_secs=120)
|
||||
self._host_reference = weakref.ref(host)
|
||||
self._service = service
|
||||
self._query_inprogress = False
|
||||
|
||||
@property
|
||||
def _host(self):
|
||||
"""
|
||||
Returns the host
|
||||
"""
|
||||
host = self._host_reference()
|
||||
return host
|
||||
|
||||
@coroutine
|
||||
def _callback(self):
|
||||
"""
|
||||
Callback for wait host services created
|
||||
"""
|
||||
response = (yield)
|
||||
self._query_inprogress = False
|
||||
|
||||
if self.task is not None:
|
||||
DLOG.verbose("Wait-Host-Services-Created callback for service: "
|
||||
"%s %s, response=%s." %
|
||||
(self._service, self._host.name, response))
|
||||
|
||||
if response['completed']:
|
||||
# A completed response means the service exists.
|
||||
self.task.task_work_complete(
|
||||
state_machine.STATE_TASK_WORK_RESULT.SUCCESS,
|
||||
empty_reason)
|
||||
else:
|
||||
DLOG.info("Wait-Host-Services-Created callback for %s, "
|
||||
"failed" % self._host.name)
|
||||
|
||||
def run(self):
|
||||
"""
|
||||
Run wait host services created
|
||||
"""
|
||||
from nfv_vim import objects
|
||||
|
||||
DLOG.verbose("Wait-Host-Services-Created for %s for service %s." %
|
||||
(self._host.name, self._service))
|
||||
|
||||
if self._service == objects.HOST_SERVICES.COMPUTE:
|
||||
self._query_inprogress = True
|
||||
nfvi.nfvi_query_compute_host_services(
|
||||
self._host.uuid, self._host.name, self._host.personality,
|
||||
self._callback())
|
||||
else:
|
||||
reason = ("Trying to wait for unknown host service %s" %
|
||||
self._service)
|
||||
DLOG.error(reason)
|
||||
self._host.update_failure_reason(reason)
|
||||
return state_machine.STATE_TASK_WORK_RESULT.FAILED, reason
|
||||
|
||||
return state_machine.STATE_TASK_WORK_RESULT.WAIT, empty_reason
|
||||
|
||||
def handle_event(self, event, event_data=None):
|
||||
"""
|
||||
Handle events while waiting for host services to be created
|
||||
"""
|
||||
from nfv_vim import objects
|
||||
|
||||
handled = False
|
||||
if HOST_EVENT.PERIODIC_TIMER == event:
|
||||
if not self._query_inprogress:
|
||||
DLOG.verbose("Wait-Host-Services-Created for %s for service "
|
||||
"%s. Repeating query." %
|
||||
(self._host.name, self._service))
|
||||
self._query_inprogress = True
|
||||
if self._service == objects.HOST_SERVICES.COMPUTE:
|
||||
nfvi.nfvi_query_compute_host_services(
|
||||
self._host.uuid, self._host.name,
|
||||
self._host.personality,
|
||||
self._callback())
|
||||
handled = True
|
||||
|
||||
return handled
|
||||
|
||||
|
||||
class EnableHostServicesTaskWork(state_machine.StateTaskWork):
|
||||
"""
|
||||
Enable Host Services Task Work
|
||||
|
@ -713,9 +801,9 @@ class EnableHostServicesTaskWork(state_machine.StateTaskWork):
|
|||
|
||||
response = (yield)
|
||||
if self.task is not None:
|
||||
DLOG.verbose("Enable-Host-Services callback for service: %s %s %s, "
|
||||
DLOG.verbose("Enable-Host-Services callback for service: %s %s, "
|
||||
"response=%s." % (self._service, self._host.name,
|
||||
self._service, response))
|
||||
response))
|
||||
if response['completed']:
|
||||
self.task.task_work_complete(
|
||||
state_machine.STATE_TASK_WORK_RESULT.SUCCESS,
|
||||
|
@ -801,9 +889,9 @@ class DisableHostServicesTaskWork(state_machine.StateTaskWork):
|
|||
|
||||
response = (yield)
|
||||
if self.task is not None:
|
||||
DLOG.verbose("Disable-Host-Services callback for service: %s, %s %s, "
|
||||
DLOG.verbose("Disable-Host-Services callback for service: %s, %s, "
|
||||
"response=%s." % (self._service, self._host.name,
|
||||
self._service, response))
|
||||
response))
|
||||
if response['completed']:
|
||||
self.task.task_work_complete(
|
||||
state_machine.STATE_TASK_WORK_RESULT.SUCCESS,
|
||||
|
|
|
@ -27,6 +27,7 @@ from nfv_vim.host_fsm._host_task_work import NotifyHostServicesEnabledTaskWork
|
|||
from nfv_vim.host_fsm._host_task_work import NotifyInstancesHostDisabledTaskWork
|
||||
from nfv_vim.host_fsm._host_task_work import NotifyInstancesHostDisablingTaskWork
|
||||
from nfv_vim.host_fsm._host_task_work import QueryHypervisorTaskWork
|
||||
from nfv_vim.host_fsm._host_task_work import WaitHostServicesCreatedTaskWork
|
||||
|
||||
DLOG = debug.debug_get_logger('nfv_vim.state_machine.host_task')
|
||||
|
||||
|
@ -41,9 +42,11 @@ class AddHostTask(state_machine.StateTask):
|
|||
|
||||
self._host_reference = weakref.ref(host)
|
||||
task_work_list = list()
|
||||
if host.host_service_configured(objects.HOST_SERVICES.COMPUTE):
|
||||
task_work_list.append(CreateHostServicesTaskWork(
|
||||
self, host, objects.HOST_SERVICES.COMPUTE))
|
||||
if not host.kubernetes_configured:
|
||||
# We only create the compute service on non-kubernetes systems.
|
||||
if host.host_service_configured(objects.HOST_SERVICES.COMPUTE):
|
||||
task_work_list.append(CreateHostServicesTaskWork(
|
||||
self, host, objects.HOST_SERVICES.COMPUTE))
|
||||
if host.host_service_configured(objects.HOST_SERVICES.NETWORK):
|
||||
task_work_list.append(CreateHostServicesTaskWork(
|
||||
self, host, objects.HOST_SERVICES.NETWORK))
|
||||
|
@ -142,13 +145,17 @@ class EnableHostTask(state_machine.StateTask):
|
|||
|
||||
self._host_reference = weakref.ref(host)
|
||||
task_work_list = list()
|
||||
if host.host_service_configured(objects.HOST_SERVICES.COMPUTE):
|
||||
task_work_list.append(NotifyHostEnabledTaskWork(
|
||||
self, host, objects.HOST_SERVICES.COMPUTE))
|
||||
if host.host_service_configured(objects.HOST_SERVICES.CONTAINER):
|
||||
task_work_list.append(EnableHostServicesTaskWork(
|
||||
self, host, objects.HOST_SERVICES.CONTAINER))
|
||||
if host.host_service_configured(objects.HOST_SERVICES.COMPUTE):
|
||||
if host.kubernetes_configured:
|
||||
# In kubernetes systems we must wait for the compute service
|
||||
# to be created before enabling it.
|
||||
task_work_list.append(WaitHostServicesCreatedTaskWork(
|
||||
self, host, objects.HOST_SERVICES.COMPUTE))
|
||||
task_work_list.append(NotifyHostEnabledTaskWork(
|
||||
self, host, objects.HOST_SERVICES.COMPUTE))
|
||||
task_work_list.append(EnableHostServicesTaskWork(
|
||||
self, host, objects.HOST_SERVICES.COMPUTE))
|
||||
if host.host_service_configured(objects.HOST_SERVICES.NETWORK):
|
||||
|
|
|
@ -156,6 +156,16 @@ class Host(ObjectData):
|
|||
"""
|
||||
return self._fsm.current_state.name
|
||||
|
||||
@property
|
||||
def kubernetes_configured(self):
|
||||
"""
|
||||
Returns whether kubernetes is configured. This will disappear once
|
||||
we cut over to kubernetes.
|
||||
"""
|
||||
if not os.path.isfile('/etc/kubernetes/admin.conf'):
|
||||
return False
|
||||
return True
|
||||
|
||||
def host_service_configured(self, service):
|
||||
"""
|
||||
Returns whether a host service is configured or not
|
||||
|
@ -211,8 +221,8 @@ class Host(ObjectData):
|
|||
at_least_one_failed = at_least_one_failed or \
|
||||
(service_state == HOST_SERVICE_STATE.FAILED)
|
||||
|
||||
DLOG.verbose("service_state: %s, all_enabled: %s" %
|
||||
(service_state, all_enabled))
|
||||
DLOG.verbose("service %s service_state: %s, all_enabled: %s" %
|
||||
(service, service_state, all_enabled))
|
||||
|
||||
if all_enabled:
|
||||
return HOST_SERVICE_STATE.ENABLED
|
||||
|
@ -731,6 +741,12 @@ class Host(ObjectData):
|
|||
alarm.host_clear_alarm(self._alarms)
|
||||
self._fsm.handle_event(host_fsm.HOST_EVENT.DELETE)
|
||||
|
||||
def periodic_timer(self):
|
||||
"""
|
||||
Periodic Timer
|
||||
"""
|
||||
self._fsm.handle_event(host_fsm.HOST_EVENT.PERIODIC_TIMER)
|
||||
|
||||
def host_services_update_all(self, host_service_state, reason=None):
|
||||
"""
|
||||
Host services update all
|
||||
|
|
Loading…
Reference in New Issue