org.apache.itest.pmanager
Class PackageManager

java.lang.Object
  extended by org.apache.itest.pmanager.PackageManager
All Implemented Interfaces:
groovy.lang.GroovyObject
Direct Known Subclasses:
AptCmdLinePackageManager, YumCmdLinePackageManager, ZypperCmdLinePackageManager

public abstract class PackageManager
extends Object
implements groovy.lang.GroovyObject


Constructor Summary
PackageManager()
           
 
Method Summary
 int addBinRepo(String record, String descr)
          Register a binary package repository so that packages can be accessed from it.
abstract  int addBinRepo(String record, String url, String key, String cookie)
          Register a binary package repository so that packages can be accessed from it.
abstract  int cleanup()
          Clean up the repository cache
abstract  List getContentList(PackageInstance pkg)
          List a content of a given package
 groovy.lang.MetaClass getMetaClass()
           
static PackageManager getPackageManager()
          Returns a concrete implementation of PackageManager specific for the distro where the code is executed (e.g.
static PackageManager getPackageManager(String linux_flavor)
          Returns a concrete implementation of PackageManager specific for a given linux flavor.
 Object getProperty(String name)
           
static String getRepository_registry()
           
abstract  List getServices(PackageInstance pkg)
          Get a list of services (System V init scripts) provided by a given package
 Shell getShRoot()
           
 Shell getShUser()
           
static String getType()
           
abstract  int install(PackageInstance pkg)
          Install a given package (from collection of all the packages available in all the repositories)
 Object invokeMethod(String name, Object args)
           
abstract  boolean isInstalled(PackageInstance pkg)
          Check if a given package is installed on the system
abstract  int refresh()
          Refresh the cached data describing the content of all registered repositories
abstract  int remove(PackageInstance pkg)
          Remove a given package that is already installed on the system
 int removeBinRepo(String record)
          De-register a binary package repository.
abstract  List search(String name, String version)
          Search for a package in all registered repositories
abstract  void setDefaults(String defaults)
          Set package manager specific default values
 void setMetaClass(groovy.lang.MetaClass metaClass)
           
 void setProperty(String name, Object value)
           
static void setRepository_registry(String value)
           
 void setShRoot(Shell value)
           
 void setShUser(Shell value)
           
static void setType(String value)
           
 void svc_do(PackageInstance pkg, String action)
          Deprecated. it is now recommended to use getServices() instead
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PackageManager

public PackageManager()
Method Detail

getType

public static String getType()

setType

public static void setType(String value)

getRepository_registry

public static String getRepository_registry()

setRepository_registry

public static void setRepository_registry(String value)

getShRoot

public Shell getShRoot()

setShRoot

public void setShRoot(Shell value)

getShUser

public Shell getShUser()

setShUser

public void setShUser(Shell value)

setDefaults

public abstract void setDefaults(String defaults)
Set package manager specific default values

Parameters:
defaults - String of default values encoded in a package manager specific way

addBinRepo

public abstract int addBinRepo(String record,
                               String url,
                               String key,
                               String cookie)
Register a binary package repository so that packages can be accessed from it. NOTE: repository management is assumed to follow a KVP API with unique implementation specific keys (records) referencing tuples of information describing a repository

Parameters:
record - a package manager specific KEY portion of the repository registration (null is default)
url - a URL containing the packages constituting the repository (null is default)
key - an optional (can be null) cryptographic key for authenticating the content of the repository
cookie - an optional, package manager specific opaque string
Returns:
int return code of the operation: o in case of success, non-zero otherwise

addBinRepo

public int addBinRepo(String record,
                      String descr)
Register a binary package repository so that packages can be accessed from it. NOTE: repository management is assumed to follow a KVP API with unique implementation specific keys (records) referencing tuples of information describing a repository

Parameters:
record - a package manager specific KEY portion of the repository registration (null is default)
descr - a full description of the repository in a native format
Returns:
int return code of the operation: o in case of success, non-zero otherwise

cleanup

public abstract int cleanup()
Clean up the repository cache

Returns:
int return code of the operation: o in case of success, non-zero otherwise

refresh

public abstract int refresh()
Refresh the cached data describing the content of all registered repositories

Returns:
int return code of the operation: o in case of success, non-zero otherwise

removeBinRepo

public int removeBinRepo(String record)
De-register a binary package repository.

Parameters:
record - a package manager specific KEY portion of the repository registration (null is default)
Returns:
int return code of the operation: o in case of success, non-zero otherwise

search

public abstract List search(String name,
                            String version)
Search for a package in all registered repositories

Parameters:
name - name of the package (inexact matches are ok)
version - a particular version of the package
Returns:
list of matching packages found in all registered repositories (can be empty)

install

public abstract int install(PackageInstance pkg)
Install a given package (from collection of all the packages available in all the repositories)

Parameters:
pkg - a package to be installed
Returns:
int return code of the operation: o in case of success, non-zero otherwise

remove

public abstract int remove(PackageInstance pkg)
Remove a given package that is already installed on the system

Parameters:
pkg - a package to be installed
Returns:
int return code of the operation: o in case of success, non-zero otherwise

isInstalled

public abstract boolean isInstalled(PackageInstance pkg)
Check if a given package is installed on the system

Parameters:
pkg - a package to be checked
Returns:
true if the package is installed and can be used, false otherwise

getServices

public abstract List getServices(PackageInstance pkg)
Get a list of services (System V init scripts) provided by a given package

Parameters:
pkg - a package that is expected to provide 0, 1 or multiple services
Returns:
list of Service instances

getContentList

public abstract List getContentList(PackageInstance pkg)
List a content of a given package

Parameters:
pkg - a package that is expected to provide >1 entry in its content
Returns:
list file and directory names belong to the package.

getPackageManager

public static PackageManager getPackageManager()
Returns a concrete implementation of PackageManager specific for the distro where the code is executed (e.g. this OS)

Returns:
instance of a concrete implementation of PackageManager

svc_do

public void svc_do(PackageInstance pkg,
                   String action)
Deprecated. it is now recommended to use getServices() instead

Operate on services provided by a package (start, stop, status, restart) NOTE: this method assumes that a given package bundles a number of services (daemons) and allows you to operate on these services without requiring an explicit knowledge of their names. If a single package provides multiple services all of them will be operated on simultaneously (you don't get to choose any subsets). If a package doesn't provide any services calling this method is a noop.

Parameters:
pkg - a package that is expected to provide 0, 1 or multiple services
action - what to do with service(s) (start, stop, status, restart)

getPackageManager

public static PackageManager getPackageManager(String linux_flavor)
Returns a concrete implementation of PackageManager specific for a given linux flavor.

Parameters:
linux_flavor - e.g. ubuntu, debian, redhat, centos, etc.
Returns:
instance of a concrete implementation of PackageManager

getMetaClass

public groovy.lang.MetaClass getMetaClass()
Specified by:
getMetaClass in interface groovy.lang.GroovyObject

setMetaClass

public void setMetaClass(groovy.lang.MetaClass metaClass)
Specified by:
setMetaClass in interface groovy.lang.GroovyObject

invokeMethod

public Object invokeMethod(String name,
                           Object args)
Specified by:
invokeMethod in interface groovy.lang.GroovyObject

getProperty

public Object getProperty(String name)
Specified by:
getProperty in interface groovy.lang.GroovyObject

setProperty

public void setProperty(String name,
                        Object value)
Specified by:
setProperty in interface groovy.lang.GroovyObject


Copyright © 2011. All Rights Reserved.