def execute(args): """ Creates volume """ openstack = OpenstackClient(auth_url=args.auth_url, username=args.username, password=args.password, project_id=args.project_id) volume_id = create_volume_helper(openstack, user_entered_cli_args=args) logging.info("Volume ID '{}' is being created".format(volume_id))
def main(): token = Token() client = OpenstackClient(session_auth=token.session_auth) packet_vms = check_vms(client) packet_volumes = check_volumes(client) packet.extend(packet_vms) packet.extend(packet_volumes) result = ZabbixSender(zserver, port, use_config=None).send(packet) return result
def execute(args): """ Creates image """ openstack = OpenstackClient(auth_url=args.auth_url, username=args.username, password=args.password, project_id=args.project_id) image = openstack.connection.images.find(name=args.image_name) image.delete()
def execute(args): """ Deletes an instance """ openstack = OpenstackClient(auth_url=args.auth_url, username=args.username, password=args.password, project_id=args.project_id) instances = get_all_instances(openstack, args.instance_name) delete(instances, args.instance_name)
def execute(args): """ Creates instance """ openstack = OpenstackClient(auth_url=args.auth_url, username=args.username, password=args.password, project_id=args.project_id) config = load_config(openstack, args.config_file) create_instance(openstack, config)
def main(): token = Token() client = OpenstackClient(session_auth=token.session_auth) servers = client.nova_api.servers.list(search_opts={'all_tenants':1}) total_vm_start = 0 total_vm_stop = 0 for server in servers: if server.status== 'ACTIVE': total_vm_start += 1 else: total_vm_stop += 1 if sys.argv[1] == 'runnning': print(total_vm_start) elif sys.argv[1] == 'shutoff': print(total_vm_stop)
def execute(args): """ Stops a running instance """ openstack = OpenstackClient(auth_url=args.auth_url, username=args.username, password=args.password, project_id=args.project_id) instance = get_instance(openstack, args.instance_name) if instance is None: logging.error("Unable to load instance " \ "'{}'".format(args.instance_name)) sys.exit(1) stop(instance, args.instance_name)
def check_status_service(session): """Lấy thông tin các agents của từng service Arguments: session {[object]} -- [session trong openstack] Returns: [type] -- [dict] """ token = Token() client = OpenstackClient(session_auth=token.session_auth) cinder_services = client.cinder_api.services.list() neutron_services = client.neutron_api.list_agents() nova_services = client.nova_api.services.list() return cinder_services, nova_services, neutron_services
def execute(args): """ Creates image """ openstack = OpenstackClient(auth_url=args.auth_url, username=args.username, password=args.password, project_id=args.project_id) instance = get_instance(openstack, args.instance_name) if instance is None: logging.error("Unable to load instance " \ "'{}'".format(args.instance_name)) sys.exit(1) else: instance.create_image(args.image_name)
def execute(args): """ Find volume and attach to an instance Note that as of the 12.0.0 Liberty release, the Nova libvirt driver no longer honors a user-supplied device name. This is the same behavior as if the device name parameter is not supplied on the request. """ openstack = OpenstackClient(auth_url=args.auth_url, username=args.username, password=args.password, project_id=args.project_id) instance = get_instance_by_name(openstack, args.instance_name) volume = get_volume_details(openstack, volume_name=args.volume_name, volume_id=args.volume_id) attach_volume_to_instance(openstack, instance, volume)
def __init__(self, session_auth): self.client = OpenstackClient(session_auth=session_auth)
def main(): token = Token() client = OpenstackClient(session_auth=token.session_auth) print(len(client.nova_api.servers.list(search_opts={'all_tenants':1})))