Exemplo n.º 1
0
    def __init__(self, **kw):
        self.status = kw.get('status', 'pending')
        self.verdict = kw.get('verdict', 'undef')
        self.ammo_path = kw.get('ammo_path', None)

        for attr in self.attr_required:
            v = kw.get(attr)
            if not v:
                raise ValueError(
                    '*{}* - required parameter missing.'.format(attr))
            setattr(self, attr, v)

        for attr in self.attr_optional:
            setattr(self, attr, kw.get(attr))

        if hasattr(self, 'load_src'):
            self.load_src = HostBuilder.from_addr(unknown_addr=self.load_src).fqdn
        if hasattr(self, 'load_dst'):
            self.load_dst = HostBuilder.from_addr(unknown_addr=self.load_dst).fqdn
Exemplo n.º 2
0
        def proc_tank_el(t):
            if t == 'all':
                return dao_host.get_many(is_tank='True', is_spec_tank='False', per_page=100)[0]

            if isinstance(t, (basestring, unicode)):
                return [HostBuilder.from_addr(unknown_addr=t)]

            if isinstance(t, dict) and t.get('line'):
                line_name = t.get('line')
                return dao_host.get_many(
                    line=line_name, is_tank='True', is_spec_tank='False', per_page=100)[0]

            if isinstance(t, dict) and t.get('dc'):
                dc_name = t.get('dc')
                return dao_host.get_many(
                    dc=dc_name, is_tank='True', is_spec_tank='False', per_page=100)[0]

            raise ValueError('mallformed tank_fqdn cfg entrie:{}'.format(t))