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
bbccc3d8
Commit
bbccc3d8
authored
6 years ago
by
Finn
Browse files
Options
Downloads
Patches
Plain Diff
Remove hardware descriptions from bot_session.
Also move `bot_session` to simply `session`.
parent
eb027263
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
buildgrid/bot/session.py
+11
-101
11 additions, 101 deletions
buildgrid/bot/session.py
with
11 additions
and
101 deletions
buildgrid/bot/
bot_
session.py
→
buildgrid/bot/session.py
+
11
−
101
View file @
bbccc3d8
...
...
@@ -18,7 +18,7 @@
"""
Bot Session
====
====
=======
Allows connections
"""
...
...
@@ -36,7 +36,7 @@ from buildgrid._exceptions import BotError
class
BotSession
:
def
__init__
(
self
,
parent
,
interface
):
def
__init__
(
self
,
parent
,
interface
,
worker
):
"""
Unique bot ID within the farm used to identify this bot
Needs to be human readable.
All prior sessions with bot_id of same ID are invalidated.
...
...
@@ -45,22 +45,20 @@ class BotSession:
"""
self
.
__logger
=
logging
.
getLogger
(
__name__
)
self
.
_bot_id
=
'
{}.{}
'
.
format
(
parent
,
platform
.
node
())
self
.
_context
=
None
self
.
_worker
=
worker
self
.
_interface
=
interface
self
.
_leases
=
{}
self
.
_name
=
None
self
.
_parent
=
parent
self
.
_status
=
BotStatus
.
OK
.
value
self
.
_work
=
None
self
.
_worker
=
None
self
.
__bot_id
=
'
{}.{}
'
.
format
(
parent
,
platform
.
node
())
self
.
__name
=
None
@property
def
bot_id
(
self
):
return
self
.
_bot_id
def
add_worker
(
self
,
worker
):
self
.
_worker
=
worker
return
self
.
__bot_id
def
create_bot_session
(
self
,
work
,
context
=
None
):
self
.
__logger
.
debug
(
"
Creating bot session
"
)
...
...
@@ -68,7 +66,7 @@ class BotSession:
self
.
_context
=
context
session
=
self
.
_interface
.
create_bot_session
(
self
.
_parent
,
self
.
get_pb2
())
self
.
_name
=
session
.
name
self
.
_
_
name
=
session
.
name
self
.
__logger
.
info
(
"
Created bot session with name: [%s]
"
,
self
.
_name
)
...
...
@@ -93,8 +91,8 @@ class BotSession:
return
bots_pb2
.
BotSession
(
worker
=
self
.
_worker
.
get_pb2
(),
status
=
self
.
_status
,
leases
=
leases
,
bot_id
=
self
.
_bot_id
,
name
=
self
.
_name
)
bot_id
=
self
.
_
_
bot_id
,
name
=
self
.
_
_
name
)
def
lease_completed
(
self
,
lease
):
lease
.
state
=
LeaseState
.
COMPLETED
.
value
...
...
@@ -132,91 +130,3 @@ class BotSession:
self
.
__logger
.
debug
(
"
Work complete: [%s]
"
,
lease
.
id
)
self
.
lease_completed
(
lease
)
class
Worker
:
def
__init__
(
self
,
properties
=
None
,
configs
=
None
):
self
.
properties
=
{}
self
.
_configs
=
{}
self
.
_devices
=
[]
if
properties
:
for
k
,
v
in
properties
.
items
():
if
k
==
'
pool
'
:
self
.
properties
[
k
]
=
v
else
:
raise
KeyError
(
'
Key not supported: [{}]
'
.
format
(
k
))
if
configs
:
for
k
,
v
in
configs
.
items
():
if
k
==
'
DockerImage
'
:
self
.
configs
[
k
]
=
v
else
:
raise
KeyError
(
'
Key not supported: [{}]
'
.
format
(
k
))
@property
def
configs
(
self
):
return
self
.
_configs
def
add_device
(
self
,
device
):
self
.
_devices
.
append
(
device
)
def
get_pb2
(
self
):
devices
=
[
device
.
get_pb2
()
for
device
in
self
.
_devices
]
worker
=
worker_pb2
.
Worker
(
devices
=
devices
)
property_message
=
worker_pb2
.
Worker
.
Property
()
for
k
,
v
in
self
.
properties
.
items
():
property_message
.
key
=
k
property_message
.
value
=
v
worker
.
properties
.
extend
([
property_message
])
config_message
=
worker_pb2
.
Worker
.
Config
()
for
k
,
v
in
self
.
properties
.
items
():
property_message
.
key
=
k
property_message
.
value
=
v
worker
.
configs
.
extend
([
config_message
])
return
worker
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
.
_name
=
str
(
uuid
.
uuid4
())
self
.
_properties
=
{}
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