Merge "Add admin_pass as a property"
This commit is contained in:
commit
66d97ab5f1
@ -175,7 +175,8 @@ class CloudServersTest(HeatTestCase):
|
||||
config_drive=None,
|
||||
disk_config=None,
|
||||
reservation_id=None,
|
||||
files=mox.IgnoreArg()).AndReturn(return_server)
|
||||
files=mox.IgnoreArg(),
|
||||
admin_pass=None).AndReturn(return_server)
|
||||
|
||||
self.m.StubOutWithMock(cloud_server.CloudServer, 'script')
|
||||
cloud_server.CloudServer.script = "foobar"
|
||||
@ -343,7 +344,8 @@ class CloudServersTest(HeatTestCase):
|
||||
meta=None, nics=None, availability_zone=None,
|
||||
block_device_mapping=None, config_drive=None,
|
||||
disk_config=None, reservation_id=None,
|
||||
files=expected_personality).AndReturn(return_server)
|
||||
files=expected_personality,
|
||||
admin_pass=None).AndReturn(return_server)
|
||||
|
||||
self.m.ReplayAll()
|
||||
scheduler.TaskRunner(server.create)()
|
||||
|
@ -40,12 +40,14 @@ class Server(resource.Resource):
|
||||
ADMIN_USER, AVAILABILITY_ZONE, SECURITY_GROUPS, NETWORKS,
|
||||
SCHEDULER_HINTS, METADATA, USER_DATA_FORMAT, USER_DATA,
|
||||
RESERVATION_ID, CONFIG_DRIVE, DISK_CONFIG, PERSONALITY,
|
||||
ADMIN_PASS,
|
||||
) = (
|
||||
'name', 'image', 'block_device_mapping', 'flavor',
|
||||
'flavor_update_policy', 'image_update_policy', 'key_name',
|
||||
'admin_user', 'availability_zone', 'security_groups', 'networks',
|
||||
'scheduler_hints', 'metadata', 'user_data_format', 'user_data',
|
||||
'reservation_id', 'config_drive', 'diskConfig', 'personality',
|
||||
'admin_pass',
|
||||
)
|
||||
|
||||
_BLOCK_DEVICE_MAPPING_KEYS = (
|
||||
@ -246,7 +248,13 @@ class Server(resource.Resource):
|
||||
_('A map of files to create/overwrite on the server upon boot. '
|
||||
'Keys are file names and values are the file contents.'),
|
||||
default={}
|
||||
)
|
||||
),
|
||||
ADMIN_PASS: properties.Schema(
|
||||
properties.Schema.STRING,
|
||||
_('The administrator password for the server.'),
|
||||
required=False,
|
||||
update_allowed=True
|
||||
),
|
||||
}
|
||||
|
||||
attributes_schema = {
|
||||
@ -322,6 +330,7 @@ class Server(resource.Resource):
|
||||
reservation_id = self.properties.get(self.RESERVATION_ID)
|
||||
config_drive = self.properties.get(self.CONFIG_DRIVE)
|
||||
disk_config = self.properties.get(self.DISK_CONFIG)
|
||||
admin_pass = self.properties.get(self.ADMIN_PASS) or None
|
||||
|
||||
server = None
|
||||
try:
|
||||
@ -340,7 +349,8 @@ class Server(resource.Resource):
|
||||
reservation_id=reservation_id,
|
||||
config_drive=config_drive,
|
||||
disk_config=disk_config,
|
||||
files=self._personality())
|
||||
files=self._personality(),
|
||||
admin_pass=admin_pass)
|
||||
finally:
|
||||
# Avoid a race condition where the thread could be cancelled
|
||||
# before the ID is stored
|
||||
|
@ -14,8 +14,9 @@
|
||||
|
||||
import collections
|
||||
import copy
|
||||
import uuid
|
||||
import mock
|
||||
import mox
|
||||
import uuid
|
||||
|
||||
from heat.engine import environment
|
||||
from heat.tests.v1_1 import fakes
|
||||
@ -126,8 +127,8 @@ class ServersTest(HeatTestCase):
|
||||
userdata=mox.IgnoreArg(), scheduler_hints=None,
|
||||
meta=None, nics=None, availability_zone=None,
|
||||
block_device_mapping=None, config_drive=None,
|
||||
disk_config=None, reservation_id=None, files={}).AndReturn(
|
||||
return_server)
|
||||
disk_config=None, reservation_id=None, files={},
|
||||
admin_pass=None).AndReturn(return_server)
|
||||
|
||||
return server
|
||||
|
||||
@ -185,8 +186,8 @@ class ServersTest(HeatTestCase):
|
||||
userdata=mox.IgnoreArg(), scheduler_hints=None,
|
||||
meta=instance_meta, nics=None, availability_zone=None,
|
||||
block_device_mapping=None, config_drive=None,
|
||||
disk_config=None, reservation_id=None, files={}).AndReturn(
|
||||
return_server)
|
||||
disk_config=None, reservation_id=None, files={},
|
||||
admin_pass=None).AndReturn(return_server)
|
||||
|
||||
self.m.StubOutWithMock(server, 'nova')
|
||||
server.nova().MultipleTimes().AndReturn(self.fc)
|
||||
@ -356,13 +357,64 @@ class ServersTest(HeatTestCase):
|
||||
userdata='wordpress', scheduler_hints=None,
|
||||
meta=None, nics=None, availability_zone=None,
|
||||
block_device_mapping=None, config_drive=None,
|
||||
disk_config=None, reservation_id=None, files={}).AndReturn(
|
||||
return_server)
|
||||
disk_config=None, reservation_id=None, files={},
|
||||
admin_pass=None).AndReturn(return_server)
|
||||
|
||||
self.m.ReplayAll()
|
||||
scheduler.TaskRunner(server.create)()
|
||||
self.m.VerifyAll()
|
||||
|
||||
@mock.patch.object(clients.OpenStackClients, 'nova')
|
||||
def test_server_create_default_admin_pass(self, mock_nova):
|
||||
return_server = self.fc.servers.list()[1]
|
||||
return_server.adminPass = 'autogenerated'
|
||||
stack_name = 'admin_pass_s'
|
||||
(t, stack) = self._setup_test_stack(stack_name)
|
||||
|
||||
server = servers.Server('WebServer',
|
||||
t['Resources']['WebServer'], stack)
|
||||
|
||||
mock_nova.return_value = self.fc
|
||||
server.t = server.stack.resolve_runtime_data(server.t)
|
||||
self.fc.servers.create = mock.Mock(return_value=return_server)
|
||||
|
||||
scheduler.TaskRunner(server.create)()
|
||||
self.fc.servers.create.assert_called_once_with(
|
||||
image=744, flavor=3, key_name='test',
|
||||
name=utils.PhysName(stack_name, server.name),
|
||||
security_groups=[],
|
||||
userdata=mock.ANY, scheduler_hints=None,
|
||||
meta=None, nics=None, availability_zone=None,
|
||||
block_device_mapping=None, config_drive=None,
|
||||
disk_config=None, reservation_id=None,
|
||||
files={}, admin_pass=None)
|
||||
|
||||
@mock.patch.object(clients.OpenStackClients, 'nova')
|
||||
def test_server_create_custom_admin_pass(self, mock_nova):
|
||||
return_server = self.fc.servers.list()[1]
|
||||
return_server.adminPass = 'foo'
|
||||
stack_name = 'admin_pass_s'
|
||||
(t, stack) = self._setup_test_stack(stack_name)
|
||||
|
||||
t['Resources']['WebServer']['Properties']['admin_pass'] = 'foo'
|
||||
server = servers.Server('WebServer',
|
||||
t['Resources']['WebServer'], stack)
|
||||
|
||||
mock_nova.return_value = self.fc
|
||||
server.t = server.stack.resolve_runtime_data(server.t)
|
||||
self.fc.servers.create = mock.Mock(return_value=return_server)
|
||||
|
||||
scheduler.TaskRunner(server.create)()
|
||||
self.fc.servers.create.assert_called_once_with(
|
||||
image=744, flavor=3, key_name='test',
|
||||
name=utils.PhysName(stack_name, server.name),
|
||||
security_groups=[],
|
||||
userdata=mock.ANY, scheduler_hints=None,
|
||||
meta=None, nics=None, availability_zone=None,
|
||||
block_device_mapping=None, config_drive=None,
|
||||
disk_config=None, reservation_id=None,
|
||||
files={}, admin_pass='foo')
|
||||
|
||||
def test_server_validate(self):
|
||||
stack_name = 'srv_val'
|
||||
(t, stack) = self._setup_test_stack(stack_name)
|
||||
|
Loading…
Reference in New Issue
Block a user