def translation_rules(self, props): if self.is_using_neutron(): translation_rules = [ translation.TranslationRule( props, translation.TranslationRule.RESOLVE, [self.NEUTRON_NETWORK], client_plugin=self.client_plugin('neutron'), finder='find_resourceid_by_name_or_id', entity='network'), translation.TranslationRule( props, translation.TranslationRule.RESOLVE, [self.NEUTRON_SUBNET], client_plugin=self.client_plugin('neutron'), finder='find_resourceid_by_name_or_id', entity='subnet') ] else: translation_rules = [ translation.TranslationRule( props, translation.TranslationRule.RESOLVE, [self.NOVA_NETWORK], client_plugin=self.client_plugin('nova'), finder='get_nova_network_id') ] return translation_rules
def translation_rules(self, props): rules = [ translation.TranslationRule( props, translation.TranslationRule.REPLACE, [self.IMAGE_ID], value_path=[self.IMAGE]), translation.TranslationRule( props, translation.TranslationRule.RESOLVE, [self.IMAGE_ID], client_plugin=self.client_plugin('glance'), finder='find_image_by_name_or_id')] if self.is_using_neutron(): rules.extend([ translation.TranslationRule( props, translation.TranslationRule.RESOLVE, [self.MANAGEMENT_NETWORK], client_plugin=self.client_plugin('neutron'), finder='find_resourceid_by_name_or_id', entity='network')]) else: rules.extend([ translation.TranslationRule( props, translation.TranslationRule.RESOLVE, [self.MANAGEMENT_NETWORK], client_plugin=self.client_plugin('nova'), finder='get_nova_network_id')]) return rules
def translation_rules(self, props): return [ translation.TranslationRule( props, translation.TranslationRule.REPLACE, [self.NETWORK], value_path=[self.NETWORK_ID] ), translation.TranslationRule( props, translation.TranslationRule.REPLACE, [self.FIXED_IPS, self.FIXED_IP_SUBNET], value_name=self.FIXED_IP_SUBNET_ID ), translation.TranslationRule( props, translation.TranslationRule.RESOLVE, [self.NETWORK], client_plugin=self.client_plugin(), finder='find_resourceid_by_name_or_id', entity='network' ), translation.TranslationRule( props, translation.TranslationRule.RESOLVE, [self.FIXED_IPS, self.FIXED_IP_SUBNET], client_plugin=self.client_plugin(), finder='find_resourceid_by_name_or_id', entity='subnet' ) ]
def translation_rules(self, props): return [ translation.TranslationRule( props, translation.TranslationRule.REPLACE, [self.NETWORK], value_path=[self.NETWORK_ID]), translation.TranslationRule( props, translation.TranslationRule.RESOLVE, [self.NETWORK], client_plugin=self.client_plugin(), finder='find_resourceid_by_name_or_id', entity='network' ), translation.TranslationRule( props, translation.TranslationRule.RESOLVE, [self.SUBNETPOOL], client_plugin=self.client_plugin(), finder='find_resourceid_by_name_or_id', entity='subnetpool' ), translation.TranslationRule( props, translation.TranslationRule.RESOLVE, [self.SEGMENT], client_plugin=self.client_plugin('openstack'), finder='find_network_segment' ) ]
def translation_rules(self, props): return [ translation.TranslationRule( props, translation.TranslationRule.RESOLVE, [self.EXTERNAL_NETWORK], client_plugin=self.client_plugin('neutron'), finder='find_resourceid_by_name_or_id', entity='network' ), translation.TranslationRule( props, translation.TranslationRule.RESOLVE, [self.FIXED_NETWORK], client_plugin=self.client_plugin('neutron'), finder='find_resourceid_by_name_or_id', entity='network' ), translation.TranslationRule( props, translation.TranslationRule.RESOLVE, [self.FIXED_SUBNET], client_plugin=self.client_plugin('neutron'), finder='find_resourceid_by_name_or_id', entity='subnet' ) ]
def test_cmp_rules(self): rules = [ translation.TranslationRule( mock.Mock(spec=properties.Properties), translation.TranslationRule.DELETE, ['any'] ), translation.TranslationRule( mock.Mock(spec=properties.Properties), translation.TranslationRule.ADD, ['any'] ), translation.TranslationRule( mock.Mock(spec=properties.Properties), translation.TranslationRule.RESOLVE, ['any'], client_plugin=mock.ANY, finder=mock.ANY ), translation.TranslationRule( mock.Mock(spec=properties.Properties), translation.TranslationRule.REPLACE, ['any'] ) ] expected = [translation.TranslationRule.ADD, translation.TranslationRule.REPLACE, translation.TranslationRule.RESOLVE, translation.TranslationRule.DELETE] result = [rule.rule for rule in sorted(rules)] self.assertEqual(expected, result)
def translation_rules(self, props): rules = [ translation.TranslationRule( props, translation.TranslationRule.RESOLVE, [self.EXTERNAL_GATEWAY, self.EXTERNAL_GATEWAY_NETWORK], client_plugin=self.client_plugin(), finder='find_resourceid_by_name_or_id', entity='network'), translation.TranslationRule( props, translation.TranslationRule.RESOLVE, [ self.EXTERNAL_GATEWAY, self.EXTERNAL_GATEWAY_FIXED_IPS, self.SUBNET ], client_plugin=self.client_plugin(), finder='find_resourceid_by_name_or_id', entity='subnet') ] if props.get(self.L3_AGENT_ID): rules.extend([ translation.TranslationRule(props, translation.TranslationRule.ADD, [self.L3_AGENT_IDS], [props.get(self.L3_AGENT_ID)]), translation.TranslationRule(props, translation.TranslationRule.DELETE, [self.L3_AGENT_ID]) ]) return rules
def translation_rules(self, props): return [ translation.TranslationRule(props, translation.TranslationRule.REPLACE, [self.SUBNET], value_path=[self.SUBNET_ID]), translation.TranslationRule(props, translation.TranslationRule.REPLACE, [self.ROUTER], value_path=[self.ROUTER_ID]) ]
def translation_rules(self, props): if props.get(self.L3_AGENT_ID): return [ translation.TranslationRule(props, translation.TranslationRule.ADD, [self.L3_AGENT_IDS], [props.get(self.L3_AGENT_ID)]), translation.TranslationRule(props, translation.TranslationRule.DELETE, [self.L3_AGENT_ID]) ]
def translation_rules(self, props): return [ translation.TranslationRule(props, translation.TranslationRule.RESOLVE, [self.VOLUME_TYPES], client_plugin=self.client_plugin(), finder='get_volume_type'), translation.TranslationRule(props, translation.TranslationRule.RESOLVE, [self.QOS_SPECS], client_plugin=self.client_plugin(), finder='get_qos_specs') ]
def translation_rules(self, properties): return [ translation.TranslationRule(properties, translation.TranslationRule.RESOLVE, [self.QOS_POLICY], client_plugin=self.client_plugin(), finder='get_qos_policy_id'), translation.TranslationRule( properties, translation.TranslationRule.RESOLVE, [self.TENANT_ID], client_plugin=self.client_plugin('keystone'), finder='get_project_id'), ]
def translation_rules(self, props): return [ translation.TranslationRule(props, translation.TranslationRule.REPLACE, [self.FLOATING_NETWORK], value_path=[self.FLOATING_NETWORK_ID]), translation.TranslationRule(props, translation.TranslationRule.RESOLVE, [self.FLOATING_NETWORK], client_plugin=self.client_plugin(), finder='find_resourceid_by_name_or_id', entity='network') ]
def translation_rules(self, props): return [ translation.TranslationRule(props, translation.TranslationRule.REPLACE, [self.CONNECTIONS, self.NETWORK], value_name=self.NETWORK_ID), translation.TranslationRule(props, translation.TranslationRule.RESOLVE, [self.CONNECTIONS, self.NETWORK], client_plugin=self.client_plugin(), finder='find_resourceid_by_name_or_id', entity='network') ]
def translation_rules(self, properties): return [ translation.TranslationRule(properties, translation.TranslationRule.RESOLVE, [self.DOMAIN], client_plugin=self.client_plugin(), finder='get_domain_id'), translation.TranslationRule(properties, translation.TranslationRule.RESOLVE, [self.PARENT], client_plugin=self.client_plugin(), finder='get_project_id'), ]
def translation_rules(self, props): return [ translation.TranslationRule( props, translation.TranslationRule.RESOLVE, [self.NODE], client_plugin=self.client_plugin('ironic'), finder='get_node'), translation.TranslationRule( props, translation.TranslationRule.RESOLVE, [self.PORTGROUP], client_plugin=self.client_plugin('ironic'), finder='get_portgroup'), ]
def translation_rules(self, props): return [ translation.TranslationRule(props, translation.TranslationRule.RESOLVE, [self.SERVICE], client_plugin=self.client_plugin(), finder='get_service_id'), translation.TranslationRule(props, translation.TranslationRule.RESOLVE, [self.REGION], client_plugin=self.client_plugin(), finder='get_region_id'), ]
def translation_rules(self, props): return [ translation.TranslationRule( props, translation.TranslationRule.RESOLVE, [self.FLAVOR], client_plugin=self.client_plugin('nova'), finder='find_flavor_by_name_or_id'), translation.TranslationRule( props, translation.TranslationRule.RESOLVE, [self.FLOATING_IP_POOL], client_plugin=self.client_plugin('neutron'), finder='find_resourceid_by_name_or_id', entity='network') ]
def translation_rules(self, props): rules = [ translation.TranslationRule(props, translation.TranslationRule.RESOLVE, translation_path=[self.PROFILE], client_plugin=self.client_plugin(), finder='get_profile_id'), translation.TranslationRule(props, translation.TranslationRule.RESOLVE, translation_path=[self.CLUSTER], client_plugin=self.client_plugin(), finder='get_cluster_id'), ] return rules
def translation_rules(self, props): return [ translation.TranslationRule( props, translation.TranslationRule.RESOLVE, [self.SUBNET], client_plugin=self.client_plugin('neutron'), finder='find_resourceid_by_name_or_id', entity='subnet'), translation.TranslationRule(props, translation.TranslationRule.RESOLVE, [self.POOL], client_plugin=self.client_plugin(), finder='get_pool'), ]
def translation_rules(self, props): client_plugin = self.client_plugin() return [ translation.TranslationRule(props, translation.TranslationRule.REPLACE, [self.NETWORK], value_path=[self.NETWORK_ID]), translation.TranslationRule(props, translation.TranslationRule.RESOLVE, [self.NETWORK], client_plugin=client_plugin, finder='find_resourceid_by_name_or_id', entity=client_plugin.RES_TYPE_NETWORK) ]
def translation_rules(self, props): if props.get(self.SEQUENCE): return [ translation.TranslationRule( props, translation.TranslationRule.ADD, [self.CHARACTER_CLASSES], [{ self.CHARACTER_CLASSES_CLASS: props.get(self.SEQUENCE), self.CHARACTER_CLASSES_MIN: 1 }]), translation.TranslationRule(props, translation.TranslationRule.DELETE, [self.SEQUENCE]) ]
def translation_rules(self, props): return [ translation.TranslationRule(props, translation.TranslationRule.RESOLVE, [self.INGRESS], client_plugin=self.client_plugin(), finder='find_resourceid_by_name_or_id', entity='port'), translation.TranslationRule(props, translation.TranslationRule.RESOLVE, [self.EGRESS], client_plugin=self.client_plugin(), finder='find_resourceid_by_name_or_id', entity='port') ]
def translation_rules(self, props): rules = [ translation.TranslationRule(props, translation.TranslationRule.RESOLVE, translation_path=[self.PROFILE], client_plugin=self.client_plugin(), finder='get_profile_id'), translation.TranslationRule( props, translation.TranslationRule.RESOLVE, translation_path=[self.POLICIES, self.P_POLICY], client_plugin=self.client_plugin(), finder='get_policy_id'), ] return rules
def translation_rules(self, props): return [ translation.TranslationRule(props, translation.TranslationRule.RESOLVE, [self.LOADBALANCER], client_plugin=self.client_plugin(), finder='find_resourceid_by_name_or_id', entity='loadbalancer'), translation.TranslationRule(props, translation.TranslationRule.RESOLVE, [self.DEFAULT_POOL], client_plugin=self.client_plugin(), finder='find_resourceid_by_name_or_id', entity='pool'), ]
def translation_rules(self, props): return [ translation.TranslationRule(props, translation.TranslationRule.RESOLVE, [self.PORT], client_plugin=self.client_plugin(), finder='find_resourceid_by_name_or_id', entity='port'), translation.TranslationRule(props, translation.TranslationRule.RESOLVE, [self.TAP_SERVICE], client_plugin=self.client_plugin(), finder='find_resourceid_by_name_or_id', entity='tap_service') ]
def translation_rules(self, props): return [ translation.TranslationRule( props, translation.TranslationRule.REPLACE, [self.NETWORK], value_path=[self.NETWORK_ID] ), translation.TranslationRule( props, translation.TranslationRule.REPLACE, [self.FIXED_IPS, self.FIXED_IP_SUBNET], value_name=self.FIXED_IP_SUBNET_ID ) ]
def translation_rules(self, props): return [ translation.TranslationRule(props, translation.TranslationRule.RESOLVE, [self.LOGICAL_SOURCE_PORT], client_plugin=self.client_plugin(), finder='find_resourceid_by_name_or_id', entity='port'), translation.TranslationRule(props, translation.TranslationRule.RESOLVE, [self.LOGICAL_DESTINATION_PORT], client_plugin=self.client_plugin(), finder='find_resourceid_by_name_or_id', entity='port') ]
def translation_rules(self, props): return [ translation.TranslationRule( props, translation.TranslationRule.RESOLVE, [self.LOADBALANCER], client_plugin=self.client_plugin(), finder='get_loadbalancer', ), translation.TranslationRule(props, translation.TranslationRule.RESOLVE, [self.DEFAULT_POOL], client_plugin=self.client_plugin(), finder='get_pool'), ]
def translation_rules(self, props): if props.get(self.SSH_AUTHORIZED_KEY): return [ translation.TranslationRule(props, translation.TranslationRule.DELETE, [self.SSH_AUTHORIZED_KEY]) ]
def test_resolve_rule_other_with_get_attr(self): client_plugin, schema = self._test_resolve_rule() class DummyStack(dict): pass class rsrc(object): pass stack = DummyStack(another_res=rsrc()) attr_func = cfn_funcs.GetAtt(stack, 'Fn::GetAtt', ['another_res', 'name']) data = {'far': attr_func} props = properties.Properties(schema, data) rule = translation.TranslationRule( props, translation.TranslationRule.RESOLVE, ['far'], client_plugin=client_plugin, finder='find_name_id') tran = translation.Translation(props) tran.set_rules([rule], client_resolve=False) self.assertFalse(tran.store_translated_values) self.assertFalse(tran.has_translation('far')) result = tran.translate('far', 'no_check', data['far']) self.assertEqual('no_check', result) self.assertIsNone(tran.resolved_translations.get('far'))