コード例 #1
0
ファイル: manager.py プロジェクト: dpaterson/cyborg
 def fpga_program_v2(self, context, controlpath_id,
                     bitstream_uuid, driver_name):
     bitstream_uuid = str(bitstream_uuid)
     if not uuidutils.is_uuid_like(bitstream_uuid):
         raise exception.InvalidUUID(uuid=bitstream_uuid)
     download_path = tempfile.NamedTemporaryFile(suffix=".gbs",
                                                 prefix=bitstream_uuid)
     self.image_api.download(context,
                             bitstream_uuid,
                             dest_path=download_path.name)
     driver = self.fpga_driver.create(driver_name)
     ret = driver.program_v2(controlpath_id, download_path.name)
     LOG.info('Driver program() API returned code %s', ret)
     os.remove(download_path.name)
コード例 #2
0
 def test_program_invalid_uuid(self, mock_program, mock_get_dep,
                               mock_get_cpid_list, mock_get_by_device_id):
     self.headers['X-Roles'] = 'admin'
     self.headers['Content-Type'] = 'application/json'
     dep_uuid = self.deployable_uuids[0]
     mock_get_dep.return_value = self.dep
     mock_get_by_device_id.return_value = self.dev
     mock_get_cpid_list.return_value = [self.cpid]
     mock_program.return_value = False
     body = [{"image_uuid": self.invalid_image_uuid}]
     try:
         self.patch_json('/deployables/%s/program' % dep_uuid,
                         [{
                             'path': '/bitstream_id',
                             'value': body,
                             'op': 'replace'
                         }],
                         headers=self.headers)
     except Exception as e:
         exc = e
     self.assertIn(
         exception.InvalidUUID(self.invalid_image_uuid).args[0],
         exc.args[0])
コード例 #3
0
ファイル: types.py プロジェクト: sainusahib/cyborg
 def validate(value):
     if not uuidutils.is_uuid_like(value):
         raise exception.InvalidUUID(uuid=value)
     return value