Add ctxt for all conductor APIs

Change-Id: I7bc27b5716aec85e50a3c7824667c3f762557fa0
This commit is contained in:
Jay Lau (Guangya Liu) 2015-01-02 03:08:16 -05:00 committed by Jay Lau
parent b37036c34d
commit 6acf2e7a0f
2 changed files with 81 additions and 72 deletions

View File

@ -30,81 +30,81 @@ class API(rpc_service.API):
# Bay Model Operations
def baymodel_create(self, bay):
return self._call('baymodel_create', bay=bay)
def baymodel_create(self, ctxt, bay):
return self._call('baymodel_create', ctxt=ctxt, bay=bay)
def baymodel_list(self, context, limit, marker, sort_key, sort_dir):
return objects.BayModel.list(context, limit, marker, sort_key,
sort_dir)
def baymodel_delete(self, uuid):
return self._call('baymodel_delete', uuid=uuid)
def baymodel_delete(self, ctxt, uuid):
return self._call('baymodel_delete', ctxt=ctxt, uuid=uuid)
def baymodel_show(self, uuid):
return self._call('baymodel_show', uuid=uuid)
def baymodel_show(self, ctxt, uuid):
return self._call('baymodel_show', ctxt=ctxt, uuid=uuid)
# Bay Operations
def bay_create(self, bay):
return self._call('bay_create', bay=bay)
def bay_create(self, ctxt, bay):
return self._call('bay_create', ctxt=ctxt, bay=bay)
def bay_list(self, context, limit, marker, sort_key, sort_dir):
return objects.Bay.list(context, limit, marker, sort_key, sort_dir)
def bay_delete(self, uuid):
return self._call('bay_delete', uuid=uuid)
def bay_delete(self, ctxt, uuid):
return self._call('bay_delete', ctxt=ctxt, uuid=uuid)
def bay_show(self, uuid):
return self._call('bay_show', uuid=uuid)
def bay_show(self, ctxt, uuid):
return self._call('bay_show', ctxt=ctxt, uuid=uuid)
# Service Operations
def service_create(self, service):
return self._call('service_create', service=service)
def service_create(self, ctxt, service):
return self._call('service_create', ctxt=ctxt, service=service)
def service_list(self, context, limit, marker, sort_key, sort_dir):
# TODO(pkilambi): return kubectl results once we parse appropriately
# or figure out a clean way to interact with k8s.
return objects.Service.list(context, limit, marker, sort_key, sort_dir)
def service_delete(self, service):
return self._call('service_delete', service)
def service_delete(self, ctxt, service):
return self._call('service_delete', ctxt=ctxt, service=service)
def service_show(self, uuid):
return self._call('service_show', uuid=uuid)
def service_show(self, ctxt, uuid):
return self._call('service_show', ctxt=ctxt, uuid=uuid)
# Pod Operations
def pod_create(self, pod):
return self._call('pod_create', pod=pod)
def pod_create(self, ctxt, pod):
return self._call('pod_create', ctxt=ctxt, pod=pod)
def pod_list(self, context, limit, marker, sort_key, sort_dir):
return objects.Pod.list(context, limit, marker, sort_key, sort_dir)
def pod_delete(self, pod):
return self._call('pod_delete', pod)
def pod_delete(self, ctxt, pod):
return self._call('pod_delete', ctxt=ctxt, pod=pod)
def pod_show(self, uuid):
return self._call('pod_show', uuid=uuid)
def pod_show(self, ctxt, uuid):
return self._call('pod_show', ctxt=ctxt, uuid=uuid)
# ReplicationController Operations
def rc_create(self, rc):
return self._call('rc_create', rc=rc)
def rc_create(self, ctxt, rc):
return self._call('rc_create', ctxt=ctxt, rc=rc)
def rc_list(self, context, limit, marker, sort_key, sort_dir):
return objects.ReplicationController.list(context, limit, marker,
sort_key, sort_dir)
def rc_delete(self, rc):
return self._call('rc_delete', rc)
def rc_delete(self, ctxt, rc):
return self._call('rc_delete', ctxt=ctxt, rc=rc)
def rc_show(self, context, uuid):
return objects.ReplicationController.get_by_uuid(context, uuid)
def rc_show(self, ctxt, uuid):
return objects.ReplicationController.get_by_uuid(ctxt, uuid)
# Container operations
def container_create(self, name, container_uuid, container):
def container_create(self, ctxt, name, container_uuid, container):
return self._call('container_create', name=name,
container_uuid=container_uuid,
container=container)
@ -113,30 +113,39 @@ class API(rpc_service.API):
return objects.Container.list(context, limit, marker, sort_key,
sort_dir)
def container_delete(self, container_uuid):
return self._call('container_delete', container_uuid=container_uuid)
def container_delete(self, ctxt, container_uuid):
return self._call('container_delete', ctxt=ctxt,
container_uuid=container_uuid)
def container_show(self, container_uuid):
return self._call('container_show', container_uuid)
def container_show(self, ctxt, container_uuid):
return self._call('container_show', ctxt=ctxt,
container_uuid=container_uuid)
def container_reboot(self, container_uuid):
return self._call('container_reboot', container_uuid=container_uuid)
def container_reboot(self, ctxt, container_uuid):
return self._call('container_reboot', ctxt=ctxt,
container_uuid=container_uuid)
def container_stop(self, container_uuid):
return self._call('container_stop', container_uuid=container_uuid)
def container_stop(self, ctxt, container_uuid):
return self._call('container_stop', ctxt=ctxt,
container_uuid=container_uuid)
def container_start(self, container_uuid):
return self._call('container_start', container_uuid=container_uuid)
def container_start(self, ctxt, container_uuid):
return self._call('container_start', ctxt=ctxt,
container_uuid=container_uuid)
def container_pause(self, container_uuid):
return self._call('container_pause', container_uuid=container_uuid)
def container_pause(self, ctxt, container_uuid):
return self._call('container_pause', ctxt=ctxt,
container_uuid=container_uuid)
def container_unpause(self, container_uuid):
return self._call('container_unpause', container_uuid=container_uuid)
def container_unpause(self, ctxt, container_uuid):
return self._call('container_unpause', ctxt=ctxt,
container_uuid=container_uuid)
def container_logs(self, container_uuid):
return self._call('container_logs', container_uuid=container_uuid)
def container_logs(self, ctxt, container_uuid):
return self._call('container_logs', ctxt=ctxt,
container_uuid=container_uuid)
def container_execute(self, container_uuid, command):
return self._call('container_execute', container_uuid=container_uuid,
def container_execute(self, ctxt, container_uuid, command):
return self._call('container_execute', ctxt=ctxt,
container_uuid=container_uuid,
command=command)

View File

@ -31,40 +31,40 @@ class Handler(object):
super(Handler, self).__init__()
self.kube_cli = kube_utils.KubeClient()
def service_create(self, context, service):
def service_create(self, ctxt, service):
LOG.debug("service_create")
# trigger a kubectl command
status = self.kube_cli.service_create(service)
if not status:
return None
# call the service object to persist in db
service.create(context)
service.create(ctxt)
return service
def service_update(self, context, service):
def service_update(self, ctxt, service):
LOG.debug("service_update")
# trigger a kubectl command
status = self.kube_cli.service_update(service)
if not status:
return None
# call the service object to persist in db
service.refresh(context)
service.refresh(ctxt)
return service
def service_list(self, context):
def service_list(self, ctxt):
LOG.debug("service_list")
return self.kube_cli.service_list()
def service_delete(self, context, service):
def service_delete(self, ctxt, service):
LOG.debug("service_delete")
# trigger a kubectl command
status = self.kube_cli.service_delete(service.uuid)
if not status:
return None
# call the service object to persist in db
service.destroy(context)
service.destroy(ctxt)
def service_get(self, context, uuid):
def service_get(self, ctxt, uuid):
LOG.debug("service_get")
return self.kube_cli.service_get(uuid)
@ -73,73 +73,73 @@ class Handler(object):
return self.kube_cli.service_show(uuid)
# Pod Operations
def pod_create(self, context, pod):
def pod_create(self, ctxt, pod):
LOG.debug("pod_create")
# trigger a kubectl command
status = self.kube_cli.pod_create(pod)
if not status:
return None
# call the pod object to persist in db
pod.create(context)
pod.create(ctxt)
return pod
def pod_update(self, context, pod):
def pod_update(self, ctxt, pod):
LOG.debug("pod_update")
# trigger a kubectl command
status = self.kube_cli.pod_update(pod)
if not status:
return None
# call the pod object to persist in db
pod.refresh(context)
pod.refresh(ctxt)
return pod
def pod_list(self, context):
def pod_list(self, ctxt):
LOG.debug("pod_list")
return self.kube_cli.pod_list()
def pod_delete(self, context, pod):
def pod_delete(self, ctxt, pod):
LOG.debug("pod_delete ")
# trigger a kubectl command
status = self.kube_cli.pod_delete(pod.uuid)
if not status:
return None
# call the pod object to persist in db
pod.destroy(context)
pod.destroy(ctxt)
def pod_get(self, context, uuid):
def pod_get(self, ctxt, uuid):
LOG.debug("pod_get")
return self.kube_cli.pod_get(uuid)
def pod_show(self, context, uuid):
def pod_show(self, ctxt, uuid):
LOG.debug("pod_show")
return self.kube_cli.pod_show(uuid)
# Replication Controller Operations
def rc_create(self, context, rc):
def rc_create(self, ctxt, rc):
LOG.debug("rc_create")
# trigger a kubectl command
status = self.kube_cli.rc_create(rc)
if not status:
return None
# call the rc object to persist in db
rc.create(context)
rc.create(ctxt)
return rc
def rc_update(self, context, rc):
def rc_update(self, ctxt, rc):
LOG.debug("rc_update")
# trigger a kubectl command
status = self.kube_cli.rc_update(rc)
if not status:
return None
# call the rc object to persist in db
rc.refresh(context)
rc.refresh(ctxt)
return rc
def rc_delete(self, context, rc):
def rc_delete(self, ctxt, rc):
LOG.debug("rc_delete ")
# trigger a kubectl command
status = self.kube_cli.pod_delete(rc.uuid)
if not status:
return None
# call the rc object to persist in db
rc.destroy(context)
rc.destroy(ctxt)