summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBill Peck <bpeck@redhat.com>2011-03-12 01:57:57 +1000
committerGerrit Code Review <gerrit@maeby.djc.id.au>2011-03-12 01:57:57 +1000
commit321fdee24465cbc46d4239207630c8889b3dc9b7 (patch)
treeb22d3e5aad9551444cdfdffb1fbd389a1eb16684
parentcbdbe353c700f8ae1aeaad1e759eae4d26b8ae08 (diff)
parent42ae49ad96fcb220fb0bcc6048cbb3aa83bf50b0 (diff)
Merge "remove XML-RPC methods for legacy RHTS" into develop
-rw-r--r--Server/bkr/server/controllers.py213
-rw-r--r--Server/bkr/server/distro.py23
2 files changed, 0 insertions, 236 deletions
diff --git a/Server/bkr/server/controllers.py b/Server/bkr/server/controllers.py
index f511cc6..36a4826 100644
--- a/Server/bkr/server/controllers.py
+++ b/Server/bkr/server/controllers.py
@@ -86,88 +86,6 @@ def identity_failure_url(errors):
return '/forbidden?%s' % urllib.urlencode({'reason': errors}, doseq=True)
config.update({'identity.failure_url': identity_failure_url})
-class Netboot:
- # For XMLRPC methods in this class.
- exposed = True
-
- # path for Legacy RHTS
- @cherrypy.expose
- def system_return(self, *args):
- return Root().system_return(*args)
-
- @cherrypy.expose
- def commandBoot(self, commands):
- """
- NetBoot Compat layer for old RHTS Scheduler
- """
- repos = []
- bootargs = None
- kickstart = None
- packages = []
- runtest_url = None
- testrepo = None
- hostname = None
- distro_name = None
- partitions = None
- SETENV = re.compile(r'SetEnvironmentVar\s+([^\s]+)\s+"*([^"]+)')
- BOOTARGS = re.compile(r'BootArgs\s+(.*)')
- KICKSTART = re.compile(r'Kickstart\s+(.*)')
- ADDREPO = re.compile(r'AddRepo\s+([^\s]+)')
- TESTREPO = re.compile(r'TestRepo\s+([^\s]+)')
- INSTALLPACKAGE = re.compile(r'InstallPackage\s+([^\s]+)')
- KICKPART = re.compile(r'KickPart\s+([^\s]+)')
-
- for command in commands.split('\n'):
- if SETENV.match(command):
- if SETENV.match(command).group(1) == "RESULT_SERVER":
- rhts_server = SETENV.match(command).group(2)
- if SETENV.match(command).group(1) == "RECIPEID":
- recipeid = SETENV.match(command).group(2)
- if SETENV.match(command).group(1) == "RUNTEST_URL":
- runtest_url = SETENV.match(command).group(2)
- if SETENV.match(command).group(1) == "HOSTNAME":
- hostname = SETENV.match(command).group(2)
- if SETENV.match(command).group(1) == "INSTALL_NAME":
- distro_name = SETENV.match(command).group(2)
- if KICKPART.match(command):
- partitions = KICKPART.match(command).group(1)
- if INSTALLPACKAGE.match(command):
- packages.append(INSTALLPACKAGE.match(command).group(1))
- if BOOTARGS.match(command):
- bootargs = BOOTARGS.match(command).group(1)
- if KICKSTART.match(command):
- kickstart = string.join(KICKSTART.match(command).group(1).split("RHTSNEWLINE"), "\n")
- if ADDREPO.match(command):
- repos.append(ADDREPO.match(command).group(1))
- if TESTREPO.match(command):
- testrepo = TESTREPO.match(command).group(1)
-
- ks_meta = "rhts_server=%s testrepo=%s recipeid=%s packages=%s" % (rhts_server, testrepo, recipeid, string.join(packages,":"))
- if config.get('test_password'):
- ks_meta = '%s password=%s' % (ks_meta, config.get('test_password'))
- if runtest_url:
- ks_meta = "%s runtest_url=%s" % (ks_meta, runtest_url)
- if repos:
- ks_meta = "%s customrepos=%s" % (ks_meta, string.join(repos,"|"))
- if partitions:
- ks_meta = "%s partitions=%s" % (ks_meta, partitions)
- if distro_name:
- distro = Distro.by_install_name(distro_name)
- else:
- raise BX(_("distro not defined"))
- if hostname:
- system = System.query().filter(System.fqdn == hostname).one()
- system.activity.append(SystemActivity(system.user, 'VIA %s' % None, 'Reserved', 'User', "", "%s" % system.user))
- system.action_auto_provision(distro,
- ks_meta,
- bootargs,
- None,
- kickstart)
- system.activity.append(SystemActivity(system.user, 'VIA %s' % None, 'Provision', 'Distro', "", "Success: %s" % distro.install_name))
- else:
- raise BX(_("hostname not defined"))
- return 0
-
class Arches:
@expose(format='json')
def by_name(self,name):
@@ -281,7 +199,6 @@ class Root(RPCRoot):
activity = Activities()
users = Users()
arches = Arches()
- netboot = Netboot()
auth = Auth()
csv = CSV()
jobs = Jobs()
@@ -1864,136 +1781,6 @@ class Root(RPCRoot):
#@identity.require(identity.in_group("admin"))
def lab_controllers(self, *args):
return [lc.fqdn for lc in LabController.query()]
-
- def pick_common(self, distro=None, user=None, xml=None):
- distro = Distro.by_install_name(distro)
- systems = distro.systems(user)
- #FIXME Should validate XML before processing.
- queries = []
- joins = []
- for child in ElementWrapper(xmltramp.parse(xml)):
- if callable(getattr(child, 'filter')):
- (join, query) = child.filter()
- queries.append(query)
- joins.extend(join)
- if joins:
- systems = systems.filter(and_(*joins))
- if queries:
- systems = systems.filter(and_(*queries))
- return systems
-
- @cherrypy.expose
- def system_pick(self, distro=None, username=None, xml=None):
- if not distro:
- return (None,"You must supply a distro")
- if not username:
- return (None,"You must supply a user name")
- if not xml:
- return (None,"No xml query provided")
-
- user = None
- try:
- # some systems use Bugzilla as auth.
- # This is only temporary and will go away.
- user = User.by_email_address(username)
- except InvalidRequestError:
- username = username.split('@')[0]
- user = User.by_user_name(username)
- if not user:
- return (None, -1)
- systems = self.pick_common(distro, user, xml)
-
- hit = False
- systems_list = systems.all()
- size = len(systems_list)
- while size:
- size = size - 1
- index = random.randint(0, size)
- system = systems_list[index]
- systems_list[index] = systems_list[size]
-
- # If the system doesn't have a current user then take it
- if session.connection(System).execute(system_table.update(
- and_(system_table.c.id==system.id,
- system_table.c.user_id==None)),
- user_id=user.user_id).rowcount == 1:
- hit = True
- break
-
- if hit:
- # We have a match and its available!
- return (dict(fqdn = system.fqdn,
- mac_address = '%s' % system.mac_address), 1)
- elif systems.count():
- # We have matches but none are available right now
- system = systems.first()
- return (dict(fqdn = system.fqdn,
- mac_address = '%s' % system.mac_address), 0)
- else:
- # Nothing matches what the user requested.
- return (None, -1)
-
- @cherrypy.expose
- def system_validate(self, distro=None, username=None, xml=None):
- if not distro:
- return (None,"You must supply a distro")
- if not username:
- return (None,"You must supply a user name")
- if not xml:
- return (None,"No xml query provided")
-
- user = None
- try:
- # some systems use Bugzilla as auth.
- # This is only temporary and will go away.
- user = User.by_email_address(username)
- except InvalidRequestError:
- username = username.split('@')[0]
- user = User.by_user_name(username)
- if not user:
- return (None, -1)
- systems = self.pick_common(distro, user, xml)
-
- if systems.count():
- # We have matches
- system = systems.first()
- return (dict(fqdn = system.fqdn,
- mac_address = '%s' % system.mac_address), 0)
- else:
- # Nothing matches what the user requested.
- return (None, -1)
-
- @cherrypy.expose
- def system_return(self, fqdn=None, full_name=None, mylog=True):
- if not fqdn:
- return (0,"You must supply a system")
- if not full_name:
- return (0,"You must supply a user name")
-
- user = None
- try:
- # some systems use Bugzilla as auth.
- # This is only temporary and will go away.
- user = User.by_email_address(full_name)
- except InvalidRequestError:
- full_name = full_name.split('@')[0]
- user = User.by_user_name(full_name)
- try:
- system = System.by_fqdn(fqdn,user)
- except InvalidRequestError:
- return (0, "Invalid system")
- if system.user == user:
- if mylog:
- system.activity.append(SystemActivity(system.user, "VIA %s" % identity.current.user, "Returned", "User", "%s" % system.user, ''))
- try:
- system.action_release()
- except BX, error:
- msg = "Failed to power off system: %s" % error
- system.activity.append(SystemActivity(system.user, "VIA %s" % identity.current.user, "Off", "Power", "", msg))
- else:
- system.user = None
- return
-
@cherrypy.expose
def legacypush(self, fqdn=None, inventory=None):
diff --git a/Server/bkr/server/distro.py b/Server/bkr/server/distro.py
index 2efd4fd..917e969 100644
--- a/Server/bkr/server/distro.py
+++ b/Server/bkr/server/distro.py
@@ -448,29 +448,6 @@ class Distros(RPCRoot):
distro.tags.remove(tag)
return removed
- @cherrypy.expose
- def pick(self, xml):
- """
- Based on XML passed in filter distro selection
- """
- distros = Distro.by_filter(xml)
- distros = distros.add_column('tree_path').join('lab_controller_assocs')
- distros = distros.add_column('fqdn').join(['lab_controller_assocs','lab_controller'])
- try:
- distro, tree_path, fqdn = distros.first()
- except TypeError:
- return None
- if distro:
- return dict(distro = distro.name,
- install_name = distro.install_name,
- arch = '%s' % distro.arch,
- family = '%s' % distro.osversion,
- variant = distro.variant,
- lab_controller = fqdn,
- tree_path = tree_path)
- else:
- return None
-
default = index
# for sphinx