コード例 #1
0
ファイル: componentwatcher.py プロジェクト: kgrvamsi/gantryd
    def __init__(self, component, project_name, machine_id, etcd_client):
        self.component = component
        self.project_name = project_name
        self.machine_id = machine_id
        self.is_running = False

        # Logging.
        self.logger = logging.getLogger(__name__)

        # Setup the state helper for the component.
        self.state = ComponentState(project_name, component, etcd_client)

        # Setup the watcher thread.
        self.watcher_thread = threading.Thread(target=self.waitForCommand,
                                               args=[])
        self.watcher_thread.daemon = True

        # Setup the monitor thread.
        self.monitor_thread = threading.Thread(target=self.monitorComponent,
                                               args=[])
        self.monitor_thread.daemon = True

        # Setup an event to ping the monitor thread when it should restart checking in
        # on the component.
        self.monitor_event = threading.Event()

        # Setup a lock to prevent multiple threads from trying to (re)start a container.
        self.update_lock = threading.Lock()
コード例 #2
0
    def listStatus(self):
        """ Lists the status of all components in this project. """
        self.getConfig()
        self.initialize([c.name for c in self.config.components])

        print "%-20s %-20s %-20s" % ('COMPONENT', 'STATUS', 'IMAGE ID')
        for component in self.components:
            state = ComponentState(self.project_name, component,
                                   self.etcd_client).getState()
            status = ComponentState.getStatusOf(state)
            imageid = ComponentState.getImageIdOf(state)
            print "%-20s %-20s %-20s" % (component.getName(), status, imageid)
コード例 #3
0
    def stopComponents(self, component_names):
        """ Tells all the given components on all systems to stop. """
        self.initialize(component_names)

        report('Marking components as stopped', project=self.project_name)
        for component in self.components:
            report('Marking component as stopped',
                   project=self.project_name,
                   component=component,
                   level=ReportLevels.EXTRA)
            state = ComponentState(self.project_name, component,
                                   self.etcd_client)
            state.setStatus(STOPPED_STATUS)
コード例 #4
0
    def markUpdated(self, component_names):
        """ Tells all the given components to update themselves. """
        self.initialize(component_names)

        report('Updating the image IDs on components',
               project=self.project_name)
        for component in self.components:
            image_id = component.getImageId()
            state = ComponentState(self.project_name, component,
                                   self.etcd_client)

            report('Component %s->%s' % (component.getName(), image_id[0:12]),
                   project=self.project_name,
                   component=component)
            state.setReadyStatus(image_id)