From 2a8444e6080b7fee190b752b17cd9d9b858cbfbc Mon Sep 17 00:00:00 2001 From: eanylin Date: Wed, 14 Jun 2017 20:25:24 -0500 Subject: [PATCH] Add Dag Add basic OpenStack CLI call dag --- shipyard_airflow/dags/openstack_api_call.py | 47 +++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 shipyard_airflow/dags/openstack_api_call.py diff --git a/shipyard_airflow/dags/openstack_api_call.py b/shipyard_airflow/dags/openstack_api_call.py new file mode 100644 index 00000000..41d0b0b5 --- /dev/null +++ b/shipyard_airflow/dags/openstack_api_call.py @@ -0,0 +1,47 @@ +""" +OpenStack CLI + +Perform basic OpenStack CLI calls +""" +from airflow import DAG +from airflow.operators.bash_operator import BashOperator +from datetime import datetime, timedelta +import os + +default_args = { + 'owner': 'airflow', + 'depends_on_past': False, + 'start_date': datetime(2017, 6, 14), + 'email': ['airflow@airflow.com'], + 'email_on_failure': False, + 'email_on_retry': False, + 'retries': 1, + 'retry_delay': timedelta(minutes=5), +} + +dag = DAG('openstack_api_call', default_args=default_args, schedule_interval=None) + +# print_date +t1 = BashOperator( + task_id='print_date', + bash_command='date', + dag=dag) + +# Current assumption is that we will be able to retrieve information from +# data manager (DeckHand) to create the admin-openrc.sh that is needed for +# airflow to perform OpenStack API calls +t2 = BashOperator( + task_id='nova_list', + bash_command='source ' + os.getcwd() + '/dags/admin-openrc.sh' + ';' + 'nova' + ' list', + retries=3, + dag=dag) + +t3 = BashOperator( + task_id='neutron_net_list', + bash_command='source ' + os.getcwd() + '/dags/admin-openrc.sh' + ';' + 'neutron' + ' net-list', + retries=3, + dag=dag) + +t2.set_upstream(t1) +t3.set_upstream(t1) +