Merge "Forced lowercase for instance names"
This commit is contained in:
commit
21f62fe288
|
@ -200,10 +200,13 @@ class DirectEngine(e.Engine):
|
|||
|
||||
return None
|
||||
|
||||
def _get_inst_name(self, cluster_name, ng_name, index):
|
||||
return ('%s-%s-%03d' % (cluster_name, ng_name, index)).lower()
|
||||
|
||||
def _run_instance(self, cluster, node_group, idx, aa_groups):
|
||||
"""Create instance using nova client and persist them into DB."""
|
||||
ctx = context.ctx()
|
||||
name = '%s-%s-%03d' % (cluster.name, node_group.name, idx)
|
||||
name = self._get_inst_name(cluster.name, node_group.name, idx)
|
||||
|
||||
userdata = self._generate_user_data_script(node_group, name)
|
||||
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
# Copyright (c) 2013 Mirantis Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
# implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import unittest2
|
||||
|
||||
from sahara.service import direct_engine as e
|
||||
|
||||
|
||||
class TestDirectEngine(unittest2.TestCase):
|
||||
def setUp(self):
|
||||
self.engine = e.DirectEngine()
|
||||
super(TestDirectEngine, self).setUp()
|
||||
|
||||
def test_get_inst_name(self):
|
||||
inst_name = "cluster-worker-001"
|
||||
self.assertEqual(
|
||||
self.engine._get_inst_name("cluster", "worker", 1), inst_name)
|
||||
self.assertEqual(
|
||||
self.engine._get_inst_name("CLUSTER", "WORKER", 1), inst_name)
|
|
@ -29,6 +29,7 @@ class TestHeat(unittest2.TestCase):
|
|||
def test_gets(self):
|
||||
inst_name = "cluster-worker-001"
|
||||
self.assertEqual(h._get_inst_name("cluster", "worker", 0), inst_name)
|
||||
self.assertEqual(h._get_inst_name("CLUSTER", "WORKER", 0), inst_name)
|
||||
self.assertEqual(h._get_port_name(inst_name),
|
||||
"cluster-worker-001-port")
|
||||
self.assertEqual(h._get_floating_name(inst_name),
|
||||
|
|
|
@ -36,7 +36,7 @@ def client():
|
|||
|
||||
|
||||
def _get_inst_name(cluster_name, ng_name, index):
|
||||
return '%s-%s-%03d' % (cluster_name, ng_name, (index + 1))
|
||||
return ('%s-%s-%03d' % (cluster_name, ng_name, (index + 1))).lower()
|
||||
|
||||
|
||||
def _get_port_name(inst_name):
|
||||
|
|
Loading…
Reference in New Issue