Skip to content

Commit d510130

Browse files
committed
format with black
1 parent 5191012 commit d510130

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

app.py

+12-9
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from flask import Flask, request
99
import os
1010

11+
1112
def create_app():
1213
app = Flask(__name__)
1314

@@ -47,6 +48,7 @@ def create_container():
4748
container = Container(**request.get_json(force=True))
4849
container.status = "creating"
4950
new_container(container)
51+
5052
def get_ip():
5153
public_ip = subprocess.getoutput(
5254
f"pct exec {get_vmid()} -- ip -6 addr show eth0 | grep -oP '(?<=inet6\s)[\da-f:]+' | head -n 1"
@@ -106,6 +108,7 @@ class Network(BaseModel):
106108
bridge: Optional[str] = "vmbr0"
107109
ipv6: Optional[str] = "dhcp"
108110

111+
109112
class Container(BaseModel):
110113
id: Optional[int] = ""
111114
hostname: str
@@ -115,15 +118,17 @@ class Container(BaseModel):
115118
ssh_public_keys: Optional[str] = ""
116119
status: Optional[str] = ""
117120

121+
118122
# Get id of container
119123
def get_vmid():
120-
max = 0
121-
for root, dirs, files in os.walk("/etc/pve/lxc/"):
122-
for file in files:
123-
vmid = int(file.replace('.conf', ''))
124-
if vmid > max:
125-
max = vmid
126-
return max
124+
max = 0
125+
for root, dirs, files in os.walk("/etc/pve/lxc/"):
126+
for file in files:
127+
vmid = int(file.replace(".conf", ""))
128+
if vmid > max:
129+
max = vmid
130+
return max
131+
127132

128133
def new_container(container: Container):
129134
# Container ssh keys (optional, but needed if you want to login)
@@ -141,5 +146,3 @@ def new_container(container: Container):
141146
pct create 999 --start --hostname 999 --net0 name=eth0,bridge=vmbr0,ip6=dhcp,gw6=2a01:4f8:160:2333:0:1:0:2 --memory 10240 local:vztmpl/debian-10-standard_10.7-1_amd64.tar.gz
142147
143148
"""
144-
145-

0 commit comments

Comments
 (0)