Skip to content
GitLab
Menu
Why GitLab
Pricing
Contact Sales
Explore
Why GitLab
Pricing
Contact Sales
Explore
Sign in
Get free trial
Primary navigation
Search or go to…
Project
buildgrid
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Privacy statement
Keyboard shortcuts
?
What's new
6
Snippets
Groups
Projects
Show more breadcrumbs
BuildGrid
buildgrid
Commits
a619731f
Commit
a619731f
authored
6 years ago
by
Finn
Browse files
Options
Downloads
Patches
Plain Diff
Add Device class.
parent
af3c84ab
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
buildgrid/bot/hardware/__init__.py
+0
-0
0 additions, 0 deletions
buildgrid/bot/hardware/__init__.py
buildgrid/bot/hardware/device.py
+57
-0
57 additions, 0 deletions
buildgrid/bot/hardware/device.py
with
57 additions
and
0 deletions
buildgrid/bot/hardware/__init__.py
0 → 100644
+
0
−
0
View file @
a619731f
This diff is collapsed.
Click to expand it.
buildgrid/bot/hardware/device.py
0 → 100644
+
57
−
0
View file @
a619731f
# Copyright (C) 2018 Bloomberg LP
#
# 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
#
# <http://www.apache.org/licenses/LICENSE-2.0>
#
# 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.
class
Device
:
def
__init__
(
self
,
properties
=
None
):
"""
Creates devices available to the worker
The first device is know as the Primary Device - the revice which
is running a bit and responsible to actually executing commands.
All other devices are known as Attatched Devices and must be controlled
by the Primary Device.
"""
self
.
__properties
=
{}
self
.
__name
=
str
(
uuid
.
uuid4
())
if
properties
:
for
k
,
v
in
properties
.
items
():
if
k
==
'
os
'
:
self
.
__properties
[
k
]
=
v
elif
k
==
'
docker
'
:
if
v
not
in
(
'
True
'
,
'
False
'
):
raise
ValueError
(
'
Value not supported: [{}]
'
.
format
(
v
))
self
.
__properties
[
k
]
=
v
else
:
raise
KeyError
(
'
Key not supported: [{}]
'
.
format
(
k
))
@property
def
name
(
self
):
return
self
.
__name
@property
def
properties
(
self
):
return
self
.
__properties
def
get_pb2
(
self
):
device
=
worker_pb2
.
Device
(
handle
=
self
.
_name
)
property_message
=
worker_pb2
.
Device
.
Property
()
for
k
,
v
in
self
.
_properties
.
items
():
property_message
.
key
=
k
property_message
.
value
=
v
device
.
properties
.
extend
([
property_message
])
return
device
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment