Fix issues in naming and few other things
This commit is contained in:
parent
f919719b1e
commit
71279a968f
21 changed files with 274 additions and 281 deletions
|
|
@ -2,7 +2,7 @@ import binascii
|
|||
import ipaddress
|
||||
import random
|
||||
import subprocess as sp
|
||||
|
||||
import logging
|
||||
import requests
|
||||
|
||||
from pyotp import TOTP
|
||||
|
|
@ -10,23 +10,28 @@ from pyotp import TOTP
|
|||
from ucloud.config import vm_pool, config
|
||||
|
||||
|
||||
logger = logging.getLogger("ucloud.api.helper")
|
||||
|
||||
def check_otp(name, realm, token):
|
||||
try:
|
||||
data = {
|
||||
"auth_name": config['api']["AUTH_NAME"],
|
||||
"auth_token": TOTP(config['api']["AUTH_SEED"]).now(),
|
||||
"auth_realm": config['api']["AUTH_REALM"],
|
||||
"auth_name": config['otp']['auth_name'],
|
||||
"auth_token": TOTP(config['otp']['auth_seed']).now(),
|
||||
"auth_realm": config['otp']['auth_realm'],
|
||||
"name": name,
|
||||
"realm": realm,
|
||||
"token": token,
|
||||
}
|
||||
except binascii.Error:
|
||||
except binascii.Error as err:
|
||||
logger.error(
|
||||
"Cannot compute OTP for seed: {}".format(config['otp']['auth_seed'])
|
||||
)
|
||||
return 400
|
||||
|
||||
response = requests.post(
|
||||
"{OTP_SERVER}{OTP_VERIFY_ENDPOINT}".format(
|
||||
OTP_SERVER=config['api']["OTP_SERVER"],
|
||||
OTP_VERIFY_ENDPOINT=config['api']["OTP_VERIFY_ENDPOINT"]
|
||||
OTP_SERVER=config['otp']['server'],
|
||||
OTP_VERIFY_ENDPOINT=config['otp']['verify_endpoint']
|
||||
),
|
||||
json=data,
|
||||
)
|
||||
|
|
@ -80,7 +85,7 @@ def resolve_image_name(name, etcd_client):
|
|||
except Exception:
|
||||
raise ValueError("Image name not in correct format i.e {store_name}:{image_name}")
|
||||
|
||||
images = etcd_client.get_prefix(config['api']['IMAGE_PREFIX'], value_in_json=True)
|
||||
images = etcd_client.get_prefix(config['etcd']['image_prefix'], value_in_json=True)
|
||||
|
||||
# Try to find image with name == image_name and store_name == store_name
|
||||
try:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue