本文整理汇总了Python中buildbot.worker.AbstractLatentWorker类的典型用法代码示例。如果您正苦于以下问题:Python AbstractLatentWorker类的具体用法?Python AbstractLatentWorker怎么用?Python AbstractLatentWorker使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AbstractLatentWorker类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(
self,
name,
password,
docker_host,
image=None,
command=None,
volumes=None,
dockerfile=None,
version=None,
tls=None,
followStartupLogs=False,
masterFQDN=None,
hostconfig=None,
networking_config="bridge",
**kwargs
):
if not client:
config.error("The python module 'docker-py>=1.4' is needed to use a" " DockerLatentWorker")
if not image and not dockerfile:
config.error("DockerLatentWorker: You need to specify at least" " an image name, or a dockerfile")
self.volumes = volumes or []
self.binds = {}
self.networking_config = networking_config
self.followStartupLogs = followStartupLogs
# Following block is only for checking config errors,
# actual parsing happens in self.parse_volumes()
# Renderables can be direct volumes definition or list member
if isinstance(volumes, list):
for volume_string in volumes or []:
if not isinstance(volume_string, str):
continue
try:
volume, bind = volume_string.split(":", 1)
except ValueError:
config.error("Invalid volume definition for docker " "%s. Skipping..." % volume_string)
continue
# Set build_wait_timeout to 0 if not explicitely set: Starting a
# container is almost immediate, we can affort doing so for each build.
if "build_wait_timeout" not in kwargs:
kwargs["build_wait_timeout"] = 0
AbstractLatentWorker.__init__(self, name, password, **kwargs)
self.image = image
self.command = command or []
self.dockerfile = dockerfile
if masterFQDN is None:
masterFQDN = socket.getfqdn()
self.masterFQDN = masterFQDN
self.hostconfig = hostconfig or {}
# Prepare the parameters for the Docker Client object.
self.client_args = {"base_url": docker_host}
if version is not None:
self.client_args["version"] = version
if tls is not None:
self.client_args["tls"] = tls
示例2: checkConfig
def checkConfig(self, name, password, hyper_host,
hyper_accesskey, hyper_secretkey, image, hyper_size="s3", masterFQDN=None, **kwargs):
AbstractLatentWorker.checkConfig(self, name, password, **kwargs)
if not Hyper:
config.error("The python modules 'docker-py>=1.4' and 'hyper_sh' are needed to use a"
" HyperLatentWorker")
if hyper_size not in self.ALLOWED_SIZES:
config.error("Size is not valid %s vs %r".format(
hyper_size, self.ALLOWED_SIZES))
示例3: checkConfig
def checkConfig(self, name, password=None, image=None,
masterFQDN=None, **kwargs):
# Set build_wait_timeout to 0 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
if image is not None and not isinstance(image, str):
if not hasattr(image, 'getRenderingFor'):
config.error("image must be a string")
AbstractLatentWorker.checkConfig(self, name, password, **kwargs)
示例4: __init__
def __init__(self, name, password,
flavor,
os_username,
os_password,
os_tenant_name,
os_auth_url,
os_user_domain=None,
os_project_domain=None,
block_devices=None,
region=None,
image=None,
meta=None,
# Have a nova_args parameter to allow passing things directly
# to novaclient.
nova_args=None,
client_version='2',
**kwargs):
if not client:
config.error("The python module 'novaclient' is needed "
"to use a OpenStackLatentWorker. "
"Please install 'python-novaclient' package.")
if not loading or not session:
config.error("The python module 'keystoneauth1' is needed "
"to use a OpenStackLatentWorker. "
"Please install the 'keystoneauth1' package.")
if not block_devices and not image:
raise ValueError('One of block_devices or image must be given')
AbstractLatentWorker.__init__(self, name, password, **kwargs)
self.flavor = flavor
self.client_version = client_version
if client:
self.novaclient = self._constructClient(
client_version, os_username, os_user_domain, os_password, os_tenant_name, os_project_domain,
os_auth_url)
if region is not None:
self.novaclient.client.region_name = region
if block_devices is not None:
self.block_devices = [
self._parseBlockDevice(bd) for bd in block_devices]
else:
self.block_devices = None
self.image = image
self.meta = meta
self.nova_args = nova_args if nova_args is not None else {}
示例5: __init__
def __init__(self, name, password, docker_host, image=None, command=None,
volumes=None, dockerfile=None, version=None, tls=None, followStartupLogs=False,
masterFQDN=None, hostconfig=None, networking_config='bridge', **kwargs):
if not client:
config.error("The python module 'docker-py>=1.4' is needed to use a"
" DockerLatentWorker")
if not image and not dockerfile:
config.error("DockerLatentWorker: You need to specify at least"
" an image name, or a dockerfile")
self.volumes = []
self.binds = {}
self.networking_config = networking_config
self.followStartupLogs = followStartupLogs
for volume_string in (volumes or []):
try:
volume, bind = volume_string.split(":", 1)
except ValueError:
config.error("Invalid volume definition for docker "
"%s. Skipping..." % volume_string)
continue
self.volumes.append(volume)
ro = False
if bind.endswith(':ro') or bind.endswith(':rw'):
ro = bind[-2:] == 'ro'
bind = bind[:-3]
self.binds[volume] = {'bind': bind, 'ro': ro}
# Set build_wait_timeout to 0 if not explicitely set: Starting a
# container is almost immediate, we can affort doing so for each build.
if 'build_wait_timeout' not in kwargs:
kwargs['build_wait_timeout'] = 0
AbstractLatentWorker.__init__(self, name, password, **kwargs)
self.image = image
self.command = command or []
self.dockerfile = dockerfile
if masterFQDN is None:
masterFQDN = socket.getfqdn()
self.masterFQDN = masterFQDN
self.hostconfig = hostconfig or {}
# Prepare the parameters for the Docker Client object.
self.client_args = {'base_url': docker_host}
if version is not None:
self.client_args['version'] = version
if tls is not None:
self.client_args['tls'] = tls
示例6: checkConfig
def checkConfig(self, name, password, hyper_host,
hyper_accesskey, hyper_secretkey, image, hyper_size="xs", masterFQDN=None, **kwargs):
# Set build_wait_timeout to 0s if not explicitely set: Starting a
# container is almost immediate, we can affort doing so for each build.
if 'build_wait_timeout' not in kwargs:
kwargs['build_wait_timeout'] = 0
AbstractLatentWorker.checkConfig(self, name, password, **kwargs)
if not Hyper:
config.error("The python modules 'docker-py>=1.4' and 'hypercompose' are needed to use a"
" HyperLatentWorker")
if hyper_size not in self.ALLOWED_SIZES:
config.error("Size is not valid %s vs %r".format(hyper_size, self.ALLOWED_SIZES))
示例7: reconfigService
def reconfigService(self, name, password, hyper_host,
hyper_accesskey, hyper_secretkey, image, hyper_size="xs", masterFQDN=None, **kwargs):
AbstractLatentWorker.reconfigService(self, name, password, **kwargs)
self.size = hyper_size
self.image = image
# Prepare the parameters for the Docker Client object.
self.client_args = {'clouds': {
hyper_host: {
"accesskey": hyper_accesskey,
"secretkey": hyper_secretkey
}
}}
if not masterFQDN: # also match empty string (for UI)
masterFQDN = socket.getfqdn()
self.masterFQDN = masterFQDN
示例8: __init__
def __init__(self, name, password, connection, hd_image, base_image=None, xml=None,
**kwargs):
AbstractLatentWorker.__init__(self, name, password, **kwargs)
if not libvirt:
config.error(
"The python module 'libvirt' is needed to use a LibVirtWorker")
self.connection = connection
self.image = hd_image
self.base_image = base_image
self.xml = xml
self.cheap_copy = True
self.graceful_shutdown = False
self.domain = None
self.ready = False
self._find_existing_deferred = self._find_existing_instance()
示例9: reconfigService
def reconfigService(self, name, password=None, image=None,
masterFQDN=None, **kwargs):
# Set build_wait_timeout to 0 if not explicitely 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
if password is None:
password = self.getRandomPass()
self.image = image
return AbstractLatentWorker.reconfigService(self, name, password, **kwargs)
示例10: stopService
def stopService(self):
# stopService will call stop_instance if the worker was up.
yield AbstractLatentWorker.stopService(self)
# we cleanup our thread and session (or reactor.stop will hang)
if self.client is not None:
self.client.close()
self.client = None
if self.threadPool is not None:
yield self.threadPool.stop()
self.threadPool = None
示例11: canStartBuild
def canStartBuild(self):
if not self.ready:
log.msg("Not accepting builds as existing domains not iterated")
return False
if self.domain and not self.isConnected():
log.msg(
"Not accepting builds as existing domain but worker not connected")
return False
return AbstractLatentWorker.canStartBuild(self)
示例12: reconfigService
def reconfigService(self, name, password=None, image=None,
masterFQDN=None, **kwargs):
# Set build_wait_timeout to 0 if not explicitely 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
if password is None:
password = self.getRandomPass()
if masterFQDN is None:
masterFQDN = socket.getfqdn()
self.masterFQDN = masterFQDN
self.image = image
self.masterhash = hashlib.sha1(self.master.name).hexdigest()[:6]
return AbstractLatentWorker.reconfigService(self, name, password, **kwargs)
示例13: reconfigService
def reconfigService(self, name, password, hyper_host,
hyper_accesskey, hyper_secretkey, image, hyper_size="s3", masterFQDN=None, **kwargs):
# Set build_wait_timeout to 0s if not explicitely set: Starting a
# container is almost immediate, we can affort doing so for each build.
if 'build_wait_timeout' not in kwargs:
kwargs['build_wait_timeout'] = 0
yield AbstractLatentWorker.reconfigService(self, name, password, **kwargs)
self.manager = yield HyperLatentManager.getService(self.master, hyper_host, hyper_accesskey,
hyper_secretkey)
self.masterhash = hashlib.sha1(self.master.name).hexdigest()[:6]
self.size = hyper_size
self.image = image
if not masterFQDN: # also match empty string (for UI)
masterFQDN = socket.getfqdn()
self.masterFQDN = masterFQDN
示例14: __init__
def __init__(self, name, password, instance_type, ami=None,
valid_ami_owners=None, valid_ami_location_regex=None,
elastic_ip=None, identifier=None, secret_identifier=None,
aws_id_file_path=None, user_data=None, region=None,
keypair_name=None,
security_name=None,
spot_instance=False, max_spot_price=1.6, volumes=None,
placement=None, price_multiplier=1.2, tags=None,
product_description='Linux/UNIX',
subnet_id=None, security_group_ids=None, instance_profile_name=None,
block_device_map=None, session=None,
**kwargs):
if not boto3:
config.error("The python module 'boto3' is needed to use a "
"EC2LatentWorker")
if keypair_name is None:
reportDeprecatedWorkerNameUsage(
"Use of default value of 'keypair_name' of EC2LatentWorker "
"constructor is deprecated. Please explicitly specify value")
keypair_name = 'latent_buildbot_slave'
if security_name is None and not subnet_id:
reportDeprecatedWorkerNameUsage(
"Use of default value of 'security_name' of EC2LatentWorker "
"constructor is deprecated. Please explicitly specify value")
security_name = 'latent_buildbot_slave'
if volumes is None:
volumes = []
if tags is None:
tags = {}
AbstractLatentWorker.__init__(self, name, password, **kwargs)
if security_name and subnet_id:
raise ValueError(
'security_name (EC2 classic security groups) is not supported '
'in a VPC. Use security_group_ids instead.')
if not ((ami is not None) ^
(valid_ami_owners is not None or
valid_ami_location_regex is not None)):
raise ValueError(
'You must provide either a specific ami, or one or both of '
'valid_ami_location_regex and valid_ami_owners')
self.ami = ami
if valid_ami_owners is not None:
if isinstance(valid_ami_owners, integer_types):
valid_ami_owners = (valid_ami_owners,)
else:
for element in valid_ami_owners:
if not isinstance(element, integer_types):
raise ValueError(
'valid_ami_owners should be int or iterable '
'of ints', element)
if valid_ami_location_regex is not None:
if not isinstance(valid_ami_location_regex, string_types):
raise ValueError(
'valid_ami_location_regex should be a string')
else:
# verify that regex will compile
re.compile(valid_ami_location_regex)
if spot_instance and price_multiplier is None and max_spot_price is None:
raise ValueError('You must provide either one, or both, of '
'price_multiplier or max_spot_price')
self.valid_ami_owners = None
if valid_ami_owners:
self.valid_ami_owners = [str(o) for o in valid_ami_owners]
self.valid_ami_location_regex = valid_ami_location_regex
self.instance_type = instance_type
self.keypair_name = keypair_name
self.security_name = security_name
self.user_data = user_data
self.spot_instance = spot_instance
self.max_spot_price = max_spot_price
self.volumes = volumes
self.price_multiplier = price_multiplier
self.product_description = product_description
if None not in [placement, region]:
self.placement = '%s%s' % (region, placement)
else:
self.placement = None
if identifier is None:
assert secret_identifier is None, (
'supply both or neither of identifier, secret_identifier')
if aws_id_file_path is None:
home = os.environ['HOME']
default_path = os.path.join(home, '.ec2', 'aws_id')
if os.path.exists(default_path):
aws_id_file_path = default_path
if aws_id_file_path:
log.msg('WARNING: EC2LatentWorker is using deprecated '
'aws_id file')
with open(aws_id_file_path, 'r') as aws_file:
identifier = aws_file.readline().strip()
secret_identifier = aws_file.readline().strip()
else:
assert aws_id_file_path is None, \
#.........这里部分代码省略.........
示例15: reconfigService
def reconfigService(self, name, _, **kwargs):
AbstractLatentWorker.reconfigService(
self, name, None,
build_wait_timeout=self._controller.build_wait_timeout,
**kwargs)