Exemplo n.º 1
0
class CloudManagerManagedLeaseForWrite( object ):

	def __init__( self, hostname ):
		self._cmr	= CloudManagerResolver()
		self._hostname 	= hostname
		self._l_fd 	= self._cmr.get_all_saving_lease_filefd( hostname = self._hostname )
		self._l_f 	= []

	def __enter__( self ):

		for fd in self._l_fd:
			afs = fd.value[ 'fd' ].__enter__()
			self._l_f.append( afs.open( fd.value[ 'saved_leases_filepath' ], 'w' ) )
		return self

	def __exit__( self, t, v, tr ):
	
		if t:
			print tr

		for f in self._l_f:
			f.close()
			self._l_f.remove( f )

		for fd in self._l_fd:
			fd.value[ 'fd' ].__exit__( t, v, tr ) 

	def write( self, l ):
		for f in self._l_f:
			f.write( l )
Exemplo n.º 2
0
    def __init__(self, resolvers=None):

        if hasattr(resolvers, '_resolver'):
            self._resolver = resolvers._resolver
        else:
            self._resolver = CloudManagerResolver()

        if hasattr(resolvers, '_appcode_resolver'):
            self._appcode_resolver = resolvers._appcode_resolver
        else:
            self._appcode_resolver = CloudManagerAppcodeResolver()

        if hasattr(resolvers, '_appcomp_resolver'):
            self._appcomp_resolver = resolvers._appcomp_resolver
        else:
            self._appcomp_resolver = CloudManagerAppCompResolver()

        if hasattr(resolvers, '_env_resolver'):
            self._env_resolver = resolvers._env_resolver
        else:
            self._env_resolver = CloudManagerEnvResolver()

        if hasattr(resolvers, '_aera_resolver'):
            self._aera_resolver = resolvers._aera_resolver
        else:
            self._aera_resolver = CloudManagerAeraResolver()

        if hasattr(resolvers, '_cloudmap_resolver'):
            self._cloudmap_resolver = resolvers.cloudmap_resolver
        else:
            self._cloudmap_resolver = CloudManagerCloudMapResolver()
Exemplo n.º 3
0
class CloudManagerManagedLeaseForWrite(object):
    def __init__(self, hostname):
        self._cmr = CloudManagerResolver()
        self._hostname = hostname
        self._l_fd = self._cmr.get_all_saving_lease_filefd(
            hostname=self._hostname)
        self._l_f = []

    def __enter__(self):

        for fd in self._l_fd:
            afs = fd.value['fd'].__enter__()
            self._l_f.append(afs.open(fd.value['saved_leases_filepath'], 'w'))
        return self

    def __exit__(self, t, v, tr):

        if t:
            print tr

        for f in self._l_f:
            f.close()
            self._l_f.remove(f)

        for fd in self._l_fd:
            fd.value['fd'].__exit__(t, v, tr)

    def write(self, l):
        for f in self._l_f:
            f.write(l)
Exemplo n.º 4
0
class CloudManagerManageDHCPForWrite( object ):

	def __init__( self, hostname ):
		self._cmr		= CloudManagerResolver()
		self._hostname 		= hostname
		self._dhcp_filepath 	= self._cmr.get_dhcp_filepath( hostname = self._hostname )
		self._f 		= None

	def __enter__( self ):
		self._f = open( self._dhcp_filepath, 'w' )
		return self._f

	def __exit__( self, t, v, tr ):
		self._f.close()
		self._f = None
def action_add( *args ):
	# Analyse des paramètres
	hardaddr 	= args[0]
	ip 		= args[1]
	hostname 	= args[2]
	lease_expires 	= os.environ[ 'DNSMASQ_LEASE_EXPIRES' ]
	cmr		= CloudManagerResolver()

	with CloudManagerManagedLeaseForWrite( hostname ) as cml:
		cml.write( '%s %s %s %s *\n' % ( lease_expires, hardaddr, ip, hostname ) )

	with CloudManagerManagedActiveHostsForWrite( hostname ) as cmah:
	        if not domainname:
                	cmah.write( '%s\t\t%s\t# %s\n' % ( ip, hostname, cloudmgr_tags ) )
         	else:
                	cmah.write( '%s\t\t%s.%s %s\t# %s\n' % ( ip, hostname, domainname, hostname, cloudmgr_tags ) )
Exemplo n.º 6
0
	def __init__( self, hostname ):
		self._cmr	= CloudManagerResolver()
		self._hostname 	= hostname
		self._l_fd 	= self._cmr.get_all_saving_lease_filefd( hostname = self._hostname )
		self._l_f 	= []
	def __init__( self ):
		self._cmr 		= CloudManagerResolver()
                self._cached_cloudmap 	= {}
                self._ref_count 	= 0
Exemplo n.º 8
0
 def __init__(self, hostname):
     self._cmr = CloudManagerResolver()
     self._hostname = hostname
     self._l_fd = self._cmr.get_all_saving_lease_filefd(
         hostname=self._hostname)
     self._l_f = []
Exemplo n.º 9
0
	def __init__( self, hostname ):
		self._cmr		= CloudManagerResolver()
		self._hostname 		= hostname
		self._dhcp_filepath 	= self._cmr.get_dhcp_filepath( hostname = self._hostname )
		self._f 		= None