Skip to content

Instantly share code, notes, and snippets.

from swiftclient import get_auth, client
import time
url, token = get_auth('http://saio:8080/auth/v1.0', 'test:tester', 'testing')
TIMEOUT = 30.0
finish = time.time() + TIMEOUT
while True:
sc = client.head_account(url, token)
print(sc)
time.sleep(1.0)
if time.time() > finish:
@clayg
clayg / slow_client.py
Created August 26, 2020 16:59
hold a connection open
#!/usr/bin/env python
import sys
import argparse
from swift.common.storage_policy import POLICIES
from swift.common.bufferedhttp import http_connect
from swift.common.utils import Timestamp
SWIFT_DIR = '/etc/swift'
@clayg
clayg / make_expand.py
Created July 28, 2020 00:17
spit out some json for swift-ring-builder-analyizer
import json
import sys
def gen_ips():
i = 147
j = 153
while True:
j += 1
if j > 254:
import ctypes
import ctypes.util
import struct
import sys
import textwrap
import zlib
lib_name = ctypes.util.find_library('erasurecode')
if not lib_name:
lib_name = 'liberasurecode.so.1'
@clayg
clayg / make_no_replication_ring.py
Created June 25, 2020 16:30
Make a no replication ring if you need it
#!/usr/bin/env python
from argparse import ArgumentParser
import sys
import os
from swift.common.ring import RingData
parser = ArgumentParser()
parser.add_argument('ring', help='path to a ring')
parser.add_argument('--output', default=None, help='override output path')
@clayg
clayg / something.patch
Created June 15, 2020 19:17
don't HEAD buckets to get account
diff --git a/swift/common/middleware/s3api/s3request.py b/swift/common/middleware/s3api/s3request.py
index 28e734f0b..2a0193867 100644
--- a/swift/common/middleware/s3api/s3request.py
+++ b/swift/common/middleware/s3api/s3request.py
@@ -37,8 +37,7 @@ from swift.common.http import HTTP_OK, HTTP_CREATED, HTTP_ACCEPTED, \
HTTP_TOO_MANY_REQUESTS, HTTP_RATE_LIMITED, is_success
from swift.common.constraints import check_utf8
-from swift.proxy.controllers.base import get_container_info, \
- headers_to_container_info
@clayg
clayg / priority-container-sharder
Created June 12, 2020 19:25
Skip some shard dbs and prioritize other containers
#!/usr/bin/env python
from swift.container import sharder
from swift.common.utils import parse_options
from swift.common.daemon import run_daemon
from optparse import OptionParser
orig_sharding_enabled = sharder.sharding_enabled
@clayg
clayg / s3_mpu_upload.py
Last active September 4, 2020 16:56
Basic boto3 s3 client Multipart Upload
from argparse import ArgumentParser
import sys
import json
import datetime
import os
import boto3
parser = ArgumentParser()
$ git diff
diff --git a/swift/container/server.py b/swift/container/server.py
index d6f0ea9b6..98d80f3ee 100644
--- a/swift/container/server.py
+++ b/swift/container/server.py
@@ -541,7 +541,7 @@ class ContainerController(BaseStorageServer):
return HTTPBadRequest('Invalid body: %r' % err)
created = self._maybe_autocreate(
broker, req_timestamp, account, requested_policy_index,
- put_shard=True)
@clayg
clayg / test_db_delete_reclaim.py
Last active May 14, 2020 19:57
try and test if reclaim locks up the database
[root@stgss0235 ~]# tail -n 20 *.out
==> orig.out <==
('delete', 1589476453, 968)
('reclaim', 1589476456.4089239, 3.372346878051758)
('delete', 1589476456, 957)
('delete', 1589476459, 546)
('reclaim', 1589476459.7816048, 2.8547749519348145)
('delete', 1589476460, 392)
('reclaim', 1589476462.6364882, 2.8673436641693115)
('delete', 1589476462, 915)