Skip to content

Commit a258cc0

Browse files
authored
CCE fixes for better CLI handling (#150)
CCE fixes for better CLI handling Reviewed-by: Rodion Gyrbu <[email protected]> Reviewed-by: Tino Schr <None> Reviewed-by: None <None> Reviewed-by: Anton Sidelnikov <None>
1 parent 7b1d34b commit a258cc0

File tree

8 files changed

+636
-286
lines changed

8 files changed

+636
-286
lines changed

examples/cce/create_cluster_node.py

Lines changed: 45 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -20,49 +20,67 @@
2020

2121

2222
attrs = {
23-
"kind": "Node",
24-
"apiVersion": "v3",
25-
"metadata": {
26-
"name": "myhost",
27-
"labels": {
28-
"foo": "bar"
23+
'kind': 'Node',
24+
'apiVersion': 'v3',
25+
'metadata': {
26+
'name': 'myhost',
27+
'labels': {
28+
'foo': 'bar'
2929
},
30-
"annotations": {
31-
"annotation1": "abc"
30+
'annotations': {
31+
'annotation1': 'abc'
3232
}
3333
},
34-
"spec": {
35-
"flavor": "s2.large.2",
36-
"az": "eu-de-02",
37-
"login": {
38-
"sshKey": "keypair-pub"
34+
'spec': {
35+
'flavor': 's2.large.2',
36+
'az': 'eu-de-02',
37+
'login': {
38+
'sshKey': 'keypair-pub'
3939
},
40-
"rootVolume": {
41-
"size": 40,
42-
"volumetype": "SATA"
40+
'rootVolume': {
41+
'size': 40,
42+
'volumetype': 'SATA'
4343
},
44-
"dataVolumes": [
44+
'dataVolumes': [
4545
{
46-
"size": 100,
47-
"volumetype": "SATA"
46+
'size': 100,
47+
'volumetype': 'SATA'
4848
}
4949
],
50-
"userTags": [
50+
'userTags': [
5151
{
52-
"key": "tag1",
53-
"value": "aaaa"
52+
'key': 'tag1',
53+
'value': 'aaaa'
5454
},
5555
{
56-
"key": "tag2",
57-
"value": "bbbb"
56+
'key': 'tag2',
57+
'value': 'bbbb'
5858
}
5959
],
60-
"k8sTags": {
61-
"label-test": "test"
60+
'k8sTags': {
61+
'label-test': 'test'
62+
},
63+
'publicIP': {
64+
# ids: ['1234', '5678']
65+
'count': 2,
66+
'eip': {
67+
'iptype': '5_bgp',
68+
'bandwidth': {
69+
'chargemode': 'traffic',
70+
'size': 10,
71+
'sharetype': 'PER'
72+
}
73+
}
74+
},
75+
'count': 2,
76+
'nodeNicSpec': {
77+
'primaryNic': {
78+
'subnetId': 'bbfc0a20-d66c-4f36-b4c1-265d669b8c62'
79+
}
6280
},
63-
"count": 1,
6481
}
6582
}
83+
6684
cluster = 'name_or_id'
6785
cluster = conn.cce.find_cluster(name_or_id=cluster)
6886
conn.cce.create_cluster_node(cluster=cluster, **attrs)

otcextensions/osclient/cce/v2/cluster.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,15 @@ def _flatten_cluster(obj):
3232
'status': obj.status.status,
3333
'type': obj.spec.type,
3434
'flavor': obj.spec.flavor,
35-
'endpoint': obj.status.endpoints.get('external_otc'),
3635
'router_id': obj.spec.host_network.router_id,
3736
'network_id': obj.spec.host_network.network_id,
3837
'version': obj.spec.version
3938
}
4039

40+
endpoints = obj.status.get('endpoints')
41+
if endpoints:
42+
data['endpoint'] = endpoints.get('external_otc')
43+
4144
return data
4245

4346

@@ -186,7 +189,7 @@ def get_parser(self, prog_name):
186189
metavar='{' + ','.join(CONTAINER_NET_MODE_CHOICES) + '}',
187190
type=lambda s: s.lower(),
188191
choices=CONTAINER_NET_MODE_CHOICES,
189-
required=True,
192+
default='overlay_l2',
190193
help=_('Container network mode.')
191194
)
192195
parser.add_argument(

0 commit comments

Comments
 (0)