本文整理汇总了Python中helion_configurationprocessor.cp.model.CPLogging.CPLogging类的典型用法代码示例。如果您正苦于以下问题:Python CPLogging类的具体用法?Python CPLogging怎么用?Python CPLogging使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CPLogging类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: validate
def validate(self):
LOG.info("%s()" % KenLog.fcn())
version = float(self.version())
input = self._create_content(version, "servers")
schema_valid = self.validate_schema(input, "server")
if schema_valid:
servers = input.get("servers", [])
baremetal = {}
try:
baremetal = self._create_content(version, "baremetal")["baremetal"][0]
except TypeError:
try:
# baremetal_networks is still suppoted for backwards compatibility
baremetal = self._create_content(version, "baremetal_network")["baremetal_network"][0]
except TypeError:
# Possible to have servers with no baremetal section if not using
# cobbler to deploy
pass
nic_mappings = self._get_dict_from_config_value(version, "nic-mappings")
iface_models = self._get_dict_from_config_value(version, "interface-models")
server_roles = self._get_dict_from_config_value(version, "server-roles")
server_groups = self._get_dict_from_config_value(version, "server-groups")
if baremetal:
self._validate_baremetal_net(baremetal)
self._validate_unique_ids(servers)
self._validate_ip_addresses(servers)
self._validate_mac_addresses(servers)
self._validate_server_groups(servers, server_groups)
self._validate_net_devices(servers, nic_mappings, server_roles, iface_models)
LOG.info("%s()" % KenLog.fcn())
return self._valid
示例2: validate
def validate(self):
LOG.info('%s()' % KenLog.fcn())
version = float(self.version())
input = self._create_content(version, "pass-through")
if input:
return self.validate_schema(input, "pass_through")
LOG.info('%s()' % KenLog.fcn())
示例3: generate
def generate(self):
LOG.info('%s()' % KenLog.fcn())
self._action = KenLog.fcn()
cloud_internal = CloudModel.internal(self._models['CloudModel'])
control_planes = CloudModel.get(cloud_internal, 'control-planes', {})
# If we have an error in an earlier generator we may not have
# control_planes in the internal model
if not control_planes:
return
routes = {}
for cp_name, cp in control_planes.iteritems():
load_balancers = cp.get('load-balancers', {})
for cluster in cp['clusters']:
for server in cluster.get('servers', []):
self._add_routes_from_server(cp, server, load_balancers, routes)
for r_name, r in cp.get('resources', {}).iteritems():
for server in r.get('servers', []):
self._add_routes_from_server(cp, server, load_balancers, routes)
#
default_routes = {}
# Warn about any routes using the "default" route
for src_net, net_routes in routes.iteritems():
for dest_net, route_data in net_routes.iteritems():
if route_data['default']:
hosts = set()
if src_net not in default_routes:
default_routes[src_net] = []
for src, src_data in route_data['used_by'].iteritems():
for dest, host_list in src_data.iteritems():
for host in host_list:
hosts.add(host)
default_routes[src_net].append({'net': dest_net, 'hosts': hosts})
if default_routes:
msg = ("Default routing used between networks\n"
"The following networks are using a 'default' route rule. To remove this warning\n"
"either add an explict route in the source network group or force the network to\n"
"attach in the interface model used by the servers.\n")
for src in sorted(default_routes):
dest_list = default_routes[src]
for dest_data in dest_list:
msg += " %s to %s\n" % (src, dest_data['net'])
for host in sorted(dest_data['hosts']):
msg += " %s\n" % (host)
self.add_warning(msg)
CloudModel.put(cloud_internal, 'routes', routes)
示例4: _generate_ring_specifications_info
def _generate_ring_specifications_info(self):
LOG.info('%s()' % KenLog.fcn())
self._action = KenLog.fcn()
cloud_version = CloudModel.version(
self._models['CloudModel'], self._version)
ring_specifications_config = CloudModel.get(
cloud_version, 'ring-specifications', [])
cloud_internal = CloudModel.internal(self._models['CloudModel'])
CloudModel.put(cloud_internal,
'ring-specifications',
ring_specifications_config)
示例5: build
def build(self):
LOG.info('%s()' % KenLog.fcn())
cloud_name = CloudDescription.get_cloud_name(self.cloud_desc)
ntp_servers = CloudModel.get(self._cloud_internal, 'ntp_servers')
dns_settings = CloudModel.get(self._cloud_internal, 'dns_settings')
smtp_settings = CloudModel.get(self._cloud_internal, 'smtp_settings')
control_planes = CloudModel.get(self._cloud_internal, 'control-planes')
net_group_firewall = CloudModel.get(self._cloud_internal, 'net-group-firewall')
firewall_settings = CloudModel.get(self._cloud_internal, 'firewall_settings')
pass_through = CloudModel.get(self._cloud_internal, 'pass_through')
components = CloudModel.get(self._cloud_internal, 'components')
services = CloudModel.get(self._cloud_internal, 'services')
for cp_name, cp in control_planes.iteritems():
for cluster in cp['clusters']:
for s in cluster['servers']:
self._build_ansible_host_vars(cloud_name, s, cp['endpoints'],
cp, cluster['name'],
ntp_servers, dns_settings, smtp_settings,
pass_through, components, services,
net_group_firewall, firewall_settings)
for r_name, resources in cp.get('resources', {}).iteritems():
for s in resources['servers']:
self._build_ansible_host_vars(cloud_name, s, cp['endpoints'],
cp, resources['name'],
ntp_servers, dns_settings, smtp_settings,
pass_through, components, services,
net_group_firewall, firewall_settings)
CloudModel.put(self._cloud_internal, 'cloud-firewall', self._cloud_firewall)
示例6: _determine_height_for_cp_networks
def _determine_height_for_cp_networks(self, elem_cp):
LOG.info('%s()' % KenLog.fcn())
height = 0
interfaces = dict()
nt = elem_cp['network-topology']
for k, v in six.iteritems(nt):
(intf, vlan_tag) = self._get_interface_info(elem_cp['type'], k)
index = '%s-%s' % (intf, vlan_tag)
if index not in interfaces:
interfaces[index] = dict()
interfaces[index]['interface'] = intf
interfaces[index]['vlan-tag'] = vlan_tag
interfaces[index]['mnemonics'] = []
if k not in interfaces[index]['mnemonics']:
interfaces[index]['mnemonics'].append(k)
for k, v in six.iteritems(interfaces):
height += self._determine_height_for_cp_interface(v)
height += 1 # Separation
return height
示例7: build
def build(self):
LOG.info('%s()' % KenLog.fcn())
file_name = os.path.join(self._file_path, 'hosts.hf')
self.add_artifact(file_name, ArtifactMode.CREATED)
allocated_addresses = CloudModel.get(self._cloud_internal, 'address_allocations')
host_aliases = CloudModel.get(self._cloud_internal, 'host_aliases')
cloud_name = CloudDescription.get_cloud_name(self.cloud_desc)
with open(file_name, 'w') as fp:
fp.write("# Cloud: %s\n" % (cloud_name))
fp.write("\n")
fp.write("# Localhost Information\n")
fp.write("127.0.0.1 localhost\n")
fp.write("\n")
for group_name, group in allocated_addresses.iteritems():
fp.write("#\n")
fp.write("# Network Group: %s\n" % (group_name))
fp.write("#\n")
for network_name, network in group.iteritems():
fp.write("# Network: %s\n" % (network_name))
ips = []
for addr in network:
aliases = host_aliases.get(group_name,
{}).get(network_name,
{}).get(addr, [])
for name in aliases:
# Expand the address to a string with leading spaces
# in each quad so that it sorts by version
ips.append(["%3s.%3s.%3s.%3s" % tuple(addr.split(".")), name])
for ip in sorted(ips, key=itemgetter(0)):
fp.write("%-16s %s\n" % (ip[0].replace(" ", ""), ip[1]))
示例8: finalize
def finalize(self):
LOG.info('%s()' % KenLog.fcn())
allocated_addresses = CloudModel.get(self._cloud_internal,
'address_allocations', {})
host_aliases = CloudModel.get(self._cloud_internal, 'host_aliases', {})
address_data = {}
for group_name, group in allocated_addresses.iteritems():
if group_name not in address_data:
address_data[group_name] = {}
for network_name, network in group.iteritems():
if network_name not in address_data[group_name]:
address_data[group_name][network_name] = {}
for addr in sorted(network):
aliases = host_aliases.get(group_name, {}).get(
network_name, {}).get(addr, [])
address_data[group_name][network_name][addr] = []
for name in aliases:
address_data[group_name][network_name][addr].append(name)
filename = os.path.join(self._file_path, 'address_info.yml')
self.add_artifact(filename, ArtifactMode.CREATED)
with open(filename, 'w') as fp:
yaml.dump(address_data, fp, default_flow_style=False, indent=4)
示例9: _determine_size_for_control_plane
def _determine_size_for_control_plane(self, elem_cp):
LOG.info('%s(elem_cp="%s")' % (
KenLog.fcn(), ControlPlane.get_name(elem_cp)))
width = 0
height = self._padding_y
for elem_t in elem_cp['tiers']:
if not Tier.is_active_or_empty(elem_t):
continue
(t_w, t_h) = self._determine_size_for_tier(elem_cp, elem_t)
if t_w > width:
width = t_w
height += t_h
width += (self._padding_x * 2)
height += (self._padding_y * 2)
height += self._determine_height_for_resource_nodes(elem_cp)
height += self._determine_height_for_cp_networks(elem_cp)
return width, height
示例10: build
def build(self):
LOG.info('%s()' % KenLog.fcn())
servers = CloudModel.get(self._cloud_internal, 'servers')
server_info = {}
for server in servers:
server_info[server['id']] = {}
data = server_info[server['id']]
data['state'] = server['state']
if server['state'] == ServerState.ALLOCATED:
data['hostname'] = server['hostname']
data['failure-zone'] = server['failure-zone']
net_info = {}
for if_name, if_data in server['interfaces'].iteritems():
net_info[if_name] = {}
for net_name, net_data in if_data['networks'].iteritems():
net_info[if_name][net_name] = \
{'addr': net_data.get('addr'),
'vlan-id': net_data.get('vlanid'),
'tagged-vlan': net_data.get('tagged-vlan', True)}
data['net_data'] = net_info
filename = "%s/info/server_info.yml" % (
self._file_path)
if not os.path.exists(os.path.dirname(filename)):
os.makedirs(os.path.dirname(filename))
self.add_artifact(filename, ArtifactMode.CREATED)
with open(filename, 'w') as fp:
yaml.dump(server_info, fp, default_flow_style=False, indent=4)
示例11: validate
def validate(self):
LOG.info('%s()' % KenLog.fcn())
if 'encryption_key' in self._instructions:
path = self._instructions['cloud_input_path']
status, messages = CPSecurity.validate(
path, self._instructions['encryption_key'])
if not status:
message = 'The Encryption Key does not meet the following ' \
'requirement(s):\n# %s' % \
'\n# '.join(messages)
self.add_error(message)
return False
score, msg = CPSecurity.calculate_complexity(
self._instructions['encryption_key'])
print('\n\nThe encryption key has a complexity score of %d ('
'%s)\n\n' % (score, msg))
if ('previous_encryption_key' in self._instructions and
'encryption_key' in self._instructions):
if (self._instructions['encryption_key'] ==
self._instructions['previous_encryption_key']):
message = 'The New Encryption Key and the Previous ' \
'Encryption Key must be different.'
self.add_error(message)
return False
return True
示例12: __init__
def __init__(self, instructions, models, controllers):
super(RandomPasswordVariable, self).__init__(
2.0, instructions, models, controllers,
'random-password-2.0')
LOG.info('%s()' % KenLog.fcn())
random.seed()
示例13: checkpoint
def checkpoint(self):
LOG.info('%s()' % KenLog.fcn())
path = self._instructions['cloud_input_path']
cloud_name, nickname = CloudNameController.get_cloud_names(path)
self.prepare_filesystem(cloud_name, 'config')
return self._checkpoint()
示例14: _determine_height_for_cp_interface
def _determine_height_for_cp_interface(self, intf):
LOG.info('%s()' % KenLog.fcn())
height = self._padding_y
height += len(intf['mnemonics'])
height += self._padding_y
return height
示例15: validate
def validate(self):
LOG.info('%s()' % KenLog.fcn())
version = float(self.version())
input = self._create_content(version, 'ring-specifications')
if input:
return self.validate_schema(input, 'ring_specifications')
else:
return True