Esempio n. 1
0
def delete(conversation, hostname):
    server = Server(hostname)

    DroneD.delete(server.droned)

    for app in list(server.apps):
        app.shouldRunOn.discard(server)

    for appinstance in list(server.appinstances):
        AppInstance.delete(appinstance)

    for appversion in list(AppVersion.objects):
        appversion.services.applicableServers.discard(server)

    for scab in list(server.scabs):
        Scab.delete(scab)

    Server.delete(server)

    conversation.say("All serializable references to %s have been deleted" %
                     hostname)

    if server.listed:
        conversation.say(
            "However this server is listed in my server list, you must remove it manually before restarting gov."
        )
Esempio n. 2
0
def delete(conversation, hostname):
  server = Server(hostname)

  DroneD.delete(server.droned)

  for app in list(server.apps):
    app.shouldRunOn.discard(server)

  for appinstance in list(server.appinstances):
    AppInstance.delete(appinstance)

  for appversion in list(AppVersion.objects):
    appversion.services.applicableServers.discard(server)

  for scab in list(server.scabs):
    Scab.delete(scab)

  Server.delete(server)

  conversation.say("All serializable references to %s have been deleted" % hostname)

  if server.listed:
    conversation.say("However this server is listed in my server list, you must remove it manually before restarting gov.")
Esempio n. 3
0
 def __init__(self, hostname):
     self.hostname = hostname
     self.installed = {}
     self.droned = DroneD(self)
     self.manager = ServerManager(self)
Esempio n. 4
0
class Server(Entity):
    implements(IDroneModelServer)
    connectFailure = None
    appinstances = property( lambda self: (i for i in AppInstance.objects if \
            i.server is self) )
    apps = property(lambda self:
                    (a for a in App.objects if self in a.shouldRunOn))
    scabs = property(lambda self:
                     (s for s in Scab.objects if s.server is self))
    unreachable = property(lambda self: self.connectFailure is not None)
    #FIXME this doesn't seem right we should remove it
    installedApps = property(lambda self: set(av.app for av in self.installed))
    debug = False
    serializable = True
    listed = False
    logs = {}

    def __init__(self, hostname):
        self.hostname = hostname
        self.installed = {}
        self.droned = DroneD(self)
        self.manager = ServerManager(self)

    def __getstate__(self):
        installed = {}
        for appversion, configs in self.installed.items():
            av = (appversion.app.name, appversion.version)
            installed[av] = []
            for configpkg in configs:
                cp = (configpkg.name, configpkg.version)
                installed[av].append(cp)

        return {
            'hostname': self.hostname,
            'connectFailure': self.connectFailure,
            'debug': self.debug,
            'installed': installed,
        }

    @staticmethod
    def construct(state):
        server = Server(state['hostname'])
        if state['connectFailure'] != server.connectFailure:
            server.connectFailure = state['connectFailure']
        if state['debug'] != server.debug:
            server.debug = state['debug']
        if 'installed' in state:
            for av, configs in state['installed'].items():
                app, version = App(av[0]), av[1]
                av = AppVersion(app, version)
                server.installed[av] = set(
                    ConfigPackage(*cp) for cp in configs)
        return server

    @staticmethod
    def byName(name):
        if Server.exists(name):
            return Server(name)
        for server in Server.objects:
            if server.hostname.startswith(name):
                return server

    def startPolling(self):
        self.droned.startPolling()

    def stopPolling(self):
        self.droned.stopPolling()
Esempio n. 5
0
 def __init__(self, hostname):
     self.hostname = hostname
     self.installed = {}
     self.droned = DroneD(self)
     self.manager = ServerManager(self)
Esempio n. 6
0
class Server(Entity):
    implements(IDroneModelServer)
    connectFailure = None
    appinstances = property( lambda self: (i for i in AppInstance.objects if \
            i.server is self) )
    apps = property( lambda self: (a for a in App.objects if self in a.shouldRunOn) )
    scabs = property( lambda self: (s for s in Scab.objects if s.server is self) )
    unreachable = property( lambda self: self.connectFailure is not None )
#FIXME this doesn't seem right we should remove it
    installedApps = property( lambda self: set(av.app for av in self.installed) )
    debug = False
    serializable = True
    listed = False
    logs = {}

    def __init__(self, hostname):
        self.hostname = hostname
        self.installed = {}
        self.droned = DroneD(self)
        self.manager = ServerManager(self)

    def __getstate__(self):
        installed = {}
        for appversion,configs in self.installed.items():
            av = (appversion.app.name, appversion.version)
            installed[av] = []
            for configpkg in configs:
                cp = (configpkg.name, configpkg.version)
                installed[av].append(cp)

        return {
            'hostname' : self.hostname,
            'connectFailure' : self.connectFailure,
            'debug' : self.debug,
            'installed' : installed,
        }

    @staticmethod
    def construct(state):
        server = Server( state['hostname'] )
        if state['connectFailure'] != server.connectFailure:
            server.connectFailure = state['connectFailure']
        if state['debug'] != server.debug:
            server.debug = state['debug']
        if 'installed' in state:
            for av,configs in state['installed'].items():
                app, version = App(av[0]), av[1]
                av = AppVersion(app,version)
                server.installed[av] = set( ConfigPackage(*cp) for cp in configs )
        return server

    @staticmethod
    def byName(name):
      if Server.exists(name):
          return Server(name)
      for server in Server.objects:
          if server.hostname.startswith(name):
              return server

    def startPolling(self):
        self.droned.startPolling()

    def stopPolling(self): 
        self.droned.stopPolling()