forked from uncloud/uncloud
Merge branch 'master' of code.ungleich.ch:ucloud/ucloud
This commit is contained in:
commit
dee0a29c91
5 changed files with 18 additions and 31 deletions
0
bin/ucloud-run-reinstall
Normal file → Executable file
0
bin/ucloud-run-reinstall
Normal file → Executable file
|
@ -30,9 +30,9 @@ CERT_CERT = changeme
|
|||
CERT_KEY = changeme
|
||||
|
||||
|
||||
FILE_PREFIX = file/
|
||||
FILE_PREFIX = files
|
||||
HOST_PREFIx = hosts
|
||||
IMAGE_PREFIX = image/
|
||||
IMAGE_PREFIX = images
|
||||
IMAGE_STORE_PREFIX = imagestore/
|
||||
|
||||
NETWORK_PREFIX = networks
|
||||
|
@ -57,10 +57,5 @@ FILE_DIR = /var/lib/ucloud/files
|
|||
FILE_PREFIX = noclue-ahmed
|
||||
|
||||
[ssh]
|
||||
SSH_USERNAME =
|
||||
SSH_PRIVATEKEY =
|
||||
|
||||
# unkown vars:
|
||||
IMAGE_DIR =
|
||||
BASE_DIR =
|
||||
IMAGE_STORE_PREFIX =
|
||||
SSH_USERNAME =
|
||||
SSH_PRIVATEKEY =
|
|
@ -18,21 +18,16 @@ if __name__ == "__main__":
|
|||
arg_parser.add_argument('component_args', nargs='*')
|
||||
args = arg_parser.parse_args()
|
||||
|
||||
if args.conf_dir:
|
||||
os.environ['UCLOUD_CONF_DIR'] = args.conf_dir
|
||||
|
||||
try:
|
||||
name = args.component
|
||||
mod = importlib.import_module("ucloud.{}.main".format(name))
|
||||
main = getattr(mod, "main")
|
||||
|
||||
if args.conf_dir:
|
||||
print("setting conf")
|
||||
os.environ['UCLOUD_CONF_DIR'] = args.conf_dir
|
||||
|
||||
main()
|
||||
|
||||
# except decouple.UndefinedValueError as e:
|
||||
# print(e)
|
||||
# sys.exit(1)
|
||||
|
||||
except Exception as e:
|
||||
logging.exception(e)
|
||||
print(e)
|
||||
|
|
|
@ -28,7 +28,7 @@ class CreateVM(Resource):
|
|||
validator = schemas.CreateVMSchema(data)
|
||||
if validator.is_valid():
|
||||
vm_uuid = uuid4().hex
|
||||
vm_key = join_path(config['api']["VM_PREFIX"), vm_uuid)
|
||||
vm_key = join_path(config['etcd']["VM_PREFIX"], vm_uuid)
|
||||
specs = {
|
||||
"cpu": validator.specs["cpu"],
|
||||
"ram": validator.specs["ram"],
|
||||
|
@ -56,7 +56,7 @@ class CreateVM(Resource):
|
|||
# Create ScheduleVM Request
|
||||
r = RequestEntry.from_scratch(
|
||||
type=RequestType.ScheduleVM, uuid=vm_uuid,
|
||||
request_prefix=config['api']["REQUEST_PREFIX")
|
||||
request_prefix=config['etcd']["REQUEST_PREFIX"]
|
||||
)
|
||||
request_pool.put(r)
|
||||
|
||||
|
@ -71,7 +71,7 @@ class VmStatus(Resource):
|
|||
validator = schemas.VMStatusSchema(data)
|
||||
if validator.is_valid():
|
||||
vm = vm_pool.get(
|
||||
join_path(config['api']["VM_PREFIX"), data["uuid"])
|
||||
join_path(config['etcd']["VM_PREFIX"], data["uuid"])
|
||||
)
|
||||
vm_value = vm.value.copy()
|
||||
vm_value["ip"] = []
|
||||
|
@ -79,7 +79,7 @@ class VmStatus(Resource):
|
|||
network_name, mac, tap = network_mac_and_tap
|
||||
network = etcd_client.get(
|
||||
join_path(
|
||||
config['api']["NETWORK_PREFIX"),
|
||||
config['etcd']["NETWORK_PREFIX"],
|
||||
data["name"],
|
||||
network_name,
|
||||
),
|
||||
|
@ -100,7 +100,7 @@ class CreateImage(Resource):
|
|||
validator = schemas.CreateImageSchema(data)
|
||||
if validator.is_valid():
|
||||
file_entry = etcd_client.get(
|
||||
join_path(config['api']["FILE_PREFIX"), data["uuid"])
|
||||
join_path(config['etcd']["FILE_PREFIX"], data["uuid"])
|
||||
)
|
||||
file_entry_value = json.loads(file_entry.value)
|
||||
|
||||
|
@ -113,7 +113,7 @@ class CreateImage(Resource):
|
|||
"visibility": "public",
|
||||
}
|
||||
etcd_client.put(
|
||||
join_path(config['etcd']["IMAGE_PREFIX"), data["uuid"]),
|
||||
join_path(config['etcd']["IMAGE_PREFIX"], data["uuid"]),
|
||||
json.dumps(image_entry_json),
|
||||
)
|
||||
|
||||
|
@ -125,7 +125,7 @@ class ListPublicImages(Resource):
|
|||
@staticmethod
|
||||
def get():
|
||||
images = etcd_client.get_prefix(
|
||||
config['etcd']["IMAGE_PREFIX"), value_in_json=True
|
||||
config['etcd']["IMAGE_PREFIX"], value_in_json=True
|
||||
)
|
||||
r = {
|
||||
"images": []
|
||||
|
@ -148,7 +148,7 @@ class VMAction(Resource):
|
|||
|
||||
if validator.is_valid():
|
||||
vm_entry = vm_pool.get(
|
||||
join_path(config['etcd']["VM_PREFIX"), data["uuid"])
|
||||
join_path(config['etcd']["VM_PREFIX"], data["uuid"])
|
||||
)
|
||||
action = data["action"]
|
||||
|
||||
|
@ -326,7 +326,7 @@ class GetSSHKeys(Resource):
|
|||
|
||||
# {user_prefix}/{realm}/{name}/key/{key_name}
|
||||
etcd_key = join_path(
|
||||
config['etcd']['USER_PREFIX'),
|
||||
config['etcd']['USER_PREFIX'],
|
||||
data["realm"],
|
||||
data["name"],
|
||||
"key",
|
||||
|
@ -430,9 +430,7 @@ class CreateNetwork(Resource):
|
|||
|
||||
prefix = nb_prefix.available_prefixes.create(
|
||||
data={
|
||||
"prefix_length": config['network'][
|
||||
"PREFIX_LENGTH"]
|
||||
),
|
||||
"prefix_length": config['network']["PREFIX_LENGTH"],
|
||||
"description": '{}\'s network "{}"'.format(
|
||||
data["name"], data["network_name"]
|
||||
),
|
||||
|
|
|
@ -25,8 +25,7 @@ config_file = os.path.join(conf_dir, conf_name)
|
|||
config = configparser.ConfigParser()
|
||||
|
||||
try:
|
||||
with open(config_file, "r") as conf_fd:
|
||||
conf.read(conf_fd)
|
||||
config.read(config_file)
|
||||
except FileNotFoundError:
|
||||
log.warn("Configuration file not found - using defaults")
|
||||
|
||||
|
|
Loading…
Reference in a new issue