Commit 481a86ea by Sunil Kumar Veerappa

Deleted accelerator tracker file

parent 60e453cd
# Copyright (c) 2018 Huawei Technologies
# All Rights Reserved.
# 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
# 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.
Track accelerator like FPGA GPU and QAT for a host. Provides the
conductor with useful information about availability through the accelerator
from oslo_log import log as logging
from oslo_messaging.rpc.client import RemoteError
from oslo_utils import uuidutils
from stevedore import driver
from stevedore.extension import ExtensionManager
from cyborg.common import exception
from cyborg.conf import CONF
from cyborg.accelerator.drivers.fpga.base import FPGADriver
from cyborg.accelerator.drivers.fpga.m2dc.driver import M2DCFPGADriver
from cyborg.common import utils
from cyborg import objects
LOG = logging.getLogger(__name__)
AGENT_RESOURCE_SEMAPHORE = "agent_resources"
ACCELERATOR_HOST_MAPS = {"pcie_address": "identifier",
"vendor": "vendorName",
"name": "deviceName"}
class AcceleratorTracker(object):
"""Agent helper class for keeping track of accelerator usage as instances
are built and destroyed.
def __init__(self, host, cond_api):
self.fpgas = None = host
self.conductor_api = cond_api
self.acc_drivers = []
'''def _initialize_drivers(self, enabled_drivers_m2dc=[]):
Load accelerator drivers.
:return: [nvidia_gpu_driver_obj, intel_fpga_driver_obj]
LOG.error("control is here in acc tracker")
acc_drivers = []
if not enabled_drivers_m2dc:
enabled_drivers_m2dc = CONF.agent.enabled_drivers_m2dc
LOG.error(" Driver name from conf" + str(enabled_drivers_m2dc))
valid_drivers = ExtensionManager(
for d in enabled_drivers_m2dc:
if d not in valid_drivers:
raise exception.InvalidDriver(name=d)
acc_driver = driver.DriverManager(
namespace='cyborg.accelerator.driver', name=d,
LOG.error("acc driver in resource " + str(acc_drivers))
self.acc_drivers = acc_drivers'''
def claim(self, context):
def _fpga_compare_and_update(self, host_dev, accelerator):
need_updated = False
for k, v in ACCELERATOR_HOST_MAPS.items():
if accelerator[k] != host_dev[v]:
need_updated = True
accelerator[k] = host_dev[v]
return need_updated
def _gen_accelerator_from_host_dev(self, host_dev):
dep = {}
for k, v in ACCELERATOR_HOST_MAPS.items():
dep[k] = host_dev[v]
dep["host"] =
dep["version"] = ACCELERATOR_VERSION
dep["availability"] = "free"
dep["uuid"] = uuidutils.generate_uuid()
dep["board"] = BOARD
dep["type"] = TYPE
dep["assignable"] = ASSIGNABLE
return dep
def update_usage(self, context):
"""Update the resource usage and stats after a change in an
LOG.error("Hello in update usage")
acc_list = []
for acc_driver in self.acc_drivers:
# Call conductor_api here to diff and report acc data. Now, we actually
# do not have the method report_data.
if acc_list:
self.conductor_api.report_data(context,, acc_list)
def create_accelerator(fpgas,bdf):
fpga = fpgas[bdf]
dep = self._gen_accelerator_from_host_dev(fpga)
obj_dep = objects.Accelerator(context, **dep)
new_dep = self.conductor_api.accelerator_create(context, obj_dep)
return new_dep
fpgas = self._get_fpga_devices()
bdfs = set(fpgas["name"])
accelerators = self.conductor_api.accelerator_get_by_host(
accls = dict([(v["pcie_address"], v) for v in accelerators])
accl_bdfs = set(accls.keys())
# Firstly update if same accelerators available in database
for mutual in accl_bdfs & bdfs:
accl = accls[mutual]
if self._fpga_compare_and_update(fpgas[mutual], accl):
self.conductor_api.accelerator_update(context, accl)
except RemoteError as e:
# Add fpga if it is not in database
new = bdfs - accl_bdfs
for n in new:
new_dep = create_accelerator(fpgas,n)
# Delete fpga if it is not present
for obsolete in accl_bdfs - bdfs:
self.conductor_api.accelerator_delete(context, accls[obsolete])
except RemoteError as e:
del accls[obsolete]
def _get_fpga_devices(self):
available_fpgas =
return available_fpgas
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment