本文整理匯總了Python中gridapi.resources.models.GridEntity類的典型用法代碼示例。如果您正苦於以下問題:Python GridEntity類的具體用法?Python GridEntity怎麽用?Python GridEntity使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了GridEntity類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: post
def post(self, grid_name):
grid = GridEntity.select().where(
GridEntity.name == grid_name).get()
args = groupparsers[grid.provider].parse_args()
self._abort_if_grid_doesnt_exist(grid_name)
self._abort_if_config_doesnt_exist(grid_name)
self._abort_if_deployment_doesnt_exist(grid_name)
grid = GridEntity.select().where(
GridEntity.name == grid_name).get()
if not groups[grid.provider].select().where(
groups[grid.provider].name == args['name'],
groups[grid.provider].parentgrid ==
grid).exists():
group = groups[grid.provider].create(
parentgrid=grid, name=args['name'])
group = groups[grid.provider].select().where(
groups[grid.provider].name == args['name'],
groups[grid.provider].parentgrid == grid).get()
if group.parentgrid.provider == 'custom':
slaves_args = [args['groupips']]
elif group.parentgrid.provider == 'openstack':
slaves_args = [args['slaves']]
else:
slaves_args = [args['cpus'], args['ram'], args['instance_type']]
group._slaves = self._slave_calculator[grid.provider](
self, *slaves_args)
for key in group._data.keys():
if key != 'id' and key != 'parentgrid' and key != '_slaves':
setattr(group, key, args[key])
group.save()
return ast.literal_eval(str(group)), 200
else:
return 'Group {} already exists'.format(args['name']), 409
示例2: post
def post(self):
args = grid_parser.parse_args()
if not GridEntity.select().where(
GridEntity.name == args['name']).exists():
grid = GridEntity.create(
name=args['name'].lower(),
provider=args['provider'],
type=args['type'])
grid.config = configs[grid.provider].create(
parentgrid=grid)
grid.deployment = deployments[grid.provider].create(
parentgrid=grid)
return ast.literal_eval(str(grid)), 200
else:
return 'Grid {} already exists'.format(args['name']), 409
示例3: __init__
def __init__(self, grid_name, api_user, api_pass, api_url, **kwargs):
self.grid_name = grid_name
self.api_user = urllib.unquote(api_user)
self.api_pass = urllib.unquote(api_pass)
self.api_url = urllib.unquote(api_url)
self.current_grid = GridEntity.select().where(GridEntity.name == grid_name).get()
self.current_config = (
configs[self.current_grid.provider]
.select()
.where(configs[self.current_grid.provider].parentgrid == self.current_grid)
.get()
)
self.private_key_text = urllib.unquote(self.current_config.sshkeydata)
self.private_key = RSA.importKey(self.private_key_text.strip())
self.public_key_text = self.private_key.publickey().exportKey("OpenSSH")
self.current_groups = []
if not os.path.exists("result/{}/infrastructure".format(grid_name)):
os.makedirs("result/{}/infrastructure".format(grid_name))
for group in groups[self.current_grid.provider].select():
if group.parentgrid.name == grid_name:
self.current_groups.append(group)
self.config = AutoDict()
self.networking = AutoDict()
self.security = AutoDict()
self.terminal = AutoDict()
self.masters = AutoDict()
示例4: put
def put(self, grid_name, group_name):
self._abort_if_grid_doesnt_exist(grid_name)
self._abort_if_config_doesnt_exist(grid_name)
self._abort_if_deployment_doesnt_exist(grid_name)
self._abort_if_group_doesnt_exist(grid_name, group_name)
grid = GridEntity.select().where(
GridEntity.name == grid_name).get()
group = groups[grid.provider].select().where(
groups[grid.provider].name == group_name,
groups[grid.provider].parentgrid == grid).get()
oldgroup = group
args = groupparsers[grid.provider].parse_args()
for key in group._data.keys():
if key != 'id' and key != 'parentgrid' and key != '_slaves':
setattr(group, key, args[key])
if group.parentgrid.provider == 'custom':
slaves_args = [args['groupips']]
elif group.parentgrid.provider == 'openstack':
slaves_args = [args['slaves']]
else:
slaves_args = [args['cpus'], args['ram'], args['instance_type']]
group._slaves = self._slave_calculator[grid.provider](
self, *slaves_args)
group.save()
if args['name'] != oldgroup.name:
deletegroup = groups[grid.provider].select().where(
groups[grid.provider].name == oldgroup.name,
groups[grid.provider].parentgrid == grid).get()
deletegroup.delete_instance()
return ast.literal_eval(str(group)), 200
示例5: get
def get(self, grid_name):
exportgroups = []
grid = GridEntity.select().where(
GridEntity.name == grid_name).get()
for group in groups[grid.provider].select():
if group.parentgrid.name == grid_name:
exportgroups.append({'name': group.name, 'role': group.role})
return exportgroups
示例6: get
def get(self, grid_name):
self._abort_if_grid_doesnt_exist(grid_name)
self._abort_if_config_doesnt_exist(grid_name)
grid = GridEntity.select().where(
GridEntity.name == grid_name).get()
config = configs[grid.provider].select().where(
configs[grid.provider].parentgrid == grid).get()
return ast.literal_eval(str(config)), 200
示例7: _abort_if_provision_deployment_doesnt_exist
def _abort_if_provision_deployment_doesnt_exist(self, grid_name):
grid = GridEntity.select().where(
GridEntity.name == grid_name).get()
if not provision_deployments[grid.provider].select().where(
provision_deployments[grid.provider
].parentgrid == grid).exists():
abort(404, message="Provision Deployment of grid {} "
"doesn't exist".format(grid_name))
示例8: _abort_if_group_doesnt_exist
def _abort_if_group_doesnt_exist(self, grid_name, group_name):
grid = GridEntity.select().where(
GridEntity.name == grid_name).get()
if not groups[grid.provider].select().where(
groups[grid.provider].name == group_name,
groups[grid.provider].parentgrid ==
grid).exists():
abort(404, message="Group {} doesn't exist".format(group_name))
示例9: __init__
def __init__(self, grid_name, *args, **kwargs):
self.grid_name = grid_name
self.current_grid = GridEntity.select().where(
GridEntity.name == grid_name).get()
self.current_config =\
configs[self.current_grid.provider].select().where(
configs[self.current_grid.provider].parentgrid ==
self.current_grid).get()
示例10: _abort_if_config_doesnt_exist
def _abort_if_config_doesnt_exist(self, grid_name):
grid = GridEntity.select().where(
GridEntity.name == grid_name).get()
if not configs[grid.provider].select().where(
configs[grid.provider].parentgrid ==
grid).exists():
abort(404, message="Config of grid {} doesn't exist".format(
grid_name))
示例11: delete
def delete(self, grid_name):
self._abort_if_grid_doesnt_exist(grid_name)
self._abort_if_config_doesnt_exist(grid_name)
grid = GridEntity.select().where(
GridEntity.name == grid_name).get()
config = configs[grid.provider].select().where(
configs[grid.provider].parentgrid == grid).get()
config.delete_instance()
return '', 200
示例12: _abort_if_infrastructure_deployment_was_not_successful
def _abort_if_infrastructure_deployment_was_not_successful(
self, grid_name):
grid = GridEntity.select().where(
GridEntity.name == grid_name).get()
infrastructure_deployment = infrastructure_deployments[
grid.provider].select().where(
infrastructure_deployments[
grid.provider].parentgrid == grid).get()
if infrastructure_deployment._status != 'deployed':
abort(404, message="Infrastructure Deployment of grid need to"
" be successful first".format(grid_name))
示例13: get
def get(self, grid_name):
self._abort_if_grid_doesnt_exist(grid_name)
self._abort_if_config_doesnt_exist(grid_name)
self._abort_if_provision_deployment_doesnt_exist(grid_name)
grid = GridEntity.select().where(
GridEntity.name == grid_name).get()
provision_deployment = provision_deployments[
grid.provider].select().where(
provision_deployments[
grid.provider].parentgrid == grid).get()
return ast.literal_eval(str(provision_deployment)), 200
示例14: __init__
def __init__(self, grid_name, **kwargs):
self.grid_name = grid_name
self.kwargs = kwargs
self.current_grid = GridEntity.select().where(GridEntity.name == grid_name).get()
self.current_config = configs[self.current_grid.provider].select().where(configs[self.current_grid.provider].parentgrid == self.current_grid).get()
self.current_groups = []
self.current_roles = []
for group in groups[self.current_grid.provider].select():
if group.parentgrid.name == grid_name:
self.current_groups.append(group)
self.current_roles.append(group.role)
示例15: __init__
def __init__(self, grid_name, aws_access_key_id, aws_secret_access_key, **kwargs):
self.aws_access_key_id = urllib.unquote(aws_access_key_id)
self.aws_secret_access_key = urllib.unquote(aws_secret_access_key)
self.grid_name = grid_name
self.kwargs = kwargs
self.current_grid = GridEntity.select().where(GridEntity.name == grid_name).get()
self.current_config = configs[self.current_grid.provider].select().where(configs[self.current_grid.provider].parentgrid == self.current_grid).get()
self.current_groups = []
self.current_roles = []
for group in groups[self.current_grid.provider].select():
if group.parentgrid.name == grid_name:
self.current_groups.append(group)
self.current_roles.append(group.role)