Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ovh flavors #109

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions teuthology/openstack/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def get_ip(self, network):
return self.private_ip

def get_floating_ip(self):
ips = json.loads(OpenStack().run("ip floating list -f json"))
ips = OpenStack().get_os_floating_ips()
for ip in ips:
if ip['Fixed IP Address'] == self.get_ip(''):
return ip['Floating IP Address']
Expand Down Expand Up @@ -279,7 +279,18 @@ def run(self, cmd, *args, **kwargs):
if 'OS_URL' in os.environ:
del os.environ['OS_URL']
return status


def get_os_floating_ips(self):
try:
ips = json.loads(self.run("ip floating list -f json"))
except subprocess.CalledProcessError as e:
log.warning(e)
if e.returncode == 1:
return []
else:
raise e
return ips

def set_provider(self):
if 'OS_AUTH_URL' not in os.environ:
raise Exception('no OS_AUTH_URL environment variable')
Expand Down Expand Up @@ -454,7 +465,7 @@ def __flavor_wrapper(self, min, good, hint, arch):
select = None
if self.get_provider() == 'ovh':
log.debug("Looking for a match among the El Cheapo flavors...")
select = '^vps-ssd-'
select = '^(vps-ssd|s1)-'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kshtsk Did you want to reverse the order here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@smithfarm yes... probably this can be implemented with ECP feature.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kshtsk Good idea. Then this PR could be closed.

try:
if (hint is not None):
return self.__flavor(hint, arch, select)
Expand All @@ -463,7 +474,7 @@ def __flavor_wrapper(self, min, good, hint, arch):
pass
log.debug("No El Cheapo flavors match the selection criteria. "
"Looking for a match among the more expensive flavors...")
select = '^(hg|sg|c2)-.*ssd'
select = '^(c2-[0-9]+|(hg|sg)-.*ssd)$'
if (hint is not None):
return self.__flavor(hint, arch, select)
return self.__flavor_range(min, good, arch, select)
Expand Down Expand Up @@ -994,7 +1005,7 @@ def get_unassociated_floating_ip():
"""
Return a floating IP address not associated with an instance or None.
"""
ips = json.loads(OpenStack().run("ip floating list -f json"))
ips = OpenStack().get_os_floating_ips()
for ip in ips:
if not ip['Port']:
return ip['Floating IP Address']
Expand Down Expand Up @@ -1035,7 +1046,7 @@ def get_floating_ip_id(ip):
"""
Return the id of a floating IP
"""
results = json.loads(OpenStack().run("ip floating list -f json"))
results = OpenStack().get_os_floating_ips()
for result in results:
if result['IP'] == ip:
return str(result['ID'])
Expand Down