|
| 1 | +""" |
| 2 | + SoftLayer.tests.CLI.modules.vs_tests |
| 3 | + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 4 | +
|
| 5 | + :license: MIT, see LICENSE for more details. |
| 6 | +""" |
| 7 | +from mock import patch |
| 8 | + |
| 9 | +from SoftLayer.tests import unittest, FixtureClient |
| 10 | +from SoftLayer.CLI.helpers import format_output |
| 11 | +from SoftLayer.CLI.modules import vs |
| 12 | + |
| 13 | + |
| 14 | +class DnsTests(unittest.TestCase): |
| 15 | + def setUp(self): |
| 16 | + self.client = FixtureClient() |
| 17 | + |
| 18 | + def test_list_vs(self): |
| 19 | + command = vs.ListVSIs(client=self.client) |
| 20 | + |
| 21 | + output = command.execute({'--tags': 'tag'}) |
| 22 | + self.assertEqual([{'datacenter': 'TEST00', |
| 23 | + 'primary_ip': '172.16.240.2', |
| 24 | + 'host': 'vs-test1.test.sftlyr.ws', |
| 25 | + 'memory': 1024, |
| 26 | + 'cores': 2, |
| 27 | + 'active_transaction': None, |
| 28 | + 'id': 100, |
| 29 | + 'backend_ip': '10.45.19.37'}, |
| 30 | + {'datacenter': 'TEST00', |
| 31 | + 'primary_ip': '172.16.240.7', |
| 32 | + 'host': 'vs-test2.test.sftlyr.ws', |
| 33 | + 'memory': 4096, |
| 34 | + 'cores': 4, |
| 35 | + 'active_transaction': None, |
| 36 | + 'id': 104, |
| 37 | + 'backend_ip': '10.45.19.35'}], |
| 38 | + format_output(output, 'python')) |
| 39 | + |
| 40 | + def test_detail_vs(self): |
| 41 | + command = vs.VSDetails(client=self.client) |
| 42 | + |
| 43 | + output = command.execute({'<identifier>': '100', |
| 44 | + '--passwords': True, |
| 45 | + '--price': True}) |
| 46 | + |
| 47 | + self.assertEqual({'active_transaction': None, |
| 48 | + 'cores': 2, |
| 49 | + 'created': '2013-08-01 15:23:45', |
| 50 | + 'datacenter': 'TEST00', |
| 51 | + 'hostname': 'vs-test1.test.sftlyr.ws', |
| 52 | + 'id': 100, |
| 53 | + 'memory': 1024, |
| 54 | + 'modified': {}, |
| 55 | + 'os': '12.04-64 Minimal for CCI', |
| 56 | + 'os_version': '12.04-64 Minimal for CCI', |
| 57 | + 'price rate': {}, |
| 58 | + 'notes': 'notes', |
| 59 | + 'tags': ['production'], |
| 60 | + 'private_cpu': {}, |
| 61 | + 'private_ip': '10.45.19.37', |
| 62 | + 'private_only': {}, |
| 63 | + 'ptr': 'test.softlayer.com.', |
| 64 | + 'public_ip': '172.16.240.2', |
| 65 | + 'state': 'RUNNING', |
| 66 | + 'status': 'ACTIVE', |
| 67 | + 'users': [{'password': 'pass', 'username': 'user'}], |
| 68 | + 'vlans': [{'type': 'PUBLIC', |
| 69 | + 'number': 23, |
| 70 | + 'id': 1}]}, |
| 71 | + format_output(output, 'python')) |
| 72 | + |
| 73 | + def test_create_options(self): |
| 74 | + command = vs.CreateOptionsVS(client=self.client) |
| 75 | + |
| 76 | + output = command.execute({'--all': True, |
| 77 | + '--cpu': True, |
| 78 | + '--datacenter': True, |
| 79 | + '--disk': True, |
| 80 | + '--memory': True, |
| 81 | + '--nic': True, |
| 82 | + '--os': True}) |
| 83 | + |
| 84 | + self.assertEqual({'cpus (private)': [], |
| 85 | + 'cpus (standard)': ['1', '2', '3', '4'], |
| 86 | + 'datacenter': ['ams01', 'dal05'], |
| 87 | + 'local disk(0)': ['25', '100'], |
| 88 | + 'memory': ['1024', '2048', '3072', '4096'], |
| 89 | + 'nic': ['10', '100', '1000'], |
| 90 | + 'os (CENTOS)': 'CENTOS_6_64', |
| 91 | + 'os (DEBIAN)': 'DEBIAN_7_64', |
| 92 | + 'os (UBUNTU)': 'UBUNTU_12_64'}, |
| 93 | + format_output(output, 'python')) |
| 94 | + |
| 95 | + @patch('SoftLayer.CLI.modules.vs.confirm') |
| 96 | + def test_create(self, confirm_mock): |
| 97 | + confirm_mock.return_value = True |
| 98 | + command = vs.CreateVS(client=self.client) |
| 99 | + |
| 100 | + output = command.execute({'--cpu': '2', |
| 101 | + '--domain': 'example.com', |
| 102 | + '--hostname': 'host', |
| 103 | + '--image': None, |
| 104 | + '--os': 'UBUNTU_LATEST', |
| 105 | + '--memory': '1024', |
| 106 | + '--nic': '100', |
| 107 | + '--hourly': True, |
| 108 | + '--monthly': False, |
| 109 | + '--like': None, |
| 110 | + '--datacenter': None, |
| 111 | + '--dedicated': False, |
| 112 | + '--san': False, |
| 113 | + '--test': False, |
| 114 | + '--export': None, |
| 115 | + '--userfile': None, |
| 116 | + '--postinstall': None, |
| 117 | + '--key': [], |
| 118 | + '--like': [], |
| 119 | + '--network': [], |
| 120 | + '--disk': [], |
| 121 | + '--private': False, |
| 122 | + '--template': None, |
| 123 | + '--userdata': None, |
| 124 | + '--vlan_public': None, |
| 125 | + '--vlan_private': None, |
| 126 | + '--wait': None, |
| 127 | + '--really': False}) |
| 128 | + |
| 129 | + self.assertEqual([{'guid': '1a2b3c-1701', |
| 130 | + 'id': 100, |
| 131 | + 'created': '2013-08-01 15:23:45'}], |
| 132 | + format_output(output, 'python')) |
0 commit comments