mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 01:18:58 +00:00
Merge pull request #35467 from rallytime/bp-33518
Back-port #33518 to 2016.3
This commit is contained in:
commit
d2dd78e25b
@ -55,16 +55,31 @@ def node_state(id_):
|
||||
'''
|
||||
Libcloud supported node states
|
||||
'''
|
||||
states = {0: 'RUNNING',
|
||||
1: 'REBOOTING',
|
||||
2: 'TERMINATED',
|
||||
3: 'PENDING',
|
||||
4: 'UNKNOWN',
|
||||
5: 'STOPPED',
|
||||
6: 'SUSPENDED',
|
||||
7: 'ERROR',
|
||||
8: 'PAUSED'}
|
||||
return states[id_]
|
||||
states_int = {
|
||||
0: 'RUNNING',
|
||||
1: 'REBOOTING',
|
||||
2: 'TERMINATED',
|
||||
3: 'PENDING',
|
||||
4: 'UNKNOWN',
|
||||
5: 'STOPPED',
|
||||
6: 'SUSPENDED',
|
||||
7: 'ERROR',
|
||||
8: 'PAUSED'}
|
||||
states_str = {
|
||||
'running': 'RUNNING',
|
||||
'rebooting': 'REBOOTING',
|
||||
'starting': 'STARTING',
|
||||
'terminated': 'TERMINATED',
|
||||
'pending': 'PENDING',
|
||||
'unknown': 'UNKNOWN',
|
||||
'stopping': 'STOPPING',
|
||||
'stopped': 'STOPPED',
|
||||
'suspended': 'SUSPENDED',
|
||||
'error': 'ERROR',
|
||||
'paused': 'PAUSED',
|
||||
'reconfiguring': 'RECONFIGURING'
|
||||
}
|
||||
return states_str[id_] if isinstance(id_, string_types) else states_int[id_]
|
||||
|
||||
|
||||
def check_libcloud_version(reqver=LIBCLOUD_MINIMAL_VERSION, why=None):
|
||||
|
36
tests/unit/cloud/libcloud_test.py
Normal file
36
tests/unit/cloud/libcloud_test.py
Normal file
@ -0,0 +1,36 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
'''
|
||||
:codeauthor: `Anthony Shaw <anthonyshaw@apache.org>`
|
||||
|
||||
tests.unit.cloud.clouds.dimensiondata_test
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
'''
|
||||
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import
|
||||
|
||||
# Import Salt Testing Libs
|
||||
from salttesting import TestCase
|
||||
|
||||
# Import Salt Libs
|
||||
import salt.cloud.libcloudfuncs as libcloud
|
||||
|
||||
# Import Salt Testing Libs
|
||||
from salttesting.helpers import ensure_in_syspath
|
||||
|
||||
ensure_in_syspath('../../')
|
||||
|
||||
|
||||
class LibcloudTestCase(TestCase):
|
||||
def test_node_state_libcloud_020(self):
|
||||
state = libcloud.node_state(2)
|
||||
self.assertEqual('TERMINATED', state)
|
||||
|
||||
def test_node_state_libcloud_100(self):
|
||||
state = libcloud.node_state('terminated')
|
||||
self.assertEqual('TERMINATED', state)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
from unit import run_tests
|
||||
run_tests(LibcloudTestCase, needs_daemon=False)
|
Loading…
Reference in New Issue
Block a user