def undefine(self, specname=None, all=False): specs = set() if all: for spec in db.select(SPECIFICATION, type='cluster'): specs.add(spec) try: spec = db.select(SPECIFICATION, type='cluster', name=specname or Default.active_specification)[0] specs.add(spec) except IndexError: pass for spec in specs: try: cluster = db.select(Cluster, specId=spec.cm_id)[0] Console.warning('Cannot undefine allocated cluster {}.'.format(cluster.name)) Console.warning('Please delete the cluster first') continue except IndexError: pass db.delete_(SPECIFICATION, cm_id = spec.cm_id) Console.ok('Undefined specification {}'.format(spec.name)) try: spec = db.select(SPECIFICATION, type='cluster')[0] Default.set_specification(spec.name) except IndexError: pass
def define(self, clustername=None, **kwargs): """Define a cluster. kwargs are passed to Cluster :returns: a cluster :rtype: :class:`Cluster` """ clustername = clustername or Default.generate_name(Names.CLUSTER_COUNTER) # remove None to defer default definitions to later for k in kwargs.keys(): if kwargs[k] is None: del kwargs[k] try: spec = db.select(SPECIFICATION, name=clustername, type='cluster')[0] spec.update(kwargs) db.updateObj(spec) except IndexError: spec = SPECIFICATION(clustername, 'cluster', kwargs) db.insert(spec) Default.set_specification(clustername) Console.ok('Defined cluster {}'.format(clustername))
def undefine(self, specname=None, all=False): specs = set() if all: for spec in db.select(SPECIFICATION, type='cluster'): specs.add(spec) try: spec = db.select(SPECIFICATION, type='cluster', name=specname or Default.active_specification)[0] specs.add(spec) except IndexError: pass for spec in specs: try: cluster = db.select(Cluster, specId=spec.cm_id)[0] Console.warning('Cannot undefine allocated cluster {}.'.format( cluster.name)) Console.warning('Please delete the cluster first') continue except IndexError: pass db.delete_(SPECIFICATION, cm_id=spec.cm_id) Console.ok('Undefined specification {}'.format(spec.name)) try: spec = db.select(SPECIFICATION, type='cluster')[0] Default.set_specification(spec.name) except IndexError: pass
def define(self, clustername=None, **kwargs): """Define a cluster. kwargs are passed to Cluster :returns: a cluster :rtype: :class:`Cluster` """ clustername = clustername or Default.generate_name( Names.CLUSTER_COUNTER) # remove None to defer default definitions to later for k in kwargs.keys(): if kwargs[k] is None: del kwargs[k] try: spec = db.select(SPECIFICATION, name=clustername, type='cluster')[0] spec.update(kwargs) db.updateObj(spec) except IndexError: spec = SPECIFICATION(clustername, 'cluster', kwargs) db.insert(spec) Default.set_specification(clustername) Console.ok('Defined cluster {}'.format(clustername))
def use(self, specname): """Activate the given specification :param specname: namne of the specification """ spec = db.select(SPECIFICATION, type='cluster', name=specname)[0] Default.set_specification(spec.name) Default.set_cluster(spec.name)
def use(self, specname): """Activate the given specification :param specname: namne of the specification """ spec = db.select(SPECIFICATION, type='cluster', name=specname)[0] Default.set_specification(spec.name) Default.set_cluster(spec.name)