Giter Club home page Giter Club logo

pyxs's People

Contributors

carlwgeorge avatar jajcus avatar jkdingwall avatar knsd avatar stephen-czetty avatar superbobry avatar vexelnet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pyxs's Issues

Unexpected Packet

Trying to use this in order to interact with xenbus on a guest VM but keep running into an issue where I get the following:

UnexpectedPacket: _Packet(op=2, rq_id=66813, tx_id=0, size=360, payload='{}')

The code I am running is pretty straight forward as I am just trying to read the networking info from a particular mac address.

from pyxs.client import Router, Client
from pyxs.connection import XenBusConnection
router = Router(XenBusConnection())

with Client(router=router) as c:
    try:
        networking = c[b"vm-data/networking/BC764E20394F"]
        print(networking)
    except:
        pass

Is there something that I need to set that I am missing, or is it that this can only be run on the underlying host and not the guest vm.

Exception printed from router thread even when one is caught by the application

Test code:

#!/usr/bin/python3

import pyxs

router = pyxs.Router(pyxs.connection.XenBusConnection())
xs = pyxs.Client(router=router)

try:
    xs.connect()
except pyxs.ConnectionError:
    print("ConnectionError caught")

Expected output on non-xen VM:

ConnectionError caught

Actual output on non-xen VM:

Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/share/python3.5/site-packages/pyxs/connection.py", line 199, in __init__
    self.fd = os.open(path, os.O_RDWR)
FileNotFoundError: [Errno 2] No such file or directory: '/proc/xen/xenbus'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/share/python3.5/threading.py", line 923, in _bootstrap_inner
    self.run()
  File "/usr/share/python3.5/threading.py", line 871, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/share/python3.5/site-packages/pyxs/client.py", line 101, in __call__
    self.connection.connect()
  File "/usr/share/python3.5/site-packages/pyxs/connection.py", line 52, in connect
    self.transport = self.create_transport()
  File "/usr/share/python3.5/site-packages/pyxs/connection.py", line 245, in create_transport
    return _XenBusTransport(self.path)
  File "/usr/share/python3.5/site-packages/pyxs/connection.py", line 202, in __init__
    .format(path, e.args))
pyxs.exceptions.ConnectionError: error while opening '/proc/xen/xenbus': (2, 'No such file or directory')

ConnectionError caught

Contributor email

Hi

Could you please update my email (in contributors) to sandeep DOT murthy AT icloud.com. Thanks.

Path validation

Hi

At the moment there's no method to check whether a given path is a valid Xenstore path - would it be useful to add such a method to pyxs.helpers? A corresponding exception would be added to pyxs.exceptions. I am happy to do that, if you think this is useful.

SM

Router.__call__ does not handle interrupted system calls in select

I'm integrating pyxs within a twisted base application.
I hit an issue where the select.select() call within Router.call was interrupted.
This call is within a try block without any except clause. It does not handle interrupted system calls within the select system call.
It seems that any error from select.select() would end up with a select.error exception which is not caught and the Router connection is terminated.
Is it right to catch such exception and re-issue the select.select() call?

Invalid check for setting up a Monitor when connected via XenBus

The client.py currently contains a check for setting up a watch on xenstore:

https://github.com/selectel/pyxs/blob/master/pyxs/client.py#L619-L621

        if isinstance(self.router.connection, XenBusConnection):
            raise PyXSError("using ``Monitor`` over XenBus is not supported",
                            UserWarning)

This no longer seems to be a valid check with Xen 4.14.x + Linux 5.4 (Ubuntu kernel). I don't know whether the solution to the original problem was in Xen or Linux or with which versions that it started working. This code works in dom0 and domU with that check commented out:

#!/usr/bin/env python3

import sys
import threading
import time

import pyxs


class Watcher(threading.Thread):
    def __init__(self):
        super().__init__()
        self._monitor = None
        self._watch = b"/"
        self._token = b"token"
        self.start()


    def run(self):
        with pyxs.client.Client(xen_bus_path="/dev/xen/xenbus") as xsc:
            self._monitor = xsc.monitor()
            self._monitor.watch(self._watch, self._token)
            while self._monitor:
                print(next(self._monitor.wait(unwatched=True)))


    def stop(self):
        mtmp = self._monitor
        self._monitor = None
        # poke an event in queue for anything currently .wait()ing
        mtmp.events.put(pyxs.client.Event(self._watch, self._token)),


def main():
    watcher = Watcher()
    time.sleep(4)
    watcher.stop()
    watcher.join()


if __name__ == "__main__":
    sys.exit(
        main()
    )

It is possible to bypass the check by instantiating the Monitor() class directly with an existing Client().

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.