From 340b8a83825a14ab883f2a2a46e18d735ac10902 Mon Sep 17 00:00:00 2001
From: Charlotte Hausman <chausman@nrao.edu>
Date: Tue, 14 Sep 2021 12:38:33 -0400
Subject: [PATCH] Relocatable Null

---
 .../app/workspaces/workspaces.component.html  | 20 +++++
 .../app/workspaces/workspaces.component.ts    | 14 ++++
 ...99abc_make_null_relocatable_for_testing.py | 73 +++++++++++++++++++
 schema/versions/42a9e35d0809_.py              | 24 ++++++
 4 files changed, 131 insertions(+)
 create mode 100644 schema/versions/257537f99abc_make_null_relocatable_for_testing.py
 create mode 100644 schema/versions/42a9e35d0809_.py

diff --git a/apps/web/src/app/workspaces/workspaces.component.html b/apps/web/src/app/workspaces/workspaces.component.html
index 89d6a4e75..29b5c9d9d 100644
--- a/apps/web/src/app/workspaces/workspaces.component.html
+++ b/apps/web/src/app/workspaces/workspaces.component.html
@@ -11,6 +11,26 @@
         Launch null capability
       </button>
     </div>
+    <div class="d-flex px-2">
+      <button
+        type="button"
+        id="launchNullCapabilityCVBtn"
+        class="btn btn-secondary btn-lg"
+        (click)="nullCVButtonOnClick()"
+      >
+        Launch null at CV-NAASC
+      </button>
+    </div>
+    <div class="d-flex px-2">
+      <button
+        type="button"
+        id="launchNullCapabilityNMTBtn"
+        class="btn btn-secondary btn-lg"
+        (click)="nullNMTButtonOnClick()"
+      >
+        Launch null at NMT
+      </button>
+    </div>
   </div>
 </div>
 <div class="container border rounded py-3 my-3">
diff --git a/apps/web/src/app/workspaces/workspaces.component.ts b/apps/web/src/app/workspaces/workspaces.component.ts
index 945c7cb2b..d030db138 100644
--- a/apps/web/src/app/workspaces/workspaces.component.ts
+++ b/apps/web/src/app/workspaces/workspaces.component.ts
@@ -37,6 +37,20 @@ export class WorkspacesComponent implements OnInit {
     this.launchCapability("null", { arguments: "-g" });
   }
 
+  /**
+   * OnClick method that creates a capability request for the null capability and submits it to CV-NAASC
+   */
+  nullCVButtonOnClick(): void {
+    this.launchCapability("null", { arguments: "-g", "remote-cv": true });
+  }
+
+  /**
+   * OnClick method that creates a capability request for the null capability and submits it to CV-NAASC
+   */
+  nullNMTButtonOnClick(): void {
+    this.launchCapability("null", { arguments: "-g", remote: true });
+  }
+
   /**
    * OnClick method that creates a capability request a given capability and submits it with the standard parameters:
    * - Product locator
diff --git a/schema/versions/257537f99abc_make_null_relocatable_for_testing.py b/schema/versions/257537f99abc_make_null_relocatable_for_testing.py
new file mode 100644
index 000000000..ac1975643
--- /dev/null
+++ b/schema/versions/257537f99abc_make_null_relocatable_for_testing.py
@@ -0,0 +1,73 @@
+"""make null relocatable for testing
+
+Revision ID: 257537f99abc
+Revises: 42a9e35d0809
+Create Date: 2021-09-14 09:52:41.666489
+
+"""
+from alembic import op
+import sqlalchemy as sa
+
+
+# revision identifiers, used by Alembic.
+revision = "257537f99abc"
+down_revision = "42a9e35d0809"
+branch_labels = None
+depends_on = None
+
+condor_content = """executable = null.sh
+arguments = {{arguments}}
+
+output = null.out
+error = null.err
+log = condor.log
+should_transfer_files = yes
+transfer_input_files = /lustre/aoc/cluster/pipeline/$ENV(CAPO_PROFILE)/workspaces/sbin/null
+
+{{#remote-cv}}
+#run on a condor node in CV-NAASC
+requirements = (CVPOST == True)
++partition = "CVPOST"
+{{/remote-cv}}
+
+{{#remote}}
+#run on a NMT condor node. (naming consistent with vlass-seci)
+requirements = (HasLustre =!= True)
+{{/remote}}
+
+queue
+
+"""
+
+
+old_content = """executable = null.sh
+arguments = {{arguments}}
+
+output = null.out
+error = null.err
+log = null.log
+should_transfer_files = yes
+transfer_input_files = /lustre/aoc/cluster/pipeline/$ENV(CAPO_PROFILE)/workspaces/sbin/null
+
+
+queue
+
+"""
+
+
+def upgrade():
+    op.execute(
+        f"""
+        UPDATE workflow_templates
+        SET content=E'{condor_content}' WHERE filename='null.condor'
+        """
+    )
+
+
+def downgrade():
+    op.execute(
+        f"""
+        UPDATE workflow_templates
+        SET content=E'{old_content}' WHERE filename='null.condor'
+        """
+    )
diff --git a/schema/versions/42a9e35d0809_.py b/schema/versions/42a9e35d0809_.py
new file mode 100644
index 000000000..2eaec9831
--- /dev/null
+++ b/schema/versions/42a9e35d0809_.py
@@ -0,0 +1,24 @@
+"""empty message
+
+Revision ID: 42a9e35d0809
+Revises: af3e4a4e7ede, 0953fe9fb794
+Create Date: 2021-09-14 09:52:37.645654
+
+"""
+from alembic import op
+import sqlalchemy as sa
+
+
+# revision identifiers, used by Alembic.
+revision = '42a9e35d0809'
+down_revision = ('af3e4a4e7ede', '0953fe9fb794')
+branch_labels = None
+depends_on = None
+
+
+def upgrade():
+    pass
+
+
+def downgrade():
+    pass
-- 
GitLab