summaryrefslogtreecommitdiffstats
path: root/configs/libretech-cc_v2_defconfig
diff options
context:
space:
mode:
Diffstat (limited to 'configs/libretech-cc_v2_defconfig')
-rw-r--r--configs/libretech-cc_v2_defconfig10
1 files changed, 3 insertions, 7 deletions
diff --git a/configs/libretech-cc_v2_defconfig b/configs/libretech-cc_v2_defconfig
index e71f88edae..017e81bb5d 100644
--- a/configs/libretech-cc_v2_defconfig
+++ b/configs/libretech-cc_v2_defconfig
@@ -1,25 +1,24 @@
CONFIG_ARM=y
CONFIG_ARCH_MESON=y
CONFIG_SYS_TEXT_BASE=0x01000000
+CONFIG_NR_DRAM_BANKS=1
CONFIG_ENV_SIZE=0x2000
CONFIG_ENV_OFFSET=0xFFFF0000
CONFIG_ENV_SECT_SIZE=0x10000
CONFIG_DM_GPIO=y
CONFIG_MESON_GXL=y
-CONFIG_NR_DRAM_BANKS=1
CONFIG_DEBUG_UART_BASE=0xc81004c0
CONFIG_DEBUG_UART_CLOCK=24000000
CONFIG_IDENT_STRING=" libretech-cc-v2"
+CONFIG_DEFAULT_DEVICE_TREE="meson-gxl-s905x-libretech-cc-v2"
CONFIG_DEBUG_UART=y
CONFIG_OF_BOARD_SETUP=y
CONFIG_USE_PREBOOT=y
-CONFIG_PREBOOT="usb start"
-CONFIG_MISC_INIT_R=y
# CONFIG_DISPLAY_CPUINFO is not set
# CONFIG_DISPLAY_BOARDINFO is not set
+CONFIG_MISC_INIT_R=y
# CONFIG_CMD_BDI is not set
# CONFIG_CMD_IMI is not set
-CONFIG_CMD_ADC=y
CONFIG_CMD_GPIO=y
# CONFIG_CMD_LOADS is not set
CONFIG_CMD_MMC=y
@@ -27,9 +26,7 @@ CONFIG_CMD_SPI=y
CONFIG_CMD_USB=y
CONFIG_CMD_USB_MASS_STORAGE=y
# CONFIG_CMD_SETEXPR is not set
-CONFIG_CMD_REGULATOR=y
CONFIG_OF_CONTROL=y
-CONFIG_DEFAULT_DEVICE_TREE="meson-gxl-s905x-libretech-cc-v2"
CONFIG_ENV_IS_IN_SPI_FLASH=y
CONFIG_SYS_RELOC_GD_ENV_ADDR=y
CONFIG_NET_RANDOM_ETHADDR=y
@@ -52,7 +49,6 @@ CONFIG_PINCTRL=y
CONFIG_PINCTRL_MESON_GXL=y
CONFIG_POWER_DOMAIN=y
CONFIG_MESON_GX_VPU_POWER_DOMAIN=y
-CONFIG_DM_REGULATOR_FIXED=y
CONFIG_DM_RESET=y
CONFIG_DEBUG_UART_ANNOUNCE=y
CONFIG_DEBUG_UART_SKIP_INIT=y
id='n154' href='#n154'>154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489
"""
Command line interface for cobbler, a network provisioning configuration
library.  Consult 'man cobbler' for general info.  This class serves
as a good reference on how to drive the API (api.py).

Copyright 2006, Red Hat, Inc
Michael DeHaan <mdehaan@redhat.com>

This software may be freely redistributed under the terms of the GNU
general public license.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
"""

import sys
import api
import os
import os.path

import cobbler_msg
import cexceptions

LOCKING_ENABLED = False
LOCKFILE="/var/lib/cobbler/lock"

