本文整理汇总了Python中nailgun.network.manager.NetworkManager类的典型用法代码示例。如果您正苦于以下问题:Python NetworkManager类的具体用法?Python NetworkManager怎么用?Python NetworkManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了NetworkManager类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: prepare_for_provisioning
def prepare_for_provisioning(cls, nodes):
"""Prepare environment for provisioning,
update fqdns, assign admin IPs
"""
cls.update_slave_nodes_fqdn(nodes)
for node in nodes:
NetworkManager.assign_admin_ips(node.id)
开发者ID:stamak,项目名称:fuel-web,代码行数:7,代码来源:helpers.py
示例2: serialize_for_cluster
def serialize_for_cluster(cls, cluster):
result = {}
result['net_manager'] = cluster.net_manager
result['networks'] = map(
cls.serialize_network_group,
cluster.network_groups
)
net_manager = NetworkManager()
result['networks'].append(
cls.serialize_network_group(
net_manager.get_admin_network_group()
)
)
if cluster.dns_nameservers:
result['dns_nameservers'] = {
"nameservers": cluster.dns_nameservers
}
if cluster.is_ha_mode:
nw_metadata = cluster.release.networks_metadata["nova_network"]
for network in nw_metadata["networks"]:
if network.get("assign_vip") is not False:
result['{0}_vip'.format(
network["name"]
)] = net_manager.assign_vip(
cluster.id,
network["name"]
)
return result
开发者ID:andrey-borisov,项目名称:fuel-web,代码行数:30,代码来源:network_configuration.py
示例3: get_common_attrs
def get_common_attrs(cls, cluster):
"""Common attributes for all facts
"""
common_attrs = super(
NovaOrchestratorHASerializer,
cls
).get_common_attrs(cluster)
netmanager = NetworkManager()
common_attrs['management_vip'] = netmanager.assign_vip(
cluster.id, 'management')
common_attrs['public_vip'] = netmanager.assign_vip(
cluster.id, 'public')
sorted_nodes = sorted(
common_attrs['nodes'], key=lambda node: int(node['uid']))
controller_nodes = cls.filter_by_roles(
sorted_nodes, ['controller', 'primary-controller'])
common_attrs['last_controller'] = controller_nodes[-1]['name']
# Assign primary controller in nodes list
cls.set_primary_controller(common_attrs['nodes'])
common_attrs['mp'] = [
{'point': '1', 'weight': '1'},
{'point': '2', 'weight': '2'}]
return common_attrs
开发者ID:andrey-borisov,项目名称:fuel-web,代码行数:29,代码来源:deployment_serializers.py
示例4: update
def update(cls, cluster, network_configuration):
from nailgun.network.manager import NetworkManager
network_manager = NetworkManager()
if 'net_manager' in network_configuration:
setattr(
cluster,
'net_manager',
network_configuration['net_manager'])
if 'networks' in network_configuration:
for ng in network_configuration['networks']:
ng_db = orm().query(NetworkGroup).get(ng['id'])
for key, value in ng.iteritems():
if key == "ip_ranges":
# deleting old ip ranges
map(
orm().delete,
orm().query(IPAddrRange).filter_by(
network_group_id=ng['id']
)
)
for r in value:
new_ip_range = IPAddrRange(
first=r[0],
last=r[1],
network_group_id=ng['id']
)
orm().add(new_ip_range)
orm().commit()
else:
setattr(ng_db, key, value)
network_manager.create_networks(ng_db)
ng_db.cluster.add_pending_changes('networks')
开发者ID:akolinko,项目名称:product,代码行数:35,代码来源:models.py
示例5: get_default
def get_default(self, node):
nics = []
network_manager = NetworkManager()
for nic in node.interfaces:
nic_dict = {
"id": nic.id,
"name": nic.name,
"mac": nic.mac,
"max_speed": nic.max_speed,
"current_speed": nic.current_speed
}
assigned_ng_ids = network_manager.get_default_nic_networkgroups(
node.id,
nic.id
)
for ng_id in assigned_ng_ids:
ng = db().query(NetworkGroup).get(ng_id)
nic_dict.setdefault("assigned_networks", []).append(
{"id": ng_id, "name": ng.name}
)
allowed_ng_ids = network_manager.get_allowed_nic_networkgroups(
node.id,
nic.id
)
for ng_id in allowed_ng_ids:
ng = db().query(NetworkGroup).get(ng_id)
nic_dict.setdefault("allowed_networks", []).append(
{"id": ng_id, "name": ng.name}
)
nics.append(nic_dict)
return nics
开发者ID:99cloud-net,项目名称:fuelweb,代码行数:34,代码来源:node.py
示例6: render
def render(cls, instance, fields=None):
json_data = JSONHandler.render(instance, fields=cls.fields)
network_manager = NetworkManager()
json_data['network_data'] = network_manager.get_node_networks(
instance.id
)
return json_data
开发者ID:akolinko,项目名称:product,代码行数:7,代码来源:node.py
示例7: update
def update(cls, cluster, network_configuration):
from nailgun.network.manager import NetworkManager
network_manager = NetworkManager()
if 'net_manager' in network_configuration:
setattr(
cluster,
'net_manager',
network_configuration['net_manager'])
if 'networks' in network_configuration:
for ng in network_configuration['networks']:
ng_db = db().query(NetworkGroup).get(ng['id'])
for key, value in ng.iteritems():
if key == "ip_ranges":
cls.__set_ip_ranges(ng['id'], value)
else:
if key == 'cidr' and \
not ng['name'] in ('public', 'floating'):
network_manager.update_ranges_from_cidr(
ng_db, value)
setattr(ng_db, key, value)
network_manager.create_networks(ng_db)
ng_db.cluster.add_pending_changes('networks')
开发者ID:99cloud-net,项目名称:fuelweb,代码行数:26,代码来源:models.py
示例8: get_common_attrs
def get_common_attrs(cls, cluster):
"""Common attributes for all facts
"""
common_attrs = super(OrchestratorHASerializer, cls).get_common_attrs(
cluster)
netmanager = NetworkManager()
common_attrs['management_vip'] = netmanager.assign_vip(
cluster.id, 'management')
common_attrs['public_vip'] = netmanager.assign_vip(
cluster.id, 'public')
common_attrs['last_controller'] = sorted(
common_attrs['controller_nodes'],
key=lambda node: node['uid'])[-1]['name']
first_controller = filter(
lambda node: 'controller' in node['role'],
common_attrs['nodes'])[0]
first_controller['role'] = 'primary-controller'
common_attrs['mp'] = [
{'point': '1', 'weight': '1'},
{'point': '2', 'weight': '2'}]
common_attrs['mountpoints'] = '1 1\\n2 2\\n'
return common_attrs
开发者ID:monroid,项目名称:fuelweb,代码行数:29,代码来源:serializers.py
示例9: get_default
def get_default(self, node):
nics = []
network_manager = NetworkManager()
for nic in node.interfaces:
nic_dict = {
"id": nic.id,
"name": nic.name,
"mac": nic.mac,
"max_speed": nic.max_speed,
"current_speed": nic.current_speed
}
assigned_ngs = network_manager.get_default_nic_networkgroups(
node, nic)
for ng in assigned_ngs:
nic_dict.setdefault('assigned_networks', []).append(
{'id': ng.id, 'name': ng.name})
allowed_ngs = network_manager.get_allowed_nic_networkgroups(
node, nic)
for ng in allowed_ngs:
nic_dict.setdefault('allowed_networks', []).append(
{'id': ng.id, 'name': ng.name})
nics.append(nic_dict)
return nics
开发者ID:loles,项目名称:fuelweb,代码行数:28,代码来源:node.py
示例10: run
def run(self):
super(FakeDeletionThread, self).run()
receiver = NailgunReceiver
kwargs = {
'task_uuid': self.task_uuid,
'nodes': self.data['args']['nodes'],
'status': 'ready'
}
nodes_to_restore = self.data['args'].get('nodes_to_restore', [])
resp_method = getattr(receiver, self.respond_to)
resp_method(**kwargs)
for node_data in nodes_to_restore:
node = Node(**node_data)
# Offline node just deleted from db
# and could not recreated with status
# discover
if not node.online:
continue
node.status = 'discover'
db().add(node)
db().commit()
node.attributes = NodeAttributes(node_id=node.id)
node.attributes.volumes = node.volume_manager.gen_volumes_info()
NetworkManager.update_interfaces_info(node)
db().commit()
ram = round(node.meta.get('ram') or 0, 1)
cores = node.meta.get('cores') or 'unknown'
notifier.notify("discover",
"New node with %s CPU core(s) "
"and %s GB memory is discovered" %
(cores, ram), node_id=node.id)
开发者ID:e0ne,项目名称:fuel-web,代码行数:35,代码来源:fake.py
示例11: prepare_for_provisioning
def prepare_for_provisioning(self):
from nailgun.network.manager import NetworkManager
from nailgun.task.helpers import TaskHelper
netmanager = NetworkManager()
for node in TaskHelper.nodes_to_provision(self):
netmanager.assign_admin_ips(
node.id, len(node.meta.get('interfaces', [])))
开发者ID:mrasskazov,项目名称:fuelweb,代码行数:8,代码来源:models.py
示例12: prepare_for_provisioning
def prepare_for_provisioning(cls, nodes):
"""Prepare environment for provisioning,
update fqdns, assign admin ips
"""
cls.update_slave_nodes_fqdn(nodes)
for node in nodes:
NetworkManager.assign_admin_ips(
node.id, len(node.meta.get('interfaces', [])))
开发者ID:adanin,项目名称:fuel-web,代码行数:8,代码来源:helpers.py
示例13: prepare_for_provisioning
def prepare_for_provisioning(self):
from nailgun.network.manager import NetworkManager
from nailgun.task.helpers import TaskHelper
netmanager = NetworkManager()
nodes = TaskHelper.nodes_to_provision(self)
TaskHelper.update_slave_nodes_fqdn(nodes)
for node in nodes:
netmanager.assign_admin_ips(node.id, len(node.meta.get("interfaces", [])))
开发者ID:rsokolkov,项目名称:fuel-web,代码行数:9,代码来源:cluster.py
示例14: get_admin_ips
def get_admin_ips(cls, node):
netmanager = NetworkManager()
admin_net_id = netmanager.get_admin_network_id()
admin_ips = set([
i.ip_addr for i in db().query(IPAddr).
filter_by(node=node.id).
filter_by(network=admin_net_id)])
return admin_ips
开发者ID:loles,项目名称:fuelweb,代码行数:9,代码来源:provisioning_serializers.py
示例15: __format_node_for_naily
def __format_node_for_naily(cls, n):
netmanager = NetworkManager()
return {
'id': n.id, 'status': n.status, 'error_type': n.error_type,
'uid': n.id, 'ip': n.ip, 'mac': n.mac, 'role': n.role,
'fqdn': n.fqdn, 'progress': n.progress, 'meta': n.meta,
'network_data': netmanager.get_node_networks(n.id),
'online': n.online
}
开发者ID:damjanek,项目名称:fuelweb,代码行数:9,代码来源:task.py
示例16: render
def render(cls, instance, fields=None):
json_data = None
try:
json_data = JSONHandler.render(instance, fields=cls.fields)
network_manager = NetworkManager()
json_data["network_data"] = network_manager.get_node_networks(instance.id)
except Exception:
logger.error(traceback.format_exc())
return json_data
开发者ID:rsokolkov,项目名称:fuel-web,代码行数:9,代码来源:node.py
示例17: serialize_for_cluster
def serialize_for_cluster(cls, cluster):
result = {}
result["net_manager"] = cluster.net_manager
result["networks"] = map(cls.serialize_network_group, cluster.network_groups)
if cluster.is_ha_mode:
net_manager = NetworkManager()
result["management_vip"] = net_manager.assign_vip(cluster.id, "management")
result["public_vip"] = net_manager.assign_vip(cluster.id, "public")
return result
开发者ID:rustyrobot,项目名称:fuelweb,代码行数:10,代码来源:network_configuration.py
示例18: remove_cluster_resp
def remove_cluster_resp(cls, **kwargs):
network_manager = NetworkManager()
logger.info(
"RPC method remove_cluster_resp received: %s" %
json.dumps(kwargs)
)
task_uuid = kwargs.get('task_uuid')
cls.remove_nodes_resp(**kwargs)
task = db().query(Task).filter_by(uuid=task_uuid).first()
cluster = task.cluster
if task.status in ('ready',):
logger.debug("Removing environment itself")
cluster_name = cluster.name
nws = itertools.chain(
*[n.networks for n in cluster.network_groups]
)
ips = db().query(IPAddr).filter(
IPAddr.network.in_([n.id for n in nws])
)
map(db().delete, ips)
db().commit()
db().delete(cluster)
db().commit()
# Dmitry's hack for clearing VLANs without networks
network_manager.clear_vlans()
notifier.notify(
"done",
u"Environment '%s' and all its nodes are deleted" % (
cluster_name
)
)
elif task.status in ('error',):
cluster.status = 'error'
db().add(cluster)
db().commit()
if not task.message:
task.message = "Failed to delete nodes:\n{0}".format(
cls._generate_error_message(
task,
error_types=('deletion',)
)
)
notifier.notify(
"error",
task.message,
cluster.id
)
开发者ID:aglarendil,项目名称:fuelweb,代码行数:55,代码来源:receiver.py
示例19: PUT
def PUT(self, cluster_id):
cluster = self.get_object_or_404(Cluster, cluster_id)
data = self.checked_data()
network_manager = NetworkManager()
for key, value in data.iteritems():
if key == "nodes":
# Todo: sepatate nodes for deletion and addition by set().
new_nodes = db().query(Node).filter(
Node.id.in_(value)
)
nodes_to_remove = [n for n in cluster.nodes
if n not in new_nodes]
nodes_to_add = [n for n in new_nodes
if n not in cluster.nodes]
for node in nodes_to_add:
if not node.online:
raise web.badrequest(
"Can not add offline node to cluster")
map(cluster.nodes.remove, nodes_to_remove)
map(cluster.nodes.append, nodes_to_add)
for node in nodes_to_remove:
network_manager.clear_assigned_networks(node.id)
network_manager.clear_all_allowed_networks(node.id)
for node in nodes_to_add:
network_manager.allow_network_assignment_to_all_interfaces(
node.id
)
network_manager.assign_networks_to_main_interface(node.id)
else:
setattr(cluster, key, value)
db().commit()
return self.render(cluster)
开发者ID:rakeshkk,项目名称:fuelweb,代码行数:33,代码来源:cluster.py
示例20: PUT
def PUT(self):
data = self.validator.validate_collection_structure(web.data())
network_manager = NetworkManager()
updated_nodes_ids = []
for node_data in data:
self.validator.verify_data_correctness(node_data)
node_id = network_manager._update_attrs(node_data)
updated_nodes_ids.append(node_id)
updated_nodes = db().query(Node).filter(
Node.id.in_(updated_nodes_ids)
).all()
return map(self.render, updated_nodes)
开发者ID:99cloud-net,项目名称:fuelweb,代码行数:12,代码来源:node.py
注:本文中的nailgun.network.manager.NetworkManager类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论