本文整理汇总了Python中nailgun.openstack.common.jsonutils.loads函数的典型用法代码示例。如果您正苦于以下问题:Python loads函数的具体用法?Python loads怎么用?Python loads使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了loads函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_deploy_neutron_error_not_enough_ip_addresses
def test_deploy_neutron_error_not_enough_ip_addresses(self, mocked_rpc):
self.env.create(
cluster_kwargs={'net_provider': 'neutron',
'net_segment_type': 'gre'},
nodes_kwargs=[{"pending_addition": True},
{"pending_addition": True},
{"pending_addition": True}]
)
net_data = jsonutils.loads(
self.env.neutron_networks_get(self.env.clusters[0].id).body)
pub = filter(lambda ng: ng['name'] == 'public',
net_data['networks'])[0]
pub.update({'ip_ranges': [['172.16.0.10', '172.16.0.11']]})
resp = self.env.neutron_networks_put(self.env.clusters[0].id, net_data)
self.assertEqual(resp.status_code, 202)
task = jsonutils.loads(resp.body)
self.assertEqual(task['status'], 'ready')
task = self.env.launch_deployment()
self.assertEqual(task.status, 'error')
self.assertEqual(
task.message,
'Not enough IP addresses. Public network must have at least '
'3 IP addresses for the current environment.')
开发者ID:iberezovskiy,项目名称:fuel-web,代码行数:27,代码来源:test_cluster_changes_handler.py
示例2: upgrade_releases
def upgrade_releases(connection):
select = text(
"""SELECT id, attributes_metadata, roles_metadata
from releases"""
)
update = text(
"""UPDATE releases
SET attributes_metadata = :attrs, roles_metadata = :roles,
wizard_metadata = :wiz_meta
WHERE id = :id"""
)
r = connection.execute(select)
# reading fixture files in loop is in general a bad idea and as long as
# wizard_metadata is the same for all existing releases getting it can
# be moved outside of the loop
wizard_meta = upgrade_release_wizard_metadata_50_to_51()
for release in r:
attrs_meta = upgrade_release_attributes_50_to_51(jsonutils.loads(release[1]))
roles_meta = upgrade_release_roles_50_to_51(jsonutils.loads(release[2]))
connection.execute(
update,
id=release[0],
attrs=jsonutils.dumps(attrs_meta),
roles=jsonutils.dumps(roles_meta),
wiz_meta=jsonutils.dumps(wizard_meta),
)
开发者ID:koder-ua,项目名称:nailgun-fcert,代码行数:27,代码来源:fuel_5_1.py
示例3: save_oldpass
def save_oldpass(self,oldclusterSetting,newcontent):
oldclusterSetting=jsonutils.loads(oldclusterSetting["cluster_setting"])
settingcontent={}
settingcontent['cluster_setting']=jsonutils.loads(newcontent)
settingcontent["cluster_setting"]["mysql"]["root_password"]=oldclusterSetting["mysql"]["root_password"]
settingcontent["cluster_setting"]["rabbitmq"]["rabbit_password"]=oldclusterSetting["rabbitmq"]["rabbit_password"]
settingcontent["cluster_setting"]["mongodb"]["mongo_password"]=oldclusterSetting["mongodb"]["mongo_password"]
settingcontent["cluster_setting"]["keystone"]["keystone_mysql_password"]=oldclusterSetting["keystone"]["keystone_mysql_password"]
settingcontent["cluster_setting"]["glance"]["glance_mysql_password"]=oldclusterSetting["glance"]["glance_mysql_password"]
settingcontent["cluster_setting"]["nova-api"]["nova_mysql_password"]=oldclusterSetting["nova-api"]["nova_mysql_password"]
settingcontent["cluster_setting"]["nova-api"]["metadata_secret"]=oldclusterSetting["nova-api"]["metadata_secret"]
settingcontent["cluster_setting"]["neutron-server"]["neutron_mysql_password"]=oldclusterSetting["neutron-server"]["neutron_mysql_password"]
settingcontent["cluster_setting"]["cinder-api"]["cinder_mysql_password"]=oldclusterSetting["cinder-api"]["cinder_mysql_password"]
settingcontent["cluster_setting"]["cinder-storage"]["cinder_mysql_password"]=oldclusterSetting["cinder-storage"]["cinder_mysql_password"]
settingcontent["cluster_setting"]["ceilometer"]["ceilometer_mongo_password"]=oldclusterSetting["ceilometer"]["ceilometer_mongo_password"]
settingcontent["cluster_setting"]["ceilometer"]["metadata_secret"]=oldclusterSetting["ceilometer"]["metadata_secret"]
settingcontent["cluster_setting"]["heat"]["heat_mysql_password"]=oldclusterSetting["heat"]["heat_mysql_password"]
settingcontent["cluster_setting"]["global"]["keystone_admin_password"]=oldclusterSetting["global"]["keystone_admin_password"]
settingcontent["cluster_setting"]["global"]["keystone_glance_password"]=oldclusterSetting["global"]["keystone_glance_password"]
settingcontent["cluster_setting"]["global"]["keystone_nova_password"]=oldclusterSetting["global"]["keystone_nova_password"]
settingcontent["cluster_setting"]["global"]["keystone_neutron_password"]=oldclusterSetting["global"]["keystone_neutron_password"]
settingcontent["cluster_setting"]["global"]["keystone_ceilometer_password"]=oldclusterSetting["global"]["keystone_ceilometer_password"]
settingcontent["cluster_setting"]["global"]["keystone_heat_password"]=oldclusterSetting["global"]["keystone_heat_password"]
settingcontent["cluster_setting"]["global"]["keystone_cinder_password"]=oldclusterSetting["global"]["keystone_cinder_password"]
settingcontent["cluster_setting"]["global"]["admin_token"]=oldclusterSetting["global"]["admin_token"]
settingcontent["cluster_setting"]["global"]["keystone_dbpass"]=oldclusterSetting["global"]["keystone_dbpass"]
settingcontent["cluster_setting"]["global"]["glance_dbpass"]=oldclusterSetting["global"]["glance_dbpass"]
settingcontent["cluster_setting"]["global"]["nova_dbpass"]=oldclusterSetting["global"]["nova_dbpass"]
settingcontent["cluster_setting"]["global"]["neutron_dbpass"]=oldclusterSetting["global"]["neutron_dbpass"]
settingcontent["cluster_setting"]["global"]["cinder_dbpass"]=oldclusterSetting["global"]["cinder_dbpass"]
settingcontent["cluster_setting"]["global"]["ceilometer_dbpass"]=oldclusterSetting["global"]["ceilometer_dbpass"]
settingcontent["cluster_setting"]["global"]["heat_dbpass"]=oldclusterSetting["global"]["heat_dbpass"]
settingcontent["cluster_setting"]["haproxy-keepalived"]["virtual_router_id"] = oldclusterSetting["haproxy-keepalived"]["virtual_router_id"]
settingcontent["cluster_setting"]["haproxy-keepalived"]["auth_pass"] = oldclusterSetting["haproxy-keepalived"]["auth_pass"]
return jsonutils.dumps(settingcontent['cluster_setting'])
开发者ID:yxh1990,项目名称:fuel-cloudmaster,代码行数:35,代码来源:cluster_setting.py
示例4: test_roles_add_duplicated_to_db_directly
def test_roles_add_duplicated_to_db_directly(self):
self.env.create_release()
resp = self.app.get(
reverse('ReleaseCollectionHandler'),
headers=self.default_headers
)
release_json = jsonutils.loads(resp.body)[0]
old_roles = list(release_json["roles"])
role = Role(name=old_roles[0],
release_id=release_json["id"])
added = True
try:
self.db.add(role)
self.db.commit()
except IntegrityError:
self.db.rollback()
added = False
self.assertFalse(added)
resp = self.app.get(
reverse('ReleaseCollectionHandler'),
headers=self.default_headers
)
release_json = jsonutils.loads(resp.body)[0]
new_roles = list(release_json["roles"])
self.assertEqual(old_roles, new_roles)
开发者ID:Axam,项目名称:nsx-web,代码行数:27,代码来源:test_roles.py
示例5: test_put_handler_with_one_node
def test_put_handler_with_one_node(self):
cluster = self.env.create_cluster(api=True)
mac = self.env.generate_random_mac()
meta = {}
self.env.set_interfaces_in_meta(meta, [
{'name': 'eth0', 'mac': mac},
{'name': 'eth1', 'mac': self.env.generate_random_mac()}])
node = self.env.create_node(api=True, meta=meta, mac=mac,
cluster_id=cluster['id'])
resp = self.app.get(
reverse('NodeNICsHandler', kwargs={'node_id': node['id']}),
headers=self.default_headers)
self.assertEqual(resp.status_code, 200)
response = jsonutils.loads(resp.body)
a_nets = filter(lambda nic: nic['mac'] == mac,
response)[0]['assigned_networks']
for resp_nic in response:
if resp_nic['mac'] == mac:
resp_nic['assigned_networks'] = []
else:
resp_nic['assigned_networks'].extend(a_nets)
resp_nic['assigned_networks'].sort()
nodes_list = [{'id': node['id'], 'interfaces': response}]
resp = self.app.put(
reverse('NodeCollectionNICsHandler'),
jsonutils.dumps(nodes_list),
headers=self.default_headers)
self.assertEqual(resp.status_code, 200)
new_response = jsonutils.loads(resp.body)
self.assertEqual(new_response, nodes_list)
开发者ID:romcheg,项目名称:fuel-web,代码行数:32,代码来源:test_node_nic_collection_handler.py
示例6: test_deploy_neutron_gre_w_changed_public_cidr
def test_deploy_neutron_gre_w_changed_public_cidr(self, mocked_rpc):
self.env.create(
cluster_kwargs={'net_provider': 'neutron',
'net_segment_type': 'gre'},
nodes_kwargs=[{"pending_addition": True},
{"pending_addition": True}]
)
net_data = jsonutils.loads(
self.env.neutron_networks_get(self.env.clusters[0].id).body)
pub = filter(lambda ng: ng['name'] == 'public',
net_data['networks'])[0]
pub.update({'ip_ranges': [['172.16.10.10', '172.16.10.122']],
'cidr': '172.16.10.0/24',
'gateway': '172.16.10.1'})
net_data['networking_parameters']['floating_ranges'] = \
[['172.16.10.130', '172.16.10.254']]
resp = self.env.neutron_networks_put(self.env.clusters[0].id, net_data)
self.assertEqual(resp.status_code, 202)
task = jsonutils.loads(resp.body)
self.assertEqual(task['status'], 'ready')
self.env.launch_deployment()
args, kwargs = nailgun.task.manager.rpc.cast.call_args
self.assertEqual(len(args), 2)
self.assertEqual(len(args[1]), 2)
n_rpc_deploy = args[1][1]['args']['deployment_info']
self.assertEqual(len(n_rpc_deploy), 2)
pub_ips = ['172.16.10.11', '172.16.10.12']
for n in n_rpc_deploy:
for i, n_common_args in enumerate(n['nodes']):
self.assertEqual(n_common_args['public_address'], pub_ips[i])
开发者ID:iberezovskiy,项目名称:fuel-web,代码行数:35,代码来源:test_cluster_changes_handler.py
示例7: test_verify_networks
def test_verify_networks(self, mocked_rpc):
cluster = self.env.create_cluster(api=True)
nets = jsonutils.loads(self.env.nova_networks_get(cluster['id']).body)
resp = self.env.nova_networks_put(cluster['id'], nets)
self.assertEqual(202, resp.status_code)
task = jsonutils.loads(resp.body)
self.assertEqual(task['status'], 'ready')
开发者ID:Axam,项目名称:nsx-web,代码行数:8,代码来源:test_cluster_collection_handlers.py
示例8: test_netconfig_error_when_admin_cidr_match_other_network_cidr
def test_netconfig_error_when_admin_cidr_match_other_network_cidr(self):
resp = self.env.nova_networks_get(self.cluster['id'])
nets = jsonutils.loads(resp.body)
resp = self.env.nova_networks_put(self.cluster['id'], nets,
expect_errors=True)
self.assertEqual(resp.status_code, 202)
task = jsonutils.loads(resp.body)
self.assertEqual(task['status'], 'error')
self.assertEqual(task['progress'], 100)
self.assertEqual(task['name'], 'check_networks')
self.assertIn("Address space intersection between networks:\n"
"admin (PXE), management.",
task['message'])
开发者ID:Axam,项目名称:nsx-web,代码行数:13,代码来源:test_network_configuration.py
示例9: test_do_not_update_net_segmentation_type
def test_do_not_update_net_segmentation_type(self):
resp = self.env.neutron_networks_get(self.cluster.id)
data = jsonutils.loads(resp.body)
data['networking_parameters']['segmentation_type'] = 'vlan'
resp = self.env.neutron_networks_put(self.cluster.id, data,
expect_errors=True)
self.assertEqual(202, resp.status_code)
task = jsonutils.loads(resp.body)
self.assertEqual(task['status'], 'error')
self.assertEqual(
task['message'],
"Change of 'segmentation_type' is prohibited"
)
开发者ID:Axam,项目名称:nsx-web,代码行数:14,代码来源:test_network_configuration.py
示例10: test_multiline_log_entry
def test_multiline_log_entry(self):
settings.LOGS[0]['multiline'] = True
log_entries = [
[
time.strftime(settings.UI_LOG_DATE_FORMAT),
'LEVEL111',
'text1',
],
[
time.strftime(settings.UI_LOG_DATE_FORMAT),
'LEVEL222',
'text\nmulti\nline',
],
[
time.strftime(settings.UI_LOG_DATE_FORMAT),
'LEVEL333',
'text3',
],
]
self.env.create_cluster(api=False)
self._create_logfile_for_node(settings.LOGS[0], log_entries)
resp = self.app.get(
reverse('LogEntryCollectionHandler'),
params={'source': settings.LOGS[0]['id']},
headers=self.default_headers
)
self.assertEqual(200, resp.status_code)
response = jsonutils.loads(resp.body)
response['entries'].reverse()
self.assertEqual(response['entries'], log_entries)
settings.LOGS[0]['multiline'] = False
开发者ID:iberezovskiy,项目名称:fuel-web,代码行数:32,代码来源:test_logs_handlers.py
示例11: test_version_handler
def test_version_handler(self):
with nested(
patch(
'nailgun.api.v1.handlers.version.glob.glob',
Mock(return_value=["test.yaml"])
),
patch(
'__builtin__.open',
mock_open(read_data='test_data'),
create=True
)
):
resp = self.app.get(
reverse('VersionHandler'),
headers=self.default_headers
)
self.assertEqual(200, resp.status_code)
self.assertEqual(
jsonutils.loads(resp.body),
{
"release": "0.1b",
"nailgun_sha": "12345",
"astute_sha": "Unknown build",
"fuellib_sha": "Unknown build",
"ostf_sha": "Unknown build",
"auth_required": True,
"release_versions": {
"test": "test_data"
}
}
)
开发者ID:Axam,项目名称:nsx-web,代码行数:31,代码来源:test_version_handler.py
示例12: test_update
def test_update(self):
c = self.env.create_cluster(api=False)
n0 = self.env.create_notification()
n1 = self.env.create_notification(cluster_id=c.id)
notification_update = [
{
'id': n0.id,
'status': 'read'
},
{
'id': n1.id,
'status': 'read'
}
]
resp = self.app.put(
reverse('NotificationCollectionHandler'),
jsonutils.dumps(notification_update),
headers=self.default_headers
)
self.assertEqual(200, resp.status_code)
response = jsonutils.loads(resp.body)
self.assertEqual(len(response), 2)
if response[0]['id'] == n0.id:
rn0 = response[0]
rn1 = response[1]
else:
rn0 = response[1]
rn1 = response[0]
self.assertEqual(rn1['cluster'], n1.cluster_id)
self.assertEqual(rn1['status'], 'read')
self.assertIsNone(rn0.get('cluster', None))
self.assertEqual(rn0['status'], 'read')
开发者ID:Axam,项目名称:nsx-web,代码行数:32,代码来源:test_notification_collection_handler.py
示例13: test_network_changing_adds_pending_changes
def test_network_changing_adds_pending_changes(self):
cluster = self.env.create_cluster(api=True)
cluster_db = self.env.clusters[0]
objects.Cluster.clear_pending_changes(cluster_db)
all_changes = self.db.query(ClusterChanges).all()
self.assertEqual(len(all_changes), 0)
resp = self.app.get(
reverse(
'NovaNetworkConfigurationHandler',
kwargs={'cluster_id': cluster['id']}),
headers=self.default_headers
)
net_id = jsonutils.loads(resp.body)['networks'][0]["id"]
resp = self.app.put(
reverse(
'NovaNetworkConfigurationHandler',
kwargs={'cluster_id': cluster['id']}),
jsonutils.dumps({'networks': [{
"id": net_id, "access": "restricted"}
]}),
headers=self.default_headers
)
pending_changes = self.db.query(ClusterChanges).filter_by(
name="networks"
).all()
self.assertEqual(len(pending_changes), 1)
开发者ID:Axam,项目名称:nsx-web,代码行数:26,代码来源:test_changes_model.py
示例14: test_get_handler_with_invalid_speed_data
def test_get_handler_with_invalid_speed_data(self):
meta = self.env.default_metadata()
meta["interfaces"] = []
node = self.env.create_node(api=True, meta=meta)
meta_clean_list = [
{"interfaces": [{"name": "eth0", "mac": "00:00:00", "max_speed": -100}]},
{"interfaces": [{"name": "eth0", "mac": "00:00:00", "current_speed": -100}]},
{"interfaces": [{"name": "eth0", "mac": "00:00:00", "current_speed": "100"}]},
{"interfaces": [{"name": "eth0", "mac": "00:00:00", "max_speed": 10.0}]},
{"interfaces": [{"name": "eth0", "mac": "00:00:00", "max_speed": "100"}]},
{"interfaces": [{"name": "eth0", "mac": "00:00:00", "current_speed": 10.0}]},
]
for nic_meta in meta_clean_list:
meta = self.env.default_metadata()
meta.update(nic_meta)
node_data = {"mac": node["mac"], "meta": meta}
resp = self.app.put(
reverse("NodeAgentHandler"),
jsonutils.dumps(node_data),
expect_errors=True,
headers=self.default_headers,
)
self.assertEqual(resp.status_code, 200)
resp = self.app.get(reverse("NodeHandler", kwargs={"obj_id": node["id"]}), headers=self.default_headers)
ifaces = jsonutils.loads(resp.body)["meta"]["interfaces"]
self.assertEqual(ifaces, [{"name": "eth0", "mac": "00:00:00", "max_speed": None, "current_speed": None}])
开发者ID:koder-ua,项目名称:nailgun-fcert,代码行数:27,代码来源:test_node_nic_handler.py
示例15: _get_cluster_networks
def _get_cluster_networks(self, cluster_id):
nets = jsonutils.loads(self.app.get(
reverse('NovaNetworkConfigurationHandler',
{"cluster_id": cluster_id}),
headers=self.default_headers,
).body)["networks"]
return nets
开发者ID:Axam,项目名称:nsx-web,代码行数:7,代码来源:test_cluster_collection_handlers.py
示例16: test_network_verify_fails_if_untagged_intersection
def test_network_verify_fails_if_untagged_intersection(self, mocked_rpc):
resp = self.app.get(
reverse(
'NovaNetworkConfigurationHandler',
kwargs={'cluster_id': self.env.clusters[0].id}
),
headers=self.default_headers
)
self.assertEqual(200, resp.status_code)
nets = jsonutils.loads(resp.body)
for net in nets['networks']:
if net['name'] in ('storage',):
net['vlan_start'] = None
task = self.env.launch_verify_networks(nets)
self.env.wait_error(task, 30)
self.assertIn(
'Some untagged networks are assigned to the same physical '
'interface. You should assign them to different physical '
'interfaces. Affected:\n',
task.message
)
for n in self.env.nodes:
self.assertIn('"storage"', task.message)
self.assertEqual(mocked_rpc.called, False)
开发者ID:mrKisaoLamb,项目名称:fuel-web,代码行数:27,代码来源:test_verify_networks_task_manager.py
示例17: test_network_verification_neutron_with_vlan_segmentation
def test_network_verification_neutron_with_vlan_segmentation(
self, mocked_rpc):
# get Neutron L2 VLAN ID range
vlan_rng_be = self.env.clusters[0].network_config.vlan_range
vlan_rng = set(range(vlan_rng_be[0], vlan_rng_be[1] + 1))
# get nodes NICs for private network
resp = self.app.get(reverse('NodeCollectionHandler'),
headers=self.default_headers)
self.assertEqual(200, resp.status_code)
priv_nics = {}
for node in jsonutils.loads(resp.body):
for net in node['network_data']:
if net['name'] == 'private':
priv_nics[node['id']] = net['dev']
break
# check private VLAN range for nodes in Verify parameters
task = self.env.launch_verify_networks()
self.assertEqual(task.status, 'running')
for node in task.cache['args']['nodes']:
for net in node['networks']:
if net['iface'] == priv_nics[node['uid']]:
self.assertTrue(vlan_rng <= set(net['vlans']))
break
开发者ID:mrKisaoLamb,项目名称:fuel-web,代码行数:25,代码来源:test_verify_networks_task_manager.py
示例18: test_network_assignment_when_node_added
def test_network_assignment_when_node_added(self):
cluster = self.env.create_cluster(api=True)
mac = self.env.generate_random_mac()
meta = self.env.default_metadata()
self.env.set_interfaces_in_meta(
meta, [{"name": "eth0", "mac": mac}, {"name": "eth1", "mac": self.env.generate_random_mac()}]
)
node = self.env.create_node(api=True, meta=meta, mac=mac)
resp = self.app.put(
reverse("NodeCollectionHandler"),
jsonutils.dumps([{"id": node["id"], "cluster_id": cluster["id"]}]),
headers=self.default_headers,
)
self.assertEqual(resp.status_code, 200)
resp = self.app.get(reverse("NodeNICsHandler", kwargs={"node_id": node["id"]}), headers=self.default_headers)
self.assertEqual(resp.status_code, 200)
response = jsonutils.loads(resp.body)
for resp_nic in response:
net_names = [net["name"] for net in resp_nic["assigned_networks"]]
if resp_nic["mac"] == mac:
self.assertTrue("fuelweb_admin" in net_names)
else:
self.assertTrue("public" in net_names)
self.assertGreater(len(resp_nic["assigned_networks"]), 0)
开发者ID:koder-ua,项目名称:nailgun-fcert,代码行数:25,代码来源:test_node_nic_assignment.py
示例19: test_discovered_node_unified_name
def test_discovered_node_unified_name(self):
node_mac = self.env.generate_random_mac()
def node_name_test(mac):
self.env.create_node(
api=True,
**{'mac': mac}
)
node = jsonutils.loads(
self.app.get(reverse('NodeCollectionHandler')).body
)[0]
self.assertEqual(node['name'],
'Untitled ({0})'.format(node_mac[-5:]))
node_name_test(node_mac.upper())
node_id = jsonutils.loads(
self.app.get(reverse('NodeCollectionHandler')).body
)[0]['id']
self.app.delete(
reverse('NodeHandler', {'obj_id': node_id})
)
node_name_test(node_mac.lower())
开发者ID:Axam,项目名称:nsx-web,代码行数:26,代码来源:test_node_collection_handlers.py
示例20: get
def get(self, node_id):
resp = self.app.get(
reverse('NodeDisksHandler', kwargs={'node_id': node_id}),
headers=self.default_headers)
self.assertEqual(200, resp.status_code)
return jsonutils.loads(resp.body)
开发者ID:igajsin,项目名称:fuel-web,代码行数:7,代码来源:test_node_disks.py
注:本文中的nailgun.openstack.common.jsonutils.loads函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论