Rename Server's 'ip' to 'host'

Change-Id: I518bfd3e8f83bee07a44db12d497bc3dd0a094b8
Related: blueprint provider-server-refactoring
This commit is contained in:
Maksym Iarmak 2014-01-10 16:52:55 +02:00 committed by Sergey Skripnick
parent fe9f79f7cc
commit b0548f69f0
7 changed files with 15 additions and 15 deletions

View File

@ -92,15 +92,15 @@ class DevstackEngine(engine.EngineFactory):
return {
'identity': {
'url': 'http://%s/' % self.servers[0].ip,
'uri': 'http://%s:5000/v2.0/' % self.servers[0].ip,
'url': 'http://%s/' % self.servers[0].host,
'uri': 'http://%s:5000/v2.0/' % self.servers[0].host,
'admin_username': 'admin',
'admin_password': self.localrc['ADMIN_PASSWORD'],
'admin_tenant_name': 'admin',
},
'compute': {
'controller_nodes': self.servers[0].ip,
'compute_nodes': self.servers[0].ip,
'controller_nodes': self.servers[0].host,
'compute_nodes': self.servers[0].host,
'controller_node_ssh_user': self.servers[0].user,
}
}

View File

@ -26,18 +26,18 @@ class Server(utils.ImmutableMixin):
Provider.create_servers should return list of instance of Server
"""
def __init__(self, ip, user, key=None, password=None, port=22):
self.ip = ip
def __init__(self, host, user, key=None, password=None, port=22):
self.host = host
self.port = port
self.user = user
self.key = key
self.password = password
self.ssh = sshutils.SSH(ip, user, port, key)
self.ssh = sshutils.SSH(host, user, port, key)
super(Server, self).__init__()
def get_credentials(self):
return {
'ip': self.ip,
'host': self.host,
'port': self.port,
'user': self.user,
'key': self.key,
@ -46,7 +46,7 @@ class Server(utils.ImmutableMixin):
@classmethod
def from_credentials(cls, creds):
return cls(creds['ip'], creds['user'], key=creds['key'],
return cls(creds['host'], creds['user'], key=creds['key'],
port=creds['port'], password=creds['password'])

View File

@ -51,7 +51,7 @@ class DummyProvider(provider.ProviderFactory):
def create_servers(self):
servers = []
for endpoint in self.credentials:
servers.append(provider.Server(ip=endpoint['host'],
servers.append(provider.Server(host=endpoint['host'],
user=endpoint['user'],
key=endpoint.get('key'),
password=endpoint.get('password'),

View File

@ -165,7 +165,7 @@ class OpenStackProvider(provider.ProviderFactory):
for os_server in os_servers:
utils.wait_for(os_server, **kwargs)
servers = [provider.Server(ip=s.addresses.values()[0][0]['addr'],
servers = [provider.Server(host=s.addresses.values()[0][0]['addr'],
user='root',
key=public_key_path)
for s in os_servers]

View File

@ -34,7 +34,7 @@ class DummyProviderTestCase(test.TestCase):
provider = serverprovider.ProviderFactory.get_provider(self.config,
None)
credentials = provider.create_servers()
self.assertEqual(['host1', 'host2'], [s.ip for s in credentials])
self.assertEqual(['host1', 'host2'], [s.host for s in credentials])
self.assertEqual(['user', 'user'], [s.user for s in credentials])
def test_invalid_config(self):

View File

@ -59,7 +59,7 @@ class VirshProviderTestCase(test.BaseTestCase):
'./get_domain_ip.sh name', shell=True),
])
mock_ipaddress.assert_called_once_with('10.0.0.1')
self.assertEqual(server.ip, '10.0.0.2')
self.assertEqual(server.host, '10.0.0.2')
self.assertEqual(server.user, 'user')
self.assertEqual(server.key, None)
self.assertEqual(server.password, 'password')
@ -77,7 +77,7 @@ class VirshProviderTestCase(test.BaseTestCase):
mock.call.check_output('ssh -o StrictHostKeyChecking=no user@host '
'./get_domain_ip.sh name', shell=True),
])
self.assertEqual(server.ip, 'None')
self.assertEqual(server.host, 'None')
@mock.patch('rally.serverprovider.providers.virsh.subprocess')
def test_destroy_vm(self, mock_subp):

View File

@ -86,7 +86,7 @@ class ServerTestCase(test.TestCase):
def setUp(self):
super(ServerTestCase, self).setUp()
self.vals = ['192.168.1.1', 'admin', 'some_key', 'pwd']
self.keys = ['ip', 'user', 'key', 'password']
self.keys = ['host', 'user', 'key', 'password']
def test_init_server_dto(self):
server = serverprovider.Server(*self.vals)