This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
"""usage: %(prog)s <nova.conf> | |
Remove unused iscsi connections (sr) from xen host and | |
tag attachments (vbd) as "openstack-volumes". | |
Connection information is parsed from nova.conf file. | |
e.g. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_api(host, password): | |
session = XenAPI.Session('http://%s' % host) | |
session.login_with_password('root', password) | |
return session.xenapi | |
def fix_srs(api): | |
for sr_ref in api.SR.get_all(): | |
sr = api.SR.get_record(sr_ref) | |
if sr['type'] != 'iscsi': | |
# we are wise to ignore non iscsi sr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import unittest | |
from StringIO import StringIO | |
import logging | |
logging.basicConfig(level=logging.DEBUG, filename='test.log', filemode='w') | |
logger = logging.getLogger() | |
class LogCaptureResult(unittest._TextTestResult): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
"""usage: %(prog)s [/etc/nova/nova.conf] [--dry-run] | |
Cleanup and/or remove unused iscsi connections (sr) from xen host and | |
tag and try to unplug "openstack-volumes" attachments (vbd). | |
Connection information is parsed from nova.conf file. | |
e.g. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
import threading | |
import time | |
import logging | |
logging.basicConfig(level=logging.DEBUG) | |
logger = logging.getLogger() | |
cmd = 'dpkg -l' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/ISCSISR b/ISCSISR | |
@@ -344,6 +344,11 @@ class ISCSISR(SR.SR): | |
if self.mpath == 'true' and self.dconf.has_key('SCSIid'): | |
self.mpathmodule.refresh(self.dconf['SCSIid'],npaths) | |
+ # Set the block scheduler | |
+ for path in os.listdir(self.path): | |
+ if path.startswith('LUN'): | |
+ self.block_setscheduler(os.path.join(self.path, path)) | |
+ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> def myfunc(a, b): | |
... print (a, b) | |
... | |
>>> myfunc(b=2, a=1) | |
(1, 2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a comes before c | |
b comes after a | |
b comes before d | |
e comes after b | |
e comes after d | |
e comes after c | |
e comes before f | |
g comes after b | |
h comes after g |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import unittest | |
import pkg_resources | |
import stevedore | |
class MockPkgResources(object): | |
def iter_entry_points(self, namespace): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In [2]: db = ContainerBroker('/srv/node1/sdb1/containers/870/23c/d9ad51fe9c211707d5c690c1b00a223c/d9ad51fe9c211707d5c690c1b00a223c.db') | |
In [4]: db.get_info() | |
Out[4]: | |
{'account': 'AUTH_test', | |
'bytes_used': 0, | |
'container': 'mycontainer', | |
'created_at': '1377204903.29857', | |
'delete_timestamp': '0', | |
'hash': '00000000000000000000000000000000', |