Repository URL to install this package:
Version:
6.0.1.dev7 ▾
|
# Copyright 2014 TrilioData Inc.
# All Rights Reserved.
"""
Client side of the scheduler manager RPC API.
"""
from workloadmgr import flags
from workloadmgr.openstack.common import jsonutils
from workloadmgr import rpc
import oslo_messaging as messaging
FLAGS = flags.FLAGS
class SchedulerAPI():
'''Client side of the scheduler rpc API.
API version history:
1.0 - Initial version.
1.1 - Add workload_snapshot() method
1.2 - Add request_spec, filter_properties arguments
to workload_snapshot()
2.0 - Using oslo_messaging instead of OpenStac/common/*
'''
RPC_API_VERSION = '2.0'
def __init__(self):
super(SchedulerAPI, self).__init__()
target = messaging.Target(topic=FLAGS.scheduler_topic,
version=self.RPC_API_VERSION)
self.client = rpc.get_client(target, self.RPC_API_VERSION)
def file_search(self, ctxt, topic, search_id,
request_spec=None, filter_properties=None):
cctxt = self.client.prepare(version=self.RPC_API_VERSION)
request_spec_p = jsonutils.to_primitive(request_spec)
return cctxt.cast(ctxt, 'file_search',
topic=topic,
search_id=search_id,
request_spec=request_spec_p,
filter_properties=filter_properties)
def workload_create(self, ctxt, topic, workload_id,
request_spec=None, filter_properties=None):
cctxt = self.client.prepare(version=self.RPC_API_VERSION)
request_spec_p = jsonutils.to_primitive(request_spec)
return cctxt.cast(ctxt, 'workload_create', topic=topic,
workload_id=workload_id,
request_spec=request_spec_p,
filter_properties=filter_properties)
def workload_delete(self, ctxt, topic, workload_id,
request_spec=None, filter_properties=None):
cctxt = self.client.prepare(version=self.RPC_API_VERSION)
request_spec_p = jsonutils.to_primitive(request_spec)
return cctxt.cast(ctxt, 'workload_delete', topic=topic,
workload_id=workload_id,
request_spec=request_spec_p,
filter_properties=filter_properties)
def workload_reset(self, ctxt, topic, workload_id,
request_spec=None, filter_properties=None):
cctxt = self.client.prepare(version=self.RPC_API_VERSION)
request_spec_p = jsonutils.to_primitive(request_spec)
return cctxt.cast(ctxt, 'workload_reset', topic=topic,
workload_id=workload_id,
request_spec=request_spec_p,
filter_properties=filter_properties)
def workload_snapshot(self, ctxt, topic, snapshot_id,
request_spec=None, filter_properties=None):
cctxt = self.client.prepare(version=self.RPC_API_VERSION)
request_spec_p = jsonutils.to_primitive(request_spec)
return cctxt.cast(ctxt, 'workload_snapshot', topic=topic,
snapshot_id=snapshot_id,
request_spec=request_spec_p,
filter_properties=filter_properties)
def workload_import(self, ctxt, topic, values, upgrade,
request_spec=None, filter_properties=None):
cctxt = self.client.prepare(version=self.RPC_API_VERSION)
request_spec_p = jsonutils.to_primitive(request_spec)
return cctxt.cast(ctxt, 'workload_import', topic=topic,
workload_id=[values.get('workload')],
upgrade=upgrade,
jobid=values.get('jobid'),
values=values,
request_spec=request_spec_p,
filter_properties=filter_properties)
def snapshot_delete(self, ctxt, topic, snapshot_id,
request_spec=None, filter_properties=None):
cctxt = self.client.prepare(version=self.RPC_API_VERSION)
request_spec_p = jsonutils.to_primitive(request_spec)
return cctxt.cast(ctxt, 'snapshot_delete', topic=topic,
snapshot_id=snapshot_id,
request_spec=request_spec_p,
filter_properties=filter_properties)
def snapshot_dismount(self, ctxt, topic, snapshot_id,
request_spec=None, filter_properties=None):
cctxt = self.client.prepare(version=self.RPC_API_VERSION)
request_spec_p = jsonutils.to_primitive(request_spec)
return cctxt.cast(ctxt, 'snapshot_dismount', topic=topic,
snapshot_id=snapshot_id,
request_spec=request_spec_p,
filter_properties=filter_properties)
def snapshot_mount(self, ctxt, topic, snapshot_id, mount_vm_id,
request_spec=None, filter_properties=None):
cctxt = self.client.prepare(version=self.RPC_API_VERSION)
request_spec_p = jsonutils.to_primitive(request_spec)
return cctxt.cast(ctxt, 'snapshot_mount', topic=topic,
snapshot_id=snapshot_id,
mount_vm_id=mount_vm_id,
request_spec=request_spec_p,
filter_properties=filter_properties)
def snapshot_restore(self, ctxt, topic, restore_id,
request_spec=None, filter_properties=None):
cctxt = self.client.prepare(version=self.RPC_API_VERSION)
request_spec_p = jsonutils.to_primitive(request_spec)
return cctxt.cast(ctxt, 'snapshot_restore', topic=topic,
restore_id=restore_id,
request_spec=request_spec_p,
filter_properties=filter_properties)
def network_topology_restore(self, ctxt, topic, restore_id,
request_spec=None, filter_properties=None):
cctxt = self.client.prepare(version=self.RPC_API_VERSION)
request_spec_p = jsonutils.to_primitive(request_spec)
return cctxt.cast(ctxt, 'network_topology_restore', topic=topic,
restore_id=restore_id,
request_spec=request_spec_p,
filter_properties=filter_properties)
def security_groups_restore(self, ctxt, topic, restore_id,
request_spec=None, filter_properties=None):
cctxt = self.client.prepare(version=self.RPC_API_VERSION)
request_spec_p = jsonutils.to_primitive(request_spec)
return cctxt.cast(
ctxt, 'security_groups_restore', topic=topic,
restore_id=restore_id,
request_spec=request_spec_p,
filter_properties=filter_properties
)
def update_service_capabilities(self, ctxt,
service_name, host,
capabilities):
cctxt = self.client.prepare(server=host, version=self.RPC_API_VERSION)
return cctxt.fanout_cast(ctxt, 'update_service_capabilities',
service_name=service_name, host=host,
capabilities=capabilities)
def migration_plan_create(self, ctxt, topic, migration_plan_id,
request_spec=None, filter_properties=None):
cctxt = self.client.prepare(version=self.RPC_API_VERSION)
request_spec_p = jsonutils.to_primitive(request_spec)
return cctxt.cast(ctxt, 'migration_plan_create', topic=topic,
migration_plan_id=migration_plan_id,
request_spec=request_spec_p,
filter_properties=filter_properties)
def migration_plan_delete(self, ctxt, topic, migration_plan_id,
request_spec=None, filter_properties=None):
cctxt = self.client.prepare(version=self.RPC_API_VERSION)
request_spec_p = jsonutils.to_primitive(request_spec)
return cctxt.cast(ctxt, 'migration_plan_delete', topic=topic,
migration_plan_id=migration_plan_id,
request_spec=request_spec_p,
filter_properties=filter_properties)
def migration_plan_discovervms(self, ctxt, topic, migration_plan_id,
request_spec=None, filter_properties=None):
cctxt = self.client.prepare(version=self.RPC_API_VERSION)
request_spec_p = jsonutils.to_primitive(request_spec)
return cctxt.cast(ctxt, 'migration_plan_discovervms', topic=topic,
migration_plan_id=migration_plan_id,
request_spec=request_spec_p,
filter_properties=filter_properties)
def migration_create(self, ctxt, topic, migration_id,
request_spec=None, filter_properties=None):
cctxt = self.client.prepare(version=self.RPC_API_VERSION)
request_spec_p = jsonutils.to_primitive(request_spec)
return cctxt.cast(ctxt, 'migration_create', topic=topic,
migration_id=migration_id,
request_spec=request_spec_p,
filter_properties=filter_properties)
def migration_delete(self, ctxt, topic, migration_id,
request_spec=None, filter_properties=None):
cctxt = self.client.prepare(version=self.RPC_API_VERSION)
request_spec_p = jsonutils.to_primitive(request_spec)
return cctxt.cast(ctxt, 'migration_delete', topic=topic,
migration_id=migration_id,
request_spec=request_spec_p,
filter_properties=filter_properties)
def schedule_send_email(self, ctxt, topic, object_id, object_type,
request_spec=None, filter_properties=None):
cctxt = self.client.prepare(version=self.RPC_API_VERSION)
request_spec_p = jsonutils.to_primitive(request_spec)
return cctxt.cast(ctxt, 'schedule_send_email', topic=topic,
object_id=object_id,
object_type=object_type,
request_spec=request_spec_p,
filter_properties=filter_properties)