def checkConfig(self, name, marathon_url, image, marathon_auth=None, marathon_extra_config=None, marathon_app_prefix="buildbot-worker/", masterFQDN=None, **kwargs): super().checkConfig(name, image=image, masterFQDN=masterFQDN, **kwargs) HTTPClientService.checkAvailable(self.__class__.__name__)
def reconfigService(self, name, marathon_url, image, marathon_auth=None, marathon_extra_config=None, marathon_app_prefix="buildbot-worker/", masterFQDN=None, **kwargs): # Set build_wait_timeout to 0s if not explicitly set: Starting a # container is almost immediate, we can afford doing so for each build. if 'build_wait_timeout' not in kwargs: kwargs['build_wait_timeout'] = 0 yield DockerBaseWorker.reconfigService(self, name, image=image, masterFQDN=masterFQDN, **kwargs) self._http = yield HTTPClientService.getService(self.master, marathon_url, auth=marathon_auth) if marathon_extra_config is None: marathon_extra_config = {} self.marathon_extra_config = marathon_extra_config self.marathon_app_prefix = marathon_app_prefix
def reconfigService(self, name, password=None, zone=None, api_username=None, api_password=None, image=None, hostconfig=None, base_url=DEFAULT_BASE_URL, masterFQDN=None, **kwargs): if password is None: password = self.getRandomPass() if masterFQDN is None: masterFQDN = socket.getfqdn() self.masterFQDN = masterFQDN self.image = image if hostconfig is None: hostconfig = {} self.hostconfig = hostconfig self.client = yield HTTPClientService.getService( self.master, base_url, auth=(api_username, api_password), debug=kwargs.get('debug', False)) masterName = util.unicode2bytes(self.master.name) self.masterhash = hashlib.sha1(masterName).hexdigest()[:6] yield AbstractLatentWorker.reconfigService(self, name, password, **kwargs)
def send(self, build): """Send build status to Bitbucket.""" self.description_suffix = '' key, result, _, summary, description = self.gather_data(build) data = { 'state': self.BITBUCKET_STATUS_CORRESP[result], 'key': key, 'name': summary[:255], 'url': build['url'], 'description': description + self.description_suffix, } url = self.forge_url(build) http_service = yield HTTPClientService.getService(self.master, url, auth=(self.login, self.password)) response = yield http_service.post('', json=data) # 200 means that the key already exists # 201 means that the key has been created successfully if response.code not in (200, 201): raise Exception( "{response.code}: unable to send status to Bitbucket: " "{url}\nRequest:\n{request}\nResponse:\n{response.content}". format(request=data, response=response, url=url)) self.logger.info('Bitbucket status sent (%s:%s on %s)' % (self.BITBUCKET_STATUS_CORRESP[result], key, url))
def fetch(self, url): if not self.http_service: self.http_service = yield HTTPClientService.getService(self.master, self.http_url, headers=self.http_headers) result = yield self.http_service.get(url) if result.code != 200: raise Exception("invalid status %d -> %s" % (result.code, url)) json = yield result.json() returnValue(json)
def _prepareRequest(self, ep, kwargs): config = self.config.getConfig() self._base_url = config['master_url'] url, req_kwargs = HTTPClientService._prepareRequest(self, ep, kwargs) # warning: this only works with txrequests! not treq for arg in ['cert', 'verify']: if arg in config: req_kwargs[arg] = self.config[arg] return url, req_kwargs
def _prepareRequest(self, ep, kwargs): config = self.config.getConfig() self._base_url = config['master_url'] url, req_kwargs = HTTPClientService._prepareRequest(self, ep, kwargs) if 'headers' not in req_kwargs: req_kwargs['headers'] = {} if 'headers' in config: req_kwargs['headers'].update(config['headers']) auth = yield self.config.getAuthorization() if auth is not None: req_kwargs['headers']['Authorization'] = auth # warning: this only works with txrequests! not treq for arg in ['cert', 'verify']: if arg in config: req_kwargs[arg] = config[arg] return defer.returnValue((url, req_kwargs))
def reconfigService(self, name, marathon_url, image, marathon_auth=None, marathon_extra_config=None, marathon_app_prefix="buildbot-worker/", masterFQDN=None, **kwargs): # Set build_wait_timeout to 0s if not explicitly set: Starting a # container is almost immediate, we can afford doing so for each build. if 'build_wait_timeout' not in kwargs: kwargs['build_wait_timeout'] = 0 yield super().reconfigService(name, image=image, masterFQDN=masterFQDN, **kwargs) self._http = yield HTTPClientService.getService( self.master, marathon_url, auth=marathon_auth) if marathon_extra_config is None: marathon_extra_config = {} self.marathon_extra_config = marathon_extra_config self.marathon_app_prefix = marathon_app_prefix
def __init__(self, kube_config=None): self.config = kube_config HTTPClientService.__init__(self, '') self._namespace = None self.addService(kube_config)
def __init__(self, kube_config=None): self.config = kube_config HTTPClientService.__init__(self, '') self._namespace = None kube_config.setServiceParent(self)