All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] Autostart bitbake server
@ 2016-07-18 16:07 Ed Bartosh
  2016-07-18 16:07 ` [PATCH 1/3] bitbake: xmlrpc: implement check of connection to server Ed Bartosh
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Ed Bartosh @ 2016-07-18 16:07 UTC (permalink / raw)
  To: bitbake-devel

Hi,

This patchet contains implementation of autostart feature. Bitbake server
is automatically started if BBSERVER variable is set to 'autostart'.

The following changes since commit 627d01997fcf6a0581d88047735769ffb2592b82:

  useradd-staticids: use map() instead of imap() (2016-07-12 23:12:00 +0100)

are available in the git repository at:

  git://git.yoctoproject.org/poky-contrib ed/bitbake/resident-autoload-5534
  http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=ed/bitbake/resident-autoload-5534

Ed Bartosh (3):
  bitbake: xmlrpc: implement check of connection to server
  bitbake: utils: add BBSERVER to the list of preserved variables
  bitbake: main: implement server autostart feature

 bitbake/lib/bb/main.py          | 21 ++++++++++++++++-----
 bitbake/lib/bb/server/xmlrpc.py | 17 +++++++++++++++++
 bitbake/lib/bb/utils.py         |  1 +
 3 files changed, 34 insertions(+), 5 deletions(-)

---
Regards,
Ed




^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/3] bitbake: xmlrpc: implement check of connection to server
  2016-07-18 16:07 [PATCH 0/3] Autostart bitbake server Ed Bartosh
@ 2016-07-18 16:07 ` Ed Bartosh
  2016-07-18 16:07 ` [PATCH 2/3] bitbake: utils: add BBSERVER to the list of preserved variables Ed Bartosh
  2016-07-18 16:07 ` [PATCH 3/3] bitbake: main: implement server autostart feature Ed Bartosh
  2 siblings, 0 replies; 4+ messages in thread
From: Ed Bartosh @ 2016-07-18 16:07 UTC (permalink / raw)
  To: bitbake-devel

Implemented check_connection function. The purpose of this function
is to check if bitbake server is accessible and functional.
To check this this function tries to connect to bitbake server and
run getVariable command.

This API is going to be used to implement autoloading of bitbake
server.

[YOCTO #5534]

Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
---
 bitbake/lib/bb/server/xmlrpc.py | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/bitbake/lib/bb/server/xmlrpc.py b/bitbake/lib/bb/server/xmlrpc.py
index 57c59a8..4131b52 100644
--- a/bitbake/lib/bb/server/xmlrpc.py
+++ b/bitbake/lib/bb/server/xmlrpc.py
@@ -85,6 +85,23 @@ def _create_server(host, port, timeout = 60):
     s = xmlrpc.client.ServerProxy("http://%s:%d/" % (host, port), transport=t, allow_none=True, use_builtin_types=True)
     return s, t
 
+def check_connection(remote, timeout):
+    try:
+        host, port = remote.split(":")
+        port = int(port)
+    except Exception as e:
+        bb.warn("Failed to read remote definition (%s)" % str(e))
+        raise e
+
+    server, _transport = _create_server(host, port, timeout)
+    try:
+        ret, err =  server.runCommand(['getVariable', 'TOPDIR'])
+        if err or not ret:
+            return False
+    except ConnectionError:
+        return False
+    return True
+
 class BitBakeServerCommands():
 
     def __init__(self, server):
-- 
2.1.4



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/3] bitbake: utils: add BBSERVER to the list of preserved variables
  2016-07-18 16:07 [PATCH 0/3] Autostart bitbake server Ed Bartosh
  2016-07-18 16:07 ` [PATCH 1/3] bitbake: xmlrpc: implement check of connection to server Ed Bartosh
@ 2016-07-18 16:07 ` Ed Bartosh
  2016-07-18 16:07 ` [PATCH 3/3] bitbake: main: implement server autostart feature Ed Bartosh
  2 siblings, 0 replies; 4+ messages in thread
From: Ed Bartosh @ 2016-07-18 16:07 UTC (permalink / raw)
  To: bitbake-devel

All environment variables that are not in the list returned by
preserved_envvars_exported are cleaned by bb.utils.clean_environment.

Added BBSERVER to the list as we need to access it in bb/main.py
after the call of bb.utils.clean_environment.

Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
---
 bitbake/lib/bb/utils.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py
index 0a1bf68..00d6474 100644
--- a/bitbake/lib/bb/utils.py
+++ b/bitbake/lib/bb/utils.py
@@ -574,6 +574,7 @@ def preserved_envvars_exported():
         'TERM',
         'USER',
         'LC_ALL',
+        'BBSERVER',
     ]
 
 def preserved_envvars():
-- 
2.1.4



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 3/3] bitbake: main: implement server autostart feature
  2016-07-18 16:07 [PATCH 0/3] Autostart bitbake server Ed Bartosh
  2016-07-18 16:07 ` [PATCH 1/3] bitbake: xmlrpc: implement check of connection to server Ed Bartosh
  2016-07-18 16:07 ` [PATCH 2/3] bitbake: utils: add BBSERVER to the list of preserved variables Ed Bartosh
@ 2016-07-18 16:07 ` Ed Bartosh
  2 siblings, 0 replies; 4+ messages in thread
