sputnik13 commented on a change in pull request #288: Refactor config
URL: https://github.com/apache/fluo-muchos/pull/288#discussion_r332234993
 
 

 ##########
 File path: lib/muchos/config/ec2.py
 ##########
 @@ -0,0 +1,184 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+from muchos.config import SERVICES, OPTIONAL_SERVICES
+from muchos.config.base import BaseConfig
+from sys import exit
+from muchos.config.decorators import *
+from muchos.config.validators import *
+from muchos.util import get_ephemeral_devices, get_arch
+import os
+import json
+import glob
+
+
+class Ec2DeployConfig(BaseConfig):
+
+    def __init__(self, deploy_path, config_path, hosts_path, checksums_path, 
templates_path, cluster_name):
+        super(Ec2DeployConfig, self).__init__(deploy_path, config_path, 
hosts_path, checksums_path, templates_path, cluster_name)
+        self.sg_name = cluster_name + '-group'
+        self.ephemeral_root = 'ephemeral'
+        self.cluster_template_d = None
+        self.metrics_drive_root = 'media-' + self.ephemeral_root
+        self.init_template(templates_path)
+
+    def verify_config(self, action):
+        self._verify_config(action)
+
+    def verify_launch(self):
+        self.verify_instance_type(self.get('ec2', 'default_instance_type'))
+        self.verify_instance_type(self.get('ec2', 'worker_instance_type'))
+
+    def init_nodes(self):
+        self.node_d = {}
+        for (hostname, value) in self.items('nodes'):
+            if hostname in self.node_d:
+                exit('Hostname {0} already exists twice in 
nodes'.format(hostname))
+            service_list = []
+            for service in value.split(','):
+                if service in SERVICES:
+                    service_list.append(service)
+                else:
+                    exit('Unknown service "%s" declared for node %s' % 
(service, hostname))
+            self.node_d[hostname] = service_list
+
+    def default_ephemeral_devices(self):
+        return get_ephemeral_devices(self.get('ec2', 'default_instance_type'))
+
+    def worker_ephemeral_devices(self):
+        return get_ephemeral_devices(self.get('ec2', 'worker_instance_type'))
+
+    def max_ephemeral(self):
+        return max((len(self.default_ephemeral_devices()), 
len(self.worker_ephemeral_devices())))
+
+    def node_type_map(self):
+        if self.cluster_template_d:
+            return self.cluster_template_d['devices']
+
+        node_types = {}
+
+        node_list = [('default', self.default_ephemeral_devices()), ('worker', 
self.worker_ephemeral_devices())]
+
+        for (ntype, devices) in node_list:
+            node_types[ntype] = {'mounts': self.mounts(len(devices)), 
'devices': devices}
+
+        return node_types
+
+    def mount_root(self):
+        return '/media/' + self.ephemeral_root
+
+    @ansible_play_var
 
 Review comment:
   yes decorators are run when the file is loaded

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to