Ejemplo n.º 1
0
    def __init__(self, depl=None):

        from noronha.db.depl import Deployment  # avoid circular import

        self.LOCALHOST = 'localhost'
        self.ORIGINAL_PORT = OnlineConst.PORT
        self.captain_compass = get_captain_compass()
        self.on_board = am_i_on_board()
        self.open_sea = is_it_open_sea()
        self.depl = depl if depl else Deployment.load()
Ejemplo n.º 2
0
 def port(self):
     
     configured = self.conf.get(self.KEY_PORT, self.DEFAULT_PORT)
     
     if self.native:
         if self.captain.tipe == DockerConst.Managers.SWARM:
             if is_it_open_sea():
                 return self.ORIGINAL_PORT
             else:
                 return configured
         elif self.captain.tipe == DockerConst.Managers.KUBE:
             if self.on_board:
                 return self.ORIGINAL_PORT
             else:
                 return configured
         else:
             raise NotImplementedError("Unrecognized container manager: {}".format(self.captain.tipe))
     else:
         return configured
Ejemplo n.º 3
0
 def host(self):
     
     configured = self.conf.get(self.KEY_HOST, self.DEFAULT_HOST)
     
     if self.native:
         if self.captain.tipe == DockerConst.Managers.SWARM:
             if is_it_open_sea():
                 return self.service_name
             elif self.on_board:
                 return find_bridge_ip()
             else:
                 return self.DEFAULT_HOST
         elif self.captain.tipe == DockerConst.Managers.KUBE:
             if self.on_board:
                 return self.service_name
             else:
                 return self.captain.get_node()
         else:
             raise NotImplementedError("Unrecognized container manager: {}".format(self.captain.tipe))
     else:
         return configured