def set_info(self):
try:
self.info = json.loads(
- misc.sh("openstack server show -f json " + self.name_or_id))
+ misc.sh("openstack -q server show -f json " + self.name_or_id))
enforce_json_dictionary(self.info)
except CalledProcessError:
self.info = None
self.get_addresses())[0]
def get_floating_ip(self):
- ips = json.loads(misc.sh("openstack ip floating list -f json"))
+ ips = json.loads(misc.sh("openstack -q ip floating list -f json"))
for ip in ips:
if ip['Instance ID'] == self['id']:
return ip['IP']
if not self.exists():
return True
volumes = self.get_volumes()
- misc.sh("openstack server set --name REMOVE-ME-" + self.name_or_id +
+ misc.sh("openstack -q server set --name REMOVE-ME-" + self.name_or_id +
" " + self['id'])
- misc.sh("openstack server delete --wait " + self['id'] +
+ misc.sh("openstack -q server delete --wait " + self['id'] +
" || true")
for volume in volumes:
- misc.sh("openstack volume set --name REMOVE-ME " + volume + " || true")
- misc.sh("openstack volume delete " + volume + " || true")
+ misc.sh("openstack -q volume set --name REMOVE-ME " + volume + " || true")
+ misc.sh("openstack -q volume delete " + volume + " || true")
return True
"""
Return true if the image exists in OpenStack.
"""
- found = misc.sh("openstack image list -f json --property name='" +
+ found = misc.sh("openstack -q image list -f json --property name='" +
self.image_name(image) + "'")
return len(json.loads(found)) > 0
"""
Return the uuid of the network in OpenStack.
"""
- r = json.loads(misc.sh("openstack network show -f json " +
+ r = json.loads(misc.sh("openstack -q network show -f json " +
network))
return self.get_value(r, 'id')
"""
Return the smallest flavor that satisfies the desired size.
"""
- flavors_string = misc.sh("openstack flavor list -f json")
+ flavors_string = misc.sh("openstack -q flavor list -f json")
flavors = json.loads(flavors_string)
found = []
for flavor in flavors:
def list_instances():
ownedby = "ownedby='" + teuth_config.openstack['ip'] + "'"
all = json.loads(misc.sh(
- "openstack server list -f json --long --name 'target'"))
+ "openstack -q server list -f json --long --name 'target'"))
return filter(lambda instance: ownedby in instance['Properties'], all)
@staticmethod
def list_volumes():
ownedby = "ownedby='" + teuth_config.openstack['ip'] + "'"
all = json.loads(misc.sh(
- "openstack volume list -f json --long"))
+ "openstack -q volume list -f json --long"))
def select(volume):
return (ownedby in volume['Properties'] and
volume['Display Name'].startswith('target'))
know already.
"""
try:
- misc.sh("openstack flavor list | tail -2")
+ misc.sh("openstack -q flavor list | tail -2")
except subprocess.CalledProcessError:
- log.exception("openstack flavor list")
+ log.exception("openstack -q flavor list")
raise Exception("verify openrc.sh has been sourced")
self.set_provider()
among instances created within the same tenant.
"""
try:
- misc.sh("openstack security group show teuthology")
+ misc.sh("openstack -q security group show teuthology")
return
except subprocess.CalledProcessError:
pass
"""
Return a floating IP address not associated with an instance or None.
"""
- ips = json.loads(misc.sh("openstack ip floating list -f json"))
+ ips = json.loads(misc.sh("openstack -q ip floating list -f json"))
for ip in ips:
if not ip['Instance ID']:
return ip['IP']
@staticmethod
def create_floating_ip():
- pools = json.loads(misc.sh("openstack ip floating pool list -f json"))
+ pools = json.loads(misc.sh("openstack -q ip floating pool list -f json"))
if not pools:
return None
pool = pools[0]['Name']
try:
ip = json.loads(misc.sh(
- "openstack ip floating create -f json '" + pool + "'"))
+ "openstack -q ip floating create -f json '" + pool + "'"))
return TeuthologyOpenStack.get_value(ip, 'ip')
except subprocess.CalledProcessError:
log.debug("create_floating_ip: not creating a floating ip")
if not ip:
ip = TeuthologyOpenStack.create_floating_ip()
if ip:
- misc.sh("openstack ip floating add " + ip + " " + name_or_id)
+ misc.sh("openstack -q ip floating add " + ip + " " + name_or_id)
@staticmethod
def get_floating_ip_id(ip):
"""
Return the id of a floating IP
"""
- results = json.loads(misc.sh("openstack ip floating list -f json"))
+ results = json.loads(misc.sh("openstack -q ip floating list -f json"))
for result in results:
if result['IP'] == ip:
return str(result['ID'])
ip = OpenStackInstance(instance_id).get_floating_ip()
if not ip:
return
- misc.sh("openstack ip floating remove " + ip + " " + instance_id)
+ misc.sh("openstack -q ip floating remove " + ip + " " + instance_id)
ip_id = TeuthologyOpenStack.get_floating_ip_id(ip)
- misc.sh("openstack ip floating delete " + ip_id)
+ misc.sh("openstack -q ip floating delete " + ip_id)
def create_cluster(self):
user_data = self.get_user_data()
self.ssh("sudo /etc/init.d/teuthology stop || true")
instance_id = self.get_instance_id(self.args.name)
self.delete_floating_ip(instance_id)
- misc.sh("openstack server delete packages-repository || true")
- misc.sh("openstack server delete --wait " + self.args.name)
+ misc.sh("openstack -q server delete packages-repository || true")
+ misc.sh("openstack -q server delete --wait " + self.args.name)
def main(ctx, argv):
return TeuthologyOpenStack(ctx, teuth_config, argv).main()