def plan_prepare(conf): music = api.API() music.keyspace_create(keyspace=conf.keyspace) plan_tmp = base.create_dynamic_model(keyspace=conf.keyspace, baseclass=plan.Plan, classname="Plan") return plan_tmp
def load_into_country_letancy(self, json_data): datamap = collections.OrderedDict() group_map = collections.OrderedDict() datamap = json.loads(json_data) #for i, j in enumerate(datamap): # group_map[j['group']] = j['countries'] music = api.API() #for row in group_map: # music.row_create() kwargs = { 'keyspace': 'conductor_inam', 'table': 'country_latency', 'pk_name': 'id' } for row in enumerate(datamap): kwargs['pk_value'] = id() kwargs['values'] = { 'country_name': row['country_name'], 'groups': row['groups'] } music.row_create(**kwargs) print(group_map)
def _init(self, conf, **kwargs): """Set up the necessary ingredients.""" self.conf = conf self.kwargs = kwargs self.Plan = kwargs.get('plan_class') self.OrderLock = kwargs.get('order_locks') self.OrderLockHistory = kwargs.get('order_locks_history') self.RegionPlaceholders = kwargs.get('region_placeholders') self.CountryLatency = kwargs.get('country_latency') self.TriageTool = kwargs.get('triage_tool') # Set up the RPC service(s) we want to talk to. self.data_service = self.setup_rpc(conf, "data") # Set up the cei and optimizer self.cei = cei.ConstraintEngineInterface(self.data_service) # self.optimizer = optimizer.Optimizer(conf) # Set up Music access. self.music = api.API() self.solver_owner_condition = { "solver_owner": socket.gethostname() } self.translated_status_condition = { "status": self.Plan.TRANSLATED } self.solving_status_condition = { "status": self.Plan.SOLVING } if not self.conf.solver.concurrent: self._reset_solving_status()
def setUp(self): # Initialize music API cfg.CONF.set_override('certificate_authority_bundle_file', '../AAF_RootCA.cer', 'music_api') music = api.API() cfg.CONF.set_override('keyspace', 'conductor') music.keyspace_create(keyspace=cfg.CONF.keyspace) self.order_lock_svc = OrdersLockingService()
def plan_prepare(conf): cfg.CONF.set_override('certificate_authority_bundle_file', '../AAF_RootCA.cer', 'music_api') music = api.API() music.keyspace_create(keyspace=conf.keyspace) plan_tmp = base.create_dynamic_model(keyspace=conf.keyspace, baseclass=plan.Plan, classname="Plan") return plan_tmp
def __init__(self, conf): self.conf = conf # Set up Music access. self.music = api.API() self.music.keyspace_create(keyspace=conf.keyspace) # Dynamically create a plan class for the specified keyspace self.Plan = base.create_dynamic_model(keyspace=conf.keyspace, baseclass=plan.Plan, classname="Plan") self.OrderLock = base.create_dynamic_model( keyspace=conf.keyspace, baseclass=order_lock.OrderLock, classname="OrderLock") self.OrderLockHistory = base.create_dynamic_model( keyspace=conf.keyspace, baseclass=order_lock_history.OrderLockHistory, classname="OrderLockHistory") self.RegionPlaceholders = base.create_dynamic_model( keyspace=conf.keyspace, baseclass=region_placeholders.RegionPlaceholders, classname="RegionPlaceholders") self.CountryLatency = base.create_dynamic_model( keyspace=conf.keyspace, baseclass=country_latency.CountryLatency, classname="CountryLatency") self.TriageTool = base.create_dynamic_model( keyspace=conf.keyspace, baseclass=triage_tool.TriageTool, classname="TriageTool") #self.Groups = base.create_dynamic_model( # keyspace=conf.keyspace, baseclass=groups.Groups, classname="Groups") #self.GroupRules = base.create_dynamic_model( # keyspace=conf.keyspace, baseclass=group_rules.GroupRules, classname="GroupRules") # Initialize Prometheus metrics Endpoint # Solver service uses index 1 PC._init_metrics(1) if not self.Plan: raise if not self.OrderLock: raise if not self.OrderLockHistory: raise if not self.RegionPlaceholders: raise if not self.CountryLatency: raise if not self.TriageTool: raise
def getTransactionId(keyspace, plan_id): """ get transaction id from a pariticular plan in MUSIC """ rows = api.API().row_read(keyspace, "plans", "id", plan_id) if 'result' in rows: rows = rows['result'] for row_id, row_value in rows.items(): template = row_value['template'] if template: data = json.loads(template) if "transaction-id" in data: return data["transaction-id"]
def music_api(configuration): """Create or return a Music API instance""" configuration = dict(configuration) kwargs = { 'host': configuration.get('host'), 'port': configuration.get('port'), 'version': configuration.get('version'), 'replication_factor': configuration.get('replication_factor'), } api_instance = api.API(**kwargs) # Create the keyspace if necessary # TODO(jdandrea): Use oslo.config with a [music] section # keyspace = conf.music.get('keyspace') # api_instance.create_keyspace(keyspace) return api_instance
def __init__(self, conf): self.conf = conf # Set up Music access. self.music = api.API() self.music.keyspace_create(keyspace=conf.keyspace) # Dynamically create a plan class for the specified keyspace self.Plan = base.create_dynamic_model( keyspace=conf.keyspace, baseclass=plan.Plan, classname="Plan") self.OrderLock = base.create_dynamic_model( keyspace=conf.keyspace, baseclass=order_lock.OrderLock, classname="OrderLock") if not self.Plan: raise if not self.OrderLock: raise
def setUp(self): # Initialize music API music = api.API() cfg.CONF.set_override('keyspace', 'conductor') music.keyspace_create(keyspace=cfg.CONF.keyspace) self.sp = SolverRequestParser() c1 = access_dist.AccessDistance(_name='c1', _type='t1', _demand_list=['d1', 'd2']) c2 = access_dist.AccessDistance(_name='c2', _type='t1', _demand_list=['d1']) self.sp.constraints = {'c1': c1, 'c2': c2} self.sp.demands = { 'd1': demand.Demand('d1'), 'd2': demand.Demand('d2') }
def _init(self, conf, **kwargs): """Set up the necessary ingredients.""" self.conf = conf self.kwargs = kwargs self.Plan = kwargs.get('plan_class') self.OrderLock = kwargs.get('order_locks') # Set up the RPC service(s) we want to talk to. self.data_service = self.setup_rpc(conf, "data") # Set up Music access. self.music = api.API() # Number of retries for reservation/release self.reservation_retries = self.conf.reservation.reserve_retries if not self.conf.reservation.concurrent: self._reset_reserving_status()
def _init(self, conf, **kwargs): self.conf = conf self.Plan = kwargs.get('plan_class') self.kwargs = kwargs # Set up the RPC service(s) we want to talk to. self.data_service = self.setup_rpc(conf, "data") # Set up Music access. self.music = api.API() self.translation_owner_condition = { "translation_owner": socket.gethostname() } self.template_status_condition = {"status": self.Plan.TEMPLATE} self.translating_status_condition = {"status": self.Plan.TRANSLATING} if not self.conf.controller.concurrent: self._reset_template_status()
def __init__(self): rph = region_placeholders.RegionPlaceholders() music = api.API() print("Music version %s" % music.version())
def main(): """Sample usage of Music.""" service.prepare_service() CONF.set_override('debug', True, 'music_api') CONF.set_override('mock', True, 'music_api') CONF.set_override('hostnames', ['music2'], 'music_api') music = api.API() print("Music version %s" % music.version()) # Randomize the name so that we don't step on each other. keyspace = 'NewVotingApp' + str(current_time_millis() / 100) music.keyspace_create(keyspace) # Create the table kwargs = { 'keyspace': keyspace, 'table': 'votecount', 'schema': { 'name': 'text', 'count': 'varint', 'PRIMARY KEY': '(name)' } } music.table_create(**kwargs) # Candidate data data = {'Joe': 5, 'Shankar': 7, 'Gueyoung': 8, 'Matti': 2, 'Kaustubh': 0} # Create an entry in the voting table for each candidate # and with a vote count of 0. kwargs = {'keyspace': keyspace, 'table': 'votecount', 'pk_name': 'name'} for name in data: # We only want the keys kwargs['pk_value'] = name kwargs['values'] = {'name': name, 'count': 0} music.row_create(**kwargs) # Update each candidate's count atomically. kwargs = {'keyspace': keyspace, 'table': 'votecount', 'pk_name': 'name'} for name in data: count = data[name] kwargs['pk_value'] = name kwargs['values'] = {'count': count} kwargs['atomic'] = True music.row_update(**kwargs) # Read all rows kwargs = {'keyspace': keyspace, 'table': 'votecount'} print(music.row_read(**kwargs)) # Reads all rows # Delete Joe, read Matti kwargs = {'keyspace': keyspace, 'table': 'votecount', 'pk_name': 'name'} kwargs['pk_value'] = 'Joe' music.row_delete(**kwargs) kwargs['pk_value'] = 'Matti' print(music.row_read(**kwargs)) # Read all rows again kwargs = {'keyspace': keyspace, 'table': 'votecount'} print(music.row_read(**kwargs)) # Reads all rows # Cleanup. music.keyspace_delete(keyspace)
def setUp(self, conf, _requests=None, _begin_time=None): self.music = api.API() self.conf = cfg.CONF self.greedy = Greedy(self.conf) self._objective = None
def setUp(self, conf, _requests=None, _begin_time=None): self.music = api.API() self.conf = cfg.CONF self.randomPick = RandomPick(self.conf)
def setUp(self): # Initialize music API music = api.API() cfg.CONF.set_override('keyspace', 'conductor') music.keyspace_create(keyspace=cfg.CONF.keyspace) self.order_lock_svc = OrdersLockingService()