@@ -74,7 +74,8 @@ def list_templates(client):
7474 _recurse_dir (os .path .join (blueprint_dir , 'var_files' ), ['yaml' , 'yml' ])
7575
7676
77- def _create_single_blueprint (config , template_file , var_files , no_prompt , extra_vars = None ):
77+ def _create_single_blueprint (config , template_file , var_files , no_prompt ,
78+ extra_vars = None , suppress_warnings = False ):
7879 blueprint_dir = os .path .expanduser (config ['blueprint_dir' ])
7980
8081 gen = BlueprintGenerator ([os .path .join (blueprint_dir , 'templates' )])
@@ -103,7 +104,8 @@ def _create_single_blueprint(config, template_file, var_files, no_prompt, extra_
103104 return gen .generate (template_file ,
104105 final_var_files , # Pass in a list
105106 variables = extra_vars ,
106- prompt = no_prompt )
107+ prompt = no_prompt ,
108+ suppress_warnings = suppress_warnings )
107109
108110
109111@blueprints .command (name = 'create' )
@@ -170,10 +172,19 @@ def create_all_blueprints(client):
170172 raise click .UsageError ('Missing \' blueprint_dir\' in config. Please run `configure`.' )
171173 mapping = yaml .safe_load (open (os .path .join (blueprint_dir , 'mappings.yaml' ), 'r' ))
172174
175+ blueprints = client .list_blueprints ()
176+
177+ blueprint_titles = [blueprint ['title' ] for blueprint in blueprints ]
178+
173179 for name , vals in mapping .items ():
180+ if name in blueprint_titles :
181+ click .secho ('Skipping creation of {0}, it already exists.' .format (name ), fg = 'yellow' )
182+ continue
183+
174184 try :
175185 bp_json = _create_single_blueprint (client .config , vals ['template' ],
176- vals ['var_files' ], False , {'title' : name })
186+ vals ['var_files' ], False , {'title' : name },
187+ suppress_warnings = True )
177188 client .create_blueprint (bp_json )
178189 click .secho ('Created blueprint {0}' .format (name ), fg = 'green' )
179190 except BlueprintException :
0 commit comments