From: Ed Bartosh @ 2016-07-18 16:07 UTC (permalink / raw)
  To: bitbake-devel

If environment variable BBSERVER == 'autostart' bitbake will
automatically load server if it's not running yet.

If host and port are in bitbake.lock then bitbake tries to check
if server is running and responses to commands and starts new
server only if this check fails.

[YOCTO #5534]

Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
---
 bitbake/lib/bb/main.py | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/bitbake/lib/bb/main.py b/bitbake/lib/bb/main.py
index 3fc3ff5..1c32e93 100755
--- a/bitbake/lib/bb/main.py
+++ b/bitbake/lib/bb/main.py
@@ -303,8 +303,10 @@ class BitBakeConfigParameters(cookerdata.ConfigParameters):
 
         # if BBSERVER says to autodetect, let's do that
         if options.remote_server:
-            [host, port] = options.remote_server.split(":", 2)
-            port = int(port)
+            port = -1
+            if options.remote_server != 'autostart':
+                host, port = options.remote_server.split(":", 2)
+                port = int(port)
             # use automatic port if port set to -1, means read it from
             # the bitbake.lock file; this is a bit tricky, but we always expect
             # to be in the base of the build directory if we need to have a
@@ -321,17 +323,18 @@ class BitBakeConfigParameters(cookerdata.ConfigParameters):
                     lf.close()
                     options.remote_server = remotedef
                 except Exception as e:
-                    raise BBMainException("Failed to read bitbake.lock (%s), invalid port" % str(e))
+                    if options.remote_server != 'autostart':
+                        raise BBMainException("Failed to read bitbake.lock (%s), invalid port" % str(e))
 
         return options, targets[1:]
 
 
 def start_server(servermodule, configParams, configuration, features):
     server = servermodule.BitBakeServer()
-    single_use = not configParams.server_only
+    single_use = not configParams.server_only and os.getenv('BBSERVER') != 'autostart'
     if configParams.bind:
         (host, port) = configParams.bind.split(':')
-        server.initServer((host, int(port)), single_use)
+        server.initServer((host, int(port)), single_use=single_use)
         configuration.interface = [server.serverImpl.host, server.serverImpl.port]
     else:
         server.initServer(single_use=single_use)
@@ -445,6 +448,14 @@ def bitbake_main(configParams, configuration):
         server = start_server(servermodule, configParams, configuration, featureset)
         bb.event.ui_queue = []
     else:
+        if os.getenv('BBSERVER') == 'autostart':
+            if configParams.remote_server == 'autostart' or \
+               not servermodule.check_connection(configParams.remote_server, timeout=2):
+                configParams.bind = 'localhost:0'
+                srv = start_server(servermodule, configParams, configuration, featureset)
+                configParams.remote_server = '%s:%d' % tuple(configuration.interface)
+                bb.event.ui_queue = []
+
         # we start a stub server that is actually a XMLRPClient that connects to a real server
         server = servermodule.BitBakeXMLRPCClient(configParams.observe_only,
                                                   configParams.xmlrpctoken)
-- 
2.1.4



^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-07-18 16:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-18 16:07 [PATCH 0/3] Autostart bitbake server Ed Bartosh
2016-07-18 16:07 ` [PATCH 1/3] bitbake: xmlrpc: implement check of connection to server Ed Bartosh
2016-07-18 16:07 ` [PATCH 2/3] bitbake: utils: add BBSERVER to the list of preserved variables Ed Bartosh
2016-07-18 16:07 ` [PATCH 3/3] bitbake: main: implement server autostart feature Ed Bartosh

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.