Merge "Validate node groups without volumes"
This commit is contained in:
commit
70b92f0625
@ -72,6 +72,7 @@ Every MapR cluster must contain:
|
||||
* exactly 1 *Webserver* process
|
||||
* odd number of *ZooKeeper* processes but not less than 1
|
||||
* *FileServer* process on every node
|
||||
* at least 1 Cinder volume or ephemeral drive per instance
|
||||
|
||||
Every Hadoop cluster must contain exactly 1 *Oozie* process
|
||||
|
||||
|
@ -78,6 +78,7 @@ class MapRFS(s.Service):
|
||||
vu.at_least(1, CLDB),
|
||||
vu.each_node_has(FILE_SERVER),
|
||||
vu.on_same_node(CLDB, FILE_SERVER),
|
||||
vu.has_volumes(),
|
||||
]
|
||||
|
||||
def service_dir(self, cluster_context):
|
||||
|
@ -19,6 +19,7 @@ from sahara.conductor import resource as r
|
||||
import sahara.exceptions as ex
|
||||
from sahara.i18n import _
|
||||
import sahara.plugins.exceptions as e
|
||||
import sahara.utils.openstack.nova as nova
|
||||
|
||||
|
||||
class LessThanCountException(e.InvalidComponentCountException):
|
||||
@ -78,6 +79,16 @@ class NodeServiceConflictException(ex.SaharaException):
|
||||
self.code = NodeServiceConflictException.ERROR_CODE
|
||||
|
||||
|
||||
class NoVolumesException(ex.SaharaException):
|
||||
MESSAGE = _('%s must have at least 1 volume or ephemeral drive')
|
||||
ERROR_CODE = "NO_VOLUMES"
|
||||
|
||||
def __init__(self, ng_name):
|
||||
super(NoVolumesException, self).__init__()
|
||||
self.message = NoVolumesException.MESSAGE % ng_name
|
||||
self.code = NoVolumesException.ERROR_CODE
|
||||
|
||||
|
||||
def at_least(count, component):
|
||||
def validate(cluster_context, component, count):
|
||||
actual_count = cluster_context.get_instances_count(component)
|
||||
@ -173,3 +184,16 @@ def create_fake_cluster(cluster, existing, additional):
|
||||
cluster_dict.update({'node_groups': updated + not_updated})
|
||||
fake = r.ClusterResource(cluster_dict)
|
||||
return fake
|
||||
|
||||
|
||||
def get_ephemeral(node_group):
|
||||
return nova.get_flavor(id=node_group.flavor_id).ephemeral
|
||||
|
||||
|
||||
def has_volumes():
|
||||
def validate(cluster_context):
|
||||
for node_group in cluster_context.cluster.node_groups:
|
||||
if not (node_group.volumes_per_node or get_ephemeral(node_group)):
|
||||
raise NoVolumesException(node_group.name)
|
||||
|
||||
return validate
|
||||
|
Loading…
Reference in New Issue
Block a user