Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cloud-computing-msc-ai-examples
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sebastian Rieger
cloud-computing-msc-ai-examples
Commits
7c2a5341
Commit
7c2a5341
authored
1 year ago
by
Usama Tahir
Browse files
Options
Downloads
Patches
Plain Diff
demo2-instance-with-init-script.py converted to python 3 using 2to3
parent
c9d8e9b0
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
demo2-instance-with-init-script.py
+8
-8
8 additions, 8 deletions
demo2-instance-with-init-script.py
with
8 additions
and
8 deletions
demo2-instance-with-init-script.py
+
8
−
8
View file @
7c2a5341
...
...
@@ -104,7 +104,7 @@ def main():
keypair_exists
=
True
if
keypair_exists
:
print
(
'
Keypair
'
+
keypair_name
+
'
already exists. Skipping import.
'
)
print
(
(
'
Keypair
'
+
keypair_name
+
'
already exists. Skipping import.
'
)
)
else
:
print
(
'
adding keypair...
'
)
conn
.
import_key_pair_from_file
(
keypair_name
,
pub_key_file
)
...
...
@@ -128,7 +128,7 @@ def main():
security_group_exists
=
True
if
security_group_exists
:
print
(
'
Security Group
'
+
all_in_one_security_group
.
name
+
'
already exists. Skipping creation.
'
)
print
(
(
'
Security Group
'
+
all_in_one_security_group
.
name
+
'
already exists. Skipping creation.
'
)
)
else
:
all_in_one_security_group
=
conn
.
ex_create_security_group
(
security_group_name
,
'
network access for all-in-one application.
'
)
...
...
@@ -159,7 +159,7 @@ def main():
instance_exists
=
True
if
instance_exists
:
print
(
'
Instance
'
+
testing_instance
.
name
+
'
already exists. Skipping creation.
'
)
print
(
(
'
Instance
'
+
testing_instance
.
name
+
'
already exists. Skipping creation.
'
)
)
exit
()
else
:
print
(
'
Starting new all-in-one instance and wait until it is running...
'
)
...
...
@@ -181,12 +181,12 @@ def main():
private_ip
=
None
if
len
(
testing_instance
.
private_ips
):
private_ip
=
testing_instance
.
private_ips
[
0
]
print
(
'
Private IP found: {}
'
.
format
(
private_ip
))
print
(
(
'
Private IP found: {}
'
.
format
(
private_ip
))
)
public_ip
=
None
if
len
(
testing_instance
.
public_ips
):
public_ip
=
testing_instance
.
public_ips
[
0
]
print
(
'
Public IP found: {}
'
.
format
(
public_ip
))
print
(
(
'
Public IP found: {}
'
.
format
(
public_ip
))
)
print
(
'
Checking for unused Floating IP...
'
)
unused_floating_ip
=
None
...
...
@@ -197,11 +197,11 @@ def main():
if
not
unused_floating_ip
and
len
(
conn
.
ex_list_floating_ip_pools
()):
pool
=
conn
.
ex_list_floating_ip_pools
()[
0
]
print
(
'
Allocating new Floating IP from pool: {}
'
.
format
(
pool
))
print
(
(
'
Allocating new Floating IP from pool: {}
'
.
format
(
pool
))
)
unused_floating_ip
=
pool
.
create_floating_ip
()
if
public_ip
:
print
(
'
Instance
'
+
testing_instance
.
name
+
'
already has a public ip. Skipping attachment.
'
)
print
(
(
'
Instance
'
+
testing_instance
.
name
+
'
already has a public ip. Skipping attachment.
'
)
)
elif
unused_floating_ip
:
conn
.
ex_attach_floating_ip_to_node
(
testing_instance
,
unused_floating_ip
)
...
...
@@ -214,7 +214,7 @@ def main():
actual_ip_address
=
private_ip
print
(
'
\n
'
)
print
(
'
The Fractals app will be deployed to http://{}
\n
'
.
format
(
actual_ip_address
))
print
(
(
'
The Fractals app will be deployed to http://{}
\n
'
.
format
(
actual_ip_address
))
)
print
(
'
You can use ssh to login to the instance using your private key. Default user name for official Ubuntu
\n
'
'
Cloud Images is: ubuntu, so you can use, e.g.:
"
ssh -i ~/.ssh/id_rsa ubuntu@<floating-ip>
"
if your private
\n
'
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment