This is an automated email from the ASF dual-hosted git repository.
omartushevskyi pushed a commit to branch DLAB-1546
in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git
The following commit(s) were added to refs/heads/DLAB-1546 by this push:
new 30389c9 [DLAB-1546]: added name convention changes
30389c9 is described below
commit 30389c990dd7b32ba0b946714266416fde412c23
Author: Oleh Martushevskyi <[email protected]>
AuthorDate: Fri Feb 28 13:50:05 2020 +0200
[DLAB-1546]: added name convention changes
---
.../scripts/azure/common_create_notebook_image.py | 1 +
.../azure/common_notebook_configure_dataengine.py | 2 +
.../scripts/azure/common_prepare_notebook.py | 1 +
.../general/scripts/azure/common_start_notebook.py | 1 +
.../scripts/azure/common_terminate_notebook.py | 2 +-
.../src/general/scripts/azure/dataengine_start.py | 1 +
.../scripts/azure/deeplearning_configure.py | 64 ++++----
.../src/general/scripts/azure/edge_configure.py | 1 +
.../src/general/scripts/azure/edge_status.py | 1 +
.../src/general/scripts/azure/edge_terminate.py | 32 ++--
.../src/general/scripts/azure/jupyter_configure.py | 75 ++++-----
.../general/scripts/azure/jupyterlab_configure.py | 180 ++++++++++-----------
.../src/general/scripts/azure/project_prepare.py | 1 +
.../src/general/scripts/azure/rstudio_configure.py | 75 ++++-----
.../src/general/scripts/azure/tensor_configure.py | 79 ++++-----
.../general/scripts/azure/zeppelin_configure.py | 77 ++++-----
16 files changed, 306 insertions(+), 287 deletions(-)
diff --git
a/infrastructure-provisioning/src/general/scripts/azure/common_create_notebook_image.py
b/infrastructure-provisioning/src/general/scripts/azure/common_create_notebook_image.py
index 10e6fb9..e84d573 100644
---
a/infrastructure-provisioning/src/general/scripts/azure/common_create_notebook_image.py
+++
b/infrastructure-provisioning/src/general/scripts/azure/common_create_notebook_image.py
@@ -28,6 +28,7 @@ import os
import traceback
import sys
import json
+from fabric.api import *
if __name__ == "__main__":
diff --git
a/infrastructure-provisioning/src/general/scripts/azure/common_notebook_configure_dataengine.py
b/infrastructure-provisioning/src/general/scripts/azure/common_notebook_configure_dataengine.py
index f28b66c..55bafa4 100644
---
a/infrastructure-provisioning/src/general/scripts/azure/common_notebook_configure_dataengine.py
+++
b/infrastructure-provisioning/src/general/scripts/azure/common_notebook_configure_dataengine.py
@@ -29,6 +29,8 @@ import dlab.actions_lib
import dlab.meta_lib
import os
import uuid
+from fabric.api import *
+import traceback
def clear_resources():
diff --git
a/infrastructure-provisioning/src/general/scripts/azure/common_prepare_notebook.py
b/infrastructure-provisioning/src/general/scripts/azure/common_prepare_notebook.py
index 4b15d64..fea0c74 100644
---
a/infrastructure-provisioning/src/general/scripts/azure/common_prepare_notebook.py
+++
b/infrastructure-provisioning/src/general/scripts/azure/common_prepare_notebook.py
@@ -30,6 +30,7 @@ import dlab.fab
import dlab.actions_lib
import dlab.meta_lib
import traceback
+from fabric.api import *
if __name__ == "__main__":
diff --git
a/infrastructure-provisioning/src/general/scripts/azure/common_start_notebook.py
b/infrastructure-provisioning/src/general/scripts/azure/common_start_notebook.py
index 7c391f6..ab3c080 100644
---
a/infrastructure-provisioning/src/general/scripts/azure/common_start_notebook.py
+++
b/infrastructure-provisioning/src/general/scripts/azure/common_start_notebook.py
@@ -31,6 +31,7 @@ import traceback
import os
import uuid
import argparse
+from fabric.api import *
if __name__ == "__main__":
diff --git
a/infrastructure-provisioning/src/general/scripts/azure/common_terminate_notebook.py
b/infrastructure-provisioning/src/general/scripts/azure/common_terminate_notebook.py
index 4fc6d9f..e28754f 100644
---
a/infrastructure-provisioning/src/general/scripts/azure/common_terminate_notebook.py
+++
b/infrastructure-provisioning/src/general/scripts/azure/common_terminate_notebook.py
@@ -99,4 +99,4 @@ if __name__ == "__main__":
result.write(json.dumps(res))
except Exception as err:
dlab.fab.append_result("Error with writing results", str(err))
- sys.exit(1)
\ No newline at end of file
+ sys.exit(1)
diff --git
a/infrastructure-provisioning/src/general/scripts/azure/dataengine_start.py
b/infrastructure-provisioning/src/general/scripts/azure/dataengine_start.py
index 6e27e96..329321e 100644
--- a/infrastructure-provisioning/src/general/scripts/azure/dataengine_start.py
+++ b/infrastructure-provisioning/src/general/scripts/azure/dataengine_start.py
@@ -30,6 +30,7 @@ import dlab.meta_lib
import os
import traceback
import uuid
+from fabric.api import *
def start_data_engine(resource_group_name, cluster_name):
diff --git
a/infrastructure-provisioning/src/general/scripts/azure/deeplearning_configure.py
b/infrastructure-provisioning/src/general/scripts/azure/deeplearning_configure.py
index 32bc774..e1743b3 100644
---
a/infrastructure-provisioning/src/general/scripts/azure/deeplearning_configure.py
+++
b/infrastructure-provisioning/src/general/scripts/azure/deeplearning_configure.py
@@ -29,6 +29,7 @@ import dlab.fab
import dlab.actions_lib
import dlab.meta_lib
import os
+from fabric.api import *
if __name__ == "__main__":
@@ -40,6 +41,8 @@ if __name__ == "__main__":
filename=local_log_filepath)
try:
+ AzureMeta = dlab.meta_lib.AzureMeta()
+ AzureActions = dlab.actions_lib.AzureActions()
notebook_config = dict()
try:
notebook_config['exploratory_name'] =
os.environ['exploratory_name'].lower()
@@ -97,25 +100,25 @@ if __name__ == "__main__":
"endpoint_tag":
notebook_config['endpoint_tag'],
"Exploratory":
notebook_config['exploratory_name'],
os.environ['conf_billing_tag_key']:
os.environ['conf_billing_tag_value']}
- notebook_config['ip_address'] =
AzureMeta().get_private_ip_address(notebook_config['resource_group_name'],
+ notebook_config['ip_address'] =
AzureMeta.get_private_ip_address(notebook_config['resource_group_name'],
notebook_config['instance_name'])
# generating variables regarding EDGE proxy on Notebook instance
- instance_hostname =
AzureMeta().get_private_ip_address(notebook_config['resource_group_name'],
-
notebook_config['instance_name'])
+ instance_hostname =
AzureMeta.get_private_ip_address(notebook_config['resource_group_name'],
+
notebook_config['instance_name'])
edge_instance_name =
'{0}-{1}-{2}-edge'.format(notebook_config['service_base_name'],
notebook_config['project_name'],
notebook_config['endpoint_name'])
- edge_instance_private_hostname =
AzureMeta().get_private_ip_address(notebook_config['resource_group_name'],
-
edge_instance_name)
+ edge_instance_private_hostname =
AzureMeta.get_private_ip_address(notebook_config['resource_group_name'],
+
edge_instance_name)
if os.environ['conf_network_type'] == 'private':
- edge_instance_hostname =
AzureMeta().get_private_ip_address(notebook_config['resource_group_name'],
-
edge_instance_name)
+ edge_instance_hostname =
AzureMeta.get_private_ip_address(notebook_config['resource_group_name'],
+
edge_instance_name)
else:
- edge_instance_hostname =
AzureMeta().get_instance_public_ip_address(notebook_config['resource_group_name'],
-
edge_instance_name)
+ edge_instance_hostname =
AzureMeta.get_instance_public_ip_address(notebook_config['resource_group_name'],
+
edge_instance_name)
keyfile_name = "{}{}.pem".format(os.environ['conf_key_dir'],
os.environ['conf_key_name'])
- edge_hostname =
AzureMeta().get_private_ip_address(notebook_config['resource_group_name'],
+ edge_hostname =
AzureMeta.get_private_ip_address(notebook_config['resource_group_name'],
edge_instance_name)
if os.environ['conf_os_family'] == 'debian':
@@ -126,7 +129,7 @@ if __name__ == "__main__":
notebook_config['sudo_group'] = 'wheel'
except Exception as err:
dlab.fab.append_result("Failed to generate variables dictionary",
str(err))
- AzureActions().remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
+ AzureActions.remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
sys.exit(1)
try:
@@ -143,7 +146,7 @@ if __name__ == "__main__":
raise Exception
except Exception as err:
dlab.fab.append_result("Failed creating ssh user 'dlab-user'.",
str(err))
- AzureActions().remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
+ AzureActions.remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
sys.exit(1)
# configuring proxy on Notebook instance
@@ -161,7 +164,7 @@ if __name__ == "__main__":
raise Exception
except Exception as err:
dlab.fab.append_result("Failed to configure proxy.", str(err))
- AzureActions().remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
+ AzureActions.remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
sys.exit(1)
try:
@@ -178,7 +181,7 @@ if __name__ == "__main__":
raise Exception
except Exception as err:
dlab.fab.append_result("Failed installing users key.", str(err))
- AzureActions().remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
+ AzureActions.remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
sys.exit(1)
# updating repositories & installing python packages
@@ -195,7 +198,7 @@ if __name__ == "__main__":
raise Exception
except Exception as err:
dlab.fab.append_result("Failed installing apps: apt & pip.", str(err))
- AzureActions().remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
+ AzureActions.remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
sys.exit(1)
try:
@@ -220,7 +223,7 @@ if __name__ == "__main__":
raise Exception
except Exception as err:
dlab.fab.append_result("Failed to configure Deep Learning node.",
str(err))
- AzureActions().remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
+ AzureActions.remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
sys.exit(1)
try:
@@ -235,7 +238,7 @@ if __name__ == "__main__":
raise Exception
except Exception as err:
dlab.fab.append_result("Failed to setup git credentials.", str(err))
- AzureActions().remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
+ AzureActions.remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
sys.exit(1)
try:
@@ -252,30 +255,30 @@ if __name__ == "__main__":
raise Exception
except Exception as err:
dlab.fab.append_result("Failed to post configuring instance.",
str(err))
- AzureActions().remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
+ AzureActions.remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
sys.exit(1)
if notebook_config['image_enabled'] == 'true':
try:
print('[CREATING IMAGE]')
- image =
AzureMeta().get_image(notebook_config['resource_group_name'],
notebook_config['expected_image_name'])
+ image =
AzureMeta.get_image(notebook_config['resource_group_name'],
notebook_config['expected_image_name'])
if image == '':
print("Looks like it's first time we configure notebook
server. Creating image.")
dlab.actions_lib.prepare_vm_for_image(True,
notebook_config['dlab_ssh_user'], instance_hostname,
keyfile_name)
-
AzureActions().create_image_from_instance(notebook_config['resource_group_name'],
-
notebook_config['instance_name'],
-
os.environ['azure_region'],
-
notebook_config['expected_image_name'],
-
json.dumps(notebook_config['image_tags']))
+
AzureActions.create_image_from_instance(notebook_config['resource_group_name'],
+
notebook_config['instance_name'],
+
os.environ['azure_region'],
+
notebook_config['expected_image_name'],
+
json.dumps(notebook_config['image_tags']))
print("Image was successfully created.")
local("~/scripts/{}.py".format('common_prepare_notebook'))
instance_running = False
while not instance_running:
- if
AzureMeta().get_instance_status(notebook_config['resource_group_name'],
+ if
AzureMeta.get_instance_status(notebook_config['resource_group_name'],
notebook_config['instance_name']) == 'running':
instance_running = True
- instance_hostname =
AzureMeta().get_private_ip_address(notebook_config['resource_group_name'],
+ instance_hostname =
AzureMeta.get_private_ip_address(notebook_config['resource_group_name'],
notebook_config['instance_name'])
dlab.actions_lib.remount_azure_disk(True,
notebook_config['dlab_ssh_user'], instance_hostname,
keyfile_name)
@@ -288,7 +291,7 @@ if __name__ == "__main__":
local("~/scripts/{}.py {}".format('common_configure_proxy',
params))
except Exception as err:
dlab.fab.append_result("Failed creating image.", str(err))
-
AzureActions().remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
+
AzureActions.remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
sys.exit(1)
try:
@@ -317,11 +320,11 @@ if __name__ == "__main__":
raise Exception
except Exception as err:
dlab.fab.append_result("Failed to set edge reverse proxy template.",
str(err))
- AzureActions().remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
+ AzureActions.remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
sys.exit(1)
try:
- ip_address =
AzureMeta().get_private_ip_address(notebook_config['resource_group_name'],
+ ip_address =
AzureMeta.get_private_ip_address(notebook_config['resource_group_name'],
notebook_config['instance_name'])
tensorboard_ip_url = 'http://' + ip_address + ':6006'
jupyter_ip_url = 'http://' + ip_address +
':8888/{}/'.format(notebook_config['exploratory_name'])
@@ -369,7 +372,6 @@ if __name__ == "__main__":
]}
result.write(json.dumps(res))
except Exception as err:
- print('Error: {0}'.format(err))
dlab.fab.append_result("Failed to generate output information.",
str(err))
- AzureActions().remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
+ AzureActions.remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
sys.exit(1)
diff --git
a/infrastructure-provisioning/src/general/scripts/azure/edge_configure.py
b/infrastructure-provisioning/src/general/scripts/azure/edge_configure.py
index ab1945c..9660c8e 100644
--- a/infrastructure-provisioning/src/general/scripts/azure/edge_configure.py
+++ b/infrastructure-provisioning/src/general/scripts/azure/edge_configure.py
@@ -31,6 +31,7 @@ import dlab.meta_lib
import logging
import traceback
import uuid
+from fabric.api import *
if __name__ == "__main__":
local_log_filename = "{}_{}_{}.log".format(os.environ['conf_resource'],
os.environ['project_name'],
diff --git
a/infrastructure-provisioning/src/general/scripts/azure/edge_status.py
b/infrastructure-provisioning/src/general/scripts/azure/edge_status.py
index 969eba8..1b3fd15 100644
--- a/infrastructure-provisioning/src/general/scripts/azure/edge_status.py
+++ b/infrastructure-provisioning/src/general/scripts/azure/edge_status.py
@@ -30,6 +30,7 @@ import dlab.fab
import dlab.actions_lib
import dlab.meta_lib
import logging
+from fabric.api import *
import traceback
diff --git
a/infrastructure-provisioning/src/general/scripts/azure/edge_terminate.py
b/infrastructure-provisioning/src/general/scripts/azure/edge_terminate.py
index 6c2c038..fb7da87 100644
--- a/infrastructure-provisioning/src/general/scripts/azure/edge_terminate.py
+++ b/infrastructure-provisioning/src/general/scripts/azure/edge_terminate.py
@@ -35,10 +35,10 @@ import traceback
def terminate_edge_node(resource_group_name, service_base_name, project_tag,
subnet_name, vpc_name):
print("Terminating EDGE, notebook and dataengine virtual machines")
try:
- for vm in
AzureMeta().compute_client.virtual_machines.list(resource_group_name):
+ for vm in
AzureMeta.compute_client.virtual_machines.list(resource_group_name):
try:
if project_tag == vm.tags["project_tag"]:
- AzureActions().remove_instance(resource_group_name,
vm.name)
+ AzureActions.remove_instance(resource_group_name, vm.name)
print("Instance {} has been terminated".format(vm.name))
except:
pass
@@ -48,10 +48,10 @@ def terminate_edge_node(resource_group_name,
service_base_name, project_tag, sub
print("Removing network interfaces")
try:
- for network_interface in
AzureMeta().list_network_interfaces(resource_group_name):
+ for network_interface in
AzureMeta.list_network_interfaces(resource_group_name):
try:
if project_tag == network_interface.tags["project_tag"]:
- AzureActions().delete_network_if(resource_group_name,
network_interface.name)
+ AzureActions.delete_network_if(resource_group_name,
network_interface.name)
print("Network interface {} has been
removed".format(network_interface.name))
except:
pass
@@ -61,10 +61,10 @@ def terminate_edge_node(resource_group_name,
service_base_name, project_tag, sub
print("Removing static public IPs")
try:
- for static_public_ip in
AzureMeta().list_static_ips(resource_group_name):
+ for static_public_ip in AzureMeta.list_static_ips(resource_group_name):
try:
if project_tag in static_public_ip.tags["project_tag"]:
-
AzureActions().delete_static_public_ip(resource_group_name,
static_public_ip.name)
+ AzureActions.delete_static_public_ip(resource_group_name,
static_public_ip.name)
print("Static public IP {} has been
removed".format(static_public_ip.name))
except:
pass
@@ -74,10 +74,10 @@ def terminate_edge_node(resource_group_name,
service_base_name, project_tag, sub
print("Removing disks")
try:
- for disk in AzureMeta().list_disks(resource_group_name):
+ for disk in AzureMeta.list_disks(resource_group_name):
try:
if project_tag in disk.tags["project_tag"]:
- AzureActions().remove_disk(resource_group_name, disk.name)
+ AzureActions.remove_disk(resource_group_name, disk.name)
print("Disk {} has been removed".format(disk.name))
except:
pass
@@ -87,10 +87,10 @@ def terminate_edge_node(resource_group_name,
service_base_name, project_tag, sub
print("Removing storage account")
try:
- for storage_account in
AzureMeta().list_storage_accounts(resource_group_name):
+ for storage_account in
AzureMeta.list_storage_accounts(resource_group_name):
try:
if project_tag == storage_account.tags["project_tag"]:
- AzureActions().remove_storage_account(resource_group_name,
storage_account.name)
+ AzureActions.remove_storage_account(resource_group_name,
storage_account.name)
print("Storage account {} has been
terminated".format(storage_account.name))
except:
pass
@@ -100,10 +100,10 @@ def terminate_edge_node(resource_group_name,
service_base_name, project_tag, sub
print("Deleting Data Lake Store directory")
try:
- for datalake in AzureMeta().list_datalakes(resource_group_name):
+ for datalake in AzureMeta.list_datalakes(resource_group_name):
try:
if service_base_name == datalake.tags["SBN"]:
- AzureActions().remove_datalake_directory(datalake.name,
project_tag + '-folder')
+ AzureActions.remove_datalake_directory(datalake.name,
project_tag + '-folder')
print("Data Lake Store directory {} has been
deleted".format(project_tag + '-folder'))
except:
pass
@@ -113,10 +113,10 @@ def terminate_edge_node(resource_group_name,
service_base_name, project_tag, sub
print("Removing security groups")
try:
- for sg in
AzureMeta().network_client.network_security_groups.list(resource_group_name):
+ for sg in
AzureMeta.network_client.network_security_groups.list(resource_group_name):
try:
if project_tag == sg.tags["project_tag"]:
- AzureActions().remove_security_group(resource_group_name,
sg.name)
+ AzureActions.remove_security_group(resource_group_name,
sg.name)
print("Security group {} has been
terminated".format(sg.name))
except:
pass
@@ -126,7 +126,7 @@ def terminate_edge_node(resource_group_name,
service_base_name, project_tag, sub
print("Removing private subnet")
try:
- AzureActions().remove_subnet(resource_group_name, vpc_name,
subnet_name)
+ AzureActions.remove_subnet(resource_group_name, vpc_name, subnet_name)
print("Private subnet {} has been terminated".format(subnet_name))
except Exception as err:
dlab.fab.append_result("Failed to remove subnet", str(err))
@@ -142,6 +142,8 @@ if __name__ == "__main__":
filename=local_log_filepath)
print('Generating infrastructure names and tags')
+ AzureMeta = dlab.meta_lib.AzureMeta()
+ AzureActions = dlab.actions_lib.AzureActions()
edge_conf = dict()
edge_conf['service_base_name'] = os.environ['conf_service_base_name']
edge_conf['resource_group_name'] = os.environ['azure_resource_group_name']
diff --git
a/infrastructure-provisioning/src/general/scripts/azure/jupyter_configure.py
b/infrastructure-provisioning/src/general/scripts/azure/jupyter_configure.py
index c645a17..6a60454 100644
--- a/infrastructure-provisioning/src/general/scripts/azure/jupyter_configure.py
+++ b/infrastructure-provisioning/src/general/scripts/azure/jupyter_configure.py
@@ -29,6 +29,7 @@ import dlab.fab
import dlab.actions_lib
import dlab.meta_lib
import os
+from fabric.api import *
if __name__ == "__main__":
@@ -39,6 +40,8 @@ if __name__ == "__main__":
level=logging.DEBUG,
filename=local_log_filepath)
try:
+ AzureMeta = dlab.meta_lib.AzureMeta()
+ AzureActions = dlab.actions_lib.AzureActions()
notebook_config = dict()
try:
notebook_config['exploratory_name'] =
os.environ['exploratory_name'].lower()
@@ -96,26 +99,26 @@ if __name__ == "__main__":
"endpoint_tag":
notebook_config['endpoint_tag'],
"Exploratory":
notebook_config['exploratory_name'],
os.environ['conf_billing_tag_key']:
os.environ['conf_billing_tag_value']}
- notebook_config['ip_address'] =
AzureMeta().get_private_ip_address(notebook_config['resource_group_name'],
-
notebook_config['instance_name'])
+ notebook_config['ip_address'] =
AzureMeta.get_private_ip_address(notebook_config['resource_group_name'],
+
notebook_config['instance_name'])
# generating variables regarding EDGE proxy on Notebook instance
- instance_hostname =
AzureMeta().get_private_ip_address(notebook_config['resource_group_name'],
-
notebook_config['instance_name'])
+ instance_hostname =
AzureMeta.get_private_ip_address(notebook_config['resource_group_name'],
+
notebook_config['instance_name'])
edge_instance_name =
'{0}-{1}-{2}-edge'.format(notebook_config['service_base_name'],
notebook_config['project_name'],
notebook_config['endpoint_name'])
- edge_instance_private_hostname =
AzureMeta().get_private_ip_address(notebook_config['resource_group_name'],
-
edge_instance_name)
+ edge_instance_private_hostname =
AzureMeta.get_private_ip_address(notebook_config['resource_group_name'],
+
edge_instance_name)
if os.environ['conf_network_type'] == 'private':
- edge_instance_hostname =
AzureMeta().get_private_ip_address(notebook_config['resource_group_name'],
-
edge_instance_name)
+ edge_instance_hostname =
AzureMeta.get_private_ip_address(notebook_config['resource_group_name'],
+
edge_instance_name)
else:
- edge_instance_hostname =
AzureMeta().get_instance_public_ip_address(notebook_config['resource_group_name'],
-
edge_instance_name)
+ edge_instance_hostname =
AzureMeta.get_instance_public_ip_address(notebook_config['resource_group_name'],
+
edge_instance_name)
keyfile_name = "{}{}.pem".format(os.environ['conf_key_dir'],
os.environ['conf_key_name'])
- edge_hostname =
AzureMeta().get_private_ip_address(notebook_config['resource_group_name'],
- edge_instance_name)
+ edge_hostname =
AzureMeta.get_private_ip_address(notebook_config['resource_group_name'],
+ edge_instance_name)
if os.environ['conf_os_family'] == 'debian':
notebook_config['initial_user'] = 'ubuntu'
@@ -125,7 +128,7 @@ if __name__ == "__main__":
notebook_config['sudo_group'] = 'wheel'
except Exception as err:
dlab.fab.append_result("Failed to generate variables dictionary",
str(err))
- AzureActions().remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
+ AzureActions.remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
sys.exit(1)
try:
@@ -142,7 +145,7 @@ if __name__ == "__main__":
raise Exception
except Exception as err:
dlab.fab.append_result("Failed creating ssh user 'dlab-user'.",
str(err))
- AzureActions().remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
+ AzureActions.remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
sys.exit(1)
# configuring proxy on Notebook instance
@@ -160,7 +163,7 @@ if __name__ == "__main__":
raise Exception
except Exception as err:
dlab.fab.append_result("Failed to configure proxy.", str(err))
- AzureActions().remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
+ AzureActions.remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
sys.exit(1)
# updating repositories & installing python packages
@@ -177,7 +180,7 @@ if __name__ == "__main__":
raise Exception
except Exception as err:
dlab.fab.append_result("Failed installing apps: apt & pip.", str(err))
- AzureActions().remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
+ AzureActions.remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
sys.exit(1)
# installing and configuring jupiter and all dependencies
@@ -203,7 +206,7 @@ if __name__ == "__main__":
raise Exception
except Exception as err:
dlab.fab.append_result("Failed to configure jupyter.", str(err))
- AzureActions().remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
+ AzureActions.remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
sys.exit(1)
try:
@@ -220,7 +223,7 @@ if __name__ == "__main__":
raise Exception
except Exception as err:
dlab.fab.append_result("Failed installing users key.", str(err))
- AzureActions().remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
+ AzureActions.remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
sys.exit(1)
try:
@@ -236,7 +239,7 @@ if __name__ == "__main__":
raise Exception
except Exception as err:
dlab.fab.append_result("Failed to setup git credentials.", str(err))
- AzureActions().remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
+ AzureActions.remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
sys.exit(1)
try:
@@ -253,32 +256,32 @@ if __name__ == "__main__":
raise Exception
except Exception as err:
dlab.fab.append_result("Failed to post configuring instance.",
str(err))
- AzureActions().remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
+ AzureActions.remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
sys.exit(1)
if notebook_config['image_enabled'] == 'true':
try:
print('[CREATING IMAGE]')
- image =
AzureMeta().get_image(notebook_config['resource_group_name'],
-
notebook_config['expected_image_name'])
+ image = AzureMeta.get_image(notebook_config['resource_group_name'],
+ notebook_config['expected_image_name'])
if image == '':
print("Looks like it's first time we configure notebook
server. Creating image.")
dlab.actions_lib.prepare_vm_for_image(True,
notebook_config['dlab_ssh_user'], instance_hostname,
keyfile_name)
-
AzureActions().create_image_from_instance(notebook_config['resource_group_name'],
-
notebook_config['instance_name'],
-
os.environ['azure_region'],
-
notebook_config['expected_image_name'],
-
json.dumps(notebook_config['image_tags']))
+
AzureActions.create_image_from_instance(notebook_config['resource_group_name'],
+
notebook_config['instance_name'],
+
os.environ['azure_region'],
+
notebook_config['expected_image_name'],
+
json.dumps(notebook_config['image_tags']))
print("Image was successfully created.")
local("~/scripts/{}.py".format('common_prepare_notebook'))
instance_running = False
while not instance_running:
- if
AzureMeta().get_instance_status(notebook_config['resource_group_name'],
-
notebook_config['instance_name']) == 'running':
+ if
AzureMeta.get_instance_status(notebook_config['resource_group_name'],
+
notebook_config['instance_name']) == 'running':
instance_running = True
- instance_hostname =
AzureMeta().get_private_ip_address(notebook_config['resource_group_name'],
-
notebook_config['instance_name'])
+ instance_hostname =
AzureMeta.get_private_ip_address(notebook_config['resource_group_name'],
+
notebook_config['instance_name'])
dlab.actions_lib.remount_azure_disk(True,
notebook_config['dlab_ssh_user'], instance_hostname,
keyfile_name)
dlab.fab.set_git_proxy(notebook_config['dlab_ssh_user'],
instance_hostname, keyfile_name,
@@ -290,7 +293,7 @@ if __name__ == "__main__":
local("~/scripts/{}.py {}".format('common_configure_proxy',
params))
except Exception as err:
dlab.fab.append_result("Failed creating image.", str(err))
-
AzureActions().remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
+
AzureActions.remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
sys.exit(1)
try:
@@ -319,13 +322,13 @@ if __name__ == "__main__":
raise Exception
except Exception as err:
dlab.fab.append_result("Failed to set edge reverse proxy template.",
str(err))
- AzureActions().remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
+ AzureActions.remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
sys.exit(1)
# generating output information
try:
- ip_address =
AzureMeta().get_private_ip_address(notebook_config['resource_group_name'],
-
notebook_config['instance_name'])
+ ip_address =
AzureMeta.get_private_ip_address(notebook_config['resource_group_name'],
+
notebook_config['instance_name'])
jupyter_ip_url = "http://" + ip_address +
":8888/{}/".format(notebook_config['exploratory_name'])
ungit_ip_url = "http://" + ip_address +
":8085/{}-ungit/".format(notebook_config['exploratory_name'])
jupyter_notebook_access_url = "https://" + edge_instance_hostname +
"/{}/".format(
@@ -365,5 +368,5 @@ if __name__ == "__main__":
result.write(json.dumps(res))
except Exception as err:
dlab.fab.append_result("Failed to generate output information",
str(err))
- AzureActions().remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
+ AzureActions.remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
sys.exit(1)
diff --git
a/infrastructure-provisioning/src/general/scripts/azure/jupyterlab_configure.py
b/infrastructure-provisioning/src/general/scripts/azure/jupyterlab_configure.py
index eaf8b75..511e768 100644
---
a/infrastructure-provisioning/src/general/scripts/azure/jupyterlab_configure.py
+++
b/infrastructure-provisioning/src/general/scripts/azure/jupyterlab_configure.py
@@ -24,10 +24,12 @@
import logging
import json
import sys
-from dlab.fab import *
-from dlab.meta_lib import *
-from dlab.actions_lib import *
+import dlab.fab
+import dlab.actions_lib
+import dlab.meta_lib
import os
+from fabric.api import *
+import traceback
if __name__ == "__main__":
@@ -38,54 +40,57 @@ if __name__ == "__main__":
level=logging.DEBUG,
filename=local_log_filepath)
try:
+ AzureMeta = dlab.meta_lib.AzureMeta()
+ AzureActions = dlab.actions_lib.AzureActions()
notebook_config = dict()
try:
- notebook_config['exploratory_name'] =
os.environ['exploratory_name'].replace('_', '-')
+ notebook_config['exploratory_name'] =
os.environ['exploratory_name'].lower()
except:
notebook_config['exploratory_name'] = ''
notebook_config['service_base_name'] =
os.environ['conf_service_base_name']
notebook_config['resource_group_name'] =
os.environ['azure_resource_group_name']
notebook_config['instance_size'] =
os.environ['azure_notebook_instance_size']
notebook_config['key_name'] = os.environ['conf_key_name']
- notebook_config['user_name'] =
os.environ['edge_user_name'].replace('_', '-')
- notebook_config['project_name'] =
os.environ['project_name'].lower().replace('_', '-')
- notebook_config['endpoint_name'] =
os.environ['endpoint_name'].lower().replace('_', '-')
- notebook_config['project_tag'] =
os.environ['project_name'].lower().replace('_', '-')
- notebook_config['endpoint_tag'] =
os.environ['endpoint_name'].lower().replace('_', '-')
- notebook_config['user_keyname'] = os.environ['project_name']
+ notebook_config['user_name'] = os.environ['edge_user_name']
+ notebook_config['project_name'] = os.environ['project_name'].lower()
+ notebook_config['endpoint_name'] = os.environ['endpoint_name'].lower()
+ notebook_config['project_tag'] = notebook_config['project_name']
+ notebook_config['endpoint_tag'] = notebook_config['endpoint_name']
+ notebook_config['user_keyname'] = notebook_config['project_name']
notebook_config['instance_name'] =
'{}-{}-{}-nb-{}'.format(notebook_config['service_base_name'],
-
notebook_config['project_name'],
-
os.environ['endpoint_name'],
-
notebook_config['exploratory_name'])
+
notebook_config['project_name'],
+
notebook_config['endpoint_name'],
+
notebook_config['exploratory_name'])
notebook_config['image_enabled'] = os.environ['conf_image_enabled']
notebook_config['shared_image_enabled'] =
os.environ['conf_shared_image_enabled']
if notebook_config['shared_image_enabled'] == 'false':
notebook_config['expected_image_name'] =
'{0}-{1}-{2}-{3}-notebook-image'.format(
- notebook_config['service_base_name'],
- notebook_config['endpoint_name'],
- notebook_config['project_name'],
- os.environ['application'])
+ notebook_config['service_base_name'],
+ notebook_config['project_name'],
+ notebook_config['endpoint_name'],
+ os.environ['application'])
notebook_config['image_tags'] = {"Name":
notebook_config['instance_name'],
- "SBN":
notebook_config['service_base_name'],
- "User": notebook_config['user_name'],
- "project_tag":
notebook_config['project_tag'],
- "endpoint_tag":
notebook_config['endpoint_tag'],
- "Exploratory":
notebook_config['exploratory_name'],
- os.environ['conf_billing_tag_key']:
os.environ['conf_billing_tag_value']}
+ "SBN":
notebook_config['service_base_name'],
+ "User":
notebook_config['user_name'],
+ "project_tag":
notebook_config['project_tag'],
+ "endpoint_tag":
notebook_config['endpoint_tag'],
+ "Exploratory":
notebook_config['exploratory_name'],
+
os.environ['conf_billing_tag_key']: os.environ['conf_billing_tag_value']}
else:
notebook_config['expected_image_name'] =
'{0}-{1}-{2}-notebook-image'.format(
notebook_config['service_base_name'],
notebook_config['endpoint_name'],
os.environ['application'])
notebook_config['image_tags'] = {"Name":
notebook_config['instance_name'],
- "SBN":
notebook_config['service_base_name'],
- "User": notebook_config['user_name'],
- "endpoint_tag":
notebook_config['endpoint_tag'],
- "Exploratory":
notebook_config['exploratory_name'],
- os.environ['conf_billing_tag_key']:
os.environ['conf_billing_tag_value']}
+ "SBN":
notebook_config['service_base_name'],
+ "User":
notebook_config['user_name'],
+ "endpoint_tag":
notebook_config['endpoint_tag'],
+ "Exploratory":
notebook_config['exploratory_name'],
+
os.environ['conf_billing_tag_key']: os.environ['conf_billing_tag_value']}
notebook_config['notebook_image_name'] =
str(os.environ.get('notebook_image_name'))
- notebook_config['security_group_name'] =
'{}-{}-nb-sg'.format(notebook_config['service_base_name'],
-
notebook_config['project_name'])
+ notebook_config['security_group_name'] =
'{}-{}-{}-nb-sg'.format(notebook_config['service_base_name'],
+
notebook_config['project_name'],
+
notebook_config['endpoint_name'])
notebook_config['dlab_ssh_user'] = os.environ['conf_os_user']
notebook_config['tags'] = {"Name": notebook_config['instance_name'],
"SBN": notebook_config['service_base_name'],
@@ -94,26 +99,26 @@ if __name__ == "__main__":
"endpoint_tag":
notebook_config['endpoint_tag'],
"Exploratory":
notebook_config['exploratory_name'],
os.environ['conf_billing_tag_key']:
os.environ['conf_billing_tag_value']}
- notebook_config['ip_address'] =
AzureMeta().get_private_ip_address(notebook_config['resource_group_name'],
-
notebook_config['instance_name'])
+ notebook_config['ip_address'] =
AzureMeta.get_private_ip_address(notebook_config['resource_group_name'],
+
notebook_config['instance_name'])
# generating variables regarding EDGE proxy on Notebook instance
- instance_hostname =
AzureMeta().get_private_ip_address(notebook_config['resource_group_name'],
-
notebook_config['instance_name'])
+ instance_hostname =
AzureMeta.get_private_ip_address(notebook_config['resource_group_name'],
+
notebook_config['instance_name'])
edge_instance_name =
'{0}-{1}-{2}-edge'.format(notebook_config['service_base_name'],
notebook_config['project_name'],
notebook_config['endpoint_name'])
- edge_instance_private_hostname =
AzureMeta().get_private_ip_address(notebook_config['resource_group_name'],
-
edge_instance_name)
+ edge_instance_private_hostname =
AzureMeta.get_private_ip_address(notebook_config['resource_group_name'],
+
edge_instance_name)
if os.environ['conf_network_type'] == 'private':
- edge_instance_hostname =
AzureMeta().get_private_ip_address(notebook_config['resource_group_name'],
-
edge_instance_name)
+ edge_instance_hostname =
AzureMeta.get_private_ip_address(notebook_config['resource_group_name'],
+
edge_instance_name)
else:
- edge_instance_hostname =
AzureMeta().get_instance_public_ip_address(notebook_config['resource_group_name'],
+ edge_instance_hostname =
AzureMeta.get_instance_public_ip_address(notebook_config['resource_group_name'],
edge_instance_name)
keyfile_name = "{}{}.pem".format(os.environ['conf_key_dir'],
os.environ['conf_key_name'])
- edge_hostname =
AzureMeta().get_private_ip_address(notebook_config['resource_group_name'],
-
edge_instance_name)
+ edge_hostname =
AzureMeta.get_private_ip_address(notebook_config['resource_group_name'],
+ edge_instance_name)
if os.environ['conf_os_family'] == 'debian':
initial_user = 'ubuntu'
@@ -122,9 +127,8 @@ if __name__ == "__main__":
initial_user = 'ec2-user'
sudo_group = 'wheel'
except Exception as err:
- print('Error: {0}'.format(err))
- append_result("Failed to generate variables dictionary.", str(err))
- AzureActions().remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
+ dlab.fab.append_result("Failed to generate variables dictionary.",
str(err))
+ AzureActions.remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
sys.exit(1)
try:
@@ -140,9 +144,8 @@ if __name__ == "__main__":
traceback.print_exc()
raise Exception
except Exception as err:
- print('Error: {0}'.format(err))
- append_result("Failed creating ssh user 'dlab-user'.", str(err))
- AzureActions().remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
+ dlab.fab.append_result("Failed creating ssh user 'dlab-user'.",
str(err))
+ AzureActions.remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
sys.exit(1)
# configuring proxy on Notebook instance
@@ -159,9 +162,8 @@ if __name__ == "__main__":
traceback.print_exc()
raise Exception
except Exception as err:
- print('Error: {0}'.format(err))
- append_result("Failed to configure proxy.", str(err))
- AzureActions().remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
+ dlab.fab.append_result("Failed to configure proxy.", str(err))
+ AzureActions.remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
sys.exit(1)
# updating repositories & installing python packages
@@ -177,9 +179,8 @@ if __name__ == "__main__":
traceback.print_exc()
raise Exception
except Exception as err:
- print('Error: {0}'.format(err))
- append_result("Failed installing apps: apt & pip.", str(err))
- AzureActions().remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
+ dlab.fab.append_result("Failed installing apps: apt & pip.", str(err))
+ AzureActions.remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
sys.exit(1)
# installing and configuring jupiter and all dependencies
@@ -198,15 +199,13 @@ if __name__ == "__main__":
notebook_config['ip_address'],
notebook_config['exploratory_name'], edge_hostname)
try:
local("~/scripts/{}.py {}".format('configure_jupyterlab_node',
params))
- remount_azure_disk(True, notebook_config['dlab_ssh_user'],
instance_hostname,
- os.environ['conf_key_dir'] +
os.environ['conf_key_name'] + ".pem")
+ dlab.actions_lib.remount_azure_disk(True,
notebook_config['dlab_ssh_user'], instance_hostname,
+ os.environ['conf_key_dir'] +
os.environ['conf_key_name'] + ".pem")
except:
traceback.print_exc()
raise Exception
except Exception as err:
- print('Error: {0}'.format(err))
- append_result("Failed to configure jupyter.", str(err))
- AzureActions().remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
+ AzureActions.remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
sys.exit(1)
try:
@@ -219,12 +218,11 @@ if __name__ == "__main__":
try:
local("~/scripts/{}.py {}".format('install_user_key', params))
except:
- append_result("Failed installing users key")
+ dlab.fab.append_result("Failed installing users key")
raise Exception
except Exception as err:
- print('Error: {0}'.format(err))
- append_result("Failed installing users key.", str(err))
- AzureActions().remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
+ dlab.fab.append_result("Failed installing users key.", str(err))
+ AzureActions.remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
sys.exit(1)
try:
@@ -236,23 +234,22 @@ if __name__ == "__main__":
# local("~/scripts/{}.py
{}".format('common_download_git_certfile', params))
local("~/scripts/{}.py {}".format('manage_git_creds', params))
except:
- append_result("Failed setup git credentials")
+ dlab.fab.append_result("Failed setup git credentials")
raise Exception
except Exception as err:
- print('Error: {0}'.format(err))
- append_result("Failed to setup git credentials.", str(err))
- AzureActions().remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
+ dlab.fab.append_result("Failed to setup git credentials.", str(err))
+ AzureActions.remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
sys.exit(1)
-
if notebook_config['image_enabled'] == 'true':
try:
print('[CREATING IMAGE]')
- image =
AzureMeta().get_image(notebook_config['resource_group_name'],
notebook_config['expected_image_name'])
+ image =
AzureMeta.get_image(notebook_config['resource_group_name'],
notebook_config['expected_image_name'])
if image == '':
print("Looks like it's first time we configure notebook
server. Creating image.")
- prepare_vm_for_image(True, notebook_config['dlab_ssh_user'],
instance_hostname, keyfile_name)
-
AzureActions().create_image_from_instance(notebook_config['resource_group_name'],
+ dlab.actions_lib.prepare_vm_for_image(True,
notebook_config['dlab_ssh_user'], instance_hostname,
+ keyfile_name)
+
AzureActions.create_image_from_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'],
os.environ['azure_region'],
notebook_config['expected_image_name'],
@@ -261,23 +258,23 @@ if __name__ == "__main__":
local("~/scripts/{}.py".format('common_prepare_notebook'))
instance_running = False
while not instance_running:
- if
AzureMeta().get_instance_status(notebook_config['resource_group_name'],
-
notebook_config['instance_name']) == 'running':
+ if
AzureMeta.get_instance_status(notebook_config['resource_group_name'],
+
notebook_config['instance_name']) == 'running':
instance_running = True
- instance_hostname =
AzureMeta().get_private_ip_address(notebook_config['resource_group_name'],
-
notebook_config['instance_name'])
- remount_azure_disk(True, notebook_config['dlab_ssh_user'],
instance_hostname, keyfile_name)
- set_git_proxy(notebook_config['dlab_ssh_user'],
instance_hostname, keyfile_name,
-
'http://{}:3128'.format(edge_instance_private_hostname))
+ instance_hostname =
AzureMeta.get_private_ip_address(notebook_config['resource_group_name'],
+
notebook_config['instance_name'])
+ dlab.actions_lib.remount_azure_disk(True,
notebook_config['dlab_ssh_user'], instance_hostname,
+ keyfile_name)
+ dlab.fab.set_git_proxy(notebook_config['dlab_ssh_user'],
instance_hostname, keyfile_name,
+
'http://{}:3128'.format(edge_instance_private_hostname))
additional_config = {"proxy_host":
edge_instance_private_hostname, "proxy_port": "3128"}
params = "--hostname {} --instance_name {} --keyfile {}
--additional_config '{}' --os_user {}" \
.format(instance_hostname,
notebook_config['instance_name'], keyfile_name,
json.dumps(additional_config),
notebook_config['dlab_ssh_user'])
local("~/scripts/{}.py {}".format('common_configure_proxy',
params))
except Exception as err:
- print('Error: {0}'.format(err))
- append_result("Failed creating image from notebook.", str(err))
-
AzureActions().remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
+ dlab.fab.append_result("Failed creating image from notebook.",
str(err))
+
AzureActions.remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
sys.exit(1)
try:
@@ -302,12 +299,11 @@ if __name__ == "__main__":
try:
local("~/scripts/{}.py
{}".format('common_configure_reverse_proxy', params))
except:
- append_result("Failed edge reverse proxy template")
+ dlab.fab.append_result("Failed edge reverse proxy template")
raise Exception
except Exception as err:
- print('Error: {0}'.format(err))
- append_result("Failed to set edge reverse proxy template.", str(err))
- AzureActions().remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
+ dlab.fab.append_result("Failed to set edge reverse proxy template.",
str(err))
+ AzureActions.remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
sys.exit(1)
try:
@@ -325,8 +321,7 @@ if __name__ == "__main__":
traceback.print_exc()
raise Exception
except Exception as err:
- print('Error: {0}'.format(err))
- append_result("Failed to configure proxy for docker.", str(err))
+ dlab.fab.append_result("Failed to configure proxy for docker.",
str(err))
GCPActions().remove_instance(notebook_config['instance_name'],
notebook_config['zone'])
sys.exit(1)
@@ -346,15 +341,14 @@ if __name__ == "__main__":
traceback.print_exc()
raise Exception
except Exception as err:
- print('Error: {0}'.format(err))
- append_result("Failed to start Jupyter container.", str(err))
+ dlab.fab.append_result("Failed to start Jupyter container.", str(err))
GCPActions().remove_instance(notebook_config['instance_name'],
notebook_config['zone'])
sys.exit(1)
# generating output information
try:
- ip_address =
AzureMeta().get_private_ip_address(notebook_config['resource_group_name'],
-
notebook_config['instance_name'])
+ ip_address =
AzureMeta.get_private_ip_address(notebook_config['resource_group_name'],
+
notebook_config['instance_name'])
jupyter_ip_url = "http://" + ip_address +
":8888/{}/".format(notebook_config['exploratory_name'])
ungit_ip_url = "http://" + ip_address +
":8085/{}-ungit/".format(notebook_config['exploratory_name'])
jupyter_notebook_acces_url = "http://" + edge_instance_hostname +
"/{}/".format(
@@ -393,6 +387,6 @@ if __name__ == "__main__":
]}
result.write(json.dumps(res))
except Exception as err:
- append_result("Failed to generate output information", str(err))
- AzureActions().remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
- sys.exit(1)
\ No newline at end of file
+ dlab.fab.append_result("Failed to generate output information",
str(err))
+ AzureActions.remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
+ sys.exit(1)
diff --git
a/infrastructure-provisioning/src/general/scripts/azure/project_prepare.py
b/infrastructure-provisioning/src/general/scripts/azure/project_prepare.py
index b48625e..990e5f9 100644
--- a/infrastructure-provisioning/src/general/scripts/azure/project_prepare.py
+++ b/infrastructure-provisioning/src/general/scripts/azure/project_prepare.py
@@ -32,6 +32,7 @@ import dlab.fab
import dlab.actions_lib
import dlab.meta_lib
import logging
+from fabric.api import *
if __name__ == "__main__":
diff --git
a/infrastructure-provisioning/src/general/scripts/azure/rstudio_configure.py
b/infrastructure-provisioning/src/general/scripts/azure/rstudio_configure.py
index 73af56c..cd9d909 100644
--- a/infrastructure-provisioning/src/general/scripts/azure/rstudio_configure.py
+++ b/infrastructure-provisioning/src/general/scripts/azure/rstudio_configure.py
@@ -29,6 +29,7 @@ import dlab.fab
import dlab.actions_lib
import dlab.meta_lib
import os
+from fabric.api import *
if __name__ == "__main__":
@@ -40,6 +41,8 @@ if __name__ == "__main__":
level=logging.DEBUG,
filename=local_log_filepath)
try:
+ AzureMeta = dlab.meta_lib.AzureMeta()
+ AzureActions = dlab.actions_lib.AzureActions()
notebook_config = dict()
try:
notebook_config['exploratory_name'] =
os.environ['exploratory_name'].lower()
@@ -97,26 +100,26 @@ if __name__ == "__main__":
"endpoint_tag":
notebook_config['endpoint_tag'],
"Exploratory":
notebook_config['exploratory_name'],
os.environ['conf_billing_tag_key']:
os.environ['conf_billing_tag_value']}
- notebook_config['ip_address'] =
AzureMeta().get_private_ip_address(notebook_config['resource_group_name'],
-
notebook_config['instance_name'])
+ notebook_config['ip_address'] =
AzureMeta.get_private_ip_address(notebook_config['resource_group_name'],
+
notebook_config['instance_name'])
# generating variables regarding EDGE proxy on Notebook instance
- instance_hostname =
AzureMeta().get_private_ip_address(notebook_config['resource_group_name'],
-
notebook_config['instance_name'])
+ instance_hostname =
AzureMeta.get_private_ip_address(notebook_config['resource_group_name'],
+
notebook_config['instance_name'])
edge_instance_name =
'{0}-{1}-{2}-edge'.format(notebook_config['service_base_name'],
notebook_config['project_name'],
notebook_config['endpoint_name'])
- edge_instance_private_hostname =
AzureMeta().get_private_ip_address(notebook_config['resource_group_name'],
-
edge_instance_name)
+ edge_instance_private_hostname =
AzureMeta.get_private_ip_address(notebook_config['resource_group_name'],
+
edge_instance_name)
if os.environ['conf_network_type'] == 'private':
- edge_instance_hostname =
AzureMeta().get_private_ip_address(notebook_config['resource_group_name'],
-
edge_instance_name)
+ edge_instance_hostname =
AzureMeta.get_private_ip_address(notebook_config['resource_group_name'],
+
edge_instance_name)
else:
- edge_instance_hostname =
AzureMeta().get_instance_public_ip_address(notebook_config['resource_group_name'],
-
edge_instance_name)
+ edge_instance_hostname =
AzureMeta.get_instance_public_ip_address(notebook_config['resource_group_name'],
+
edge_instance_name)
keyfile_name = "{}{}.pem".format(os.environ['conf_key_dir'],
os.environ['conf_key_name'])
- edge_hostname =
AzureMeta().get_private_ip_address(notebook_config['resource_group_name'],
- edge_instance_name)
+ edge_hostname =
AzureMeta.get_private_ip_address(notebook_config['resource_group_name'],
+ edge_instance_name)
notebook_config['rstudio_pass'] = dlab.fab.id_generator()
if os.environ['conf_os_family'] == 'debian':
notebook_config['initial_user'] = 'ubuntu'
@@ -126,7 +129,7 @@ if __name__ == "__main__":
notebook_config['sudo_group'] = 'wheel'
except Exception as err:
dlab.fab.append_result("Failed to generate variables dictionary",
str(err))
- AzureActions().remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
+ AzureActions.remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
sys.exit(1)
try:
@@ -143,7 +146,7 @@ if __name__ == "__main__":
raise Exception
except Exception as err:
dlab.fab.append_result("Failed creating ssh user 'dlab'.", str(err))
- AzureActions().remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
+ AzureActions.remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
sys.exit(1)
# configuring proxy on Notebook instance
@@ -161,7 +164,7 @@ if __name__ == "__main__":
raise Exception
except Exception as err:
dlab.fab.append_result("Failed to configure proxy.", str(err))
- AzureActions().remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
+ AzureActions.remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
sys.exit(1)
# updating repositories & installing python packages
@@ -178,7 +181,7 @@ if __name__ == "__main__":
raise Exception
except Exception as err:
dlab.fab.append_result("Failed installing apps: apt & pip.", str(err))
- AzureActions().remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
+ AzureActions.remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
sys.exit(1)
# installing and configuring R_STUDIO and all dependencies
@@ -203,7 +206,7 @@ if __name__ == "__main__":
raise Exception
except Exception as err:
dlab.fab.append_result("Failed to configure rstudio.", str(err))
- AzureActions().remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
+ AzureActions.remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
sys.exit(1)
try:
@@ -220,7 +223,7 @@ if __name__ == "__main__":
raise Exception
except Exception as err:
dlab.fab.append_result("Failed installing users key.", str(err))
- AzureActions().remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
+ AzureActions.remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
sys.exit(1)
try:
@@ -235,7 +238,7 @@ if __name__ == "__main__":
raise Exception
except Exception as err:
dlab.fab.append_result("Failed to setup git credentials.", str(err))
- AzureActions().remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
+ AzureActions.remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
sys.exit(1)
try:
@@ -252,32 +255,32 @@ if __name__ == "__main__":
raise Exception
except Exception as err:
dlab.fab.append_result("Failed to post configuring instance.",
str(err))
- AzureActions().remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
+ AzureActions.remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
sys.exit(1)
if notebook_config['image_enabled'] == 'true':
try:
print('[CREATING IMAGE]')
- image =
AzureMeta().get_image(notebook_config['resource_group_name'],
-
notebook_config['expected_image_name'])
+ image = AzureMeta.get_image(notebook_config['resource_group_name'],
+ notebook_config['expected_image_name'])
if image == '':
print("Looks like it's first time we configure notebook
server. Creating image.")
dlab.actions_lib.prepare_vm_for_image(True,
notebook_config['dlab_ssh_user'], instance_hostname,
keyfile_name)
-
AzureActions().create_image_from_instance(notebook_config['resource_group_name'],
-
notebook_config['instance_name'],
-
os.environ['azure_region'],
-
notebook_config['expected_image_name'],
-
json.dumps(notebook_config['image_tags']))
+
AzureActions.create_image_from_instance(notebook_config['resource_group_name'],
+
notebook_config['instance_name'],
+
os.environ['azure_region'],
+
notebook_config['expected_image_name'],
+
json.dumps(notebook_config['image_tags']))
print("Image was successfully created.")
local("~/scripts/{}.py".format('common_prepare_notebook'))
instance_running = False
while not instance_running:
- if
AzureMeta().get_instance_status(notebook_config['resource_group_name'],
-
notebook_config['instance_name']) == 'running':
+ if
AzureMeta.get_instance_status(notebook_config['resource_group_name'],
+
notebook_config['instance_name']) == 'running':
instance_running = True
- instance_hostname =
AzureMeta().get_private_ip_address(notebook_config['resource_group_name'],
-
notebook_config['instance_name'])
+ instance_hostname =
AzureMeta.get_private_ip_address(notebook_config['resource_group_name'],
+
notebook_config['instance_name'])
dlab.actions_lib.remount_azure_disk(True,
notebook_config['dlab_ssh_user'], instance_hostname,
keyfile_name)
dlab.fab.set_git_proxy(notebook_config['dlab_ssh_user'],
instance_hostname, keyfile_name,
@@ -289,7 +292,7 @@ if __name__ == "__main__":
local("~/scripts/{}.py {}".format('common_configure_proxy',
params))
except Exception as err:
dlab.fab.append_result("Failed creating image.", str(err))
-
AzureActions().remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
+
AzureActions.remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
sys.exit(1)
try:
@@ -318,13 +321,13 @@ if __name__ == "__main__":
raise Exception
except Exception as err:
dlab.fab.append_result("Failed to set edge reverse proxy template.",
str(err))
- AzureActions().remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
+ AzureActions.remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
sys.exit(1)
try:
# generating output information
- ip_address =
AzureMeta().get_private_ip_address(notebook_config['resource_group_name'],
-
notebook_config['instance_name'])
+ ip_address =
AzureMeta.get_private_ip_address(notebook_config['resource_group_name'],
+
notebook_config['instance_name'])
rstudio_ip_url = "http://" + ip_address + ":8787/"
ungit_ip_url = "http://" + ip_address +
":8085/{}-ungit/".format(notebook_config['exploratory_name'])
rstudio_notebook_access_url = "https://" + edge_instance_hostname +
"/{}/".format(
@@ -368,5 +371,5 @@ if __name__ == "__main__":
result.write(json.dumps(res))
except Exception as err:
dlab.fab.append_result("Failed to generate output information",
str(err))
- AzureActions().remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
+ AzureActions.remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
sys.exit(1)
diff --git
a/infrastructure-provisioning/src/general/scripts/azure/tensor_configure.py
b/infrastructure-provisioning/src/general/scripts/azure/tensor_configure.py
index bb9392a..c6f381a 100644
--- a/infrastructure-provisioning/src/general/scripts/azure/tensor_configure.py
+++ b/infrastructure-provisioning/src/general/scripts/azure/tensor_configure.py
@@ -30,6 +30,7 @@ import dlab.actions_lib
import dlab.meta_lib
import os
import traceback
+from fabric.api import *
if __name__ == "__main__":
@@ -42,6 +43,8 @@ if __name__ == "__main__":
filename=local_log_filepath)
try:
+ AzureMeta = dlab.meta_lib.AzureMeta()
+ AzureActions = dlab.actions_lib.AzureActions()
notebook_config = dict()
try:
notebook_config['exploratory_name'] =
os.environ['exploratory_name'].lower()
@@ -99,26 +102,26 @@ if __name__ == "__main__":
"endpoint_tag":
notebook_config['endpoint_tag'],
"Exploratory":
notebook_config['exploratory_name'],
os.environ['conf_billing_tag_key']:
os.environ['conf_billing_tag_value']}
- notebook_config['ip_address'] =
AzureMeta().get_private_ip_address(notebook_config['resource_group_name'],
-
notebook_config['instance_name'])
+ notebook_config['ip_address'] =
AzureMeta.get_private_ip_address(notebook_config['resource_group_name'],
+
notebook_config['instance_name'])
# generating variables regarding EDGE proxy on Notebook instance
- instance_hostname =
AzureMeta().get_private_ip_address(notebook_config['resource_group_name'],
-
notebook_config['instance_name'])
+ instance_hostname =
AzureMeta.get_private_ip_address(notebook_config['resource_group_name'],
+
notebook_config['instance_name'])
edge_instance_name =
'{0}-{1}-{2}-edge'.format(notebook_config['service_base_name'],
-
notebook_config['project_name'],
-
notebook_config['endpoint_name'])
- edge_instance_private_hostname =
AzureMeta().get_private_ip_address(notebook_config['resource_group_name'],
-
edge_instance_name)
+
notebook_config['project_name'],
+
notebook_config['endpoint_name'])
+ edge_instance_private_hostname =
AzureMeta.get_private_ip_address(notebook_config['resource_group_name'],
+
edge_instance_name)
if os.environ['conf_network_type'] == 'private':
- edge_instance_hostname =
AzureMeta().get_private_ip_address(notebook_config['resource_group_name'],
-
edge_instance_name)
+ edge_instance_hostname =
AzureMeta.get_private_ip_address(notebook_config['resource_group_name'],
+
edge_instance_name)
else:
- edge_instance_hostname =
AzureMeta().get_instance_public_ip_address(notebook_config['resource_group_name'],
-
edge_instance_name)
+ edge_instance_hostname =
AzureMeta.get_instance_public_ip_address(notebook_config['resource_group_name'],
+
edge_instance_name)
keyfile_name = "{}{}.pem".format(os.environ['conf_key_dir'],
os.environ['conf_key_name'])
- edge_hostname =
AzureMeta().get_private_ip_address(notebook_config['resource_group_name'],
- edge_instance_name)
+ edge_hostname =
AzureMeta.get_private_ip_address(notebook_config['resource_group_name'],
+ edge_instance_name)
if os.environ['conf_os_family'] == 'debian':
notebook_config['initial_user'] = 'ubuntu'
@@ -128,7 +131,7 @@ if __name__ == "__main__":
notebook_config['sudo_group'] = 'wheel'
except Exception as err:
dlab.fab.append_result("Failed to generate variables dictionary",
str(err))
- AzureActions().remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
+ AzureActions.remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
sys.exit(1)
try:
@@ -145,7 +148,7 @@ if __name__ == "__main__":
raise Exception
except Exception as err:
dlab.fab.append_result("Failed creating ssh user 'dlab'.", str(err))
- AzureActions().remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
+ AzureActions.remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
sys.exit(1)
# configuring proxy on Notebook instance
@@ -163,7 +166,7 @@ if __name__ == "__main__":
raise Exception
except Exception as err:
dlab.fab.append_result("Failed to configure proxy.", str(err))
- AzureActions().remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
+ AzureActions.remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
sys.exit(1)
# updating repositories & installing python packages
@@ -180,7 +183,7 @@ if __name__ == "__main__":
raise Exception
except Exception as err:
dlab.fab.append_result("Failed installing apps: apt & pip.", str(err))
- AzureActions().remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
+ AzureActions.remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
sys.exit(1)
# installing and configuring TensorFlow and all dependencies
@@ -202,7 +205,7 @@ if __name__ == "__main__":
raise Exception
except Exception as err:
dlab.fab.append_result("Failed to configure TensorFlow.", str(err))
- AzureActions().remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
+ AzureActions.remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
sys.exit(1)
try:
@@ -219,7 +222,7 @@ if __name__ == "__main__":
raise Exception
except Exception as err:
dlab.fab.append_result("Failed installing users key.", str(err))
- AzureActions().remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
+ AzureActions.remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
sys.exit(1)
try:
@@ -234,7 +237,7 @@ if __name__ == "__main__":
raise Exception
except Exception as err:
dlab.fab.append_result("Failed to setup git credentials.", str(err))
- AzureActions().remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
+ AzureActions.remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
sys.exit(1)
try:
@@ -251,32 +254,32 @@ if __name__ == "__main__":
raise Exception
except Exception as err:
dlab.fab.append_result("Failed to post configuring instance.",
str(err))
- AzureActions().remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
+ AzureActions.remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
sys.exit(1)
if notebook_config['image_enabled'] == 'true':
try:
print('[CREATING IMAGE]')
- image =
AzureMeta().get_image(notebook_config['resource_group_name'],
-
notebook_config['expected_image_name'])
+ image = AzureMeta.get_image(notebook_config['resource_group_name'],
+ notebook_config['expected_image_name'])
if image == '':
print("Looks like it's first time we configure notebook
server. Creating image.")
dlab.actions_lib.prepare_vm_for_image(True,
notebook_config['dlab_ssh_user'], instance_hostname,
keyfile_name)
-
AzureActions().create_image_from_instance(notebook_config['resource_group_name'],
-
notebook_config['instance_name'],
-
os.environ['azure_region'],
-
notebook_config['expected_image_name'],
-
json.dumps(notebook_config['image_tags']))
+
AzureActions.create_image_from_instance(notebook_config['resource_group_name'],
+
notebook_config['instance_name'],
+
os.environ['azure_region'],
+
notebook_config['expected_image_name'],
+
json.dumps(notebook_config['image_tags']))
print("Image was successfully created.")
local("~/scripts/{}.py".format('common_prepare_notebook'))
instance_running = False
while not instance_running:
- if
AzureMeta().get_instance_status(notebook_config['resource_group_name'],
-
notebook_config['instance_name']) == 'running':
+ if
AzureMeta.get_instance_status(notebook_config['resource_group_name'],
+
notebook_config['instance_name']) == 'running':
instance_running = True
- instance_hostname =
AzureMeta().get_private_ip_address(notebook_config['resource_group_name'],
-
notebook_config['instance_name'])
+ instance_hostname =
AzureMeta.get_private_ip_address(notebook_config['resource_group_name'],
+
notebook_config['instance_name'])
dlab.actions_lib.remount_azure_disk(True,
notebook_config['dlab_ssh_user'], instance_hostname,
keyfile_name)
dlab.fab.set_git_proxy(notebook_config['dlab_ssh_user'],
instance_hostname, keyfile_name,
@@ -288,7 +291,7 @@ if __name__ == "__main__":
local("~/scripts/{}.py {}".format('common_configure_proxy',
params))
except Exception as err:
dlab.fab.append_result("Failed creating image.", str(err))
-
AzureActions().remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
+
AzureActions.remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
sys.exit(1)
try:
@@ -317,13 +320,13 @@ if __name__ == "__main__":
raise Exception
except Exception as err:
dlab.fab.append_result("Failed to set edge reverse proxy template.",
str(err))
- AzureActions().remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
+ AzureActions.remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
sys.exit(1)
# generating output information
try:
- ip_address =
AzureMeta().get_private_ip_address(notebook_config['resource_group_name'],
-
notebook_config['instance_name'])
+ ip_address =
AzureMeta.get_private_ip_address(notebook_config['resource_group_name'],
+
notebook_config['instance_name'])
tensorboard_url = "http://" + ip_address + ":6006/"
jupyter_ip_url = "http://" + ip_address +
":8888/{}/".format(notebook_config['exploratory_name'])
ungit_ip_url = "http://" + ip_address +
":8085/{}-ungit/".format(notebook_config['exploratory_name'])
@@ -373,5 +376,5 @@ if __name__ == "__main__":
result.write(json.dumps(res))
except Exception as err:
dlab.fab.append_result("Failed to generate output information.",
str(err))
- AzureActions().remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
+ AzureActions.remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
sys.exit(1)
diff --git
a/infrastructure-provisioning/src/general/scripts/azure/zeppelin_configure.py
b/infrastructure-provisioning/src/general/scripts/azure/zeppelin_configure.py
index 0aa483c..56917e4 100644
---
a/infrastructure-provisioning/src/general/scripts/azure/zeppelin_configure.py
+++
b/infrastructure-provisioning/src/general/scripts/azure/zeppelin_configure.py
@@ -30,6 +30,7 @@ import dlab.actions_lib
import dlab.meta_lib
import os
import traceback
+from fabric.api import *
if __name__ == "__main__":
@@ -41,6 +42,8 @@ if __name__ == "__main__":
level=logging.DEBUG,
filename=local_log_filepath)
try:
+ AzureMeta = dlab.meta_lib.AzureMeta()
+ AzureActions = dlab.actions_lib.AzureActions()
notebook_config = dict()
try:
notebook_config['exploratory_name'] =
os.environ['exploratory_name'].lower()
@@ -98,26 +101,26 @@ if __name__ == "__main__":
"endpoint_tag":
notebook_config['endpoint_tag'],
"Exploratory":
notebook_config['exploratory_name'],
os.environ['conf_billing_tag_key']:
os.environ['conf_billing_tag_value']}
- notebook_config['ip_address'] =
AzureMeta().get_private_ip_address(notebook_config['resource_group_name'],
-
notebook_config['instance_name'])
+ notebook_config['ip_address'] =
AzureMeta.get_private_ip_address(notebook_config['resource_group_name'],
+
notebook_config['instance_name'])
# generating variables regarding EDGE proxy on Notebook instance
- instance_hostname =
AzureMeta().get_private_ip_address(notebook_config['resource_group_name'],
-
notebook_config['instance_name'])
+ instance_hostname =
AzureMeta.get_private_ip_address(notebook_config['resource_group_name'],
+
notebook_config['instance_name'])
edge_instance_name =
'{0}-{1}-{2}-edge'.format(notebook_config['service_base_name'],
-
notebook_config['project_name'],
-
notebook_config['endpoint_name'])
- edge_instance_private_hostname =
AzureMeta().get_private_ip_address(notebook_config['resource_group_name'],
-
edge_instance_name)
+
notebook_config['project_name'],
+
notebook_config['endpoint_name'])
+ edge_instance_private_hostname =
AzureMeta.get_private_ip_address(notebook_config['resource_group_name'],
+
edge_instance_name)
if os.environ['conf_network_type'] == 'private':
- edge_instance_hostname =
AzureMeta().get_private_ip_address(notebook_config['resource_group_name'],
-
edge_instance_name)
+ edge_instance_hostname =
AzureMeta.get_private_ip_address(notebook_config['resource_group_name'],
+
edge_instance_name)
else:
- edge_instance_hostname =
AzureMeta().get_instance_public_ip_address(notebook_config['resource_group_name'],
+ edge_instance_hostname =
AzureMeta.get_instance_public_ip_address(notebook_config['resource_group_name'],
edge_instance_name)
keyfile_name = "{}{}.pem".format(os.environ['conf_key_dir'],
os.environ['conf_key_name'])
- edge_hostname =
AzureMeta().get_private_ip_address(notebook_config['resource_group_name'],
- edge_instance_name)
+ edge_hostname =
AzureMeta.get_private_ip_address(notebook_config['resource_group_name'],
+ edge_instance_name)
if os.environ['conf_os_family'] == 'debian':
notebook_config['initial_user'] = 'ubuntu'
@@ -127,7 +130,7 @@ if __name__ == "__main__":
notebook_config['sudo_group'] = 'wheel'
except Exception as err:
dlab.fab.append_result("Failed to generate variables dictionary",
str(err))
- AzureActions().remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
+ AzureActions.remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
sys.exit(1)
try:
@@ -144,7 +147,7 @@ if __name__ == "__main__":
raise Exception
except Exception as err:
dlab.fab.append_result("Failed creating ssh user 'dlab'.", str(err))
- AzureActions().remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
+ AzureActions.remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
sys.exit(1)
# configuring proxy on Notebook instance
@@ -162,7 +165,7 @@ if __name__ == "__main__":
raise Exception
except Exception as err:
dlab.fab.append_result('Unable to configure proxy on zeppelin
notebook. Exception: ' + str(err))
- AzureActions().remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
+ AzureActions.remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
sys.exit(1)
# updating repositories & installing python packages
@@ -179,7 +182,7 @@ if __name__ == "__main__":
raise Exception
except Exception as err:
dlab.fab.append_result("Failed installing apps: apt & pip.", str(err))
- AzureActions().remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
+ AzureActions.remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
sys.exit(1)
# installing and configuring zeppelin and all dependencies
@@ -215,7 +218,7 @@ if __name__ == "__main__":
raise Exception
except Exception as err:
dlab.fab.append_result("Failed to configure zeppelin.", str(err))
- AzureActions().remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
+ AzureActions.remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
sys.exit(1)
try:
@@ -232,7 +235,7 @@ if __name__ == "__main__":
raise Exception
except Exception as err:
dlab.fab.append_result("Failed installing users key.", str(err))
- AzureActions().remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
+ AzureActions.remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
sys.exit(1)
try:
@@ -247,7 +250,7 @@ if __name__ == "__main__":
raise Exception
except Exception as err:
dlab.fab.append_result("Failed to setup git credentials.", str(err))
- AzureActions().remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
+ AzureActions.remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
sys.exit(1)
try:
@@ -264,32 +267,32 @@ if __name__ == "__main__":
raise Exception
except Exception as err:
dlab.fab.append_result("Failed to post configuring instance.",
str(err))
- AzureActions().remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
+ AzureActions.remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
sys.exit(1)
if notebook_config['image_enabled'] == 'true':
try:
print('[CREATING IMAGE]')
- image =
AzureMeta().get_image(notebook_config['resource_group_name'],
-
notebook_config['expected_image_name'])
+ image = AzureMeta.get_image(notebook_config['resource_group_name'],
+ notebook_config['expected_image_name'])
if image == '':
print("Looks like it's first time we configure notebook
server. Creating image.")
dlab.actions_lib.prepare_vm_for_image(True,
notebook_config['dlab_ssh_user'], instance_hostname,
keyfile_name)
-
AzureActions().create_image_from_instance(notebook_config['resource_group_name'],
-
notebook_config['instance_name'],
-
os.environ['azure_region'],
-
notebook_config['expected_image_name'],
-
json.dumps(notebook_config['image_tags']))
+
AzureActions.create_image_from_instance(notebook_config['resource_group_name'],
+
notebook_config['instance_name'],
+
os.environ['azure_region'],
+
notebook_config['expected_image_name'],
+
json.dumps(notebook_config['image_tags']))
print("Image was successfully created.")
local("~/scripts/{}.py".format('common_prepare_notebook'))
instance_running = False
while not instance_running:
- if
AzureMeta().get_instance_status(notebook_config['resource_group_name'],
-
notebook_config['instance_name']) == 'running':
+ if
AzureMeta.get_instance_status(notebook_config['resource_group_name'],
+
notebook_config['instance_name']) == 'running':
instance_running = True
- instance_hostname =
AzureMeta().get_private_ip_address(notebook_config['resource_group_name'],
-
notebook_config['instance_name'])
+ instance_hostname =
AzureMeta.get_private_ip_address(notebook_config['resource_group_name'],
+
notebook_config['instance_name'])
dlab.actions_lib.remount_azure_disk(True,
notebook_config['dlab_ssh_user'], instance_hostname,
keyfile_name)
dlab.fab.set_git_proxy(notebook_config['dlab_ssh_user'],
instance_hostname, keyfile_name,
@@ -301,7 +304,7 @@ if __name__ == "__main__":
local("~/scripts/{}.py {}".format('common_configure_proxy',
params))
except Exception as err:
dlab.fab.append_result("Failed creating image.", str(err))
-
AzureActions().remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
+
AzureActions.remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
sys.exit(1)
try:
@@ -330,13 +333,13 @@ if __name__ == "__main__":
raise Exception
except Exception as err:
dlab.fab.append_result("Failed to set edge reverse proxy template.",
str(err))
- AzureActions().remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
+ AzureActions.remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
sys.exit(1)
# generating output information
try:
- ip_address =
AzureMeta().get_private_ip_address(notebook_config['resource_group_name'],
-
notebook_config['instance_name'])
+ ip_address =
AzureMeta.get_private_ip_address(notebook_config['resource_group_name'],
+
notebook_config['instance_name'])
zeppelin_ip_url = "http://" + ip_address + ":8080/"
ungit_ip_url = "http://" + ip_address +
":8085/{}-ungit/".format(notebook_config['exploratory_name'])
zeppelin_notebook_access_url = "https://" + edge_instance_hostname +
"/{}/".format(
@@ -376,5 +379,5 @@ if __name__ == "__main__":
result.write(json.dumps(res))
except Exception as err:
dlab.fab.append_result("Failed to generate output information.",
str(err))
- AzureActions().remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
+ AzureActions.remove_instance(notebook_config['resource_group_name'],
notebook_config['instance_name'])
sys.exit(1)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]