class BootCLI:


    def __init__(self,args):
        """
        Build the command line parser and API instances, etc.
        """
        self.args = args
        self.api = api.BootAPI()
        self.commands = {}
        self.commands['distro'] = {
            'add'     :  self.distro_edit,
            'edit'    :  self.distro_edit,
            'delete'  :  self.distro_remove,
            'remove'  :  self.distro_remove,
            'list'    :  self.distro_list,
            'report'  :  self.distro_report
        }
        self.commands['profile'] = {
            'add'     :  self.profile_edit,
            'edit'    :  self.profile_edit,
            'delete'  :  self.profile_remove,
            'remove'  :  self.profile_remove,
            'list'    :  self.profile_list,
            'report'  :  self.profile_report
        }
        self.commands['system'] = {
            'add'     :  self.system_edit,
            'edit'    :  self.system_edit,
            'delete'  :  self.system_remove,
            'remove'  :  self.system_remove,
            'list'    :  self.system_list,
            'report'  :  self.system_report
        }
        self.commands['repo'] = {
            'add'     :  self.repo_edit,
            'edit'    :  self.repo_edit,
            'delete'  :  self.repo_remove,
            'remove'  :  self.repo_remove,
            'list'    :  self.repo_list,
            'report'  :  self.repo_report,
            'sync'    :  self.reposync
        }
        self.commands['toplevel'] = {
            'check'        : self.check,
            'list'         : self.list,
            'report'       : self.report,
            'distros'      : self.distro,
            'distro'       : self.distro,
            'profiles'     : self.profile,
            'profile'      : self.profile,
            'systems'      : self.system,
            'system'       : self.system,
            'repos'        : self.repo,
            'repo'         : self.repo,
            'sync'         : self.sync,
            'reposync'     : self.reposync,
            'import'       : self.import_tree,
            'enchant'      : self.enchant,
            'clobber'      : self.enchant,
            'transmogrify' : self.enchant,
            'help'         : self.usage,
            '--help'       : self.usage,
            '/?'           : self.usage
        }

    def run(self):
        """
        Run the command line and return system exit code
        """
        self.api.deserialize()
        self.curry_args(self.args[1:], self.commands['toplevel'])

    def usage(self,args):
        """
        Print out abbreviated help if user gives bad syntax
        """
        print cobbler_msg.USAGE

    def list(self,args):
        args.append("") # filler
        for a in args:
            if a == '--distros' or len(args) == 1:
                print "Distros:"
                self.distro_list([])
            if a == '--repos' or len(args) == 1:
                print "Repos:"
                self.repo_list([])
            if a == '--profiles' or len(args) == 1:
                print "Profiles:"
                self.profile_list([])
            if a == '--systems' or len(args) == 1:
                print "Systems:"
                self.system_list([])

    def __sorter(self, a, b):
        return cmp(a.name, b.name)

    def __print_sorted(self, collection):
        collection = [x for x in collection]
        collection.sort(self.__sorter)
        for x in collection:
            print x.printable()

    def distro_report(self,args):
        self.__print_sorted(self.api.distros())
        return True

    def system_report(self,args):
        self.__print_sorted(self.api.systems())
        return True

    def profile_report(self,args):
        self.__print_sorted(self.api.profiles())
        return True

    def repo_report(self,args):
        self.__print_sorted(self.api.repos())
        return True

    def report(self,args):

        args.append("") # filler

        for a in args:
            if a == '--distros' or len(args) == 1:
                self.distro_report([])
            if a == '--repos' or len(args) == 1:
                self.repo_report([])
            if a == '--profiles' or len(args) == 1:
                self.profile_report([])
            if a == '--systems' or len(args) == 1:
                self.system_report([])

    def system_remove(self,args):
        """
        Delete a system:  'cobbler system remove --name=foo'
        """
        commands = {
           '--name'       : lambda(a):  self.api.systems().remove(a),
           '--system'     : lambda(a):  self.api.systems().remove(a),
        }
        on_ok = lambda: True
        return self.apply_args(args,commands,on_ok)

    def __list_names(self, collection):
        names = [ x.name for x in collection]
        names.sort() # sorted() is 2.4 only
        for name in names:
           print "   %s" % name
        return True

    def system_list(self, args):
        return self.__list_names(self.api.systems())
    
    def distro_list(self, args):
        return self.__list_names(self.api.distros())
    
    def profile_list(self, args):
        return self.__list_names(self.api.profiles())
    
    def repo_list(self, args):
        return self.__list_names(self.api.repos())
  
    def profile_remove(self,args):
        """
        Delete a profile:   'cobbler profile remove --name=foo'
        """
        commands = {
           '--name'       : lambda(a):  self.api.profiles().remove(a),
           '--profile'    : lambda(a):  self.api.profiles().remove(a)
        }
        on_ok = lambda: True
        return self.apply_args(args,commands,on_ok)


    def distro_remove(self,args):
        """
        Delete a distro:  'cobbler distro remove --name='foo'
        """
        commands = {
           '--name'     : lambda(a):  self.api.distros().remove(a),
           '--distro'   : lambda(a):  self.api.distros().remove(a)
        }
        on_ok = lambda: True
        return self.apply_args(args,commands,on_ok)

    def repo_remove(self,args):
        """
        Delete a repo:  'cobbler repo remove --name='foo'
        """
        commands = {
           '--name'   : lambda(a):  self.api.repos().remove(a),
           '--repo'   : lambda(a):  self.api.repos().remove(a)
        }
        on_ok = lambda: True
        return self.apply_args(args,commands,on_ok)

    def enchant(self,args):
        """
        Reinstall a system:
        'cobbler system enchant --name='foo' [--password='foo']
        """
        self.temp_profile = None
        self.temp_system = None
        self.temp_address = None
        self.is_virt = False
        def set_is_virt(a):
           if a.lower() in [ "1", "true", "yes", "y", "on" ]:
               self.is_virt = True
               return True
           elif a.lower() not in [ "0", "false", "no", "n", "off" ]:
               return False
        def set_profile(a):
           self.temp_profile = a
           return True
        def set_system(a):
           self.temp_system = a
           return True
        def set_address(a):
           self.temp_address = a
           return True
        def go_enchant():
           return self.api.enchant(self.temp_address,self.temp_profile,self.temp_system,self.is_virt)
        commands = {
           '--address'  :  lambda(a): set_address(a),
           '--profile'  :  lambda(a): set_profile(a),
           '--system'   :  lambda(a): set_system(a),
           '--virt'     :  lambda(a): set_is_virt(a)
        }
        on_ok = lambda: go_enchant()
        return self.apply_args(args,commands,on_ok)

    def import_tree(self,args):
        """
        Import a directory tree and auto-create distros & profiles.
        'cobbler
        """
        self.temp_path = None
        self.temp_mirror = None
        self.temp_mirror_name = None
        def set_mirror_name(a):
            self.temp_mirror_name = a
        def set_mirror(a):
            self.temp_mirror = a
        def set_path(a):
            if os.path.isdir(a):
                self.temp_path = a
                return True
            return False
        def go_import():
            return self.api.import_tree(self.temp_path,
                self.temp_mirror,
                self.temp_mirror_name)
        commands = {
            '--path'         : lambda(a): set_path(a),
            '--mirror'       : lambda(a): set_mirror(a),
            '--mirror-name'  : lambda(a): set_mirror_name(a),
            '--name'         : lambda(a): set_mirror_name(a)
        }
        on_ok = lambda: go_import()
        return self.apply_args(args,commands,on_ok)

    def system_edit(self,args):
        """
        Create/Edit a system:  'cobbler system edit --name='foo' ...
        """
        sys = self.api.new_system()
        commands = {
           '--name'        :  lambda(a) : sys.set_name(a),
           '--system'      :  lambda(a) : sys.set_name(a),
           '--profile'     :  lambda(a) : sys.set_profile(a),
           '--kopts'       :  lambda(a) : sys.set_kernel_options(a),
           '--ksmeta'      :  lambda(a) : sys.set_ksmeta(a),
           '--pxe-address' :  lambda(a) : sys.set_pxe_address(a)
        }
        on_ok = lambda: self.api.systems().add(sys)
        return self.apply_args(args,commands,on_ok)


    def profile_edit(self,args):
        """
        Create/Edit a profile:  'cobbler profile edit --name='foo' ...
        """
        profile = self.api.new_profile()
        commands = {
            '--name'            :  lambda(a) : profile.set_name(a),
            '--profile'         :  lambda(a) : profile.set_name(a),
            '--distro'          :  lambda(a) : profile.set_distro(a),
            '--kickstart'       :  lambda(a) : profile.set_kickstart(a),
            '--kick-start'      :  lambda(a) : profile.set_kickstart(a),
            '--kopts'           :  lambda(a) : profile.set_kernel_options(a),
            '--xen-name'        :  lambda(a) : profile.set_virt_name(a),
            '--virt-name'       :  lambda(a) : profile.set_virt_name(a),
            '--xen-file-size'   :  lambda(a) : profile.set_virt_file_size(a),
            '--virt-file-size'  :  lambda(a) : profile.set_virt_file_size(a),
            '--xen-ram'         :  lambda(a) : profile.set_virt_ram(a),
            '--virt-ram'        :  lambda(a) : profile.set_virt_ram(a),
            '--ksmeta'          :  lambda(a) : profile.set_ksmeta(a),
            '--repos'           :  lambda(a) : profile.set_repos(a)
        }
        on_ok = lambda: self.api.profiles().add(profile)
        return self.apply_args(args,commands,on_ok)

    def repo_edit(self,args):
        """
        Create/edit a repo:  'cobbler repo add --name='foo' ...
        """
        repo = self.api.new_repo()
        commands = {
           '--name'             :  lambda(a): repo.set_name(a),
           '--mirror-name'      :  lambda(a): repo.set_name(a),
           '--mirror'           :  lambda(a): repo.set_mirror(a),
           '--keep-updated'     :  lambda(a): repo.set_keep_updated(a),
           '--local-filename'   :  lambda(a): repo.set_local_filename(a)
        }
        on_ok = lambda: self.api.repos().add(repo)
        return self.apply_args(args,commands,on_ok)

    def distro_edit(self,args):
        """
        Create/Edit a distro:  'cobbler distro edit --name='foo' ...
        """
        distro = self.api.new_distro()
        commands = {
            '--name'      :  lambda(a) : distro.set_name(a),
            '--distro'    :  lambda(a) : distro.set_name(a),
            '--kernel'    :  lambda(a) : distro.set_kernel(a),
            '--initrd'    :  lambda(a) : distro.set_initrd(a),
            '--kopts'     :  lambda(a) : distro.set_kernel_options(a),
            '--arch'      :  lambda(a) : distro.set_arch(a),
            '--ksmeta'    :  lambda(a) : distro.set_ksmeta(a)
        }
        on_ok = lambda: self.api.distros().add(distro)
        return self.apply_args(args,commands,on_ok)


    def apply_args(self,args,input_routines,on_ok):
        """
        Custom CLI handling, instead of getopt/optparse.
        Parses arguments of the form --foo=bar.
        'on_ok' is a callable that is run if all arguments are parsed
        successfully.  'input_routines' is a dispatch table of routines
        that parse the arguments.  See distro_edit for an example.
        """
        if len(args) == 0:
            raise cexceptions.CobblerException("no_args")
        for x in args:
            try:
                key, value = x.split("=",1)
                value = value.replace('"','').replace("'",'')
            except:
                raise cexceptions.CobblerException("bad_arg",x)
            if input_routines.has_key(key):
                input_routines[key](value)
            else:
                raise cexceptions.CobblerException("weird_arg", key)
        on_ok()
        self.api.serialize()

    def curry_args(self, args, commands):
        """
        Lookup command args[0] in the dispatch table and
        feed it the remaining args[1:-1] as arguments.
        """
        if args is None or len(args) == 0:
            print cobbler_msg.USAGE
            return True
        if args[0] in commands:
            commands[args[0]](args[1:])
        else:
            raise cexceptions.CobblerException("unknown_cmd", args[0])
        return True

    def sync(self, args):
        """
        Sync the config file with the system config: 'cobbler sync [--dryrun]'
        """
        status = None
        if args is not None and ("--dryrun" in args or "-n" in args):
            status = self.api.sync(dryrun=True)
        else:
            status = self.api.sync(dryrun=False)
        return status

    def reposync(self, args):
        """
        Sync the repo-specific portions of the config with the filesystem.
        'cobbler reposync'.  Intended to be run on cron.
        """
        status = None
        if args is not None and ("--dryrun" in args or "-n" in args):
            status = self.api.reposync(dryrun=True)
        else:
            status = self.api.reposync(dryrun=False)
        return status

    def check(self,args):
        """
        Check system for network boot decency/prereqs: 'cobbler check'
        """
        status = self.api.check()
        if len(status) == 0:
            print cobbler_msg.lookup("check_ok")
            return True
        else:
            print cobbler_msg.lookup("need_to_fix")
            for i,x in enumerate(status):
               print "#%d: %s" % (i,x)
            return False

    def distro(self,args):
        """
        Handles any of the 'cobbler distro' subcommands
        """
        return self.curry_args(args, self.commands['distro'])

    def profile(self,args):
        """
        Handles any of the 'cobbler profile' subcommands
        """
        return self.curry_args(args, self.commands['profile'])

    def system(self,args):
        """
        Handles any of the 'cobbler system' subcommands
        """
        return self.curry_args(args, self.commands['system'])

    def repo(self,args):
        """
        Handles any of the 'cobbler repo' subcommands
        """
        return self.curry_args(args, self.commands['repo'])

def main():
    """
    CLI entry point
    """
    exitcode = 0
    try:
        if LOCKING_ENABLED:
            if os.path.exists(LOCKFILE):
                raise cexceptions.CobblerException("lock")
            try:
                lockfile = open(LOCKFILE,"w+")
            except:
                raise cexceptions.CobblerException("no_create",LOCKFILE)
            lockfile.close()
        BootCLI(sys.argv).run()
    except cexceptions.CobblerException, exc:
        print str(exc)[1:-1]  # remove framing air quotes
        exitcode = 1
    if LOCKING_ENABLED:
        try:
            os.remove(LOCKFILE)
        except:
            pass
    return exitcode

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