Skip to content

Commit

Permalink
Introduce RQD_TAGS for setting tags to RQD host. (#875)
Browse files Browse the repository at this point in the history
  • Loading branch information
splhack committed Jan 22, 2021
1 parent bf128e4 commit 7341f82
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions rqd/rqd/rqconstants.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
RQD_USE_IP_AS_HOSTNAME = True
RQD_BECOME_JOB_USER = True
RQD_CREATE_USER_IF_NOT_EXISTS = True
RQD_TAGS = ''

KILL_SIGNAL = 9
if platform.system() == 'Linux':
Expand Down Expand Up @@ -188,6 +189,8 @@
RQD_USE_IP_AS_HOSTNAME = config.getboolean(__section, "RQD_USE_IP_AS_HOSTNAME")
if config.has_option(__section, "RQD_BECOME_JOB_USER"):
RQD_BECOME_JOB_USER = config.getboolean(__section, "RQD_BECOME_JOB_USER")
if config.has_option(__section, "RQD_TAGS"):
RQD_TAGS = config.getint(__section, "RQD_TAGS")
if config.has_option(__section, "DEFAULT_FACILITY"):
DEFAULT_FACILITY = config.get(__section, "DEFAULT_FACILITY")
if config.has_option(__section, "LAUNCH_FRAME_USER_GID"):
Expand Down
4 changes: 4 additions & 0 deletions rqd/rqd/rqmachine.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,10 @@ def __initMachineTags(self):
"""Sets the hosts tags"""
self.__renderHost.tags.append("rqdv-%s" % rqd.rqconstants.VERSION)

if rqd.rqconstants.RQD_TAGS:
for tag in rqd.rqconstants.RQD_TAGS.split():
self.__renderHost.tags.append(tag)

# Tag with desktop if it is a desktop
if self.isDesktop():
self.__renderHost.tags.append("desktop")
Expand Down
7 changes: 7 additions & 0 deletions rqd/tests/rqmachine_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,13 @@ def test_reserveHT(self):

self.assertEqual({0, 1, 2, 3, 4, 5, 6, 7}, self.machine._Machine__tasksets)

def test_tags(self):
tags = ["test1", "test2", "test3"]
rqd.rqconstants.RQD_TAGS = " ".join(tags)

machine = rqd.rqmachine.Machine(self.rqCore, self.coreDetail)

self.assertTrue(all(tag in machine.__dict__['_Machine__renderHost'].tags for tag in tags))

class CpuinfoTests(unittest.TestCase):

Expand Down

0 comments on commit 7341f82

Please sign in to comment.