def setUp(self): super(TestInstance, self).setUp() self.sess = mock.Mock(spec=adapter.Adapter) self.sess.get = mock.Mock() self.sess.post = mock.Mock() self.sess.delete = mock.Mock() self.sess.put = mock.Mock() self.sot = instance.Instance()
def test_basic(self): sot = instance.Instance() self.assertEqual('scaling_group_instance', sot.resource_key) self.assertEqual('scaling_group_instances', sot.resources_key) self.assertEqual('/scaling_group_instance', sot.base_path) self.assertTrue(sot.allow_list) self.assertFalse(sot.allow_create) self.assertFalse(sot.allow_fetch) self.assertFalse(sot.allow_commit) self.assertTrue(sot.allow_delete)
def batch_instance_action( self, group, instances, action, delete_instance=False): """Batch add instances for auto scaling group :param group: The group which instances will be added to, The value can be the ID of a group or a :class:`~otcextensions.sdk.auto_scaling.v1.group.Group` instance. :param instances: The list item value can be ID of an instance or a :class:`~otcextensions.sdk.auto_scaling.v1.instance.Instance` instance :param action: Action type [``ADD``, ``REMOVE``, ``PROTECT``, ``UNPROTECT``] :param delete_instance: When set to ``True``, instance will be deleted after removed """ group = self._get_resource(_group.Group, group) instance = _instance.Instance(scaling_group_id=group.id) return instance.batch_action(self, instances, action, delete_instance)