aboutsummaryrefslogtreecommitdiffstats
path: root/package/kernel/gpio-button-hotplug/src/gpio-button-hotplug.c
diff options
context:
space:
mode:
authorDaniel Golle <daniel@makrotopia.org>2023-03-27 18:15:13 +0100
committerDaniel Golle <daniel@makrotopia.org>2023-03-27 19:07:54 +0100
commit53dc9a60c05642e9596b25e5cfba1136a5d9e09e (patch)
treec01ed33d773a44927abf97ef1eddf1e2048090c2 /package/kernel/gpio-button-hotplug/src/gpio-button-hotplug.c
parent880d1311335120f64447ca9d11933872d734e19a (diff)
downloadupstream-53dc9a60c05642e9596b25e5cfba1136a5d9e09e.tar.gz
upstream-53dc9a60c05642e9596b25e5cfba1136a5d9e09e.tar.bz2
upstream-53dc9a60c05642e9596b25e5cfba1136a5d9e09e.zip
generic: mtk_eth_soc: switch to external PCS driver
Backport patch to make use of the new PCS driver in mtk_eth_soc. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Diffstat (limited to 'package/kernel/gpio-button-hotplug/src/gpio-button-hotplug.c')
0 files changed, 0 insertions, 0 deletions
'n132' href='#n132'>132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177
#============================================================================
# This library is free software; you can redistribute it and/or
# modify it under the terms of version 2.1 of the GNU Lesser General Public
# License as published by the Free Software Foundation.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#============================================================================
# Copyright (C) 2004, 2005 Mike Wray <mike.wray@hp.com>
#============================================================================

import traceback
from StringIO import StringIO

from xen.web import http

from xen.xend import sxp
from xen.xend import XendDomain
from xen.xend.Args import FormFn
from xen.xend.XendError import XendError
from xen.xend.XendLogging import log

from xen.web.SrvDir import SrvDir
from SrvDomain import SrvDomain

class SrvDomainDir(SrvDir):
    """Service that manages the domain directory.
    """

    def __init__(self):
        SrvDir.__init__(self)
        self.xd = XendDomain.instance()

    def domain(self, x):
        val = None
        dom = self.xd.domain_lookup_by_name(x)
        if not dom:
            raise XendError('No such domain ' + str(x))
        val = SrvDomain(dom)
        return val

    def get(self, x):
        v = SrvDir.get(self, x)
        if v is not None:
            return v
        v = self.domain(x)
        return v

    def op_create(self, op, req):
        """Create a domain.
        Expects the domain config in request parameter 'config' in SXP format.
        """
        ok = 0
        errmsg = ''
        try:
            configstring = req.args.get('config')[0]
            #print 'op_create>', 'config:', configstring
            pin = sxp.Parser()
            pin.input(configstring)
            pin.input_eof()
            config = pin.get_val()
            ok = 1
        except Exception, ex:
            print 'op_create> Exception in config', ex
            traceback.print_exc()
            errmsg = 'Configuration error ' + str(ex)
        except sxp.ParseError, ex:
            errmsg = 'Invalid configuration ' + str(ex)
        if not ok:
            raise XendError(errmsg)
        try:
            dominfo = self.xd.domain_create(config)
            return self._op_create_cb(dominfo, configstring, req)
        except Exception, ex:
            print 'op_create> Exception creating domain:'
            traceback.print_exc()
            raise XendError("Error creating domain: " + str(ex))

    def _op_create_cb(self, dominfo, configstring, req):
        """Callback to handle domain creation.
        """
        dom = dominfo.getName()
        domurl = "%s/%s" % (req.prePathURL(), dom)
        req.setResponseCode(http.CREATED, "created")