-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cce scenario #1
base: master
Are you sure you want to change the base?
Cce scenario #1
Changes from all commits
a4b77bf
6312aed
8fcb4f1
d8175fe
4606a63
f2ac6c8
79c5741
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import sys | ||
|
||
import openstack | ||
from otcextensions import sdk | ||
|
||
# openstack.enable_logging(True, http_debug=True) | ||
|
||
# An 'otc' is a cloud connection with name 'otc' configured in the clouds.yaml | ||
conn = openstack.connect() | ||
|
||
# Register OTC Extensions | ||
sdk.register_otc_extensions(conn) | ||
|
||
cluster = conn.cce.find_cluster(sys.argv[1]) | ||
dict = { | ||
'metadata': { | ||
'name': sys.argv[1] | ||
}, | ||
'spec': { | ||
'type': 'VirtualMachine', | ||
'version': 'v1.11.7-r2', | ||
'hostNetwork': { | ||
'vpc': sys.argv[2], | ||
'subnet': sys.argv[3] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. subnet => network_id There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also changed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same like as mentioned above |
||
}, | ||
'flavor': 'cce.s1.small', | ||
'containerNetwork': { | ||
'mode': 'overlay_l2', | ||
'cidr': '172.16.0.0/16' | ||
} | ||
} | ||
} | ||
|
||
if (cluster is None): | ||
cluster = conn.cce.create_cluster(**dict) | ||
job = conn.cce.get_job(cluster.job_id) | ||
conn.cce.wait_for_job(job) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import sys | ||
|
||
import openstack | ||
from otcextensions import sdk | ||
|
||
# openstack.enable_logging(True, http_debug=True) | ||
|
||
# An 'otc' is a cloud connection with name 'otc' configured in the clouds.yaml | ||
conn = openstack.connect() | ||
|
||
# Register OTC Extensions | ||
sdk.register_otc_extensions(conn) | ||
|
||
cluster = conn.cce.find_cluster(sys.argv[1]) | ||
node = conn.cce.find_cluster_node(cluster, sys.argv[2]) | ||
dict = { | ||
"metadata": { | ||
"name": sys.argv[2] | ||
}, | ||
"spec": { | ||
"flavor": "s2.large.4", | ||
"az": "eu-de-01", | ||
"login": { | ||
"sshKey": sys.argv[3] | ||
}, | ||
"rootVolume": { | ||
"size": 40, | ||
"volumetype": "SATA" | ||
}, | ||
"dataVolumes": [ | ||
{ | ||
"size": 100, | ||
"volumetype": "SATA" | ||
} | ||
], | ||
"count": 1 | ||
} | ||
} | ||
|
||
if cluster and (node is None): | ||
node = conn.cce.create_cluster_node(cluster, **dict) | ||
job = conn.cce.get_job(node.job_id) | ||
conn.cce.wait_for_job(job) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import sys | ||
import time | ||
|
||
import openstack | ||
from otcextensions import sdk | ||
|
||
openstack.enable_logging(True, http_debug=True) | ||
|
||
# An 'otc' is a cloud connection with name 'otc' configured in the clouds.yaml | ||
conn = openstack.connect() | ||
|
||
# Register OTC Extensions | ||
sdk.register_otc_extensions(conn) | ||
|
||
cluster = conn.cce.find_cluster(sys.argv[1]) | ||
|
||
timer = 0 | ||
|
||
if cluster: | ||
conn.cce.delete_cluster(cluster) | ||
time.sleep(100) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import sys | ||
|
||
import openstack | ||
from otcextensions import sdk | ||
|
||
openstack.enable_logging(True, http_debug=True) | ||
|
||
# An 'otc' is a cloud connection with name 'otc' configured in the clouds.yaml | ||
conn = openstack.connect() | ||
|
||
# Register OTC Extensions | ||
sdk.register_otc_extensions(conn) | ||
|
||
cluster = conn.cce.find_cluster(sys.argv[1]) | ||
node = conn.cce.find_cluster_node(cluster, sys.argv[2]) | ||
|
||
if cluster and node: | ||
node = conn.cce.delete_cluster_node(cluster, node) | ||
# job = conn.cce.get_job(node.job_id) | ||
# conn.cce.wait_for_job(job) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import openstack | ||
import sys | ||
|
||
from otcextensions import sdk | ||
|
||
# openstack.enable_logging(True, http_debug=True) | ||
|
||
# An 'otc' is a cloud connection with name 'otc' configured in the clouds.yaml | ||
conn = openstack.connect() | ||
|
||
# Register OTC Extensions | ||
sdk.register_otc_extensions(conn) | ||
|
||
cluster = conn.cce.find_cluster(sys.argv[1]) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import openstack | ||
import sys | ||
|
||
from otcextensions import sdk | ||
|
||
# openstack.enable_logging(True, http_debug=True) | ||
|
||
# An 'otc' is a cloud connection with name 'otc' configured in the clouds.yaml | ||
conn = openstack.connect() | ||
|
||
# Register OTC Extensions | ||
sdk.register_otc_extensions(conn) | ||
|
||
cluster = conn.cce.find_cluster(sys.argv[1]) | ||
node = conn.cce.find_cluster_node(cluster, sys.argv[2]) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import openstack | ||
from otcextensions import sdk | ||
|
||
# openstack.enable_logging(True, http_debug=True) | ||
|
||
# An 'otc' is a cloud connection with name 'otc' configured in the clouds.yaml | ||
conn = openstack.connect() | ||
|
||
# Register OTC Extensions | ||
sdk.register_otc_extensions(conn) | ||
|
||
|
||
cluster = conn.cce.get_cluster('e9d8539e-c894-11e9-a4c3-0255ac101618') |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import re | ||
import sys | ||
|
||
import openstack | ||
from otcextensions import sdk | ||
|
||
# openstack.enable_logging(True, http_debug=True) | ||
|
||
# An 'otc' is a cloud connection with name 'otc' configured in the clouds.yaml | ||
conn = openstack.connect() | ||
|
||
# Register OTC Extensions | ||
sdk.register_otc_extensions(conn) | ||
|
||
# Search for corresponding cluster | ||
cluster = conn.cce.find_cluster(sys.argv[1]) | ||
|
||
# Query Certificate information | ||
certificates = conn.cce.get_cluster_certificates(cluster) | ||
|
||
# Use RegEx to create kubectl conform configuration information | ||
ca_regex = r"ca=(\w*\={,2})," | ||
client_certificate_regex = r"client_certificate=(\w*\={,2})," | ||
client_key_regex = r"client_key=(\w*\={,2})," | ||
internal_ip_regex = r"context={'name': 'internal', 'cluster': 'https://((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]):[0-9]{,5})" | ||
|
||
ca_data = re.search(ca_regex, str(certificates)) | ||
client_certificate_data = re.search(client_certificate_regex, | ||
str(certificates)) | ||
client_key_data = re.search(client_key_regex, str(certificates)) | ||
internal_ip_data = re.search(internal_ip_regex, str(certificates)) | ||
|
||
ca_data = ca_data.group(1) | ||
client_certificate_data = client_certificate_data.group(1) | ||
client_key_data = client_key_data.group(1) | ||
internal_ip_data = "https://" + internal_ip_data.group(1) | ||
|
||
# print("CA-data: " + ca_data) | ||
# print("Client Cert Data: " + client_certificate_data) | ||
# print("Client Key Data: " + client_key_data) | ||
# print("IP Data: " + internal_ip_data) | ||
|
||
kube_config = { | ||
"kind": "Config", | ||
"apiVersion": "v1", | ||
"preferences": { | ||
}, | ||
"clusters": [ | ||
{ | ||
"name": "internalCluster", | ||
"cluster": { | ||
"server": internal_ip_data, | ||
"certificate-authority-data": ca_data | ||
} | ||
} | ||
], | ||
"users": [ | ||
{ | ||
"name": "user", | ||
"user": { | ||
"client-certificate-data": client_certificate_data, | ||
"client-key-data": client_key_data | ||
} | ||
} | ||
], | ||
"contexts": [ | ||
{ | ||
"name": "internal", | ||
"context": { | ||
"cluster": "internalCluster", | ||
"user": "user" | ||
} | ||
} | ||
], | ||
"current-context": "internal" | ||
} | ||
|
||
print(str(kube_config)) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import openstack | ||
from otcextensions import sdk | ||
|
||
# openstack.enable_logging(True, http_debug=True) | ||
|
||
# An 'otc' is a cloud connection with name 'otc' configured in the clouds.yaml | ||
conn = openstack.connect() | ||
|
||
# Register OTC Extensions | ||
sdk.register_otc_extensions(conn) | ||
|
||
for cluster in conn.cce.clusters(): | ||
print(cluster) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import openstack | ||
from otcextensions import sdk | ||
|
||
import sys | ||
|
||
# openstack.enable_logging(True, http_debug=True) | ||
|
||
# An 'otc' is a cloud connection with name 'otc' configured in the clouds.yaml | ||
conn = openstack.connect() | ||
|
||
# Register OTC Extensions | ||
sdk.register_otc_extensions(conn) | ||
|
||
|
||
cluster = conn.cce.find_cluster(sys.argv[1]) | ||
conn.cce.wait_for_cluster(cluster, status='Available', | ||
failures=None, interval=10, wait=960) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vpc is currently renamed to router_id
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I oriented my self @ the official docu. After now how this mapping is done, I see the point. Thanks for the hint. Changed it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ich changed both values, but get "BadRequest" if I do this. Switching back works again.