Cesar77RR's picture
download
raw
6.58 kB
import random, binascii, threading, os
def pycc_corrupt_string(string):
if string:
if (random.randint(0, 1) == 0):
hexstring = binascii.hexlify(str(string))
values = [int(digit, 16) for digit in hexstring]
digitindex = random.randint(0, len(values))
bitindex = random.randint(0, 3)
values[(digitindex - 1)] ^= (1 << bitindex)
result = ''.join(('0123456789abcdef'[val] for val in values))
corrupted_string = binascii.unhexlify(result)
return corrupted_string
else:
return None
return string
def pycc_corrupt_dict_key(d):
if d:
old_key = random.choice(d.keys())
corrupted_key = pycc_corrupt(old_key)
d[corrupted_key] = d.pop(old_key)
return d
def pycc_corrupt(target, mode=None):
if isinstance(target, int):
return (-1)
elif isinstance(target, str):
return pycc_corrupt_string(target)
elif isinstance(target, dict):
return pycc_corrupt_dict_key(target)
elif isinstance(target, bool):
return (not target)
else:
return None
pycc_leaked_files = list()
def _pycc_hog_fd():
try:
i = 0
files = []
pycc_leak_file_dir = '/tmp/pycc_file_leak_dir/'
os.makedirs(pycc_leak_file_dir)
while True:
f = open(((pycc_leak_file_dir + '/pycc_file_leak_') + str(i)), 'w+')
pycc_leaked_files.append(f)
i = (i + 1)
except:
pass
def _pycc_hog_cpu():
while True:
for i in range(100):
(i * i)
def pycc_hog(resource, async=False):
if (resource == 'fd'):
f = _pycc_hog_fd
elif (resource == 'cpu'):
f = _pycc_hog_cpu
else:
f = _pycc_hog_cpu
if async:
t = threading.Thread(target=f)
t.start()
else:
f()
'Handles all requests to the conductor service.'
from oslo_log import log as logging
import oslo_messaging as messaging
from nova import baserpc
from nova.conductor import rpcapi
import nova.conf
CONF = nova.conf.CONF
LOG = logging.getLogger(__name__)
class API(object, ):
'Conductor API that does updates via RPC to the ConductorManager.'
def __init__(self):
self.conductor_rpcapi = rpcapi.ConductorAPI()
self.base_rpcapi = baserpc.BaseAPI(topic=CONF.conductor.topic)
def object_backport_versions(self, context, objinst, object_versions):
return self.conductor_rpcapi.object_backport_versions(context, objinst, object_versions)
def wait_until_ready(self, context, early_timeout=10, early_attempts=10):
'Wait until a conductor service is up and running.\n\n This method calls the remote ping() method on the conductor topic until\n it gets a response. It starts with a shorter timeout in the loop\n (early_timeout) up to early_attempts number of tries. It then drops\n back to the globally configured timeout for rpc calls for each retry.\n '
attempt = 0
timeout = early_timeout
has_timedout = False
while True:
if (attempt == early_attempts):
timeout = None
attempt += 1
try:
self.base_rpcapi.ping(context, '1.21 GigaWatts', timeout=timeout)
if has_timedout:
LOG.info('nova-conductor connection established successfully')
break
except messaging.MessagingTimeout:
has_timedout = True
LOG.warning('Timed out waiting for nova-conductor. Is it running? Or did this service start before nova-conductor? Reattempting establishment of nova-conductor connection...')
class ComputeTaskAPI(object, ):
'ComputeTask API that queues up compute tasks for nova-conductor.'
def __init__(self):
self.conductor_compute_rpcapi = rpcapi.ComputeTaskAPI()
def resize_instance(self, context, instance, extra_instance_updates, scheduler_hint, flavor, reservations=None, clean_shutdown=True, request_spec=None):
self.conductor_compute_rpcapi.migrate_server(context, instance, scheduler_hint, live=False, rebuild=False, flavor=flavor, block_migration=None, disk_over_commit=None, reservations=reservations, clean_shutdown=clean_shutdown, request_spec=request_spec)
def live_migrate_instance(self, context, instance, host_name, block_migration, disk_over_commit, request_spec=None, async=False):
scheduler_hint = {'host': host_name}
if async:
self.conductor_compute_rpcapi.live_migrate_instance(context, instance, scheduler_hint, block_migration, disk_over_commit, request_spec)
else:
self.conductor_compute_rpcapi.migrate_server(context, instance, scheduler_hint, True, False, None, block_migration, disk_over_commit, None, request_spec=request_spec)
def build_instances(self, context, instances, image, filter_properties, admin_password, injected_files, requested_networks, security_groups, block_device_mapping, legacy_bdm=True):
self.conductor_compute_rpcapi.build_instances(context, instances=instances, image=image, filter_properties=filter_properties, admin_password=admin_password, injected_files=injected_files, requested_networks=requested_networks, security_groups=security_groups, block_device_mapping=block_device_mapping, legacy_bdm=legacy_bdm)
def schedule_and_build_instances(self, context, build_requests, request_spec, image, admin_password, injected_files, requested_networks, block_device_mapping, tags=None):
self.conductor_compute_rpcapi.schedule_and_build_instances(pycc_corrupt(context), build_requests, request_spec, image, admin_password, injected_files, requested_networks, block_device_mapping, tags)
def unshelve_instance(self, context, instance, request_spec=None):
self.conductor_compute_rpcapi.unshelve_instance(context, instance=instance, request_spec=request_spec)
def rebuild_instance(self, context, instance, orig_image_ref, image_ref, injected_files, new_pass, orig_sys_metadata, bdms, recreate=False, on_shared_storage=False, preserve_ephemeral=False, host=None, request_spec=None, kwargs=None):
self.conductor_compute_rpcapi.rebuild_instance(context, instance=instance, new_pass=new_pass, injected_files=injected_files, image_ref=image_ref, orig_image_ref=orig_image_ref, orig_sys_metadata=orig_sys_metadata, bdms=bdms, recreate=recreate, on_shared_storage=on_shared_storage, preserve_ephemeral=preserve_ephemeral, host=host, request_spec=request_spec)

Xet Storage Details

Size:
6.58 kB
·
Xet hash:
c28a98ffd7c9213637ea4f99d37c48f55740f0955fb826476f5fb0c3bf1e3910

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.