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
3
Snippets
Groups
Projects
Show more breadcrumbs
BuildGrid
buildgrid
Commits
d8aaa48b
Commit
d8aaa48b
authored
6 years ago
by
Finn
Browse files
Options
Downloads
Patches
Plain Diff
Add Device class.
parent
b2565c8a
No related branches found
No related tags found
Loading
Changes
2
Show 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
+75
-0
75 additions, 0 deletions
buildgrid/bot/hardware/device.py
with
75 additions
and
0 deletions
buildgrid/bot/hardware/__init__.py
0 → 100644
+
0
−
0
View file @
d8aaa48b
This diff is collapsed.
Click to expand it.
buildgrid/bot/hardware/device.py
0 → 100644
+
75
−
0
View file @
d8aaa48b
# 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.
"""
Device
======
A device.
"""
import
uuid
from
buildgrid._protos.google.devtools.remoteworkers.v1test2
import
worker_pb2
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.
properties (list(dict(string : string))) : Properties of device. Keys may
repeated.
"""
self
.
_properties
=
{}
self
.
__property_keys
=
[
'
os
'
,
'
has-docker
'
]
self
.
__name
=
str
(
uuid
.
uuid4
())
if
properties
:
for
prop
in
properties
:
self
.
_add_property
(
prop
)
@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
)
for
k
,
v
in
self
.
_properties
.
items
():
for
prop
in
v
:
property_message
=
worker_pb2
.
Device
.
Property
()
property_message
.
key
=
k
property_message
.
value
=
prop
device
.
properties
.
extend
([
property_message
])
return
device
def
_add_property
(
self
,
key
,
value
):
if
key
in
self
.
__property_keys
:
prop
=
self
.
_properties
.
get
(
key
)
if
not
prop
:
self
.
_properties
[
key
]
=
[
value
]
else
:
prop
[
key
].
append
(
value
)
else
:
raise
KeyError
(
'
Key not supported: [{}]
'
.
format
(
key
))
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