<s> from gbpautomation . heat . engine . resources import gbpresource <EOL> from heat . common . i18n import _ <EOL> from heat . engine import properties <EOL> from neutronclient . common . exceptions import NeutronClientException <EOL> class ServiceChainNode ( gbpresource . GBPResource ) : <EOL> PROPERTIES = ( <EOL> TENANT_ID , NAME , DESCRIPTION , SERVICE_TYPE , SERVICE_PROFILE_ID , <EOL> CONFIG , SHARED <EOL> ) = ( <EOL> '<STR_LIT>' , '<STR_LIT:name>' , '<STR_LIT:description>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' <EOL> ) <EOL> properties_schema = { <EOL> TENANT_ID : properties . Schema ( <EOL> properties . Schema . STRING , <EOL> _ ( '<STR_LIT>' ) <EOL> ) , <EOL> NAME : properties . Schema ( <EOL> properties . Schema . STRING , <EOL> _ ( '<STR_LIT>' ) , <EOL> update_allowed = True <EOL> ) , <EOL> DESCRIPTION : properties . Schema ( <EOL> properties . Schema . STRING , <EOL> _ ( '<STR_LIT>' ) , <EOL> update_allowed = True <EOL> ) , <EOL> SERVICE_TYPE : properties . Schema ( <EOL> properties . Schema . STRING , <EOL> _ ( '<STR_LIT>' ) , <EOL> required = False , <EOL> update_allowed = True <EOL> ) , <EOL> SERVICE_PROFILE_ID : properties . Schema ( <EOL> properties . Schema . STRING , <EOL> _ ( '<STR_LIT>' ) , <EOL> required = True , <EOL> update_allowed = True <EOL> ) , <EOL> CONFIG : properties . Schema ( <EOL> properties . Schema . STRING , <EOL> _ ( '<STR_LIT>' ) , <EOL> required = True , <EOL> update_allowed = False <EOL> ) , <EOL> SHARED : properties . Schema ( <EOL> properties . Schema . BOOLEAN , <EOL> _ ( '<STR_LIT>' ) , <EOL> update_allowed = True , required = True <EOL> ) <EOL> } <EOL> def _show_resource ( self ) : <EOL> client = self . grouppolicy ( ) <EOL> sc_node_id = self . resource_id <EOL> return client . show_servicechain_node ( sc_node_id ) [ '<STR_LIT>' ] <EOL> def handle_create ( self ) : <EOL> client = self . grouppolicy ( ) <EOL> props = { } <EOL> for key in self . properties : <EOL> if self . properties . get ( key ) is not None : <EOL> props [ key ] = self . properties . get ( key ) <EOL> sc_node = client . create_servicechain_node ( <EOL> { '<STR_LIT>' : props } ) [ '<STR_LIT>' ] <EOL> self . resource_id_set ( sc_node [ '<STR_LIT:id>' ] ) <EOL> def handle_delete ( self ) : <EOL> client = self . grouppolicy ( ) <EOL> sc_node_id = self . resource_id <EOL> try : <EOL> client . delete_servicechain_node ( sc_node_id ) <EOL> except NeutronClientException as ex : <EOL> self . client_plugin ( ) . ignore_not_found ( ex ) <EOL> else : <EOL> return self . _delete_task ( ) <EOL> def handle_update ( self , json_snippet , tmpl_diff , prop_diff ) : <EOL> if prop_diff : <EOL> self . grouppolicy ( ) . update_servicechain_node ( <EOL> self . resource_id , { '<STR_LIT>' : prop_diff } ) <EOL> class ServiceChainSpec ( gbpresource . GBPResource ) : <EOL> PROPERTIES = ( <EOL> TENANT_ID , NAME , DESCRIPTION , NODES , SHARED <EOL> ) = ( <EOL> '<STR_LIT>' , '<STR_LIT:name>' , '<STR_LIT:description>' , '<STR_LIT>' , '<STR_LIT>' <EOL> ) <EOL> properties_schema = { <EOL> TENANT_ID : properties . Schema ( <EOL> properties . Schema . STRING , <EOL> _ ( '<STR_LIT>' ) <EOL> ) , <EOL> NAME : properties . Schema ( <EOL> properties . Schema . STRING , <EOL> _ ( '<STR_LIT>' ) , <EOL> update_allowed = True <EOL> ) , <EOL> DESCRIPTION : properties . Schema ( <EOL> properties . Schema . STRING , <EOL> _ ( '<STR_LIT>' ) , <EOL> update_allowed = True <EOL> ) , <EOL> NODES : properties . Schema ( <EOL> properties . Schema . LIST , <EOL> _ ( '<STR_LIT>' ) , <EOL> required = True , <EOL> update_allowed = True <EOL> ) , <EOL> SHARED : properties . Schema ( <EOL> properties . Schema . BOOLEAN , <EOL> _ ( '<STR_LIT>' ) , <EOL> update_allowed = True , required = True <EOL> ) <EOL> } <EOL> def _show_resource ( self ) : <EOL> client = self . grouppolicy ( ) <EOL> sc_spec_id = self . resource_id <EOL> return client . show_servicechain_spec ( sc_spec_id ) [ '<STR_LIT>' ] <EOL> def handle_create ( self ) : <EOL> client = self . grouppolicy ( ) <EOL> props = { } <EOL> for key in self . properties : <EOL> if self . properties . get ( key ) is not None : <EOL> props [ key ] = self . properties . get ( key ) <EOL> sc_spec = client . create_servicechain_spec ( <EOL> { '<STR_LIT>' : props } ) [ '<STR_LIT>' ] <EOL> self . resource_id_set ( sc_spec [ '<STR_LIT:id>' ] ) <EOL> def handle_delete ( self ) : <EOL> client = self . grouppolicy ( ) <EOL> sc_spec_id = self . resource_id <EOL> try : <EOL> client . delete_servicechain_spec ( sc_spec_id ) <EOL> except NeutronClientException as ex : <EOL> self . client_plugin ( ) . ignore_not_found ( ex ) <EOL> else : <EOL> return self . _delete_task ( ) <EOL> def handle_update ( self , json_snippet , tmpl_diff , prop_diff ) : <EOL> if prop_diff : <EOL> self . grouppolicy ( ) . update_servicechain_spec ( <EOL> self . resource_id , { '<STR_LIT>' : prop_diff } ) <EOL> class ServiceProfile ( gbpresource . GBPResource ) : <EOL> PROPERTIES = ( <EOL> TENANT_ID , NAME , DESCRIPTION , SHARED , VENDOR , INSERTION_MODE , <EOL> SERVICE_TYPE , SERVICE_FLAVOR <EOL> ) = ( <EOL> '<STR_LIT>' , '<STR_LIT:name>' , '<STR_LIT:description>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' <EOL> ) <EOL> properties_schema = { <EOL> TENANT_ID : properties . Schema ( <EOL> properties . Schema . STRING , <EOL> _ ( '<STR_LIT>' ) <EOL> ) , <EOL> NAME : properties . Schema ( <EOL> properties . Schema . STRING , <EOL> _ ( '<STR_LIT>' ) , <EOL> update_allowed = True <EOL> ) , <EOL> DESCRIPTION : properties . Schema ( <EOL> properties . Schema . STRING , <EOL> _ ( '<STR_LIT>' ) , <EOL> update_allowed = True <EOL> ) , <EOL> SHARED : properties . Schema ( <EOL> properties . Schema . BOOLEAN , <EOL> _ ( '<STR_LIT>' ) , <EOL> update_allowed = True <EOL> ) , <EOL> VENDOR : properties . Schema ( <EOL> properties . Schema . STRING , <EOL> _ ( '<STR_LIT>' ) , <EOL> update_allowed = True <EOL> ) , <EOL> INSERTION_MODE : properties . Schema ( <EOL> properties . Schema . STRING , <EOL> _ ( '<STR_LIT>' ) , <EOL> update_allowed = True <EOL> ) , <EOL> SERVICE_TYPE : properties . Schema ( <EOL> properties . Schema . STRING , <EOL> _ ( '<STR_LIT>' ) , <EOL> required = True , <EOL> update_allowed = True <EOL> ) , <EOL> SERVICE_FLAVOR : properties . Schema ( <EOL> properties . Schema . STRING , <EOL> _ ( '<STR_LIT>' ) , <EOL> update_allowed = False <EOL> ) <EOL> } <EOL> def _show_resource ( self ) : <EOL> client = self . grouppolicy ( ) <EOL> svc_profile_id = self . resource_id <EOL> return client . show_service_profile ( svc_profile_id ) [ '<STR_LIT>' ] <EOL> def handle_create ( self ) : <EOL> client = self . grouppolicy ( ) <EOL> props = { } <EOL> for key in self . properties : <EOL> if self . properties . get ( key ) is not None : <EOL> props [ key ] = self . properties . get ( key ) <EOL> svc_profile = client . create_service_profile ( <EOL> { '<STR_LIT>' : props } ) [ '<STR_LIT>' ] <EOL> self . resource_id_set ( svc_profile [ '<STR_LIT:id>' ] ) <EOL> def handle_delete ( self ) : <EOL> client = self . grouppolicy ( ) <EOL> svc_profile_id = self . resource_id <EOL> try : <EOL> client . delete_service_profile ( svc_profile_id ) <EOL> except NeutronClientException as ex : <EOL> self . client_plugin ( ) . ignore_not_found ( ex ) <EOL> else : <EOL> return self . _delete_task ( ) <EOL> def handle_update ( self , json_snippet , tmpl_diff , prop_diff ) : <EOL> if prop_diff : <EOL> self . grouppolicy ( ) . update_service_profile ( <EOL> self . resource_id , { '<STR_LIT>' : prop_diff } ) <EOL> def resource_mapping ( ) : <EOL> return { <EOL> '<STR_LIT>' : ServiceChainNode , <EOL> '<STR_LIT>' : ServiceChainSpec , <EOL> '<STR_LIT>' : ServiceProfile , <EOL> } </s>
