Ejemplo n.º 1
0
 def run(self, cmd, user=None):
     (out, err) = proc = Popen(self._args(cmd), stdout=PIPE).communicate()
     if out is None:
         out = ''
     if err is None:
         err = ''
     info("schroot: out: " + out)
     info("schroot: err: " + err)
     return out
Ejemplo n.º 2
0
    def dut_exec(self, cmd):
        hostname = self.get_cf(['ssh', 'hostname'])
        username = self.get_cf(['ssh', 'username'])
        port = str(self.get_cf(['ssh', 'port']))

        info("executing on DUT: %s" % repr(cmd))

        return (
            call(['ssh', ("%s@%s" % (username, hostname)), '-p', port, '--'] +
                 cmd) == 0)
Ejemplo n.º 3
0
 def load_target(self, name, pool):
     fn = 'cf/targets/%s.yml' % name
     try:
         with open(fn) as f:
             spec = yaml.safe_load(f)
             info("loaded target config: "+fn)
             self._my_targets[name] = TargetSpec(name, pool, self, spec)
     except:
         info("failed to load target config: "+fn)
         self._my_targets[name] = TargetSpec(name, pool, self, {})
     return self._my_targets[name]
Ejemplo n.º 4
0
    def __init__(self, chroot_name, user):
        self.chroot_name = chroot_name
        self.user = user

        ## create a new session
        args = ['schroot', '-b', '-c', chroot_name]
        (out, err) = proc = Popen(args + ['--'], stdout=PIPE).communicate()

        self.session_name = out.strip()
        info("created schroot session: %s [user %s]" %
             (self.session_name, user))
Ejemplo n.º 5
0
    def get_dut(self, name):
        if name in self._my_dut_cache:
            return self._my_dut_cache

        fn = self.get_pathconf('dut-path', 'cf/dut')+"/"+name+".cf"

        with open(fn) as f:
            cf = yaml.safe_load(f)
            info("loaded config: "+fn)
            return DutSpec(name, cf, self)

        raise SpecError("missing dut config: "+fn)
Ejemplo n.º 6
0
 def log_info(self, text):
     info("("+self.name+") "+text)
Ejemplo n.º 7
0
 def remove(self):
     info("removed schroot session: %s" % self.session_name)
     ret = call(['schroot', '-c', self.session_name, '-e', '-f'])
     self.session_name = None
Ejemplo n.º 8
0
 def load_spec(self, fn):
     with open(fn) as f:
         # use safe_load instead load
         self.set_spec(yaml.load(f, yaml.CSafeLoader))
         info("loaded config: " + fn)