mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 01:18:58 +00:00
commit
1e99177c92
@ -1,5 +1,5 @@
|
||||
mysql-python
|
||||
timelib
|
||||
yappi >= 0.8.2
|
||||
python-novaclient
|
||||
python-novaclient > 2.17.0
|
||||
python-gnupg
|
||||
|
@ -953,7 +953,7 @@ def volume_attach(name, server_name, device='/dev/xvdb', **kwargs):
|
||||
|
||||
def volume_list(**kwargs):
|
||||
'''
|
||||
Attach block volume
|
||||
List block devices
|
||||
'''
|
||||
conn = get_conn()
|
||||
return conn.volume_list()
|
||||
|
@ -213,7 +213,7 @@ def volume_list(provider):
|
||||
|
||||
'''
|
||||
client = _get_client()
|
||||
info = client.extra_action(provider, 'name', action='volume_list')
|
||||
info = client.extra_action(action='volume_list', provider=provider, names='name')
|
||||
return info['name']
|
||||
|
||||
|
||||
@ -229,7 +229,7 @@ def volume_delete(provider, names, **kwargs):
|
||||
|
||||
'''
|
||||
client = _get_client()
|
||||
info = client.extra_action(provider, names, action='volume_delete', **kwargs)
|
||||
info = client.extra_action(provider=provider, names=names, action='volume_delete', **kwargs)
|
||||
return info
|
||||
|
||||
|
||||
@ -246,7 +246,7 @@ def volume_create(provider, names, **kwargs):
|
||||
|
||||
'''
|
||||
client = _get_client()
|
||||
info = client.extra_action(provider, names, action='volume_create', **kwargs)
|
||||
info = client.extra_action(action='volume_create', names=names, provider=provider, **kwargs)
|
||||
return info
|
||||
|
||||
|
||||
@ -264,7 +264,7 @@ def volume_attach(provider, names, **kwargs):
|
||||
|
||||
'''
|
||||
client = _get_client()
|
||||
info = client.extra_action(provider, names, action='volume_attach', **kwargs)
|
||||
info = client.extra_action(provider=provider, names=names, action='volume_attach', **kwargs)
|
||||
return info
|
||||
|
||||
|
||||
@ -281,7 +281,7 @@ def volume_detach(provider, names, **kwargs):
|
||||
|
||||
'''
|
||||
client = _get_client()
|
||||
info = client.extra_action(provider, names, action='volume_detach', **kwargs)
|
||||
info = client.extra_action(provider=provider, names=names, action='volume_detach', **kwargs)
|
||||
return info
|
||||
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
'''
|
||||
Nova class
|
||||
'''
|
||||
from __future__ import with_statement
|
||||
|
||||
# Import third party libs
|
||||
HAS_NOVA = False
|
||||
@ -132,17 +133,20 @@ class SaltNova(object):
|
||||
|
||||
self.kwargs = sanatize_novaclient(self.kwargs)
|
||||
|
||||
conn = client.Client(**self.kwargs)
|
||||
try:
|
||||
conn.client.authenticate()
|
||||
except novaclient.exceptions.AmbiguousEndpoints:
|
||||
raise SaltCloudSystemExit(
|
||||
"Nova provider requires a 'region_name' to be specified"
|
||||
)
|
||||
if not hasattr(client.Client, '__exit__'):
|
||||
raise SaltCloudSystemExit("Newer version of novaclient required for __exit__.")
|
||||
|
||||
self.kwargs['auth_token'] = conn.client.auth_token
|
||||
self.catalog = \
|
||||
conn.client.service_catalog.catalog['access']['serviceCatalog']
|
||||
with client.Client(**self.kwargs) as conn:
|
||||
try:
|
||||
conn.client.authenticate()
|
||||
except novaclient.exceptions.AmbiguousEndpoints:
|
||||
raise SaltCloudSystemExit(
|
||||
"Nova provider requires a 'region_name' to be specified"
|
||||
)
|
||||
|
||||
self.kwargs['auth_token'] = conn.client.auth_token
|
||||
self.catalog = \
|
||||
conn.client.service_catalog.catalog['access']['serviceCatalog']
|
||||
|
||||
if not region_name is None:
|
||||
servers_endpoints = get_entry(self.catalog, 'type', 'compute')['endpoints']
|
||||
@ -301,11 +305,14 @@ class SaltNova(object):
|
||||
Delete a block device
|
||||
'''
|
||||
nt_ks = self.volume_conn
|
||||
volume = self.volume_show(name)
|
||||
try:
|
||||
volume = self.volume_show(name)
|
||||
except KeyError as exc:
|
||||
raise SaltCloudSystemExit('Unable to find {0} volume: {1}'.format(name, exc))
|
||||
if volume['status'] == 'deleted':
|
||||
return volume
|
||||
response = nt_ks.volumes.delete(volume['id'])
|
||||
return self.volume_show(name)
|
||||
return volume
|
||||
|
||||
def volume_detach(self,
|
||||
name,
|
||||
@ -313,7 +320,10 @@ class SaltNova(object):
|
||||
'''
|
||||
Detach a block device
|
||||
'''
|
||||
volume = self.volume_show(name)
|
||||
try:
|
||||
volume = self.volume_show(name)
|
||||
except KeyError as exc:
|
||||
raise SaltCloudSystemExit('Unable to find {0} volume: {1}'.format(name, exc))
|
||||
if not volume['attachments']:
|
||||
return True
|
||||
response = self.compute_conn.volumes.delete_server_volume(
|
||||
@ -348,7 +358,10 @@ class SaltNova(object):
|
||||
'''
|
||||
Attach a block device
|
||||
'''
|
||||
volume = self.volume_show(name)
|
||||
try:
|
||||
volume = self.volume_show(name)
|
||||
except KeyError as exc:
|
||||
raise SaltCloudSystemExit('Unable to find {0} volume: {1}'.format(name, exc))
|
||||
server = self.server_by_name(server_name)
|
||||
response = self.compute_conn.volumes.create_server_volume(
|
||||
server.id,
|
||||
@ -669,7 +682,10 @@ class SaltNova(object):
|
||||
Show details of one server
|
||||
'''
|
||||
ret = {}
|
||||
servers = self.server_list_detailed()
|
||||
try:
|
||||
servers = self.server_list_detailed()
|
||||
except AttributeError as exc:
|
||||
raise SaltCloudSystemExit('Corrupt server in server_list_detailed. Remove corrupt servers.')
|
||||
for server_name, server in servers.iteritems():
|
||||
if str(server['id']) == server_id:
|
||||
ret[server_name] = server
|
||||
|
Loading…
Reference in New Issue
Block a user