This call converts a stack name into a fully-qualified stack identifier.
This allows us to, e.g., add support for keeping deleted stacks around in
the database while still allowing stack names to be reused, since the
deleted stacks can be referenced using this ID.
Change-Id: Ide19841a92a25d2f6172f19c2627d24ab6d2fd63
Signed-off-by: Zane Bitter <zbitter@redhat.com>
"""Load configuration options and connect to the hypervisor."""
pass
+ def identify_stack(self, context, stack_name):
+ """
+ The identify_stack method returns the full stack identifier for a
+ single, live stack given the stack name.
+ arg1 -> RPC context.
+ arg2 -> Name of the stack to look up.
+ """
+ auth.authenticate(context)
+
+ s = db_api.stack_get_by_name(context, stack_name)
+ if s:
+ stack = parser.Stack.load(context, s.id)
+ return stack.identifier()
+ else:
+ raise AttributeError('Unknown stack name')
+
def show_stack(self, context, stack_name, params):
"""
The show_stack method returns the attributes of one stack.
topic=FLAGS.engine_topic,
default_version=self.BASE_RPC_API_VERSION)
+ def identify_stack(self, ctxt, stack_name):
+ """
+ The identify_stack method returns the full stack identifier for a
+ single, live stack given the stack name.
+
+ :param ctxt: RPC context.
+ :param stack_name: Name of the stack you want to see,
+ or None to see all
+ """
+ return self.call(ctxt, self.make_msg('identify_stack',
+ stack_name=stack_name,
+ topic=_engine_topic(self.topic,
+ ctxt,
+ None)))
+
def show_stack(self, ctxt, stack_name, params):
"""
The show_stack method returns the attributes of one stack.
stack.store()
stack.create()
cls.stack = stack
+ cls.stack_identity = stack.identifier()
m.UnsetStubs()
def tearDown(self):
self.m.UnsetStubs()
+ def test_stack_identify(self):
+ identity = self.man.identify_stack(self.ctx, self.stack_name)
+ self.assertEqual(identity, self.stack_identity)
+
+ def test_stack_identify_nonexist(self):
+ self.assertRaises(AttributeError, self.man.identify_stack,
+ self.ctx, 'wibble')
+
def test_stack_event_list(self):
el = self.man.list_events(self.ctx, self.stack_name, {})