Merge "Assign rackspace server name from physical_resource_name."
This commit is contained in:
commit
0c366c6929
|
@ -30,12 +30,12 @@ logger = logging.getLogger(__name__)
|
|||
class CloudServer(instance.Instance):
|
||||
"""Resource for Rackspace Cloud Servers."""
|
||||
|
||||
properties_schema = {'ServerName': {'Type': 'String', 'Required': True},
|
||||
'Flavor': {'Type': 'String', 'Required': True},
|
||||
properties_schema = {'Flavor': {'Type': 'String', 'Required': True},
|
||||
'ImageName': {'Type': 'String', 'Required': True},
|
||||
'UserData': {'Type': 'String'},
|
||||
'key_name': {'Type': 'String'},
|
||||
'Volumes': {'Type': 'List'}}
|
||||
'Volumes': {'Type': 'List'},
|
||||
'name': {'Type': 'String'}}
|
||||
|
||||
attributes_schema = {'PrivateDnsName': ('Private DNS name of the specified'
|
||||
' instance.'),
|
||||
|
@ -146,7 +146,7 @@ zypper --non-interactive in cloud-init python-boto python-pip gcc python-devel
|
|||
# Template keys supported for handle_update. Properties not
|
||||
# listed here trigger an UpdateReplace
|
||||
update_allowed_keys = ('Metadata', 'Properties')
|
||||
update_allowed_properties = ('Flavor', 'ServerName')
|
||||
update_allowed_properties = ('Flavor', 'name')
|
||||
|
||||
def __init__(self, name, json_snippet, stack):
|
||||
super(CloudServer, self).__init__(name, json_snippet, stack)
|
||||
|
@ -155,6 +155,13 @@ zypper --non-interactive in cloud-init python-boto python-pip gcc python-devel
|
|||
json_snippet,
|
||||
stack)
|
||||
|
||||
def physical_resource_name(self):
|
||||
name = self.properties.get('name')
|
||||
if name:
|
||||
return name
|
||||
|
||||
return super(CloudServer, self).physical_resource_name()
|
||||
|
||||
def nova(self):
|
||||
return self.rs.nova() # Override the Instance method
|
||||
|
||||
|
@ -320,7 +327,7 @@ zypper --non-interactive in cloud-init python-boto python-pip gcc python-devel
|
|||
|
||||
# Create server
|
||||
client = self.nova().servers
|
||||
server = client.create(self.properties['ServerName'],
|
||||
server = client.create(self.physical_resource_name(),
|
||||
self.image_id,
|
||||
flavor,
|
||||
files=personality_files)
|
||||
|
@ -426,12 +433,12 @@ zypper --non-interactive in cloud-init python-boto python-pip gcc python-devel
|
|||
self.flavor)
|
||||
resize(wait_time=1.0)
|
||||
|
||||
# If ServerName is the only update, fail update
|
||||
if prop_diff.keys() == ['ServerName'] and \
|
||||
# If name is the only update, fail update
|
||||
if prop_diff.keys() == ['name'] and \
|
||||
tmpl_diff.keys() == ['Properties']:
|
||||
raise exception.NotSupported(feature="Cloud Server rename")
|
||||
# Other updates were successful, so don't cause update to fail
|
||||
elif 'ServerName' in prop_diff:
|
||||
elif 'name' in prop_diff:
|
||||
logger.info("Cloud Server rename not supported.")
|
||||
|
||||
return True
|
||||
|
|
|
@ -28,6 +28,7 @@ from heat.engine.resources.rackspace import cloud_server
|
|||
from heat.engine.resources.rackspace import rackspace_resource
|
||||
from heat.openstack.common import uuidutils
|
||||
from heat.tests.common import HeatTestCase
|
||||
from heat.tests import utils
|
||||
from heat.tests.utils import setup_dummy_db
|
||||
|
||||
|
||||
|
@ -49,7 +50,6 @@ wp_template = '''
|
|||
"Type": "Rackspace::Cloud::Server",
|
||||
"Properties": {
|
||||
"ImageName" : "Fedora 17 (Beefy Miracle)",
|
||||
"ServerName" : "Heat test",
|
||||
"Flavor" : "2",
|
||||
"UserData" : "wordpress"
|
||||
}
|
||||
|
@ -150,8 +150,6 @@ class RackspaceCloudServerTest(HeatTestCase):
|
|||
stack_name = '%s_stack' % name
|
||||
(t, stack) = self._setup_test_stack(stack_name)
|
||||
|
||||
server_name = "Heat test"
|
||||
t['Resources']['WebServer']['Properties']['ServerName'] = server_name
|
||||
cs_name = 'Fedora 17 (Beefy Miracle)'
|
||||
t['Resources']['WebServer']['Properties']['ImageName'] = cs_name
|
||||
t['Resources']['WebServer']['Properties']['Flavor'] = '2'
|
||||
|
@ -164,7 +162,8 @@ class RackspaceCloudServerTest(HeatTestCase):
|
|||
flavor = t['Resources']['WebServer']['Properties']['Flavor']
|
||||
|
||||
self.m.StubOutWithMock(self.fc.servers, 'create')
|
||||
self.fc.servers.create(server_name, "1", flavor,
|
||||
self.fc.servers.create(utils.PhysName(stack_name, cs.name),
|
||||
"1", flavor,
|
||||
files=mox.IgnoreArg()).AndReturn(return_server)
|
||||
return_server.adminPass = "foobar"
|
||||
|
||||
|
|
Loading…
Reference in New Issue